mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
Declare declare_bridge_chain_runtime_apis! macro
Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
5cc874e7b8
commit
59c168e89b
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0"
|
||||
smallvec = "1.7"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
@@ -29,6 +29,7 @@ use sp_std::prelude::*;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use bp_polkadot_core::*;
|
||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
||||
|
||||
/// Kusama Chain
|
||||
pub type Kusama = PolkadotLike;
|
||||
@@ -90,72 +91,4 @@ pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||
/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime.
|
||||
pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier";
|
||||
|
||||
/// Name of the `KusamaFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_KUSAMA_HEADER_METHOD: &str = "KusamaFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToKusamaOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_KUSAMA_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToKusamaOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToKusamaOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "ToKusamaOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromKusamaInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_KUSAMA_MESSAGE_DETAILS_METHOD: &str = "FromKusamaInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Kusama headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Kusama chain, not the
|
||||
/// Kusama runtime itself.
|
||||
pub trait KusamaFinalityApi {
|
||||
/// 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 Kusama chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Kusama chain, not the
|
||||
/// Kusama runtime itself.
|
||||
pub trait ToKusamaOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Kusama from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
kusama_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Kusama chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Kusama chain, not the
|
||||
/// Kusama runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromKusamaInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(kusama);
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ mod millau_hash;
|
||||
use bp_messages::{
|
||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||
};
|
||||
use bp_runtime::Chain;
|
||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||
Parameter, RuntimeDebug,
|
||||
@@ -254,72 +254,4 @@ pub const RIALTO_PARACHAIN_TO_MILLAU_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||
/// Name of the RialtoParachain fee multiplier parameter, stored in the Millau runtime.
|
||||
pub const RIALTO_PARACHAIN_FEE_MULTIPLIER_PARAMETER_NAME: &str = "RialtoParachainFeeMultiplier";
|
||||
|
||||
/// Name of the `MillauFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_MILLAU_HEADER_METHOD: &str = "MillauFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToMillauOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToMillauOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToMillauOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_MILLAU_MESSAGE_DETAILS_METHOD: &str = "ToMillauOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromMillauInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_MILLAU_MESSAGE_DETAILS_METHOD: &str = "FromMillauInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Millau headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Millau chain, not the
|
||||
/// Millau runtime itself.
|
||||
pub trait MillauFinalityApi {
|
||||
/// 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 Millau chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Millau chain, not the
|
||||
/// Millau runtime itself.
|
||||
pub trait ToMillauOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Millau from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
millau_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Millau chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Millau chain, not the
|
||||
/// Millau runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromMillauInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(millau);
|
||||
|
||||
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
smallvec = "1.7"
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use sp_std::prelude::*;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use bp_polkadot_core::*;
|
||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
||||
|
||||
/// Polkadot Chain
|
||||
pub type Polkadot = PolkadotLike;
|
||||
@@ -90,73 +91,4 @@ pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str =
|
||||
/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime.
|
||||
pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier";
|
||||
|
||||
/// Name of the `PolkadotFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_POLKADOT_HEADER_METHOD: &str = "PolkadotFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToPolkadotOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_POLKADOT_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToPolkadotOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToPolkadotOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_POLKADOT_MESSAGE_DETAILS_METHOD: &str = "ToPolkadotOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromPolkadotInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_POLKADOT_MESSAGE_DETAILS_METHOD: &str =
|
||||
"FromPolkadotOutboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Polkadot headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Polkadot chain, not the
|
||||
/// Polkadot runtime itself.
|
||||
pub trait PolkadotFinalityApi {
|
||||
/// 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 Polkadot chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Polkadot chain, not the
|
||||
/// Polkadot runtime itself.
|
||||
pub trait ToPolkadotOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Polkadot from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
polkadot_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Polkadot chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Polkadot chain, not the
|
||||
/// Polkadot runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromPolkadotInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(polkadot);
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use bp_messages::{
|
||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||
};
|
||||
use bp_runtime::Chain;
|
||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||
Parameter, RuntimeDebug,
|
||||
@@ -193,75 +193,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.
|
||||
pub const MILLAU_FEE_MULTIPLIER_PARAMETER_NAME: &str = "MillauFeeMultiplier";
|
||||
|
||||
/// Name of the `RialtoParachainFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD: &str =
|
||||
"RialtoParachainFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToRialtoParachainOutboundLaneApi::estimate_message_delivery_and_dispatch_fee`
|
||||
/// runtime method.
|
||||
pub const TO_RIALTO_PARACHAIN_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToRialtoParachainOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToRialtoParachainOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
||||
"ToRialtoParachainOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromRialtoParachainInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_RIALTO_PARACHAIN_MESSAGE_DETAILS_METHOD: &str =
|
||||
"FromRialtoParachainInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized RialtoParachain headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
pub trait RialtoParachainFinalityApi {
|
||||
/// 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 RialtoParachain chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
pub trait ToRialtoParachainOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to RialtoParachain from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
rialto_parachain_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by RialtoParachain chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from RialtoParachain chain, not the
|
||||
/// RialtoParachain runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromRialtoParachainInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(rialto_parachain);
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use bp_messages::{
|
||||
InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails,
|
||||
};
|
||||
use bp_runtime::Chain;
|
||||
use bp_runtime::{declare_bridge_chain_runtime_apis, Chain};
|
||||
use frame_support::{
|
||||
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, Weight},
|
||||
Parameter, RuntimeDebug,
|
||||
@@ -217,72 +217,4 @@ pub const PARAS_REGISTRAR_PALLET_NAME: &str = "Registrar";
|
||||
/// Name of the parachains pallet in the Rialto runtime.
|
||||
pub const PARAS_PALLET_NAME: &str = "Paras";
|
||||
|
||||
/// Name of the `RialtoFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_RIALTO_HEADER_METHOD: &str = "RialtoFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToRialtoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_RIALTO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToRialtoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToRialtoOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_RIALTO_MESSAGE_DETAILS_METHOD: &str = "ToRialtoOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromRialtoInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_RIALTO_MESSAGE_DETAILS_METHOD: &str = "FromRialtoInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Rialto headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Rialto chain, not the
|
||||
/// Rialto runtime itself.
|
||||
pub trait RialtoFinalityApi {
|
||||
/// 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 Rialto chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Rialto chain, not the
|
||||
/// Rialto runtime itself.
|
||||
pub trait ToRialtoOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Rialto from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
rialto_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Rialto chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Rialto chain, not the
|
||||
/// Rialto runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromRialtoInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(rialto);
|
||||
|
||||
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
paste = "1.0"
|
||||
smallvec = "1.7"
|
||||
|
||||
# Bridge Dependencies
|
||||
|
||||
@@ -29,6 +29,7 @@ use sp_std::prelude::*;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use bp_polkadot_core::*;
|
||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
||||
|
||||
/// Rococo Chain
|
||||
pub type Rococo = PolkadotLike;
|
||||
@@ -74,19 +75,6 @@ pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa";
|
||||
/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages";
|
||||
|
||||
/// Name of the `RococoFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_ROCOCO_HEADER_METHOD: &str = "RococoFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToRococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_ROCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToRococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToRococoOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "ToRococoOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromRococoInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_ROCOCO_MESSAGE_DETAILS_METHOD: &str = "FromRococoInboundLaneApi_message_details";
|
||||
|
||||
/// Existential deposit on Rococo.
|
||||
pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100;
|
||||
|
||||
@@ -99,59 +87,4 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100;
|
||||
/// transactions cheaper.
|
||||
pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000;
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Rococo headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Rococo chain, not the
|
||||
/// Rococo runtime itself.
|
||||
pub trait RococoFinalityApi {
|
||||
/// 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 Rococo chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Rococo chain, not the
|
||||
/// Rococo runtime itself.
|
||||
pub trait ToRococoOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Rococo from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
rococo_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Rococo chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Rococo chain, not the
|
||||
/// Rococo runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromRococoInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(rococo);
|
||||
|
||||
@@ -8,6 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
paste = "1.0"
|
||||
|
||||
# Bridge Dependencies
|
||||
bp-messages = { path = "../messages", default-features = false }
|
||||
|
||||
@@ -27,6 +27,7 @@ use sp_std::prelude::*;
|
||||
pub use bp_polkadot_core::*;
|
||||
// Rococo runtime = Wococo runtime
|
||||
pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION};
|
||||
use bp_runtime::declare_bridge_chain_runtime_apis;
|
||||
|
||||
/// Wococo Chain
|
||||
pub type Wococo = PolkadotLike;
|
||||
@@ -43,72 +44,4 @@ pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa";
|
||||
/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains.
|
||||
pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages";
|
||||
|
||||
/// Name of the `WococoFinalityApi::best_finalized` runtime method.
|
||||
pub const BEST_FINALIZED_WOCOCO_HEADER_METHOD: &str = "WococoFinalityApi_best_finalized";
|
||||
|
||||
/// Name of the `ToWococoOutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const TO_WOCOCO_ESTIMATE_MESSAGE_FEE_METHOD: &str =
|
||||
"ToWococoOutboundLaneApi_estimate_message_delivery_and_dispatch_fee";
|
||||
/// Name of the `ToWococoOutboundLaneApi::message_details` runtime method.
|
||||
pub const TO_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "ToWococoOutboundLaneApi_message_details";
|
||||
|
||||
/// Name of the `FromWococoInboundLaneApi::message_details` runtime method.
|
||||
pub const FROM_WOCOCO_MESSAGE_DETAILS_METHOD: &str = "FromWococoInboundLaneApi_message_details";
|
||||
|
||||
sp_api::decl_runtime_apis! {
|
||||
/// API for querying information about the finalized Wococo headers.
|
||||
///
|
||||
/// This API is implemented by runtimes that are bridging with the Wococo chain, not the
|
||||
/// Wococo runtime itself.
|
||||
pub trait WococoFinalityApi {
|
||||
/// 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 Wococo chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are sending messages to Wococo chain, not the
|
||||
/// Wococo runtime itself.
|
||||
pub trait ToWococoOutboundLaneApi<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to Wococo from this chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be good idea to pay a bit over this price to account
|
||||
/// future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
wococo_to_this_conversion_rate: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by Wococo chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from Wococo chain, not the
|
||||
/// Wococo runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait FromWococoInboundLaneApi<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
declare_bridge_chain_runtime_apis!(wococo);
|
||||
|
||||
@@ -214,3 +214,95 @@ pub type AccountPublicOf<C> = <SignatureOf<C> as Verify>::Signer;
|
||||
|
||||
/// Transaction era used by the chain.
|
||||
pub type TransactionEraOf<C> = crate::TransactionEra<BlockNumberOf<C>, HashOf<C>>;
|
||||
|
||||
/// Convenience macro that declares runtime apis and related constants for a bridge chain.
|
||||
/// This includes:
|
||||
/// - chain-specific bridge runtime APIs:
|
||||
/// - `<ThisChain>FinalityApi`
|
||||
/// - `To<ThisChain>OutboundLaneApi`
|
||||
/// - `From<ThisChain>InboundLaneApi`
|
||||
/// - 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>_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`).
|
||||
#[macro_export]
|
||||
macro_rules! declare_bridge_chain_runtime_apis {
|
||||
($chain: ident) => {
|
||||
paste::item! {
|
||||
/// Name of the `<ThisChain>FinalityApi::best_finalized` runtime method.
|
||||
pub const [<BEST_FINALIZED_ $chain:upper _HEADER_METHOD>]: &str =
|
||||
stringify!([<$chain:camel FinalityApi_best_finalized>]);
|
||||
|
||||
/// Name of the `To<ThisChain>OutboundLaneApi::estimate_message_delivery_and_dispatch_fee` runtime
|
||||
/// method.
|
||||
pub const [<TO_ $chain:upper _ESTIMATE_MESSAGE_FEE_METHOD>]: &str =
|
||||
stringify!([<To $chain:camel OutboundLaneApi_estimate_message_delivery_and_dispatch_fee>]);
|
||||
/// Name of the `To<ThisChain>OutboundLaneApi::message_details` runtime method.
|
||||
pub const [<TO_ $chain:upper _MESSAGE_DETAILS_METHOD>]: &str =
|
||||
stringify!([<To $chain:camel OutboundLaneApi_message_details>]);
|
||||
|
||||
/// Name of the `From<ThisChain>InboundLaneApi::message_details` runtime method.
|
||||
pub const [<FROM_ $chain:upper _MESSAGE_DETAILS_METHOD>]: &str =
|
||||
stringify!([<From $chain:camel InboundLaneApi_message_details>]);
|
||||
|
||||
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.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
||||
/// chain's runtime itself.
|
||||
pub trait [<To $chain:camel OutboundLaneApi>]<OutboundMessageFee: Parameter, OutboundPayload: Parameter> {
|
||||
/// Estimate message delivery and dispatch fee that needs to be paid by the sender on
|
||||
/// this chain.
|
||||
///
|
||||
/// Returns `None` if message is too expensive to be sent to this chain from the bridged chain.
|
||||
///
|
||||
/// Please keep in mind that this method returns the lowest message fee required for message
|
||||
/// to be accepted to the lane. It may be a good idea to pay a bit over this price to account
|
||||
/// for future exchange rate changes and guarantee that relayer would deliver your message
|
||||
/// to the target chain.
|
||||
fn estimate_message_delivery_and_dispatch_fee(
|
||||
lane_id: LaneId,
|
||||
payload: OutboundPayload,
|
||||
[<$chain:lower _to_this_conversion_rate>]: Option<FixedU128>,
|
||||
) -> Option<OutboundMessageFee>;
|
||||
/// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all
|
||||
/// messages in given inclusive range.
|
||||
///
|
||||
/// If some (or all) messages are missing from the storage, they'll also will
|
||||
/// be missing from the resulting vector. The vector is ordered by the nonce.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
begin: MessageNonce,
|
||||
end: MessageNonce,
|
||||
) -> Vec<OutboundMessageDetails<OutboundMessageFee>>;
|
||||
}
|
||||
|
||||
/// Inbound message lane API for messages sent by this chain.
|
||||
///
|
||||
/// This API is implemented by runtimes that are receiving messages from this chain, not by this
|
||||
/// chain's runtime itself.
|
||||
///
|
||||
/// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the
|
||||
/// `messages` vector may (and need to) be read using `To<ThisChain>OutboundLaneApi::message_details`.
|
||||
pub trait [<From $chain:camel InboundLaneApi>]<InboundMessageFee: Parameter> {
|
||||
/// Return details of given inbound messages.
|
||||
fn message_details(
|
||||
lane: LaneId,
|
||||
messages: Vec<(MessagePayload, OutboundMessageDetails<InboundMessageFee>)>,
|
||||
) -> Vec<InboundMessageDetails>;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user