mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-25 11:45:47 +00:00
Split decl_bridge_runtime_apis!() (#1553)
Signed-off-by: Serban Iorga <serban@parity.io> Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
7ad5b0fe56
commit
f3a151feeb
@@ -29,7 +29,9 @@ use sp_std::prelude::*;
|
|||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
};
|
||||||
|
|
||||||
/// Kusama Chain
|
/// Kusama Chain
|
||||||
pub type Kusama = PolkadotLike;
|
pub type Kusama = PolkadotLike;
|
||||||
@@ -91,4 +93,4 @@ pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str =
|
|||||||
/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime.
|
/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime.
|
||||||
pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier";
|
pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(kusama);
|
decl_bridge_runtime_apis!(kusama);
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ mod millau_hash;
|
|||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||||
};
|
};
|
||||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
Chain,
|
||||||
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||||
Parameter, RuntimeDebug,
|
Parameter, RuntimeDebug,
|
||||||
@@ -254,4 +257,4 @@ pub const RIALTO_PARACHAIN_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME: &str =
|
|||||||
/// Name of the RialtoParachain fee multiplier parameter, stored in the Millau runtime.
|
/// Name of the RialtoParachain fee multiplier parameter, stored in the Millau runtime.
|
||||||
pub const RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME: &str = "RialtoParachainFeeMultiplier";
|
pub const RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME: &str = "RialtoParachainFeeMultiplier";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(millau);
|
decl_bridge_runtime_apis!(millau);
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ use sp_std::prelude::*;
|
|||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
};
|
||||||
|
|
||||||
/// Polkadot Chain
|
/// Polkadot Chain
|
||||||
pub type Polkadot = PolkadotLike;
|
pub type Polkadot = PolkadotLike;
|
||||||
@@ -91,4 +93,4 @@ pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str =
|
|||||||
/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime.
|
/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime.
|
||||||
pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier";
|
pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(polkadot);
|
decl_bridge_runtime_apis!(polkadot);
|
||||||
|
|||||||
@@ -21,7 +21,10 @@
|
|||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||||
};
|
};
|
||||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
Chain,
|
||||||
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||||
Parameter, RuntimeDebug,
|
Parameter, RuntimeDebug,
|
||||||
@@ -193,4 +196,4 @@ pub const MILLAU_TO_RIALTO_PARACHAIN_CONVERSION_RATE_PARAMETER_NAME: &str =
|
|||||||
/// Name of the Millau fee multiplier parameter, stored in the Rialto parachain runtime.
|
/// Name of the Millau fee multiplier parameter, stored in the Rialto parachain runtime.
|
||||||
pub const MILLAU_FEE_MULTIPLIER_PARAMETER_NAME: &str = "MillauFeeMultiplier";
|
pub const MILLAU_FEE_MULTIPLIER_PARAMETER_NAME: &str = "MillauFeeMultiplier";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(rialto_parachain);
|
decl_bridge_runtime_apis!(rialto_parachain);
|
||||||
|
|||||||
@@ -21,7 +21,10 @@
|
|||||||
use bp_messages::{
|
use bp_messages::{
|
||||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||||
};
|
};
|
||||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
Chain,
|
||||||
|
};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||||
Parameter, RuntimeDebug,
|
Parameter, RuntimeDebug,
|
||||||
@@ -217,4 +220,4 @@ pub const PARAS_REGISTRAR_PALLET_NAME: &str = "Registrar";
|
|||||||
/// Name of the parachains pallet in the Rialto runtime.
|
/// Name of the parachains pallet in the Rialto runtime.
|
||||||
pub const PARAS_PALLET_NAME: &str = "Paras";
|
pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(rialto);
|
decl_bridge_runtime_apis!(rialto);
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ use sp_std::prelude::*;
|
|||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
};
|
||||||
|
|
||||||
/// Rococo Chain
|
/// Rococo Chain
|
||||||
pub type Rococo = PolkadotLike;
|
pub type Rococo = PolkadotLike;
|
||||||
@@ -87,4 +89,4 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100;
|
|||||||
/// transactions cheaper.
|
/// transactions cheaper.
|
||||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(rococo);
|
decl_bridge_runtime_apis!(rococo);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
|
||||||
|
paste = "1.0"
|
||||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||||
smallvec = "1.7"
|
smallvec = "1.7"
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use sp_std::prelude::*;
|
|||||||
use sp_version::RuntimeVersion;
|
use sp_version::RuntimeVersion;
|
||||||
|
|
||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
|
use bp_runtime::decl_bridge_finality_runtime_apis;
|
||||||
|
|
||||||
/// Westend Chain
|
/// Westend Chain
|
||||||
pub type Westend = PolkadotLike;
|
pub type Westend = PolkadotLike;
|
||||||
@@ -85,9 +86,6 @@ pub const WITH_WESTEND_GRANDPA_PALLET_NAME: &str = "BridgeWestendGrandpa";
|
|||||||
/// Name of the With-Westend parachains bridge pallet instance that is deployed at bridged chains.
|
/// Name of the With-Westend parachains bridge pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeWestendParachains";
|
pub const WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeWestendParachains";
|
||||||
|
|
||||||
/// Name of the `WestendFinalityApi::best_finalized` runtime method.
|
|
||||||
pub const BEST_FINALIZED_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_best_finalized";
|
|
||||||
|
|
||||||
/// The target length of a session (how often authorities change) on Westend measured in of number
|
/// The target length of a session (how often authorities change) on Westend measured in of number
|
||||||
/// of blocks.
|
/// of blocks.
|
||||||
///
|
///
|
||||||
@@ -95,28 +93,9 @@ pub const BEST_FINALIZED_WESTEND_HEADER_METHOD: &str = "WestendFinalityApi_best_
|
|||||||
/// conditions.
|
/// conditions.
|
||||||
pub const SESSION_LENGTH: BlockNumber = 10 * time_units::MINUTES;
|
pub const SESSION_LENGTH: BlockNumber = 10 * time_units::MINUTES;
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
|
||||||
/// API for querying information about the finalized Westend headers.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are bridging with the Westend chain, not the
|
|
||||||
/// Westend runtime itself.
|
|
||||||
pub trait WestendFinalityApi {
|
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
|
||||||
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// API for querying information about the finalized Westmint headers.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are bridging with the Westmint chain, not the
|
|
||||||
/// Westmint runtime itself.
|
|
||||||
pub trait WestmintFinalityApi {
|
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
|
||||||
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Identifier of Westmint parachain at the Westend relay chain.
|
/// Identifier of Westmint parachain at the Westend relay chain.
|
||||||
pub const WESTMINT_PARACHAIN_ID: u32 = 2000;
|
pub const WESTMINT_PARACHAIN_ID: u32 = 2000;
|
||||||
|
|
||||||
/// Name of the `WestmintFinalityApi::best_finalized` runtime method.
|
decl_bridge_finality_runtime_apis!(westend);
|
||||||
pub const BEST_FINALIZED_WESTMINT_HEADER_METHOD: &str = "WestmintFinalityApi_best_finalized";
|
|
||||||
|
decl_bridge_finality_runtime_apis!(westmint);
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ use sp_std::prelude::*;
|
|||||||
pub use bp_polkadot_core::*;
|
pub use bp_polkadot_core::*;
|
||||||
// Rococo runtime = Wococo runtime
|
// Rococo runtime = Wococo runtime
|
||||||
pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION};
|
pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION};
|
||||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
use bp_runtime::{
|
||||||
|
decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, decl_bridge_runtime_apis,
|
||||||
|
};
|
||||||
|
|
||||||
/// Wococo Chain
|
/// Wococo Chain
|
||||||
pub type Wococo = PolkadotLike;
|
pub type Wococo = PolkadotLike;
|
||||||
@@ -44,4 +46,4 @@ pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
|
|||||||
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
||||||
pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages";
|
pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages";
|
||||||
|
|
||||||
declare_bridge_chain_runtime_apis!(wococo);
|
decl_bridge_runtime_apis!(wococo);
|
||||||
|
|||||||
@@ -215,25 +215,57 @@ pub type AccountPublicOf<C> = <SignatureOf<C> as Verify>::Signer;
|
|||||||
/// Transaction era used by the chain.
|
/// Transaction era used by the chain.
|
||||||
pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>;
|
pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>;
|
||||||
|
|
||||||
/// Convenience macro that declares runtime apis and related constants for a bridge chain.
|
/// Convenience macro that declares bridge finality runtime apis and related constants for a chain.
|
||||||
/// This includes:
|
/// This includes:
|
||||||
/// - chain-specific bridge runtime APIs:
|
/// - chain-specific bridge runtime APIs:
|
||||||
/// - `<ThisChain>FinalityApi`
|
/// - `<ThisChain>FinalityApi`
|
||||||
|
/// - constants that are stringified names of runtime API methods:
|
||||||
|
/// - `BEST_FINALIZED_<THIS_CHAIN>_HEADER_METHOD`
|
||||||
|
/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`).
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! decl_bridge_finality_runtime_apis {
|
||||||
|
($chain: ident) => {
|
||||||
|
paste::item! {
|
||||||
|
mod [<$chain _finality_api>] {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Name of the `<ThisChain>FinalityApi::best_finalized` runtime method.
|
||||||
|
pub const [<BEST_FINALIZED_ $chain:upper _HEADER_METHOD>]: &str =
|
||||||
|
stringify!([<$chain:camel FinalityApi_best_finalized>]);
|
||||||
|
|
||||||
|
sp_api::decl_runtime_apis! {
|
||||||
|
/// API for querying information about the finalized chain headers.
|
||||||
|
///
|
||||||
|
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
||||||
|
/// chain's runtime itself.
|
||||||
|
pub trait [<$chain:camel FinalityApi>] {
|
||||||
|
/// Returns number and hash of the best finalized header known to the bridge module.
|
||||||
|
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use [<$chain _finality_api>]::*;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Convenience macro that declares bridge messages runtime apis and related constants for a chain.
|
||||||
|
/// This includes:
|
||||||
|
/// - chain-specific bridge runtime APIs:
|
||||||
/// - `To<ThisChain>OutboundLaneApi`
|
/// - `To<ThisChain>OutboundLaneApi`
|
||||||
/// - `From<ThisChain>InboundLaneApi`
|
/// - `From<ThisChain>InboundLaneApi`
|
||||||
/// - constants that are stringified names of runtime API methods:
|
/// - constants that are stringified names of runtime API methods:
|
||||||
/// - `BEST_FINALIZED_<THIS_CHAIN>_HEADER_METHOD`
|
|
||||||
/// - `TO_<THIS_CHAIN>_ESTIMATE_MESSAGE_FEE_METHOD`
|
/// - `TO_<THIS_CHAIN>_ESTIMATE_MESSAGE_FEE_METHOD`
|
||||||
/// - `TO_<THIS_CHAIN>_MESSAGE_DETAILS_METHOD`
|
/// - `TO_<THIS_CHAIN>_MESSAGE_DETAILS_METHOD`
|
||||||
/// - `FROM_<THIS_CHAIN>_MESSAGE_DETAILS_METHOD`,
|
/// - `FROM_<THIS_CHAIN>_MESSAGE_DETAILS_METHOD`,
|
||||||
/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`).
|
/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`).
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! declare_bridge_chain_runtime_apis {
|
macro_rules! decl_bridge_messages_runtime_apis {
|
||||||
($chain: ident) => {
|
($chain: ident) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
/// Name of the `<ThisChain>FinalityApi::best_finalized` runtime method.
|
mod [<$chain _messages_api>] {
|
||||||
pub const [<BEST_FINALIZED_ $chain:upper _HEADER_METHOD>]: &str =
|
use super::*;
|
||||||
stringify!([<$chain:camel FinalityApi_best_finalized>]);
|
|
||||||
|
|
||||||
/// Name of the `To<ThisChain>OutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
/// Name of the `To<ThisChain>OutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||||
/// method.
|
/// method.
|
||||||
@@ -248,15 +280,6 @@ macro_rules! declare_bridge_chain_runtime_apis {
|
|||||||
stringify!([<From $chain:camel InboundLaneApi_message_details>]);
|
stringify!([<From $chain:camel InboundLaneApi_message_details>]);
|
||||||
|
|
||||||
sp_api::decl_runtime_apis! {
|
sp_api::decl_runtime_apis! {
|
||||||
/// API for querying information about the finalized chain headers.
|
|
||||||
///
|
|
||||||
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
|
||||||
/// chain's runtime itself.
|
|
||||||
pub trait [<$chain:camel FinalityApi>] {
|
|
||||||
/// Returns number and hash of the best finalized header known to the bridge module.
|
|
||||||
fn best_finalized() -> Option<bp_runtime::HeaderId<Hash, BlockNumber>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Outbound message lane API for messages that are sent to this chain.
|
/// Outbound message lane API for messages that are sent to this chain.
|
||||||
///
|
///
|
||||||
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
||||||
@@ -304,5 +327,19 @@ macro_rules! declare_bridge_chain_runtime_apis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub use [<$chain _messages_api>]::*;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convenience macro that declares bridge finality runtime apis, bridge messages runtime apis
|
||||||
|
/// and related constants for a chain.
|
||||||
|
/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`).
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! decl_bridge_runtime_apis {
|
||||||
|
($chain: ident) => {
|
||||||
|
decl_bridge_finality_runtime_apis!($chain);
|
||||||
|
decl_bridge_messages_runtime_apis!($chain);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user