Skip to content
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: not possible to cancel SendToEthereum transactions (fixes #389) #532

Merged

Conversation

thomas-nguy
Copy link
Collaborator

@thomas-nguy thomas-nguy commented May 31, 2022

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

Solve this issue #389

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

@thomas-nguy thomas-nguy requested a review from a team as a code owner May 31, 2022 07:18
@thomas-nguy thomas-nguy requested review from calvinaco and adu-crypto and removed request for a team May 31, 2022 07:18
@thomas-nguy thomas-nguy marked this pull request as draft May 31, 2022 07:24
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #532 (01eae9e) into main (f223294) will increase coverage by 1.92%.
The diff coverage is 79.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #532      +/-   ##
==========================================
+ Coverage   39.91%   41.83%   +1.92%     
==========================================
  Files          30       30              
  Lines        1596     1690      +94     
==========================================
+ Hits          637      707      +70     
- Misses        913      929      +16     
- Partials       46       54       +8     
Impacted Files Coverage Δ
x/cronos/types/contracts.go 56.00% <20.00%> (-9.00%) ⬇️
x/cronos/keeper/evm_log_handlers.go 82.39% <81.08%> (-2.05%) ⬇️
x/cronos/keeper/evm.go 58.00% <100.00%> (ø)

@thomas-nguy thomas-nguy changed the title [WIP]Feature: Add CancelSendToEthereum support Feature: Add CancelSendToEthereum support May 31, 2022
@thomas-nguy thomas-nguy changed the title Feature: Add CancelSendToEthereum support Problem: Not possible to cancel SendToEthereum Transaction Jun 1, 2022
@thomas-nguy thomas-nguy changed the title Problem: Not possible to cancel SendToEthereum Transaction Problem: Not possible to cancel SendToEthereum Transactions Jun 1, 2022
@thomas-nguy thomas-nguy changed the title Problem: Not possible to cancel SendToEthereum Transactions Problem: not possible to cancel SendToEthereum Transactions Jun 1, 2022
@thomas-nguy thomas-nguy changed the title Problem: not possible to cancel SendToEthereum Transactions Problem: not possible to cancel SendToEthereum transactions Jun 1, 2022
@thomas-nguy thomas-nguy marked this pull request as ready for review June 1, 2022 03:30
}

// send to ethereum through gravity bridge
function send_to_ethereum_v2(address recipient, uint amount, uint bridge_fee) external {
Copy link
Collaborator Author

@thomas-nguy thomas-nguy Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without having to migrate all existing contract, it is possible to create a wrapper over the CRC20 to be able to call __CronosSendToEthereum and have a separate supply from the original CRC20

It would be cleaner to remove send_to_ethereum from the CRC20.sol and remove the _v2 here however this might change the bytecode of the original CRC20 standard (even though nobody is using this method now)

Any opinion @tomtau @yihuang

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the standard extension, and deprecate the send_to_ethereum from the original one.
But existing contracts still need to migrate code to support the gravity bridge, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another idea is to have a wrapper over exsting CRC20 contract to be able to add the ability to bridge.
For example having ETH_VVS will be a wrapper of VVS.sol and expose send_to_ethereum and wrapping/unwrapping functions
The 1-1 supply control will be guarantee by the smart contract

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest documenting these architectural decisions: https://github.com/crypto-org-chain/cronos/blob/main/docs/architecture/adr-template.md + getting some feedback from dApp developers on it

Copy link
Collaborator

@yihuang yihuang Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another idea is to have a wrapper over exsting CRC20 contract to be able to add the ability to bridge. For example having ETH_VVS will be a wrapper of VVS.sol and expose send_to_ethereum and wrapping/unwrapping functions The 1-1 supply control will be guarantee by the smart contract

it's still a contract migration, the client need to use a different contract address, but internally it reuse the old contract to avoid state migration, right?
I think dapps could have multiple solutions to do this, sometimes even have the upgradability build-in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the client need to use a different contract address, but internally it reuse the old contract to avoid state migration

Why does it need to use old contract? Mapping between gravitydenom <-> contract address will be done on the wrapped contract.
The drawback is that to be able to send to ethereum, one needs to wrap its token first (or unwrap for the opposite direction) but that can be integrated seeminglessly by the Dapp

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, you mean a 1-to-1 token wrapping contract, I guess for erc20, user will need to do a) approve, b) swap, c) send_to_ethereum, right?

CHANGELOG.md Outdated Show resolved Hide resolved
x/cronos/keeper/evm.go Outdated Show resolved Hide resolved
@yihuang yihuang self-requested a review June 9, 2022 02:47
Copy link
Collaborator

@yihuang yihuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, only some minor suggestions.

@thomas-nguy
Copy link
Collaborator Author

thomas-nguy commented Jun 9, 2022

client/docs/statik/statik.go

this is modified after running gofmt -s -w .

Copy link
Collaborator

@yihuang yihuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants