mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 20:45:40 +00:00
Rename pallet-message-lane into pallet-bridge-messages (#834)
* use runtime:: prefix for message-lane pallet traces * renamed message-lane (module and primitives) folder into messages * replace "message lane" with "messages" where appropriate
This commit is contained in:
committed by
Bastian Köcher
parent
eb7c96ba14
commit
4105575794
@@ -15,10 +15,10 @@ hash-db = { version = "0.15.2", default-features = false }
|
||||
# Bridge dependencies
|
||||
|
||||
bp-message-dispatch = { path = "../../primitives/message-dispatch", default-features = false }
|
||||
bp-message-lane = { path = "../../primitives/message-lane", default-features = false }
|
||||
bp-messages = { path = "../../primitives/messages", default-features = false }
|
||||
bp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
pallet-bridge-call-dispatch = { path = "../../modules/call-dispatch", default-features = false }
|
||||
pallet-message-lane = { path = "../../modules/message-lane", default-features = false }
|
||||
pallet-bridge-messages = { path = "../../modules/messages", default-features = false }
|
||||
pallet-finality-verifier = { path = "../../modules/finality-verifier", default-features = false }
|
||||
|
||||
# Substrate dependencies
|
||||
@@ -34,14 +34,14 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" ,
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-message-dispatch/std",
|
||||
"bp-message-lane/std",
|
||||
"bp-messages/std",
|
||||
"bp-runtime/std",
|
||||
"codec/std",
|
||||
"frame-support/std",
|
||||
"hash-db/std",
|
||||
"pallet-bridge-call-dispatch/std",
|
||||
"pallet-finality-verifier/std",
|
||||
"pallet-message-lane/std",
|
||||
"pallet-bridge-messages/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-state-machine/std",
|
||||
@@ -51,6 +51,6 @@ std = [
|
||||
runtime-benchmarks = [
|
||||
"ed25519-dalek/u64_backend",
|
||||
"pallet-finality-verifier/runtime-benchmarks",
|
||||
"pallet-message-lane/runtime-benchmarks",
|
||||
"pallet-bridge-messages/runtime-benchmarks",
|
||||
"sp-state-machine",
|
||||
]
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
# Helpers for Message Lane Module Integration
|
||||
# Helpers for Messages Module Integration
|
||||
|
||||
The [`messages`](./src/messages.rs) module of this crate contains a bunch of helpers for integrating
|
||||
message lane module into your runtime. Basic prerequisites of these helpers are:
|
||||
messages module into your runtime. Basic prerequisites of these helpers are:
|
||||
- we're going to bridge Substrate-based chain with another Substrate-based chain;
|
||||
- both chains have [message lane module](../../modules/message-lane/README.md), Substrate bridge
|
||||
- both chains have [messages module](../../modules/messages/README.md), Substrate bridge
|
||||
module and the [call dispatch module](../../modules/call-dispatch/README.md);
|
||||
- all message lanes are identical and may be used to transfer the same messages;
|
||||
- the messages sent over the bridge are dispatched using
|
||||
[call dispatch module](../../modules/call-dispatch/README.md);
|
||||
- the messages are `pallet_bridge_call_dispatch::MessagePayload` structures, where `call` field is
|
||||
encoded `Call` of the target chain. This means that the `Call` is opaque to the
|
||||
[message lane module](../../modules/message-lane/README.md) instance at the source chain.
|
||||
[messages module](../../modules/messages/README.md) instance at the source chain.
|
||||
It is pre-encoded by the message submitter;
|
||||
- all proofs in the [message lane module](../../modules/message-lane/README.md) transactions are
|
||||
- all proofs in the [messages module](../../modules/messages/README.md) transactions are
|
||||
based on the storage proofs from the bridged chain: storage proof of the outbound message (value
|
||||
from the `pallet_message_lane::Store::MessagePayload` map), storage proof of the outbound lane
|
||||
state (value from the `pallet_message_lane::Store::OutboundLanes` map) and storage proof of the
|
||||
inbound lane state (value from the `pallet_message_lane::Store::InboundLanes` map);
|
||||
from the `pallet_bridge_messages::Store::MessagePayload` map), storage proof of the outbound lane
|
||||
state (value from the `pallet_bridge_messages::Store::OutboundLanes` map) and storage proof of the
|
||||
inbound lane state (value from the `pallet_bridge_messages::Store::InboundLanes` map);
|
||||
- storage proofs are built at the finalized headers of the corresponding chain. So all message lane
|
||||
transactions with proofs are verifying storage proofs against finalized chain headers from
|
||||
Substrate bridge module.
|
||||
@@ -27,7 +27,7 @@ message lane module into your runtime. Basic prerequisites of these helpers are:
|
||||
|
||||
## Contents
|
||||
- [`MessageBridge` Trait](#messagebridge-trait)
|
||||
- [`ChainWithMessageLanes` Trait ](#chainwithmessagelanes-trait)
|
||||
- [`ChainWithMessages` Trait ](#ChainWithMessages-trait)
|
||||
- [Helpers for the Source Chain](#helpers-for-the-source-chain)
|
||||
- [Helpers for the Target Chain](#helpers-for-the-target-chain)
|
||||
|
||||
@@ -40,41 +40,41 @@ tokens into this chain tokens. The bridge also requires two associated types to
|
||||
|
||||
Worth to say that if you're going to use hardcoded constant (conversion rate) in the
|
||||
`MessageBridge::bridged_balance_to_this_balance` method (or in any other method of
|
||||
`ThisChainWithMessageLanes` or `BridgedChainWithMessageLanes` traits), then you should take a
|
||||
`ThisChainWithMessages` or `BridgedChainWithMessages` traits), then you should take a
|
||||
look at the
|
||||
[message lane parameters functionality](../../modules/message-lane/README.md#Non-Essential-Functionality).
|
||||
[messages parameters functionality](../../modules/messages/README.md#Non-Essential-Functionality).
|
||||
They allow pallet owner to update constants more frequently than runtime upgrade happens.
|
||||
|
||||
## `ChainWithMessageLanes` Trait
|
||||
## `ChainWithMessages` Trait
|
||||
|
||||
The trait is quite simple and can easily be implemented - you just need to specify types used at the
|
||||
corresponding chain. There is single exception, though (it may be changed in the future):
|
||||
|
||||
- `ChainWithMessageLanes::MessageLaneInstance`: this is used to compute runtime storage keys. There
|
||||
may be several instances of message lane pallet, included in the Runtime. Every instance stores
|
||||
- `ChainWithMessages::MessagesInstance`: this is used to compute runtime storage keys. There
|
||||
may be several instances of messages pallet, included in the Runtime. Every instance stores
|
||||
messages and these messages stored under different keys. When we are verifying storage proofs from
|
||||
the bridged chain, we should know which instance we're talking to. This is fine, but there's
|
||||
significant inconvenience with that - this chain runtime must have the same message lane pallet
|
||||
significant inconvenience with that - this chain runtime must have the same messages pallet
|
||||
instance. This does not necessarily mean that we should use the same instance on both chains -
|
||||
this instance may be used to bridge with another chain/instance, or may not be used at all.
|
||||
|
||||
## `ThisChainWithMessageLanes` Trait
|
||||
## `ThisChainWithMessages` Trait
|
||||
|
||||
This trait represents this chain from bridge point of view. Let's review every method of this trait:
|
||||
|
||||
- `ThisChainWithMessageLanes::is_outbound_lane_enabled`: is used to check whether given lane accepts
|
||||
- `ThisChainWithMessages::is_outbound_lane_enabled`: is used to check whether given lane accepts
|
||||
outbound messages.
|
||||
|
||||
- `ThisChainWithMessageLanes::maximal_pending_messages_at_outbound_lane`: you should return maximal
|
||||
- `ThisChainWithMessages::maximal_pending_messages_at_outbound_lane`: you should return maximal
|
||||
number of pending (undelivered) messages from this function. Returning small values would require
|
||||
relayers to operate faster and could make message sending logic more complicated. On the other
|
||||
hand, returning large values could lead to chain state growth.
|
||||
|
||||
- `ThisChainWithMessageLanes::estimate_delivery_confirmation_transaction`: you'll need to return
|
||||
- `ThisChainWithMessages::estimate_delivery_confirmation_transaction`: you'll need to return
|
||||
estimated size and dispatch weight of the delivery confirmation transaction (that happens on
|
||||
this chain) from this function.
|
||||
|
||||
- `ThisChainWithMessageLanes::transaction_payment`: you'll need to return fee that the submitter
|
||||
- `ThisChainWithMessages::transaction_payment`: you'll need to return fee that the submitter
|
||||
must pay for given transaction on this chain. Normally, you would use transaction payment pallet
|
||||
for this. However, if your chain has non-zero fee multiplier set, this would mean that the
|
||||
payment will be computed using current value of this multiplier. But since this transaction
|
||||
@@ -82,11 +82,11 @@ This trait represents this chain from bridge point of view. Let's review every m
|
||||
non-altruistic relayer may choose not to submit this transaction until number of transactions
|
||||
will decrease.
|
||||
|
||||
## `BridgedChainWithMessageLanes` Trait
|
||||
## `BridgedChainWithMessages` Trait
|
||||
|
||||
This trait represents this chain from bridge point of view. Let's review every method of this trait:
|
||||
|
||||
- `BridgedChainWithMessageLanes::maximal_extrinsic_size`: you will need to return the maximal
|
||||
- `BridgedChainWithMessages::maximal_extrinsic_size`: you will need to return the maximal
|
||||
extrinsic size of the target chain from this function.
|
||||
|
||||
- `MessageBridge::message_weight_limits`: you'll need to return a range of
|
||||
@@ -106,7 +106,7 @@ This trait represents this chain from bridge point of view. Let's review every m
|
||||
|
||||
- `MessageBridge::transaction_payment`: you'll need to return fee that the submitter
|
||||
must pay for given transaction on bridged chain. The best case is when you have the same conversion
|
||||
formula on both chains - then you may just reuse the `ThisChainWithMessageLanes::transaction_payment`
|
||||
formula on both chains - then you may just reuse the `ThisChainWithMessages::transaction_payment`
|
||||
implementation. Otherwise, you'll need to hardcode this formula into your runtime.
|
||||
|
||||
## Helpers for the Source Chain
|
||||
@@ -121,7 +121,7 @@ are: `maximal_message_size`, `verify_chain_message`, `verify_messages_delivery_p
|
||||
`pallet_bridge_call_dispatch::MessagePayload`, where `call` field is encoded target chain call. So
|
||||
at this chain we don't see internals of this call - we just know its size.
|
||||
|
||||
`FromThisChainMessageVerifier` is an implementation of `bp_message_lane::LaneMessageVerifier`. It
|
||||
`FromThisChainMessageVerifier` is an implementation of `bp_messages::LaneMessageVerifier`. It
|
||||
has following checks in its `verify_message` method:
|
||||
|
||||
1. it'll verify that the used outbound lane is enabled in our runtime;
|
||||
@@ -167,10 +167,10 @@ The helpers for the target chain reside in the `target` submodule of the
|
||||
|
||||
`FromBridgedChainMessagePayload` corresponds to the `FromThisChainMessagePayload` at the bridged
|
||||
chain. We expect that messages with this payload are stored in the `OutboundMessages` storage map of
|
||||
the [message lane module](../../modules/message-lane/README.md). This map is used to build
|
||||
the [messages module](../../modules/messages/README.md). This map is used to build
|
||||
`FromBridgedChainMessagesProof`. The proof holds the lane id, range of message nonces included in
|
||||
the proof, storage proof of `OutboundMessages` entries and the hash of bridged chain header that has
|
||||
been used to build the proof. Additionally, there's storage proof may contain the proof of outbound
|
||||
lane state. It may be required to prune `relayers` entries at this chain (see
|
||||
[message lane module documentation](../../modules/message-lane/README.md#What-about-other-Constants-in-the-Message-Lane-Module-Configuration-Trait)
|
||||
[messages module documentation](../../modules/messages/README.md#What-about-other-Constants-in-the-Messages-Module-Configuration-Trait)
|
||||
for details). This proof is verified by the `verify_messages_proof` function.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//! of to elements - message lane id and message nonce.
|
||||
|
||||
use bp_message_dispatch::MessageDispatch as _;
|
||||
use bp_message_lane::{
|
||||
use bp_messages::{
|
||||
source_chain::{LaneMessageVerifier, Sender},
|
||||
target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages},
|
||||
InboundLaneData, LaneId, Message, MessageData, MessageKey, MessageNonce, OutboundLaneData,
|
||||
@@ -46,16 +46,16 @@ pub trait MessageBridge {
|
||||
const RELAYER_FEE_PERCENT: u32;
|
||||
|
||||
/// This chain in context of message bridge.
|
||||
type ThisChain: ThisChainWithMessageLanes;
|
||||
type ThisChain: ThisChainWithMessages;
|
||||
/// Bridged chain in context of message bridge.
|
||||
type BridgedChain: BridgedChainWithMessageLanes;
|
||||
type BridgedChain: BridgedChainWithMessages;
|
||||
|
||||
/// Convert Bridged chain balance into This chain balance.
|
||||
fn bridged_balance_to_this_balance(bridged_balance: BalanceOf<BridgedChain<Self>>) -> BalanceOf<ThisChain<Self>>;
|
||||
}
|
||||
|
||||
/// Chain that has `message-lane` and `call-dispatch` modules.
|
||||
pub trait ChainWithMessageLanes {
|
||||
/// Chain that has `pallet-bridge-messages` and `call-dispatch` modules.
|
||||
pub trait ChainWithMessages {
|
||||
/// Hash used in the chain.
|
||||
type Hash: Decode;
|
||||
/// Accound id on the chain.
|
||||
@@ -72,21 +72,21 @@ pub trait ChainWithMessageLanes {
|
||||
/// Type of balances that is used on the chain.
|
||||
type Balance: Encode + Decode + CheckedAdd + CheckedDiv + CheckedMul + PartialOrd + From<u32> + Copy;
|
||||
|
||||
/// Instance of the message-lane pallet.
|
||||
type MessageLaneInstance: Instance;
|
||||
/// Instance of the `pallet-bridge-messages` pallet.
|
||||
type MessagesInstance: Instance;
|
||||
}
|
||||
|
||||
/// Message-lane related transaction parameters estimation.
|
||||
/// Message related transaction parameters estimation.
|
||||
#[derive(RuntimeDebug)]
|
||||
pub struct MessageLaneTransaction<Weight> {
|
||||
pub struct MessageTransaction<Weight> {
|
||||
/// The estimated dispatch weight of the transaction.
|
||||
pub dispatch_weight: Weight,
|
||||
/// The estimated size of the encoded transaction.
|
||||
pub size: u32,
|
||||
}
|
||||
|
||||
/// This chain that has `message-lane` and `call-dispatch` modules.
|
||||
pub trait ThisChainWithMessageLanes: ChainWithMessageLanes {
|
||||
/// This chain that has `pallet-bridge-messages` and `call-dispatch` modules.
|
||||
pub trait ThisChainWithMessages: ChainWithMessages {
|
||||
/// Call type on the chain.
|
||||
type Call: Encode + Decode;
|
||||
|
||||
@@ -99,14 +99,14 @@ pub trait ThisChainWithMessageLanes: ChainWithMessageLanes {
|
||||
fn maximal_pending_messages_at_outbound_lane() -> MessageNonce;
|
||||
|
||||
/// Estimate size and weight of single message delivery confirmation transaction at This chain.
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageLaneTransaction<WeightOf<Self>>;
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageTransaction<WeightOf<Self>>;
|
||||
|
||||
/// Returns minimal transaction fee that must be paid for given transaction at This chain.
|
||||
fn transaction_payment(transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self>;
|
||||
fn transaction_payment(transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self>;
|
||||
}
|
||||
|
||||
/// Bridged chain that has `message-lane` and `call-dispatch` modules.
|
||||
pub trait BridgedChainWithMessageLanes: ChainWithMessageLanes {
|
||||
/// Bridged chain that has `pallet-bridge-messages` and `call-dispatch` modules.
|
||||
pub trait BridgedChainWithMessages: ChainWithMessages {
|
||||
/// Maximal extrinsic size at Bridged chain.
|
||||
fn maximal_extrinsic_size() -> u32;
|
||||
|
||||
@@ -125,23 +125,23 @@ pub trait BridgedChainWithMessageLanes: ChainWithMessageLanes {
|
||||
fn estimate_delivery_transaction(
|
||||
message_payload: &[u8],
|
||||
message_dispatch_weight: WeightOf<Self>,
|
||||
) -> MessageLaneTransaction<WeightOf<Self>>;
|
||||
) -> MessageTransaction<WeightOf<Self>>;
|
||||
|
||||
/// Returns minimal transaction fee that must be paid for given transaction at the Bridged chain.
|
||||
fn transaction_payment(transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self>;
|
||||
fn transaction_payment(transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self>;
|
||||
}
|
||||
|
||||
pub(crate) type ThisChain<B> = <B as MessageBridge>::ThisChain;
|
||||
pub(crate) type BridgedChain<B> = <B as MessageBridge>::BridgedChain;
|
||||
pub(crate) type HashOf<C> = <C as ChainWithMessageLanes>::Hash;
|
||||
pub(crate) type AccountIdOf<C> = <C as ChainWithMessageLanes>::AccountId;
|
||||
pub(crate) type SignerOf<C> = <C as ChainWithMessageLanes>::Signer;
|
||||
pub(crate) type SignatureOf<C> = <C as ChainWithMessageLanes>::Signature;
|
||||
pub(crate) type WeightOf<C> = <C as ChainWithMessageLanes>::Weight;
|
||||
pub(crate) type BalanceOf<C> = <C as ChainWithMessageLanes>::Balance;
|
||||
pub(crate) type MessageLaneInstanceOf<C> = <C as ChainWithMessageLanes>::MessageLaneInstance;
|
||||
pub(crate) type HashOf<C> = <C as ChainWithMessages>::Hash;
|
||||
pub(crate) type AccountIdOf<C> = <C as ChainWithMessages>::AccountId;
|
||||
pub(crate) type SignerOf<C> = <C as ChainWithMessages>::Signer;
|
||||
pub(crate) type SignatureOf<C> = <C as ChainWithMessages>::Signature;
|
||||
pub(crate) type WeightOf<C> = <C as ChainWithMessages>::Weight;
|
||||
pub(crate) type BalanceOf<C> = <C as ChainWithMessages>::Balance;
|
||||
pub(crate) type MessagesInstanceOf<C> = <C as ChainWithMessages>::MessagesInstance;
|
||||
|
||||
pub(crate) type CallOf<C> = <C as ThisChainWithMessageLanes>::Call;
|
||||
pub(crate) type CallOf<C> = <C as ThisChainWithMessages>::Call;
|
||||
|
||||
/// Raw storage proof type (just raw trie nodes).
|
||||
type RawStorageProof = Vec<Vec<u8>>;
|
||||
@@ -157,7 +157,7 @@ pub fn transaction_payment<Balance: AtLeast32BitUnsigned + FixedPointOperand>(
|
||||
per_byte_fee: Balance,
|
||||
multiplier: FixedU128,
|
||||
weight_to_fee: impl Fn(Weight) -> Balance,
|
||||
transaction: MessageLaneTransaction<Weight>,
|
||||
transaction: MessageTransaction<Weight>,
|
||||
) -> Balance {
|
||||
// base fee is charged for every tx
|
||||
let base_fee = weight_to_fee(base_extrinsic_weight);
|
||||
@@ -357,7 +357,7 @@ pub mod source {
|
||||
) -> Result<ParsedMessagesDeliveryProofFromBridgedChain<B>, &'static str>
|
||||
where
|
||||
ThisRuntime: pallet_finality_verifier::Config,
|
||||
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||
ThisRuntime: pallet_bridge_messages::Config<MessagesInstanceOf<BridgedChain<B>>>,
|
||||
HashOf<BridgedChain<B>>:
|
||||
Into<bp_runtime::HashOf<<ThisRuntime as pallet_finality_verifier::Config>::BridgedChain>>,
|
||||
{
|
||||
@@ -372,9 +372,9 @@ pub mod source {
|
||||
|storage| {
|
||||
// Messages delivery proof is just proof of single storage key read => any error
|
||||
// is fatal.
|
||||
let storage_inbound_lane_data_key = pallet_message_lane::storage_keys::inbound_lane_data_key::<
|
||||
let storage_inbound_lane_data_key = pallet_bridge_messages::storage_keys::inbound_lane_data_key::<
|
||||
ThisRuntime,
|
||||
MessageLaneInstanceOf<BridgedChain<B>>,
|
||||
MessagesInstanceOf<BridgedChain<B>>,
|
||||
>(&lane);
|
||||
let raw_inbound_lane_data = storage
|
||||
.read_value(storage_inbound_lane_data_key.0.as_ref())
|
||||
@@ -462,7 +462,7 @@ pub mod target {
|
||||
}
|
||||
|
||||
impl<B: MessageBridge, ThisRuntime, ThisCallDispatchInstance>
|
||||
MessageDispatch<<BridgedChain<B> as ChainWithMessageLanes>::Balance>
|
||||
MessageDispatch<<BridgedChain<B> as ChainWithMessages>::Balance>
|
||||
for FromBridgedChainMessageDispatch<B, ThisRuntime, ThisCallDispatchInstance>
|
||||
where
|
||||
ThisCallDispatchInstance: frame_support::traits::Instance,
|
||||
@@ -511,7 +511,7 @@ pub mod target {
|
||||
) -> Result<ProvedMessages<Message<BalanceOf<BridgedChain<B>>>>, &'static str>
|
||||
where
|
||||
ThisRuntime: pallet_finality_verifier::Config,
|
||||
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||
ThisRuntime: pallet_bridge_messages::Config<MessagesInstanceOf<BridgedChain<B>>>,
|
||||
HashOf<BridgedChain<B>>:
|
||||
Into<bp_runtime::HashOf<<ThisRuntime as pallet_finality_verifier::Config>::BridgedChain>>,
|
||||
{
|
||||
@@ -573,11 +573,11 @@ pub mod target {
|
||||
where
|
||||
H: Hasher,
|
||||
B: MessageBridge,
|
||||
ThisRuntime: pallet_message_lane::Config<MessageLaneInstanceOf<BridgedChain<B>>>,
|
||||
ThisRuntime: pallet_bridge_messages::Config<MessagesInstanceOf<BridgedChain<B>>>,
|
||||
{
|
||||
fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option<Vec<u8>> {
|
||||
let storage_outbound_lane_data_key = pallet_message_lane::storage_keys::outbound_lane_data_key::<
|
||||
MessageLaneInstanceOf<BridgedChain<B>>,
|
||||
let storage_outbound_lane_data_key = pallet_bridge_messages::storage_keys::outbound_lane_data_key::<
|
||||
MessagesInstanceOf<BridgedChain<B>>,
|
||||
>(lane_id);
|
||||
self.storage
|
||||
.read_value(storage_outbound_lane_data_key.0.as_ref())
|
||||
@@ -585,9 +585,9 @@ pub mod target {
|
||||
}
|
||||
|
||||
fn read_raw_message(&self, message_key: &MessageKey) -> Option<Vec<u8>> {
|
||||
let storage_message_key = pallet_message_lane::storage_keys::message_key::<
|
||||
let storage_message_key = pallet_bridge_messages::storage_keys::message_key::<
|
||||
ThisRuntime,
|
||||
MessageLaneInstanceOf<BridgedChain<B>>,
|
||||
MessagesInstanceOf<BridgedChain<B>>,
|
||||
>(&message_key.lane_id, message_key.nonce);
|
||||
self.storage.read_value(storage_message_key.0.as_ref()).ok()?
|
||||
}
|
||||
@@ -808,7 +808,7 @@ mod tests {
|
||||
|
||||
struct ThisChain;
|
||||
|
||||
impl ChainWithMessageLanes for ThisChain {
|
||||
impl ChainWithMessages for ThisChain {
|
||||
type Hash = ();
|
||||
type AccountId = ThisChainAccountId;
|
||||
type Signer = ThisChainSigner;
|
||||
@@ -816,10 +816,10 @@ mod tests {
|
||||
type Weight = frame_support::weights::Weight;
|
||||
type Balance = ThisChainBalance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
type MessagesInstance = pallet_bridge_messages::DefaultInstance;
|
||||
}
|
||||
|
||||
impl ThisChainWithMessageLanes for ThisChain {
|
||||
impl ThisChainWithMessages for ThisChain {
|
||||
type Call = ThisChainCall;
|
||||
|
||||
fn is_outbound_lane_enabled(lane: &LaneId) -> bool {
|
||||
@@ -830,19 +830,19 @@ mod tests {
|
||||
MAXIMAL_PENDING_MESSAGES_AT_TEST_LANE
|
||||
}
|
||||
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageLaneTransaction<WeightOf<Self>> {
|
||||
MessageLaneTransaction {
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageTransaction<WeightOf<Self>> {
|
||||
MessageTransaction {
|
||||
dispatch_weight: DELIVERY_CONFIRMATION_TRANSACTION_WEIGHT,
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn transaction_payment(transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
fn transaction_payment(transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
ThisChainBalance(transaction.dispatch_weight as u32 * THIS_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
||||
}
|
||||
}
|
||||
|
||||
impl BridgedChainWithMessageLanes for ThisChain {
|
||||
impl BridgedChainWithMessages for ThisChain {
|
||||
fn maximal_extrinsic_size() -> u32 {
|
||||
unreachable!()
|
||||
}
|
||||
@@ -854,18 +854,18 @@ mod tests {
|
||||
fn estimate_delivery_transaction(
|
||||
_message_payload: &[u8],
|
||||
_message_dispatch_weight: WeightOf<Self>,
|
||||
) -> MessageLaneTransaction<WeightOf<Self>> {
|
||||
) -> MessageTransaction<WeightOf<Self>> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn transaction_payment(_transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
fn transaction_payment(_transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
struct BridgedChain;
|
||||
|
||||
impl ChainWithMessageLanes for BridgedChain {
|
||||
impl ChainWithMessages for BridgedChain {
|
||||
type Hash = ();
|
||||
type AccountId = BridgedChainAccountId;
|
||||
type Signer = BridgedChainSigner;
|
||||
@@ -873,10 +873,10 @@ mod tests {
|
||||
type Weight = frame_support::weights::Weight;
|
||||
type Balance = BridgedChainBalance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
type MessagesInstance = pallet_bridge_messages::DefaultInstance;
|
||||
}
|
||||
|
||||
impl ThisChainWithMessageLanes for BridgedChain {
|
||||
impl ThisChainWithMessages for BridgedChain {
|
||||
type Call = BridgedChainCall;
|
||||
|
||||
fn is_outbound_lane_enabled(_lane: &LaneId) -> bool {
|
||||
@@ -887,16 +887,16 @@ mod tests {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageLaneTransaction<WeightOf<Self>> {
|
||||
fn estimate_delivery_confirmation_transaction() -> MessageTransaction<WeightOf<Self>> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
fn transaction_payment(_transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
fn transaction_payment(_transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl BridgedChainWithMessageLanes for BridgedChain {
|
||||
impl BridgedChainWithMessages for BridgedChain {
|
||||
fn maximal_extrinsic_size() -> u32 {
|
||||
BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE
|
||||
}
|
||||
@@ -909,14 +909,14 @@ mod tests {
|
||||
fn estimate_delivery_transaction(
|
||||
_message_payload: &[u8],
|
||||
message_dispatch_weight: WeightOf<Self>,
|
||||
) -> MessageLaneTransaction<WeightOf<Self>> {
|
||||
MessageLaneTransaction {
|
||||
) -> MessageTransaction<WeightOf<Self>> {
|
||||
MessageTransaction {
|
||||
dispatch_weight: DELIVERY_TRANSACTION_WEIGHT + message_dispatch_weight,
|
||||
size: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn transaction_payment(transaction: MessageLaneTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
fn transaction_payment(transaction: MessageTransaction<WeightOf<Self>>) -> BalanceOf<Self> {
|
||||
BridgedChainBalance(transaction.dispatch_weight as u32 * BRIDGED_CHAIN_WEIGHT_TO_BALANCE_RATE as u32)
|
||||
}
|
||||
}
|
||||
@@ -1415,7 +1415,7 @@ mod tests {
|
||||
10,
|
||||
FixedU128::zero(),
|
||||
|weight| weight,
|
||||
MessageLaneTransaction {
|
||||
MessageTransaction {
|
||||
size: 50,
|
||||
dispatch_weight: 777
|
||||
},
|
||||
@@ -1432,7 +1432,7 @@ mod tests {
|
||||
10,
|
||||
FixedU128::one(),
|
||||
|weight| weight,
|
||||
MessageLaneTransaction {
|
||||
MessageTransaction {
|
||||
size: 50,
|
||||
dispatch_weight: 777
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
//! Everything required to run benchmarks of message-lanes, based on
|
||||
//! Everything required to run benchmarks of messages module, based on
|
||||
//! `bridge_runtime_common::messages` implementation.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
@@ -24,11 +24,11 @@ use crate::messages::{
|
||||
BridgedChain, HashOf, MessageBridge, ThisChain,
|
||||
};
|
||||
|
||||
use bp_message_lane::{LaneId, MessageData, MessageKey, MessagePayload};
|
||||
use bp_messages::{LaneId, MessageData, MessageKey, MessagePayload};
|
||||
use codec::Encode;
|
||||
use ed25519_dalek::{PublicKey, SecretKey, Signer, KEYPAIR_LENGTH, SECRET_KEY_LENGTH};
|
||||
use frame_support::weights::Weight;
|
||||
use pallet_message_lane::benchmarking::{MessageDeliveryProofParams, MessageProofParams, ProofSize};
|
||||
use pallet_bridge_messages::benchmarking::{MessageDeliveryProofParams, MessageProofParams, ProofSize};
|
||||
use sp_core::Hasher;
|
||||
use sp_runtime::traits::Header;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
Reference in New Issue
Block a user