From d29494f4e2bd60011b529edd36d0792e9e66fb14 Mon Sep 17 00:00:00 2001 From: David Dunn <26876072+doubledup@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:40:30 +0300 Subject: [PATCH 1/8] Fix cumulus builds --- Cargo.lock | 1 + .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 11 ++++++++--- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 10 +++------- polkadot-parachain/src/chain_spec/bridge_hubs.rs | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96731469060..23f3dc526e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13334,6 +13334,7 @@ dependencies = [ name = "snowbridge-core" version = "0.1.1" dependencies = [ + "ethabi-decode", "frame-support", "frame-system", "parity-scale-codec", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 305bc8d4272..71638fbbc70 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -69,6 +69,7 @@ use frame_system::{ }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; +use xcm::v2::NetworkId::{self, Polkadot}; use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; use bp_parachains::SingleParaStoredHeaderDataBuilder; @@ -102,6 +103,7 @@ use parachains_common::{ impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; +use xcm_builder::{EnsureXcmOrigin, SignedToAccountId32}; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -594,7 +596,6 @@ impl snowbridge_inbound_queue::Config for Runtime { type Verifier = snowbridge_ethereum_beacon_client::Pallet; type XcmSender = XcmRouter; type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo; - type AllowListLength = ConstU32<8>; #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; } @@ -667,16 +668,20 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime { } parameter_types! { - pub const GovernanceProxyContract: snowbridge_core::ContractId = snowbridge_core::ContractId::new(hex_literal::hex!("44bef07c29162ad04096f5cbe78ca2df62dffe97cea85825f08d13319e13f34a")); + // TODO: placeholder value - choose a real one + pub const MaxUpgradeDataSize: u32 = 1024; + pub const RelayNetwork: NetworkId = Polkadot; } +pub type LocalOriginToLocation = SignedToAccountId32; impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; - type GovernanceProxyContract = GovernanceProxyContract; type MessageHasher = BlakeTwo256; type WeightInfo = (); + type MaxUpgradeDataSize = MaxUpgradeDataSize; + type EnsureCreateAgentOrigin = EnsureXcmOrigin; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 1849cad76f9..8da4417848f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -57,7 +57,7 @@ parameter_types! { X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; - + // Network and location for the local Ethereum testnet. pub const EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 15 }; pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get()))); @@ -65,8 +65,8 @@ parameter_types! { // The Registry contract for the bridge which is also the origin for reserves and the prefix of all assets. pub EthereumRegistryLocation: MultiLocation = EthereumLocation::get() .pushed_with_interior( - AccountKey20 { - network: None, + AccountKey20 { + network: None, key: hex_literal::hex!("D184c103F7acc340847eEE82a0B909E3358bc28d"), } ).unwrap(); @@ -210,10 +210,6 @@ impl Contains for SafeCallFilter { >::initialize { .. }) | RuntimeCall::EthereumBeaconClient( snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. }, - ) | - RuntimeCall::EthereumInboundQueue( - snowbridge_inbound_queue::Call::add_allow_list { .. } | - snowbridge_inbound_queue::Call::remove_allow_list { .. }, ) ) } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index 45ebc4a38aa..09a7004f800 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -341,7 +341,7 @@ pub mod rococo { }, // Ethereum Bridge ethereum_inbound_queue: bridge_hub_rococo_runtime::EthereumInboundQueueConfig { - allowlist: Default::default(), + gateway: Default::default(), }, } } From eed64da407a4ccdbb1fed7b2346c5d9ab1a34303 Mon Sep 17 00:00:00 2001 From: Ron Date: Thu, 20 Jul 2023 10:35:51 +0800 Subject: [PATCH 2/8] Update cumulus (#46) --- Cargo.lock | 61 +++++++++++++------ .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 +- .../bridge-hub-rococo/src/xcm_config.rs | 16 +++-- .../src/chain_spec/bridge_hubs.rs | 3 +- 4 files changed, 60 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23f3dc526e3..5f42c51a2f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1067,7 +1067,7 @@ version = "0.1.0" dependencies = [ "bp-messages", "bp-polkadot-core", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "frame-system", "polkadot-primitives", @@ -1081,7 +1081,7 @@ version = "0.1.0" dependencies = [ "bp-bridge-hub-cumulus", "bp-messages", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "sp-api", "sp-std", @@ -1093,7 +1093,7 @@ version = "0.1.0" dependencies = [ "bp-bridge-hub-cumulus", "bp-messages", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "sp-api", "sp-std", @@ -1103,7 +1103,7 @@ dependencies = [ name = "bp-header-chain" version = "0.1.0" dependencies = [ - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "finality-grandpa", "frame-support", @@ -1123,7 +1123,7 @@ name = "bp-messages" version = "0.1.0" dependencies = [ "bp-header-chain", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "hex", "hex-literal 0.4.1", @@ -1140,7 +1140,7 @@ version = "0.1.0" dependencies = [ "bp-header-chain", "bp-polkadot-core", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "impl-trait-for-tuples", "parity-scale-codec", @@ -1155,7 +1155,7 @@ name = "bp-polkadot-core" version = "0.1.0" dependencies = [ "bp-messages", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "frame-system", "hex", @@ -1173,7 +1173,7 @@ name = "bp-relayers" version = "0.1.0" dependencies = [ "bp-messages", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "hex", "hex-literal 0.4.1", @@ -1189,7 +1189,7 @@ version = "0.1.0" dependencies = [ "bp-header-chain", "bp-polkadot-core", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "sp-api", ] @@ -1216,6 +1216,28 @@ dependencies = [ "trie-db", ] +[[package]] +name = "bp-runtime" +version = "0.1.0" +source = "git+https://github.com/Snowfork/cumulus.git?branch=snowbridge#1a8a815c224fa51a5df00a92eb28235b42defda6" +dependencies = [ + "frame-support", + "frame-system", + "hash-db", + "impl-trait-for-tuples", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "trie-db", +] + [[package]] name = "bp-test-utils" version = "0.1.0" @@ -1223,7 +1245,7 @@ dependencies = [ "bp-header-chain", "bp-parachains", "bp-polkadot-core", - "bp-runtime", + "bp-runtime 0.1.0", "ed25519-dalek", "finality-grandpa", "parity-scale-codec", @@ -1242,7 +1264,7 @@ dependencies = [ "bp-header-chain", "bp-polkadot-core", "bp-rococo", - "bp-runtime", + "bp-runtime 0.1.0", "frame-support", "sp-api", ] @@ -1384,7 +1406,7 @@ dependencies = [ "bp-polkadot-core", "bp-relayers", "bp-rococo", - "bp-runtime", + "bp-runtime 0.1.0", "bp-wococo", "bridge-hub-test-utils", "bridge-runtime-common", @@ -1474,7 +1496,7 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-relayers", - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "bridge-runtime-common", "cumulus-pallet-dmp-queue", @@ -1516,7 +1538,7 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-relayers", - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "frame-support", "frame-system", @@ -7365,7 +7387,7 @@ name = "pallet-bridge-grandpa" version = "0.1.0" dependencies = [ "bp-header-chain", - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "finality-grandpa", "frame-benchmarking", @@ -7387,7 +7409,7 @@ name = "pallet-bridge-messages" version = "0.1.0" dependencies = [ "bp-messages", - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "frame-benchmarking", "frame-support", @@ -7410,7 +7432,7 @@ dependencies = [ "bp-header-chain", "bp-parachains", "bp-polkadot-core", - "bp-runtime", + "bp-runtime 0.1.0", "bp-test-utils", "frame-benchmarking", "frame-support", @@ -7432,7 +7454,7 @@ version = "0.1.0" dependencies = [ "bp-messages", "bp-relayers", - "bp-runtime", + "bp-runtime 0.1.0", "frame-benchmarking", "frame-support", "frame-system", @@ -13374,6 +13396,7 @@ dependencies = [ name = "snowbridge-ethereum-beacon-client" version = "0.0.1" dependencies = [ + "bp-runtime 0.1.0 (git+https://github.com/Snowfork/cumulus.git?branch=snowbridge)", "byte-slice-cast", "frame-benchmarking", "frame-support", @@ -13398,6 +13421,7 @@ dependencies = [ name = "snowbridge-inbound-queue" version = "0.1.1" dependencies = [ + "bp-runtime 0.1.0 (git+https://github.com/Snowfork/cumulus.git?branch=snowbridge)", "ethabi-decode", "frame-benchmarking", "frame-support", @@ -13423,6 +13447,7 @@ dependencies = [ name = "snowbridge-outbound-queue" version = "0.1.1" dependencies = [ + "bp-runtime 0.1.0 (git+https://github.com/Snowfork/cumulus.git?branch=snowbridge)", "ethabi-decode", "frame-benchmarking", "frame-support", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 71638fbbc70..3871c7817a6 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -69,7 +69,7 @@ use frame_system::{ }; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; -use xcm::v2::NetworkId::{self, Polkadot}; +use xcm::v3::NetworkId::{self, Rococo}; use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; use bp_parachains::SingleParaStoredHeaderDataBuilder; @@ -670,7 +670,7 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime { parameter_types! { // TODO: placeholder value - choose a real one pub const MaxUpgradeDataSize: u32 = 1024; - pub const RelayNetwork: NetworkId = Polkadot; + pub const RelayNetwork: NetworkId = Rococo; } pub type LocalOriginToLocation = SignedToAccountId32; @@ -738,7 +738,7 @@ construct_runtime!( // Ethereum Bridge EthereumInboundQueue: snowbridge_inbound_queue::{Pallet, Call, Config, Storage, Event} = 48, - EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Storage, Event} = 49, + 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, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 8da4417848f..147dec3b783 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -207,10 +207,18 @@ impl Contains for SafeCallFilter { RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< Runtime, BridgeGrandpaWococoInstance, - >::initialize { .. }) | - RuntimeCall::EthereumBeaconClient( - snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. }, - ) + >::initialize { .. }) + | RuntimeCall::EthereumBeaconClient( + snowbridge_ethereum_beacon_client::Call::force_checkpoint { .. } + | snowbridge_ethereum_beacon_client::Call::set_owner { .. } + | snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. }, + ) | RuntimeCall::EthereumInboundQueue( + snowbridge_inbound_queue::Call::set_owner { .. } + | snowbridge_inbound_queue::Call::set_operating_mode { .. }, + ) | RuntimeCall::EthereumOutboundQueue( + snowbridge_outbound_queue::Call::set_owner { .. } + | snowbridge_outbound_queue::Call::set_operating_mode { .. }, + ) | RuntimeCall::EthereumControl(snowbridge_control::Call::upgrade { .. },) ) } } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index 09a7004f800..cd43858da8a 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -336,12 +336,13 @@ pub mod rococo { ..Default::default() }, bridge_wococo_messages: bridge_hub_rococo_runtime::BridgeWococoMessagesConfig { - owner: bridges_pallet_owner, + owner: bridges_pallet_owner.clone(), ..Default::default() }, // Ethereum Bridge ethereum_inbound_queue: bridge_hub_rococo_runtime::EthereumInboundQueueConfig { gateway: Default::default(), + ..Default::default() }, } } From bc252fece0c27585bf9169dde004cb93396c2738 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Thu, 20 Jul 2023 15:37:38 +0200 Subject: [PATCH 3/8] Create Agent (#47) * add hashed description * use existing account * add call filter --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 7 +++---- .../bridge-hub-rococo/src/xcm_config.rs | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 3871c7817a6..facfb31f239 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -70,7 +70,7 @@ use frame_system::{ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::v3::NetworkId::{self, Rococo}; -use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin}; +use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, LocalOriginToLocation}; use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::HeaderId; @@ -103,7 +103,7 @@ use parachains_common::{ impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; -use xcm_builder::{EnsureXcmOrigin, SignedToAccountId32}; +use xcm_builder::EnsureXcmOrigin; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -673,7 +673,6 @@ parameter_types! { pub const RelayNetwork: NetworkId = Rococo; } -pub type LocalOriginToLocation = SignedToAccountId32; impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OwnParaId = ParachainInfo; @@ -681,7 +680,7 @@ impl snowbridge_control::Config for Runtime { type MessageHasher = BlakeTwo256; type WeightInfo = (); type MaxUpgradeDataSize = MaxUpgradeDataSize; - type EnsureCreateAgentOrigin = EnsureXcmOrigin; + type CreateAgentOrigin = EnsureXcmOrigin; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index b02956129d5..e28a9672cd3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -39,11 +39,12 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, - ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, - WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, + CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, + DescribeFamily, EnsureXcmOrigin, HashedDescription, IsConcrete, ParentAsSuperuser, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, + WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ traits::{ExportXcm, WithOriginFilter}, @@ -98,6 +99,8 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, + // Foreign locations alias into accounts according to a hash of their standard description. + HashedDescription>, ); /// Means for transacting the native currency on this chain. @@ -218,7 +221,10 @@ impl Contains for SafeCallFilter { ) | RuntimeCall::EthereumOutboundQueue( snowbridge_outbound_queue::Call::set_owner { .. } | snowbridge_outbound_queue::Call::set_operating_mode { .. }, - ) | RuntimeCall::EthereumControl(snowbridge_control::Call::upgrade { .. },) + ) | RuntimeCall::EthereumControl( + snowbridge_control::Call::upgrade { .. } + | snowbridge_control::Call::create_agent { .. }, + ) ) } } From c6945210ade3a1a78e9713103b27291f67875a5b Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Sun, 23 Jul 2023 17:34:40 +0200 Subject: [PATCH 4/8] Create Agent (#48) * initial * update cargo lock * handle local accounts and pallets --- Cargo.lock | 1 + .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 1 + .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 9 +++++--- .../bridge-hub-rococo/src/xcm_config.rs | 21 ++++++++++++------- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f42c51a2f2..e49e43815f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13350,6 +13350,7 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", + "xcm-builder", ] [[package]] diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 6b4becc57f2..d77f5ab3990 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -208,6 +208,7 @@ runtime-benchmarks = [ "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", + "snowbridge-control/runtime-benchmarks", "snowbridge-core/runtime-benchmarks", "snowbridge-inbound-queue/runtime-benchmarks", "snowbridge-outbound-queue/runtime-benchmarks", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index facfb31f239..c6c246f7805 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -67,10 +67,13 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; + +use pallet_xcm::EnsureXcm; + pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::v3::NetworkId::{self, Rococo}; -use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, LocalOriginToLocation}; +use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, DescribeAgentLocation}; use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::HeaderId; @@ -103,7 +106,6 @@ use parachains_common::{ impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; -use xcm_builder::EnsureXcmOrigin; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -680,7 +682,8 @@ impl snowbridge_control::Config for Runtime { type MessageHasher = BlakeTwo256; type WeightInfo = (); type MaxUpgradeDataSize = MaxUpgradeDataSize; - type CreateAgentOrigin = EnsureXcmOrigin; + type CreateAgentOrigin = EnsureXcm; + type DescribeAgentLocation = DescribeAgentLocation; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index e28a9672cd3..48d7b463217 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -39,12 +39,12 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, - DescribeFamily, EnsureXcmOrigin, HashedDescription, IsConcrete, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, - TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, - WithComputedOrigin, WithUniqueTopic, + CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAccountId32Terminal, + DescribeAccountKey20Terminal, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, + EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ traits::{ExportXcm, WithOriginFilter}, @@ -99,8 +99,13 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, - // Foreign locations alias into accounts according to a hash of their standard description. - HashedDescription>, +); + +pub type DescribeAgentLocation = ( + DescribePalletTerminal, + DescribeAccountId32Terminal, + DescribeAccountKey20Terminal, + DescribeFamily, ); /// Means for transacting the native currency on this chain. From f59e134668a744b8c01b743350cd92775d61f3a0 Mon Sep 17 00:00:00 2001 From: David Dunn <26876072+doubledup@users.noreply.github.com> Date: Mon, 24 Jul 2023 22:40:20 +0200 Subject: [PATCH 5/8] Add set_gateway to safe call filter (#49) --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 48d7b463217..a56b6899fad 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -222,6 +222,7 @@ impl Contains for SafeCallFilter { | snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumInboundQueue( snowbridge_inbound_queue::Call::set_owner { .. } + | snowbridge_inbound_queue::Call::set_gateway { .. } | snowbridge_inbound_queue::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumOutboundQueue( snowbridge_outbound_queue::Call::set_owner { .. } From dc8f4254ad2d1a57554e646a0658f8c52bd0b70e Mon Sep 17 00:00:00 2001 From: Clara van Staden Date: Tue, 25 Jul 2023 11:28:19 +0200 Subject: [PATCH 6/8] Fix cumulus bridgehub runtime for proxy contracts. (#50) Co-authored-by: claravanstaden --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 4 +--- .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index c6c246f7805..f0f791cd77d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -81,8 +81,6 @@ use bp_runtime::HeaderId; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -pub use snowbridge_core::MessageId; - use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -593,9 +591,9 @@ impl BenchmarkHelper for Runtim impl snowbridge_inbound_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type Verifier = snowbridge_ethereum_beacon_client::Pallet; type Token = Balances; type Reward = Reward; - type Verifier = snowbridge_ethereum_beacon_client::Pallet; type XcmSender = XcmRouter; type WeightInfo = weights::snowbridge_inbound_queue::WeightInfo; #[cfg(feature = "runtime-benchmarks")] diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index a56b6899fad..fab18c808ac 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -396,7 +396,7 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter { destination, message, ) - .map(|result| ((EthereumNetwork::get(), result.0), result.1)) + .map(|result| ((EthereumNetwork::get(), (result.0, XcmHash::default())), result.1)) }, _ => unimplemented!("Unsupported network: {:?}", network), } @@ -409,7 +409,7 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter { Rococo => ToBridgeHubRococoHaulBlobExporter::deliver(ticket), Wococo => ToBridgeHubWococoHaulBlobExporter::deliver(ticket), location if location == EthereumNetwork::get() && relay == NetworkId::Rococo => { - SnowbridgeExporter::deliver(ticket) + SnowbridgeExporter::deliver(ticket.0) }, _ => unimplemented!("Unsupported network: {:?}", network), } From c0d90e08c0b4e89cabefe983c09eaec0ad3a0e81 Mon Sep 17 00:00:00 2001 From: Clara van Staden Date: Wed, 26 Jul 2023 09:24:02 +0200 Subject: [PATCH 7/8] Update inbound queue benchmarks. (#51) * Update inbound queue benchmarks. * Update inbound queue benchmarks. --------- Co-authored-by: claravanstaden --- .../src/weights/snowbridge_inbound_queue.rs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_inbound_queue.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_inbound_queue.rs index 9da9c0ef16e..830b978ea7f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_inbound_queue.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_inbound_queue.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `snowbridge_inbound_queue` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Claras-MacBook-Pro-2.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 @@ -34,10 +34,12 @@ use core::marker::PhantomData; /// Weight functions for `snowbridge_inbound_queue`. pub struct WeightInfo(PhantomData); impl snowbridge_inbound_queue::WeightInfo for WeightInfo { + /// Storage: EthereumInboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumInboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: EthereumBeaconClient ExecutionHeaders (r:1 w:0) /// Proof: EthereumBeaconClient ExecutionHeaders (max_values: None, max_size: Some(136), added: 2611, mode: MaxEncodedLen) - /// Storage: EthereumInboundQueue AllowList (r:1 w:0) - /// Proof: EthereumInboundQueue AllowList (max_values: Some(1), max_size: Some(161), added: 656, mode: MaxEncodedLen) + /// Storage: EthereumInboundQueue Gateway (r:1 w:0) + /// Proof: EthereumInboundQueue Gateway (max_values: Some(1), max_size: Some(20), added: 515, mode: MaxEncodedLen) /// Storage: EthereumInboundQueue Nonce (r:1 w:1) /// Proof: EthereumInboundQueue Nonce (max_values: None, max_size: Some(20), added: 2495, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) @@ -54,12 +56,12 @@ impl snowbridge_inbound_queue::WeightInfo for WeightInf /// Proof Skipped: ParachainSystem RelevantMessagingState (max_values: Some(1), max_size: None, mode: Measured) fn submit() -> Weight { // Proof Size summary in bytes: - // Measured: `577` - // Estimated: `4042` - // Minimum execution time: 118_000_000 picoseconds. - Weight::from_parts(125_000_000, 0) - .saturating_add(Weight::from_parts(0, 4042)) - .saturating_add(T::DbWeight::get().reads(9)) + // Measured: `575` + // Estimated: `4040` + // Minimum execution time: 98_000_000 picoseconds. + Weight::from_parts(107_000_000, 0) + .saturating_add(Weight::from_parts(0, 4040)) + .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().writes(4)) } } From c6cf3c37f94f5433ca3bfa2751083b9d1add1f35 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Fri, 28 Jul 2023 14:23:54 +0200 Subject: [PATCH 8/8] Asset transfer (#52) * update registry to gateway * added agent config * ws * increase message size --- Cargo.lock | 2 ++ .../assets/asset-hub-kusama/src/lib.rs | 2 +- .../assets/asset-hub-kusama/src/xcm_config.rs | 10 +++--- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 9 ++++-- .../bridge-hub-rococo/src/xcm_config.rs | 32 ++++++++----------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e49e43815f3..71d6eab4a6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13351,6 +13351,7 @@ dependencies = [ "sp-std", "xcm", "xcm-builder", + "xcm-executor", ] [[package]] @@ -13505,6 +13506,7 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", + "xcm-builder", "xcm-executor", ] diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index f33b38aa2a7..8858e1baebf 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -304,7 +304,7 @@ impl pallet_assets::Config for Runtime { ( FromSiblingParachain>, snowbridge_router_primitives::inbound::FromEthereumGlobalConsensus< - crate::bridging::EthereumRegistryLocation, + crate::bridging::EthereumGatewayLocation, >, ), ForeignCreatorsSovereignAccountOf, diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs index d6eda78ca10..12ad726a544 100644 --- a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -540,11 +540,11 @@ pub mod bridging { pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get()))); // The Registry contract for the bridge which is also the origin for reserves and the prefix of all assets. - pub EthereumRegistryLocation: MultiLocation = EthereumLocation::get() + pub EthereumGatewayLocation: MultiLocation = EthereumLocation::get() .pushed_with_interior( AccountKey20 { network: None, - key: hex_literal::hex!("D184c103F7acc340847eEE82a0B909E3358bc28d"), + key: hex_literal::hex!("EDa338E4dC46038493b885327842fD3E301CaB39"), } ).unwrap(); @@ -604,14 +604,14 @@ pub mod bridging { EthereumLocation::get(), AssetFilter::ByMultiLocation( MultiLocationFilter::default() - .add_starts_with(EthereumRegistryLocation::get()) + .add_starts_with(EthereumGatewayLocation::get()) ) ), ( - EthereumRegistryLocation::get(), + EthereumGatewayLocation::get(), AssetFilter::ByMultiLocation( MultiLocationFilter::default() - .add_starts_with(EthereumRegistryLocation::get()) + .add_starts_with(EthereumGatewayLocation::get()) ) ), ]; diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index f0f791cd77d..64021565c81 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -31,6 +31,7 @@ pub mod xcm_config; use constants::currency::*; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use snowbridge_beacon_primitives::{Fork, ForkVersions}; +use snowbridge_router_primitives::outbound::AgentHashedDescription; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -73,7 +74,7 @@ use pallet_xcm::EnsureXcm; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::v3::NetworkId::{self, Rococo}; -use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin, DescribeAgentLocation}; +use xcm_config::{RelayLocation, UniversalLocation, XcmConfig, XcmOriginToTransactDispatchOrigin}; use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::HeaderId; @@ -601,7 +602,7 @@ impl snowbridge_inbound_queue::Config for Runtime { } parameter_types! { - pub const MaxMessagePayloadSize: u32 = 256; + pub const MaxMessagePayloadSize: u32 = 512; pub const MaxMessagesPerBlock: u32 = 32; } @@ -681,7 +682,9 @@ impl snowbridge_control::Config for Runtime { type WeightInfo = (); type MaxUpgradeDataSize = MaxUpgradeDataSize; type CreateAgentOrigin = EnsureXcm; - type DescribeAgentLocation = DescribeAgentLocation; + type AgentHashedDescription = AgentHashedDescription; + type UniversalLocation = UniversalLocation; + type RelayLocation = RelayLocation; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index fab18c808ac..f99cafa9da7 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -33,18 +33,17 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; use polkadot_parachain::primitives::Sibling; use snowbridge_outbound_queue; -use snowbridge_router_primitives::outbound::EthereumBlobExporter; +use snowbridge_router_primitives::outbound::{AgentHashedDescription, EthereumBlobExporter}; use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, - CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAccountId32Terminal, - DescribeAccountKey20Terminal, DescribeAllTerminal, DescribeFamily, DescribePalletTerminal, - EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, + CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, + IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, + WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ traits::{ExportXcm, WithOriginFilter}, @@ -64,11 +63,11 @@ parameter_types! { pub EthereumLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(EthereumNetwork::get()))); // The Registry contract for the bridge which is also the origin for reserves and the prefix of all assets. - pub EthereumRegistryLocation: MultiLocation = EthereumLocation::get() + pub EthereumGatewayLocation: MultiLocation = EthereumLocation::get() .pushed_with_interior( AccountKey20 { network: None, - key: hex_literal::hex!("D184c103F7acc340847eEE82a0B909E3358bc28d"), + key: hex_literal::hex!("EDa338E4dC46038493b885327842fD3E301CaB39"), } ).unwrap(); } @@ -101,13 +100,6 @@ pub type LocationToAccountId = ( AccountId32Aliases, ); -pub type DescribeAgentLocation = ( - DescribePalletTerminal, - DescribeAccountId32Terminal, - DescribeAccountKey20Terminal, - DescribeFamily, -); - /// Means for transacting the native currency on this chain. pub type CurrencyTransactor = CurrencyAdapter< // Use this currency: @@ -355,8 +347,12 @@ impl cumulus_pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; } -pub type SnowbridgeExporter = - EthereumBlobExporter>; +pub type SnowbridgeExporter = EthereumBlobExporter< + UniversalLocation, + EthereumGatewayLocation, + snowbridge_outbound_queue::Pallet, + AgentHashedDescription +>; /// Hacky switch implementation, because we have just one runtime for Rococo and Wococo BridgeHub, so it means we have just one XcmConfig pub struct BridgeHubRococoOrBridgeHubWococoSwitchExporter;