Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bridges/snowbridge/primitives/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sp-runtime = { workspace = true }
sp-std = { workspace = true }

xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }

snowbridge-core = { workspace = true }
Expand All @@ -43,13 +44,15 @@ std = [
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"snowbridge-core/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ where
}
}

/// DEPRECATED in favor of [xcm_builder::ExternalConsensusLocationsConverterFor]
pub struct EthereumLocationsConverterFor<AccountId>(PhantomData<AccountId>);
impl<AccountId> ConvertLocation<AccountId> for EthereumLocationsConverterFor<AccountId>
where
Expand Down
21 changes: 18 additions & 3 deletions bridges/snowbridge/primitives/router/src/inbound/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ use super::EthereumLocationsConverterFor;
use crate::inbound::{
mock::*, Command, ConvertMessage, Destination, MessageV1, VersionedMessage, H160,
};
use frame_support::assert_ok;
use frame_support::{assert_ok, parameter_types};
use hex_literal::hex;
use xcm::prelude::*;
use xcm_builder::ExternalConsensusLocationsConverterFor;
use xcm_executor::traits::ConvertLocation;

parameter_types! {
pub UniversalLocation: InteriorLocation = [GlobalConsensus(ByGenesis([9; 32])), Parachain(1234)].into();
}

#[test]
fn test_ethereum_network_converts_successfully() {
let expected_account: [u8; 32] =
Expand All @@ -15,7 +20,12 @@ fn test_ethereum_network_converts_successfully() {

let account =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();

assert_eq!(account, expected_account);
let account =
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
&contract_location,
)
.unwrap();
assert_eq!(account, expected_account);
}

Expand All @@ -30,7 +40,12 @@ fn test_contract_location_with_network_converts_successfully() {

let account =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&contract_location).unwrap();

assert_eq!(account, expected_account);
let account =
ExternalConsensusLocationsConverterFor::<UniversalLocation, [u8; 32]>::convert_location(
&contract_location,
)
.unwrap();
assert_eq!(account, expected_account);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ sp-runtime = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod imports {
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
};
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::imports::*;
use ahr_xcm_config::UniversalLocation as AssetHubRococoUniversalLocation;
use codec::{Decode, Encode};
use emulated_integration_tests_common::xcm_emulator::ConvertLocation;
use frame_support::pallet_prelude::TypeInfo;
Expand All @@ -24,9 +25,7 @@ use snowbridge_pallet_inbound_queue_fixtures::{
send_token::make_send_token_message, send_token_to_penpal::make_send_token_to_penpal_message,
};
use snowbridge_pallet_system;
use snowbridge_router_primitives::inbound::{
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
};
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use sp_core::H256;
use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable};
use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork;
Expand Down Expand Up @@ -319,8 +318,13 @@ fn send_weth_from_ethereum_to_penpal() {
let origin_location = (Parent, Parent, ethereum_network_v5).into();

// Fund ethereum sovereign on AssetHub
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubRococoUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});
AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on the Penpal parachain.
Expand Down Expand Up @@ -526,8 +530,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
use ahr_xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
let assethub_location = BridgeHubRococo::sibling_location_of(AssetHubRococo::para_id());
let assethub_sovereign = BridgeHubRococo::sovereign_account_id_of(assethub_location);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubRococo::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubRococoUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

AssetHubRococo::force_default_xcm_version(Some(XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(XCM_VERSION));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ sp-runtime = { workspace = true }
# Polkadot
pallet-xcm = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod imports {
prelude::{AccountId32 as AccountId32Junction, *},
v5,
};
pub use xcm_builder::ExternalConsensusLocationsConverterFor;
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{imports::*, tests::penpal_emulated_chain::penpal_runtime};
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
use asset_hub_westend_runtime::xcm_config::{
bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee,
UniversalLocation as AssetHubWestendUniversalLocation,
};
use bridge_hub_westend_runtime::{
bridge_to_ethereum_config::EthereumGatewayAddress, EthereumBeaconClient, EthereumInboundQueue,
};
Expand All @@ -24,9 +27,7 @@ use hex_literal::hex;
use rococo_westend_system_emulated_network::asset_hub_westend_emulated_chain::genesis::AssetHubWestendAssetOwner;
use snowbridge_core::{inbound::InboundQueueFixture, AssetMetadata, TokenIdOf};
use snowbridge_pallet_inbound_queue_fixtures::send_native_eth::make_send_native_eth_message;
use snowbridge_router_primitives::inbound::{
Command, Destination, EthereumLocationsConverterFor, MessageV1, VersionedMessage,
};
use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage};
use sp_core::H256;
use testnet_parachains_constants::westend::snowbridge::EthereumNetwork;
use xcm_executor::traits::ConvertLocation;
Expand Down Expand Up @@ -161,8 +162,13 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
fn send_weth_token_from_ethereum_to_asset_hub() {
let ethereum_network: NetworkId = EthereumNetwork::get().into();
let origin_location = Location::new(2, ethereum_network);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id().into(), INITIAL_FUND);

Expand Down Expand Up @@ -280,8 +286,13 @@ fn send_weth_from_ethereum_to_penpal() {
let origin_location = (Parent, Parent, ethereum_network_v5).into();

// Fund ethereum sovereign on AssetHub
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

// Create asset on the Penpal parachain.
Expand Down Expand Up @@ -387,8 +398,13 @@ fn send_eth_asset_from_asset_hub_to_ethereum_and_back() {
use asset_hub_westend_runtime::xcm_config::bridging::to_ethereum::DefaultBridgeHubEthereumBaseFee;
let assethub_location = BridgeHubWestend::sibling_location_of(AssetHubWestend::para_id());
let assethub_sovereign = BridgeHubWestend::sovereign_account_id_of(assethub_location);
let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<AccountId>::convert_location(&origin_location).unwrap();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
AccountId,
>::convert_location(&origin_location)
.unwrap()
});

AssetHubWestend::force_default_xcm_version(Some(XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(XCM_VERSION));
Expand Down Expand Up @@ -934,13 +950,17 @@ fn transfer_relay_token() {

let expected_token_id = TokenIdOf::convert_location(&expected_asset_id).unwrap();

let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&Location::new(
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
[u8; 32],
>::convert_location(&Location::new(
2,
[GlobalConsensus(EthereumNetwork::get())],
))
.unwrap()
.into();
.into()
});

// Register token
BridgeHubWestend::execute_with(|| {
Expand Down Expand Up @@ -1082,10 +1102,14 @@ fn transfer_ah_token() {

let ethereum_destination = Location::new(2, [GlobalConsensus(Ethereum { chain_id: CHAIN_ID })]);

let ethereum_sovereign: AccountId =
EthereumLocationsConverterFor::<[u8; 32]>::convert_location(&ethereum_destination)
.unwrap()
.into();
let ethereum_sovereign: AccountId = AssetHubWestend::execute_with(|| {
ExternalConsensusLocationsConverterFor::<
AssetHubWestendUniversalLocation,
[u8; 32],
>::convert_location(&ethereum_destination)
.unwrap()
.into()
});
AssetHubWestend::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]);

let asset_id: Location =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ snowbridge-router-primitives = { workspace = true }
[dev-dependencies]
asset-test-utils = { workspace = true, default-features = true }
parachains-runtimes-test-utils = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }

[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use snowbridge_router_primitives::inbound::EthereumLocationsConverterFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use testnet_parachains_constants::rococo::snowbridge::{
EthereumNetwork, INBOUND_QUEUE_PALLET_INDEX,
Expand All @@ -52,16 +51,15 @@ use xcm_builder::{
AccountId32Aliases, AliasChildLocation, AllowExplicitUnpaidExecutionFrom,
AllowHrmpNotificationsFromRelayChain, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, DenyRecursively, DenyReserveTransferToRelayChain, DenyThenTry,
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, FrameTransactionalProcessor,
FungibleAdapter, FungiblesAdapter, GlobalConsensusParachainConvertsFor, HashedDescription,
IsConcrete, LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking,
NonFungiblesAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter,
SovereignPaidRemoteExporter, SovereignSignedViaLocation, StartsWith,
StartsWithExplicitGlobalConsensus, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithLatestLocationConverter, WithUniqueTopic,
XcmFeeManagerFromComponents,
DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin, ExternalConsensusLocationsConverterFor,
FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, HashedDescription, IsConcrete,
LocalMint, MatchedConvertedConcreteId, NetworkExportTableItem, NoChecking, NonFungiblesAdapter,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SingleAssetExchangeAdapter, SovereignPaidRemoteExporter,
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
WithLatestLocationConverter, WithUniqueTopic, XcmFeeManagerFromComponents,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -105,12 +103,8 @@ 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)
EthereumLocationsConverterFor<AccountId>,
// Different global consensus locations sovereign accounts.
ExternalConsensusLocationsConverterFor<UniversalLocation, AccountId>,
);

/// Means for transacting the native currency on this chain.
Expand Down
Loading
Loading