mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Move storage keys computation to the message-lane pallet (#478)
* compute required storage keys in the message-lane pallet * Update modules/message-lane/src/lib.rs Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
2d7eacf6e2
commit
804ef55146
@@ -21,34 +21,37 @@ use crate::Runtime;
|
||||
use bp_message_lane::{
|
||||
source_chain::TargetHeaderChain,
|
||||
target_chain::{ProvedMessages, SourceHeaderChain},
|
||||
InboundLaneData, LaneId, Message, MessageKey, MessageNonce,
|
||||
InboundLaneData, LaneId, Message, MessageNonce,
|
||||
};
|
||||
use bp_runtime::InstanceId;
|
||||
use bridge_runtime_common::messages::{self, MessageBridge};
|
||||
use bridge_runtime_common::messages::{self, ChainWithMessageLanes, MessageBridge};
|
||||
use frame_support::{
|
||||
storage::generator::StorageMap,
|
||||
weights::{Weight, WeightToFeePolynomial},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use pallet_message_lane::{DefaultInstance, InboundLanes, OutboundLanes, OutboundMessages};
|
||||
use sp_core::storage::StorageKey;
|
||||
use sp_trie::StorageProof;
|
||||
|
||||
/// Storage key of the Millau -> Rialto message in the runtime storage.
|
||||
pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey {
|
||||
let message_key = MessageKey { lane_id: *lane, nonce };
|
||||
let raw_storage_key = OutboundMessages::<Runtime, DefaultInstance>::storage_map_final_key(message_key);
|
||||
StorageKey(raw_storage_key)
|
||||
pallet_message_lane::storage_keys::message_key::<Runtime, <Millau as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane, nonce,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Millau -> Rialto message lane state in the runtime storage.
|
||||
pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
StorageKey(OutboundLanes::<DefaultInstance>::storage_map_final_key(*lane))
|
||||
pallet_message_lane::storage_keys::outbound_lane_data_key::<<Millau as ChainWithMessageLanes>::MessageLaneInstance>(
|
||||
lane,
|
||||
)
|
||||
}
|
||||
|
||||
/// Storage key of the Rialto -> Millau message lane state in the runtime storage.
|
||||
pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey {
|
||||
StorageKey(InboundLanes::<Runtime, DefaultInstance>::storage_map_final_key(*lane))
|
||||
pallet_message_lane::storage_keys::inbound_lane_data_key::<
|
||||
Runtime,
|
||||
<Millau as ChainWithMessageLanes>::MessageLaneInstance,
|
||||
>(lane)
|
||||
}
|
||||
|
||||
/// Message payload for Millau -> Rialto messages.
|
||||
@@ -116,12 +119,15 @@ impl MessageBridge for WithRialtoMessageBridge {
|
||||
pub struct Millau;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Millau {
|
||||
type Hash = bp_millau::Hash;
|
||||
type AccountId = bp_millau::AccountId;
|
||||
type Signer = bp_millau::AccountSigner;
|
||||
type Signature = bp_millau::Signature;
|
||||
type Call = crate::Call;
|
||||
type Weight = Weight;
|
||||
type Balance = bp_millau::Balance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
}
|
||||
|
||||
/// Rialto chain from message lane point of view.
|
||||
@@ -129,12 +135,15 @@ impl messages::ChainWithMessageLanes for Millau {
|
||||
pub struct Rialto;
|
||||
|
||||
impl messages::ChainWithMessageLanes for Rialto {
|
||||
type Hash = bp_rialto::Hash;
|
||||
type AccountId = bp_rialto::AccountId;
|
||||
type Signer = bp_rialto::AccountSigner;
|
||||
type Signature = bp_rialto::Signature;
|
||||
type Call = (); // unknown to us
|
||||
type Weight = Weight;
|
||||
type Balance = bp_rialto::Balance;
|
||||
|
||||
type MessageLaneInstance = pallet_message_lane::DefaultInstance;
|
||||
}
|
||||
|
||||
impl TargetHeaderChain<ToRialtoMessagePayload, bp_rialto::AccountId> for Rialto {
|
||||
|
||||
Reference in New Issue
Block a user