diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 60732339cf106..ad424f5cae6e7 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -501,7 +501,6 @@ impl pallet_bridge_messages::Config for Run parameter_types! { pub const RialtoParachainMessagesLane: bp_messages::LaneId = rialto_parachain_messages::XCM_LANE; - pub const RialtoParachainId: u32 = bp_rialto_parachain::RIALTO_PARACHAIN_ID; pub const RialtoParasPalletName: &'static str = bp_rialto::PARAS_PALLET_NAME; pub const WestendParasPalletName: &'static str = bp_westend::PARAS_PALLET_NAME; pub const MaxRialtoParaHeadDataSize: u32 = bp_rialto::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; @@ -602,7 +601,7 @@ bp_runtime::generate_static_str_provider!(BridgeRefundRialtoPara2000Lane0Msgs); pub type PriorityBoostPerMessage = ConstU64<324_316_715>; pub type BridgeRefundRialtoParachainMessages = RefundBridgedParachainMessages< Runtime, - RefundableParachain, + RefundableParachain, RefundableMessagesLane, ActualFeeRefund, PriorityBoostPerMessage, diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index de8ca493520e8..32b25b0e0bd4d 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -390,7 +390,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognised. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index 039e323b9b71e..08d102cc753ab 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -40,10 +40,8 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } # Polkadot dependencies -pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } -xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } [dev-dependencies] bp-test-utils = { path = "../../primitives/test-utils" } @@ -68,7 +66,6 @@ std = [ "pallet-bridge-relayers/std", "pallet-transaction-payment/std", "pallet-utility/std", - "pallet-xcm/std", "scale-info/std", "sp-api/std", "sp-core/std", @@ -78,13 +75,12 @@ std = [ "sp-trie/std", "xcm/std", "xcm-builder/std", - "xcm-executor/std", ] runtime-benchmarks = [ "pallet-bridge-grandpa/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", "pallet-bridge-parachains/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", + "pallet-bridge-relayers/runtime-benchmarks", "xcm-builder/runtime-benchmarks", ] integrity-test = [ diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs index 00ea70aa04eac..c54198373167f 100644 --- a/bridges/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs @@ -24,7 +24,7 @@ use crate::messages_call_ext::{ }; use bp_messages::{LaneId, MessageNonce}; use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; -use bp_runtime::{RangeInclusiveExt, StaticStrProvider}; +use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider}; use codec::{Decode, Encode}; use frame_support::{ dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo}, @@ -71,9 +71,9 @@ pub trait RefundableParachainId { } /// Default implementation of `RefundableParachainId`. -pub struct RefundableParachain(PhantomData<(Instance, Id)>); +pub struct DefaultRefundableParachainId(PhantomData<(Instance, Id)>); -impl RefundableParachainId for RefundableParachain +impl RefundableParachainId for DefaultRefundableParachainId where Id: Get, { @@ -81,6 +81,17 @@ where type Id = Id; } +/// Implementation of `RefundableParachainId` for `trait Parachain`. +pub struct RefundableParachain(PhantomData<(Instance, Para)>); + +impl RefundableParachainId for RefundableParachain +where + Para: Parachain, +{ + type Instance = Instance; + type Id = ParachainIdOf; +} + /// Trait identifying a bridged messages lane. A relayer might be refunded for delivering messages /// coming from this lane. pub trait RefundableMessagesLaneId { @@ -682,7 +693,7 @@ mod tests { bp_runtime::generate_static_str_provider!(TestExtension); type TestExtension = RefundBridgedParachainMessages< TestRuntime, - RefundableParachain<(), TestParachain>, + DefaultRefundableParachainId<(), TestParachain>, RefundableMessagesLane<(), TestLaneId>, ActualFeeRefund, ConstU64<1>, diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index 7670a3bacfe8d..5a393af7cc4e5 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -394,10 +394,10 @@ pub mod pallet { Some(parachain_head_data) => parachain_head_data, None => { log::trace!( - target: LOG_TARGET, - "The head of parachain {:?} has been provided, but it is not tracked by the pallet", - parachain, - ); + target: LOG_TARGET, + "The head of parachain {:?} has been provided, but it is not tracked by the pallet", + parachain, + ); Self::deposit_event(Event::UntrackedParachainRejected { parachain }); continue }, diff --git a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs index 6ca2cd047fb7e..00b6c8301e4c2 100644 --- a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs @@ -72,12 +72,10 @@ pub type Address = MultiAddress; pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002; /// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains. -// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages"; /// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged /// chains. -// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; decl_bridge_finality_runtime_apis!(bridge_hub_kusama); diff --git a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs index 646fb0a6e4186..8bd9167b618b1 100644 --- a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs @@ -59,16 +59,13 @@ impl Parachain for BridgeHubPolkadot { } /// Identifier of BridgeHubPolkadot in the Polkadot relay chain. -// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002; /// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains. -// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages"; /// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged /// chains. -// TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; decl_bridge_finality_runtime_apis!(bridge_hub_polkadot); diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 8e5aec8afda33..5cef6ae0ee64b 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras"; /// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa"; +/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot +/// parachains. +/// +/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some +/// reserve. +pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; + decl_bridge_finality_runtime_apis!(kusama); diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 92995601698d0..51d9f6f0233e3 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -62,4 +62,11 @@ pub const PARAS_PALLET_NAME: &str = "Paras"; /// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa"; +/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot +/// parachains. +/// +/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some +/// reserve. +pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; + decl_bridge_finality_runtime_apis!(polkadot); diff --git a/bridges/primitives/polkadot-core/src/parachains.rs b/bridges/primitives/polkadot-core/src/parachains.rs index 0b410dff49f75..9cac3279c7285 100644 --- a/bridges/primitives/polkadot-core/src/parachains.rs +++ b/bridges/primitives/polkadot-core/src/parachains.rs @@ -18,8 +18,8 @@ //! //! Even though this (bridges) repository references polkadot repository, we can't //! reference polkadot crates from pallets. That's because bridges repository is -//! included in the polkadot repository and included pallets are used by polkadot -//! chains. Having pallets that are referencing polkadot, would mean that there may +//! included in the Cumulus repository and included pallets are used by Cumulus +//! parachains. Having pallets that are referencing polkadot, would mean that there may //! be two versions of polkadot crates included in the runtime. Which is bad. use bp_runtime::{RawStorageProof, Size}; diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index 94b3a193c5829..c79058cea90cf 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -232,6 +232,14 @@ where const PARACHAIN_ID: u32 = <::Chain as Parachain>::PARACHAIN_ID; } +/// Adapter for `Get` to access `PARACHAIN_ID` from `trait Parachain` +pub struct ParachainIdOf(sp_std::marker::PhantomData); +impl frame_support::traits::Get for ParachainIdOf { + fn get() -> u32 { + Para::PARACHAIN_ID + } +} + /// Underlying chain type. pub type UnderlyingChainOf = ::Chain; diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 742ffe32ea753..1922a2eb16040 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -31,8 +31,8 @@ use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec}; pub use chain::{ AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf, - HasherOf, HeaderOf, IndexOf, Parachain, SignatureOf, TransactionEraOf, UnderlyingChainOf, - UnderlyingChainProvider, + HasherOf, HeaderOf, IndexOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf, + UnderlyingChainOf, UnderlyingChainProvider, }; pub use frame_support::storage::storage_prefix as storage_value_final_key; use num_traits::{CheckedAdd, CheckedSub, One, SaturatingAdd, Zero}; @@ -95,7 +95,7 @@ pub const BRIDGE_HUB_WOCOCO_CHAIN_ID: ChainId = *b"bhwo"; pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks"; /// BridgeHubPolkadot chain id. -pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhwo"; +pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd"; /// Generic header Id. #[derive( diff --git a/bridges/relays/bin-substrate/src/chains/kusama.rs b/bridges/relays/bin-substrate/src/chains/kusama.rs index 6d5a4764f91ec..0a30a0c07a095 100644 --- a/bridges/relays/bin-substrate/src/chains/kusama.rs +++ b/bridges/relays/bin-substrate/src/chains/kusama.rs @@ -26,7 +26,6 @@ impl CliChain for Kusama { } impl CliChain for BridgeHubKusama { - // TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945) const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 }); + Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 21 }); } diff --git a/bridges/relays/bin-substrate/src/chains/polkadot.rs b/bridges/relays/bin-substrate/src/chains/polkadot.rs index 4fe5a48398bcd..b2585dbb3050d 100644 --- a/bridges/relays/bin-substrate/src/chains/polkadot.rs +++ b/bridges/relays/bin-substrate/src/chains/polkadot.rs @@ -26,7 +26,6 @@ impl CliChain for Polkadot { } impl CliChain for BridgeHubPolkadot { - // TODO: fix me (https://github.com/paritytech/parity-bridges-common/issues/1945) const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion { spec_version: 4242, transaction_version: 42 }); + Some(SimpleRuntimeVersion { spec_version: 9410, transaction_version: 22 }); } diff --git a/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs b/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs index 18bdafc0f04de..96a5b4fe033c7 100644 --- a/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs +++ b/bridges/relays/client-bridge-hub-kusama/src/runtime_wrapper.rs @@ -54,16 +54,13 @@ pub enum Call { Utility(UtilityCall), /// Polkadot bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 41)] + #[codec(index = 51)] BridgePolkadotGrandpa(BridgePolkadotGrandpaCall), /// Polkadot parachain bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 42)] + #[codec(index = 52)] BridgePolkadotParachain(BridgeParachainCall), /// Polkadot messages bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 46)] + #[codec(index = 53)] BridgePolkadotMessages(BridgePolkadotMessagesCall), } diff --git a/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs b/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs index 5afac61dbb3fc..924d3bbef07d6 100644 --- a/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs +++ b/bridges/relays/client-bridge-hub-polkadot/src/runtime_wrapper.rs @@ -53,16 +53,13 @@ pub enum Call { Utility(UtilityCall), /// Kusama bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 43)] + #[codec(index = 51)] BridgeKusamaGrandpa(BridgeKusamaGrandpaCall), /// Kusama parachain bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 44)] + #[codec(index = 52)] BridgeKusamaParachain(BridgeParachainCall), /// Kusama messages bridge pallet. - // TODO: the index is wrong (https://github.com/paritytech/parity-bridges-common/issues/1945) - #[codec(index = 45)] + #[codec(index = 53)] BridgeKusamaMessages(BridgeKusamaMessagesCall), } @@ -114,6 +111,6 @@ mod tests { // encode call as hex string let hex_encoded_call = format!("0x{:?}", HexDisplay::from(&Encode::encode(&tx))); - assert_eq!(hex_encoded_call, "0x2b01ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000"); + assert_eq!(hex_encoded_call, "0x3301ae4a25acf250d72ed02c149ecc7dd3c9ee976d41a2888fc551de8064521dc01d2d0192b965f0656a4e0e5fc0167da2d4b5ee72b3be2c1583c4c1e5236c8c12aa141bd2c0afaab32de0cb8f7f0d89217e37c5ea302c1ffb5a7a83e10d20f12c32874d0000060000000000000000"); } } diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs index 99a52b4baf434..3d53fe8f9f186 100644 --- a/bridges/relays/client-kusama/src/lib.rs +++ b/bridges/relays/client-kusama/src/lib.rs @@ -55,6 +55,5 @@ impl ChainWithBalances for Kusama { impl RelayChain for Kusama { const PARAS_PALLET_NAME: &'static str = bp_kusama::PARAS_PALLET_NAME; - // TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgeKusamaParachain"; } diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs index 7f8615e0cd0ef..96453ab9041a8 100644 --- a/bridges/relays/client-polkadot/src/lib.rs +++ b/bridges/relays/client-polkadot/src/lib.rs @@ -55,6 +55,5 @@ impl ChainWithBalances for Polkadot { impl RelayChain for Polkadot { const PARAS_PALLET_NAME: &'static str = bp_polkadot::PARAS_PALLET_NAME; - // TODO: check me (https://github.com/paritytech/parity-bridges-common/issues/1945) const PARACHAINS_FINALITY_PALLET_NAME: &'static str = "BridgePolkadotParachain"; }