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
This commit is contained in:
Svyatoslav Nikolsky
2024-01-11 12:39:23 +03:00
committed by Bastian Köcher
parent 37bb1e7909
commit 4004742e85
56 changed files with 389 additions and 268 deletions
+1
View File
@@ -16,6 +16,7 @@
//! Common types/functions that may be used by runtimes of all bridged chains. //! Common types/functions that may be used by runtimes of all bridged chains.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use crate::messages_call_ext::MessagesCallSubType; use crate::messages_call_ext::MessagesCallSubType;
@@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Signed extension for the `pallet-bridge-messages` that is able to reject obsolete
//! (and some other invalid) transactions.
use crate::messages::{ use crate::messages::{
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
}; };
@@ -116,7 +119,9 @@ impl ReceiveMessagesDeliveryProofInfo {
/// which tries to update a single lane. /// which tries to update a single lane.
#[derive(PartialEq, RuntimeDebug)] #[derive(PartialEq, RuntimeDebug)]
pub enum CallInfo { pub enum CallInfo {
/// Messages delivery call info.
ReceiveMessagesProof(ReceiveMessagesProofInfo), ReceiveMessagesProof(ReceiveMessagesProofInfo),
/// Messages delivery confirmation call info.
ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo), ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo),
} }
@@ -132,7 +137,7 @@ impl CallInfo {
/// Helper struct that provides methods for working with a call supported by `CallInfo`. /// Helper struct that provides methods for working with a call supported by `CallInfo`.
pub struct CallHelper<T: Config<I>, I: 'static> { pub struct CallHelper<T: Config<I>, I: 'static> {
pub _phantom_data: sp_std::marker::PhantomData<(T, I)>, _phantom_data: sp_std::marker::PhantomData<(T, I)>,
} }
impl<T: Config<I>, I: 'static> CallHelper<T, I> { impl<T: Config<I>, I: 'static> CallHelper<T, I> {
@@ -40,11 +40,14 @@ use sp_std::{fmt::Debug, marker::PhantomData};
use xcm::prelude::*; use xcm::prelude::*;
use xcm_builder::{DispatchBlob, DispatchBlobError}; 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)] #[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)]
pub enum XcmBlobMessageDispatchResult { pub enum XcmBlobMessageDispatchResult {
/// We've been unable to decode message payload.
InvalidPayload, InvalidPayload,
/// Message has been dispatched.
Dispatched, Dispatched,
/// Message has **NOT** been dispatched because of given error.
NotDispatched(#[codec(skip)] Option<DispatchBlobError>), NotDispatched(#[codec(skip)] Option<DispatchBlobError>),
} }
+6
View File
@@ -314,6 +314,8 @@ impl From<BridgedChainOrigin>
pub struct ThisUnderlyingChain; pub struct ThisUnderlyingChain;
impl Chain for ThisUnderlyingChain { impl Chain for ThisUnderlyingChain {
const ID: ChainId = *b"tuch";
type BlockNumber = ThisChainBlockNumber; type BlockNumber = ThisChainBlockNumber;
type Hash = ThisChainHash; type Hash = ThisChainHash;
type Hasher = ThisChainHasher; type Hasher = ThisChainHasher;
@@ -354,6 +356,8 @@ pub struct BridgedUnderlyingParachain;
pub struct BridgedChainCall; pub struct BridgedChainCall;
impl Chain for BridgedUnderlyingChain { impl Chain for BridgedUnderlyingChain {
const ID: ChainId = *b"buch";
type BlockNumber = BridgedChainBlockNumber; type BlockNumber = BridgedChainBlockNumber;
type Hash = BridgedChainHash; type Hash = BridgedChainHash;
type Hasher = BridgedChainHasher; type Hasher = BridgedChainHasher;
@@ -380,6 +384,8 @@ impl ChainWithGrandpa for BridgedUnderlyingChain {
} }
impl Chain for BridgedUnderlyingParachain { impl Chain for BridgedUnderlyingParachain {
const ID: ChainId = *b"bupc";
type BlockNumber = BridgedChainBlockNumber; type BlockNumber = BridgedChainBlockNumber;
type Hash = BridgedChainHash; type Hash = BridgedChainHash;
type Hasher = BridgedChainHasher; type Hasher = BridgedChainHasher;
@@ -84,5 +84,5 @@ where
let (relay_block_number, relay_block_hash) = let (relay_block_number, relay_block_hash) =
insert_header_to_grandpa_pallet::<R, R::BridgesGrandpaPalletInstance>(state_root); insert_header_to_grandpa_pallet::<R, R::BridgesGrandpaPalletInstance>(state_root);
(relay_block_number, relay_block_hash, ParaHeadsProof(proof), parachain_heads) (relay_block_number, relay_block_hash, ParaHeadsProof { storage_proof: proof }, parachain_heads)
} }
@@ -116,7 +116,7 @@ where
/// Refund calculator. /// Refund calculator.
pub trait RefundCalculator { 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; type Balance;
/// Compute refund for given transaction. /// Compute refund for given transaction.
@@ -986,7 +986,7 @@ mod tests {
ParaId(TestParachain::get()), ParaId(TestParachain::get()),
[parachain_head_at_relay_header_number as u8; 32].into(), [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()), [1u8; 32].into()),
(ParaId(TestParachain::get() + 1), [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), message_delivery_call(200),
], ],
+1
View File
@@ -29,6 +29,7 @@
//! Given the header hash, other pallets are able to verify header-based proofs //! Given the header hash, other pallets are able to verify header-based proofs
//! (e.g. storage proofs, transaction inclusion proofs, etc.). //! (e.g. storage proofs, transaction inclusion proofs, etc.).
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use bp_beefy::{ChainWithBeefy, InitializationData}; use bp_beefy::{ChainWithBeefy, InitializationData};
+3 -1
View File
@@ -22,7 +22,7 @@ use crate::{
}; };
use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash}; use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash};
use bp_runtime::{BasicOperatingMode, Chain}; use bp_runtime::{BasicOperatingMode, Chain, ChainId};
use codec::Encode; use codec::Encode;
use frame_support::{construct_runtime, derive_impl, weights::Weight}; use frame_support::{construct_runtime, derive_impl, weights::Weight};
use sp_core::{sr25519::Signature, Pair}; use sp_core::{sr25519::Signature, Pair};
@@ -81,6 +81,8 @@ impl beefy::Config for TestRuntime {
pub struct TestBridgedChain; pub struct TestBridgedChain;
impl Chain for TestBridgedChain { impl Chain for TestBridgedChain {
const ID: ChainId = *b"tbch";
type BlockNumber = TestBridgedBlockNumber; type BlockNumber = TestBridgedBlockNumber;
type Hash = H256; type Hash = H256;
type Hasher = BlakeTwo256; type Hasher = BlakeTwo256;
+3 -2
View File
@@ -32,9 +32,8 @@
//! Shall the fork occur on the bridged chain governance intervention will be required to //! Shall the fork occur on the bridged chain governance intervention will be required to
//! re-initialize the bridge and track the right fork. //! re-initialize the bridge and track the right fork.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// Runtime-generated enums
#![allow(clippy::large_enum_variant)]
pub use storage_types::StoredAuthoritySet; pub use storage_types::StoredAuthoritySet;
@@ -408,7 +407,9 @@ pub mod pallet {
pub enum Event<T: Config<I>, I: 'static = ()> { pub enum Event<T: Config<I>, I: 'static = ()> {
/// Best finalized chain header has been updated to the header with given number and hash. /// Best finalized chain header has been updated to the header with given number and hash.
UpdatedBestFinalizedHeader { UpdatedBestFinalizedHeader {
/// Number of the new best finalized header.
number: BridgedBlockNumber<T, I>, number: BridgedBlockNumber<T, I>,
/// Hash of the new best finalized header.
hash: BridgedBlockHash<T, I>, hash: BridgedBlockHash<T, I>,
/// The Grandpa info associated to the new best finalized header. /// The Grandpa info associated to the new best finalized header.
grandpa_info: StoredHeaderGrandpaInfo<BridgedHeader<T, I>>, grandpa_info: StoredHeaderGrandpaInfo<BridgedHeader<T, I>>,
+4 -2
View File
@@ -18,7 +18,7 @@
#![allow(clippy::from_over_into)] #![allow(clippy::from_over_into)]
use bp_header_chain::ChainWithGrandpa; use bp_header_chain::ChainWithGrandpa;
use bp_runtime::Chain; use bp_runtime::{Chain, ChainId};
use frame_support::{ use frame_support::{
construct_runtime, derive_impl, parameter_types, traits::Hooks, weights::Weight, construct_runtime, derive_impl, parameter_types, traits::Hooks, weights::Weight,
}; };
@@ -64,7 +64,9 @@ impl grandpa::Config for TestRuntime {
pub struct TestBridgedChain; pub struct TestBridgedChain;
impl Chain for TestBridgedChain { impl Chain for TestBridgedChain {
type BlockNumber = TestNumber; const ID: ChainId = *b"tbch";
type BlockNumber = frame_system::pallet_prelude::BlockNumberFor<TestRuntime>;
type Hash = <TestRuntime as frame_system::Config>::Hash; type Hash = <TestRuntime as frame_system::Config>::Hash;
type Hasher = <TestRuntime as frame_system::Config>::Hashing; type Hasher = <TestRuntime as frame_system::Config>::Hashing;
type Header = TestHeader; type Header = TestHeader;
+14 -4
View File
@@ -33,9 +33,8 @@
//! If this test fails with your weights, then either weights are computed incorrectly, //! If this test fails with your weights, then either weights are computed incorrectly,
//! or some benchmarks assumptions are broken for your runtime. //! or some benchmarks assumptions are broken for your runtime.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// Generated by `decl_event!`
#![allow(clippy::unused_unit)]
pub use inbound_lane::StoredInboundLaneData; pub use inbound_lane::StoredInboundLaneData;
pub use outbound_lane::StoredMessagePayload; pub use outbound_lane::StoredMessagePayload;
@@ -514,13 +513,24 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> { pub enum Event<T: Config<I>, I: 'static = ()> {
/// Message has been accepted and is waiting to be delivered. /// 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. /// Messages have been received from the bridged chain.
MessagesReceived( MessagesReceived(
/// Result of received messages dispatch.
Vec<ReceivedMessages<<T::MessageDispatch as MessageDispatch>::DispatchLevelResult>>, Vec<ReceivedMessages<<T::MessageDispatch as MessageDispatch>::DispatchLevelResult>>,
), ),
/// Messages in the inclusive range have been delivered to the bridged chain. /// 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] #[pallet::error]
+1 -1
View File
@@ -178,7 +178,7 @@ mod tests {
RuntimeCall::Parachains(crate::Call::<TestRuntime, ()>::submit_parachain_heads { RuntimeCall::Parachains(crate::Call::<TestRuntime, ()>::submit_parachain_heads {
at_relay_block: (num, Default::default()), at_relay_block: (num, Default::default()),
parachains, parachains,
parachain_heads_proof: ParaHeadsProof(Vec::new()), parachain_heads_proof: ParaHeadsProof { storage_proof: Vec::new() },
}) })
.check_obsolete_submit_parachain_heads() .check_obsolete_submit_parachain_heads()
.is_ok() .is_ok()
+29 -5
View File
@@ -21,6 +21,7 @@
//! accepts storage proof of some parachain `Heads` entries from bridged relay chain. //! accepts storage proof of some parachain `Heads` entries from bridged relay chain.
//! It requires corresponding relay headers to be already synced. //! It requires corresponding relay headers to be already synced.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use weights::WeightInfo; pub use weights::WeightInfo;
@@ -98,27 +99,49 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> { pub enum Event<T: Config<I>, I: 'static = ()> {
/// The caller has provided head of parachain that the pallet is not configured to track. /// 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 /// The caller has declared that he has provided given parachain head, but it is missing
/// from the storage proof. /// 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 /// The caller has provided parachain head hash that is not matching the hash read from the
/// storage proof. /// storage proof.
IncorrectParachainHeadHash { IncorrectParachainHeadHash {
/// Identifier of the parachain with incorrect head hast.
parachain: ParaId, parachain: ParaId,
/// Specified parachain head hash.
parachain_head_hash: ParaHash, parachain_head_hash: ParaHash,
/// Actual parachain head hash.
actual_parachain_head_hash: ParaHash, actual_parachain_head_hash: ParaHash,
}, },
/// The caller has provided obsolete parachain head, which is already known to the pallet. /// 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. /// The caller has provided parachain head that exceeds the maximal configured head size.
RejectedLargeParachainHead { RejectedLargeParachainHead {
/// Identifier of the parachain with rejected head.
parachain: ParaId, parachain: ParaId,
/// Parachain head hash.
parachain_head_hash: ParaHash, parachain_head_hash: ParaHash,
/// Parachain head size.
parachain_head_size: u32, parachain_head_size: u32,
}, },
/// Parachain head has been updated. /// 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] #[pallet::error]
@@ -137,6 +160,7 @@ pub mod pallet {
pub trait BoundedBridgeGrandpaConfig<I: 'static>: pub trait BoundedBridgeGrandpaConfig<I: 'static>:
pallet_bridge_grandpa::Config<I, BridgedChain = Self::BridgedRelayChain> pallet_bridge_grandpa::Config<I, BridgedChain = Self::BridgedRelayChain>
{ {
/// Type of the bridged relay chain.
type BridgedRelayChain: Chain< type BridgedRelayChain: Chain<
BlockNumber = RelayBlockNumber, BlockNumber = RelayBlockNumber,
Hash = RelayBlockHash, Hash = RelayBlockHash,
@@ -336,7 +360,7 @@ pub mod pallet {
let mut storage = GrandpaPalletOf::<T, I>::storage_proof_checker( let mut storage = GrandpaPalletOf::<T, I>::storage_proof_checker(
relay_block_hash, relay_block_hash,
parachain_heads_proof.0, parachain_heads_proof.storage_proof,
) )
.map_err(Error::<T, I>::HeaderChainStorageProof)?; .map_err(Error::<T, I>::HeaderChainStorageProof)?;
+13 -1
View File
@@ -16,7 +16,7 @@
use bp_header_chain::ChainWithGrandpa; use bp_header_chain::ChainWithGrandpa;
use bp_polkadot_core::parachains::ParaId; use bp_polkadot_core::parachains::ParaId;
use bp_runtime::{Chain, Parachain}; use bp_runtime::{Chain, ChainId, Parachain};
use frame_support::{ use frame_support::{
construct_runtime, derive_impl, parameter_types, traits::ConstU32, weights::Weight, construct_runtime, derive_impl, parameter_types, traits::ConstU32, weights::Weight,
}; };
@@ -49,6 +49,8 @@ pub type BigParachainHeader = sp_runtime::generic::Header<u128, BlakeTwo256>;
pub struct Parachain1; pub struct Parachain1;
impl Chain for Parachain1 { impl Chain for Parachain1 {
const ID: ChainId = *b"pch1";
type BlockNumber = u64; type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hasher = RegularParachainHasher; type Hasher = RegularParachainHasher;
@@ -73,6 +75,8 @@ impl Parachain for Parachain1 {
pub struct Parachain2; pub struct Parachain2;
impl Chain for Parachain2 { impl Chain for Parachain2 {
const ID: ChainId = *b"pch2";
type BlockNumber = u64; type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hasher = RegularParachainHasher; type Hasher = RegularParachainHasher;
@@ -97,6 +101,8 @@ impl Parachain for Parachain2 {
pub struct Parachain3; pub struct Parachain3;
impl Chain for Parachain3 { impl Chain for Parachain3 {
const ID: ChainId = *b"pch3";
type BlockNumber = u64; type BlockNumber = u64;
type Hash = H256; type Hash = H256;
type Hasher = RegularParachainHasher; type Hasher = RegularParachainHasher;
@@ -122,6 +128,8 @@ impl Parachain for Parachain3 {
pub struct BigParachain; pub struct BigParachain;
impl Chain for BigParachain { impl Chain for BigParachain {
const ID: ChainId = *b"bpch";
type BlockNumber = u128; type BlockNumber = u128;
type Hash = H256; type Hash = H256;
type Hasher = RegularParachainHasher; type Hasher = RegularParachainHasher;
@@ -229,6 +237,8 @@ impl pallet_bridge_parachains::benchmarking::Config<()> for TestRuntime {
pub struct TestBridgedChain; pub struct TestBridgedChain;
impl Chain for TestBridgedChain { impl Chain for TestBridgedChain {
const ID: ChainId = *b"tbch";
type BlockNumber = crate::RelayBlockNumber; type BlockNumber = crate::RelayBlockNumber;
type Hash = crate::RelayBlockHash; type Hash = crate::RelayBlockHash;
type Hasher = crate::RelayBlockHasher; type Hasher = crate::RelayBlockHasher;
@@ -260,6 +270,8 @@ impl ChainWithGrandpa for TestBridgedChain {
pub struct OtherBridgedChain; pub struct OtherBridgedChain;
impl Chain for OtherBridgedChain { impl Chain for OtherBridgedChain {
const ID: ChainId = *b"obch";
type BlockNumber = u64; type BlockNumber = u64;
type Hash = crate::RelayBlockHash; type Hash = crate::RelayBlockHash;
type Hasher = crate::RelayBlockHasher; type Hasher = crate::RelayBlockHasher;
@@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of all Cumulus-based bridge hubs.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use bp_polkadot_core::{ 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); pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
parameter_types! { parameter_types! {
/// Size limit of the Cumulus-based bridge hub blocks.
pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio( pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(
5 * 1024 * 1024, 5 * 1024 * 1024,
NORMAL_DISPATCH_RATIO, NORMAL_DISPATCH_RATIO,
@@ -73,6 +77,7 @@ parameter_types! {
pub const ExtrinsicBaseWeight: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS, 0) pub const ExtrinsicBaseWeight: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS, 0)
.saturating_mul(125_000); .saturating_mul(125_000);
/// Weight limit of the Cumulus-based bridge hub blocks.
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder()
.base_block(BlockExecutionWeight::get()) .base_block(BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| { .for_class(DispatchClass::all(), |weights| {
@@ -17,12 +17,13 @@
//! Module with configuration which reflects BridgeHubKusama runtime setup (AccountId, Headers, //! Module with configuration which reflects BridgeHubKusama runtime setup (AccountId, Headers,
//! Hashes...) //! Hashes...)
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use bp_bridge_hub_cumulus::*; pub use bp_bridge_hub_cumulus::*;
use bp_messages::*; use bp_messages::*;
use bp_runtime::{ 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::{ use frame_support::{
dispatch::DispatchClass, dispatch::DispatchClass,
@@ -35,6 +36,8 @@ use sp_runtime::RuntimeDebug;
pub struct BridgeHubKusama; pub struct BridgeHubKusama;
impl Chain for BridgeHubKusama { impl Chain for BridgeHubKusama {
const ID: ChainId = *b"bhks";
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
@@ -61,6 +64,15 @@ impl Parachain for BridgeHubKusama {
const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID; 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. /// Public key of the chain account that may be used to verify signatures.
pub type AccountSigner = MultiSigner; pub type AccountSigner = MultiSigner;
@@ -17,12 +17,13 @@
//! Module with configuration which reflects BridgeHubPolkadot runtime setup //! Module with configuration which reflects BridgeHubPolkadot runtime setup
//! (AccountId, Headers, Hashes...) //! (AccountId, Headers, Hashes...)
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use bp_bridge_hub_cumulus::*; pub use bp_bridge_hub_cumulus::*;
use bp_messages::*; use bp_messages::*;
use bp_runtime::{ 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 frame_support::dispatch::DispatchClass;
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
@@ -32,6 +33,8 @@ use sp_runtime::RuntimeDebug;
pub struct BridgeHubPolkadot; pub struct BridgeHubPolkadot;
impl Chain for BridgeHubPolkadot { impl Chain for BridgeHubPolkadot {
const ID: ChainId = *b"bhpd";
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
@@ -58,6 +61,16 @@ impl Parachain for BridgeHubPolkadot {
const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID; 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. /// Identifier of BridgeHubPolkadot in the Polkadot relay chain.
pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002; pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002;
@@ -17,12 +17,13 @@
//! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers, //! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers,
//! Hashes...) //! Hashes...)
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use bp_bridge_hub_cumulus::*; pub use bp_bridge_hub_cumulus::*;
use bp_messages::*; use bp_messages::*;
use bp_runtime::{ 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 frame_support::dispatch::DispatchClass;
use sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug}; use sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug};
@@ -32,6 +33,8 @@ use sp_runtime::{MultiAddress, MultiSigner, RuntimeDebug};
pub struct BridgeHubRococo; pub struct BridgeHubRococo;
impl Chain for BridgeHubRococo { impl Chain for BridgeHubRococo {
const ID: ChainId = *b"bhro";
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
@@ -58,6 +61,16 @@ impl Parachain for BridgeHubRococo {
const PARACHAIN_ID: u32 = BRIDGE_HUB_ROCOCO_PARACHAIN_ID; 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. /// Public key of the chain account that may be used to verify signatures.
pub type AccountSigner = MultiSigner; pub type AccountSigner = MultiSigner;
@@ -22,7 +22,7 @@
pub use bp_bridge_hub_cumulus::*; pub use bp_bridge_hub_cumulus::*;
use bp_messages::*; use bp_messages::*;
use bp_runtime::{ 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 frame_support::dispatch::DispatchClass;
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
@@ -32,6 +32,8 @@ use sp_runtime::RuntimeDebug;
pub struct BridgeHubWestend; pub struct BridgeHubWestend;
impl Chain for BridgeHubWestend { impl Chain for BridgeHubWestend {
const ID: ChainId = *b"bhwd";
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
@@ -58,6 +60,16 @@ impl Parachain for BridgeHubWestend {
const PARACHAIN_ID: u32 = BRIDGE_HUB_WESTEND_PARACHAIN_ID; 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. /// Identifier of BridgeHubWestend in the Westend relay chain.
pub const BRIDGE_HUB_WESTEND_PARACHAIN_ID: u32 = 1002; pub const BRIDGE_HUB_WESTEND_PARACHAIN_ID: u32 = 1002;
+16 -13
View File
@@ -14,36 +14,39 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the Kusama chain.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]
pub use bp_polkadot_core::*; pub use bp_polkadot_core::*;
use bp_header_chain::ChainWithGrandpa; 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; use frame_support::weights::Weight;
/// Kusama Chain /// Kusama Chain
pub struct Kusama; pub struct Kusama;
impl Chain for Kusama { impl Chain for Kusama {
type BlockNumber = <PolkadotLike as Chain>::BlockNumber; const ID: ChainId = *b"ksma";
type Hash = <PolkadotLike as Chain>::Hash;
type Hasher = <PolkadotLike as Chain>::Hasher;
type Header = <PolkadotLike as Chain>::Header;
type AccountId = <PolkadotLike as Chain>::AccountId; type BlockNumber = BlockNumber;
type Balance = <PolkadotLike as Chain>::Balance; type Hash = Hash;
type Nonce = <PolkadotLike as Chain>::Nonce; type Hasher = Hasher;
type Signature = <PolkadotLike as Chain>::Signature; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
fn max_extrinsic_size() -> u32 { fn max_extrinsic_size() -> u32 {
PolkadotLike::max_extrinsic_size() max_extrinsic_size()
} }
fn max_extrinsic_weight() -> Weight { fn max_extrinsic_weight() -> Weight {
PolkadotLike::max_extrinsic_weight() max_extrinsic_weight()
} }
} }
@@ -20,14 +20,14 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use bp_header_chain::ChainWithGrandpa; use bp_header_chain::ChainWithGrandpa;
use bp_messages::MessageNonce; use bp_messages::{ChainWithMessages, MessageNonce};
use bp_runtime::{ use bp_runtime::{
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis,
extensions::{ extensions::{
CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion,
CheckWeight, GenericSignedExtension, GenericSignedExtensionSchema, CheckWeight, GenericSignedExtension, GenericSignedExtensionSchema,
}, },
Chain, TransactionEra, Chain, ChainId, TransactionEra,
}; };
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use frame_support::{ use frame_support::{
@@ -177,6 +177,8 @@ parameter_types! {
pub struct PolkadotBulletin; pub struct PolkadotBulletin;
impl Chain for PolkadotBulletin { impl Chain for PolkadotBulletin {
const ID: ChainId = *b"pdbc";
type BlockNumber = BlockNumber; type BlockNumber = BlockNumber;
type Hash = Hash; type Hash = Hash;
type Hasher = Hasher; type Hasher = Hasher;
@@ -211,5 +213,15 @@ impl ChainWithGrandpa for PolkadotBulletin {
const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE; 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_finality_runtime_apis!(polkadot_bulletin, grandpa);
decl_bridge_messages_runtime_apis!(polkadot_bulletin); decl_bridge_messages_runtime_apis!(polkadot_bulletin);
+18 -13
View File
@@ -14,36 +14,41 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the Polkadot chain.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]
pub use bp_polkadot_core::*; pub use bp_polkadot_core::*;
use bp_header_chain::ChainWithGrandpa; 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; use frame_support::weights::Weight;
/// Polkadot Chain /// Polkadot Chain
pub struct Polkadot; pub struct Polkadot;
impl Chain for Polkadot { impl Chain for Polkadot {
type BlockNumber = <PolkadotLike as Chain>::BlockNumber; const ID: ChainId = *b"pdot";
type Hash = <PolkadotLike as Chain>::Hash;
type Hasher = <PolkadotLike as Chain>::Hasher;
type Header = <PolkadotLike as Chain>::Header;
type AccountId = <PolkadotLike as Chain>::AccountId; type BlockNumber = BlockNumber;
type Balance = <PolkadotLike as Chain>::Balance; type Hash = Hash;
type Nonce = <PolkadotLike as Chain>::Nonce; type Hasher = Hasher;
type Signature = <PolkadotLike as Chain>::Signature; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
fn max_extrinsic_size() -> u32 { fn max_extrinsic_size() -> u32 {
PolkadotLike::max_extrinsic_size() max_extrinsic_size()
} }
fn max_extrinsic_weight() -> Weight { fn max_extrinsic_weight() -> Weight {
PolkadotLike::max_extrinsic_weight() max_extrinsic_weight()
} }
} }
+17 -18
View File
@@ -14,36 +14,39 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the Rococo chain.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]
pub use bp_polkadot_core::*; pub use bp_polkadot_core::*;
use bp_header_chain::ChainWithGrandpa; 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::{parameter_types, weights::Weight}; use frame_support::weights::Weight;
/// Rococo Chain /// Rococo Chain
pub struct Rococo; pub struct Rococo;
impl Chain for Rococo { impl Chain for Rococo {
type BlockNumber = <PolkadotLike as Chain>::BlockNumber; const ID: ChainId = *b"roco";
type Hash = <PolkadotLike as Chain>::Hash;
type Hasher = <PolkadotLike as Chain>::Hasher;
type Header = <PolkadotLike as Chain>::Header;
type AccountId = <PolkadotLike as Chain>::AccountId; type BlockNumber = BlockNumber;
type Balance = <PolkadotLike as Chain>::Balance; type Hash = Hash;
type Nonce = <PolkadotLike as Chain>::Nonce; type Hasher = Hasher;
type Signature = <PolkadotLike as Chain>::Signature; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
fn max_extrinsic_size() -> u32 { fn max_extrinsic_size() -> u32 {
PolkadotLike::max_extrinsic_size() max_extrinsic_size()
} }
fn max_extrinsic_weight() -> Weight { 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; const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE;
} }
parameter_types! {
pub const SS58Prefix: u8 = 42;
}
// The SignedExtension used by Rococo. // The SignedExtension used by Rococo.
pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; pub use bp_polkadot_core::CommonSignedExtension as SignedExtension;
+17 -18
View File
@@ -14,36 +14,39 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the Westend chain.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]
pub use bp_polkadot_core::*; pub use bp_polkadot_core::*;
use bp_header_chain::ChainWithGrandpa; 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::{parameter_types, weights::Weight}; use frame_support::weights::Weight;
/// Westend Chain /// Westend Chain
pub struct Westend; pub struct Westend;
impl Chain for Westend { impl Chain for Westend {
type BlockNumber = <PolkadotLike as Chain>::BlockNumber; const ID: ChainId = *b"wend";
type Hash = <PolkadotLike as Chain>::Hash;
type Hasher = <PolkadotLike as Chain>::Hasher;
type Header = <PolkadotLike as Chain>::Header;
type AccountId = <PolkadotLike as Chain>::AccountId; type BlockNumber = BlockNumber;
type Balance = <PolkadotLike as Chain>::Balance; type Hash = Hash;
type Nonce = <PolkadotLike as Chain>::Nonce; type Hasher = Hasher;
type Signature = <PolkadotLike as Chain>::Signature; type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
fn max_extrinsic_size() -> u32 { fn max_extrinsic_size() -> u32 {
PolkadotLike::max_extrinsic_size() max_extrinsic_size()
} }
fn max_extrinsic_weight() -> Weight { 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; const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE;
} }
parameter_types! {
pub const SS58Prefix: u8 = 42;
}
// The SignedExtension used by Westend. // The SignedExtension used by Westend.
pub use bp_polkadot_core::CommonSignedExtension as SignedExtension; pub use bp_polkadot_core::CommonSignedExtension as SignedExtension;
+13 -1
View File
@@ -17,6 +17,7 @@
//! Defines traits which represent a common interface for Substrate pallets which want to //! Defines traits which represent a common interface for Substrate pallets which want to
//! incorporate bridge functionality. //! incorporate bridge functionality.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use crate::justification::{ use crate::justification::{
@@ -145,6 +146,7 @@ pub trait ConsensusLogReader {
pub struct GrandpaConsensusLogReader<Number>(sp_std::marker::PhantomData<Number>); pub struct GrandpaConsensusLogReader<Number>(sp_std::marker::PhantomData<Number>);
impl<Number: Codec> GrandpaConsensusLogReader<Number> { impl<Number: Codec> GrandpaConsensusLogReader<Number> {
/// Find and return scheduled (regular) change digest item.
pub fn find_scheduled_change( pub fn find_scheduled_change(
digest: &Digest, digest: &Digest,
) -> Option<sp_consensus_grandpa::ScheduledChange<Number>> { ) -> Option<sp_consensus_grandpa::ScheduledChange<Number>> {
@@ -158,6 +160,8 @@ impl<Number: Codec> GrandpaConsensusLogReader<Number> {
}) })
} }
/// 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( pub fn find_forced_change(
digest: &Digest, digest: &Digest,
) -> Option<(Number, sp_consensus_grandpa::ScheduledChange<Number>)> { ) -> Option<(Number, sp_consensus_grandpa::ScheduledChange<Number>)> {
@@ -229,12 +233,17 @@ pub enum BridgeGrandpaCall<Header: HeaderT> {
/// `pallet-bridge-grandpa::Call::submit_finality_proof` /// `pallet-bridge-grandpa::Call::submit_finality_proof`
#[codec(index = 0)] #[codec(index = 0)]
submit_finality_proof { submit_finality_proof {
/// The header that we are going to finalize.
finality_target: Box<Header>, finality_target: Box<Header>,
/// Finality justification for the `finality_target`.
justification: justification::GrandpaJustification<Header>, justification: justification::GrandpaJustification<Header>,
}, },
/// `pallet-bridge-grandpa::Call::initialize` /// `pallet-bridge-grandpa::Call::initialize`
#[codec(index = 1)] #[codec(index = 1)]
initialize { init_data: InitializationData<Header> }, initialize {
/// All data, required to initialize the pallet.
init_data: InitializationData<Header>,
},
} }
/// The `BridgeGrandpaCall` used by a chain. /// The `BridgeGrandpaCall` used by a chain.
@@ -325,12 +334,15 @@ pub fn max_expected_submit_finality_proof_arguments_size<C: ChainWithGrandpa>(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use bp_runtime::ChainId;
use frame_support::weights::Weight; use frame_support::weights::Weight;
use sp_runtime::{testing::H256, traits::BlakeTwo256, MultiSignature}; use sp_runtime::{testing::H256, traits::BlakeTwo256, MultiSignature};
struct TestChain; struct TestChain;
impl Chain for TestChain { impl Chain for TestChain {
const ID: ChainId = *b"test";
type BlockNumber = u32; type BlockNumber = u32;
type Hash = H256; type Hash = H256;
type Hasher = BlakeTwo256; type Hasher = BlakeTwo256;
+42 -5
View File
@@ -16,14 +16,13 @@
//! Primitives of messages module. //! Primitives of messages module.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
// RuntimeApi generated functions
#![allow(clippy::too_many_arguments)]
use bp_header_chain::HeaderChainError; use bp_header_chain::HeaderChainError;
use bp_runtime::{ use bp_runtime::{
messages::MessageDispatchResult, BasicOperatingMode, OperatingMode, RangeInclusiveExt, messages::MessageDispatchResult, BasicOperatingMode, Chain, OperatingMode, RangeInclusiveExt,
StorageProofError, StorageProofError, UnderlyingChainOf, UnderlyingChainProvider,
}; };
use codec::{Decode, Encode, MaxEncodedLen}; use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::PalletError; use frame_support::PalletError;
@@ -39,6 +38,36 @@ pub mod source_chain;
pub mod storage_keys; pub mod storage_keys;
pub mod target_chain; 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<T> ChainWithMessages for T
where
T: Chain + UnderlyingChainProvider,
UnderlyingChainOf<T>: ChainWithMessages,
{
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str =
UnderlyingChainOf::<T>::WITH_CHAIN_MESSAGES_PALLET_NAME;
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce =
UnderlyingChainOf::<T>::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX;
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce =
UnderlyingChainOf::<T>::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
}
/// Messages pallet operating mode. /// Messages pallet operating mode.
#[derive( #[derive(
Encode, Encode,
@@ -264,6 +293,7 @@ pub struct ReceivedMessages<DispatchLevelResult> {
} }
impl<DispatchLevelResult> ReceivedMessages<DispatchLevelResult> { impl<DispatchLevelResult> ReceivedMessages<DispatchLevelResult> {
/// Creates new `ReceivedMessages` structure from given results.
pub fn new( pub fn new(
lane: LaneId, lane: LaneId,
receive_results: Vec<(MessageNonce, ReceivalResult<DispatchLevelResult>)>, receive_results: Vec<(MessageNonce, ReceivalResult<DispatchLevelResult>)>,
@@ -271,6 +301,7 @@ impl<DispatchLevelResult> ReceivedMessages<DispatchLevelResult> {
ReceivedMessages { lane, receive_results } ReceivedMessages { lane, receive_results }
} }
/// Push `result` of the `message` delivery onto `receive_results` vector.
pub fn push(&mut self, message: MessageNonce, result: ReceivalResult<DispatchLevelResult>) { pub fn push(&mut self, message: MessageNonce, result: ReceivalResult<DispatchLevelResult>) {
self.receive_results.push((message, result)); self.receive_results.push((message, result));
} }
@@ -342,7 +373,7 @@ pub struct UnrewardedRelayersState {
} }
impl 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<RelayerId>(&self, lane_data: &InboundLaneData<RelayerId>) -> bool { pub fn is_valid<RelayerId>(&self, lane_data: &InboundLaneData<RelayerId>) -> bool {
self == &lane_data.into() self == &lane_data.into()
} }
@@ -423,15 +454,21 @@ pub enum BridgeMessagesCall<AccountId, MessagesProof, MessagesDeliveryProof> {
/// `pallet-bridge-messages::Call::receive_messages_proof` /// `pallet-bridge-messages::Call::receive_messages_proof`
#[codec(index = 2)] #[codec(index = 2)]
receive_messages_proof { receive_messages_proof {
/// Account id of relayer at the **bridged** chain.
relayer_id_at_bridged_chain: AccountId, relayer_id_at_bridged_chain: AccountId,
/// Messages proof.
proof: MessagesProof, proof: MessagesProof,
/// A number of messages in the proof.
messages_count: u32, messages_count: u32,
/// Total dispatch weight of messages in the proof.
dispatch_weight: Weight, dispatch_weight: Weight,
}, },
/// `pallet-bridge-messages::Call::receive_messages_delivery_proof` /// `pallet-bridge-messages::Call::receive_messages_delivery_proof`
#[codec(index = 3)] #[codec(index = 3)]
receive_messages_delivery_proof { receive_messages_delivery_proof {
/// Messages delivery proof.
proof: MessagesDeliveryProof, proof: MessagesDeliveryProof,
/// "Digest" of unrewarded relayers state at the bridged chain.
relayers_state: UnrewardedRelayersState, relayers_state: UnrewardedRelayersState,
}, },
} }
+4
View File
@@ -16,6 +16,7 @@
//! Primitives of parachains module. //! Primitives of parachains module.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub use bp_header_chain::StoredHeaderData; pub use bp_header_chain::StoredHeaderData;
@@ -173,8 +174,11 @@ pub enum BridgeParachainCall {
/// `pallet-bridge-parachains::Call::submit_parachain_heads` /// `pallet-bridge-parachains::Call::submit_parachain_heads`
#[codec(index = 0)] #[codec(index = 0)]
submit_parachain_heads { submit_parachain_heads {
/// Relay chain block, for which we have submitted the `parachain_heads_proof`.
at_relay_block: (RelayBlockNumber, RelayBlockHash), at_relay_block: (RelayBlockNumber, RelayBlockHash),
/// Parachain identifiers and their head hashes.
parachains: Vec<(ParaId, ParaHash)>, parachains: Vec<(ParaId, ParaHash)>,
/// Parachain heads proof.
parachain_heads_proof: ParaHeadsProof, parachain_heads_proof: ParaHeadsProof,
}, },
} }
+22 -26
View File
@@ -14,6 +14,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Primitives of the Polkadot-like chains.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
@@ -24,7 +27,7 @@ use bp_runtime::{
CheckSpecVersion, CheckTxVersion, CheckWeight, GenericSignedExtension, CheckSpecVersion, CheckTxVersion, CheckWeight, GenericSignedExtension,
SignedExtensionSchema, SignedExtensionSchema,
}, },
Chain, EncodedOrDecodedCall, StorageMapKeyProvider, TransactionEra, EncodedOrDecodedCall, StorageMapKeyProvider, TransactionEra,
}; };
use frame_support::{ use frame_support::{
dispatch::DispatchClass, dispatch::DispatchClass,
@@ -40,7 +43,7 @@ use sp_core::{storage::StorageKey, Hasher as HasherT};
use sp_runtime::{ use sp_runtime::{
generic, generic,
traits::{BlakeTwo256, IdentifyAccount, Verify}, traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiAddress, MultiSignature, OpaqueExtrinsic, RuntimeDebug, MultiAddress, MultiSignature, OpaqueExtrinsic,
}; };
use sp_std::prelude::Vec; use sp_std::prelude::Vec;
@@ -173,11 +176,16 @@ pub use time_units::*;
pub mod time_units { pub mod time_units {
use super::BlockNumber; use super::BlockNumber;
/// Milliseconds between Polkadot-like chain blocks.
pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const MILLISECS_PER_BLOCK: u64 = 6000;
/// Slot duration in Polkadot-like chain consensus algorithms.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; 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); 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; pub const HOURS: BlockNumber = MINUTES * 60;
/// A day, expressed in Polkadot-like chain blocks.
pub const DAYS: BlockNumber = HOURS * 24; pub const DAYS: BlockNumber = HOURS * 24;
} }
@@ -227,31 +235,17 @@ pub type UncheckedExtrinsic<Call, SignedExt> =
/// Account address, used by the Polkadot-like chain. /// Account address, used by the Polkadot-like chain.
pub type Address = MultiAddress<AccountId, ()>; pub type Address = MultiAddress<AccountId, ()>;
/// Polkadot-like chain. /// Returns maximal extrinsic size on all Polkadot-like chains.
#[derive(RuntimeDebug)] pub fn max_extrinsic_size() -> u32 {
pub struct PolkadotLike; *BlockLength::get().max.get(DispatchClass::Normal)
}
impl Chain for PolkadotLike { /// Returns maximal extrinsic weight on all Polkadot-like chains.
type BlockNumber = BlockNumber; pub fn max_extrinsic_weight() -> Weight {
type Hash = Hash; BlockWeights::get()
type Hasher = Hasher; .get(DispatchClass::Normal)
type Header = Header; .max_extrinsic
.unwrap_or(Weight::MAX)
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
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)
}
} }
/// Provides a storage key for account data. /// Provides a storage key for account data.
@@ -271,8 +265,10 @@ impl StorageMapKeyProvider for AccountInfoStorageMapKeyProvider {
} }
impl AccountInfoStorageMapKeyProvider { impl AccountInfoStorageMapKeyProvider {
/// Name of the system pallet.
const PALLET_NAME: &'static str = "System"; const PALLET_NAME: &'static str = "System";
/// Return storage key for given account data.
pub fn final_key(id: &AccountId) -> StorageKey { pub fn final_key(id: &AccountId) -> StorageKey {
<Self as StorageMapKeyProvider>::final_key(Self::PALLET_NAME, id) <Self as StorageMapKeyProvider>::final_key(Self::PALLET_NAME, id)
} }
@@ -89,11 +89,18 @@ pub type ParaHasher = crate::Hasher;
/// Raw storage proof of parachain heads, stored in polkadot-like chain runtime. /// Raw storage proof of parachain heads, stored in polkadot-like chain runtime.
#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] #[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 { impl Size for ParaHeadsProof {
fn size(&self) -> u32 { fn size(&self) -> u32 {
u32::try_from(self.0.iter().fold(0usize, |sum, node| sum.saturating_add(node.len()))) u32::try_from(
.unwrap_or(u32::MAX) self.storage_proof
.iter()
.fold(0usize, |sum, node| sum.saturating_add(node.len())),
)
.unwrap_or(u32::MAX)
} }
} }
+7 -1
View File
@@ -14,7 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>. // along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use crate::HeaderIdProvider; use crate::{ChainId, HeaderIdProvider};
use codec::{Codec, Decode, Encode, MaxEncodedLen}; use codec::{Codec, Decode, Encode, MaxEncodedLen};
use frame_support::{weights::Weight, Parameter}; use frame_support::{weights::Weight, Parameter};
use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero}; use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero};
@@ -99,6 +100,9 @@ impl<ChainCall: Encode> Encode for EncodedOrDecodedCall<ChainCall> {
/// Minimal Substrate-based chain representation that may be used from no_std environment. /// Minimal Substrate-based chain representation that may be used from no_std environment.
pub trait Chain: Send + Sync + 'static { 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. /// 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` // Constraits come from the associated Number type of `sp_runtime::traits::Header`
// See here for more info: // See here for more info:
@@ -208,6 +212,8 @@ impl<T> Chain for T
where where
T: Send + Sync + 'static + UnderlyingChainProvider, T: Send + Sync + 'static + UnderlyingChainProvider,
{ {
const ID: ChainId = <T::Chain as Chain>::ID;
type BlockNumber = <T::Chain as Chain>::BlockNumber; type BlockNumber = <T::Chain as Chain>::BlockNumber;
type Hash = <T::Chain as Chain>::Hash; type Hash = <T::Chain as Chain>::Hash;
type Hasher = <T::Chain as Chain>::Hasher; type Hasher = <T::Chain as Chain>::Hasher;
@@ -102,6 +102,7 @@ impl SignedExtensionSchema for Tuple {
/// and signed payloads in the client code. /// and signed payloads in the client code.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub struct GenericSignedExtension<S: SignedExtensionSchema> { pub struct GenericSignedExtension<S: SignedExtensionSchema> {
/// A payload that is included in the transaction.
pub payload: S::Payload, pub payload: S::Payload,
#[codec(skip)] #[codec(skip)]
// It may be set to `None` if extensions are decoded. We are never reconstructing transactions // It may be set to `None` if extensions are decoded. We are never reconstructing transactions
@@ -112,6 +113,7 @@ pub struct GenericSignedExtension<S: SignedExtensionSchema> {
} }
impl<S: SignedExtensionSchema> GenericSignedExtension<S> { impl<S: SignedExtensionSchema> GenericSignedExtension<S> {
/// Create new `GenericSignedExtension` object.
pub fn new(payload: S::Payload, additional_signed: Option<S::AdditionalSigned>) -> Self { pub fn new(payload: S::Payload, additional_signed: Option<S::AdditionalSigned>) -> Self {
Self { payload, additional_signed } Self { payload, additional_signed }
} }
+10 -33
View File
@@ -16,6 +16,7 @@
//! Primitives that may be used at (bridges) runtime level. //! Primitives that may be used at (bridges) runtime level.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; 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. /// Use this when something must be shared among all instances.
pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0]; 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. /// Generic header Id.
#[derive( #[derive(
RuntimeDebug, RuntimeDebug,
@@ -126,10 +97,10 @@ pub type HeaderIdOf<C> = HeaderId<HashOf<C>, BlockNumberOf<C>>;
/// Generic header id provider. /// Generic header id provider.
pub trait HeaderIdProvider<Header: HeaderT> { pub trait HeaderIdProvider<Header: HeaderT> {
// Get the header id. /// Get the header id.
fn id(&self) -> HeaderId<Header::Hash, Header::Number>; fn id(&self) -> HeaderId<Header::Hash, Header::Number>;
// Get the header id for the parent block. /// Get the header id for the parent block.
fn parent_id(&self) -> Option<HeaderId<Header::Hash, Header::Number>>; fn parent_id(&self) -> Option<HeaderId<Header::Hash, Header::Number>>;
} }
@@ -350,7 +321,7 @@ pub enum OwnedBridgeModuleError {
/// Operating mode for a bridge module. /// Operating mode for a bridge module.
pub trait OperatingMode: Send + Copy + Debug + FullCodec { 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; fn is_halted(&self) -> bool;
} }
@@ -392,8 +363,11 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
/// The target that will be used when publishing logs related to this module. /// The target that will be used when publishing logs related to this module.
const LOG_TARGET: &'static str; const LOG_TARGET: &'static str;
/// A storage entry that holds the module `Owner` account.
type OwnerStorage: StorageValue<T::AccountId, Query = Option<T::AccountId>>; type OwnerStorage: StorageValue<T::AccountId, Query = Option<T::AccountId>>;
/// Operating mode type of the pallet.
type OperatingMode: OperatingMode; type OperatingMode: OperatingMode;
/// A storage value that holds the pallet operating mode.
type OperatingModeStorage: StorageValue<Self::OperatingMode, Query = Self::OperatingMode>; type OperatingModeStorage: StorageValue<Self::OperatingMode, Query = Self::OperatingMode>;
/// Check if the module is halted. /// Check if the module is halted.
@@ -469,9 +443,11 @@ impl WeightExtraOps for Weight {
/// Trait that provides a static `str`. /// Trait that provides a static `str`.
pub trait StaticStrProvider { pub trait StaticStrProvider {
/// Static string.
const STR: &'static str; const STR: &'static str;
} }
/// A macro that generates `StaticStrProvider` with the string set to its stringified argument.
#[macro_export] #[macro_export]
macro_rules! generate_static_str_provider { macro_rules! generate_static_str_provider {
($str:expr) => { ($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)] #[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, TypeInfo)]
#[scale_info(skip_type_params(T))] #[scale_info(skip_type_params(T))]
pub struct StrippableError<T> { pub struct StrippableError<T> {
+9 -1
View File
@@ -24,12 +24,17 @@ use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId};
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
use sp_std::prelude::*; 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); pub const ALICE: Account = Account(0);
/// Set of test accounts with friendly names: Bob.
pub const BOB: Account = Account(1); pub const BOB: Account = Account(1);
/// Set of test accounts with friendly names: Charlie.
pub const CHARLIE: Account = Account(2); pub const CHARLIE: Account = Account(2);
/// Set of test accounts with friendly names: Dave.
pub const DAVE: Account = Account(3); pub const DAVE: Account = Account(3);
/// Set of test accounts with friendly names: Eve.
pub const EVE: Account = Account(4); pub const EVE: Account = Account(4);
/// Set of test accounts with friendly names: Ferdie.
pub const FERDIE: Account = Account(5); pub const FERDIE: Account = Account(5);
/// A test account which can be used to sign messages. /// 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); pub struct Account(pub u16);
impl Account { impl Account {
/// Returns public key of this account.
pub fn public(&self) -> VerifyingKey { pub fn public(&self) -> VerifyingKey {
self.pair().verifying_key() self.pair().verifying_key()
} }
/// Returns key pair, used to sign data on behalf of this account.
pub fn pair(&self) -> SigningKey { pub fn pair(&self) -> SigningKey {
let data = self.0.encode(); let data = self.0.encode();
let mut bytes = [0_u8; 32]; let mut bytes = [0_u8; 32];
@@ -48,6 +55,7 @@ impl Account {
SigningKey::from_bytes(&bytes) SigningKey::from_bytes(&bytes)
} }
/// Generate a signature of given message.
pub fn sign(&self, msg: &[u8]) -> Signature { pub fn sign(&self, msg: &[u8]) -> Signature {
use ed25519_dalek::Signer; use ed25519_dalek::Signer;
self.pair().sign(msg) self.pair().sign(msg)
+5 -1
View File
@@ -16,6 +16,7 @@
//! Utilities for testing runtime code. //! Utilities for testing runtime code.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use bp_header_chain::justification::{required_justification_precommits, GrandpaJustification}; use bp_header_chain::justification::{required_justification_precommits, GrandpaJustification};
@@ -33,8 +34,11 @@ pub use keyring::*;
mod keyring; mod keyring;
/// GRANDPA round number used across tests.
pub const TEST_GRANDPA_ROUND: u64 = 1; pub const TEST_GRANDPA_ROUND: u64 = 1;
/// GRANDPA validators set id used across tests.
pub const TEST_GRANDPA_SET_ID: SetId = 1; pub const TEST_GRANDPA_SET_ID: SetId = 1;
/// Name of the `Paras` pallet used across tests.
pub const PARAS_PALLET_NAME: &str = "Paras"; pub const PARAS_PALLET_NAME: &str = "Paras";
/// Configuration parameters when generating test GRANDPA justifications. /// Configuration parameters when generating test GRANDPA justifications.
@@ -190,7 +194,7 @@ pub fn prepare_parachain_heads_proof<H: HeaderT>(
.map_err(|_| "record_all_trie_keys has failed") .map_err(|_| "record_all_trie_keys has failed")
.expect("record_all_trie_keys should not fail in benchmarks"); .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. /// Create signed precommit with given target.
@@ -40,6 +40,8 @@ pub mod rococo_parachains_to_rococo_bulletin;
pub struct RococoBaseAsPolkadot; pub struct RococoBaseAsPolkadot;
impl bp_runtime::Chain for RococoBaseAsPolkadot { impl bp_runtime::Chain for RococoBaseAsPolkadot {
const ID: ChainId = relay_rococo_client::Rococo::ID;
type BlockNumber = BlockNumberOf<bp_rococo::Rococo>; type BlockNumber = BlockNumberOf<bp_rococo::Rococo>;
type Hash = HashOf<bp_rococo::Rococo>; type Hash = HashOf<bp_rococo::Rococo>;
type Hasher = HasherOf<bp_rococo::Rococo>; type Hasher = HasherOf<bp_rococo::Rococo>;
@@ -78,7 +80,6 @@ impl bp_runtime::UnderlyingChainProvider for RococoAsPolkadot {
} }
impl relay_substrate_client::Chain 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 NAME: &'static str = relay_rococo_client::Rococo::NAME;
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
relay_polkadot_client::Polkadot::BEST_FINALIZED_HEADER_ID_METHOD; relay_polkadot_client::Polkadot::BEST_FINALIZED_HEADER_ID_METHOD;
@@ -146,6 +147,8 @@ impl CliChain for RococoAsPolkadot {
pub struct BaseBridgeHubRococoAsBridgeHubPolkadot; pub struct BaseBridgeHubRococoAsBridgeHubPolkadot;
impl bp_runtime::Chain for BaseBridgeHubRococoAsBridgeHubPolkadot { impl bp_runtime::Chain for BaseBridgeHubRococoAsBridgeHubPolkadot {
const ID: ChainId = relay_bridge_hub_rococo_client::BridgeHubRococo::ID;
type BlockNumber = BlockNumberOf<bp_bridge_hub_rococo::BridgeHubRococo>; type BlockNumber = BlockNumberOf<bp_bridge_hub_rococo::BridgeHubRococo>;
type Hash = HashOf<bp_bridge_hub_rococo::BridgeHubRococo>; type Hash = HashOf<bp_bridge_hub_rococo::BridgeHubRococo>;
type Hasher = HasherOf<bp_bridge_hub_rococo::BridgeHubRococo>; type Hasher = HasherOf<bp_bridge_hub_rococo::BridgeHubRococo>;
@@ -169,6 +172,16 @@ impl bp_runtime::Parachain for BaseBridgeHubRococoAsBridgeHubPolkadot {
const PARACHAIN_ID: u32 = bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID; 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. /// Relay `Chain` implementation of Rococo Bridge Hub, pretending to be a Polkadot Bridge Hub.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BridgeHubRococoAsBridgeHubPolkadot; pub struct BridgeHubRococoAsBridgeHubPolkadot;
@@ -178,7 +191,6 @@ impl bp_runtime::UnderlyingChainProvider for BridgeHubRococoAsBridgeHubPolkadot
} }
impl relay_substrate_client::Chain 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 NAME: &'static str = relay_bridge_hub_rococo_client::BridgeHubRococo::NAME;
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::BEST_FINALIZED_HEADER_ID_METHOD; 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 { 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> = const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::WITH_CHAIN_RELAYERS_PALLET_NAME; 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; relay_bridge_hub_polkadot_client::BridgeHubPolkadot::TO_CHAIN_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
relay_bridge_hub_polkadot_client::BridgeHubPolkadot::FROM_CHAIN_MESSAGE_DETAILS_METHOD; 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 { impl CliChain for BridgeHubRococoAsBridgeHubPolkadot {
@@ -18,9 +18,7 @@ relay-substrate-client = { path = "../client-substrate" }
bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" } bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" }
bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" } bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" }
bp-header-chain = { path = "../../primitives/header-chain" } bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" } bp-parachains = { path = "../../primitives/parachains" }
bp-runtime = { path = "../../primitives/runtime" }
bp-polkadot = { path = "../../primitives/chain-polkadot" } bp-polkadot = { path = "../../primitives/chain-polkadot" }
bridge-runtime-common = { path = "../../bin/runtime-common" } bridge-runtime-common = { path = "../../bin/runtime-common" }
@@ -17,9 +17,7 @@
//! Types used to connect to the BridgeHub-Kusama-Substrate parachain. //! Types used to connect to the BridgeHub-Kusama-Substrate parachain.
use bp_bridge_hub_kusama::AVERAGE_BLOCK_INTERVAL; use bp_bridge_hub_kusama::AVERAGE_BLOCK_INTERVAL;
use bp_messages::MessageNonce;
use bp_polkadot::SuffixedCommonSignedExtensionExt; use bp_polkadot::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
@@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubKusama {
} }
impl Chain for BridgeHubKusama { impl Chain for BridgeHubKusama {
const ID: ChainId = bp_runtime::BRIDGE_HUB_KUSAMA_CHAIN_ID;
const NAME: &'static str = "BridgeHubKusama"; const NAME: &'static str = "BridgeHubKusama";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_bridge_hub_kusama::BEST_FINALIZED_BRIDGE_HUB_KUSAMA_HEADER_METHOD; bp_bridge_hub_kusama::BEST_FINALIZED_BRIDGE_HUB_KUSAMA_HEADER_METHOD;
@@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubKusama {
} }
impl ChainWithMessages 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> = const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
Some(bp_bridge_hub_kusama::WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME); 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; bp_bridge_hub_kusama::TO_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_kusama::FROM_BRIDGE_HUB_KUSAMA_MESSAGE_DETAILS_METHOD; 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)] #[cfg(test)]
@@ -18,7 +18,6 @@ relay-substrate-client = { path = "../client-substrate" }
bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" } bp-bridge-hub-kusama = { path = "../../primitives/chain-bridge-hub-kusama" }
bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" } bp-bridge-hub-polkadot = { path = "../../primitives/chain-bridge-hub-polkadot" }
bp-header-chain = { path = "../../primitives/header-chain" } bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" } bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot-bulletin = { path = "../../primitives/chain-polkadot-bulletin" } bp-polkadot-bulletin = { path = "../../primitives/chain-polkadot-bulletin" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-polkadot-core = { path = "../../primitives/polkadot-core" }
@@ -17,9 +17,7 @@
//! Types used to connect to the BridgeHub-Polkadot-Substrate parachain. //! Types used to connect to the BridgeHub-Polkadot-Substrate parachain.
use bp_bridge_hub_polkadot::AVERAGE_BLOCK_INTERVAL; use bp_bridge_hub_polkadot::AVERAGE_BLOCK_INTERVAL;
use bp_messages::MessageNonce;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
@@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubPolkadot {
} }
impl Chain for BridgeHubPolkadot { impl Chain for BridgeHubPolkadot {
const ID: ChainId = bp_runtime::BRIDGE_HUB_POLKADOT_CHAIN_ID;
const NAME: &'static str = "BridgeHubPolkadot"; const NAME: &'static str = "BridgeHubPolkadot";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_bridge_hub_polkadot::BEST_FINALIZED_BRIDGE_HUB_POLKADOT_HEADER_METHOD; bp_bridge_hub_polkadot::BEST_FINALIZED_BRIDGE_HUB_POLKADOT_HEADER_METHOD;
@@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubPolkadot {
} }
impl ChainWithMessages 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> = const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
Some(bp_bridge_hub_polkadot::WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME); 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; bp_bridge_hub_polkadot::TO_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_polkadot::FROM_BRIDGE_HUB_POLKADOT_MESSAGE_DETAILS_METHOD; 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)] #[cfg(test)]
@@ -11,7 +11,7 @@ workspace = true
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, 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 # Bridge dependencies
@@ -19,9 +19,7 @@
pub mod codegen_runtime; pub mod codegen_runtime;
use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; use bp_bridge_hub_rococo::{SignedExtension, AVERAGE_BLOCK_INTERVAL};
use bp_messages::MessageNonce;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages,
@@ -52,7 +50,6 @@ impl UnderlyingChainProvider for BridgeHubRococo {
} }
impl Chain for BridgeHubRococo { impl Chain for BridgeHubRococo {
const ID: ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID;
const NAME: &'static str = "BridgeHubRococo"; const NAME: &'static str = "BridgeHubRococo";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_bridge_hub_rococo::BEST_FINALIZED_BRIDGE_HUB_ROCOCO_HEADER_METHOD; bp_bridge_hub_rococo::BEST_FINALIZED_BRIDGE_HUB_ROCOCO_HEADER_METHOD;
@@ -134,8 +131,6 @@ impl ChainWithTransactions for BridgeHubRococo {
} }
impl ChainWithMessages 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> = const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
Some(bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME); 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; bp_bridge_hub_rococo::TO_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_rococo::FROM_BRIDGE_HUB_ROCOCO_MESSAGE_DETAILS_METHOD; 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)] #[cfg(test)]
@@ -11,18 +11,16 @@ workspace = true
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.1.5", features = ["derive"] }
scale-info = { version = "2.10.0", default-features = false, 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 # Bridge dependencies
bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" } bp-bridge-hub-rococo = { path = "../../primitives/chain-bridge-hub-rococo" }
bp-bridge-hub-westend = { path = "../../primitives/chain-bridge-hub-westend" } bp-bridge-hub-westend = { path = "../../primitives/chain-bridge-hub-westend" }
bp-header-chain = { path = "../../primitives/header-chain" } bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" }
bp-parachains = { path = "../../primitives/parachains" } bp-parachains = { path = "../../primitives/parachains" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-rococo = { path = "../../primitives/chain-rococo" } bp-rococo = { path = "../../primitives/chain-rococo" }
bp-runtime = { path = "../../primitives/runtime" }
bridge-runtime-common = { path = "../../bin/runtime-common" } bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-substrate-client = { path = "../client-substrate" } 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" } sp-weights = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
[dev-dependencies] [dev-dependencies]
bp-runtime = { path = "../../primitives/runtime" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" }
@@ -17,9 +17,7 @@
//! Types used to connect to the BridgeHub-Westend-Substrate parachain. //! Types used to connect to the BridgeHub-Westend-Substrate parachain.
use bp_bridge_hub_westend::AVERAGE_BLOCK_INTERVAL; use bp_bridge_hub_westend::AVERAGE_BLOCK_INTERVAL;
use bp_messages::MessageNonce;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet, Chain, ChainWithBalances, ChainWithMessages, ChainWithTransactions, ChainWithUtilityPallet,
@@ -43,7 +41,6 @@ impl UnderlyingChainProvider for BridgeHubWestend {
} }
impl Chain for BridgeHubWestend { impl Chain for BridgeHubWestend {
const ID: ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
const NAME: &'static str = "BridgeHubWestend"; const NAME: &'static str = "BridgeHubWestend";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_bridge_hub_westend::BEST_FINALIZED_BRIDGE_HUB_WESTEND_HEADER_METHOD; bp_bridge_hub_westend::BEST_FINALIZED_BRIDGE_HUB_WESTEND_HEADER_METHOD;
@@ -116,8 +113,6 @@ impl ChainWithTransactions for BridgeHubWestend {
} }
impl ChainWithMessages 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> = const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> =
Some(bp_bridge_hub_westend::WITH_BRIDGE_HUB_WESTEND_RELAYERS_PALLET_NAME); 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; bp_bridge_hub_westend::TO_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_bridge_hub_westend::FROM_BRIDGE_HUB_WESTEND_MESSAGE_DETAILS_METHOD; 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)] #[cfg(test)]
-2
View File
@@ -20,7 +20,6 @@ pub mod codegen_runtime;
use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; use bp_kusama::{AccountInfoStorageMapKeyProvider, KUSAMA_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
@@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Kusama {
} }
impl Chain for Kusama { impl Chain for Kusama {
const ID: ChainId = bp_runtime::KUSAMA_CHAIN_ID;
const NAME: &'static str = "Kusama"; const NAME: &'static str = "Kusama";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_kusama::BEST_FINALIZED_KUSAMA_HEADER_METHOD; bp_kusama::BEST_FINALIZED_KUSAMA_HEADER_METHOD;
@@ -18,9 +18,7 @@
mod codegen_runtime; mod codegen_runtime;
use bp_messages::MessageNonce;
use bp_polkadot_bulletin::POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use bp_polkadot_bulletin::POLKADOT_BULLETIN_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, ChainWithTransactions, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithMessages, ChainWithTransactions,
@@ -65,8 +63,6 @@ impl UnderlyingChainProvider for PolkadotBulletin {
} }
impl Chain for PolkadotBulletin { impl Chain for PolkadotBulletin {
const ID: ChainId = *b"pbch";
const NAME: &'static str = "PolkadotBulletin"; const NAME: &'static str = "PolkadotBulletin";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_polkadot_bulletin::BEST_FINALIZED_POLKADOT_BULLETIN_HEADER_METHOD; bp_polkadot_bulletin::BEST_FINALIZED_POLKADOT_BULLETIN_HEADER_METHOD;
@@ -84,8 +80,6 @@ impl ChainWithGrandpa for PolkadotBulletin {
} }
impl ChainWithMessages 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 // 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 // to be changed when we'll polish the bridge configuration
const WITH_CHAIN_RELAYERS_PALLET_NAME: Option<&'static str> = None; 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; bp_polkadot_bulletin::TO_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD;
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str = const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str =
bp_polkadot_bulletin::FROM_POLKADOT_BULLETIN_MESSAGE_DETAILS_METHOD; 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 { impl ChainWithBalances for PolkadotBulletin {
@@ -20,7 +20,6 @@ mod codegen_runtime;
use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD}; use bp_polkadot::{AccountInfoStorageMapKeyProvider, POLKADOT_SYNCED_HEADERS_GRANDPA_INFO_METHOD};
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
@@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Polkadot {
} }
impl Chain for Polkadot { impl Chain for Polkadot {
const ID: ChainId = bp_runtime::POLKADOT_CHAIN_ID;
const NAME: &'static str = "Polkadot"; const NAME: &'static str = "Polkadot";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_polkadot::BEST_FINALIZED_POLKADOT_HEADER_METHOD; bp_polkadot::BEST_FINALIZED_POLKADOT_HEADER_METHOD;
-1
View File
@@ -17,7 +17,6 @@ subxt = { version = "0.32.1", default-features = false, features = ["native"] }
bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-rococo = { path = "../../primitives/chain-rococo" } bp-rococo = { path = "../../primitives/chain-rococo" }
bp-runtime = { path = "../../primitives/runtime" }
relay-substrate-client = { path = "../client-substrate" } relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" } relay-utils = { path = "../utils" }
-2
View File
@@ -20,7 +20,6 @@ pub mod codegen_runtime;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use bp_rococo::ROCOCO_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use bp_runtime::ChainId;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError, Chain, ChainWithBalances, ChainWithGrandpa, ChainWithTransactions, Error as SubstrateError,
@@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Rococo {
} }
impl Chain for Rococo { impl Chain for Rococo {
const ID: ChainId = bp_runtime::ROCOCO_CHAIN_ID;
const NAME: &'static str = "Rococo"; const NAME: &'static str = "Rococo";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD; bp_rococo::BEST_FINALIZED_ROCOCO_HEADER_METHOD;
+4 -20
View File
@@ -17,10 +17,10 @@
use crate::calls::UtilityCall; use crate::calls::UtilityCall;
use bp_header_chain::ChainWithGrandpa as ChainWithGrandpaBase; use bp_header_chain::ChainWithGrandpa as ChainWithGrandpaBase;
use bp_messages::MessageNonce; use bp_messages::ChainWithMessages as ChainWithMessagesBase;
use bp_runtime::{ use bp_runtime::{
Chain as ChainBase, ChainId, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra,
TransactionEra, TransactionEraOf, UnderlyingChainProvider, TransactionEraOf, UnderlyingChainProvider,
}; };
use codec::{Codec, Decode, Encode}; use codec::{Codec, Decode, Encode};
use jsonrpsee::core::{DeserializeOwned, Serialize}; 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. /// Substrate-based chain from minimal relay-client point of view.
pub trait Chain: ChainBase + Clone { pub trait Chain: ChainBase + Clone {
/// Chain id.
const ID: ChainId;
/// Chain name. /// Chain name.
const NAME: &'static str; const NAME: &'static str;
/// Name of the runtime API method that is returning best known finalized header number /// Name of the runtime API method that is returning best known finalized header number
@@ -91,14 +89,7 @@ pub trait Parachain: Chain + ParachainBase {}
impl<T> Parachain for T where T: UnderlyingChainProvider + Chain + ParachainBase {} impl<T> Parachain for T where T: UnderlyingChainProvider + Chain + ParachainBase {}
/// Substrate-based chain with messaging support from minimal relay-client point of view. /// Substrate-based chain with messaging support from minimal relay-client point of view.
pub trait ChainWithMessages: Chain { pub trait ChainWithMessages: Chain + ChainWithMessagesBase {
/// 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;
// TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): check all the names // TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): check all the names
// after the issue is fixed - all names must be changed // after the issue is fixed - all names must be changed
@@ -116,13 +107,6 @@ pub trait ChainWithMessages: Chain {
/// Name of the `From<ChainWithMessages>InboundLaneApi::message_details` runtime API method. /// Name of the `From<ChainWithMessages>InboundLaneApi::message_details` runtime API method.
/// The method is provided by the runtime that is bridged with this `ChainWithMessages`. /// The method is provided by the runtime that is bridged with this `ChainWithMessages`.
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str; 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. /// Call type used by the chain.
@@ -31,6 +31,8 @@ use std::time::Duration;
pub struct TestChain; pub struct TestChain;
impl bp_runtime::Chain for TestChain { impl bp_runtime::Chain for TestChain {
const ID: ChainId = *b"test";
type BlockNumber = u32; type BlockNumber = u32;
type Hash = sp_core::H256; type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256; type Hasher = sp_runtime::traits::BlakeTwo256;
@@ -51,7 +53,6 @@ impl bp_runtime::Chain for TestChain {
} }
impl Chain for TestChain { impl Chain for TestChain {
const ID: ChainId = *b"test";
const NAME: &'static str = "Test"; const NAME: &'static str = "Test";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestMethod"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestMethod";
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0); const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0);
@@ -73,6 +74,8 @@ impl ChainWithBalances for TestChain {
pub struct TestParachainBase; pub struct TestParachainBase;
impl bp_runtime::Chain for TestParachainBase { impl bp_runtime::Chain for TestParachainBase {
const ID: ChainId = *b"tstp";
type BlockNumber = u32; type BlockNumber = u32;
type Hash = sp_core::H256; type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256; type Hasher = sp_runtime::traits::BlakeTwo256;
@@ -105,7 +108,6 @@ impl bp_runtime::UnderlyingChainProvider for TestParachain {
} }
impl Chain for TestParachain { impl Chain for TestParachain {
const ID: ChainId = *b"test";
const NAME: &'static str = "TestParachain"; const NAME: &'static str = "TestParachain";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestParachainMethod"; const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestParachainMethod";
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0); const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0);
-2
View File
@@ -19,7 +19,6 @@
pub mod codegen_runtime; pub mod codegen_runtime;
use bp_polkadot_core::SuffixedCommonSignedExtensionExt; use bp_polkadot_core::SuffixedCommonSignedExtensionExt;
use bp_runtime::ChainId;
use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD; use bp_westend::WESTEND_SYNCED_HEADERS_GRANDPA_INFO_METHOD;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
@@ -55,7 +54,6 @@ impl UnderlyingChainProvider for Westend {
} }
impl Chain for Westend { impl Chain for Westend {
const ID: ChainId = bp_runtime::WESTEND_CHAIN_ID;
const NAME: &'static str = "Westend"; const NAME: &'static str = "Westend";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = const BEST_FINALIZED_HEADER_ID_METHOD: &'static str =
bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD; bp_westend::BEST_FINALIZED_WESTEND_HEADER_METHOD;
@@ -24,7 +24,7 @@ use crate::{
}; };
use async_std::sync::Arc; use async_std::sync::Arc;
use bp_messages::{LaneId, MessageNonce}; use bp_messages::{ChainWithMessages as _, LaneId, MessageNonce};
use bp_runtime::{ use bp_runtime::{
AccountIdOf, Chain as _, EncodedOrDecodedCall, HeaderIdOf, TransactionEra, WeightExtraOps, AccountIdOf, Chain as _, EncodedOrDecodedCall, HeaderIdOf, TransactionEra, WeightExtraOps,
}; };
@@ -32,8 +32,8 @@ use async_std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use bp_messages::{ use bp_messages::{
storage_keys::{operating_mode_key, outbound_lane_data_key}, storage_keys::{operating_mode_key, outbound_lane_data_key},
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, MessagesOperatingMode, ChainWithMessages as _, InboundMessageDetails, LaneId, MessageNonce, MessagePayload,
OutboundLaneData, OutboundMessageDetails, MessagesOperatingMode, OutboundLaneData, OutboundMessageDetails,
}; };
use bp_runtime::{BasicOperatingMode, HeaderIdProvider}; use bp_runtime::{BasicOperatingMode, HeaderIdProvider};
use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof;
@@ -31,8 +31,8 @@ use crate::{
use async_std::sync::Arc; use async_std::sync::Arc;
use async_trait::async_trait; use async_trait::async_trait;
use bp_messages::{ use bp_messages::{
storage_keys::inbound_lane_data_key, InboundLaneData, LaneId, MessageNonce, storage_keys::inbound_lane_data_key, ChainWithMessages as _, InboundLaneData, LaneId,
UnrewardedRelayersState, MessageNonce, UnrewardedRelayersState,
}; };
use bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof; use bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof;
use messages_relay::{ use messages_relay::{
@@ -40,8 +40,8 @@ use messages_relay::{
message_lane_loop::{NoncesSubmitArtifacts, TargetClient, TargetClientState}, message_lane_loop::{NoncesSubmitArtifacts, TargetClient, TargetClientState},
}; };
use relay_substrate_client::{ use relay_substrate_client::{
AccountIdOf, AccountKeyPairOf, BalanceOf, CallOf, ChainWithMessages, Client, AccountIdOf, AccountKeyPairOf, BalanceOf, CallOf, Client, Error as SubstrateError, HashOf,
Error as SubstrateError, HashOf, TransactionEra, TransactionTracker, UnsignedTransaction, TransactionEra, TransactionTracker, UnsignedTransaction,
}; };
use relay_utils::relay_loop::Client as RelayClient; use relay_utils::relay_loop::Client as RelayClient;
use sp_core::Pair; use sp_core::Pair;
@@ -164,6 +164,6 @@ where
})?; })?;
let parachain_head_hash = parachain_head.hash(); 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))
} }
} }
@@ -648,7 +648,8 @@ mod tests {
_at_block: HeaderIdOf<TestChain>, _at_block: HeaderIdOf<TestChain>,
) -> Result<(ParaHeadsProof, ParaHash), TestError> { ) -> Result<(ParaHeadsProof, ParaHash), TestError> {
let head = *self.data.lock().await.source_head.clone()?.as_available().unwrap(); 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) self.data.lock().await.source_proof.clone().map(|_| proof)
} }
} }