-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: missing high-level docs for x/cronos #183
Conversation
Codecov Report
@@ Coverage Diff @@
## main #183 +/- ##
==========================================
+ Coverage 21.51% 26.73% +5.21%
==========================================
Files 27 33 +6
Lines 1729 2338 +609
==========================================
+ Hits 372 625 +253
- Misses 1324 1666 +342
- Partials 33 47 +14
Continue to review full report at Codecov.
|
should we include @lezzokafka and @aw126 to do proofreading |
x/cronos/spec/01_concepts.md
Outdated
|
||
## Cronos | ||
|
||
Cronos is the name of Crypto.org EVM Chain, also the module that glue multiple components together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cronos is an EVM chain in Crypto.org ecosystem. It allows users to deploy and interact with smart contracts. Powered by Ethermint, it is built using cosmos SDK which allows to leverage to full capability of the cosmos ecosystem. It is also connected to the ethereum network with the gravity bridge integration (WIP).
Bridging asset from cosmos or ethereum are automatically converted to a CRC20 asset when moved to Cronos which make it extremely easy to integrate with existing web3 tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, added.
|
||
# State Transitions | ||
|
||
<!-- define state transitions for accounts and storage --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this should define the token mapping management / hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added sth about the CRUD of token mapping.
x/cronos/spec/01_concepts.md
Outdated
|
||
## Cronos | ||
|
||
Cronos is the name of Crypto.org EVM Chain, also the name of the main module that glues multiple components together for Cronos chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe briefly describe which components have been used in Cronos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
- When transferring CRO to Cronos chain, the decimal places of the amount are expanded to 18. | ||
- When transferring CRO from Cronos chain, the amount is truncated to 8 decimals, the remaining part is left in Cronos, so the total value is preserved. | ||
|
||
## Native Token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe introduce the Token
system prior to Gas Token
, move Gas Token
under this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or separate the token system to an independent spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By token system, do you mean the difference between cosmos native tokens and evm tokens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the native token you described after line 28. then move the gas token section (line 13) under Native token
- When a `TokenMappingChangeProposal` gov proposal is executed. | ||
- When the admin account execute a `MsgUpdateTokenMapping` message. | ||
|
||
There's no way to delete a token mapping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Highlight this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the token mapping part of the solidity contract or just in the store of the Cronos module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the storage of Cronos module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe Highlight this?
added a Delete
section for it.
x/cronos/spec/README.md
Outdated
order: 0 | ||
title: EVM Overview | ||
parent: | ||
title: "evm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the titles need to be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good 👍, I'd suggest running the text through some spell or grammar checking software (I skipped a few typos, as I guess it can be captured by https://github.com/tbroadley/spellchecker-cli grammarly etc.), but overall it's good.
two potentially good things to document are the expected upgrade behaviour + the expected Cosmos/Ethereum tooling usage, because I assume one needs to be careful there?
|
||
Cronos is an EVM chain in Crypto.org ecosystem. It allows users to deploy and interact with smart contracts. Powered by Ethermint, it is built using cosmos SDK which allows to leverage to full capability of the cosmos ecosystem. It is also connected to the ethereum network with the gravity bridge integration (WIP). | ||
|
||
Bridging asset from cosmos or ethereum are automatically converted to a CRC20 asset when moved to Cronos which make it extremely easy to integrate with existing web3 tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a link to CRC20 definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it's briefly described below -- but may be good to link the actual crc20 doc describing the interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the link to the contract itself for now, maybe document the crc20 later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets create a new repository and add the specification for CRC20 and transferable tokens through bridge
|
||
## Auto-deployed Contract | ||
|
||
A contract whose byte code is embedded in Cronos module and deployed by it, and some operations in it are only authorized to Cronos module. These contracts can be trusted by Cronos module directly. Currently, Cronos module support auto-deploy a minimal CRC20 contract to support automatic wrapping native token in EVM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe linking the contract description or sketching out its code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the link to the ModuleCRC20.sol
.
x/cronos/spec/07_params.md
Outdated
- `KeyIbcTimeout` The timeout value to use when Cronos module transfer tokens to IBC channels. | ||
|
||
- `KeyCronosAdmin` The account that is authorized to manage token mapping through message, empty means no admin, should be a valid bech32 cosmos address if specified. | ||
- `KeyEnableAutoDeployment` specifies if the auto-deployment feature is enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens when auto-deployment is off and then it's turned on via paramchange proposal? maybe good to add some comments on these parameters whether they are easily "updatable" -- to me, it seems only CronosAdmin can be updated via paramchange... the others look like that they'd need some extra code to be executed for store migrations etc. (so perhaps there should be a warning that they are not easily updatable, but would need some custom upgrade logic?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment on the side effects of update at runtime, it seems only IbcCroDenom
needs special care to migrate the tokens.
EnableAutoDeployment
should be good, because when it's disabled at runtime, only the new contract deployment is disabled, token withdrawn is not.
|
||
## MsgUpdateTokenMapping | ||
|
||
Update external token mapping, insert if not exists, can only be called by Cronos admin account, which is configured in module parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is the supply managed if there was an existing token mapping, and it was updated to a different one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one other thing: what if one maps several native tokens to one contract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, the issue is fixed here: #187
added a failure case in the doc.
x/cronos/spec/04_messages.md
Outdated
|
||
## MsgTransferTokens | ||
|
||
Transfer IBC tokens away from Cronos chain, will do decimals conversion automatically for CRO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe some details on what it does -- I assume it'll do the conversion and do some implicit action with ibc-transfer: https://github.com/cosmos/ibc-go/blob/main/proto/ibc/applications/transfer/v1/tx.proto#L20 with some of those fields hardcoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it actually calls the TransferKeeper.SendTranser
directly:
Line 168 in 5e60034
return k.transferKeeper.SendTransfer( |
Added doc about this, and the hardcoded timeout paramters.
- The coin denom is neither IBC nor gravity tokens. | ||
- The mapping does not exist and auto-deployment is not enabled. | ||
|
||
## MsgTransferTokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the reverse of MsgConvertVouchers
or how does one "exit" the EVM contract? what if the contract locks the tokens in some way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments that these messages are not supposed to be used by end-user normally, end-user can use the smart contract APIs, which might need to be documented at another time.
Currently, MsgTransferTokens
only handles IBC tokens, while MsgConvertVouchers
can also handle gravity tokens, so they are not the exact reverse.
how does one "exit" the EVM contract?
The message work on native token only, there's not much difference from using ibc-transfer message directly for non-cro tokens, for cro, it also does the decimal conversion.
@@ -0,0 +1,36 @@ | |||
<!-- order: 4 --> | |||
|
|||
# Messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one useful information for MsgConvertVouchers
and MsgTransferTokens
would be to specify from/to addresses which ecosystem they are expected to come from... I assume address
in MsgConvertVouchers
would the be used in EVM, so it should come from the Ethereum ecosystem, but when on first transfers in the IBC tokens, they may land on an address that comes from the Cosmos ecosystem?
or would those message check the account types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, documented the fields.
or would those message check the account types?
The from
addresses is the message signer, so they must be normal accounts. other than that, there seems no other explicit check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume address in MsgConvertVouchers would the be used in EVM
The underlying method of MsgConvertVouchers
is called in ibc hooks, to convert the arrived ibc token to crc20.
|
||
## Token Mapping | ||
|
||
### Create/Update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are the supplies transitioned on updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment on that, I think the contract develop should be able to manage the token migration themselves, on the smart contract level.
Closes: crypto-org-chain#64 Solution: - write cronos module spec fix wordings add state transition update title highlight token mapping deletion Apply suggestions from code review Co-authored-by: aw126 <78806365+aw126@users.noreply.github.com> apply suggestions tmp Apply suggestions from code review Co-authored-by: Tomas Tauber <2410580+tomtau@users.noreply.github.com> remove Key prefix review suggstions Revert "remove Key prefix" This reverts commit 9fa8583a425f4cc7669fb2cb0c1ce29dcb484ea6. remove Key prefix review suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Closes: #64
Solution:
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
PR Checklist:
make
)make test
)go fmt
)golangci-lint run
)go list -json -m all | nancy sleuth
)Thank you for your code, it's appreciated! :)