diff --git a/Cargo.lock b/Cargo.lock index f70cf63c8e4..4b1b98eb35d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1412,6 +1412,7 @@ dependencies = [ "pallet-bridge-parachains", "pallet-bridge-relayers", "pallet-collator-selection", + "pallet-message-queue", "pallet-multisig", "pallet-session", "pallet-timestamp", @@ -1431,10 +1432,12 @@ dependencies = [ "serde", "smallvec", "snowbridge-beacon-primitives", + "snowbridge-control", "snowbridge-core", "snowbridge-ethereum-beacon-client", "snowbridge-inbound-queue", "snowbridge-outbound-queue", + "snowbridge-outbound-queue-runtime-api", "snowbridge-router-primitives", "sp-api", "sp-block-builder", @@ -9974,7 +9977,6 @@ dependencies = [ "serde", "serde_json", "shell-runtime", - "snowbridge-outbound-queue-rpc", "sp-api", "sp-block-builder", "sp-blockchain", @@ -13308,6 +13310,24 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "snowbridge-control" +version = "4.0.0-dev" +dependencies = [ + "ethabi-decode", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "snowbridge-core", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", +] + [[package]] name = "snowbridge-core" version = "0.1.1" @@ -13322,6 +13342,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-std", + "xcm", ] [[package]] @@ -13407,33 +13428,33 @@ dependencies = [ "scale-info", "serde", "snowbridge-core", - "snowbridge-outbound-queue-merkle-proof", + "snowbridge-outbound-queue-merkle-tree", "sp-core", "sp-io", "sp-runtime", "sp-std", + "xcm", ] [[package]] -name = "snowbridge-outbound-queue-merkle-proof" +name = "snowbridge-outbound-queue-merkle-tree" version = "0.1.1" dependencies = [ "parity-scale-codec", + "scale-info", "sp-core", "sp-runtime", ] [[package]] -name = "snowbridge-outbound-queue-rpc" +name = "snowbridge-outbound-queue-runtime-api" version = "0.1.0" dependencies = [ - "jsonrpsee", "parity-scale-codec", - "parking_lot 0.11.2", - "snowbridge-outbound-queue-merkle-proof", + "snowbridge-outbound-queue-merkle-tree", + "sp-api", "sp-core", - "sp-offchain", - "sp-runtime", + "sp-std", ] [[package]] @@ -13443,6 +13464,7 @@ dependencies = [ "ethabi-decode", "frame-support", "frame-system", + "hex-literal 0.4.1", "parity-scale-codec", "scale-info", "serde", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 02ddf9931e8..6b4becc57f2 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -28,6 +28,7 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-message-queue = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -89,11 +90,14 @@ bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common", defau # Ethereum Bridge (Snowbridge) snowbridge-core = { path = "../../../../../parachain/primitives/core", default-features = false } -snowbridge-beacon-primitives = { path = "../../../../../parachain/primitives/beacon", default-features = false } snowbridge-router-primitives = { path = "../../../../../parachain/primitives/router", default-features = false } +snowbridge-beacon-primitives = { path = "../../../../../parachain/primitives/beacon", default-features = false } snowbridge-inbound-queue = { path = "../../../../../parachain/pallets/inbound-queue", default-features = false } snowbridge-outbound-queue = { path = "../../../../../parachain/pallets/outbound-queue", default-features = false } +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 } + [dev-dependencies] static_assertions = "1.1" @@ -141,6 +145,7 @@ std = [ "pallet-bridge-parachains/std", "pallet-bridge-relayers/std", "pallet-collator-selection/std", + "pallet-message-queue/std", "pallet-multisig/std", "pallet-session/std", "pallet-timestamp/std", @@ -170,11 +175,13 @@ std = [ "xcm-executor/std", "xcm/std", "snowbridge-core/std", - "snowbridge-beacon-primitives/std", "snowbridge-router-primitives/std", + "snowbridge-beacon-primitives/std", "snowbridge-inbound-queue/std", "snowbridge-outbound-queue/std", + "snowbridge-outbound-queue-runtime-api/std", "snowbridge-ethereum-beacon-client/std", + "snowbridge-control/std", "substrate-wasm-builder", ] @@ -190,6 +197,7 @@ runtime-benchmarks = [ "pallet-bridge-parachains/runtime-benchmarks", "pallet-bridge-relayers/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", @@ -223,6 +231,7 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", + "pallet-message-queue/try-runtime", "pallet-multisig/try-runtime", "pallet-session/try-runtime", "pallet-timestamp/try-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 7088d051228..0b1921b3d2d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -400,6 +400,24 @@ impl pallet_utility::Config for Runtime { type WeightInfo = weights::pallet_utility::WeightInfo; } +parameter_types! { + /// Amount of weight that can be spent per block to service messages. + pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000); + pub const MessageQueueHeapSize: u32 = 65_536; + pub const MessageQueueMaxStale: u32 = 16; +} + +impl pallet_message_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Size = u32; + type HeapSize = MessageQueueHeapSize; + type MaxStale = MessageQueueMaxStale; + type ServiceWeight = MessageQueueServiceWeight; + type MessageProcessor = EthereumOutboundQueue; + type QueueChangeHandler = (); + type WeightInfo = (); +} + // Add bridge pallets (GPA) /// Add GRANDPA bridge pallet to track Wococo relay chain on Rococo BridgeHub @@ -549,8 +567,6 @@ impl pallet_bridge_relayers::Config for Runtime { // Ethereum Bridge -use snowbridge_router_primitives::InboundMessageConverter; - parameter_types! { pub const EthereumNetwork: xcm::v3::NetworkId = xcm::v3::NetworkId::Ethereum { chain_id: 1 }; } @@ -564,21 +580,21 @@ impl snowbridge_inbound_queue::Config for Runtime { type Token = Balances; type Reward = Reward; type Verifier = snowbridge_ethereum_beacon_client::Pallet; - type MessageConversion = InboundMessageConverter; type XcmSender = XcmRouter; type WeightInfo = (); } parameter_types! { pub const MaxMessagePayloadSize: u32 = 256; - pub const MaxMessagesPerCommit: u32 = 20; + pub const MaxMessagesPerBlock: u32 = 32; } impl snowbridge_outbound_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Hashing = Keccak256; + type MessageQueue = MessageQueue; type MaxMessagePayloadSize = MaxMessagePayloadSize; - type MaxMessagesPerCommit = MaxMessagesPerCommit; + type MaxMessagesPerBlock = MaxMessagesPerBlock; type WeightInfo = (); } @@ -635,6 +651,19 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime { type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo; } +parameter_types! { + pub const GovernanceProxyContract: snowbridge_core::ContractId = snowbridge_core::ContractId::new(hex_literal::hex!("44bef07c29162ad04096f5cbe78ca2df62dffe97cea85825f08d13319e13f34a")); +} + +impl snowbridge_control::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OwnParaId = ParachainInfo; + type OutboundQueue = EthereumOutboundQueue; + type GovernanceProxyContract = GovernanceProxyContract; + type MessageHasher = BlakeTwo256; + type WeightInfo = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -689,8 +718,13 @@ construct_runtime!( // Ethereum Bridge EthereumInboundQueue: snowbridge_inbound_queue::{Pallet, Call, Config, Storage, Event} = 48, - EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Config, Storage, Event} = 49, + EthereumOutboundQueue: snowbridge_outbound_queue::{Pallet, Storage, Event} = 49, EthereumBeaconClient: snowbridge_ethereum_beacon_client::{Pallet, Call, Storage, Event} = 50, + EthereumControl: snowbridge_control::{Pallet, Call, Storage, Event} = 51, + + // Message Queue. Registered after EthereumOutboundQueue so that their `on_initialize` handlers + // run in the desired order. + MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event} = 60, } ); @@ -714,6 +748,7 @@ mod benches { [frame_system, SystemBench::] [pallet_balances, Balances] [pallet_multisig, Multisig] + [pallet_message_queue, MessageQueue] [pallet_session, SessionBench::] [pallet_utility, Utility] [pallet_timestamp, Timestamp] @@ -969,6 +1004,12 @@ impl_runtime_apis! { } } + impl snowbridge_outbound_queue_runtime_api::OutboundQueueApi for Runtime { + fn prove_message(leaf_index: u64) -> Option { + snowbridge_outbound_queue::api::prove_message::(leaf_index) + } + } + #[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/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 067592c72a3..ab61c60b22d 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 @@ -22,8 +22,7 @@ use super::{ }; use crate::{ bridge_hub_rococo_config::ToBridgeHubWococoHaulBlobExporter, - bridge_hub_wococo_config::ToBridgeHubRococoHaulBlobExporter, - EthereumNetwork, + bridge_hub_wococo_config::ToBridgeHubRococoHaulBlobExporter, EthereumNetwork, }; use frame_support::{ match_types, parameter_types, @@ -34,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::export::EthereumBlobExporter; +use snowbridge_router_primitives::outbound::EthereumBlobExporter; use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index d0e9485cf93..c535772c04a 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -90,9 +90,6 @@ cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inhere cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" } color-print = "0.3.4" -# Ethereum Bridge -snowbridge-outbound-queue-rpc = { path = "../../parachain/pallets/outbound-queue/rpc" } - [build-dependencies] substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index febb21b6647..51bd6e4924d 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -346,9 +346,6 @@ pub mod rococo { ethereum_inbound_queue: bridge_hub_rococo_runtime::EthereumInboundQueueConfig { allowlist: Default::default(), }, - ethereum_outbound_queue: bridge_hub_rococo_runtime::EthereumOutboundQueueConfig { - interval: 1, - }, } } } diff --git a/polkadot-parachain/src/rpc.rs b/polkadot-parachain/src/rpc.rs index c0cc5cfc2cf..0ccd2f63223 100644 --- a/polkadot-parachain/src/rpc.rs +++ b/polkadot-parachain/src/rpc.rs @@ -63,7 +63,6 @@ where { use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; - use snowbridge_outbound_queue_rpc::{OutboundQueue, OutboundQueueApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); @@ -73,13 +72,6 @@ where module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(StateMigration::new(client, backend.clone(), deny_unsafe).into_rpc())?; - if let Some(outbound_queue_rpc) = backend - .offchain_storage() - .map(|storage| OutboundQueue::::new(storage).into_rpc()) - { - module.merge(outbound_queue_rpc)?; - } - Ok(module) }