From 91fbcec128f7d9f8279ca351389a7eede0987cd8 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 29 Aug 2023 08:51:24 +0800 Subject: [PATCH 01/26] Upgrade for Control pallet --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 1 + .../src/weights/snowbridge_control.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) 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 aaec18c20c2..a025f86e30d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -686,6 +686,7 @@ impl snowbridge_control::Config for Runtime { type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; + type Token = Balances; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs index 5f679d24ddf..01de69f4a83 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs @@ -124,4 +124,15 @@ impl snowbridge_control::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } + + fn update_operation_fee() -> Weight { + // Proof Size summary in bytes: + // Measured: `84` + // Estimated: `3517` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(35_000_000, 0) + .saturating_add(Weight::from_parts(0, 3517)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } } From a2c518af0ff84794077e194bbf7cdade4b19df9b Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 31 Aug 2023 11:07:21 +0800 Subject: [PATCH 02/26] Update dependency --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index ac7cba187b3..65b8e45fd4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13348,6 +13348,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "snowbridge-core", + "snowbridge-router-primitives", "sp-core", "sp-io", "sp-runtime", From 3496ebc9eb4e7ee227bdfad1772163047a0d836d Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 31 Aug 2023 19:51:32 +0800 Subject: [PATCH 03/26] Allow utility call through xcm --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 287fe2965ef..f42c9c81140 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 @@ -199,7 +199,7 @@ impl Contains for SafeCallFilter { ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | RuntimeCall::XcmpQueue(..) | RuntimeCall::DmpQueue(..) - | RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + | RuntimeCall::Utility(..) | RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< Runtime, BridgeGrandpaRococoInstance, From d83bdb3d1b8dba0a20d5b27b32cc2fc5dbace64a Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 31 Aug 2023 21:27:55 +0800 Subject: [PATCH 04/26] Add SovereignAccountOf --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 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 a025f86e30d..0035965bc05 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -31,7 +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 snowbridge_router_primitives::outbound::{AgentAccountDescription, AgentHashedDescription}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -681,7 +681,8 @@ impl snowbridge_control::Config for Runtime { type MessageHasher = BlakeTwo256; type WeightInfo = weights::snowbridge_control::WeightInfo; type MaxUpgradeDataSize = MaxUpgradeDataSize; - type AgentHashedDescription = AgentHashedDescription; + type AgentIdOf = AgentHashedDescription; + type SovereignAccountOf = AgentAccountDescription; type UniversalLocation = UniversalLocation; type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; From 37413ddcc801a55a1f4513be07d6c20c1921ffc1 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 4 Sep 2023 23:52:57 +0800 Subject: [PATCH 05/26] More refactor --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 8 +++++--- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 4 ++-- 2 files changed, 7 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 0035965bc05..161676e91f9 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -31,7 +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::{AgentAccountDescription, AgentHashedDescription}; +use snowbridge_router_primitives::outbound::{AgentIdOf, SovereignAccountOf}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -672,6 +672,7 @@ parameter_types! { // TODO: placeholder value - choose a real one pub const MaxUpgradeDataSize: u32 = 1024; pub const RelayNetwork: NetworkId = Rococo; + pub const ControlPalletId: PalletId = PalletId(*b"snow/ctl"); } impl snowbridge_control::Config for Runtime { @@ -681,13 +682,14 @@ impl snowbridge_control::Config for Runtime { type MessageHasher = BlakeTwo256; type WeightInfo = weights::snowbridge_control::WeightInfo; type MaxUpgradeDataSize = MaxUpgradeDataSize; - type AgentIdOf = AgentHashedDescription; - type SovereignAccountOf = AgentAccountDescription; + type AgentIdOf = AgentIdOf; + type SovereignAccountOf = SovereignAccountOf; type UniversalLocation = UniversalLocation; type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; type Token = Balances; + type ControlPalletId = ControlPalletId; } // 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 f42c9c81140..14ad4139c82 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,7 +33,7 @@ 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::{AgentHashedDescription, EthereumBlobExporter}; +use snowbridge_router_primitives::outbound::{AgentIdOf, EthereumBlobExporter}; use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ @@ -348,7 +348,7 @@ pub type SnowbridgeExporter = EthereumBlobExporter< UniversalLocation, EthereumGatewayLocation, snowbridge_outbound_queue::Pallet, - AgentHashedDescription + AgentIdOf, >; /// Hacky switch implementation, because we have just one runtime for Rococo and Wococo BridgeHub, so it means we have just one XcmConfig From 3a7d5dd95e25668506ef3727f1990772eeef809c Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 5 Sep 2023 08:56:46 +0800 Subject: [PATCH 06/26] Add FeeProvider config --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 161676e91f9..be2da31072c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -673,6 +673,16 @@ parameter_types! { pub const MaxUpgradeDataSize: u32 = 1024; pub const RelayNetwork: NetworkId = Rococo; pub const ControlPalletId: PalletId = PalletId(*b"snow/ctl"); + + // Multiplier based on gas report as follows,assume gas cost for a no-op operation is 1000 + // | createAgent | 839 | 184709 | 237187 | 237187 | 9 | + // | createChannel | 399 | 31023 | 2829 | 75402 | 5 | + // | updateChannel | 817 | 15121 | 3552 | 36762 | 5 | + // | transferNativeFromAgent | 770 | 21730 | 21730 | 42691 | 2 | + pub const CreateAgentMultiplier: u128 = 237; + pub const CreateChannelMultiplier: u128 = 75; + pub const UpdateChannelMultiplier: u128 = 37; + pub const TransferNativeFromAgentMultiplier: u128 = 43; } impl snowbridge_control::Config for Runtime { @@ -690,6 +700,11 @@ impl snowbridge_control::Config for Runtime { type ChannelOrigin = EnsureXcm; type Token = Balances; type ControlPalletId = ControlPalletId; + type CreateAgentMultiplier = CreateAgentMultiplier; + type CreateChannelMultiplier = CreateChannelMultiplier; + type UpdateChannelMultiplier = UpdateChannelMultiplier; + type TransferNativeFromAgentMultiplier = TransferNativeFromAgentMultiplier; + type FeeProvider = EthereumOutboundQueue; } // Create the runtime by composing the FRAME pallets that were previously configured. From 9f68486a2acf7c4491e154bf24084d5119e67bc6 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 5 Sep 2023 10:35:14 +0800 Subject: [PATCH 07/26] Allow xcm to config base_fee --- .../bridge-hubs/bridge-hub-rococo/src/xcm_config.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 14ad4139c82..563b8e5b895 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 @@ -216,10 +216,8 @@ impl Contains for SafeCallFilter { 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 { .. } | - snowbridge_outbound_queue::Call::set_operating_mode { .. }, - ) | RuntimeCall::EthereumControl(..) + ) | RuntimeCall::EthereumOutboundQueue(..) + | RuntimeCall::EthereumControl(..) ) } } From 9bb56aa608eb4899118a43328a55825618e8a36e Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 5 Sep 2023 12:40:19 +0800 Subject: [PATCH 08/26] Remove unused --- .../src/weights/snowbridge_control.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs index 01de69f4a83..5f679d24ddf 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs @@ -124,15 +124,4 @@ impl snowbridge_control::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } - - fn update_operation_fee() -> Weight { - // Proof Size summary in bytes: - // Measured: `84` - // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) - .saturating_add(Weight::from_parts(0, 3517)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } } From 7e62e96a7ed7b68dd952bedf7b8e1e7dea943c35 Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 13 Sep 2023 08:45:43 +0800 Subject: [PATCH 09/26] Move config to outbound queue --- Cargo.lock | 2 ++ .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65b8e45fd4a..c1b778a3d79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13470,6 +13470,8 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", + "xcm-builder", + "xcm-executor", ] [[package]] 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 aa62f9803a7..5dc60a4f898 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -609,6 +609,7 @@ impl snowbridge_inbound_queue::Config for Runtime { parameter_types! { pub const MaxMessagePayloadSize: u32 = 2048; pub const MaxMessagesPerBlock: u32 = 32; + pub const LocalPalletId: PalletId = PalletId(*b"snow/out"); } impl snowbridge_outbound_queue::Config for Runtime { @@ -617,6 +618,9 @@ impl snowbridge_outbound_queue::Config for Runtime { type MessageQueue = MessageQueue; type MaxMessagePayloadSize = MaxMessagePayloadSize; type MaxMessagesPerBlock = MaxMessagesPerBlock; + type LocalPalletId = LocalPalletId; + type SovereignAccountOf = SovereignAccountOf; + type Token = Balances; type WeightInfo = (); } @@ -698,18 +702,10 @@ impl snowbridge_control::Config for Runtime { type WeightInfo = weights::snowbridge_control::WeightInfo; type MaxUpgradeDataSize = MaxUpgradeDataSize; type AgentIdOf = AgentIdOf; - type SovereignAccountOf = SovereignAccountOf; type UniversalLocation = UniversalLocation; type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; - type Token = Balances; - type ControlPalletId = ControlPalletId; - type CreateAgentMultiplier = CreateAgentMultiplier; - type CreateChannelMultiplier = CreateChannelMultiplier; - type UpdateChannelMultiplier = UpdateChannelMultiplier; - type TransferNativeFromAgentMultiplier = TransferNativeFromAgentMultiplier; - type FeeProvider = EthereumOutboundQueue; } // Create the runtime by composing the FRAME pallets that were previously configured. From 0e14a70f546fbd48413422b7acacae4c9237efec Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 13 Sep 2023 20:22:32 +0800 Subject: [PATCH 10/26] Update dependency --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c1b778a3d79..5595dcb069d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13348,7 +13348,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "snowbridge-core", - "snowbridge-router-primitives", "sp-core", "sp-io", "sp-runtime", From d84ae93a01f5803f6187753d381b7252d667a697 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 22 Sep 2023 09:30:10 +0800 Subject: [PATCH 11/26] Use Treasury account to collect fees --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 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 5dc60a4f898..3126dfb8f47 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -609,7 +609,7 @@ impl snowbridge_inbound_queue::Config for Runtime { parameter_types! { pub const MaxMessagePayloadSize: u32 = 2048; pub const MaxMessagesPerBlock: u32 = 32; - pub const LocalPalletId: PalletId = PalletId(*b"snow/out"); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); } impl snowbridge_outbound_queue::Config for Runtime { @@ -618,7 +618,7 @@ impl snowbridge_outbound_queue::Config for Runtime { type MessageQueue = MessageQueue; type MaxMessagePayloadSize = MaxMessagePayloadSize; type MaxMessagesPerBlock = MaxMessagesPerBlock; - type LocalPalletId = LocalPalletId; + type LocalPalletId = TreasuryPalletId; type SovereignAccountOf = SovereignAccountOf; type Token = Balances; type WeightInfo = (); From 1a1ab19a6e0d4449211ee24897ee7211b72cf9a1 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 22 Sep 2023 09:37:17 +0800 Subject: [PATCH 12/26] Remove unused const --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 11 ----------- 1 file changed, 11 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 3126dfb8f47..0415a73bb75 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -681,17 +681,6 @@ parameter_types! { // TODO: placeholder value - choose a real one pub const MaxUpgradeDataSize: u32 = 1024; pub const RelayNetwork: NetworkId = Rococo; - pub const ControlPalletId: PalletId = PalletId(*b"snow/ctl"); - - // Multiplier based on gas report as follows,assume gas cost for a no-op operation is 1000 - // | createAgent | 839 | 184709 | 237187 | 237187 | 9 | - // | createChannel | 399 | 31023 | 2829 | 75402 | 5 | - // | updateChannel | 817 | 15121 | 3552 | 36762 | 5 | - // | transferNativeFromAgent | 770 | 21730 | 21730 | 42691 | 2 | - pub const CreateAgentMultiplier: u128 = 237; - pub const CreateChannelMultiplier: u128 = 75; - pub const UpdateChannelMultiplier: u128 = 37; - pub const TransferNativeFromAgentMultiplier: u128 = 43; } impl snowbridge_control::Config for Runtime { From f15a7522499cf65fdc7c2c4ee1d2f47e44757f9d Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 22 Sep 2023 22:41:39 +0800 Subject: [PATCH 13/26] Add configs --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 0415a73bb75..fc1580d0c67 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -609,7 +609,6 @@ impl snowbridge_inbound_queue::Config for Runtime { parameter_types! { pub const MaxMessagePayloadSize: u32 = 2048; pub const MaxMessagesPerBlock: u32 = 32; - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); } impl snowbridge_outbound_queue::Config for Runtime { @@ -618,9 +617,6 @@ impl snowbridge_outbound_queue::Config for Runtime { type MessageQueue = MessageQueue; type MaxMessagePayloadSize = MaxMessagePayloadSize; type MaxMessagesPerBlock = MaxMessagesPerBlock; - type LocalPalletId = TreasuryPalletId; - type SovereignAccountOf = SovereignAccountOf; - type Token = Balances; type WeightInfo = (); } @@ -681,6 +677,7 @@ parameter_types! { // TODO: placeholder value - choose a real one pub const MaxUpgradeDataSize: u32 = 1024; pub const RelayNetwork: NetworkId = Rococo; + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); } impl snowbridge_control::Config for Runtime { @@ -695,6 +692,9 @@ impl snowbridge_control::Config for Runtime { type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; + type LocalPalletId = TreasuryPalletId; + type SovereignAccountOf = SovereignAccountOf; + type Token = Balances; } // Create the runtime by composing the FRAME pallets that were previously configured. From 722d098e225028a240d8f45996bcd6a7127f8784 Mon Sep 17 00:00:00 2001 From: ron Date: Sat, 23 Sep 2023 10:08:47 +0800 Subject: [PATCH 14/26] Clean dependencies --- Cargo.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5595dcb069d..ac7cba187b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13469,8 +13469,6 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", - "xcm-builder", - "xcm-executor", ] [[package]] From aa52862edd9257aa5ef0cda1a72d48cd174359c0 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 26 Sep 2023 23:05:23 +0800 Subject: [PATCH 15/26] Add estimate rpc --- Cargo.lock | 2 ++ .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ac7cba187b3..9dfe2cec077 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13486,10 +13486,12 @@ name = "snowbridge-outbound-queue-runtime-api" version = "0.1.0" dependencies = [ "parity-scale-codec", + "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", "sp-api", "sp-core", "sp-std", + "xcm", ] [[package]] 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 fc1580d0c67..ce73c84228e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -101,10 +101,12 @@ use bridge_runtime_common::{ messages::{source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter}, messages_xcm_extension::{XcmAsPlainPayload, XcmBlobMessageDispatch}, }; +use cumulus_primitives_core::MultiAssets; 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 snowbridge_core::outbound::{Message, SubmitError}; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -1041,6 +1043,10 @@ impl_runtime_apis! { fn prove_message(leaf_index: u64) -> Option { snowbridge_outbound_queue::api::prove_message::(leaf_index) } + + fn estimate_fee(message: &Message) -> Result { + snowbridge_outbound_queue::api::estimate_fee::(message) + } } #[cfg(feature = "try-runtime")] From 3e1db633a2031947fb656d802551117de60f37e6 Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 27 Sep 2023 08:03:28 +0800 Subject: [PATCH 16/26] Add runtime api --- Cargo.lock | 1 + .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 9dfe2cec077..b7a5654d8da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13361,6 +13361,7 @@ dependencies = [ name = "snowbridge-core" version = "0.1.1" dependencies = [ + "derivative", "ethabi-decode", "frame-support", "frame-system", 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 ce73c84228e..a5e341d8273 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -106,7 +106,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 snowbridge_core::outbound::{Message, SubmitError}; +use snowbridge_core::outbound::{CommandIndex, Message, SubmitError}; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -1047,6 +1047,10 @@ impl_runtime_apis! { fn estimate_fee(message: &Message) -> Result { snowbridge_outbound_queue::api::estimate_fee::(message) } + + fn estimate_fee_by_command_index(command_index: CommandIndex) -> Result { + snowbridge_outbound_queue::api::estimate_fee_by_command_index::(command_index) + } } #[cfg(feature = "try-runtime")] From 304c89698a371772fe6dd343f5ee07ba400848b2 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 28 Sep 2023 01:14:23 +0800 Subject: [PATCH 17/26] runtime api for compute_fee_reward --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 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 a5e341d8273..a4edc4af738 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -30,10 +30,8 @@ pub mod xcm_config; use constants::currency::*; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_router_primitives::outbound::{AgentIdOf, SovereignAccountOf}; use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, H160, OpaqueMetadata}; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, Keccak256}, @@ -41,20 +39,20 @@ use sp_runtime::{ ApplyExtrinsicResult, }; -use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; #[cfg(feature = "runtime-benchmarks")] -pub use snowbridge_ethereum_beacon_client::ExecutionHeaderBuffer; +use snowbridge_beacon_primitives::CompactExecutionHeader; #[cfg(feature = "runtime-benchmarks")] use snowbridge_core::RingBufferMap; #[cfg(feature = "runtime-benchmarks")] -use snowbridge_inbound_queue::BenchmarkHelper; +pub use snowbridge_ethereum_beacon_client::ExecutionHeaderBuffer; #[cfg(feature = "runtime-benchmarks")] -use snowbridge_beacon_primitives::CompactExecutionHeader; +use snowbridge_inbound_queue::BenchmarkHelper; #[cfg(feature = "runtime-benchmarks")] use sp_core::H256; +use sp_std::prelude::*; +#[cfg(feature = "std")] +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, @@ -74,7 +72,10 @@ 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::{EthereumGatewayAddress, RelayLocation, UniversalLocation, XcmConfig, XcmOriginToTransactDispatchOrigin}; +use xcm_config::{ + EthereumGatewayAddress, RelayLocation, UniversalLocation, XcmConfig, + XcmOriginToTransactDispatchOrigin, +}; use bp_parachains::SingleParaStoredHeaderDataBuilder; use bp_runtime::HeaderId; @@ -101,12 +102,13 @@ use bridge_runtime_common::{ messages::{source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter}, messages_xcm_extension::{XcmAsPlainPayload, XcmBlobMessageDispatch}, }; -use cumulus_primitives_core::MultiAssets; 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 snowbridge_core::outbound::{CommandIndex, Message, SubmitError}; +use snowbridge_beacon_primitives::{Fork, ForkVersions}; +use snowbridge_core::outbound::{CommandIndex, FeeAmount, Message, SubmitError}; +use snowbridge_router_primitives::outbound::{AgentIdOf, SovereignAccountOf}; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -1044,12 +1046,12 @@ impl_runtime_apis! { snowbridge_outbound_queue::api::prove_message::(leaf_index) } - fn estimate_fee(message: &Message) -> Result { - snowbridge_outbound_queue::api::estimate_fee::(message) + fn compute_fee_reward(message: &Message) -> Result<(FeeAmount, FeeAmount), SubmitError> { + snowbridge_outbound_queue::api::compute_fee_reward::(message) } - fn estimate_fee_by_command_index(command_index: CommandIndex) -> Result { - snowbridge_outbound_queue::api::estimate_fee_by_command_index::(command_index) + fn compute_fee_reward_by_command_index(command_index: CommandIndex) -> Result<(FeeAmount, FeeAmount), SubmitError> { + snowbridge_outbound_queue::api::compute_fee_reward_by_command_index::(command_index) } } From 98cffe28041ab62643f853b2b33c0645a938d73c Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 28 Sep 2023 09:03:16 +0800 Subject: [PATCH 18/26] Use TreasuryAccount more specific --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 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 a4edc4af738..2ef667665e9 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -84,6 +84,7 @@ use bp_runtime::HeaderId; pub use sp_runtime::BuildStorage; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; +use sp_runtime::traits::AccountIdConversion; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use crate::{ @@ -681,7 +682,7 @@ parameter_types! { // TODO: placeholder value - choose a real one pub const MaxUpgradeDataSize: u32 = 1024; pub const RelayNetwork: NetworkId = Rococo; - pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating(); } impl snowbridge_control::Config for Runtime { @@ -696,7 +697,7 @@ impl snowbridge_control::Config for Runtime { type RelayLocation = RelayLocation; type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; - type LocalPalletId = TreasuryPalletId; + type TreasuryAccount = TreasuryAccount; type SovereignAccountOf = SovereignAccountOf; type Token = Balances; } From 870bf36630a60c1a6e0debb4a7a495900f063672 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 28 Sep 2023 14:15:38 +0800 Subject: [PATCH 19/26] Cleanup --- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 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 2ef667665e9..6ea7625a73c 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -108,7 +108,7 @@ use parachains_common::{ AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_core::outbound::{CommandIndex, FeeAmount, Message, SubmitError}; +use snowbridge_core::outbound::{FeeAmount, Message, SubmitError}; use snowbridge_router_primitives::outbound::{AgentIdOf, SovereignAccountOf}; use xcm_executor::XcmExecutor; @@ -1050,10 +1050,6 @@ impl_runtime_apis! { fn compute_fee_reward(message: &Message) -> Result<(FeeAmount, FeeAmount), SubmitError> { snowbridge_outbound_queue::api::compute_fee_reward::(message) } - - fn compute_fee_reward_by_command_index(command_index: CommandIndex) -> Result<(FeeAmount, FeeAmount), SubmitError> { - snowbridge_outbound_queue::api::compute_fee_reward_by_command_index::(command_index) - } } #[cfg(feature = "try-runtime")] From e3d87a17c0cd90dbf941b29223737cdb595732c7 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Tue, 3 Oct 2023 21:43:30 +0300 Subject: [PATCH 20/26] Update rococo runtime --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 27 ++++++++++++++++--- .../bridge-hub-rococo/src/xcm_config.rs | 14 +++++++++- 2 files changed, 37 insertions(+), 4 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 6ea7625a73c..89b16dadb57 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -622,6 +622,10 @@ impl snowbridge_outbound_queue::Config for Runtime { type MessageQueue = MessageQueue; type MaxMessagePayloadSize = MaxMessagePayloadSize; type MaxMessagesPerBlock = MaxMessagesPerBlock; + type GasMeter = snowbridge_core::outbound::ConstantGasMeter; + type Balance = Balance; + type Fee = ConstU128<10>; + type Reward = ConstU128<10>; type WeightInfo = (); } @@ -685,6 +689,22 @@ parameter_types! { pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating(); } +/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used +/// when determining sovereign accounts for asset transacting. +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the parent `AccountId`. + ParentIsPreset, + // Sibling parachain origins convert to AccountId via the `ParaId::into`. + SiblingParachainConvertsVia, + // Straight up local `AccountId32` origins just alias directly to `AccountId`. + AccountId32Aliases, + // Other nested consensus systems on sibling parachains or relay chain. + HashedDescription> +); + +// CreateAgent: allow consensus systems on sibling parachains + + impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OwnParaId = ParachainInfo; @@ -695,10 +715,11 @@ impl snowbridge_control::Config for Runtime { type AgentIdOf = AgentIdOf; type UniversalLocation = UniversalLocation; type RelayLocation = RelayLocation; - type AgentOrigin = EnsureXcm; - type ChannelOrigin = EnsureXcm; + type AgentOrigin = EnsureXcm; + type ChannelOrigin = EnsureXcm; type TreasuryAccount = TreasuryAccount; - type SovereignAccountOf = SovereignAccountOf; + type SovereignAccountOf = LocationToAccountId; + type Fee = ConstU128<10>; type Token = Balances; } 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 cfea785ea25..a4eb85be1e8 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 @@ -216,7 +216,7 @@ impl Contains for SafeCallFilter { ) | RuntimeCall::EthereumInboundQueue( snowbridge_inbound_queue::Call::set_owner { .. } | snowbridge_inbound_queue::Call::set_operating_mode { .. }, - ) | RuntimeCall::EthereumOutboundQueue(..) + ) | RuntimeCall::EthereumOutboundQueue(..) | RuntimeCall::EthereumControl(..) ) } @@ -433,3 +433,15 @@ impl Contains for AllowSiblingsOnly { } } } + +/// [`Contains`] implementation that allows multiLocation from sibling chains and children of sibling chains. +pub struct AllowSiblingsChildrenOnly; +impl Contains for AllowSiblingsChildrenOnly { + fn contains(l: &MultiLocation) -> bool { + match l.split_first_interior() { + (MultiLocation { parents: 1, .. }, Some(Parachain(_))) => true, + _ => false, + + } + } +} From 3677f64c3c882d033ff639271becf069bc9d8cfb Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Wed, 4 Oct 2023 10:30:19 +0300 Subject: [PATCH 21/26] update --- Cargo.lock | 1 + .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 35 ++++--------------- .../bridge-hub-rococo/src/xcm_config.rs | 17 +++++++-- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b7a5654d8da..296bb808348 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13465,6 +13465,7 @@ dependencies = [ "serde", "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", 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 89b16dadb57..01cb9e53d85 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -58,7 +58,7 @@ use frame_support::{ construct_runtime, dispatch::DispatchClass, parameter_types, - traits::{ConstBool, ConstU32, ConstU64, ConstU8, Everything}, + traits::{ConstBool, ConstU32, ConstU64, ConstU8, ConstU128, Everything}, weights::{ConstantMultiplier, Weight}, PalletId, }; @@ -97,7 +97,7 @@ use crate::{ WithBridgeHubRococoMessageBridge, }, constants::fee::WeightToFee, - xcm_config::{AllowSiblingsOnly, XcmRouter}, + xcm_config::XcmRouter, }; use bridge_runtime_common::{ messages::{source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter}, @@ -108,8 +108,6 @@ use parachains_common::{ AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; use snowbridge_beacon_primitives::{Fork, ForkVersions}; -use snowbridge_core::outbound::{FeeAmount, Message, SubmitError}; -use snowbridge_router_primitives::outbound::{AgentIdOf, SovereignAccountOf}; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -689,38 +687,21 @@ parameter_types! { pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating(); } -/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used -/// when determining sovereign accounts for asset transacting. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the parent `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, - // Other nested consensus systems on sibling parachains or relay chain. - HashedDescription> -); - -// CreateAgent: allow consensus systems on sibling parachains - - impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; type MessageHasher = BlakeTwo256; - type WeightInfo = weights::snowbridge_control::WeightInfo; - type MaxUpgradeDataSize = MaxUpgradeDataSize; - type AgentIdOf = AgentIdOf; + type AgentIdOf = xcm_config::AgentIdOf; type UniversalLocation = UniversalLocation; type RelayLocation = RelayLocation; - type AgentOrigin = EnsureXcm; + type AgentOrigin = EnsureXcm; type ChannelOrigin = EnsureXcm; type TreasuryAccount = TreasuryAccount; - type SovereignAccountOf = LocationToAccountId; + type SovereignAccountOf = xcm_config::SovereignAccountOf; type Fee = ConstU128<10>; type Token = Balances; + type WeightInfo = weights::snowbridge_control::WeightInfo; } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -1067,10 +1048,6 @@ impl_runtime_apis! { fn prove_message(leaf_index: u64) -> Option { snowbridge_outbound_queue::api::prove_message::(leaf_index) } - - fn compute_fee_reward(message: &Message) -> Result<(FeeAmount, FeeAmount), SubmitError> { - snowbridge_outbound_queue::api::compute_fee_reward::(message) - } } #[cfg(feature = "try-runtime")] 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 a4eb85be1e8..649aabfa990 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,8 +33,8 @@ 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::{AgentIdOf, EthereumBlobExporter}; -use sp_core::Get; +use snowbridge_router_primitives::outbound::EthereumBlobExporter; +use sp_core::{H256, Get}; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -45,6 +45,8 @@ use xcm_builder::{ SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; +use xcm_builder::{HashedDescription, DescribeFamily, DescribeAllTerminal}; + use xcm_executor::{ traits::{ExportXcm, WithOriginFilter}, XcmExecutor, @@ -358,6 +360,17 @@ impl cumulus_pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; } +pub type AgentIdOf = HashedDescription>; + +/// Ethereum control pallet: Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used +/// when determining sovereign accounts for asset transacting +pub type SovereignAccountOf = ( + // Relay chain, sibling parachains, and local children + LocationToAccountId, + // Other nested consensus systems on sibling parachains + HashedDescription>, +); + pub type SnowbridgeExporter = EthereumBlobExporter< UniversalLocation, EthereumGatewayLocation, From 3c7bd12c28cf32e192e4e5d8381b20ae51fab83e Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Wed, 4 Oct 2023 16:20:12 +0300 Subject: [PATCH 22/26] Update weights --- .../bridge-hub-rococo/src/weights/snowbridge_control.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs index 5f679d24ddf..e7cc3355e0b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs @@ -45,7 +45,7 @@ impl snowbridge_control::WeightInfo for WeightInfo { /// Storage: MessageQueue Pages (r:0 w:1) /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) /// The range of component `x` is `[0, 1023]`. - fn upgrade(x: u32, ) -> Weight { + fn upgrade() -> Weight { // Proof Size summary in bytes: // Measured: `80` // Estimated: `3517` @@ -53,7 +53,7 @@ impl snowbridge_control::WeightInfo for WeightInfo { Weight::from_parts(30_740_411, 0) .saturating_add(Weight::from_parts(0, 3517)) // Standard Error: 66 - .saturating_add(Weight::from_parts(8_805, 0).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(8_805, 0).saturating_mul(256)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } From 28e108bbfc2eccb0aeb185970f37ac634d8d0a6e Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 5 Oct 2023 14:15:40 +0800 Subject: [PATCH 23/26] Fix for smoke test --- parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 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 01cb9e53d85..bb5169b0b28 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -58,7 +58,7 @@ use frame_support::{ construct_runtime, dispatch::DispatchClass, parameter_types, - traits::{ConstBool, ConstU32, ConstU64, ConstU8, ConstU128, Everything}, + traits::{ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Everything}, weights::{ConstantMultiplier, Weight}, PalletId, }; @@ -699,7 +699,7 @@ impl snowbridge_control::Config for Runtime { type ChannelOrigin = EnsureXcm; type TreasuryAccount = TreasuryAccount; type SovereignAccountOf = xcm_config::SovereignAccountOf; - type Fee = ConstU128<10>; + type Fee = ConstU128<100000000000>; //should be enough to cover the existentialDeposit type Token = Balances; type WeightInfo = weights::snowbridge_control::WeightInfo; } From 5508ea93c20744353df2485fd65389aef8a30e88 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Sun, 8 Oct 2023 21:42:07 +0300 Subject: [PATCH 24/26] Update rococo runtime --- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 11 +++------ .../bridge-hub-rococo/src/xcm_config.rs | 23 ------------------- 2 files changed, 3 insertions(+), 31 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 bb5169b0b28..644e9252672 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -681,9 +681,6 @@ 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 = Rococo; pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating(); } @@ -692,13 +689,11 @@ impl snowbridge_control::Config for Runtime { type OwnParaId = ParachainInfo; type OutboundQueue = EthereumOutboundQueue; type MessageHasher = BlakeTwo256; + type AgentOwnerOrigin = EnsureXcm; + type ChannelOwnerOrigin = EnsureXcm; type AgentIdOf = xcm_config::AgentIdOf; - type UniversalLocation = UniversalLocation; - type RelayLocation = RelayLocation; - type AgentOrigin = EnsureXcm; - type ChannelOrigin = EnsureXcm; - type TreasuryAccount = TreasuryAccount; type SovereignAccountOf = xcm_config::SovereignAccountOf; + type TreasuryAccount = TreasuryAccount; type Fee = ConstU128<100000000000>; //should be enough to cover the existentialDeposit type Token = Balances; type WeightInfo = weights::snowbridge_control::WeightInfo; 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 649aabfa990..affd96ec48d 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 @@ -435,26 +435,3 @@ impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter { } } } - -/// [`Contains`] implementation that allows multiLocation from sibling chains only -pub struct AllowSiblingsOnly; -impl Contains for AllowSiblingsOnly { - fn contains(l: &MultiLocation) -> bool { - match l { - MultiLocation { parents: 1, interior: X1(Parachain(_)) } => true, - _ => false, - } - } -} - -/// [`Contains`] implementation that allows multiLocation from sibling chains and children of sibling chains. -pub struct AllowSiblingsChildrenOnly; -impl Contains for AllowSiblingsChildrenOnly { - fn contains(l: &MultiLocation) -> bool { - match l.split_first_interior() { - (MultiLocation { parents: 1, .. }, Some(Parachain(_))) => true, - _ => false, - - } - } -} From 3671c1f8d3bc148986f104ed0ae55e5b35e44407 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 9 Oct 2023 16:35:12 +0800 Subject: [PATCH 25/26] Remove set_owner --- Cargo.lock | 61 ++++++------------- .../bridge-hub-rococo/src/xcm_config.rs | 7 +-- 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac7cba187b3..2883f0374a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1067,7 +1067,7 @@ version = "0.1.0" dependencies = [ "bp-messages", "bp-polkadot-core", - "bp-runtime 0.1.0", + "bp-runtime", "frame-support", "frame-system", "polkadot-primitives", @@ -1081,7 +1081,7 @@ version = "0.1.0" dependencies = [ "bp-bridge-hub-cumulus", "bp-messages", - "bp-runtime 0.1.0", + "bp-runtime", "frame-support", "sp-api", "sp-std", @@ -1093,7 +1093,7 @@ version = "0.1.0" dependencies = [ "bp-bridge-hub-cumulus", "bp-messages", - "bp-runtime 0.1.0", + "bp-runtime", "frame-support", "sp-api", "sp-std", @@ -1103,7 +1103,7 @@ dependencies = [ name = "bp-header-chain" version = "0.1.0" dependencies = [ - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "finality-grandpa", "frame-support", @@ -1123,7 +1123,7 @@ name = "bp-messages" version = "0.1.0" dependencies = [ "bp-header-chain", - "bp-runtime 0.1.0", + "bp-runtime", "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 0.1.0", + "bp-runtime", "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 0.1.0", + "bp-runtime", "frame-support", "frame-system", "hex", @@ -1173,7 +1173,7 @@ name = "bp-relayers" version = "0.1.0" dependencies = [ "bp-messages", - "bp-runtime 0.1.0", + "bp-runtime", "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 0.1.0", + "bp-runtime", "frame-support", "sp-api", ] @@ -1216,28 +1216,6 @@ 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" @@ -1245,7 +1223,7 @@ dependencies = [ "bp-header-chain", "bp-parachains", "bp-polkadot-core", - "bp-runtime 0.1.0", + "bp-runtime", "ed25519-dalek", "finality-grandpa", "parity-scale-codec", @@ -1264,7 +1242,7 @@ dependencies = [ "bp-header-chain", "bp-polkadot-core", "bp-rococo", - "bp-runtime 0.1.0", + "bp-runtime", "frame-support", "sp-api", ] @@ -1406,7 +1384,7 @@ dependencies = [ "bp-polkadot-core", "bp-relayers", "bp-rococo", - "bp-runtime 0.1.0", + "bp-runtime", "bp-wococo", "bridge-hub-test-utils", "bridge-runtime-common", @@ -1496,7 +1474,7 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-relayers", - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "bridge-runtime-common", "cumulus-pallet-dmp-queue", @@ -1538,7 +1516,7 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-relayers", - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "frame-support", "frame-system", @@ -7387,7 +7365,7 @@ name = "pallet-bridge-grandpa" version = "0.1.0" dependencies = [ "bp-header-chain", - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "finality-grandpa", "frame-benchmarking", @@ -7409,7 +7387,7 @@ name = "pallet-bridge-messages" version = "0.1.0" dependencies = [ "bp-messages", - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "frame-benchmarking", "frame-support", @@ -7432,7 +7410,7 @@ dependencies = [ "bp-header-chain", "bp-parachains", "bp-polkadot-core", - "bp-runtime 0.1.0", + "bp-runtime", "bp-test-utils", "frame-benchmarking", "frame-support", @@ -7454,7 +7432,7 @@ version = "0.1.0" dependencies = [ "bp-messages", "bp-relayers", - "bp-runtime 0.1.0", + "bp-runtime", "frame-benchmarking", "frame-support", "frame-system", @@ -13401,7 +13379,6 @@ 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", @@ -13426,7 +13403,6 @@ 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", @@ -13452,7 +13428,6 @@ 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/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 0c0e8ae2a9d..5d4ce7b0ff4 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 @@ -211,13 +211,10 @@ impl Contains for SafeCallFilter { >::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 { .. }, + | snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumInboundQueue( - snowbridge_inbound_queue::Call::set_owner { .. } - | snowbridge_inbound_queue::Call::set_operating_mode { .. }, + snowbridge_inbound_queue::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumOutboundQueue( - snowbridge_outbound_queue::Call::set_owner { .. } | snowbridge_outbound_queue::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumControl(..) ) From 755b82a041702e72b4a4cf2a2c23accab594fc37 Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Mon, 9 Oct 2023 20:44:47 +0300 Subject: [PATCH 26/26] update benchmarking logic in cumulus --- Cargo.lock | 13 ++ .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 3 + .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 23 ++- .../src/weights/snowbridge_control.rs | 177 +++++++++++++----- .../bridge-hub-rococo/src/xcm_config.rs | 9 - 5 files changed, 161 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 296bb808348..280726f057e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1457,6 +1457,7 @@ dependencies = [ "smallvec", "snowbridge-beacon-primitives", "snowbridge-control", + "snowbridge-control-runtime-api", "snowbridge-core", "snowbridge-ethereum-beacon-client", "snowbridge-inbound-queue", @@ -13357,6 +13358,18 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "snowbridge-control-runtime-api" +version = "0.1.0" +dependencies = [ + "parity-scale-codec", + "snowbridge-core", + "sp-api", + "sp-core", + "sp-std", + "xcm", +] + [[package]] name = "snowbridge-core" version = "0.1.1" diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index d77f5ab3990..4c60a41b216 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -97,6 +97,8 @@ snowbridge-outbound-queue = { path = "../../../../../parachain/pallets/outbound- snowbridge-outbound-queue-runtime-api = { path = "../../../../../parachain/pallets/outbound-queue/runtime-api", default-features = false } snowbridge-ethereum-beacon-client = { path = "../../../../../parachain/pallets/ethereum-beacon-client", default-features = false } snowbridge-control = { path = "../../../../../parachain/pallets/control", default-features = false } +snowbridge-control-runtime-api = { path = "../../../../../parachain/pallets/control/runtime-api", default-features = false } + [dev-dependencies] @@ -182,6 +184,7 @@ std = [ "snowbridge-outbound-queue-runtime-api/std", "snowbridge-ethereum-beacon-client/std", "snowbridge-control/std", + "snowbridge-control-runtime-api/std", "substrate-wasm-builder", ] 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 644e9252672..ba8ce9bbebb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -56,8 +56,8 @@ use sp_version::RuntimeVersion; use frame_support::{ construct_runtime, - dispatch::DispatchClass, parameter_types, + dispatch::DispatchClass, traits::{ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, Everything}, weights::{ConstantMultiplier, Weight}, PalletId, @@ -71,9 +71,9 @@ 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::VersionedMultiLocation; use xcm_config::{ - EthereumGatewayAddress, RelayLocation, UniversalLocation, XcmConfig, + EthereumGatewayAddress, XcmConfig, XcmOriginToTransactDispatchOrigin, }; @@ -108,6 +108,7 @@ use parachains_common::{ AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; use snowbridge_beacon_primitives::{Fork, ForkVersions}; +use snowbridge_core::AgentId; use xcm_executor::XcmExecutor; /// The address format for describing accounts. @@ -684,6 +685,13 @@ parameter_types! { pub TreasuryAccount: AccountId = PalletId(*b"py/trsry").into_account_truncating(); } +#[cfg(feature = "runtime-benchmarks")] +impl snowbridge_control::BenchmarkHelper for () { + fn make_xcm_origin(location: xcm::latest::MultiLocation) -> RuntimeOrigin { + RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location)) + } +} + impl snowbridge_control::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OwnParaId = ParachainInfo; @@ -692,11 +700,12 @@ impl snowbridge_control::Config for Runtime { type AgentOwnerOrigin = EnsureXcm; type ChannelOwnerOrigin = EnsureXcm; type AgentIdOf = xcm_config::AgentIdOf; - type SovereignAccountOf = xcm_config::SovereignAccountOf; type TreasuryAccount = TreasuryAccount; type Fee = ConstU128<100000000000>; //should be enough to cover the existentialDeposit type Token = Balances; type WeightInfo = weights::snowbridge_control::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type Helper = (); } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -1045,6 +1054,12 @@ impl_runtime_apis! { } } + impl snowbridge_control_runtime_api::ControlApi for Runtime { + fn agent_id(location: VersionedMultiLocation) -> Option { + snowbridge_control::api::agent_id::(location) + } + } + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs index e7cc3355e0b..06e12a2a038 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs @@ -2,26 +2,23 @@ //! Autogenerated weights for `snowbridge_control` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-07-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-09, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `macbook pro 14 m2`, CPU: `m2-arm64` +//! HOSTNAME: `crake.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: // target/release/polkadot-parachain // benchmark // pallet -// --chain=bridge-hub-rococo-dev +// --chain +// bridge-hub-rococo-dev // --pallet=snowbridge_control // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --steps -// 50 -// --repeat -// 20 // --output -// ./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs +// parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/snowbridge_control.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,23 +41,22 @@ impl snowbridge_control::WeightInfo for WeightInfo { /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) /// Storage: MessageQueue Pages (r:0 w:1) /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) - /// The range of component `x` is `[0, 1023]`. fn upgrade() -> Weight { // Proof Size summary in bytes: // Measured: `80` // Estimated: `3517` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(30_740_411, 0) + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(47_000_000, 0) .saturating_add(Weight::from_parts(0, 3517)) - // Standard Error: 66 - .saturating_add(Weight::from_parts(8_805, 0).saturating_mul(256)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } - /// Storage: ParachainInfo ParachainId (r:1 w:0) - /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: EthereumControl Agents (r:1 w:1) /// Proof: EthereumControl Agents (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: MessageQueue BookStateFor (r:1 w:1) @@ -71,57 +67,136 @@ impl snowbridge_control::WeightInfo for WeightInfo { /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn create_agent() -> Weight { // Proof Size summary in bytes: - // Measured: `84` - // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) - .saturating_add(Weight::from_parts(0, 3517)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `187` + // Estimated: `6196` + // Minimum execution time: 87_000_000 picoseconds. + Weight::from_parts(87_000_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } - - /// Todo: update with benchmarked + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EthereumControl Agents (r:1 w:0) + /// Proof: EthereumControl Agents (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: EthereumControl Channels (r:1 w:1) + /// Proof: EthereumControl Channels (max_values: None, max_size: Some(12), added: 2487, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn create_channel() -> Weight { // Proof Size summary in bytes: - // Measured: `84` - // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) - .saturating_add(Weight::from_parts(0, 3517)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `602` + // Estimated: `69050` + // Minimum execution time: 84_000_000 picoseconds. + Weight::from_parts(84_000_000, 0) + .saturating_add(Weight::from_parts(0, 69050)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(5)) } - + /// Storage: EthereumControl Channels (r:1 w:0) + /// Proof: EthereumControl Channels (max_values: None, max_size: Some(12), added: 2487, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:0 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn update_channel() -> Weight { // Proof Size summary in bytes: - // Measured: `84` - // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) - .saturating_add(Weight::from_parts(0, 3517)) + // Measured: `256` + // Estimated: `6044` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(41_000_000, 0) + .saturating_add(Weight::from_parts(0, 6044)) .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - + /// Storage: EthereumControl Channels (r:1 w:0) + /// Proof: EthereumControl Channels (max_values: None, max_size: Some(12), added: 2487, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:0 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) + fn force_update_channel() -> Weight { + // Proof Size summary in bytes: + // Measured: `256` + // Estimated: `6044` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(41_000_000, 0) + .saturating_add(Weight::from_parts(0, 6044)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:1) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:0 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn set_operating_mode() -> Weight { // Proof Size summary in bytes: - // Measured: `84` + // Measured: `80` // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(30_000_000, 0) .saturating_add(Weight::from_parts(0, 3517)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } - + /// Storage: EthereumControl Agents (r:1 w:0) + /// Proof: EthereumControl Agents (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:0 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn transfer_native_from_agent() -> Weight { // Proof Size summary in bytes: - // Measured: `84` - // Estimated: `3517` - // Minimum execution time: 34_000_000 picoseconds. - Weight::from_parts(35_000_000, 0) - .saturating_add(Weight::from_parts(0, 3517)) + // Measured: `252` + // Estimated: `6044` + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(43_000_000, 0) + .saturating_add(Weight::from_parts(0, 6044)) .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: EthereumControl Agents (r:1 w:0) + /// Proof: EthereumControl Agents (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: EthereumOutboundQueue PalletOperatingMode (r:1 w:0) + /// Proof: EthereumOutboundQueue PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:0 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) + fn force_transfer_native_from_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `252` + // Estimated: `6044` + // Minimum execution time: 42_000_000 picoseconds. + Weight::from_parts(42_000_000, 0) + .saturating_add(Weight::from_parts(0, 6044)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } } 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 affd96ec48d..dc34bff26df 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 @@ -362,15 +362,6 @@ impl cumulus_pallet_xcm::Config for Runtime { pub type AgentIdOf = HashedDescription>; -/// Ethereum control pallet: Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used -/// when determining sovereign accounts for asset transacting -pub type SovereignAccountOf = ( - // Relay chain, sibling parachains, and local children - LocationToAccountId, - // Other nested consensus systems on sibling parachains - HashedDescription>, -); - pub type SnowbridgeExporter = EthereumBlobExporter< UniversalLocation, EthereumGatewayLocation,