diff --git a/Cargo.lock b/Cargo.lock index ea18262d1..936fbc747 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1382,6 +1382,7 @@ dependencies = [ "pallet-bridge-dispatch", "pallet-bridge-grandpa", "pallet-bridge-messages", + "pallet-bridge-parachains", "pallet-collective", "pallet-democracy", "pallet-elections-phragmen", @@ -2522,6 +2523,7 @@ dependencies = [ "pallet-bridge-dispatch", "pallet-bridge-grandpa", "pallet-bridge-messages", + "pallet-bridge-parachains", "pallet-collective", "pallet-democracy", "pallet-elections-phragmen", @@ -6524,6 +6526,7 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-runtime", + "frame-benchmarking", "frame-support", "frame-system", "pallet-bridge-grandpa", diff --git a/node/src/chain_spec/crab.rs b/node/src/chain_spec/crab.rs index 223b21299..caf865dd4 100644 --- a/node/src/chain_spec/crab.rs +++ b/node/src/chain_spec/crab.rs @@ -193,7 +193,8 @@ pub fn genesis_config() -> ChainSpec { base_fee: Default::default(), // S2S stuff. - bridge_darwinia_grandpa: Default::default(), + bridge_polkadot_grandpa: Default::default(), + bridge_polkadot_parachain: Default::default(), bridge_darwinia_messages: Default::default(), darwinia_fee_market: Default::default(), } @@ -232,7 +233,12 @@ fn testnet_genesis( transaction_payment: Default::default(), assets: AssetsConfig { assets: vec![(AssetIds::CKton as _, array_bytes::hex_n_into_unchecked(ALITH), true, 1)], - metadata: vec![(AssetIds::CKton as _, b"Crab Commitment Token".to_vec(), b"CKTON".to_vec(), 18)], + metadata: vec![( + AssetIds::CKton as _, + b"Crab Commitment Token".to_vec(), + b"CKTON".to_vec(), + 18, + )], ..Default::default() }, @@ -320,7 +326,8 @@ fn testnet_genesis( base_fee: Default::default(), // S2S stuff. - bridge_darwinia_grandpa: Default::default(), + bridge_polkadot_grandpa: Default::default(), + bridge_polkadot_parachain: Default::default(), bridge_darwinia_messages: Default::default(), darwinia_fee_market: Default::default(), } diff --git a/node/src/chain_spec/darwinia.rs b/node/src/chain_spec/darwinia.rs index 99f6ee39c..ea3ed8dc7 100644 --- a/node/src/chain_spec/darwinia.rs +++ b/node/src/chain_spec/darwinia.rs @@ -193,7 +193,8 @@ pub fn genesis_config() -> ChainSpec { base_fee: Default::default(), // S2S stuff. - bridge_crab_grandpa: Default::default(), + bridge_kusama_grandpa: Default::default(), + bridge_kusama_parachain: Default::default(), bridge_crab_messages: Default::default(), crab_fee_market: Default::default(), } @@ -232,7 +233,12 @@ fn testnet_genesis( transaction_payment: Default::default(), assets: AssetsConfig { assets: vec![(AssetIds::Kton as _, array_bytes::hex_n_into_unchecked(ALITH), true, 1)], - metadata: vec![(AssetIds::Kton as _, b"Darwinia Commitment Token".to_vec(), b"KTON".to_vec(), 18)], + metadata: vec![( + AssetIds::Kton as _, + b"Darwinia Commitment Token".to_vec(), + b"KTON".to_vec(), + 18, + )], ..Default::default() }, @@ -320,7 +326,8 @@ fn testnet_genesis( base_fee: Default::default(), // S2S stuff. - bridge_crab_grandpa: Default::default(), + bridge_kusama_grandpa: Default::default(), + bridge_kusama_parachain: Default::default(), bridge_crab_messages: Default::default(), crab_fee_market: Default::default(), } diff --git a/runtime/crab/Cargo.toml b/runtime/crab/Cargo.toml index ecd97eb63..e918c0331 100644 --- a/runtime/crab/Cargo.toml +++ b/runtime/crab/Cargo.toml @@ -48,15 +48,16 @@ darwinia-staking = { default-features = false, path = "../../pa dc-primitives = { default-features = false, path = "../../core/primitives" } # darwinia-messages-substrate -bp-message-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-polkadot-core = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-runtime = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bridge-runtime-common = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-grandpa = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-fee-market = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-message-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-polkadot-core = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-runtime = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bridge-runtime-common = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-grandpa = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-parachains = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-fee-market = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } # frontier fp-rpc = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.30" } @@ -168,6 +169,7 @@ std = [ "pallet-bridge-dispatch/std", "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", + "pallet-bridge-parachains/std", "pallet-fee-market/std", # frontier @@ -256,6 +258,7 @@ runtime-benchmarks = [ "bridge-runtime-common/runtime-benchmarks", "pallet-bridge-grandpa/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", "pallet-fee-market/runtime-benchmarks", # frontier diff --git a/runtime/crab/src/bridges_message/darwinia.rs b/runtime/crab/src/bridges_message/darwinia.rs index e9883b2e4..20ea1e71f 100644 --- a/runtime/crab/src/bridges_message/darwinia.rs +++ b/runtime/crab/src/bridges_message/darwinia.rs @@ -25,6 +25,7 @@ use sp_runtime::{FixedPointNumber, FixedU128}; // darwinia use crate::*; use bp_messages::{source_chain::*, target_chain::*, *}; +use bp_polkadot_core::parachains::ParaId; use bp_runtime::*; use bridge_runtime_common::{ lanes::*, @@ -155,11 +156,12 @@ impl TargetHeaderChain::Ac fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - source::verify_messages_delivery_proof::< + source::verify_messages_delivery_proof_from_parachain::< WithDarwiniaMessageBridge, + bp_darwinia::Header, Runtime, - WithDarwiniaGrandpa, - >(proof) + WithPolkadotParachainsInstance, + >(ParaId(2046), proof) } } impl SourceHeaderChain<::Balance> for Darwinia { @@ -170,9 +172,11 @@ impl SourceHeaderChain<::Balance> for Darwinia { proof: Self::MessagesProof, messages_count: u32, ) -> Result::Balance>>, Self::Error> { - target::verify_messages_proof::( - proof, - messages_count, - ) + target::verify_messages_proof_from_parachain::< + WithDarwiniaMessageBridge, + bp_darwinia::Header, + Runtime, + WithPolkadotParachainsInstance, + >(ParaId(2046), proof, messages_count) } } diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index d379aa5b2..6e8cdab54 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -316,7 +316,8 @@ frame_support::construct_runtime! { MessageTransact: darwinia_message_transact = 39, // S2S stuff. - BridgeDarwiniaGrandpa: pallet_bridge_grandpa:: = 35, + BridgePolkadotGrandpa: pallet_bridge_grandpa:: = 35, + BridgePolkadotParachain: pallet_bridge_parachains:: = 42, BridgeDarwiniaMessages: pallet_bridge_messages:: = 36, BridgeDarwiniaDispatch: pallet_bridge_dispatch:: = 37, DarwiniaFeeMarket: pallet_fee_market:: = 38 diff --git a/runtime/crab/src/pallets/bridge_grandpa.rs b/runtime/crab/src/pallets/bridge_grandpa.rs index 8fdfa09d4..986228c63 100644 --- a/runtime/crab/src/pallets/bridge_grandpa.rs +++ b/runtime/crab/src/pallets/bridge_grandpa.rs @@ -16,14 +16,16 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -pub use pallet_bridge_grandpa::Instance1 as WithDarwiniaGrandpa; +pub use pallet_bridge_grandpa::Instance1 as WithPolkadotGrandpa; // darwinia use crate::*; -impl pallet_bridge_grandpa::Config for Runtime { +pub type PolkadotHeadersToKeep = ConstU32<500>; + +impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_darwinia::DarwiniaLike; - type HeadersToKeep = ConstU32<500>; + type HeadersToKeep = PolkadotHeadersToKeep; type MaxBridgedAuthorities = (); type MaxBridgedHeaderSize = (); type MaxRequests = ConstU32<50>; diff --git a/runtime/crab/src/pallets/bridge_parachains.rs b/runtime/crab/src/pallets/bridge_parachains.rs new file mode 100644 index 000000000..3c0190d20 --- /dev/null +++ b/runtime/crab/src/pallets/bridge_parachains.rs @@ -0,0 +1,36 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2022 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +pub use pallet_bridge_parachains::Instance1 as WithPolkadotParachainsInstance; + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub const ParasPalletName: &'static str = bp_polkadot_core::parachains::PARAS_PALLET_NAME; +} + +impl pallet_bridge_parachains::Config for Runtime { + type BridgesGrandpaPalletInstance = WithPolkadotGrandpa; + type HeadsToKeep = PolkadotHeadersToKeep; + type MaxParaHeadSize = ConstU32<1024>; + type ParasPalletName = ParasPalletName; + type RuntimeEvent = RuntimeEvent; + type TrackedParachains = frame_support::traits::Everything; + type WeightInfo = (); +} diff --git a/runtime/crab/src/pallets/mod.rs b/runtime/crab/src/pallets/mod.rs index a64ad0db0..ed2a23a2f 100644 --- a/runtime/crab/src/pallets/mod.rs +++ b/runtime/crab/src/pallets/mod.rs @@ -117,5 +117,8 @@ pub use bridge_grandpa::*; mod bridge_messages; pub use bridge_messages::*; +mod bridge_parachains; +pub use bridge_parachains::*; + mod fee_market; pub use fee_market::*; diff --git a/runtime/darwinia/Cargo.toml b/runtime/darwinia/Cargo.toml index 54770923f..10cd885a5 100644 --- a/runtime/darwinia/Cargo.toml +++ b/runtime/darwinia/Cargo.toml @@ -48,15 +48,16 @@ darwinia-staking = { default-features = false, path = "../../pa dc-primitives = { default-features = false, path = "../../core/primitives" } # darwinia-messages-substrate -bp-message-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-polkadot-core = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bp-runtime = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -bridge-runtime-common = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-grandpa = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-bridge-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } -pallet-fee-market = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-message-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-polkadot-core = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bp-runtime = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +bridge-runtime-common = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-dispatch = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-grandpa = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-messages = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-bridge-parachains = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } +pallet-fee-market = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.30" } # frontier fp-rpc = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.30" } @@ -168,6 +169,7 @@ std = [ "pallet-bridge-dispatch/std", "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", + "pallet-bridge-parachains/std", "pallet-fee-market/std", # frontier @@ -256,6 +258,7 @@ runtime-benchmarks = [ "bridge-runtime-common/runtime-benchmarks", "pallet-bridge-grandpa/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", "pallet-fee-market/runtime-benchmarks", # frontier diff --git a/runtime/darwinia/src/bridges_message/crab.rs b/runtime/darwinia/src/bridges_message/crab.rs index dde6a12f8..b3772962d 100644 --- a/runtime/darwinia/src/bridges_message/crab.rs +++ b/runtime/darwinia/src/bridges_message/crab.rs @@ -25,6 +25,7 @@ use sp_runtime::{FixedPointNumber, FixedU128}; // darwinia use crate::*; use bp_messages::{source_chain::*, target_chain::*, *}; +use bp_polkadot_core::parachains::ParaId; use bp_runtime::*; use bridge_runtime_common::{ lanes::*, @@ -149,9 +150,12 @@ impl TargetHeaderChain::Accoun fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - source::verify_messages_delivery_proof::( - proof, - ) + source::verify_messages_delivery_proof_from_parachain::< + WithCrabMessageBridge, + bp_crab::Header, + Runtime, + WithKusamaParachainsInstance, + >(ParaId(2105), proof) } } impl SourceHeaderChain<::Balance> for Crab { @@ -162,9 +166,11 @@ impl SourceHeaderChain<::Balance> for Crab { proof: Self::MessagesProof, messages_count: u32, ) -> Result::Balance>>, Self::Error> { - target::verify_messages_proof::( - proof, - messages_count, - ) + target::verify_messages_proof_from_parachain::< + WithCrabMessageBridge, + bp_crab::Header, + Runtime, + WithKusamaParachainsInstance, + >(ParaId(2105), proof, messages_count) } } diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index c1f694ab2..1afd451c0 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -316,7 +316,8 @@ frame_support::construct_runtime! { MessageTransact: darwinia_message_transact = 39, // S2S stuff. - BridgeCrabGrandpa: pallet_bridge_grandpa:: = 35, + BridgeKusamaGrandpa: pallet_bridge_grandpa:: = 35, + BridgeKusamaParachain: pallet_bridge_parachains:: = 42, BridgeCrabMessages: pallet_bridge_messages:: = 36, BridgeCrabDispatch: pallet_bridge_dispatch:: = 37, CrabFeeMarket: pallet_fee_market:: = 38 diff --git a/runtime/darwinia/src/pallets/bridge_grandpa.rs b/runtime/darwinia/src/pallets/bridge_grandpa.rs index 6d64b9f8f..e1a8b7358 100644 --- a/runtime/darwinia/src/pallets/bridge_grandpa.rs +++ b/runtime/darwinia/src/pallets/bridge_grandpa.rs @@ -16,14 +16,16 @@ // You should have received a copy of the GNU General Public License // along with Darwinia. If not, see . -pub use pallet_bridge_grandpa::Instance1 as WithCrabGrandpa; +pub use pallet_bridge_grandpa::Instance1 as WithKusamaGrandpa; // darwinia use crate::*; -impl pallet_bridge_grandpa::Config for Runtime { +pub type KusamaHeadersToKeep = ConstU32<500>; + +impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_crab::DarwiniaLike; - type HeadersToKeep = ConstU32<500>; + type HeadersToKeep = KusamaHeadersToKeep; type MaxBridgedAuthorities = (); type MaxBridgedHeaderSize = (); type MaxRequests = ConstU32<50>; diff --git a/runtime/darwinia/src/pallets/bridge_parachains.rs b/runtime/darwinia/src/pallets/bridge_parachains.rs new file mode 100644 index 000000000..810f25788 --- /dev/null +++ b/runtime/darwinia/src/pallets/bridge_parachains.rs @@ -0,0 +1,36 @@ +// This file is part of Darwinia. +// +// Copyright (C) 2018-2022 Darwinia Network +// SPDX-License-Identifier: GPL-3.0 +// +// Darwinia is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Darwinia is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Darwinia. If not, see . + +pub use pallet_bridge_parachains::Instance1 as WithKusamaParachainsInstance; + +// darwinia +use crate::*; + +frame_support::parameter_types! { + pub const ParasPalletName: &'static str = bp_polkadot_core::parachains::PARAS_PALLET_NAME; +} + +impl pallet_bridge_parachains::Config for Runtime { + type BridgesGrandpaPalletInstance = WithKusamaGrandpa; + type HeadsToKeep = KusamaHeadersToKeep; + type MaxParaHeadSize = ConstU32<1024>; + type ParasPalletName = ParasPalletName; + type RuntimeEvent = RuntimeEvent; + type TrackedParachains = frame_support::traits::Everything; + type WeightInfo = (); +} diff --git a/runtime/darwinia/src/pallets/mod.rs b/runtime/darwinia/src/pallets/mod.rs index a64ad0db0..ed2a23a2f 100644 --- a/runtime/darwinia/src/pallets/mod.rs +++ b/runtime/darwinia/src/pallets/mod.rs @@ -117,5 +117,8 @@ pub use bridge_grandpa::*; mod bridge_messages; pub use bridge_messages::*; +mod bridge_parachains; +pub use bridge_parachains::*; + mod fee_market; pub use fee_market::*;