From 08fbd55ee4479c7f2749bbfedd0785a67f15e031 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Sun, 12 Nov 2023 11:29:56 +0200 Subject: [PATCH 1/4] runtime changes for channel-id --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 12 +++-------- .../src/chain_spec/bridge_hubs.rs | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) 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 073e44558744..2718bde301fd 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 @@ -100,8 +100,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use crate::{ bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages, - bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages, - xcm_config::XcmRouter, + bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages, xcm_config::XcmRouter, }; use parachains_common::{ impls::DealWithFees, @@ -598,12 +597,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 { @@ -613,6 +606,7 @@ impl snowbridge_control::BenchmarkHelper for () { impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type AssetHubParaId = bridge_hub_rococo_config::AssetHubRococoParaId; type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; type MessageHasher = BlakeTwo256; @@ -677,7 +671,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..268e1fc0aa71 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -252,6 +252,26 @@ pub mod rococo { bridges_pallet_owner_seed .as_ref() .map(|seed| get_account_id_from_seed::(seed)), + snowbridge_agents: vec![ + bridge_hub_rococo_runtime::AssetHubAgentId::get(), + bridge_hub_rococo_runtime::BridgeHubAgentId::get(), + ], + snowbridge_channels: vec![ + ( + bridge_hub_rococo_runtime::AssetHubChannelId::get(), + Channel { + agent_id: bridge_hub_rococo_runtime::AssetHubAgentId::get(), + para_id: bridge_hub_rococo_runtime::AssetHubParaId::get(), + } + ), + ( + bridge_hub_rococo_runtime::BridgeHubChannelId::get(), + Channel { + agent_id: bridge_hub_rococo_runtime::BridgeHubAgentId::get(), + para_id: bridge_hub_rococo_runtime::BridgeHubParaId::get(), + } + ) + ] ) }, Vec::new(), @@ -325,6 +345,7 @@ pub mod rococo { owner: bridges_pallet_owner, ..Default::default() }, + ethereum_control: Default::default() } } } From dcf920699d88a34650582be7817bd447d514d406 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Mon, 13 Nov 2023 17:31:02 +0200 Subject: [PATCH 2/4] update bridge-hub-rococo config --- Cargo.lock | 1 + .../bridge-hub-rococo/src/tests/snowbridge.rs | 51 +++++++++++-------- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 7 +-- .../src/chain_spec/bridge_hubs.rs | 6 ++- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2c91f68609b..18483e69bcf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17134,6 +17134,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 e5419d1b7674..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; @@ -613,10 +613,7 @@ impl snowbridge_control::BenchmarkHelper for () { impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type AssetHubParaId = bridge_hub_rococo_config::AssetHubRococoParaId; - type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; - type MessageHasher = BlakeTwo256; type SiblingOrigin = EnsureXcm; type AgentIdOf = xcm_config::AgentIdOf; type TreasuryAccount = TreasuryAccount; diff --git a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs index 268e1fc0aa71..e3282fc878c9 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -20,6 +20,7 @@ use parachains_common::Balance as BridgeHubBalance; use sc_chain_spec::ChainSpec; use sp_core::sr25519; use std::{path::PathBuf, str::FromStr}; +use hex_literal::hex; /// Collects all supported BridgeHub configurations #[derive(Debug, PartialEq)] @@ -345,7 +346,10 @@ pub mod rococo { owner: bridges_pallet_owner, ..Default::default() }, - ethereum_control: Default::default() + ethereum_control: bridge_hub_rococo_runtime::EthereumControlConfig { + para_id: id, + asset_hub_para_id: 1000.into(), + } } } } From e7e815dafbdae2fdca01d72e4b3bf59dcee1b82d Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Mon, 13 Nov 2023 19:17:21 +0200 Subject: [PATCH 3/4] Fix chainspec for bridge-hub-rococo --- .../src/chain_spec/bridge_hubs.rs | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs index e3282fc878c9..c50c7931c879 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -20,7 +20,6 @@ use parachains_common::Balance as BridgeHubBalance; use sc_chain_spec::ChainSpec; use sp_core::sr25519; use std::{path::PathBuf, str::FromStr}; -use hex_literal::hex; /// Collects all supported BridgeHub configurations #[derive(Debug, PartialEq)] @@ -253,26 +252,6 @@ pub mod rococo { bridges_pallet_owner_seed .as_ref() .map(|seed| get_account_id_from_seed::(seed)), - snowbridge_agents: vec![ - bridge_hub_rococo_runtime::AssetHubAgentId::get(), - bridge_hub_rococo_runtime::BridgeHubAgentId::get(), - ], - snowbridge_channels: vec![ - ( - bridge_hub_rococo_runtime::AssetHubChannelId::get(), - Channel { - agent_id: bridge_hub_rococo_runtime::AssetHubAgentId::get(), - para_id: bridge_hub_rococo_runtime::AssetHubParaId::get(), - } - ), - ( - bridge_hub_rococo_runtime::BridgeHubChannelId::get(), - Channel { - agent_id: bridge_hub_rococo_runtime::BridgeHubAgentId::get(), - para_id: bridge_hub_rococo_runtime::BridgeHubParaId::get(), - } - ) - ] ) }, Vec::new(), @@ -349,7 +328,8 @@ pub mod rococo { ethereum_control: bridge_hub_rococo_runtime::EthereumControlConfig { para_id: id, asset_hub_para_id: 1000.into(), - } + ..Default::default() + }, } } } From 42c125867975a22dc51eeec8001a56eba9d511e8 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Mon, 13 Nov 2023 20:40:50 +0200 Subject: [PATCH 4/4] bump Cargo.lock --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index 18483e69bcf3..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",