Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b6d2577
add generic location to account converter
Nathy-bajo Jan 23, 2025
8e399fd
add generic to account converter
Nathy-bajo Jan 27, 2025
d6bfcfa
Merge branch 'master' into generic-location
Nathy-bajo Jan 27, 2025
2fcf7ae
Update XCM location conversion
Nathy-bajo Feb 11, 2025
5b96271
remove unwanted files
Nathy-bajo Feb 11, 2025
3b11295
Update cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_c…
Nathy-bajo Feb 19, 2025
5776359
Update polkadot/xcm/xcm-builder/src/location_conversion.rs
Nathy-bajo Feb 19, 2025
c03272d
Update polkadot/xcm/xcm-builder/src/location_conversion.rs
Nathy-bajo Feb 19, 2025
c6b833c
Update polkadot/xcm/xcm-builder/src/location_conversion.rs
Nathy-bajo Feb 19, 2025
598a025
Merge branch 'master' into generic-location
Nathy-bajo Feb 19, 2025
3eb3f8d
more changes
Nathy-bajo Feb 19, 2025
7c5680c
add prdoc file
Nathy-bajo Feb 19, 2025
7613bf6
nit
Nathy-bajo Feb 19, 2025
11a4cae
nit
Nathy-bajo Feb 19, 2025
1aa9d7c
Merge branch 'master' into generic-location
Nathy-bajo Feb 19, 2025
605364e
Update polkadot/xcm/xcm-builder/src/location_conversion.rs
Nathy-bajo Feb 19, 2025
a608bab
Merge branch 'master' of github.com:paritytech/polkadot-sdk into gene…
acatangiu Feb 28, 2025
c5d660c
fix formatting and add deprecation docs
acatangiu Feb 28, 2025
23eb121
use new location converter
acatangiu Feb 28, 2025
eae2b20
fix tests
acatangiu Feb 28, 2025
028dbb7
fix prdoc
acatangiu Feb 28, 2025
be0c3a7
added external consensus location conversion tests
x3c41a Mar 4, 2025
ff5ad86
added extra tail test cases
x3c41a Mar 4, 2025
e5b30a1
Merge branch 'master' into generic-location
acatangiu Mar 5, 2025
c6702d6
moved sp_io into cargo.toml
x3c41a Mar 5, 2025
ccf95c5
fixed PRdoc and added missing runtime-benchmarks to snowbridge
x3c41a Mar 5, 2025
8d0c67f
executed taplo format --config .config/taplo.toml
x3c41a Mar 5, 2025
82dd119
changed bump to minor
x3c41a Mar 5, 2025
e1f62ea
Merge branch 'master' into generic-location
x3c41a Mar 5, 2025
d928504
Merge branch 'master' into generic-location
Nathy-bajo Mar 5, 2025
af29332
added missing crates to prdoc and reverted pov-validator changes
x3c41a Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ pub type LocationToAccountId = (
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
// Different global consensus parachain sovereign account.
// (Used for over-bridge transfers and reserve processing)
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
GlobalLocationToAccount<UniversalLocation, AccountId>,
);

pub type GlobalLocationToAccount<UniversalLocation, AccountId> = (
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
EthereumLocationsConverterFor<AccountId>,
ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
);

/// Means for transacting the native currency on this chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ pub type LocationToAccountId = (
AccountId32Aliases<RelayNetwork, AccountId>,
// Foreign locations alias into accounts according to a hash of their standard description.
HashedDescription<AccountId, DescribeFamily<DescribeAllTerminal>>,
// Different global consensus parachain sovereign account.
// (Used for over-bridge transfers and reserve processing)
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
// Ethereum contract sovereign account.
// (Used to get convert ethereum contract locations to sovereign account)
GlobalLocationToAccount<UniversalLocation, AccountId>,
);

pub type GlobalLocationToAccount<UniversalLocation, AccountId> = (
GlobalConsensusParachainConvertsFor<UniversalLocation, AccountId>,
EthereumLocationsConverterFor<AccountId>,
ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
);


/// Means for transacting the native currency on this chain.
pub type FungibleTransactor = FungibleAdapter<
// Use this currency:
Expand Down
45 changes: 45 additions & 0 deletions polkadot/xcm/xcm-builder/src/location_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
DescribeBodyTerminal,
);


pub struct DescribeFamily<DescribeInterior>(PhantomData<DescribeInterior>);
impl<Suffix: DescribeLocation> DescribeLocation for DescribeFamily<Suffix> {
fn describe_location(l: &Location) -> Option<Vec<u8>> {
Expand Down Expand Up @@ -412,6 +413,7 @@
}
}


/// Converts a location which is a top-level parachain (i.e. a parachain held on a
/// Relay-chain which provides its own consensus) into a 32-byte `AccountId`.
///
Expand Down Expand Up @@ -458,6 +460,48 @@
}
}

/// Converts locations from external global consensus systems (e.g., Ethereum, other parachains) into `AccountId`.
/// This includes handling child locations (e.g., `AccountId(Alice)`) and extending the functionality of
/// `GlobalConsensusParachainConvertsFor` and `EthereumLocationsConverterFor`.
pub struct ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>(PhantomData<(UniversalLocation, AccountId)>);

Check failure on line 466 in polkadot/xcm/xcm-builder/src/location_conversion.rs

View workflow job for this annotation

GitHub Actions / cargo-check-all-crate-macos

struct `ExternalConsensusLocationsConverterFor` is never constructed

impl<UniversalLocation: Get<InteriorLocation>, AccountId: From<[u8; 32]> + Clone>
ConvertLocation<AccountId> for ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>
{
fn convert_location(location: &Location) -> Option<AccountId> {
let universal_source = UniversalLocation::get();
log::trace!(
target: "xcm::location_conversion",
"ExternalConsensusLocationsConverterFor universal_source: {:?}, location: {:?}",
universal_source, location,
);

let owned_location = location.clone();
let (remote_network, remote_location) = ensure_is_remote(universal_source, owned_location).ok()?;

// replaces and extends `EthereumLocationsConverterFor` and `GlobalConsensusParachainConvertsFor`
let acc_id: AccountId = if let Ethereum { chain_id } = &remote_network {
match remote_location.as_slice() {
// equivalent to `EthereumLocationsConverterFor`
[] => (b"ethereum-chain", chain_id).using_encoded(blake2_256).into(),
// equivalent to `EthereumLocationsConverterFor`
[AccountKey20 { network: _, key }] => (b"ethereum-chain", chain_id, *key).using_encoded(blake2_256).into(),
// extends `EthereumLocationsConverterFor`
tail =>(b"ethereum-chain", chain_id, tail).using_encoded(blake2_256).into(),
}
} else {
match remote_location.as_slice() {
// equivalent to `GlobalConsensusParachainConvertsFor`
[Parachain(para_id)] => (b"glblcnsnss/prchn_", remote_network, para_id).using_encoded(blake2_256).into(),
// converts everything else based on hash of encoded location tail
tail => (b"glblcnsnss", remote_network, tail).using_encoded(blake2_256).into(),
}
};
Some(acc_id)
}
}


#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1010,4 +1054,5 @@
actual_description
);
}

}
17 changes: 17 additions & 0 deletions prdoc/pr_7313.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: [XCM] add generic location to account converter that also works with external ecosystems.

doc:
- audience: Runtime User
description: |-
Adds a new `ExternalConsensusLocationsConverterFor` struct to handle external global
consensus locations and their child locations.
This struct extends the functionality of existing converters (`GlobalConsensusParachainConvertsFor`
and `EthereumLocationsConverterFor`) while maintaining backward compatibility.

crates:
- name: xcm-builder
bump: minor
- name: asset-hub-rococo-runtime
bump: minor
- name: asset-hub-westend-runtime
bump: minor
Loading