-
Notifications
You must be signed in to change notification settings - Fork 235
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: bi-directional token conversion is not implemented #600
Problem: bi-directional token conversion is not implemented #600
Conversation
de252b0
to
bf32a1e
Compare
Codecov Report
@@ Coverage Diff @@
## main #600 +/- ##
==========================================
+ Coverage 39.12% 40.35% +1.22%
==========================================
Files 36 36
Lines 1848 1990 +142
==========================================
+ Hits 723 803 +80
- Misses 1071 1117 +46
- Partials 54 70 +16
|
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.
integration test need to be updated, the code changes looks good.
d50b3d9
to
8c09c03
Compare
8c09c03
to
d7dc2ca
Compare
8c828fb
to
96d4099
Compare
96d4099
to
2f3a349
Compare
56900c1
to
51c7583
Compare
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.
Code changes looks good, can you add an integration test case to boost confidence?
integration tests for ibc added there |
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.
LGTM
balanceOf[src] = sub(balanceOf[src], amount); | ||
balanceOf[dst] = add(balanceOf[dst], amount); | ||
emit Transfer(src, dst, amount); | ||
} |
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.
Based on the whole code, looks all good to me. Not sure if the DSToken code is the same as the current ModuleCRC20 token in cronos-token-init-launch
repo, if so then all good.
Additional question about the isSource
flag:
- in the current version, this flag can only be initialized once in constructor when it was deployed. It means we cannot switch contract model to the previous version of
ModuleCRC20
. Is that an expected feature? Can you provide more details? - I'm not sure if the module_address will perform a burn operation in actual script(guess it should do to keep consistence with previous version?). And please ensure the actual burn operation() after triggered the corresponding
__CronosSendToIbc
or__CronosSendToChain
event. - Can you explain what this module_address actually is?
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 I guess this module_address will transfer or burn the corresponding tokens according to the actual feature(to chain or to ibc). Like this below:
- to ibc: transfer tokens from user to module_address, then module_address burn tokens to keep consistence with previous version.
- to chain: transfer tokens from user to module_address, then module_address transfer to Gravity Bridge to the target chain(e.g. Ethereum).
Please correct me if I'm wrong. Thanks!
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 I guess you will use module_address to do different operations according to the actual use?
Based on the previous ModuleCRC20
contract, all tokens will be burn when sending tokens:
- to ibc: 2 kinds of methods to do that, transfer to module_address then burn / transfer to module_address and directly to ibc(when getting back, directly transfer back to user, doesn't need to mint)
- to chain: 2 kinds of methods to do that, transfer to module_address then burn(mint tokens on GB side, when getting back, directly burn GB side and mint in this CRC21 side) / the same as above.
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.
to clarify about the source boolean.
Source define is the contract token represent an asset originated from the chain (cronos) like VVS, FERRO etc or comes from another chain (ETH, WBTC, ATOM)
It should be defined during initialisation and should probably not change.
module_address
is a special address use by the module when performing an evm operation. The module will invoke the smart contract method bypassing the orignal transaction flow and the "msg.sender" address will be set to module_address
. It holds certains priviledge in the contract such as be able to mint or burn tokens freely or move tokens
The reason we are not "burning/minting" tokens for source
contract but move them instead is that we want to preserve the total supply of the tokens (calculated by total_supply())
For non-source tokens, burning is okay because the total supply is defined on the original contract (not 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.
Can you explain what this module_address actually is?
module_address
is only used in:
require(msg.sender == module_address);
which guarantees it can only be called by chain native code, rather than anyone else.
👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻
Solution: Implement ADR-008
Todo: add test
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! :)