diff --git a/Cargo.lock b/Cargo.lock index d2c91f68609b..826cb263b0d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17127,6 +17127,7 @@ dependencies = [ "ethabi-decode", "frame-support", "frame-system", + "hex-literal", "parity-scale-codec", "polkadot-parachain-primitives", "scale-info", @@ -17134,6 +17135,7 @@ dependencies = [ "snowbridge-beacon-primitives", "sp-arithmetic", "sp-core", + "sp-io", "sp-runtime", "sp-std", "staging-xcm", diff --git a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index aa8bc44b7037..c62d75f8943e 100644 --- a/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -13,12 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::*; +use codec::Encode; use hex_literal::hex; use integration_tests_common::{AssetHubRococoPallet, BridgeHubRococoPallet}; use snowbridge_control; use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage}; use sp_core::H256; +use snowbridge_core::outbound::OperatingMode; + const INITIAL_FUND: u128 = 5_000_000_000 * ROCOCO_ED; const CHAIN_ID: u64 = 15; const DEST_PARA_ID: u32 = 1000; @@ -31,10 +34,12 @@ const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EB #[test] fn create_agent() { + let origin_para: u32 = 1001; + BridgeHubRococo::fund_accounts(vec![( BridgeHubRococo::sovereign_account_id_of(MultiLocation { parents: 1, - interior: X1(Parachain(DEST_PARA_ID)), + interior: X1(Parachain(origin_para)), }), INITIAL_FUND, )]); @@ -44,11 +49,11 @@ fn create_agent() { let remote_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(X1(Parachain(DEST_PARA_ID))), + DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![51, 1].into(), + call: vec![51, 2].into(), }, ])); @@ -91,7 +96,9 @@ fn create_agent() { #[test] fn create_channel() { - let source_location = MultiLocation { parents: 1, interior: X1(Parachain(DEST_PARA_ID)) }; + let origin_para: u32 = 1001; + + let source_location = MultiLocation { parents: 1, interior: X1(Parachain(origin_para)) }; BridgeHubRococo::fund_accounts(vec![( BridgeHubRococo::sovereign_account_id_of(source_location), @@ -104,21 +111,21 @@ fn create_channel() { let create_agent_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(X1(Parachain(DEST_PARA_ID))), + DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![51, 1].into(), + call: vec![51, 2].into(), }, ])); let create_channel_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - DescendOrigin(X1(Parachain(DEST_PARA_ID))), + DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![51, 2].into(), + call: ([51u8, 3u8], OperatingMode::Normal, 1u128).encode().into(), }, ])); @@ -378,21 +385,25 @@ fn reserve_transfer_token() { ); let events = BridgeHubRococo::events(); assert!( - events.iter().find(|&event| matches!( - event, - RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount }) - if *who == TREASURY_ACCOUNT.into() && *amount == 16903333 - )) - .is_some(), + events + .iter() + .find(|&event| matches!( + event, + RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount }) + if *who == TREASURY_ACCOUNT.into() && *amount == 16903333 + )) + .is_some(), "Snowbridge sovereign takes local fee." ); assert!( - events.iter().find(|&event| matches!( - event, - RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount }) - if *who == ASSETHUB_SOVEREIGN.into() && *amount == 2200000000000 - )) - .is_some(), + events + .iter() + .find(|&event| matches!( + event, + RuntimeEvent::Balances(pallet_balances::Event::Deposit{ who, amount }) + if *who == ASSETHUB_SOVEREIGN.into() && *amount == 2200000000000 + )) + .is_some(), "Assethub sovereign takes remote fee." ); }); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index b8f349938e80..fe8f83e5d618 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -491,7 +491,7 @@ impl pallet_message_queue::Config for Runtime { type ServiceWeight = MessageQueueServiceWeight; type MessageProcessor = EthereumOutboundQueue; type QueueChangeHandler = (); - type QueuePausedQuery = EthereumOutboundQueue; + type QueuePausedQuery = (); type WeightInfo = (); } @@ -523,6 +523,7 @@ impl snowbridge_inbound_queue::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type XcmSender = DoNothingRouter; type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo; + type ChannelLookup = EthereumControl; type GatewayAddress = GatewayAddress; #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; @@ -544,7 +545,6 @@ impl snowbridge_outbound_queue::Config for Runtime { type Decimals = ConstU8<12>; type MaxMessagePayloadSize = ConstU32<2048>; type MaxMessagesPerBlock = ConstU32<32>; - type OwnParaId = ParachainInfo; type GasMeter = snowbridge_core::outbound::ConstantGasMeter; type Balance = Balance; type WeightToFee = WeightToFee; @@ -604,12 +604,6 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime { type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo; } -parameter_types! { - // TODO: placeholder value - choose a real one - pub const MaxUpgradeDataSize: u32 = 1024; - pub const RelayNetwork: NetworkId = Rococo; -} - #[cfg(feature = "runtime-benchmarks")] impl snowbridge_control::BenchmarkHelper for () { fn make_xcm_origin(location: xcm::latest::MultiLocation) -> RuntimeOrigin { @@ -619,9 +613,7 @@ impl snowbridge_control::BenchmarkHelper for () { impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; - type MessageHasher = BlakeTwo256; type SiblingOrigin = EnsureXcm; type AgentIdOf = xcm_config::AgentIdOf; type TreasuryAccount = TreasuryAccount; @@ -683,7 +675,7 @@ construct_runtime!( EthereumInboundQueue: snowbridge_inbound_queue::{Pallet, Call, Storage, Event} = 48, EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Call, Storage, Event} = 49, EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Storage, Event} = 50, - EthereumControl: snowbridge_control::{Pallet, Call, Storage, Event} = 51, + EthereumControl: snowbridge_control::{Pallet, Call, Storage, Config, Event} = 51, // Message Queue. Registered after EthereumOutboundQueue so that their `on_initialize` handlers // run in the desired order. diff --git a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs index ca5583fe2e53..c50c7931c879 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -325,6 +325,11 @@ pub mod rococo { owner: bridges_pallet_owner, ..Default::default() }, + ethereum_control: bridge_hub_rococo_runtime::EthereumControlConfig { + para_id: id, + asset_hub_para_id: 1000.into(), + ..Default::default() + }, } } }