-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support Native ETH in v1 #1354
base: main
Are you sure you want to change the base?
Support Native ETH in v1 #1354
Conversation
c2835dd
to
b75401c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1354 +/- ##
==========================================
- Coverage 77.83% 76.58% -1.25%
==========================================
Files 14 17 +3
Lines 415 739 +324
Branches 76 110 +34
==========================================
+ Hits 323 566 +243
- Misses 75 162 +87
+ Partials 17 11 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@vgeddes we have a Command called |
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.
+1
Changes: 1. Use the 0x0000000000000000000000000000000000000000 token address as Native ETH. 2. Convert it to/from `{ parents: 2, interior: X1(GlobalConsensus(Ethereum{chain_id: 1})) }` when encountered. Onchain changes: This will require a governance request to register native ETH (with the above location) in the foreign assets pallet and make it sufficient. Related solidity changes: Snowfork/snowbridge#1354 TODO: - [x] Emulated Tests --------- Co-authored-by: Vincent Geddes <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
Changes: 1. Use the 0x0000000000000000000000000000000000000000 token address as Native ETH. 2. Convert it to/from `{ parents: 2, interior: X1(GlobalConsensus(Ethereum{chain_id: 1})) }` when encountered. Onchain changes: This will require a governance request to register native ETH (with the above location) in the foreign assets pallet and make it sufficient. Related solidity changes: Snowfork/snowbridge#1354 TODO: - [x] Emulated Tests --------- Co-authored-by: Vincent Geddes <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> (cherry picked from commit 4059282)
* do not dispatch transfer from native command * test to make sure the behavior is off * fmt * naming
c778b96
to
757bcc0
Compare
contracts/src/AgentExecutor.sol
Outdated
function transferNative(address payable recipient, uint256 amount) external { | ||
recipient.safeNativeTransfer(amount); | ||
} | ||
|
||
/// @dev Transfer ether to Gateway. Used once off for migration purposes. Can be removed after version 1. | ||
function transferNativeToGateway(address payable gateway, uint256 amount) external { |
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.
In this context, msg.sender
will always be the gateway address, as verified by Agent.invoke
. So having a gateway
parameter is redundant.
Also, prefer this naming in this context:
function transferNativeToGateway(address payable gateway, uint256 amount) external { | |
function transferEtherToGateway(address payable gateway, uint256 amount) external { |
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.
Addressed in aca3846
contracts/src/Assets.sol
Outdated
@@ -60,7 +62,7 @@ library Assets { | |||
) external view returns (Costs memory costs) { | |||
AssetsStorage.Layout storage $ = AssetsStorage.layout(); | |||
TokenInfo storage info = $.tokenRegistry[token]; | |||
if (!info.isRegistered) { | |||
if (!info.isRegistered && token != address(0)) { |
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.
Why not just register ether as a token, so we can avoid the complexity of this 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.
Addressed in a3e5aa4
contracts/src/Assets.sol
Outdated
@@ -144,7 +148,18 @@ library Assets { | |||
AssetsStorage.Layout storage $ = AssetsStorage.layout(); | |||
|
|||
// Lock the funds into AssetHub's agent contract | |||
_transferToAgent($.assetHubAgent, token, sender, amount); | |||
if (token != address(0)) { |
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 think the way you've introduced native ether support adds complexity by adding a lot of decision branches at the lowest level.
We already have branches at a higher level to choose between foreign, native tokens. We can add a branch for eth support there.
Concretely, I would suggest adding a new _sendEther
function instead of adding branches in _sendNativeToken
.
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.
Addressed in d8a9a58
contracts/src/Assets.sol
Outdated
payable($.assetHubAgent).safeNativeTransfer(amount); | ||
ticket.value = amount; | ||
|
||
ticket.dest = $.assetHubParaID; |
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 seems that both _sendEther
and _sendNativeToken
share this ticket/payload creation code. Can we not factor that out?
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.
addressed in 0921ff9
Changes
0x0000000000000000000000000000000000000000
token address as Native ETH.0x00..
an amount ofmsg.value
is locked in asset hub agent.Related polkadot-sdk: paritytech/polkadot-sdk#6855
TODO
Resolves: https://linear.app/snowfork/issue/SNO-1222