From db157ce08b2a80c42857439fd5f0f092025dd311 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 11 Jan 2024 12:39:23 +0300 Subject: [PATCH] Port safe commits from master to polkadot-staging (#2761) * introduce bp_messages::ChainWithMessages (#2171) * Move Chain::ID from relay-level Chain to primitives-level Chain (#2181) * move Chain::ID from relay-level Chain to primitives-level Chain * removed chain IDs from bp-runtime * add missing file header * Some code grooming (#2276) * some code grooming: enable warn(missing_docs) for all piblic crates + added missing documentation + removed obsolete clippy/deny workarounds * removed strange allow + added comment related to other allow * removed incorrect_clone_impl_on_copy_type which is unknown to CI clippy --- bridges/bin/runtime-common/src/lib.rs | 1 + .../runtime-common/src/messages_call_ext.rs | 7 ++- .../src/messages_xcm_extension.rs | 5 +- bridges/bin/runtime-common/src/mock.rs | 6 +++ .../src/parachains_benchmarking.rs | 2 +- .../src/refund_relayer_extension.rs | 6 +-- bridges/modules/beefy/src/lib.rs | 1 + bridges/modules/beefy/src/mock.rs | 4 +- bridges/modules/grandpa/src/lib.rs | 5 +- bridges/modules/grandpa/src/mock.rs | 6 ++- bridges/modules/messages/src/lib.rs | 18 +++++-- bridges/modules/parachains/src/call_ext.rs | 2 +- bridges/modules/parachains/src/lib.rs | 34 +++++++++++-- bridges/modules/parachains/src/mock.rs | 14 +++++- .../chain-bridge-hub-cumulus/src/lib.rs | 5 ++ .../chain-bridge-hub-kusama/src/lib.rs | 14 +++++- .../chain-bridge-hub-polkadot/src/lib.rs | 15 +++++- .../chain-bridge-hub-rococo/src/lib.rs | 15 +++++- .../chain-bridge-hub-westend/src/lib.rs | 14 +++++- bridges/primitives/chain-kusama/src/lib.rs | 29 ++++++----- .../chain-polkadot-bulletin/src/lib.rs | 16 ++++++- bridges/primitives/chain-polkadot/src/lib.rs | 31 +++++++----- bridges/primitives/chain-rococo/src/lib.rs | 35 +++++++------- bridges/primitives/chain-westend/src/lib.rs | 35 +++++++------- bridges/primitives/header-chain/src/lib.rs | 14 +++++- bridges/primitives/messages/src/lib.rs | 47 ++++++++++++++++-- bridges/primitives/parachains/src/lib.rs | 4 ++ bridges/primitives/polkadot-core/src/lib.rs | 48 +++++++++---------- .../polkadot-core/src/parachains.rs | 13 +++-- bridges/primitives/runtime/src/chain.rs | 8 +++- bridges/primitives/runtime/src/extensions.rs | 2 + bridges/primitives/runtime/src/lib.rs | 43 ++++------------- bridges/primitives/test-utils/src/keyring.rs | 10 +++- bridges/primitives/test-utils/src/lib.rs | 6 ++- .../src/bridges/rococo_bulletin/mod.rs | 23 +++++---- .../client-bridge-hub-kusama/Cargo.toml | 2 - .../client-bridge-hub-kusama/src/lib.rs | 10 ---- .../client-bridge-hub-polkadot/Cargo.toml | 1 - .../client-bridge-hub-polkadot/src/lib.rs | 10 ---- .../client-bridge-hub-rococo/Cargo.toml | 2 +- .../client-bridge-hub-rococo/src/lib.rs | 10 ---- .../client-bridge-hub-westend/Cargo.toml | 5 +- .../client-bridge-hub-westend/src/lib.rs | 10 ---- bridges/relays/client-kusama/src/lib.rs | 2 - .../client-polkadot-bulletin/src/lib.rs | 11 ----- bridges/relays/client-polkadot/src/lib.rs | 2 - bridges/relays/client-rococo/Cargo.toml | 1 - bridges/relays/client-rococo/src/lib.rs | 2 - bridges/relays/client-substrate/src/chain.rs | 24 ++-------- .../relays/client-substrate/src/test_chain.rs | 6 ++- bridges/relays/client-westend/src/lib.rs | 2 - .../lib-substrate-relay/src/messages_lane.rs | 2 +- .../src/messages_source.rs | 4 +- .../src/messages_target.rs | 8 ++-- .../src/parachains/source.rs | 2 +- .../relays/parachains/src/parachains_loop.rs | 3 +- 56 files changed, 389 insertions(+), 268 deletions(-) diff --git a/bridges/bin/runtime-common/src/lib.rs b/bridges/bin/runtime-common/src/lib.rs index d3b3b21061d05..2722f6f1c6d14 100644 --- a/bridges/bin/runtime-common/src/lib.rs +++ b/bridges/bin/runtime-common/src/lib.rs @@ -16,6 +16,7 @@ //! Common types/functions that may be used by runtimes of all bridged chains. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use crate::messages_call_ext::MessagesCallSubType; diff --git a/bridges/bin/runtime-common/src/messages_call_ext.rs b/bridges/bin/runtime-common/src/messages_call_ext.rs index 5303fcb7ba030..fb07f7b6dd691 100644 --- a/bridges/bin/runtime-common/src/messages_call_ext.rs +++ b/bridges/bin/runtime-common/src/messages_call_ext.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Signed extension for the `pallet-bridge-messages` that is able to reject obsolete +//! (and some other invalid) transactions. + use crate::messages::{ source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, }; @@ -116,7 +119,9 @@ impl ReceiveMessagesDeliveryProofInfo { /// which tries to update a single lane. #[derive(PartialEq, RuntimeDebug)] pub enum CallInfo { + /// Messages delivery call info. ReceiveMessagesProof(ReceiveMessagesProofInfo), + /// Messages delivery confirmation call info. ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo), } @@ -132,7 +137,7 @@ impl CallInfo { /// Helper struct that provides methods for working with a call supported by `CallInfo`. pub struct CallHelper, I: 'static> { - pub _phantom_data: sp_std::marker::PhantomData<(T, I)>, + _phantom_data: sp_std::marker::PhantomData<(T, I)>, } impl, I: 'static> CallHelper { diff --git a/bridges/bin/runtime-common/src/messages_xcm_extension.rs b/bridges/bin/runtime-common/src/messages_xcm_extension.rs index 53c0579c4cd04..4892297a3dfdf 100644 --- a/bridges/bin/runtime-common/src/messages_xcm_extension.rs +++ b/bridges/bin/runtime-common/src/messages_xcm_extension.rs @@ -40,11 +40,14 @@ use sp_std::{fmt::Debug, marker::PhantomData}; use xcm::prelude::*; use xcm_builder::{DispatchBlob, DispatchBlobError}; -/// Message dispatch result type for single message +/// Message dispatch result type for single message. #[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)] pub enum XcmBlobMessageDispatchResult { + /// We've been unable to decode message payload. InvalidPayload, + /// Message has been dispatched. Dispatched, + /// Message has **NOT** been dispatched because of given error. NotDispatched(#[codec(skip)] Option), } diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index b783ce987ced3..8877a4fd95ce3 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -314,6 +314,8 @@ impl From pub struct ThisUnderlyingChain; impl Chain for ThisUnderlyingChain { + const ID: ChainId = *b"tuch"; + type BlockNumber = ThisChainBlockNumber; type Hash = ThisChainHash; type Hasher = ThisChainHasher; @@ -354,6 +356,8 @@ pub struct BridgedUnderlyingParachain; pub struct BridgedChainCall; impl Chain for BridgedUnderlyingChain { + const ID: ChainId = *b"buch"; + type BlockNumber = BridgedChainBlockNumber; type Hash = BridgedChainHash; type Hasher = BridgedChainHasher; @@ -380,6 +384,8 @@ impl ChainWithGrandpa for BridgedUnderlyingChain { } impl Chain for BridgedUnderlyingParachain { + const ID: ChainId = *b"bupc"; + type BlockNumber = BridgedChainBlockNumber; type Hash = BridgedChainHash; type Hasher = BridgedChainHasher; diff --git a/bridges/bin/runtime-common/src/parachains_benchmarking.rs b/bridges/bin/runtime-common/src/parachains_benchmarking.rs index 63dc78385e46e..b3050b9ac0f3c 100644 --- a/bridges/bin/runtime-common/src/parachains_benchmarking.rs +++ b/bridges/bin/runtime-common/src/parachains_benchmarking.rs @@ -84,5 +84,5 @@ where let (relay_block_number, relay_block_hash) = insert_header_to_grandpa_pallet::(state_root); - (relay_block_number, relay_block_hash, ParaHeadsProof(proof), parachain_heads) + (relay_block_number, relay_block_hash, ParaHeadsProof { storage_proof: proof }, parachain_heads) } diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs index 6d8b211480858..27b7ff1a5519b 100644 --- a/bridges/bin/runtime-common/src/refund_relayer_extension.rs +++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs @@ -116,7 +116,7 @@ where /// Refund calculator. pub trait RefundCalculator { - // The underlying integer type in which the refund is calculated. + /// The underlying integer type in which the refund is calculated. type Balance; /// Compute refund for given transaction. @@ -986,7 +986,7 @@ mod tests { ParaId(TestParachain::get()), [parachain_head_at_relay_header_number as u8; 32].into(), )], - parachain_heads_proof: ParaHeadsProof(vec![]), + parachain_heads_proof: ParaHeadsProof { storage_proof: vec![] }, }) } @@ -1732,7 +1732,7 @@ mod tests { (ParaId(TestParachain::get()), [1u8; 32].into()), (ParaId(TestParachain::get() + 1), [1u8; 32].into()), ], - parachain_heads_proof: ParaHeadsProof(vec![]), + parachain_heads_proof: ParaHeadsProof { storage_proof: vec![] }, }), message_delivery_call(200), ], diff --git a/bridges/modules/beefy/src/lib.rs b/bridges/modules/beefy/src/lib.rs index 686115a7b0ed5..27c83921021bb 100644 --- a/bridges/modules/beefy/src/lib.rs +++ b/bridges/modules/beefy/src/lib.rs @@ -29,6 +29,7 @@ //! Given the header hash, other pallets are able to verify header-based proofs //! (e.g. storage proofs, transaction inclusion proofs, etc.). +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use bp_beefy::{ChainWithBeefy, InitializationData}; diff --git a/bridges/modules/beefy/src/mock.rs b/bridges/modules/beefy/src/mock.rs index f89fd1e63480c..c99566b6b06d1 100644 --- a/bridges/modules/beefy/src/mock.rs +++ b/bridges/modules/beefy/src/mock.rs @@ -22,7 +22,7 @@ use crate::{ }; use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash}; -use bp_runtime::{BasicOperatingMode, Chain}; +use bp_runtime::{BasicOperatingMode, Chain, ChainId}; use codec::Encode; use frame_support::{construct_runtime, derive_impl, weights::Weight}; use sp_core::{sr25519::Signature, Pair}; @@ -81,6 +81,8 @@ impl beefy::Config for TestRuntime { pub struct TestBridgedChain; impl Chain for TestBridgedChain { + const ID: ChainId = *b"tbch"; + type BlockNumber = TestBridgedBlockNumber; type Hash = H256; type Hasher = BlakeTwo256; diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 22df604bf1895..f58db2481ada1 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -32,9 +32,8 @@ //! Shall the fork occur on the bridged chain governance intervention will be required to //! re-initialize the bridge and track the right fork. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// Runtime-generated enums -#![allow(clippy::large_enum_variant)] pub use storage_types::StoredAuthoritySet; @@ -408,7 +407,9 @@ pub mod pallet { pub enum Event, I: 'static = ()> { /// Best finalized chain header has been updated to the header with given number and hash. UpdatedBestFinalizedHeader { + /// Number of the new best finalized header. number: BridgedBlockNumber, + /// Hash of the new best finalized header. hash: BridgedBlockHash, /// The Grandpa info associated to the new best finalized header. grandpa_info: StoredHeaderGrandpaInfo>, diff --git a/bridges/modules/grandpa/src/mock.rs b/bridges/modules/grandpa/src/mock.rs index a54f56c4a6249..e41e89341b312 100644 --- a/bridges/modules/grandpa/src/mock.rs +++ b/bridges/modules/grandpa/src/mock.rs @@ -18,7 +18,7 @@ #![allow(clippy::from_over_into)] use bp_header_chain::ChainWithGrandpa; -use bp_runtime::Chain; +use bp_runtime::{Chain, ChainId}; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::Hooks, weights::Weight, }; @@ -64,7 +64,9 @@ impl grandpa::Config for TestRuntime { pub struct TestBridgedChain; impl Chain for TestBridgedChain { - type BlockNumber = TestNumber; + const ID: ChainId = *b"tbch"; + + type BlockNumber = frame_system::pallet_prelude::BlockNumberFor; type Hash = ::Hash; type Hasher = ::Hashing; type Header = TestHeader; diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs index eeae95b482c86..401ec185485b7 100644 --- a/bridges/modules/messages/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -33,9 +33,8 @@ //! If this test fails with your weights, then either weights are computed incorrectly, //! or some benchmarks assumptions are broken for your runtime. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// Generated by `decl_event!` -#![allow(clippy::unused_unit)] pub use inbound_lane::StoredInboundLaneData; pub use outbound_lane::StoredMessagePayload; @@ -514,13 +513,24 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { /// Message has been accepted and is waiting to be delivered. - MessageAccepted { lane_id: LaneId, nonce: MessageNonce }, + MessageAccepted { + /// Lane, which has accepted the message. + lane_id: LaneId, + /// Nonce of accepted message. + nonce: MessageNonce, + }, /// Messages have been received from the bridged chain. MessagesReceived( + /// Result of received messages dispatch. Vec::DispatchLevelResult>>, ), /// Messages in the inclusive range have been delivered to the bridged chain. - MessagesDelivered { lane_id: LaneId, messages: DeliveredMessages }, + MessagesDelivered { + /// Lane for which the delivery has been confirmed. + lane_id: LaneId, + /// Delivered messages. + messages: DeliveredMessages, + }, } #[pallet::error] diff --git a/bridges/modules/parachains/src/call_ext.rs b/bridges/modules/parachains/src/call_ext.rs index 198ff11be4951..da91a40a23223 100644 --- a/bridges/modules/parachains/src/call_ext.rs +++ b/bridges/modules/parachains/src/call_ext.rs @@ -178,7 +178,7 @@ mod tests { RuntimeCall::Parachains(crate::Call::::submit_parachain_heads { at_relay_block: (num, Default::default()), parachains, - parachain_heads_proof: ParaHeadsProof(Vec::new()), + parachain_heads_proof: ParaHeadsProof { storage_proof: Vec::new() }, }) .check_obsolete_submit_parachain_heads() .is_ok() diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs index b2ef0bf52bd3d..9adeacb0eb882 100644 --- a/bridges/modules/parachains/src/lib.rs +++ b/bridges/modules/parachains/src/lib.rs @@ -21,6 +21,7 @@ //! accepts storage proof of some parachain `Heads` entries from bridged relay chain. //! It requires corresponding relay headers to be already synced. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use weights::WeightInfo; @@ -98,27 +99,49 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { /// The caller has provided head of parachain that the pallet is not configured to track. - UntrackedParachainRejected { parachain: ParaId }, + UntrackedParachainRejected { + /// Identifier of the parachain that is not tracked by the pallet. + parachain: ParaId, + }, /// The caller has declared that he has provided given parachain head, but it is missing /// from the storage proof. - MissingParachainHead { parachain: ParaId }, + MissingParachainHead { + /// Identifier of the parachain with missing head. + parachain: ParaId, + }, /// The caller has provided parachain head hash that is not matching the hash read from the /// storage proof. IncorrectParachainHeadHash { + /// Identifier of the parachain with incorrect head hast. parachain: ParaId, + /// Specified parachain head hash. parachain_head_hash: ParaHash, + /// Actual parachain head hash. actual_parachain_head_hash: ParaHash, }, /// The caller has provided obsolete parachain head, which is already known to the pallet. - RejectedObsoleteParachainHead { parachain: ParaId, parachain_head_hash: ParaHash }, + RejectedObsoleteParachainHead { + /// Identifier of the parachain with obsolete head. + parachain: ParaId, + /// Obsolete parachain head hash. + parachain_head_hash: ParaHash, + }, /// The caller has provided parachain head that exceeds the maximal configured head size. RejectedLargeParachainHead { + /// Identifier of the parachain with rejected head. parachain: ParaId, + /// Parachain head hash. parachain_head_hash: ParaHash, + /// Parachain head size. parachain_head_size: u32, }, /// Parachain head has been updated. - UpdatedParachainHead { parachain: ParaId, parachain_head_hash: ParaHash }, + UpdatedParachainHead { + /// Identifier of the parachain that has been updated. + parachain: ParaId, + /// Parachain head hash. + parachain_head_hash: ParaHash, + }, } #[pallet::error] @@ -137,6 +160,7 @@ pub mod pallet { pub trait BoundedBridgeGrandpaConfig: pallet_bridge_grandpa::Config { + /// Type of the bridged relay chain. type BridgedRelayChain: Chain< BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, @@ -336,7 +360,7 @@ pub mod pallet { let mut storage = GrandpaPalletOf::::storage_proof_checker( relay_block_hash, - parachain_heads_proof.0, + parachain_heads_proof.storage_proof, ) .map_err(Error::::HeaderChainStorageProof)?; diff --git a/bridges/modules/parachains/src/mock.rs b/bridges/modules/parachains/src/mock.rs index 1c7851364d1c0..143f11d986371 100644 --- a/bridges/modules/parachains/src/mock.rs +++ b/bridges/modules/parachains/src/mock.rs @@ -16,7 +16,7 @@ use bp_header_chain::ChainWithGrandpa; use bp_polkadot_core::parachains::ParaId; -use bp_runtime::{Chain, Parachain}; +use bp_runtime::{Chain, ChainId, Parachain}; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::ConstU32, weights::Weight, }; @@ -49,6 +49,8 @@ pub type BigParachainHeader = sp_runtime::generic::Header; pub struct Parachain1; impl Chain for Parachain1 { + const ID: ChainId = *b"pch1"; + type BlockNumber = u64; type Hash = H256; type Hasher = RegularParachainHasher; @@ -73,6 +75,8 @@ impl Parachain for Parachain1 { pub struct Parachain2; impl Chain for Parachain2 { + const ID: ChainId = *b"pch2"; + type BlockNumber = u64; type Hash = H256; type Hasher = RegularParachainHasher; @@ -97,6 +101,8 @@ impl Parachain for Parachain2 { pub struct Parachain3; impl Chain for Parachain3 { + const ID: ChainId = *b"pch3"; + type BlockNumber = u64; type Hash = H256; type Hasher = RegularParachainHasher; @@ -122,6 +128,8 @@ impl Parachain for Parachain3 { pub struct BigParachain; impl Chain for BigParachain { + const ID: ChainId = *b"bpch"; + type BlockNumber = u128; type Hash = H256; type Hasher = RegularParachainHasher; @@ -229,6 +237,8 @@ impl pallet_bridge_parachains::benchmarking::Config<()> for TestRuntime { pub struct TestBridgedChain; impl Chain for TestBridgedChain { + const ID: ChainId = *b"tbch"; + type BlockNumber = crate::RelayBlockNumber; type Hash = crate::RelayBlockHash; type Hasher = crate::RelayBlockHasher; @@ -260,6 +270,8 @@ impl ChainWithGrandpa for TestBridgedChain { pub struct OtherBridgedChain; impl Chain for OtherBridgedChain { + const ID: ChainId = *b"obch"; + type BlockNumber = u64; type Hash = crate::RelayBlockHash; type Hasher = crate::RelayBlockHasher; diff --git a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs index cd281324ee55f..285f00204810b 100644 --- a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of all Cumulus-based bridge hubs. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use bp_polkadot_core::{ @@ -61,6 +64,7 @@ const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(constants::WEIGHT_REF_TI pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); parameter_types! { + /// Size limit of the Cumulus-based bridge hub blocks. pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio( 5 * 1024 * 1024, NORMAL_DISPATCH_RATIO, @@ -73,6 +77,7 @@ parameter_types! { pub const ExtrinsicBaseWeight: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS, 0) .saturating_mul(125_000); + /// Weight limit of the Cumulus-based bridge hub blocks. pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() .base_block(BlockExecutionWeight::get()) .for_class(DispatchClass::all(), |weights| { diff --git a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs index 66e0dad05895c..576e3dbee80d0 100644 --- a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs @@ -17,12 +17,13 @@ //! Module with configuration which reflects BridgeHubKusama runtime setup (AccountId, Headers, //! Hashes...) +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use bp_bridge_hub_cumulus::*; use bp_messages::*; use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain, }; use frame_support::{ dispatch::DispatchClass, @@ -35,6 +36,8 @@ use sp_runtime::RuntimeDebug; pub struct BridgeHubKusama; impl Chain for BridgeHubKusama { + const ID: ChainId = *b"bhks"; + type BlockNumber = BlockNumber; type Hash = Hash; type Hasher = Hasher; @@ -61,6 +64,15 @@ impl Parachain for BridgeHubKusama { const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID; } +impl ChainWithMessages for BridgeHubKusama { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME; + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Public key of the chain account that may be used to verify signatures. pub type AccountSigner = MultiSigner; diff --git a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs index c3661c1adcada..6db389c92994d 100644 --- a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs @@ -17,12 +17,13 @@ //! Module with configuration which reflects BridgeHubPolkadot runtime setup //! (AccountId, Headers, Hashes...) +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use bp_bridge_hub_cumulus::*; use bp_messages::*; use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain, }; use frame_support::dispatch::DispatchClass; use sp_runtime::RuntimeDebug; @@ -32,6 +33,8 @@ use sp_runtime::RuntimeDebug; pub struct BridgeHubPolkadot; impl Chain for BridgeHubPolkadot { + const ID: ChainId = *b"bhpd"; + type BlockNumber = BlockNumber; type Hash = Hash; type Hasher = Hasher; @@ -58,6 +61,16 @@ impl Parachain for BridgeHubPolkadot { const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID; } +impl ChainWithMessages for BridgeHubPolkadot { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME; + + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Identifier of BridgeHubPolkadot in the Polkadot relay chain. pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002; diff --git a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs index f79b8a8afb321..7b109f30fe0b9 100644 --- a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs @@ -17,12 +17,13 @@ //! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers, //! Hashes...) +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use bp_bridge_hub_cumulus::*; use bp_messages::*; use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain, }; use frame_support::dispatch::DispatchClass; use sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug}; @@ -32,6 +33,8 @@ use sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug}; pub struct BridgeHubRococo; impl Chain for BridgeHubRococo { + const ID: ChainId = *b"bhro"; + type BlockNumber = BlockNumber; type Hash = Hash; type Hasher = Hasher; @@ -58,6 +61,16 @@ impl Parachain for BridgeHubRococo { const PARACHAIN_ID: u32 = BRIDGE_HUB_ROCOCO_PARACHAIN_ID; } +impl ChainWithMessages for BridgeHubRococo { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME; + + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Public key of the chain account that may be used to verify signatures. pub type AccountSigner = MultiSigner; diff --git a/bridges/primitives/chain-bridge-hub-westend/src/lib.rs b/bridges/primitives/chain-bridge-hub-westend/src/lib.rs index f4524f719f9fd..83d4d6e33a759 100644 --- a/bridges/primitives/chain-bridge-hub-westend/src/lib.rs +++ b/bridges/primitives/chain-bridge-hub-westend/src/lib.rs @@ -22,7 +22,7 @@ pub use bp_bridge_hub_cumulus::*; use bp_messages::*; use bp_runtime::{ - decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, ChainId, Parachain, }; use frame_support::dispatch::DispatchClass; use sp_runtime::RuntimeDebug; @@ -32,6 +32,8 @@ use sp_runtime::RuntimeDebug; pub struct BridgeHubWestend; impl Chain for BridgeHubWestend { + const ID: ChainId = *b"bhwd"; + type BlockNumber = BlockNumber; type Hash = Hash; type Hasher = Hasher; @@ -58,6 +60,16 @@ impl Parachain for BridgeHubWestend { const PARACHAIN_ID: u32 = BRIDGE_HUB_WESTEND_PARACHAIN_ID; } +impl ChainWithMessages for BridgeHubWestend { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME; + + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Identifier of BridgeHubWestend in the Westend relay chain. pub const BRIDGE_HUB_WESTEND_PARACHAIN_ID: u32 = 1002; diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 5f089fbc589f6..e3b4d0520f61c 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -14,36 +14,39 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of the Kusama chain. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] pub use bp_polkadot_core::*; use bp_header_chain::ChainWithGrandpa; -use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, ChainId}; use frame_support::weights::Weight; /// Kusama Chain pub struct Kusama; impl Chain for Kusama { - type BlockNumber = ::BlockNumber; - type Hash = ::Hash; - type Hasher = ::Hasher; - type Header = ::Header; + const ID: ChainId = *b"ksma"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; - type AccountId = ::AccountId; - type Balance = ::Balance; - type Nonce = ::Nonce; - type Signature = ::Signature; + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; fn max_extrinsic_size() -> u32 { - PolkadotLike::max_extrinsic_size() + max_extrinsic_size() } fn max_extrinsic_weight() -> Weight { - PolkadotLike::max_extrinsic_weight() + max_extrinsic_weight() } } diff --git a/bridges/primitives/chain-polkadot-bulletin/src/lib.rs b/bridges/primitives/chain-polkadot-bulletin/src/lib.rs index fe82c9644b673..f2eebf9312470 100644 --- a/bridges/primitives/chain-polkadot-bulletin/src/lib.rs +++ b/bridges/primitives/chain-polkadot-bulletin/src/lib.rs @@ -20,14 +20,14 @@ #![cfg_attr(not(feature = "std"), no_std)] use bp_header_chain::ChainWithGrandpa; -use bp_messages::MessageNonce; +use bp_messages::{ChainWithMessages, MessageNonce}; use bp_runtime::{ decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, extensions::{ CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckWeight, GenericSignedExtension, GenericSignedExtensionSchema, }, - Chain, TransactionEra, + Chain, ChainId, TransactionEra, }; use codec::{Decode, Encode}; use frame_support::{ @@ -177,6 +177,8 @@ parameter_types! { pub struct PolkadotBulletin; impl Chain for PolkadotBulletin { + const ID: ChainId = *b"pdbc"; + type BlockNumber = BlockNumber; type Hash = Hash; type Hasher = Hasher; @@ -211,5 +213,15 @@ impl ChainWithGrandpa for PolkadotBulletin { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } +impl ChainWithMessages for PolkadotBulletin { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + WITH_POLKADOT_BULLETIN_MESSAGES_PALLET_NAME; + + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + decl_bridge_finality_runtime_apis!(polkadot_bulletin, grandpa); decl_bridge_messages_runtime_apis!(polkadot_bulletin); diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index 9a5b8970accb2..fc5e10308a8e3 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -14,36 +14,41 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of the Polkadot chain. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] pub use bp_polkadot_core::*; use bp_header_chain::ChainWithGrandpa; -use bp_runtime::{decl_bridge_finality_runtime_apis, extensions::PrevalidateAttests, Chain}; +use bp_runtime::{ + decl_bridge_finality_runtime_apis, extensions::PrevalidateAttests, Chain, ChainId, +}; use frame_support::weights::Weight; /// Polkadot Chain pub struct Polkadot; impl Chain for Polkadot { - type BlockNumber = ::BlockNumber; - type Hash = ::Hash; - type Hasher = ::Hasher; - type Header = ::Header; + const ID: ChainId = *b"pdot"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; - type AccountId = ::AccountId; - type Balance = ::Balance; - type Nonce = ::Nonce; - type Signature = ::Signature; + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; fn max_extrinsic_size() -> u32 { - PolkadotLike::max_extrinsic_size() + max_extrinsic_size() } fn max_extrinsic_weight() -> Weight { - PolkadotLike::max_extrinsic_weight() + max_extrinsic_weight() } } diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 7f3e762715f32..f1b256f0f090f 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -14,36 +14,39 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of the Rococo chain. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] pub use bp_polkadot_core::*; use bp_header_chain::ChainWithGrandpa; -use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; -use frame_support::{parameter_types, weights::Weight}; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, ChainId}; +use frame_support::weights::Weight; /// Rococo Chain pub struct Rococo; impl Chain for Rococo { - type BlockNumber = ::BlockNumber; - type Hash = ::Hash; - type Hasher = ::Hasher; - type Header = ::Header; + const ID: ChainId = *b"roco"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; - type AccountId = ::AccountId; - type Balance = ::Balance; - type Nonce = ::Nonce; - type Signature = ::Signature; + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; fn max_extrinsic_size() -> u32 { - PolkadotLike::max_extrinsic_size() + max_extrinsic_size() } fn max_extrinsic_weight() -> Weight { - PolkadotLike::max_extrinsic_weight() + max_extrinsic_weight() } } @@ -56,10 +59,6 @@ impl ChainWithGrandpa for Rococo { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -parameter_types! { - pub const SS58Prefix: u8 = 42; -} - // The SignedExtension used by Rococo. pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index 7fa5e140d5707..f03fd2160a700 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -14,36 +14,39 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of the Westend chain. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] pub use bp_polkadot_core::*; use bp_header_chain::ChainWithGrandpa; -use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; -use frame_support::{parameter_types, weights::Weight}; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, ChainId}; +use frame_support::weights::Weight; /// Westend Chain pub struct Westend; impl Chain for Westend { - type BlockNumber = ::BlockNumber; - type Hash = ::Hash; - type Hasher = ::Hasher; - type Header = ::Header; + const ID: ChainId = *b"wend"; + + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; - type AccountId = ::AccountId; - type Balance = ::Balance; - type Nonce = ::Nonce; - type Signature = ::Signature; + type AccountId = AccountId; + type Balance = Balance; + type Nonce = Nonce; + type Signature = Signature; fn max_extrinsic_size() -> u32 { - PolkadotLike::max_extrinsic_size() + max_extrinsic_size() } fn max_extrinsic_weight() -> Weight { - PolkadotLike::max_extrinsic_weight() + max_extrinsic_weight() } } @@ -56,10 +59,6 @@ impl ChainWithGrandpa for Westend { const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; } -parameter_types! { - pub const SS58Prefix: u8 = 42; -} - // The SignedExtension used by Westend. pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; diff --git a/bridges/primitives/header-chain/src/lib.rs b/bridges/primitives/header-chain/src/lib.rs index 1459b1c1994bc..f5485aca1ee8b 100644 --- a/bridges/primitives/header-chain/src/lib.rs +++ b/bridges/primitives/header-chain/src/lib.rs @@ -17,6 +17,7 @@ //! Defines traits which represent a common interface for Substrate pallets which want to //! incorporate bridge functionality. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use crate::justification::{ @@ -145,6 +146,7 @@ pub trait ConsensusLogReader { pub struct GrandpaConsensusLogReader(sp_std::marker::PhantomData); impl GrandpaConsensusLogReader { + /// Find and return scheduled (regular) change digest item. pub fn find_scheduled_change( digest: &Digest, ) -> Option> { @@ -158,6 +160,8 @@ impl GrandpaConsensusLogReader { }) } + /// Find and return forced change digest item. Or light client can't do anything + /// with forced changes, so we can't accept header with the forced change digest. pub fn find_forced_change( digest: &Digest, ) -> Option<(Number, sp_consensus_grandpa::ScheduledChange)> { @@ -229,12 +233,17 @@ pub enum BridgeGrandpaCall { /// `pallet-bridge-grandpa::Call::submit_finality_proof` #[codec(index = 0)] submit_finality_proof { + /// The header that we are going to finalize. finality_target: Box
, + /// Finality justification for the `finality_target`. justification: justification::GrandpaJustification
, }, /// `pallet-bridge-grandpa::Call::initialize` #[codec(index = 1)] - initialize { init_data: InitializationData
}, + initialize { + /// All data, required to initialize the pallet. + init_data: InitializationData
, + }, } /// The `BridgeGrandpaCall` used by a chain. @@ -325,12 +334,15 @@ pub fn max_expected_submit_finality_proof_arguments_size( #[cfg(test)] mod tests { use super::*; + use bp_runtime::ChainId; use frame_support::weights::Weight; use sp_runtime::{testing::H256, traits::BlakeTwo256, MultiSignature}; struct TestChain; impl Chain for TestChain { + const ID: ChainId = *b"test"; + type BlockNumber = u32; type Hash = H256; type Hasher = BlakeTwo256; diff --git a/bridges/primitives/messages/src/lib.rs b/bridges/primitives/messages/src/lib.rs index e48914f759186..51b3f25f71518 100644 --- a/bridges/primitives/messages/src/lib.rs +++ b/bridges/primitives/messages/src/lib.rs @@ -16,14 +16,13 @@ //! Primitives of messages module. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] -// RuntimeApi generated functions -#![allow(clippy::too_many_arguments)] use bp_header_chain::HeaderChainError; use bp_runtime::{ - messages::MessageDispatchResult, BasicOperatingMode, OperatingMode, RangeInclusiveExt, - StorageProofError, + messages::MessageDispatchResult, BasicOperatingMode, Chain, OperatingMode, RangeInclusiveExt, + StorageProofError, UnderlyingChainOf, UnderlyingChainProvider, }; use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::PalletError; @@ -39,6 +38,36 @@ pub mod source_chain; pub mod storage_keys; pub mod target_chain; +/// Substrate-based chain with messaging support. +pub trait ChainWithMessages: Chain { + /// Name of the bridge messages pallet (used in `construct_runtime` macro call) that is + /// deployed at some other chain to bridge with this `ChainWithMessages`. + /// + /// We assume that all chains that are bridging with this `ChainWithMessages` are using + /// the same name. + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str; + + /// Maximal number of unrewarded relayers in a single confirmation transaction at this + /// `ChainWithMessages`. + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce; + /// Maximal number of unconfirmed messages in a single confirmation transaction at this + /// `ChainWithMessages`. + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce; +} + +impl ChainWithMessages for T +where + T: Chain + UnderlyingChainProvider, + UnderlyingChainOf: ChainWithMessages, +{ + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + UnderlyingChainOf::::WITH_CHAIN_MESSAGES_PALLET_NAME; + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + UnderlyingChainOf::::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + UnderlyingChainOf::::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Messages pallet operating mode. #[derive( Encode, @@ -264,6 +293,7 @@ pub struct ReceivedMessages { } impl ReceivedMessages { + /// Creates new `ReceivedMessages` structure from given results. pub fn new( lane: LaneId, receive_results: Vec<(MessageNonce, ReceivalResult)>, @@ -271,6 +301,7 @@ impl ReceivedMessages { ReceivedMessages { lane, receive_results } } + /// Push `result` of the `message` delivery onto `receive_results` vector. pub fn push(&mut self, message: MessageNonce, result: ReceivalResult) { self.receive_results.push((message, result)); } @@ -342,7 +373,7 @@ pub struct UnrewardedRelayersState { } impl UnrewardedRelayersState { - // Verify that the relayers state corresponds with the `InboundLaneData`. + /// Verify that the relayers state corresponds with the `InboundLaneData`. pub fn is_valid(&self, lane_data: &InboundLaneData) -> bool { self == &lane_data.into() } @@ -423,15 +454,21 @@ pub enum BridgeMessagesCall { /// `pallet-bridge-messages::Call::receive_messages_proof` #[codec(index = 2)] receive_messages_proof { + /// Account id of relayer at the **bridged** chain. relayer_id_at_bridged_chain: AccountId, + /// Messages proof. proof: MessagesProof, + /// A number of messages in the proof. messages_count: u32, + /// Total dispatch weight of messages in the proof. dispatch_weight: Weight, }, /// `pallet-bridge-messages::Call::receive_messages_delivery_proof` #[codec(index = 3)] receive_messages_delivery_proof { + /// Messages delivery proof. proof: MessagesDeliveryProof, + /// "Digest" of unrewarded relayers state at the bridged chain. relayers_state: UnrewardedRelayersState, }, } diff --git a/bridges/primitives/parachains/src/lib.rs b/bridges/primitives/parachains/src/lib.rs index 262b9c6f97752..692bbd99ecef3 100644 --- a/bridges/primitives/parachains/src/lib.rs +++ b/bridges/primitives/parachains/src/lib.rs @@ -16,6 +16,7 @@ //! Primitives of parachains module. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] pub use bp_header_chain::StoredHeaderData; @@ -173,8 +174,11 @@ pub enum BridgeParachainCall { /// `pallet-bridge-parachains::Call::submit_parachain_heads` #[codec(index = 0)] submit_parachain_heads { + /// Relay chain block, for which we have submitted the `parachain_heads_proof`. at_relay_block: (RelayBlockNumber, RelayBlockHash), + /// Parachain identifiers and their head hashes. parachains: Vec<(ParaId, ParaHash)>, + /// Parachain heads proof. parachain_heads_proof: ParaHeadsProof, }, } diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 586cbf8cb9b47..df2836495bbe1 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Primitives of the Polkadot-like chains. + +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use bp_messages::MessageNonce; @@ -24,7 +27,7 @@ use bp_runtime::{ CheckSpecVersion, CheckTxVersion, CheckWeight, GenericSignedExtension, SignedExtensionSchema, }, - Chain, EncodedOrDecodedCall, StorageMapKeyProvider, TransactionEra, + EncodedOrDecodedCall, StorageMapKeyProvider, TransactionEra, }; use frame_support::{ dispatch::DispatchClass, @@ -40,7 +43,7 @@ use sp_core::{storage::StorageKey, Hasher as HasherT}; use sp_runtime::{ generic, traits::{BlakeTwo256, IdentifyAccount, Verify}, - MultiAddress, MultiSignature, OpaqueExtrinsic, RuntimeDebug, + MultiAddress, MultiSignature, OpaqueExtrinsic, }; use sp_std::prelude::Vec; @@ -173,11 +176,16 @@ pub use time_units::*; pub mod time_units { use super::BlockNumber; + /// Milliseconds between Polkadot-like chain blocks. pub const MILLISECS_PER_BLOCK: u64 = 6000; + /// Slot duration in Polkadot-like chain consensus algorithms. pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + /// A minute, expressed in Polkadot-like chain blocks. pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); + /// A hour, expressed in Polkadot-like chain blocks. pub const HOURS: BlockNumber = MINUTES * 60; + /// A day, expressed in Polkadot-like chain blocks. pub const DAYS: BlockNumber = HOURS * 24; } @@ -227,31 +235,17 @@ pub type UncheckedExtrinsic = /// Account address, used by the Polkadot-like chain. pub type Address = MultiAddress; -/// Polkadot-like chain. -#[derive(RuntimeDebug)] -pub struct PolkadotLike; - -impl Chain for PolkadotLike { - type BlockNumber = BlockNumber; - type Hash = Hash; - type Hasher = Hasher; - type Header = Header; - - type AccountId = AccountId; - type Balance = Balance; - type Nonce = Nonce; - type Signature = Signature; - - fn max_extrinsic_size() -> u32 { - *BlockLength::get().max.get(DispatchClass::Normal) - } +/// Returns maximal extrinsic size on all Polkadot-like chains. +pub fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) +} - fn max_extrinsic_weight() -> Weight { - BlockWeights::get() - .get(DispatchClass::Normal) - .max_extrinsic - .unwrap_or(Weight::MAX) - } +/// Returns maximal extrinsic weight on all Polkadot-like chains. +pub fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) } /// Provides a storage key for account data. @@ -271,8 +265,10 @@ impl StorageMapKeyProvider for AccountInfoStorageMapKeyProvider { } impl AccountInfoStorageMapKeyProvider { + /// Name of the system pallet. const PALLET_NAME: &'static str = "System"; + /// Return storage key for given account data. pub fn final_key(id: &AccountId) -> StorageKey { ::final_key(Self::PALLET_NAME, id) } diff --git a/bridges/primitives/polkadot-core/src/parachains.rs b/bridges/primitives/polkadot-core/src/parachains.rs index 223956171f864..433cd2845abd9 100644 --- a/bridges/primitives/polkadot-core/src/parachains.rs +++ b/bridges/primitives/polkadot-core/src/parachains.rs @@ -89,11 +89,18 @@ pub type ParaHasher = crate::Hasher; /// Raw storage proof of parachain heads, stored in polkadot-like chain runtime. #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct ParaHeadsProof(pub RawStorageProof); +pub struct ParaHeadsProof { + /// Unverified storage proof of finalized parachain heads. + pub storage_proof: RawStorageProof, +} impl Size for ParaHeadsProof { fn size(&self) -> u32 { - u32::try_from(self.0.iter().fold(0usize, |sum, node| sum.saturating_add(node.len()))) - .unwrap_or(u32::MAX) + u32::try_from( + self.storage_proof + .iter() + .fold(0usize, |sum, node| sum.saturating_add(node.len())), + ) + .unwrap_or(u32::MAX) } } diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs index 469c839ba151f..7ca956e267013 100644 --- a/bridges/primitives/runtime/src/chain.rs +++ b/bridges/primitives/runtime/src/chain.rs @@ -14,7 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use crate::HeaderIdProvider; +use crate::{ChainId, HeaderIdProvider}; + use codec::{Codec, Decode, Encode, MaxEncodedLen}; use frame_support::{weights::Weight, Parameter}; use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero}; @@ -99,6 +100,9 @@ impl Encode for EncodedOrDecodedCall { /// Minimal Substrate-based chain representation that may be used from no_std environment. pub trait Chain: Send + Sync + 'static { + /// Chain id. + const ID: ChainId; + /// A type that fulfills the abstract idea of what a Substrate block number is. // Constraits come from the associated Number type of `sp_runtime::traits::Header` // See here for more info: @@ -208,6 +212,8 @@ impl Chain for T where T: Send + Sync + 'static + UnderlyingChainProvider, { + const ID: ChainId = ::ID; + type BlockNumber = ::BlockNumber; type Hash = ::Hash; type Hasher = ::Hasher; diff --git a/bridges/primitives/runtime/src/extensions.rs b/bridges/primitives/runtime/src/extensions.rs index 8a618721b23a6..d896bc92efffc 100644 --- a/bridges/primitives/runtime/src/extensions.rs +++ b/bridges/primitives/runtime/src/extensions.rs @@ -102,6 +102,7 @@ impl SignedExtensionSchema for Tuple { /// and signed payloads in the client code. #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub struct GenericSignedExtension { + /// A payload that is included in the transaction. pub payload: S::Payload, #[codec(skip)] // It may be set to `None` if extensions are decoded. We are never reconstructing transactions @@ -112,6 +113,7 @@ pub struct GenericSignedExtension { } impl GenericSignedExtension { + /// Create new `GenericSignedExtension` object. pub fn new(payload: S::Payload, additional_signed: Option) -> Self { Self { payload, additional_signed } } diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 0513cfa2a6c75..e3bdc53c51549 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -16,6 +16,7 @@ //! Primitives that may be used at (bridges) runtime level. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; @@ -61,36 +62,6 @@ pub use sp_runtime::paste; /// Use this when something must be shared among all instances. pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0]; -/// Polkadot chain id. -pub const POLKADOT_CHAIN_ID: ChainId = *b"pdot"; - -/// Polkadot Bulletin chain id. -pub const POLKADOT_BULLETIN_CHAIN_ID: ChainId = *b"pdbc"; - -/// Kusama chain id. -pub const KUSAMA_CHAIN_ID: ChainId = *b"ksma"; - -/// Westend chain id. -pub const WESTEND_CHAIN_ID: ChainId = *b"wend"; - -/// `AssetHubWestmint` chain id. -pub const ASSET_HUB_WESTEND_CHAIN_ID: ChainId = *b"ahwe"; - -/// Rococo chain id. -pub const ROCOCO_CHAIN_ID: ChainId = *b"roco"; - -/// BridgeHubRococo chain id. -pub const BRIDGE_HUB_ROCOCO_CHAIN_ID: ChainId = *b"bhro"; - -/// BridgeHubWestend chain id. -pub const BRIDGE_HUB_WESTEND_CHAIN_ID: ChainId = *b"bhwd"; - -/// BridgeHubKusama chain id. -pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks"; - -/// BridgeHubPolkadot chain id. -pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd"; - /// Generic header Id. #[derive( RuntimeDebug, @@ -126,10 +97,10 @@ pub type HeaderIdOf = HeaderId, BlockNumberOf>; /// Generic header id provider. pub trait HeaderIdProvider { - // Get the header id. + /// Get the header id. fn id(&self) -> HeaderId; - // Get the header id for the parent block. + /// Get the header id for the parent block. fn parent_id(&self) -> Option>; } @@ -350,7 +321,7 @@ pub enum OwnedBridgeModuleError { /// Operating mode for a bridge module. pub trait OperatingMode: Send + Copy + Debug + FullCodec { - // Returns true if the bridge module is halted. + /// Returns true if the bridge module is halted. fn is_halted(&self) -> bool; } @@ -392,8 +363,11 @@ pub trait OwnedBridgeModule { /// The target that will be used when publishing logs related to this module. const LOG_TARGET: &'static str; + /// A storage entry that holds the module `Owner` account. type OwnerStorage: StorageValue>; + /// Operating mode type of the pallet. type OperatingMode: OperatingMode; + /// A storage value that holds the pallet operating mode. type OperatingModeStorage: StorageValue; /// Check if the module is halted. @@ -469,9 +443,11 @@ impl WeightExtraOps for Weight { /// Trait that provides a static `str`. pub trait StaticStrProvider { + /// Static string. const STR: &'static str; } +/// A macro that generates `StaticStrProvider` with the string set to its stringified argument. #[macro_export] macro_rules! generate_static_str_provider { ($str:expr) => { @@ -485,6 +461,7 @@ macro_rules! generate_static_str_provider { }; } +/// Error message that is only dispayable in `std` environment. #[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct StrippableError { diff --git a/bridges/primitives/test-utils/src/keyring.rs b/bridges/primitives/test-utils/src/keyring.rs index eabf9c784eb81..22691183acf7a 100644 --- a/bridges/primitives/test-utils/src/keyring.rs +++ b/bridges/primitives/test-utils/src/keyring.rs @@ -24,12 +24,17 @@ use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId}; use sp_runtime::RuntimeDebug; use sp_std::prelude::*; -/// Set of test accounts with friendly names. +/// Set of test accounts with friendly names: Alice. pub const ALICE: Account = Account(0); +/// Set of test accounts with friendly names: Bob. pub const BOB: Account = Account(1); +/// Set of test accounts with friendly names: Charlie. pub const CHARLIE: Account = Account(2); +/// Set of test accounts with friendly names: Dave. pub const DAVE: Account = Account(3); +/// Set of test accounts with friendly names: Eve. pub const EVE: Account = Account(4); +/// Set of test accounts with friendly names: Ferdie. pub const FERDIE: Account = Account(5); /// A test account which can be used to sign messages. @@ -37,10 +42,12 @@ pub const FERDIE: Account = Account(5); pub struct Account(pub u16); impl Account { + /// Returns public key of this account. pub fn public(&self) -> VerifyingKey { self.pair().verifying_key() } + /// Returns key pair, used to sign data on behalf of this account. pub fn pair(&self) -> SigningKey { let data = self.0.encode(); let mut bytes = [0_u8; 32]; @@ -48,6 +55,7 @@ impl Account { SigningKey::from_bytes(&bytes) } + /// Generate a signature of given message. pub fn sign(&self, msg: &[u8]) -> Signature { use ed25519_dalek::Signer; self.pair().sign(msg) diff --git a/bridges/primitives/test-utils/src/lib.rs b/bridges/primitives/test-utils/src/lib.rs index 4d3b84759938b..f23ddd1a10d36 100644 --- a/bridges/primitives/test-utils/src/lib.rs +++ b/bridges/primitives/test-utils/src/lib.rs @@ -16,6 +16,7 @@ //! Utilities for testing runtime code. +#![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] use bp_header_chain::justification::{required_justification_precommits, GrandpaJustification}; @@ -33,8 +34,11 @@ pub use keyring::*; mod keyring; +/// GRANDPA round number used across tests. pub const TEST_GRANDPA_ROUND: u64 = 1; +/// GRANDPA validators set id used across tests. pub const TEST_GRANDPA_SET_ID: SetId = 1; +/// Name of the `Paras` pallet used across tests. pub const PARAS_PALLET_NAME: &str = "Paras"; /// Configuration parameters when generating test GRANDPA justifications. @@ -190,7 +194,7 @@ pub fn prepare_parachain_heads_proof( .map_err(|_| "record_all_trie_keys has failed") .expect("record_all_trie_keys should not fail in benchmarks"); - (root, ParaHeadsProof(storage_proof), parachains) + (root, ParaHeadsProof { storage_proof }, parachains) } /// Create signed precommit with given target. diff --git a/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs b/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs index 7e37b62b68594..196978c16e8c9 100644 --- a/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs +++ b/bridges/relays/bin-substrate/src/bridges/rococo_bulletin/mod.rs @@ -40,6 +40,8 @@ pub mod rococo_parachains_to_rococo_bulletin; pub struct RococoBaseAsPolkadot; impl bp_runtime::Chain for RococoBaseAsPolkadot { + const ID: ChainId = relay_rococo_client::Rococo::ID; + type BlockNumber = BlockNumberOf; type Hash = HashOf; type Hasher = HasherOf; @@ -78,7 +80,6 @@ impl bp_runtime::UnderlyingChainProvider for RococoAsPolkadot { } impl relay_substrate_client::Chain for RococoAsPolkadot { - const ID: ChainId = relay_rococo_client::Rococo::ID; const NAME: &'static str = relay_rococo_client::Rococo::NAME; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = relay_polkadot_client::Polkadot::BEST_FINALIZED_HEADER_ID_METHOD; @@ -146,6 +147,8 @@ impl CliChain for RococoAsPolkadot { pub struct BaseBridgeHubRococoAsBridgeHubPolkadot; impl bp_runtime::Chain for BaseBridgeHubRococoAsBridgeHubPolkadot { + const ID: ChainId = relay_bridge_hub_rococo_client::BridgeHubRococo::ID; + type BlockNumber = BlockNumberOf; type Hash = HashOf; type Hasher = HasherOf; @@ -169,6 +172,16 @@ impl bp_runtime::Parachain for BaseBridgeHubRococoAsBridgeHubPolkadot { const PARACHAIN_ID: u32 = bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID; } +impl bp_messages::ChainWithMessages for BaseBridgeHubRococoAsBridgeHubPolkadot { + const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = + relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_MESSAGES_PALLET_NAME; + + const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = + relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = + relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; +} + /// Relay `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct BridgeHubRococoAsBridgeHubPolkadot; @@ -178,7 +191,6 @@ impl bp_runtime::UnderlyingChainProvider for BridgeHubRococoAsBridgeHubPolkadot } impl relay_substrate_client::Chain for BridgeHubRococoAsBridgeHubPolkadot { - const ID: ChainId = relay_bridge_hub_rococo_client::BridgeHubRococo::ID; const NAME: &'static str = relay_bridge_hub_rococo_client::BridgeHubRococo::NAME; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = relay_bridge_hub_polkadot_client::BridgeHubPolkadot::BEST_FINALIZED_HEADER_ID_METHOD; @@ -236,8 +248,6 @@ impl relay_substrate_client::ChainWithTransactions for BridgeHubRococoAsBridgeHu } impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPolkadot { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_MESSAGES_PALLET_NAME; const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_RELAYERS_PALLET_NAME; @@ -245,11 +255,6 @@ impl relay_substrate_client::ChainWithMessages for BridgeHubRococoAsBridgeHubPol relay_bridge_hub_polkadot_client::BridgeHubPolkadot::TO_CHAIN_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = relay_bridge_hub_polkadot_client::BridgeHubPolkadot::FROM_CHAIN_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - relay_bridge_hub_rococo_client::BridgeHubRococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } impl CliChain for BridgeHubRococoAsBridgeHubPolkadot { diff --git a/bridges/relays/client-bridge-hub-kusama/Cargo.toml b/bridges/relays/client-bridge-hub-kusama/Cargo.toml index 19a8e25a7027a..ea94dac7de4b3 100644 --- a/bridges/relays/client-bridge-hub-kusama/Cargo.toml +++ b/bridges/relays/client-bridge-hub-kusama/Cargo.toml @@ -18,9 +18,7 @@ relay-substrate-client = { path = "../client-substrate" } bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" } bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" } bp-header-chain = { path = "../../primitives/header-chain" } -bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } -bp-runtime = { path = "../../primitives/runtime" } bp-polkadot = { path = "../../primitives/chain-polkadot" } bridge-runtime-common = { path = "../../bin/runtime-common" } diff --git a/bridges/relays/client-bridge-hub-kusama/src/lib.rs b/bridges/relays/client-bridge-hub-kusama/src/lib.rs index f54f32f9bfeb2..d4bb057de1c23 100644 --- a/bridges/relays/client-bridge-hub-kusama/src/lib.rs +++ b/bridges/relays/client-bridge-hub-kusama/src/lib.rs @@ -17,9 +17,7 @@ //! Types used to connect to the BridgeHub-Kusama-Substrate parachain. use bp_bridge_hub_kusama::AVERAGE_BLOCK_INTERVAL; -use bp_messages::MessageNonce; use bp_polkadot::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, @@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubKusama { } impl Chain for BridgeHubKusama { - const ID: ChainId = bp_runtime::BRIDGE_HUB_KUSAMA_CHAIN_ID; const NAME: &'static str = "BridgeHubKusama"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_bridge_hub_kusama::BEST_FINALIZED_BRIDGE_HUB_KUSAMA_HEADER_METHOD; @@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubKusama { } impl ChainWithMessages for BridgeHubKusama { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_bridge_hub_kusama::WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME; const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some(bp_bridge_hub_kusama::WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME); @@ -125,11 +120,6 @@ impl ChainWithMessages for BridgeHubKusama { bp_bridge_hub_kusama::TO_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_kusama::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_kusama::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } #[cfg(test)] diff --git a/bridges/relays/client-bridge-hub-polkadot/Cargo.toml b/bridges/relays/client-bridge-hub-polkadot/Cargo.toml index 7cac7f4973be0..2fd950efabe57 100644 --- a/bridges/relays/client-bridge-hub-polkadot/Cargo.toml +++ b/bridges/relays/client-bridge-hub-polkadot/Cargo.toml @@ -18,7 +18,6 @@ relay-substrate-client = { path = "../client-substrate" } bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" } bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" } bp-header-chain = { path = "../../primitives/header-chain" } -bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } bp-polkadot-bulletin = { path = "../../primitives/chain-polkadot-bulletin" } bp-polkadot-core = { path = "../../primitives/polkadot-core" } diff --git a/bridges/relays/client-bridge-hub-polkadot/src/lib.rs b/bridges/relays/client-bridge-hub-polkadot/src/lib.rs index 299bc4d736aec..00006da303008 100644 --- a/bridges/relays/client-bridge-hub-polkadot/src/lib.rs +++ b/bridges/relays/client-bridge-hub-polkadot/src/lib.rs @@ -17,9 +17,7 @@ //! Types used to connect to the BridgeHub-Polkadot-Substrate parachain. use bp_bridge_hub_polkadot::AVERAGE_BLOCK_INTERVAL; -use bp_messages::MessageNonce; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, @@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubPolkadot { } impl Chain for BridgeHubPolkadot { - const ID: ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID; const NAME: &'static str = "BridgeHubPolkadot"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_bridge_hub_polkadot::BEST_FINALIZED_BRIDGE_HUB_POLKADOT_HEADER_METHOD; @@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubPolkadot { } impl ChainWithMessages for BridgeHubPolkadot { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_bridge_hub_polkadot::WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME; const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some(bp_bridge_hub_polkadot::WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME); @@ -125,11 +120,6 @@ impl ChainWithMessages for BridgeHubPolkadot { bp_bridge_hub_polkadot::TO_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_polkadot::FROM_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_polkadot::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_polkadot::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } #[cfg(test)] diff --git a/bridges/relays/client-bridge-hub-rococo/Cargo.toml b/bridges/relays/client-bridge-hub-rococo/Cargo.toml index 04b0d0d38e51c..ea59240fd9274 100644 --- a/bridges/relays/client-bridge-hub-rococo/Cargo.toml +++ b/bridges/relays/client-bridge-hub-rococo/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -subxt = { version = "0.32.1", default-features = false, features = [] } +subxt = { version = "0.32.1", default-features = false, features = ["native"] } # Bridge dependencies diff --git a/bridges/relays/client-bridge-hub-rococo/src/lib.rs b/bridges/relays/client-bridge-hub-rococo/src/lib.rs index b92e0009f5b80..80a6316a454bf 100644 --- a/bridges/relays/client-bridge-hub-rococo/src/lib.rs +++ b/bridges/relays/client-bridge-hub-rococo/src/lib.rs @@ -19,9 +19,7 @@ pub mod codegen_runtime; use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_messages::MessageNonce; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -52,7 +50,6 @@ impl UnderlyingChainProvider for BridgeHubRococo { } impl Chain for BridgeHubRococo { - const ID: ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID; const NAME: &'static str = "BridgeHubRococo"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_bridge_hub_rococo::BEST_FINALIZED_BRIDGE_HUB_ROCOCO_HEADER_METHOD; @@ -134,8 +131,6 @@ impl ChainWithTransactions for BridgeHubRococo { } impl ChainWithMessages for BridgeHubRococo { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME; const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some(bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME); @@ -143,11 +138,6 @@ impl ChainWithMessages for BridgeHubRococo { bp_bridge_hub_rococo::TO_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_rococo::FROM_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } #[cfg(test)] diff --git a/bridges/relays/client-bridge-hub-westend/Cargo.toml b/bridges/relays/client-bridge-hub-westend/Cargo.toml index 4eae91963a2ae..ecc23ec81d9de 100644 --- a/bridges/relays/client-bridge-hub-westend/Cargo.toml +++ b/bridges/relays/client-bridge-hub-westend/Cargo.toml @@ -11,18 +11,16 @@ workspace = true [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -subxt = { version = "0.32.1", default-features = false, features = [] } +subxt = { version = "0.32.1", default-features = false, features = ["native"] } # Bridge dependencies bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" } bp-bridge-hub-westend = { path = "../../primitives/chain-bridge-hub-westend" } bp-header-chain = { path = "../../primitives/header-chain" } -bp-messages = { path = "../../primitives/messages" } bp-parachains = { path = "../../primitives/parachains" } bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-rococo = { path = "../../primitives/chain-rococo" } -bp-runtime = { path = "../../primitives/runtime" } bridge-runtime-common = { path = "../../bin/runtime-common" } relay-substrate-client = { path = "../client-substrate" } @@ -34,4 +32,5 @@ sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "mas sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } [dev-dependencies] +bp-runtime = { path = "../../primitives/runtime" } sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/bridges/relays/client-bridge-hub-westend/src/lib.rs b/bridges/relays/client-bridge-hub-westend/src/lib.rs index addbbe0414786..825082e10a11a 100644 --- a/bridges/relays/client-bridge-hub-westend/src/lib.rs +++ b/bridges/relays/client-bridge-hub-westend/src/lib.rs @@ -17,9 +17,7 @@ //! Types used to connect to the BridgeHub-Westend-Substrate parachain. use bp_bridge_hub_westend::AVERAGE_BLOCK_INTERVAL; -use bp_messages::MessageNonce; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, @@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubWestend { } impl Chain for BridgeHubWestend { - const ID: ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID; const NAME: &'static str = "BridgeHubWestend"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_bridge_hub_westend::BEST_FINALIZED_BRIDGE_HUB_WESTEND_HEADER_METHOD; @@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubWestend { } impl ChainWithMessages for BridgeHubWestend { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_MESSAGES_PALLET_NAME; const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = Some(bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_RELAYERS_PALLET_NAME); @@ -125,11 +120,6 @@ impl ChainWithMessages for BridgeHubWestend { bp_bridge_hub_westend::TO_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_bridge_hub_westend::FROM_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_westend::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_bridge_hub_westend::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } #[cfg(test)] diff --git a/bridges/relays/client-kusama/src/lib.rs b/bridges/relays/client-kusama/src/lib.rs index 7fa88959a3c5b..42350ccc52f74 100644 --- a/bridges/relays/client-kusama/src/lib.rs +++ b/bridges/relays/client-kusama/src/lib.rs @@ -20,7 +20,6 @@ pub mod codegen_runtime; use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, @@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Kusama { } impl Chain for Kusama { - const ID: ChainId = bp_runtime::KUSAMA_CHAIN_ID; const NAME: &'static str = "Kusama"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_kusama::BEST_FINALIZED_KUSAMA_HEADER_METHOD; diff --git a/bridges/relays/client-polkadot-bulletin/src/lib.rs b/bridges/relays/client-polkadot-bulletin/src/lib.rs index 56dd7b487f55f..647df2ada32ec 100644 --- a/bridges/relays/client-polkadot-bulletin/src/lib.rs +++ b/bridges/relays/client-polkadot-bulletin/src/lib.rs @@ -18,9 +18,7 @@ mod codegen_runtime; -use bp_messages::MessageNonce; use bp_polkadot_bulletin::POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, @@ -65,8 +63,6 @@ impl UnderlyingChainProvider for PolkadotBulletin { } impl Chain for PolkadotBulletin { - const ID: ChainId = *b"pbch"; - const NAME: &'static str = "PolkadotBulletin"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_polkadot_bulletin::BEST_FINALIZED_POLKADOT_BULLETIN_HEADER_METHOD; @@ -84,8 +80,6 @@ impl ChainWithGrandpa for PolkadotBulletin { } impl ChainWithMessages for PolkadotBulletin { - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str = - bp_polkadot_bulletin::WITH_POLKADOT_BULLETIN_MESSAGES_PALLET_NAME; // this is not critical (some metrics will be missing from the storage), but probably it needs // to be changed when we'll polish the bridge configuration const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = None; @@ -94,11 +88,6 @@ impl ChainWithMessages for PolkadotBulletin { bp_polkadot_bulletin::TO_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD; const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = bp_polkadot_bulletin::FROM_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD; - - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = - bp_polkadot_bulletin::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = - bp_polkadot_bulletin::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; } impl ChainWithBalances for PolkadotBulletin { diff --git a/bridges/relays/client-polkadot/src/lib.rs b/bridges/relays/client-polkadot/src/lib.rs index d0f7a7cb686d9..8e2a2c81748b7 100644 --- a/bridges/relays/client-polkadot/src/lib.rs +++ b/bridges/relays/client-polkadot/src/lib.rs @@ -20,7 +20,6 @@ mod codegen_runtime; use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, @@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Polkadot { } impl Chain for Polkadot { - const ID: ChainId = bp_runtime::POLKADOT_CHAIN_ID; const NAME: &'static str = "Polkadot"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_polkadot::BEST_FINALIZED_POLKADOT_HEADER_METHOD; diff --git a/bridges/relays/client-rococo/Cargo.toml b/bridges/relays/client-rococo/Cargo.toml index bcc4c7ab147cf..ba546396fac78 100644 --- a/bridges/relays/client-rococo/Cargo.toml +++ b/bridges/relays/client-rococo/Cargo.toml @@ -17,7 +17,6 @@ subxt = { version = "0.32.1", default-features = false, features = ["native"] } bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-rococo = { path = "../../primitives/chain-rococo" } -bp-runtime = { path = "../../primitives/runtime" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } diff --git a/bridges/relays/client-rococo/src/lib.rs b/bridges/relays/client-rococo/src/lib.rs index 5ac11f1ef7230..c96e421fa28d5 100644 --- a/bridges/relays/client-rococo/src/lib.rs +++ b/bridges/relays/client-rococo/src/lib.rs @@ -20,7 +20,6 @@ pub mod codegen_runtime; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD; -use bp_runtime::ChainId; use codec::Encode; use relay_substrate_client::{ Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, @@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Rococo { } impl Chain for Rococo { - const ID: ChainId = bp_runtime::ROCOCO_CHAIN_ID; const NAME: &'static str = "Rococo"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD; diff --git a/bridges/relays/client-substrate/src/chain.rs b/bridges/relays/client-substrate/src/chain.rs index ced25fe8ddb26..9de7308c5bdd3 100644 --- a/bridges/relays/client-substrate/src/chain.rs +++ b/bridges/relays/client-substrate/src/chain.rs @@ -17,10 +17,10 @@ use crate::calls::UtilityCall; use bp_header_chain::ChainWithGrandpa as ChainWithGrandpaBase; -use bp_messages::MessageNonce; +use bp_messages::ChainWithMessages as ChainWithMessagesBase; use bp_runtime::{ - Chain as ChainBase, ChainId, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, - TransactionEra, TransactionEraOf, UnderlyingChainProvider, + Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra, + TransactionEraOf, UnderlyingChainProvider, }; use codec::{Codec, Decode, Encode}; use jsonrpsee::core::{DeserializeOwned, Serialize}; @@ -37,8 +37,6 @@ use std::{fmt::Debug, time::Duration}; /// Substrate-based chain from minimal relay-client point of view. pub trait Chain: ChainBase + Clone { - /// Chain id. - const ID: ChainId; /// Chain name. const NAME: &'static str; /// Name of the runtime API method that is returning best known finalized header number @@ -91,14 +89,7 @@ pub trait Parachain: Chain + ParachainBase {} impl Parachain for T where T: UnderlyingChainProvider + Chain + ParachainBase {} /// Substrate-based chain with messaging support from minimal relay-client point of view. -pub trait ChainWithMessages: Chain { - /// Name of the bridge messages pallet (used in `construct_runtime` macro call) that is deployed - /// at some other chain to bridge with this `ChainWithMessages`. - /// - /// We assume that all chains that are bridging with this `ChainWithMessages` are using - /// the same name. - const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str; - +pub trait ChainWithMessages: Chain + ChainWithMessagesBase { // TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): check all the names // after the issue is fixed - all names must be changed @@ -116,13 +107,6 @@ pub trait ChainWithMessages: Chain { /// Name of the `FromInboundLaneApi::message_details` runtime API method. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`. const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; - - /// Maximal number of unrewarded relayers in a single confirmation transaction at this - /// `ChainWithMessages`. - const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce; - /// Maximal number of unconfirmed messages in a single confirmation transaction at this - /// `ChainWithMessages`. - const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce; } /// Call type used by the chain. diff --git a/bridges/relays/client-substrate/src/test_chain.rs b/bridges/relays/client-substrate/src/test_chain.rs index 923092b1bcb7b..214f8d87a1f9f 100644 --- a/bridges/relays/client-substrate/src/test_chain.rs +++ b/bridges/relays/client-substrate/src/test_chain.rs @@ -31,6 +31,8 @@ use std::time::Duration; pub struct TestChain; impl bp_runtime::Chain for TestChain { + const ID: ChainId = *b"test"; + type BlockNumber = u32; type Hash = sp_core::H256; type Hasher = sp_runtime::traits::BlakeTwo256; @@ -51,7 +53,6 @@ impl bp_runtime::Chain for TestChain { } impl Chain for TestChain { - const ID: ChainId = *b"test"; const NAME: &'static str = "Test"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestMethod"; const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0); @@ -73,6 +74,8 @@ impl ChainWithBalances for TestChain { pub struct TestParachainBase; impl bp_runtime::Chain for TestParachainBase { + const ID: ChainId = *b"tstp"; + type BlockNumber = u32; type Hash = sp_core::H256; type Hasher = sp_runtime::traits::BlakeTwo256; @@ -105,7 +108,6 @@ impl bp_runtime::UnderlyingChainProvider for TestParachain { } impl Chain for TestParachain { - const ID: ChainId = *b"test"; const NAME: &'static str = "TestParachain"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestParachainMethod"; const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0); diff --git a/bridges/relays/client-westend/src/lib.rs b/bridges/relays/client-westend/src/lib.rs index 8cacffba99134..789599bbb1d29 100644 --- a/bridges/relays/client-westend/src/lib.rs +++ b/bridges/relays/client-westend/src/lib.rs @@ -19,7 +19,6 @@ pub mod codegen_runtime; use bp_polkadot_core::SuffixedCommonSignedExtensionExt; -use bp_runtime::ChainId; use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use codec::Encode; use relay_substrate_client::{ @@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Westend { } impl Chain for Westend { - const ID: ChainId = bp_runtime::WESTEND_CHAIN_ID; const NAME: &'static str = "Westend"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD; diff --git a/bridges/relays/lib-substrate-relay/src/messages_lane.rs b/bridges/relays/lib-substrate-relay/src/messages_lane.rs index 41f04c8f986ee..abeab8c1402d6 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_lane.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_lane.rs @@ -24,7 +24,7 @@ use crate::{ }; use async_std::sync::Arc; -use bp_messages::{LaneId, MessageNonce}; +use bp_messages::{ChainWithMessages as _, LaneId, MessageNonce}; use bp_runtime::{ AccountIdOf, Chain as _, EncodedOrDecodedCall, HeaderIdOf, TransactionEra, WeightExtraOps, }; diff --git a/bridges/relays/lib-substrate-relay/src/messages_source.rs b/bridges/relays/lib-substrate-relay/src/messages_source.rs index f128546bad3fb..26e10f8868cea 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_source.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_source.rs @@ -32,8 +32,8 @@ use async_std::sync::Arc; use async_trait::async_trait; use bp_messages::{ storage_keys::{operating_mode_key, outbound_lane_data_key}, - InboundMessageDetails, LaneId, MessageNonce, MessagePayload, MessagesOperatingMode, - OutboundLaneData, OutboundMessageDetails, + ChainWithMessages as _, InboundMessageDetails, LaneId, MessageNonce, MessagePayload, + MessagesOperatingMode, OutboundLaneData, OutboundMessageDetails, }; use bp_runtime::{BasicOperatingMode, HeaderIdProvider}; use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; diff --git a/bridges/relays/lib-substrate-relay/src/messages_target.rs b/bridges/relays/lib-substrate-relay/src/messages_target.rs index f47b48010ecdd..9396e785530d2 100644 --- a/bridges/relays/lib-substrate-relay/src/messages_target.rs +++ b/bridges/relays/lib-substrate-relay/src/messages_target.rs @@ -31,8 +31,8 @@ use crate::{ use async_std::sync::Arc; use async_trait::async_trait; use bp_messages::{ - storage_keys::inbound_lane_data_key, InboundLaneData, LaneId, MessageNonce, - UnrewardedRelayersState, + storage_keys::inbound_lane_data_key, ChainWithMessages as _, InboundLaneData, LaneId, + MessageNonce, UnrewardedRelayersState, }; use bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof; use messages_relay::{ @@ -40,8 +40,8 @@ use messages_relay::{ message_lane_loop::{NoncesSubmitArtifacts, TargetClient, TargetClientState}, }; use relay_substrate_client::{ - AccountIdOf, AccountKeyPairOf, BalanceOf, CallOf, ChainWithMessages, Client, - Error as SubstrateError, HashOf, TransactionEra, TransactionTracker, UnsignedTransaction, + AccountIdOf, AccountKeyPairOf, BalanceOf, CallOf, Client, Error as SubstrateError, HashOf, + TransactionEra, TransactionTracker, UnsignedTransaction, }; use relay_utils::relay_loop::Client as RelayClient; use sp_core::Pair; diff --git a/bridges/relays/lib-substrate-relay/src/parachains/source.rs b/bridges/relays/lib-substrate-relay/src/parachains/source.rs index 146c5840cd51f..ba59171c8e01a 100644 --- a/bridges/relays/lib-substrate-relay/src/parachains/source.rs +++ b/bridges/relays/lib-substrate-relay/src/parachains/source.rs @@ -164,6 +164,6 @@ where })?; let parachain_head_hash = parachain_head.hash(); - Ok((ParaHeadsProof(parachain_heads_proof), parachain_head_hash)) + Ok((ParaHeadsProof { storage_proof: parachain_heads_proof }, parachain_head_hash)) } } diff --git a/bridges/relays/parachains/src/parachains_loop.rs b/bridges/relays/parachains/src/parachains_loop.rs index 9b9038fd9761a..390b02b859459 100644 --- a/bridges/relays/parachains/src/parachains_loop.rs +++ b/bridges/relays/parachains/src/parachains_loop.rs @@ -648,7 +648,8 @@ mod tests { _at_block: HeaderIdOf, ) -> Result<(ParaHeadsProof, ParaHash), TestError> { let head = *self.data.lock().await.source_head.clone()?.as_available().unwrap(); - let proof = (ParaHeadsProof(vec![head.hash().encode()]), head.hash()); + let storage_proof = vec![head.hash().encode()]; + let proof = (ParaHeadsProof { storage_proof }, head.hash()); self.data.lock().await.source_proof.clone().map(|_| proof) } }