From c6756cd37fecf0c9379c0f96a9ca70ed4f4971e9 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Wed, 16 Nov 2022 23:16:48 +0100 Subject: [PATCH] BridgeHub fixes --- Cargo.lock | 34 +++++------- Cargo.toml | 6 ++- .../bridge-hubs/bridge-hub-rococo/Cargo.toml | 2 - .../src/bridge_hub_rococo_config.rs | 53 +++++++------------ .../src/bridge_hub_wococo_config.rs | 53 +++++++------------ 5 files changed, 55 insertions(+), 93 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 127f1a1c1c..f0a310083e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -721,6 +721,8 @@ dependencies = [ "bp-polkadot-core", "bp-runtime", "frame-support", + "polkadot-runtime-constants", + "smallvec", "sp-api", "sp-std", ] @@ -754,6 +756,7 @@ dependencies = [ "sp-finality-grandpa", "sp-runtime", "sp-std", + "sp-trie", ] [[package]] @@ -936,7 +939,6 @@ dependencies = [ "bp-bridge-hub-rococo", "bp-bridge-hub-wococo", "bp-messages", - "bp-polkadot-core", "bp-rococo", "bp-runtime", "bp-wococo", @@ -1006,6 +1008,7 @@ dependencies = [ name = "bridge-runtime-common" version = "0.1.0" dependencies = [ + "bp-header-chain", "bp-messages", "bp-parachains", "bp-polkadot-core", @@ -4383,7 +4386,7 @@ dependencies = [ "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=master)", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-gilt", @@ -6182,7 +6185,7 @@ dependencies = [ "frame-support", "frame-system", "log", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech//substrate?branch=sv-locked-for-gav-xcm-v3-and-bridges)", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", "rand 0.7.3", "scale-info", @@ -6196,19 +6199,6 @@ dependencies = [ "strum", ] -[[package]] -name = "pallet-election-provider-support-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#87f3fdea8f227d33322c439d45a9e1796637e972" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-system", - "parity-scale-codec", - "sp-npos-elections", - "sp-runtime", -] - [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" @@ -6435,7 +6425,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#87f3fdea8f227d33322c439d45a9e1796637e972" +source = "git+https://github.com/paritytech//substrate?branch=sv-locked-for-gav-xcm-v3-and-bridges#87f3fdea8f227d33322c439d45a9e1796637e972" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6482,7 +6472,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#87f3fdea8f227d33322c439d45a9e1796637e972" +source = "git+https://github.com/paritytech//substrate?branch=sv-locked-for-gav-xcm-v3-and-bridges#87f3fdea8f227d33322c439d45a9e1796637e972" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6639,7 +6629,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#87f3fdea8f227d33322c439d45a9e1796637e972" +source = "git+https://github.com/paritytech//substrate?branch=sv-locked-for-gav-xcm-v3-and-bridges#87f3fdea8f227d33322c439d45a9e1796637e972" dependencies = [ "frame-benchmarking", "frame-support", @@ -8416,7 +8406,7 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=master)", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", @@ -12433,7 +12423,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#87f3fdea8f227d33322c439d45a9e1796637e972" +source = "git+https://github.com/paritytech//substrate?branch=sv-locked-for-gav-xcm-v3-and-bridges#87f3fdea8f227d33322c439d45a9e1796637e972" dependencies = [ "array-bytes", "async-trait", @@ -13655,7 +13645,7 @@ dependencies = [ "pallet-collective", "pallet-democracy", "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=master)", + "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", "pallet-fast-unstake", "pallet-grandpa", diff --git a/Cargo.toml b/Cargo.toml index 2939fd905e..925a43226d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ members = [ "bridges/modules/relayers", "bridges/modules/shift-session-manager", "bridges/primitives/messages", - "bridges/primitives/polkadot-core", "bridges/primitives/runtime", "bridges/primitives/chain-bridge-hub-rococo", "bridges/primitives/chain-bridge-hub-wococo", @@ -248,6 +247,11 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech//substrat substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } substrate-wasm-builder = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } try-runtime-cli = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } +substrate-test-client = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } +pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } +pallet-offences-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } +pallet-session-benchmarking = { git = "https://github.com/paritytech//substrate", branch = "sv-locked-for-gav-xcm-v3-and-bridges" } [patch."https://github.com/paritytech/polkadot"] kusama-runtime = { git = "https://github.com/paritytech//polkadot", branch = "locked-for-gav-xcm-v3-and-bridges" } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 3845258ed6..25bdd1bcbe 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -73,7 +73,6 @@ parachains-common = { path = "../../../../parachains/common", default-features = bp-bridge-hub-rococo = { path = "../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false } bp-bridge-hub-wococo = { path = "../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false } bp-messages = { path = "../../../../bridges/primitives/messages", default-features = false } -bp-polkadot-core = { path = "../../../../bridges/primitives/polkadot-core", default-features = false } bp-runtime = { path = "../../../../bridges/primitives/runtime", default-features = false } bp-rococo = { path = "../../../../bridges/primitives/chain-rococo", default-features = false } bp-wococo = { path = "../../../../bridges/primitives/chain-wococo", default-features = false } @@ -91,7 +90,6 @@ default = [ std = [ "bp-bridge-hub-rococo/std", "bp-bridge-hub-wococo/std", - "bp-polkadot-core/std", "bp-messages/std", "bp-runtime/std", "bp-rococo/std", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs index cc3aef6aa6..c242285c35 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -15,22 +15,21 @@ // along with Cumulus. If not, see . use crate::{ - ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, - XcmBlobHaulerAdapter, XcmRouter, + BridgeParachainWococoInstance, ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, + XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter, }; use bp_messages::{ source_chain::TargetHeaderChain, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, MessageNonce, }; -use bp_polkadot_core::parachains::ParaId; -use bp_runtime::{Chain, ChainId}; +use bp_runtime::ChainId; use bridge_runtime_common::{ messages, messages::{ target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation, - BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain, - ThisChainWithMessages, + BridgedChain, MessageBridge, MessageTransaction, ThisChain, ThisChainWithMessages, + UnderlyingChainProvider, }, }; use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug}; @@ -89,6 +88,11 @@ impl MessageBridge for WithBridgeHubWococoMessageBridge { bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME; type ThisChain = BridgeHubRococo; type BridgedChain = BridgeHubWococo; + type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< + Runtime, + BridgeParachainWococoInstance, + bp_bridge_hub_wococo::BridgeHubWococo, + >; fn bridged_balance_to_this_balance( bridged_balance: bridge_runtime_common::messages::BalanceOf>, @@ -112,12 +116,8 @@ pub type ToBridgeHubWococoMaximalOutboundPayloadSize = #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubWococo; -impl ChainWithMessages for BridgeHubWococo { - type Hash = bp_bridge_hub_wococo::Hash; - type AccountId = bp_bridge_hub_wococo::AccountId; - type Signer = bp_bridge_hub_wococo::AccountSigner; - type Signature = bp_bridge_hub_wococo::Signature; - type Balance = bp_bridge_hub_wococo::Balance; +impl UnderlyingChainProvider for BridgeHubWococo { + type Chain = bp_bridge_hub_wococo::BridgeHubWococo; } impl SourceHeaderChain for BridgeHubWococo { @@ -128,12 +128,10 @@ impl SourceHeaderChain for BridgeHubWococo { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::< + bridge_runtime_common::messages::target::verify_messages_proof::< WithBridgeHubWococoMessageBridge, - bp_bridge_hub_wococo::Header, - crate::Runtime, - crate::BridgeParachainWococoInstance, - >(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof, messages_count) + >(proof, messages_count) + .map_err(Into::into) } } @@ -149,20 +147,11 @@ impl TargetHeaderChain for BridgeHubWococo fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof_from_parachain::< - WithBridgeHubWococoMessageBridge, - bp_bridge_hub_wococo::Header, - crate::Runtime, - crate::BridgeParachainWococoInstance, - >(ParaId(bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID), proof) + messages::source::verify_messages_delivery_proof::(proof) } } impl messages::BridgedChainWithMessages for BridgeHubWococo { - fn maximal_extrinsic_size() -> u32 { - bp_bridge_hub_wococo::BridgeHubWococo::max_extrinsic_size() - } - fn verify_dispatch_weight(_message_payload: &[u8]) -> bool { true } @@ -206,19 +195,15 @@ impl messages::BridgedChainWithMessages for BridgeHubWococo { #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubRococo; -impl ChainWithMessages for BridgeHubRococo { - type Hash = bp_bridge_hub_rococo::Hash; - type AccountId = bp_bridge_hub_rococo::AccountId; - type Signer = bp_bridge_hub_rococo::AccountSigner; - type Signature = bp_bridge_hub_rococo::Signature; - type Balance = bp_bridge_hub_rococo::Balance; +impl UnderlyingChainProvider for BridgeHubRococo { + type Chain = bp_bridge_hub_rococo::BridgeHubRococo; } impl ThisChainWithMessages for BridgeHubRococo { type RuntimeOrigin = crate::RuntimeOrigin; type RuntimeCall = crate::RuntimeCall; type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation< - Self::AccountId, + bp_bridge_hub_rococo::AccountId, { bp_bridge_hub_rococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() }, { bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE }, { bp_bridge_hub_rococo::TX_EXTRA_BYTES }, diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs index a4039e1b94..c90b3dd29d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -15,22 +15,21 @@ // along with Cumulus. If not, see . use crate::{ - ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, XcmAsPlainPayload, XcmBlobHauler, - XcmBlobHaulerAdapter, XcmRouter, + BridgeParachainRococoInstance, ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, + XcmAsPlainPayload, XcmBlobHauler, XcmBlobHaulerAdapter, XcmRouter, }; use bp_messages::{ source_chain::TargetHeaderChain, target_chain::{ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, MessageNonce, }; -use bp_polkadot_core::parachains::ParaId; -use bp_runtime::{Chain, ChainId}; +use bp_runtime::ChainId; use bridge_runtime_common::{ messages, messages::{ target::FromBridgedChainMessagesProof, BasicConfirmationTransactionEstimation, - BridgedChain, ChainWithMessages, MessageBridge, MessageTransaction, ThisChain, - ThisChainWithMessages, + BridgedChain, MessageBridge, MessageTransaction, ThisChain, ThisChainWithMessages, + UnderlyingChainProvider, }, }; use frame_support::{dispatch::Weight, parameter_types, RuntimeDebug}; @@ -89,6 +88,11 @@ impl MessageBridge for WithBridgeHubRococoMessageBridge { bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME; type ThisChain = BridgeHubWococo; type BridgedChain = BridgeHubRococo; + type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< + Runtime, + BridgeParachainRococoInstance, + bp_bridge_hub_rococo::BridgeHubRococo, + >; fn bridged_balance_to_this_balance( bridged_balance: bridge_runtime_common::messages::BalanceOf>, @@ -112,12 +116,8 @@ pub type ToBridgeHubRococoMaximalOutboundPayloadSize = #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubRococo; -impl ChainWithMessages for BridgeHubRococo { - type Hash = bp_bridge_hub_rococo::Hash; - type AccountId = bp_bridge_hub_rococo::AccountId; - type Signer = bp_bridge_hub_rococo::AccountSigner; - type Signature = bp_bridge_hub_rococo::Signature; - type Balance = bp_bridge_hub_rococo::Balance; +impl UnderlyingChainProvider for BridgeHubRococo { + type Chain = bp_bridge_hub_rococo::BridgeHubRococo; } impl SourceHeaderChain for BridgeHubRococo { @@ -128,12 +128,10 @@ impl SourceHeaderChain for BridgeHubRococo { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - bridge_runtime_common::messages::target::verify_messages_proof_from_parachain::< + bridge_runtime_common::messages::target::verify_messages_proof::< WithBridgeHubRococoMessageBridge, - bp_bridge_hub_rococo::Header, - crate::Runtime, - crate::BridgeParachainRococoInstance, - >(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof, messages_count) + >(proof, messages_count) + .map_err(Into::into) } } @@ -149,20 +147,11 @@ impl TargetHeaderChain for BridgeHubRococo fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof_from_parachain::< - WithBridgeHubRococoMessageBridge, - bp_bridge_hub_rococo::Header, - crate::Runtime, - crate::BridgeParachainRococoInstance, - >(ParaId(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), proof) + messages::source::verify_messages_delivery_proof::(proof) } } impl messages::BridgedChainWithMessages for BridgeHubRococo { - fn maximal_extrinsic_size() -> u32 { - bp_bridge_hub_rococo::BridgeHubRococo::max_extrinsic_size() - } - fn verify_dispatch_weight(_message_payload: &[u8]) -> bool { true } @@ -206,19 +195,15 @@ impl messages::BridgedChainWithMessages for BridgeHubRococo { #[derive(RuntimeDebug, Clone, Copy)] pub struct BridgeHubWococo; -impl ChainWithMessages for BridgeHubWococo { - type Hash = bp_bridge_hub_wococo::Hash; - type AccountId = bp_bridge_hub_wococo::AccountId; - type Signer = bp_bridge_hub_wococo::AccountSigner; - type Signature = bp_bridge_hub_wococo::Signature; - type Balance = bp_bridge_hub_wococo::Balance; +impl UnderlyingChainProvider for BridgeHubWococo { + type Chain = bp_bridge_hub_wococo::BridgeHubWococo; } impl ThisChainWithMessages for BridgeHubWococo { type RuntimeOrigin = crate::RuntimeOrigin; type RuntimeCall = crate::RuntimeCall; type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation< - Self::AccountId, + bp_bridge_hub_wococo::AccountId, { bp_bridge_hub_wococo::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() }, { bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE }, { bp_bridge_hub_wococo::TX_EXTRA_BYTES },