-
Notifications
You must be signed in to change notification settings - Fork 106
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
Snowbridge: Add support for Ether #548
base: main
Are you sure you want to change the base?
Snowbridge: Add support for Ether #548
Conversation
Doesn't look good, new crates bring new minor or major versions of deps, doesn't build. I see the snowfork crates have semver-minor bump, I expected patch bumps to have everything working ok. |
042c49e
to
2ea7fd3
Compare
This reverts commit 2ea7fd3.
61541b1
to
d46f577
Compare
AssetHubPolkadot::fund_accounts(vec![ | ||
(AssetHubPolkadotReceiver::get(), INITIAL_FUND), | ||
(ethereum_sovereign_account(), INITIAL_FUND), | ||
]); |
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.
This may not be necessary.
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 test failed without (AssetHubPolkadotReceiver::get(), INITIAL_FUND),
so I pulled it in from the WETH test. The fee assertions of the test are what failed.
let message = VersionedMessage::V1(MessageV1 { | ||
chain_id: CHAIN_ID, | ||
command: Command::SendToken { | ||
token: [0; 20].into(), |
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.
Adding a comment like [0;20] representing Ether is better.
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 a0a5211
<AssetHubPolkadot as AssetHubPolkadotPallet>::Balances::free_balance( | ||
AssetHubPolkadotReceiver::get(), | ||
); | ||
// Send the Weth back to Ethereum |
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.
Should be ether
here.
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 7d39a0a
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
Review required! Latest push from author must always be reviewed |
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.
@alistair-singh adding ether does not require any runtime config, except the new snowbridge-router-primitives
crate version, right?
No, we just need the new code in the crate which interprets |
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
<<BridgeHubPolkadot as BridgeHubPolkadotPallet>::Balances as frame_support::traits::fungible::Inspect<_>>::balance(&RelayTreasuryPalletAccount::get()) | ||
}); | ||
|
||
// Send Ether from Asset Hub. |
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.
// Send Ether from Asset Hub. | |
// Send Ether from Asset Hub back to Ethereum. |
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 e946e28
assert!(free_balance_diff > AH_BASE_FEE); | ||
}); | ||
|
||
// Recieve Ether on Bridge Hub and dispatch |
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.
// Recieve Ether on Bridge Hub and dispatch | |
// Check that message with Ether was queued on the BridgeHub |
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 e946e28
// Check that the transfer token back to Ethereum message was queue in the Ethereum | ||
// Outbound Queue |
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.
// Check that the transfer token back to Ethereum message was queue in the Ethereum | |
// Outbound Queue | |
// check the outbound queue |
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 e946e28
); | ||
}); | ||
|
||
// Receive ether on Asset Hub. |
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.
// Receive ether on Asset Hub. | |
// Receive Ether on Asset Hub. |
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 e946e28
assert_expected_events!( | ||
AssetHubPolkadot, | ||
vec![ | ||
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, |
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.
we could/should be exact here:
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, | |
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, .. }) => { | |
asset_id: *asset_id == ether_location, | |
}, |
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 798229c
); | ||
}); | ||
|
||
// Send Ether from Bridge Hub |
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.
// Send Ether from Bridge Hub | |
// Send Ether from Bridge Hub (simulates received Command from Ethereum) |
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 e946e28
|
||
let ether_location: Location = (Parent, Parent, EthereumNetwork::get()).into(); | ||
|
||
AssetHubPolkadot::execute_with(|| { |
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.
AssetHubPolkadot::execute_with(|| { | |
// Register Ether as foreign asset on AH. | |
AssetHubPolkadot::execute_with(|| { |
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 e946e28
@@ -459,6 +461,184 @@ fn send_token_from_ethereum_to_asset_hub() { | |||
}); | |||
} | |||
|
|||
/// Tests sending ether from Ethereum to Asset Hub and back to Ethereum | |||
#[test] | |||
fn send_eth_asset_from_asset_hub_to_ethereum() { |
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 can imagine to create some generic helper function:
fn send_token_from_ethereum_to_asset_hub_and_back_works(token: Location) {
// copy the code below
}
and then reuse for test-cases, something like:
#[test]
fn send_weth_from_ethereum_to_asset_hub() {
send_token_from_ethereum_to_asset_hub_and_back_works(WETH)
}
#[test]
fn send_eth_from_ethereum_to_asset_hub() {
let ether_location: Location = (Parent, Parent, EthereumNetwork::get()).into();
send_token_from_ethereum_to_asset_hub_and_back_works(ether_location)
}
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 798229c
Adds support for the bridging Ether.
TODO
2409-1
0.16.1