-
Notifications
You must be signed in to change notification settings - Fork 769
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: allow account conversion for Ethereum accounts #6221
Merged
acatangiu
merged 3 commits into
paritytech:master
from
acatangiu:enhance-ethereum-account-derivation
Nov 5, 2024
+48
−20
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
use super::GlobalConsensusEthereumConvertsFor; | ||||||
use super::EthereumLocationsConverterFor; | ||||||
use crate::inbound::CallIndex; | ||||||
use frame_support::{assert_ok, parameter_types}; | ||||||
use hex_literal::hex; | ||||||
|
@@ -17,14 +17,28 @@ parameter_types! { | |||||
} | ||||||
|
||||||
#[test] | ||||||
fn test_contract_location_with_network_converts_successfully() { | ||||||
fn test_ethereum_network_converts_successfully() { | ||||||
let expected_account: [u8; 32] = | ||||||
hex!("ce796ae65569a670d0c1cc1ac12515a3ce21b5fbf729d63d7b289baad070139d"); | ||||||
let contract_location = Location::new(2, [GlobalConsensus(NETWORK)]); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let account = | ||||||
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location) | ||||||
.unwrap(); | ||||||
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap(); | ||||||
|
||||||
assert_eq!(account, expected_account); | ||||||
} | ||||||
|
||||||
#[test] | ||||||
fn test_contract_location_with_network_converts_successfully() { | ||||||
let expected_account: [u8; 32] = | ||||||
hex!("9038d35aba0e78e072d29b2d65be9df5bb4d7d94b4609c9cf98ea8e66e544052"); | ||||||
let contract_location = Location::new( | ||||||
2, | ||||||
[GlobalConsensus(NETWORK), AccountKey20 { network: None, key: [123u8; 20] }], | ||||||
); | ||||||
|
||||||
let account = | ||||||
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap(); | ||||||
|
||||||
assert_eq!(account, expected_account); | ||||||
} | ||||||
|
@@ -34,7 +48,7 @@ fn test_contract_location_with_incorrect_location_fails_convert() { | |||||
let contract_location = Location::new(2, [GlobalConsensus(Polkadot), Parachain(1000)]); | ||||||
|
||||||
assert_eq!( | ||||||
GlobalConsensusEthereumConvertsFor::<[u8; 32]>::convert_location(&contract_location), | ||||||
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location), | ||||||
None, | ||||||
); | ||||||
} | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
title: Enable approval-voting-parallel by default on kusama | ||
acatangiu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
Replaced `GlobalConsensusEthereumConvertsFor` with `EthereumLocationsConverterFor` that allows `Location` | ||
to `AccountId` conversion for the Ethereum network root as before, but also for Ethereum contracts and accounts. | ||
crates: | ||
- name: snowbridge-router-primitives | ||
bump: major |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Why be explicit on the parents here instead? Wouldnt this limit its usage to being relative to parachains?
It would be parents 1 if relative to the relaychain. It would also be parents 1 if relative to another Ethereum chain. This wont break any existing use cases though so maybe its fine.
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.
Sorry, I forgot to mention this as well in the description (edited now).
I prefer tightening the match to explicit
parents: 2
since this converter is meant to be used by parachains only. I can't think of a valid (long-term) use case for the Relay chain to need to derive Ethereum locations.You mean if you use this converter in an Ethereum SC? I don't think there is such a real case, but if there will ever be I suggest adding a new entry to the match there or even using a separate converter since they would be different in output anyway (32bytes vs 20bytes).
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 Are you refering to another convert to convert a token location of PNA to a stable ID.
Then It's nothing to do with the above change, the above is for ENA and should be fine to set parents to 2.