diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index b3c8637fe..44b0be145 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -60,10 +60,6 @@ contract Gateway is IGateway, IInitializable { bytes4 internal immutable BRIDGE_HUB_PARA_ID_ENCODED; bytes32 internal immutable BRIDGE_HUB_AGENT_ID; - // AssetHub - ParaID internal immutable ASSET_HUB_PARA_ID; - bytes32 internal immutable ASSET_HUB_AGENT_ID; - // ChannelIDs ChannelID internal constant PRIMARY_GOVERNANCE_CHANNEL_ID = ChannelID.wrap(bytes32(uint256(1))); ChannelID internal constant SECONDARY_GOVERNANCE_CHANNEL_ID = ChannelID.wrap(bytes32(uint256(2))); diff --git a/parachain/pallets/system/src/mock.rs b/parachain/pallets/system/src/mock.rs index cf0cc4675..7a4f61189 100644 --- a/parachain/pallets/system/src/mock.rs +++ b/parachain/pallets/system/src/mock.rs @@ -12,14 +12,13 @@ use xcm_executor::traits::ConvertLocation; use snowbridge_core::{ gwei, meth, outbound::ConstantGasMeter, sibling_sovereign_account, AgentId, AllowSiblingsOnly, - DescribeHere, ParaId, PricingParameters, Rewards, + ParaId, PricingParameters, Rewards, }; use sp_runtime::{ traits::{AccountIdConversion, BlakeTwo256, IdentityLookup, Keccak256}, AccountId32, BuildStorage, FixedU128, }; use xcm::prelude::*; -use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription}; #[cfg(feature = "runtime-benchmarks")] use crate::BenchmarkHelper; @@ -221,8 +220,7 @@ impl crate::Config for Test { type RuntimeEvent = RuntimeEvent; type OutboundQueue = OutboundQueue; type SiblingOrigin = pallet_xcm_origin::EnsureXcm; - type AgentIdOf = - HashedDescription)>; + type AgentIdOf = snowbridge_core::AgentIdOf; type TreasuryAccount = TreasuryAccount; type Token = Balances; type DefaultPricingParameters = Parameters; diff --git a/parachain/primitives/core/src/lib.rs b/parachain/primitives/core/src/lib.rs index 8a98dcde5..ecbc3bb36 100644 --- a/parachain/primitives/core/src/lib.rs +++ b/parachain/primitives/core/src/lib.rs @@ -33,7 +33,7 @@ use xcm::prelude::{ Junctions::{Here, X1}, MultiLocation, }; -use xcm_builder::DescribeLocation; +use xcm_builder::{DescribeAllTerminal, DescribeFamily, DescribeLocation, HashedDescription}; /// The ID of an agent contract pub type AgentId = H256; @@ -168,3 +168,7 @@ impl DescribeLocation for DescribeHere { } } } + +/// Creates an AgentId from a MultiLocation. An AgentId is a unique mapping to a Agent contract on +/// Ethereum which acts as the sovereign account for the MultiLocation. +pub type AgentIdOf = HashedDescription)>; diff --git a/parachain/primitives/router/src/outbound/mod.rs b/parachain/primitives/router/src/outbound/mod.rs index 8260cbe89..c7f2f4408 100644 --- a/parachain/primitives/router/src/outbound/mod.rs +++ b/parachain/primitives/router/src/outbound/mod.rs @@ -93,12 +93,11 @@ where SendError::Unroutable })?; - // local_sub is relative to the relaychain. No conversion needed. - let local_sub_location: MultiLocation = local_sub.into(); - let agent_id = match AgentHashedDescription::convert_location(&local_sub_location) { + let source_location: MultiLocation = MultiLocation { parents: 1, interior: local_sub }; + let agent_id = match AgentHashedDescription::convert_location(&source_location) { Some(id) => id, None => { - log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{local_sub_location:?}'"); + log::error!(target: "xcm::ethereum_blob_exporter", "unroutable due to not being able to create agent id. '{source_location:?}'"); return Err(SendError::Unroutable) }, }; diff --git a/parachain/primitives/router/src/outbound/tests.rs b/parachain/primitives/router/src/outbound/tests.rs index f64ad8698..153d934c3 100644 --- a/parachain/primitives/router/src/outbound/tests.rs +++ b/parachain/primitives/router/src/outbound/tests.rs @@ -1,11 +1,10 @@ use frame_support::parameter_types; use hex_literal::hex; -use snowbridge_core::outbound::{Fee, SendError, SendMessageFeeProvider}; - +use snowbridge_core::{ + outbound::{Fee, SendError, SendMessageFeeProvider}, + AgentIdOf, +}; use xcm::v3::prelude::SendError as XcmSendError; -use xcm_builder::{DescribeAllTerminal, DescribeFamily, HashedDescription}; - -pub type AgentIdOf = HashedDescription>; use super::*; @@ -1035,3 +1034,30 @@ fn xcm_converter_convert_with_non_ethereum_chain_beneficiary_yields_beneficiary_ let result = converter.convert(); assert_eq!(result.err(), Some(XcmConverterError::BeneficiaryResolutionFailed)); } + +#[test] +fn test_describe_asset_hub() { + let legacy_location: MultiLocation = + MultiLocation { parents: 0, interior: X1(Parachain(1000)) }; + let legacy_agent_id = AgentIdOf::convert_location(&legacy_location).unwrap(); + assert_eq!( + legacy_agent_id, + hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4").into() + ); + let location: MultiLocation = MultiLocation { parents: 1, interior: X1(Parachain(1000)) }; + let agent_id = AgentIdOf::convert_location(&location).unwrap(); + assert_eq!( + agent_id, + hex!("81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79").into() + ) +} + +#[test] +fn test_describe_here() { + let location: MultiLocation = MultiLocation { parents: 0, interior: Here }; + let agent_id = AgentIdOf::convert_location(&location).unwrap(); + assert_eq!( + agent_id, + hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into() + ) +} diff --git a/polkadot-sdk b/polkadot-sdk index decead036..9cdc1d2bd 160000 --- a/polkadot-sdk +++ b/polkadot-sdk @@ -1 +1 @@ -Subproject commit decead03621dc48b8b3ea1d764d6438a49516e0a +Subproject commit 9cdc1d2bd0169a0ddce9ccc8be898c90f7ffdf53 diff --git a/smoketest/src/constants.rs b/smoketest/src/constants.rs index 3e1d572b2..761be9a8b 100644 --- a/smoketest/src/constants.rs +++ b/smoketest/src/constants.rs @@ -30,7 +30,7 @@ pub const BRIDGE_HUB_AGENT_ID: [u8; 32] = hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314"); // Agent for asset hub parachain 1000 pub const ASSET_HUB_AGENT_ID: [u8; 32] = - hex!("72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4"); + hex!("81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79"); // Agent for penpal parachain 2000 pub const SIBLING_AGENT_ID: [u8; 32] = hex!("5097ee1101e90c3aadb882858c59a22108668021ec81bce9f4930155e5c21e59"); diff --git a/web/packages/test/scripts/set-env.sh b/web/packages/test/scripts/set-env.sh index a49a72b90..df0a8de21 100755 --- a/web/packages/test/scripts/set-env.sh +++ b/web/packages/test/scripts/set-env.sh @@ -41,7 +41,7 @@ export BRIDGE_HUB_AGENT_ID="${BRIDGE_HUB_AGENT_ID:-0x03170a2e7597b7b7e3d84c05391 assethub_ws_url="${ASSET_HUB_WS_URL:-ws://127.0.0.1:12144}" assethub_seed="${ASSET_HUB_SEED:-//Alice}" export ASSET_HUB_PARAID="${ASSET_HUB_PARAID:-1000}" -export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x72456f48efed08af20e5b317abf8648ac66e86bb90a411d9b0b713f7364b75b4}" +export ASSET_HUB_AGENT_ID="${ASSET_HUB_AGENT_ID:-0x81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79}" export ASSET_HUB_CHANNEL_ID="0xc173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539" export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3"