From e018aba2d16941772a8d8c3d9c42f822c9b14d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 22 Sep 2021 12:20:22 +0200 Subject: [PATCH] Rename MessageId -> BridgeMessageId (#1152) --- bridges/bin/millau/runtime/src/lib.rs | 2 +- bridges/bin/rialto/runtime/src/lib.rs | 2 +- bridges/bin/runtime-common/src/messages.rs | 2 +- bridges/modules/dispatch/src/lib.rs | 38 +++++++++---------- .../primitives/message-dispatch/src/lib.rs | 4 +- bridges/primitives/messages/src/lib.rs | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index e395c378125a..3aa42ef8bd2e 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -211,7 +211,7 @@ impl pallet_aura::Config for Runtime { } impl pallet_bridge_dispatch::Config for Runtime { type Event = Event; - type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); + type BridgeMessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; type CallFilter = (); type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall; diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index bdbea8438b11..8e7f3f2e421f 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -291,7 +291,7 @@ impl pallet_bridge_currency_exchange::Config for Runtime impl pallet_bridge_dispatch::Config for Runtime { type Event = Event; - type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); + type BridgeMessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; type CallFilter = (); type EncodedCall = crate::millau_messages::FromMillauEncodedCall; diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index f85cc47ecef0..3286d364c7e5 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -495,7 +495,7 @@ pub mod target { where BalanceOf>: Saturating + FixedPointOperand, ThisDispatchInstance: 'static, - ThisRuntime: pallet_bridge_dispatch::Config + ThisRuntime: pallet_bridge_dispatch::Config + pallet_transaction_payment::Config, ::OnChargeTransaction: pallet_transaction_payment::OnChargeTransaction>>, diff --git a/bridges/modules/dispatch/src/lib.rs b/bridges/modules/dispatch/src/lib.rs index c68f064e9d12..b334d862d857 100644 --- a/bridges/modules/dispatch/src/lib.rs +++ b/bridges/modules/dispatch/src/lib.rs @@ -58,7 +58,7 @@ pub mod pallet { /// Id of the message. Whenever message is passed to the dispatch module, it emits /// event with this id + dispatch result. Could be e.g. (LaneId, MessageNonce) if /// it comes from the messages module. - type MessageId: Parameter; + type BridgeMessageId: Parameter; /// Type of account ID on source chain. type SourceChainAccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default; /// Type of account public key on target chain. @@ -91,7 +91,7 @@ pub mod pallet { type AccountIdConverter: sp_runtime::traits::Convert; } - type MessageIdOf = >::MessageId; + type BridgeMessageIdOf = >::BridgeMessageId; #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] @@ -105,37 +105,37 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - #[pallet::metadata(::AccountId = "AccountId", MessageIdOf = "MessageId")] + #[pallet::metadata(::AccountId = "AccountId", BridgeMessageIdOf = "BridgeMessageId")] pub enum Event, I: 'static = ()> { /// Message has been rejected before reaching dispatch. - MessageRejected(ChainId, MessageIdOf), + MessageRejected(ChainId, BridgeMessageIdOf), /// Message has been rejected by dispatcher because of spec version mismatch. /// Last two arguments are: expected and passed spec version. - MessageVersionSpecMismatch(ChainId, MessageIdOf, SpecVersion, SpecVersion), + MessageVersionSpecMismatch(ChainId, BridgeMessageIdOf, SpecVersion, SpecVersion), /// Message has been rejected by dispatcher because of weight mismatch. /// Last two arguments are: expected and passed call weight. - MessageWeightMismatch(ChainId, MessageIdOf, Weight, Weight), + MessageWeightMismatch(ChainId, BridgeMessageIdOf, Weight, Weight), /// Message signature mismatch. - MessageSignatureMismatch(ChainId, MessageIdOf), + MessageSignatureMismatch(ChainId, BridgeMessageIdOf), /// We have failed to decode Call from the message. - MessageCallDecodeFailed(ChainId, MessageIdOf), + MessageCallDecodeFailed(ChainId, BridgeMessageIdOf), /// The call from the message has been rejected by the call filter. - MessageCallRejected(ChainId, MessageIdOf), + MessageCallRejected(ChainId, BridgeMessageIdOf), /// The origin account has failed to pay fee for dispatching the message. MessageDispatchPaymentFailed( ChainId, - MessageIdOf, + BridgeMessageIdOf, ::AccountId, Weight, ), /// Message has been dispatched with given result. - MessageDispatched(ChainId, MessageIdOf, DispatchResult), + MessageDispatched(ChainId, BridgeMessageIdOf, DispatchResult), /// Phantom member, never used. Needed to handle multiple pallet instances. _Dummy(PhantomData), } } -impl, I: 'static> MessageDispatch for Pallet { +impl, I: 'static> MessageDispatch for Pallet { type Message = MessagePayload; @@ -146,7 +146,7 @@ impl, I: 'static> MessageDispatch for P fn dispatch Result<(), ()>>( source_chain: ChainId, target_chain: ChainId, - id: T::MessageId, + id: T::BridgeMessageId, message: Result, pay_dispatch_fee: P, ) -> MessageDispatchResult { @@ -416,7 +416,7 @@ mod tests { }; type AccountId = u64; - type MessageId = [u8; 4]; + type BridgeMessageId = [u8; 4]; const SOURCE_CHAIN_ID: ChainId = *b"srce"; const TARGET_CHAIN_ID: ChainId = *b"trgt"; @@ -502,7 +502,7 @@ mod tests { impl Config for TestRuntime { type Event = Event; - type MessageId = MessageId; + type BridgeMessageId = BridgeMessageId; type SourceChainAccountId = AccountId; type TargetChainAccountPublic = TestAccountPublic; type TargetChainSignature = TestSignature; @@ -542,7 +542,7 @@ mod tests { fn prepare_message( origin: CallOrigin, call: Call, - ) -> as MessageDispatch::MessageId>>::Message { + ) -> as MessageDispatch::BridgeMessageId>>::Message { MessagePayload { spec_version: TEST_SPEC_VERSION, weight: TEST_WEIGHT, @@ -554,20 +554,20 @@ mod tests { fn prepare_root_message( call: Call, - ) -> as MessageDispatch::MessageId>>::Message { + ) -> as MessageDispatch::BridgeMessageId>>::Message { prepare_message(CallOrigin::SourceRoot, call) } fn prepare_target_message( call: Call, - ) -> as MessageDispatch::MessageId>>::Message { + ) -> as MessageDispatch::BridgeMessageId>>::Message { let origin = CallOrigin::TargetAccount(1, TestAccountPublic(1), TestSignature(1)); prepare_message(origin, call) } fn prepare_source_message( call: Call, - ) -> as MessageDispatch::MessageId>>::Message { + ) -> as MessageDispatch::BridgeMessageId>>::Message { let origin = CallOrigin::SourceAccount(1); prepare_message(origin, call) } diff --git a/bridges/primitives/message-dispatch/src/lib.rs b/bridges/primitives/message-dispatch/src/lib.rs index 65f9fc15dc23..794091c78919 100644 --- a/bridges/primitives/message-dispatch/src/lib.rs +++ b/bridges/primitives/message-dispatch/src/lib.rs @@ -34,7 +34,7 @@ pub type Weight = u64; pub type SpecVersion = u32; /// A generic trait to dispatch arbitrary messages delivered over the bridge. -pub trait MessageDispatch { +pub trait MessageDispatch { /// A type of the message to be dispatched. type Message: codec::Decode; @@ -60,7 +60,7 @@ pub trait MessageDispatch { fn dispatch Result<(), ()>>( source_chain: ChainId, target_chain: ChainId, - id: MessageId, + id: BridgeMessageId, message: Result, pay_dispatch_fee: P, ) -> MessageDispatchResult; diff --git a/bridges/primitives/messages/src/lib.rs b/bridges/primitives/messages/src/lib.rs index 9e1de98a9f6f..f639cea933a0 100644 --- a/bridges/primitives/messages/src/lib.rs +++ b/bridges/primitives/messages/src/lib.rs @@ -75,7 +75,7 @@ pub type LaneId = [u8; 4]; pub type MessageNonce = u64; /// Message id as a tuple. -pub type MessageId = (LaneId, MessageNonce); +pub type BridgeMessageId = (LaneId, MessageNonce); /// Opaque message payload. We only decode this payload when it is dispatched. pub type MessagePayload = Vec;