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
+4 -20
View File
@@ -17,10 +17,10 @@
use crate::calls::UtilityCall;
use bp_header_chain::ChainWithGrandpa as ChainWithGrandpaBase;
use bp_messages::MessageNonce;
use bp_messages::ChainWithMessages as ChainWithMessagesBase;
use bp_runtime::{
Chain as ChainBase, ChainId, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase,
TransactionEra, TransactionEraOf, UnderlyingChainProvider,
Chain as ChainBase, EncodedOrDecodedCall, HashOf, Parachain as ParachainBase, TransactionEra,
TransactionEraOf, UnderlyingChainProvider,
};
use codec::{Codec, Decode, Encode};
use jsonrpsee::core::{DeserializeOwned, Serialize};
@@ -37,8 +37,6 @@ use std::{fmt::Debug, time::Duration};
/// Substrate-based chain from minimal relay-client point of view.
pub trait Chain: ChainBase + Clone {
/// Chain id.
const ID: ChainId;
/// Chain name.
const NAME: &'static str;
/// Name of the runtime API method that is returning best known finalized header number
@@ -91,14 +89,7 @@ pub trait Parachain: Chain + ParachainBase {}
impl<T> Parachain for T where T: UnderlyingChainProvider + Chain + ParachainBase {}
/// Substrate-based chain with messaging support from minimal relay-client point of view.
pub trait ChainWithMessages: Chain {
/// Name of the bridge messages pallet (used in `construct_runtime` macro call) that is deployed
/// at some other chain to bridge with this `ChainWithMessages`.
///
/// We assume that all chains that are bridging with this `ChainWithMessages` are using
/// the same name.
const WITH_CHAIN_MESSAGES_PALLET_NAME: &'static str;
pub trait ChainWithMessages: Chain + ChainWithMessagesBase {
// TODO (https://github.com/paritytech/parity-bridges-common/issues/1692): check all the names
// after the issue is fixed - all names must be changed
@@ -116,13 +107,6 @@ pub trait ChainWithMessages: Chain {
/// Name of the `From<ChainWithMessages>InboundLaneApi::message_details` runtime API method.
/// The method is provided by the runtime that is bridged with this `ChainWithMessages`.
const FROM_CHAIN_MESSAGE_DETAILS_METHOD: &'static str;
/// Maximal number of unrewarded relayers in a single confirmation transaction at this
/// `ChainWithMessages`.
const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce;
/// Maximal number of unconfirmed messages in a single confirmation transaction at this
/// `ChainWithMessages`.
const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce;
}
/// Call type used by the chain.
@@ -31,6 +31,8 @@ use std::time::Duration;
pub struct TestChain;
impl bp_runtime::Chain for TestChain {
const ID: ChainId = *b"test";
type BlockNumber = u32;
type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256;
@@ -51,7 +53,6 @@ impl bp_runtime::Chain for TestChain {
}
impl Chain for TestChain {
const ID: ChainId = *b"test";
const NAME: &'static str = "Test";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestMethod";
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0);
@@ -73,6 +74,8 @@ impl ChainWithBalances for TestChain {
pub struct TestParachainBase;
impl bp_runtime::Chain for TestParachainBase {
const ID: ChainId = *b"tstp";
type BlockNumber = u32;
type Hash = sp_core::H256;
type Hasher = sp_runtime::traits::BlakeTwo256;
@@ -105,7 +108,6 @@ impl bp_runtime::UnderlyingChainProvider for TestParachain {
}
impl Chain for TestParachain {
const ID: ChainId = *b"test";
const NAME: &'static str = "TestParachain";
const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "TestParachainMethod";
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_millis(0);