From 4105575794d8002fa183634df611af869cafa1da Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Mon, 22 Mar 2021 19:28:31 +0300 Subject: [PATCH] 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 --- bridges/README.md | 2 +- bridges/bin/millau/node/Cargo.toml | 6 +- bridges/bin/millau/node/src/chain_spec.rs | 5 +- bridges/bin/millau/node/src/service.rs | 14 +-- bridges/bin/millau/runtime/Cargo.toml | 8 +- bridges/bin/millau/runtime/src/lib.rs | 62 +++++----- .../bin/millau/runtime/src/rialto_messages.rs | 48 ++++---- bridges/bin/rialto/node/Cargo.toml | 6 +- bridges/bin/rialto/node/src/chain_spec.rs | 5 +- bridges/bin/rialto/node/src/service.rs | 14 +-- bridges/bin/rialto/runtime/Cargo.toml | 10 +- bridges/bin/rialto/runtime/src/lib.rs | 110 ++++++++--------- .../bin/rialto/runtime/src/millau_messages.rs | 48 ++++---- bridges/bin/runtime-common/Cargo.toml | 10 +- bridges/bin/runtime-common/README.md | 52 ++++---- bridges/bin/runtime-common/src/messages.rs | 112 +++++++++--------- .../src/messages_benchmarking.rs | 6 +- bridges/docs/high-level-overview.md | 2 +- bridges/modules/call-dispatch/README.md | 4 +- bridges/modules/call-dispatch/src/lib.rs | 2 +- .../{message-lane => messages}/Cargo.toml | 7 +- .../{message-lane => messages}/README.md | 86 +++++++------- .../{message-lane => messages}/rpc/Cargo.toml | 6 +- .../rpc/src/error.rs | 2 +- .../{message-lane => messages}/rpc/src/lib.rs | 20 ++-- .../src/benchmarking.rs | 4 +- .../src/inbound_lane.rs | 2 +- .../src/instant_payments.rs | 8 +- .../{message-lane => messages}/src/lib.rs | 79 +++++++----- .../{message-lane => messages}/src/mock.rs | 20 ++-- .../src/outbound_lane.rs | 2 +- .../{message-lane => messages}/src/weights.rs | 10 +- .../src/weights_ext.rs | 2 +- bridges/primitives/chains/kusama/Cargo.toml | 4 +- bridges/primitives/chains/kusama/src/lib.rs | 2 +- bridges/primitives/chains/millau/Cargo.toml | 4 +- bridges/primitives/chains/millau/src/lib.rs | 10 +- bridges/primitives/chains/polkadot/Cargo.toml | 4 +- bridges/primitives/chains/polkadot/src/lib.rs | 2 +- bridges/primitives/chains/rialto/Cargo.toml | 4 +- bridges/primitives/chains/rialto/src/lib.rs | 10 +- bridges/primitives/chains/rococo/Cargo.toml | 4 +- bridges/primitives/chains/rococo/src/lib.rs | 2 +- bridges/primitives/chains/westend/Cargo.toml | 4 +- bridges/primitives/chains/westend/src/lib.rs | 2 +- .../{message-lane => messages}/Cargo.toml | 4 +- .../{message-lane => messages}/src/lib.rs | 6 +- .../src/source_chain.rs | 2 +- .../src/target_chain.rs | 2 +- bridges/primitives/polkadot-core/Cargo.toml | 4 +- bridges/primitives/polkadot-core/src/lib.rs | 2 +- bridges/primitives/runtime/src/lib.rs | 7 +- bridges/relays/clients/substrate/Cargo.toml | 2 +- .../relays/clients/substrate/src/client.rs | 8 +- bridges/relays/clients/substrate/src/rpc.rs | 8 +- bridges/relays/generic/messages/Cargo.toml | 2 +- bridges/relays/generic/messages/src/lib.rs | 2 +- .../generic/messages/src/message_lane_loop.rs | 4 +- .../messages/src/message_race_delivery.rs | 2 +- .../generic/messages/src/message_race_loop.rs | 2 +- .../messages/src/message_race_receiving.rs | 2 +- .../messages/src/message_race_strategy.rs | 2 +- .../relays/generic/messages/src/metrics.rs | 2 +- bridges/relays/substrate/Cargo.toml | 4 +- bridges/relays/substrate/src/cli.rs | 10 +- bridges/relays/substrate/src/messages_lane.rs | 8 +- .../relays/substrate/src/messages_source.rs | 2 +- .../relays/substrate/src/messages_target.rs | 2 +- .../relays/substrate/src/rialto_millau/cli.rs | 12 +- .../millau_messages_to_rialto.rs | 8 +- .../relays/substrate/src/rialto_millau/mod.rs | 20 ++-- .../rialto_messages_to_millau.rs | 8 +- 72 files changed, 492 insertions(+), 471 deletions(-) rename bridges/modules/{message-lane => messages}/Cargo.toml (93%) rename bridges/modules/{message-lane => messages}/README.md (88%) rename bridges/modules/{message-lane => messages}/rpc/Cargo.toml (83%) rename bridges/modules/{message-lane => messages}/rpc/src/error.rs (96%) rename bridges/modules/{message-lane => messages}/rpc/src/lib.rs (90%) rename bridges/modules/{message-lane => messages}/src/benchmarking.rs (99%) rename bridges/modules/{message-lane => messages}/src/inbound_lane.rs (99%) rename bridges/modules/{message-lane => messages}/src/instant_payments.rs (98%) rename bridges/modules/{message-lane => messages}/src/lib.rs (94%) rename bridges/modules/{message-lane => messages}/src/mock.rs (96%) rename bridges/modules/{message-lane => messages}/src/outbound_lane.rs (98%) rename bridges/modules/{message-lane => messages}/src/weights.rs (97%) rename bridges/modules/{message-lane => messages}/src/weights_ext.rs (99%) rename bridges/primitives/{message-lane => messages}/Cargo.toml (91%) rename bridges/primitives/{message-lane => messages}/src/lib.rs (98%) rename bridges/primitives/{message-lane => messages}/src/source_chain.rs (99%) rename bridges/primitives/{message-lane => messages}/src/target_chain.rs (98%) diff --git a/bridges/README.md b/bridges/README.md index c02608a9d6..7258eb6c5d 100644 --- a/bridges/README.md +++ b/bridges/README.md @@ -87,7 +87,7 @@ the `relays` which are used to pass messages between chains. ├── modules // Substrate Runtime Modules (a.k.a Pallets) │ ├── ethereum // Ethereum PoA Header Sync Module │ ├── substrate // Substrate Based Chain Header Sync Module -│ ├── message-lane // Cross Chain Message Passing +│ ├── messages // Cross Chain Message Passing │ └── ... ├── primitives // Code shared between modules, runtimes, and relays │ └── ... diff --git a/bridges/bin/millau/node/Cargo.toml b/bridges/bin/millau/node/Cargo.toml index 4e8606b497..5c09367b36 100644 --- a/bridges/bin/millau/node/Cargo.toml +++ b/bridges/bin/millau/node/Cargo.toml @@ -15,12 +15,12 @@ structopt = "0.3.21" # Bridge dependencies -bp-message-lane = { path = "../../../primitives/message-lane" } +bp-messages = { path = "../../../primitives/messages" } bp-millau= { path = "../../../primitives/chains/millau" } bp-runtime = { path = "../../../primitives/runtime" } millau-runtime = { path = "../runtime" } -pallet-message-lane = { path = "../../../modules/message-lane" } -pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" } +pallet-bridge-messages = { path = "../../../modules/messages" } +pallet-bridge-messages-rpc = { path = "../../../modules/messages/rpc" } # Substrate Dependencies diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs index 8e9aded9f1..ac9a873f4f 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -122,7 +122,10 @@ impl Alternative { get_account_id_from_seed::("Ferdie//stash"), get_account_id_from_seed::("George//stash"), get_account_id_from_seed::("Harry//stash"), - pallet_message_lane::Module::::relayer_fund_account_id(), + pallet_bridge_messages::Module::< + millau_runtime::Runtime, + pallet_bridge_messages::DefaultInstance, + >::relayer_fund_account_id(), derive_account_from_rialto_id(bp_runtime::SourceAccount::Account( get_account_id_from_seed::("Dave"), )), diff --git a/bridges/bin/millau/node/src/service.rs b/bridges/bin/millau/node/src/service.rs index 0729353af3..18c46736dc 100644 --- a/bridges/bin/millau/node/src/service.rs +++ b/bridges/bin/millau/node/src/service.rs @@ -190,17 +190,17 @@ pub fn new_full(mut config: Configuration) -> Result let prometheus_registry = config.prometheus_registry().cloned(); let rpc_extensions_builder = { - use bp_message_lane::{LaneId, MessageNonce}; + use bp_messages::{LaneId, MessageNonce}; use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE}; use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider; use sp_core::storage::StorageKey; // This struct is here to ease update process. - /// Millau runtime from message-lane RPC point of view. - struct MillauMessageLaneKeys; + /// Millau runtime from messages RPC point of view. + struct MillauMessagesKeys; - impl pallet_message_lane_rpc::Runtime for MillauMessageLaneKeys { + impl pallet_bridge_messages_rpc::Runtime for MillauMessagesKeys { fn message_key(&self, instance: &InstanceId, lane: &LaneId, nonce: MessageNonce) -> Option { match *instance { RIALTO_BRIDGE_INSTANCE => Some(millau_runtime::rialto_messages::message_key(lane, nonce)), @@ -223,7 +223,7 @@ pub fn new_full(mut config: Configuration) -> Result } } - use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler}; + use pallet_bridge_messages_rpc::{MessagesApi, MessagesRpcHandler}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler}; use sc_rpc::DenyUnsafe; @@ -257,9 +257,9 @@ pub fn new_full(mut config: Configuration) -> Result subscription_executor, finality_proof_provider.clone(), ))); - io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new( + io.extend_with(MessagesApi::to_delegate(MessagesRpcHandler::new( backend.clone(), - Arc::new(MillauMessageLaneKeys), + Arc::new(MillauMessagesKeys), ))); io }) diff --git a/bridges/bin/millau/runtime/Cargo.toml b/bridges/bin/millau/runtime/Cargo.toml index 92193b1153..c95328b0a9 100644 --- a/bridges/bin/millau/runtime/Cargo.toml +++ b/bridges/bin/millau/runtime/Cargo.toml @@ -15,7 +15,7 @@ serde = { version = "1.0.124", optional = true, features = ["derive"] } # Bridge dependencies bp-header-chain = { path = "../../../primitives/header-chain", default-features = false } -bp-message-lane = { path = "../../../primitives/message-lane", default-features = false } +bp-messages = { path = "../../../primitives/messages", default-features = false } bp-millau = { path = "../../../primitives/chains/millau", default-features = false } bp-rialto = { path = "../../../primitives/chains/rialto", default-features = false } bp-runtime = { path = "../../../primitives/runtime", default-features = false } @@ -23,7 +23,7 @@ bp-westend = { path = "../../../primitives/chains/westend", default-features = f bridge-runtime-common = { path = "../../runtime-common", default-features = false } pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default-features = false } pallet-finality-verifier = { path = "../../../modules/finality-verifier", default-features = false } -pallet-message-lane = { path = "../../../modules/message-lane", default-features = false } +pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false } pallet-substrate-bridge = { path = "../../../modules/substrate", default-features = false } @@ -63,7 +63,7 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2. default = ["std"] std = [ "bp-header-chain/std", - "bp-message-lane/std", + "bp-messages/std", "bp-millau/std", "bp-rialto/std", "bp-runtime/std", @@ -79,7 +79,7 @@ std = [ "pallet-bridge-call-dispatch/std", "pallet-finality-verifier/std", "pallet-grandpa/std", - "pallet-message-lane/std", + "pallet-bridge-messages/std", "pallet-randomness-collective-flip/std", "pallet-shift-session-manager/std", "pallet-session/std", diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index 87d5ab8714..0be3642dec 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -62,9 +62,9 @@ pub use frame_support::{ pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; +pub use pallet_bridge_messages::Call as MessagesCall; pub use pallet_finality_verifier::Call as FinalityBridgeRialtoCall; pub use pallet_finality_verifier::Call as FinalityBridgeWestendCall; -pub use pallet_message_lane::Call as MessageLaneCall; pub use pallet_substrate_bridge::Call as BridgeRialtoCall; pub use pallet_sudo::Call as SudoCall; pub use pallet_timestamp::Call as TimestampCall; @@ -209,7 +209,7 @@ impl pallet_aura::Config for Runtime { } impl pallet_bridge_call_dispatch::Config for Runtime { type Event = Event; - type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce); + type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; type CallFilter = (); type EncodedCall = crate::rialto_messages::FromRialtoEncodedCall; @@ -328,10 +328,10 @@ impl pallet_finality_verifier::Config for Runti impl pallet_shift_session_manager::Config for Runtime {} parameter_types! { - pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8; - pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_message_lane::MessageNonce = + pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8; + pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE; - pub const MaxUnconfirmedMessagesAtInboundLane: bp_message_lane::MessageNonce = + pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = bp_millau::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE; // `IdentityFee` is used by Millau => we may use weight directly pub const GetDeliveryConfirmationTransactionFee: Balance = @@ -339,11 +339,11 @@ parameter_types! { pub const RootAccountForPayments: Option = None; } -impl pallet_message_lane::Config for Runtime { +impl pallet_bridge_messages::Config for Runtime { type Event = Event; // TODO: https://github.com/paritytech/parity-bridges-common/issues/390 - type WeightInfo = pallet_message_lane::weights::RialtoWeight; - type Parameter = rialto_messages::MillauToRialtoMessageLaneParameter; + type WeightInfo = pallet_bridge_messages::weights::RialtoWeight; + type Parameter = rialto_messages::MillauToRialtoMessagesParameter; type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce; type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; @@ -359,7 +359,7 @@ impl pallet_message_lane::Config for Runtime { type TargetHeaderChain = crate::rialto_messages::Rialto; type LaneMessageVerifier = crate::rialto_messages::ToRialtoMessageVerifier; - type MessageDeliveryAndDispatchPayment = pallet_message_lane::instant_payments::InstantCurrencyPayments< + type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, pallet_balances::Module, GetDeliveryConfirmationTransactionFee, @@ -377,7 +377,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config}, - BridgeRialtoMessageLane: pallet_message_lane::{Module, Call, Storage, Event}, + BridgeRialtoMessages: pallet_bridge_messages::{Module, Call, Storage, Event}, BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event}, BridgeRialtoFinalityVerifier: pallet_finality_verifier::{Module, Call}, BridgeWestendFinalityVerifier: pallet_finality_verifier::::{Module, Call}, @@ -603,7 +603,7 @@ impl_runtime_apis! { impl bp_rialto::ToRialtoOutboundLaneApi for Runtime { fn estimate_message_delivery_and_dispatch_fee( - _lane_id: bp_message_lane::LaneId, + _lane_id: bp_messages::LaneId, payload: ToRialtoMessagePayload, ) -> Option { estimate_message_dispatch_and_delivery_fee::( @@ -613,12 +613,12 @@ impl_runtime_apis! { } fn messages_dispatch_weight( - lane: bp_message_lane::LaneId, - begin: bp_message_lane::MessageNonce, - end: bp_message_lane::MessageNonce, - ) -> Vec<(bp_message_lane::MessageNonce, Weight, u32)> { + lane: bp_messages::LaneId, + begin: bp_messages::MessageNonce, + end: bp_messages::MessageNonce, + ) -> Vec<(bp_messages::MessageNonce, Weight, u32)> { (begin..=end).filter_map(|nonce| { - let encoded_payload = BridgeRialtoMessageLane::outbound_message_payload(lane, nonce)?; + let encoded_payload = BridgeRialtoMessages::outbound_message_payload(lane, nonce)?; let decoded_payload = rialto_messages::ToRialtoMessagePayload::decode( &mut &encoded_payload[..] ).ok()?; @@ -627,26 +627,26 @@ impl_runtime_apis! { .collect() } - fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeRialtoMessageLane::outbound_latest_received_nonce(lane) + fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeRialtoMessages::outbound_latest_received_nonce(lane) } - fn latest_generated_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeRialtoMessageLane::outbound_latest_generated_nonce(lane) + fn latest_generated_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeRialtoMessages::outbound_latest_generated_nonce(lane) } } impl bp_rialto::FromRialtoInboundLaneApi for Runtime { - fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeRialtoMessageLane::inbound_latest_received_nonce(lane) + fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeRialtoMessages::inbound_latest_received_nonce(lane) } - fn latest_confirmed_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeRialtoMessageLane::inbound_latest_confirmed_nonce(lane) + fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeRialtoMessages::inbound_latest_confirmed_nonce(lane) } - fn unrewarded_relayers_state(lane: bp_message_lane::LaneId) -> bp_message_lane::UnrewardedRelayersState { - BridgeRialtoMessageLane::inbound_unrewarded_relayers_state(lane) + fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState { + BridgeRialtoMessages::inbound_unrewarded_relayers_state(lane) } } } @@ -682,9 +682,9 @@ mod tests { #[test] fn ensure_millau_message_lane_weights_are_correct() { // TODO: https://github.com/paritytech/parity-bridges-common/issues/390 - type Weights = pallet_message_lane::weights::RialtoWeight; + type Weights = pallet_bridge_messages::weights::RialtoWeight; - pallet_message_lane::ensure_weights_are_correct::( + pallet_bridge_messages::ensure_weights_are_correct::( bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, @@ -693,19 +693,19 @@ mod tests { let max_incoming_message_proof_size = bp_rialto::EXTRA_STORAGE_PROOF_SIZE.saturating_add( messages::target::maximal_incoming_message_size(bp_millau::max_extrinsic_size()), ); - pallet_message_lane::ensure_able_to_receive_message::( + pallet_bridge_messages::ensure_able_to_receive_message::( bp_millau::max_extrinsic_size(), bp_millau::max_extrinsic_weight(), max_incoming_message_proof_size, messages::target::maximal_incoming_message_dispatch_weight(bp_millau::max_extrinsic_weight()), ); - let max_incoming_inbound_lane_data_proof_size = bp_message_lane::InboundLaneData::<()>::encoded_size_hint( + let max_incoming_inbound_lane_data_proof_size = bp_messages::InboundLaneData::<()>::encoded_size_hint( bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _, ) .unwrap_or(u32::MAX); - pallet_message_lane::ensure_able_to_receive_confirmation::( + pallet_bridge_messages::ensure_able_to_receive_confirmation::( bp_millau::max_extrinsic_size(), bp_millau::max_extrinsic_weight(), max_incoming_inbound_lane_data_proof_size, diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index 1d84fc32b8..48908432b6 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -14,17 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Everything required to serve Millau <-> Rialto message lanes. +//! Everything required to serve Millau <-> Rialto messages. use crate::Runtime; -use bp_message_lane::{ +use bp_messages::{ source_chain::TargetHeaderChain, target_chain::{ProvedMessages, SourceHeaderChain}, - InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessageLaneParameter, + InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter, }; use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE}; -use bridge_runtime_common::messages::{self, ChainWithMessageLanes, MessageBridge, MessageLaneTransaction}; +use bridge_runtime_common::messages::{self, ChainWithMessages, MessageBridge, MessageTransaction}; use codec::{Decode, Encode}; use frame_support::{ parameter_types, @@ -42,23 +42,23 @@ parameter_types! { /// Storage key of the Millau -> Rialto message in the runtime storage. pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey { - pallet_message_lane::storage_keys::message_key::::MessageLaneInstance>( + pallet_bridge_messages::storage_keys::message_key::::MessagesInstance>( lane, nonce, ) } /// Storage key of the Millau -> Rialto message lane state in the runtime storage. pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey { - pallet_message_lane::storage_keys::outbound_lane_data_key::<::MessageLaneInstance>( + pallet_bridge_messages::storage_keys::outbound_lane_data_key::<::MessagesInstance>( lane, ) } /// Storage key of the Rialto -> Millau message lane state in the runtime storage. pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey { - pallet_message_lane::storage_keys::inbound_lane_data_key::< + pallet_bridge_messages::storage_keys::inbound_lane_data_key::< Runtime, - ::MessageLaneInstance, + ::MessagesInstance, >(lane) } @@ -109,7 +109,7 @@ impl MessageBridge for WithRialtoMessageBridge { #[derive(RuntimeDebug, Clone, Copy)] pub struct Millau; -impl messages::ChainWithMessageLanes for Millau { +impl messages::ChainWithMessages for Millau { type Hash = bp_millau::Hash; type AccountId = bp_millau::AccountId; type Signer = bp_millau::AccountSigner; @@ -117,10 +117,10 @@ impl messages::ChainWithMessageLanes for Millau { type Weight = Weight; type Balance = bp_millau::Balance; - type MessageLaneInstance = pallet_message_lane::DefaultInstance; + type MessagesInstance = pallet_bridge_messages::DefaultInstance; } -impl messages::ThisChainWithMessageLanes for Millau { +impl messages::ThisChainWithMessages for Millau { type Call = crate::Call; fn is_outbound_lane_enabled(lane: &LaneId) -> bool { @@ -131,12 +131,12 @@ impl messages::ThisChainWithMessageLanes for Millau { MessageNonce::MAX } - fn estimate_delivery_confirmation_transaction() -> MessageLaneTransaction { + fn estimate_delivery_confirmation_transaction() -> MessageTransaction { let inbound_data_size = InboundLaneData::::encoded_size_hint(bp_millau::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, 1) .unwrap_or(u32::MAX); - MessageLaneTransaction { + MessageTransaction { dispatch_weight: bp_millau::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, size: inbound_data_size .saturating_add(bp_rialto::EXTRA_STORAGE_PROOF_SIZE) @@ -144,7 +144,7 @@ impl messages::ThisChainWithMessageLanes for Millau { } } - fn transaction_payment(transaction: MessageLaneTransaction) -> bp_millau::Balance { + fn transaction_payment(transaction: MessageTransaction) -> bp_millau::Balance { // in our testnets, both per-byte fee and weight-to-fee are 1:1 messages::transaction_payment( bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic, @@ -160,7 +160,7 @@ impl messages::ThisChainWithMessageLanes for Millau { #[derive(RuntimeDebug, Clone, Copy)] pub struct Rialto; -impl messages::ChainWithMessageLanes for Rialto { +impl messages::ChainWithMessages for Rialto { type Hash = bp_rialto::Hash; type AccountId = bp_rialto::AccountId; type Signer = bp_rialto::AccountSigner; @@ -168,10 +168,10 @@ impl messages::ChainWithMessageLanes for Rialto { type Weight = Weight; type Balance = bp_rialto::Balance; - type MessageLaneInstance = pallet_message_lane::DefaultInstance; + type MessagesInstance = pallet_bridge_messages::DefaultInstance; } -impl messages::BridgedChainWithMessageLanes for Rialto { +impl messages::BridgedChainWithMessages for Rialto { fn maximal_extrinsic_size() -> u32 { bp_rialto::max_extrinsic_size() } @@ -191,12 +191,12 @@ impl messages::BridgedChainWithMessageLanes for Rialto { fn estimate_delivery_transaction( message_payload: &[u8], message_dispatch_weight: Weight, - ) -> MessageLaneTransaction { + ) -> MessageTransaction { let message_payload_len = u32::try_from(message_payload.len()).unwrap_or(u32::MAX); let extra_bytes_in_payload = Weight::from(message_payload_len) - .saturating_sub(pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); + .saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); - MessageLaneTransaction { + MessageTransaction { dispatch_weight: extra_bytes_in_payload .saturating_mul(bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) .saturating_add(bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT) @@ -207,7 +207,7 @@ impl messages::BridgedChainWithMessageLanes for Rialto { } } - fn transaction_payment(transaction: MessageLaneTransaction) -> bp_rialto::Balance { + fn transaction_payment(transaction: MessageTransaction) -> bp_rialto::Balance { // in our testnets, both per-byte fee and weight-to-fee are 1:1 messages::transaction_payment( bp_rialto::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic, @@ -257,15 +257,15 @@ impl SourceHeaderChain for Rialto { /// Millau -> Rialto message lane pallet parameters. #[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)] -pub enum MillauToRialtoMessageLaneParameter { +pub enum MillauToRialtoMessagesParameter { /// The conversion formula we use is: `MillauTokens = RialtoTokens * conversion_rate`. RialtoToMillauConversionRate(FixedU128), } -impl MessageLaneParameter for MillauToRialtoMessageLaneParameter { +impl MessagesParameter for MillauToRialtoMessagesParameter { fn save(&self) { match *self { - MillauToRialtoMessageLaneParameter::RialtoToMillauConversionRate(ref conversion_rate) => { + MillauToRialtoMessagesParameter::RialtoToMillauConversionRate(ref conversion_rate) => { RialtoToMillauConversionRate::set(conversion_rate) } } diff --git a/bridges/bin/rialto/node/Cargo.toml b/bridges/bin/rialto/node/Cargo.toml index d287b0c3c9..a3bbd8c018 100644 --- a/bridges/bin/rialto/node/Cargo.toml +++ b/bridges/bin/rialto/node/Cargo.toml @@ -15,11 +15,11 @@ structopt = "0.3.21" # Bridge dependencies -bp-message-lane = { path = "../../../primitives/message-lane" } +bp-messages = { path = "../../../primitives/messages" } bp-runtime = { path = "../../../primitives/runtime" } bp-rialto = { path = "../../../primitives/chains/rialto" } -pallet-message-lane = { path = "../../../modules/message-lane" } -pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" } +pallet-bridge-messages = { path = "../../../modules/messages" } +pallet-bridge-messages-rpc = { path = "../../../modules/messages/rpc" } rialto-runtime = { path = "../runtime" } # Substrate Dependencies diff --git a/bridges/bin/rialto/node/src/chain_spec.rs b/bridges/bin/rialto/node/src/chain_spec.rs index 00a73cd445..55a2abbd08 100644 --- a/bridges/bin/rialto/node/src/chain_spec.rs +++ b/bridges/bin/rialto/node/src/chain_spec.rs @@ -122,7 +122,10 @@ impl Alternative { get_account_id_from_seed::("Ferdie//stash"), get_account_id_from_seed::("George//stash"), get_account_id_from_seed::("Harry//stash"), - pallet_message_lane::Module::::relayer_fund_account_id(), + pallet_bridge_messages::Module::< + rialto_runtime::Runtime, + pallet_bridge_messages::DefaultInstance, + >::relayer_fund_account_id(), derive_account_from_millau_id(bp_runtime::SourceAccount::Account( get_account_id_from_seed::("Dave"), )), diff --git a/bridges/bin/rialto/node/src/service.rs b/bridges/bin/rialto/node/src/service.rs index 5c5ff92e88..7f3958997d 100644 --- a/bridges/bin/rialto/node/src/service.rs +++ b/bridges/bin/rialto/node/src/service.rs @@ -190,17 +190,17 @@ pub fn new_full(mut config: Configuration) -> Result let prometheus_registry = config.prometheus_registry().cloned(); let rpc_extensions_builder = { - use bp_message_lane::{LaneId, MessageNonce}; + use bp_messages::{LaneId, MessageNonce}; use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE}; use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider; use sp_core::storage::StorageKey; // This struct is here to ease update process. - /// Rialto runtime from message-lane RPC point of view. - struct RialtoMessageLaneKeys; + /// Rialto runtime from messages RPC point of view. + struct RialtoMessagesKeys; - impl pallet_message_lane_rpc::Runtime for RialtoMessageLaneKeys { + impl pallet_bridge_messages_rpc::Runtime for RialtoMessagesKeys { fn message_key(&self, instance: &InstanceId, lane: &LaneId, nonce: MessageNonce) -> Option { match *instance { MILLAU_BRIDGE_INSTANCE => Some(rialto_runtime::millau_messages::message_key(lane, nonce)), @@ -223,7 +223,7 @@ pub fn new_full(mut config: Configuration) -> Result } } - use pallet_message_lane_rpc::{MessageLaneApi, MessageLaneRpcHandler}; + use pallet_bridge_messages_rpc::{MessagesApi, MessagesRpcHandler}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use sc_finality_grandpa_rpc::{GrandpaApi, GrandpaRpcHandler}; use sc_rpc::DenyUnsafe; @@ -257,9 +257,9 @@ pub fn new_full(mut config: Configuration) -> Result subscription_executor, finality_proof_provider.clone(), ))); - io.extend_with(MessageLaneApi::to_delegate(MessageLaneRpcHandler::new( + io.extend_with(MessagesApi::to_delegate(MessagesRpcHandler::new( backend.clone(), - Arc::new(RialtoMessageLaneKeys), + Arc::new(RialtoMessagesKeys), ))); io diff --git a/bridges/bin/rialto/runtime/Cargo.toml b/bridges/bin/rialto/runtime/Cargo.toml index bb4740071e..536c90bce1 100644 --- a/bridges/bin/rialto/runtime/Cargo.toml +++ b/bridges/bin/rialto/runtime/Cargo.toml @@ -20,7 +20,7 @@ bp-currency-exchange = { path = "../../../primitives/currency-exchange", default bp-eth-poa = { path = "../../../primitives/ethereum-poa", default-features = false } bp-header-chain = { path = "../../../primitives/header-chain", default-features = false } 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-millau = { path = "../../../primitives/chains/millau", default-features = false } bp-rialto = { path = "../../../primitives/chains/rialto", default-features = false } bp-runtime = { path = "../../../primitives/runtime", default-features = false } @@ -30,7 +30,7 @@ pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default pallet-bridge-currency-exchange = { path = "../../../modules/currency-exchange", default-features = false } pallet-finality-verifier = { path = "../../../modules/finality-verifier", default-features = false } pallet-substrate-bridge = { path = "../../../modules/substrate", default-features = false } -pallet-message-lane = { path = "../../../modules/message-lane", default-features = false } +pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false } # Substrate Dependencies @@ -78,7 +78,7 @@ std = [ "bp-eth-poa/std", "bp-header-chain/std", "bp-message-dispatch/std", - "bp-message-lane/std", + "bp-messages/std", "bp-millau/std", "bp-rialto/std", "bp-runtime/std", @@ -97,7 +97,7 @@ std = [ "pallet-bridge-currency-exchange/std", "pallet-finality-verifier/std", "pallet-grandpa/std", - "pallet-message-lane/std", + "pallet-bridge-messages/std", "pallet-randomness-collective-flip/std", "pallet-shift-session-manager/std", "pallet-substrate-bridge/std", @@ -129,6 +129,6 @@ runtime-benchmarks = [ "libsecp256k1", "pallet-bridge-currency-exchange/runtime-benchmarks", "pallet-bridge-eth-poa/runtime-benchmarks", - "pallet-message-lane/runtime-benchmarks", + "pallet-bridge-messages/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 0674965da5..4aa8126900 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -70,8 +70,8 @@ pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_bridge_currency_exchange::Call as BridgeCurrencyExchangeCall; pub use pallet_bridge_eth_poa::Call as BridgeEthPoACall; +pub use pallet_bridge_messages::Call as MessagesCall; pub use pallet_finality_verifier::Call as FinalityBridgeMillauCall; -pub use pallet_message_lane::Call as MessageLaneCall; pub use pallet_substrate_bridge::Call as BridgeMillauCall; pub use pallet_sudo::Call as SudoCall; pub use pallet_timestamp::Call as TimestampCall; @@ -259,7 +259,7 @@ impl pallet_bridge_currency_exchange::Config for Runtime impl pallet_bridge_call_dispatch::Config for Runtime { type Event = Event; - type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce); + type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; type CallFilter = (); type EncodedCall = crate::millau_messages::FromMillauEncodedCall; @@ -427,10 +427,10 @@ impl pallet_finality_verifier::Config for Runtime { impl pallet_shift_session_manager::Config for Runtime {} parameter_types! { - pub const MaxMessagesToPruneAtOnce: bp_message_lane::MessageNonce = 8; - pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_message_lane::MessageNonce = + pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8; + pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE; - pub const MaxUnconfirmedMessagesAtInboundLane: bp_message_lane::MessageNonce = + pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = bp_rialto::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE; // `IdentityFee` is used by Rialto => we may use weight directly pub const GetDeliveryConfirmationTransactionFee: Balance = @@ -438,11 +438,11 @@ parameter_types! { pub const RootAccountForPayments: Option = None; } -pub(crate) type WithMillauMessageLaneInstance = pallet_message_lane::DefaultInstance; -impl pallet_message_lane::Config for Runtime { +pub(crate) type WithMillauMessagesInstance = pallet_bridge_messages::DefaultInstance; +impl pallet_bridge_messages::Config for Runtime { type Event = Event; - type WeightInfo = pallet_message_lane::weights::RialtoWeight; - type Parameter = millau_messages::RialtoToMillauMessageLaneParameter; + type WeightInfo = pallet_bridge_messages::weights::RialtoWeight; + type Parameter = millau_messages::RialtoToMillauMessagesParameter; type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce; type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; @@ -458,7 +458,7 @@ impl pallet_message_lane::Config for Runtime { type TargetHeaderChain = crate::millau_messages::Millau; type LaneMessageVerifier = crate::millau_messages::ToMillauMessageVerifier; - type MessageDeliveryAndDispatchPayment = pallet_message_lane::instant_payments::InstantCurrencyPayments< + type MessageDeliveryAndDispatchPayment = pallet_bridge_messages::instant_payments::InstantCurrencyPayments< Runtime, pallet_balances::Module, GetDeliveryConfirmationTransactionFee, @@ -482,7 +482,7 @@ construct_runtime!( BridgeMillau: pallet_substrate_bridge::{Module, Call, Storage, Config}, BridgeFinalityVerifier: pallet_finality_verifier::{Module, Call}, BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event}, - BridgeMillauMessageLane: pallet_message_lane::{Module, Call, Storage, Event}, + BridgeMillauMessages: pallet_bridge_messages::{Module, Call, Storage, Event}, System: frame_system::{Module, Call, Config, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, @@ -746,7 +746,7 @@ impl_runtime_apis! { impl bp_millau::ToMillauOutboundLaneApi for Runtime { fn estimate_message_delivery_and_dispatch_fee( - _lane_id: bp_message_lane::LaneId, + _lane_id: bp_messages::LaneId, payload: ToMillauMessagePayload, ) -> Option { estimate_message_dispatch_and_delivery_fee::( @@ -756,12 +756,12 @@ impl_runtime_apis! { } fn messages_dispatch_weight( - lane: bp_message_lane::LaneId, - begin: bp_message_lane::MessageNonce, - end: bp_message_lane::MessageNonce, - ) -> Vec<(bp_message_lane::MessageNonce, Weight, u32)> { + lane: bp_messages::LaneId, + begin: bp_messages::MessageNonce, + end: bp_messages::MessageNonce, + ) -> Vec<(bp_messages::MessageNonce, Weight, u32)> { (begin..=end).filter_map(|nonce| { - let encoded_payload = BridgeMillauMessageLane::outbound_message_payload(lane, nonce)?; + let encoded_payload = BridgeMillauMessages::outbound_message_payload(lane, nonce)?; let decoded_payload = millau_messages::ToMillauMessagePayload::decode( &mut &encoded_payload[..] ).ok()?; @@ -770,26 +770,26 @@ impl_runtime_apis! { .collect() } - fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeMillauMessageLane::outbound_latest_received_nonce(lane) + fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeMillauMessages::outbound_latest_received_nonce(lane) } - fn latest_generated_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeMillauMessageLane::outbound_latest_generated_nonce(lane) + fn latest_generated_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeMillauMessages::outbound_latest_generated_nonce(lane) } } impl bp_millau::FromMillauInboundLaneApi for Runtime { - fn latest_received_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeMillauMessageLane::inbound_latest_received_nonce(lane) + fn latest_received_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeMillauMessages::inbound_latest_received_nonce(lane) } - fn latest_confirmed_nonce(lane: bp_message_lane::LaneId) -> bp_message_lane::MessageNonce { - BridgeMillauMessageLane::inbound_latest_confirmed_nonce(lane) + fn latest_confirmed_nonce(lane: bp_messages::LaneId) -> bp_messages::MessageNonce { + BridgeMillauMessages::inbound_latest_confirmed_nonce(lane) } - fn unrewarded_relayers_state(lane: bp_message_lane::LaneId) -> bp_message_lane::UnrewardedRelayersState { - BridgeMillauMessageLane::inbound_unrewarded_relayers_state(lane) + fn unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState { + BridgeMillauMessages::inbound_unrewarded_relayers_state(lane) } } @@ -857,16 +857,16 @@ impl_runtime_apis! { use crate::millau_messages::{ToMillauMessagePayload, WithMillauMessageBridge}; use bridge_runtime_common::messages; - use pallet_message_lane::benchmarking::{ - Module as MessageLaneBench, - Config as MessageLaneConfig, - MessageDeliveryProofParams as MessageLaneMessageDeliveryProofParams, - MessageParams as MessageLaneMessageParams, - MessageProofParams as MessageLaneMessageProofParams, - ProofSize as MessageLaneProofSize, + use pallet_bridge_messages::benchmarking::{ + Module as MessagesBench, + Config as MessagesConfig, + MessageDeliveryProofParams, + MessageParams, + MessageProofParams, + ProofSize as MessagesProofSize, }; - impl MessageLaneConfig for Runtime { + impl MessagesConfig for Runtime { fn maximal_message_size() -> u32 { messages::source::maximal_message_size::() } @@ -887,7 +887,7 @@ impl_runtime_apis! { } fn prepare_outbound_message( - params: MessageLaneMessageParams, + params: MessageParams, ) -> (millau_messages::ToMillauMessagePayload, Balance) { let message_payload = vec![0; params.size as usize]; let dispatch_origin = pallet_bridge_call_dispatch::CallOrigin::SourceAccount( @@ -900,25 +900,25 @@ impl_runtime_apis! { origin: dispatch_origin, call: message_payload, }; - (message, pallet_message_lane::benchmarking::MESSAGE_FEE.into()) + (message, pallet_bridge_messages::benchmarking::MESSAGE_FEE.into()) } fn prepare_message_proof( - params: MessageLaneMessageProofParams, + params: MessageProofParams, ) -> (millau_messages::FromMillauMessagesProof, Weight) { use crate::millau_messages::{Millau, WithMillauMessageBridge}; - use bp_message_lane::MessageKey; + use bp_messages::MessageKey; use bridge_runtime_common::{ - messages::ChainWithMessageLanes, + messages::ChainWithMessages, messages_benchmarking::{ed25519_sign, prepare_message_proof}, }; use codec::Encode; use frame_support::weights::GetDispatchInfo; - use pallet_message_lane::storage_keys; + use pallet_bridge_messages::storage_keys; use sp_runtime::traits::Header; let remark = match params.size { - MessageLaneProofSize::Minimal(ref size) => vec![0u8; *size as _], + MessagesProofSize::Minimal(ref size) => vec![0u8; *size as _], _ => vec![], }; let call = Call::System(SystemCall::remark(remark)); @@ -936,12 +936,12 @@ impl_runtime_apis! { let make_millau_message_key = |message_key: MessageKey| storage_keys::message_key::< Runtime, - ::MessageLaneInstance, + ::MessagesInstance, >( &message_key.lane_id, message_key.nonce, ).0; let make_millau_outbound_lane_data_key = |lane_id| storage_keys::outbound_lane_data_key::< - ::MessageLaneInstance, + ::MessagesInstance, >( &lane_id, ).0; @@ -977,20 +977,20 @@ impl_runtime_apis! { } fn prepare_message_delivery_proof( - params: MessageLaneMessageDeliveryProofParams, + params: MessageDeliveryProofParams, ) -> millau_messages::ToMillauMessagesDeliveryProof { use crate::millau_messages::{Millau, WithMillauMessageBridge}; use bridge_runtime_common::{ - messages::ChainWithMessageLanes, + messages::ChainWithMessages, messages_benchmarking::prepare_message_delivery_proof, }; use sp_runtime::traits::Header; prepare_message_delivery_proof::( params, - |lane_id| pallet_message_lane::storage_keys::inbound_lane_data_key::< + |lane_id| pallet_bridge_messages::storage_keys::inbound_lane_data_key::< Runtime, - ::MessageLaneInstance, + ::MessagesInstance, >( &lane_id, ).0, @@ -1015,8 +1015,8 @@ impl_runtime_apis! { add_benchmark!( params, batches, - pallet_message_lane, - MessageLaneBench:: + pallet_bridge_messages, + MessagesBench:: ); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } @@ -1091,9 +1091,9 @@ mod tests { #[test] fn ensure_rialto_message_lane_weights_are_correct() { - type Weights = pallet_message_lane::weights::RialtoWeight; + type Weights = pallet_bridge_messages::weights::RialtoWeight; - pallet_message_lane::ensure_weights_are_correct::( + pallet_bridge_messages::ensure_weights_are_correct::( bp_rialto::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT, bp_rialto::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT, bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, @@ -1102,19 +1102,19 @@ mod tests { let max_incoming_message_proof_size = bp_millau::EXTRA_STORAGE_PROOF_SIZE.saturating_add( messages::target::maximal_incoming_message_size(bp_rialto::max_extrinsic_size()), ); - pallet_message_lane::ensure_able_to_receive_message::( + pallet_bridge_messages::ensure_able_to_receive_message::( bp_rialto::max_extrinsic_size(), bp_rialto::max_extrinsic_weight(), max_incoming_message_proof_size, messages::target::maximal_incoming_message_dispatch_weight(bp_rialto::max_extrinsic_weight()), ); - let max_incoming_inbound_lane_data_proof_size = bp_message_lane::InboundLaneData::<()>::encoded_size_hint( + let max_incoming_inbound_lane_data_proof_size = bp_messages::InboundLaneData::<()>::encoded_size_hint( bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE as _, ) .unwrap_or(u32::MAX); - pallet_message_lane::ensure_able_to_receive_confirmation::( + pallet_bridge_messages::ensure_able_to_receive_confirmation::( bp_rialto::max_extrinsic_size(), bp_rialto::max_extrinsic_weight(), max_incoming_inbound_lane_data_proof_size, diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index d6898ef8db..8b0aaea994 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -14,17 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Everything required to serve Millau <-> Rialto message lanes. +//! Everything required to serve Millau <-> Rialto messages. use crate::Runtime; -use bp_message_lane::{ +use bp_messages::{ source_chain::TargetHeaderChain, target_chain::{ProvedMessages, SourceHeaderChain}, - InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessageLaneParameter, + InboundLaneData, LaneId, Message, MessageNonce, Parameter as MessagesParameter, }; use bp_runtime::{InstanceId, MILLAU_BRIDGE_INSTANCE}; -use bridge_runtime_common::messages::{self, ChainWithMessageLanes, MessageBridge, MessageLaneTransaction}; +use bridge_runtime_common::messages::{self, ChainWithMessages, MessageBridge, MessageTransaction}; use codec::{Decode, Encode}; use frame_support::{ parameter_types, @@ -42,23 +42,23 @@ parameter_types! { /// Storage key of the Rialto -> Millau message in the runtime storage. pub fn message_key(lane: &LaneId, nonce: MessageNonce) -> StorageKey { - pallet_message_lane::storage_keys::message_key::::MessageLaneInstance>( + pallet_bridge_messages::storage_keys::message_key::::MessagesInstance>( lane, nonce, ) } /// Storage key of the Rialto -> Millau message lane state in the runtime storage. pub fn outbound_lane_data_key(lane: &LaneId) -> StorageKey { - pallet_message_lane::storage_keys::outbound_lane_data_key::<::MessageLaneInstance>( + pallet_bridge_messages::storage_keys::outbound_lane_data_key::<::MessagesInstance>( lane, ) } /// Storage key of the Millau -> Rialto message lane state in the runtime storage. pub fn inbound_lane_data_key(lane: &LaneId) -> StorageKey { - pallet_message_lane::storage_keys::inbound_lane_data_key::< + pallet_bridge_messages::storage_keys::inbound_lane_data_key::< Runtime, - ::MessageLaneInstance, + ::MessagesInstance, >(lane) } @@ -109,7 +109,7 @@ impl MessageBridge for WithMillauMessageBridge { #[derive(RuntimeDebug, Clone, Copy)] pub struct Rialto; -impl messages::ChainWithMessageLanes for Rialto { +impl messages::ChainWithMessages for Rialto { type Hash = bp_rialto::Hash; type AccountId = bp_rialto::AccountId; type Signer = bp_rialto::AccountSigner; @@ -117,10 +117,10 @@ impl messages::ChainWithMessageLanes for Rialto { type Weight = Weight; type Balance = bp_rialto::Balance; - type MessageLaneInstance = crate::WithMillauMessageLaneInstance; + type MessagesInstance = crate::WithMillauMessagesInstance; } -impl messages::ThisChainWithMessageLanes for Rialto { +impl messages::ThisChainWithMessages for Rialto { type Call = crate::Call; fn is_outbound_lane_enabled(lane: &LaneId) -> bool { @@ -131,12 +131,12 @@ impl messages::ThisChainWithMessageLanes for Rialto { MessageNonce::MAX } - fn estimate_delivery_confirmation_transaction() -> MessageLaneTransaction { + fn estimate_delivery_confirmation_transaction() -> MessageTransaction { let inbound_data_size = InboundLaneData::::encoded_size_hint(bp_rialto::MAXIMAL_ENCODED_ACCOUNT_ID_SIZE, 1) .unwrap_or(u32::MAX); - MessageLaneTransaction { + MessageTransaction { dispatch_weight: bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT, size: inbound_data_size .saturating_add(bp_millau::EXTRA_STORAGE_PROOF_SIZE) @@ -144,7 +144,7 @@ impl messages::ThisChainWithMessageLanes for Rialto { } } - fn transaction_payment(transaction: MessageLaneTransaction) -> bp_rialto::Balance { + fn transaction_payment(transaction: MessageTransaction) -> bp_rialto::Balance { // in our testnets, both per-byte fee and weight-to-fee are 1:1 messages::transaction_payment( bp_rialto::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic, @@ -160,7 +160,7 @@ impl messages::ThisChainWithMessageLanes for Rialto { #[derive(RuntimeDebug, Clone, Copy)] pub struct Millau; -impl messages::ChainWithMessageLanes for Millau { +impl messages::ChainWithMessages for Millau { type Hash = bp_millau::Hash; type AccountId = bp_millau::AccountId; type Signer = bp_millau::AccountSigner; @@ -168,10 +168,10 @@ impl messages::ChainWithMessageLanes for Millau { type Weight = Weight; type Balance = bp_millau::Balance; - type MessageLaneInstance = pallet_message_lane::DefaultInstance; + type MessagesInstance = pallet_bridge_messages::DefaultInstance; } -impl messages::BridgedChainWithMessageLanes for Millau { +impl messages::BridgedChainWithMessages for Millau { fn maximal_extrinsic_size() -> u32 { bp_millau::max_extrinsic_size() } @@ -191,12 +191,12 @@ impl messages::BridgedChainWithMessageLanes for Millau { fn estimate_delivery_transaction( message_payload: &[u8], message_dispatch_weight: Weight, - ) -> MessageLaneTransaction { + ) -> MessageTransaction { let message_payload_len = u32::try_from(message_payload.len()).unwrap_or(u32::MAX); let extra_bytes_in_payload = Weight::from(message_payload_len) - .saturating_sub(pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); + .saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH.into()); - MessageLaneTransaction { + MessageTransaction { dispatch_weight: extra_bytes_in_payload .saturating_mul(bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT) .saturating_add(bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT) @@ -207,7 +207,7 @@ impl messages::BridgedChainWithMessageLanes for Millau { } } - fn transaction_payment(transaction: MessageLaneTransaction) -> bp_millau::Balance { + fn transaction_payment(transaction: MessageTransaction) -> bp_millau::Balance { // in our testnets, both per-byte fee and weight-to-fee are 1:1 messages::transaction_payment( bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic, @@ -257,15 +257,15 @@ impl SourceHeaderChain for Millau { /// Rialto -> Millau message lane pallet parameters. #[derive(RuntimeDebug, Clone, Encode, Decode, PartialEq, Eq)] -pub enum RialtoToMillauMessageLaneParameter { +pub enum RialtoToMillauMessagesParameter { /// The conversion formula we use is: `RialtoTokens = MillauTokens * conversion_rate`. MillauToRialtoConversionRate(FixedU128), } -impl MessageLaneParameter for RialtoToMillauMessageLaneParameter { +impl MessagesParameter for RialtoToMillauMessagesParameter { fn save(&self) { match *self { - RialtoToMillauMessageLaneParameter::MillauToRialtoConversionRate(ref conversion_rate) => { + RialtoToMillauMessagesParameter::MillauToRialtoConversionRate(ref conversion_rate) => { MillauToRialtoConversionRate::set(conversion_rate) } } diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index dfae0861bb..2bbf942180 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -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", ] diff --git a/bridges/bin/runtime-common/README.md b/bridges/bin/runtime-common/README.md index 8d90bc7a8c..90ebc8976d 100644 --- a/bridges/bin/runtime-common/README.md +++ b/bridges/bin/runtime-common/README.md @@ -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. diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index c69b2073d7..26c087ac69 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -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>) -> BalanceOf>; } -/// 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 + 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 { +pub struct MessageTransaction { /// 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>; + fn estimate_delivery_confirmation_transaction() -> MessageTransaction>; /// Returns minimal transaction fee that must be paid for given transaction at This chain. - fn transaction_payment(transaction: MessageLaneTransaction>) -> BalanceOf; + fn transaction_payment(transaction: MessageTransaction>) -> BalanceOf; } -/// 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, - ) -> MessageLaneTransaction>; + ) -> MessageTransaction>; /// Returns minimal transaction fee that must be paid for given transaction at the Bridged chain. - fn transaction_payment(transaction: MessageLaneTransaction>) -> BalanceOf; + fn transaction_payment(transaction: MessageTransaction>) -> BalanceOf; } pub(crate) type ThisChain = ::ThisChain; pub(crate) type BridgedChain = ::BridgedChain; -pub(crate) type HashOf = ::Hash; -pub(crate) type AccountIdOf = ::AccountId; -pub(crate) type SignerOf = ::Signer; -pub(crate) type SignatureOf = ::Signature; -pub(crate) type WeightOf = ::Weight; -pub(crate) type BalanceOf = ::Balance; -pub(crate) type MessageLaneInstanceOf = ::MessageLaneInstance; +pub(crate) type HashOf = ::Hash; +pub(crate) type AccountIdOf = ::AccountId; +pub(crate) type SignerOf = ::Signer; +pub(crate) type SignatureOf = ::Signature; +pub(crate) type WeightOf = ::Weight; +pub(crate) type BalanceOf = ::Balance; +pub(crate) type MessagesInstanceOf = ::MessagesInstance; -pub(crate) type CallOf = ::Call; +pub(crate) type CallOf = ::Call; /// Raw storage proof type (just raw trie nodes). type RawStorageProof = Vec>; @@ -157,7 +157,7 @@ pub fn transaction_payment( per_byte_fee: Balance, multiplier: FixedU128, weight_to_fee: impl Fn(Weight) -> Balance, - transaction: MessageLaneTransaction, + transaction: MessageTransaction, ) -> 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, &'static str> where ThisRuntime: pallet_finality_verifier::Config, - ThisRuntime: pallet_message_lane::Config>>, + ThisRuntime: pallet_bridge_messages::Config>>, HashOf>: Into::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>, + MessagesInstanceOf>, >(&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 - MessageDispatch< as ChainWithMessageLanes>::Balance> + MessageDispatch< as ChainWithMessages>::Balance> for FromBridgedChainMessageDispatch where ThisCallDispatchInstance: frame_support::traits::Instance, @@ -511,7 +511,7 @@ pub mod target { ) -> Result>>>, &'static str> where ThisRuntime: pallet_finality_verifier::Config, - ThisRuntime: pallet_message_lane::Config>>, + ThisRuntime: pallet_bridge_messages::Config>>, HashOf>: Into::BridgedChain>>, { @@ -573,11 +573,11 @@ pub mod target { where H: Hasher, B: MessageBridge, - ThisRuntime: pallet_message_lane::Config>>, + ThisRuntime: pallet_bridge_messages::Config>>, { fn read_raw_outbound_lane_data(&self, lane_id: &LaneId) -> Option> { - let storage_outbound_lane_data_key = pallet_message_lane::storage_keys::outbound_lane_data_key::< - MessageLaneInstanceOf>, + let storage_outbound_lane_data_key = pallet_bridge_messages::storage_keys::outbound_lane_data_key::< + MessagesInstanceOf>, >(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> { - let storage_message_key = pallet_message_lane::storage_keys::message_key::< + let storage_message_key = pallet_bridge_messages::storage_keys::message_key::< ThisRuntime, - MessageLaneInstanceOf>, + MessagesInstanceOf>, >(&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> { - MessageLaneTransaction { + fn estimate_delivery_confirmation_transaction() -> MessageTransaction> { + MessageTransaction { dispatch_weight: DELIVERY_CONFIRMATION_TRANSACTION_WEIGHT, size: 0, } } - fn transaction_payment(transaction: MessageLaneTransaction>) -> BalanceOf { + fn transaction_payment(transaction: MessageTransaction>) -> BalanceOf { 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, - ) -> MessageLaneTransaction> { + ) -> MessageTransaction> { unreachable!() } - fn transaction_payment(_transaction: MessageLaneTransaction>) -> BalanceOf { + fn transaction_payment(_transaction: MessageTransaction>) -> BalanceOf { 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> { + fn estimate_delivery_confirmation_transaction() -> MessageTransaction> { unreachable!() } - fn transaction_payment(_transaction: MessageLaneTransaction>) -> BalanceOf { + fn transaction_payment(_transaction: MessageTransaction>) -> BalanceOf { 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, - ) -> MessageLaneTransaction> { - MessageLaneTransaction { + ) -> MessageTransaction> { + MessageTransaction { dispatch_weight: DELIVERY_TRANSACTION_WEIGHT + message_dispatch_weight, size: 0, } } - fn transaction_payment(transaction: MessageLaneTransaction>) -> BalanceOf { + fn transaction_payment(transaction: MessageTransaction>) -> BalanceOf { 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 }, diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs index 56b427cb0e..39d3ec9262 100644 --- a/bridges/bin/runtime-common/src/messages_benchmarking.rs +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! 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::*; diff --git a/bridges/docs/high-level-overview.md b/bridges/docs/high-level-overview.md index 763371bbf1..e7dba6c65c 100644 --- a/bridges/docs/high-level-overview.md +++ b/bridges/docs/high-level-overview.md @@ -90,7 +90,7 @@ message dispatch. #### Message Lanes Delivery -The [Message delivery pallet](../modules/message-lane/src/lib.rs) is responsible for queueing up +The [Message delivery pallet](../modules/messages/src/lib.rs) is responsible for queueing up messages and delivering them in order on the target chain. It also dispatches messages, but we will cover that in the next section. diff --git a/bridges/modules/call-dispatch/README.md b/bridges/modules/call-dispatch/README.md index 0351aa9e50..d870193e0e 100644 --- a/bridges/modules/call-dispatch/README.md +++ b/bridges/modules/call-dispatch/README.md @@ -11,7 +11,7 @@ Every message that is being dispatched has three main characteristics: identifier of the bridged chain (like `b"rlto"` for messages coming from `Rialto`), or the identifier of the bridge itself (`b"rimi"` for `Rialto` <-> `Millau` bridge); - `id` is the unique id of the message within the given bridge. For messages coming from the - [message lane module](../message-lane/README.md), it may worth to use a tuple + [messages module](../messages/README.md), it may worth to use a tuple `(LaneId, MessageNonce)` to identify a message; - `message` is the `pallet_bridge_call_dispatch::MessagePayload` structure. The `call` field is set to the (potentially) encoded `Call` of this chain. @@ -52,7 +52,7 @@ When we talk about module in context of bridges, these events are helping in fol 1. when the message submitter has access to the state of both chains and wants to monitor what has happened with his message. Then he could use the message id (that he gets from the - [message lane module events](../message-lane/README.md#General-Information)) to filter events of + [messages module events](../messages/README.md#General-Information)) to filter events of call dispatch module at the target chain and actually see what has happened with his message; 1. when the message submitter only has access to the source chain state (for example, when sender is diff --git a/bridges/modules/call-dispatch/src/lib.rs b/bridges/modules/call-dispatch/src/lib.rs index 3f6bf632a2..9e6fb9e531 100644 --- a/bridges/modules/call-dispatch/src/lib.rs +++ b/bridges/modules/call-dispatch/src/lib.rs @@ -118,7 +118,7 @@ pub trait Config: frame_system::Config { type Event: From> + Into<::Event>; /// 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 message-lane module. + /// it comes from the messages module. type MessageId: Parameter; /// Type of account ID on source chain. type SourceChainAccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default; diff --git a/bridges/modules/message-lane/Cargo.toml b/bridges/modules/messages/Cargo.toml similarity index 93% rename from bridges/modules/message-lane/Cargo.toml rename to bridges/modules/messages/Cargo.toml index d4bced0811..19dc78af72 100644 --- a/bridges/modules/message-lane/Cargo.toml +++ b/bridges/modules/messages/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-message-lane" +name = "pallet-bridge-messages" description = "Module that allows bridged chains to exchange messages using lane concept." version = "0.1.0" authors = ["Parity Technologies "] @@ -14,7 +14,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } # Bridge dependencies -bp-message-lane = { path = "../../primitives/message-lane", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } bp-rialto = { path = "../../primitives/chains/rialto", default-features = false } bp-runtime = { path = "../../primitives/runtime", default-features = false } @@ -28,6 +28,7 @@ sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } [dev-dependencies] +hex = "0.4" hex-literal = "0.3" sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -35,7 +36,7 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "m [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-runtime/std", "bp-rialto/std", "codec/std", diff --git a/bridges/modules/message-lane/README.md b/bridges/modules/messages/README.md similarity index 88% rename from bridges/modules/message-lane/README.md rename to bridges/modules/messages/README.md index a732042bd0..eda5e28a6c 100644 --- a/bridges/modules/message-lane/README.md +++ b/bridges/modules/messages/README.md @@ -1,25 +1,25 @@ -# Message Lane Module +# Messages Module -The message lane module is used to deliver messages from source chain to target chain. Message is +The messages module is used to deliver messages from source chain to target chain. Message is (almost) opaque to the module and the final goal is to hand message to the message dispatch mechanism. ## Contents - [Overview](#overview) - [Message Workflow](#message-workflow) -- [Integrating Message Lane Module into Runtime](#integrating-message-lane-module-into-runtime) +- [Integrating Message Lane Module into Runtime](#integrating-messages-module-into-runtime) - [Non-Essential Functionality](#non-essential-functionality) - [Weights of Module Extrinsics](#weights-of-module-extrinsics) ## Overview Message lane is an unidirectional channel, where messages are sent from source chain to the target -chain. At the same time, a single instance of message lane module supports both outbound lanes and +chain. At the same time, a single instance of messages module supports both outbound lanes and inbound lanes. So the chain where the module is deployed (this chain), may act as a source chain for outbound messages (heading to a bridged chain) and as a target chain for inbound messages (coming from a bridged chain). -Message lane module supports multiple message lanes. Every message lane is identified with a 4-byte +Messages module supports multiple message lanes. Every message lane is identified with a 4-byte identifier. Messages sent through the lane are assigned unique (for this lane) increasing integer value that is known as nonce ("number that can only be used once"). Messages that are sent over the same lane are guaranteed to be delivered to the target chain in the same order they're sent from @@ -41,12 +41,12 @@ now. We assume that there are external, offchain actors, called relayers, that are submitting module related transactions to both target and source chains. The pallet itself has no assumptions about relayers incentivization scheme, but it has some callbacks for paying rewards. See -[Integrating Message Lane Module into runtime](#Integrating-Message-Lane-Module-into-runtime) +[Integrating Messages Module into runtime](#Integrating-Messages-Module-into-runtime) for details. Eventually, some relayer would notice this message in the "undelivered" state and it would decide to deliver this message. Relayer then crafts `receive_messages_proof()` transaction (aka delivery -transaction) for the message lane module instance, deployed at the target chain. Relayer provides +transaction) for the messages module instance, deployed at the target chain. Relayer provides his account id at the source chain, the proof of message (or several messages), the number of messages in the transaction and their cumulative dispatch weight. Once a transaction is mined, the message is considered "delivered". @@ -54,12 +54,12 @@ message is considered "delivered". Once a message is delivered, the relayer may want to confirm delivery back to the source chain. There are two reasons why he would want to do that. The first is that we intentionally limit number of "delivered", but not yet "confirmed" messages at inbound lanes -(see [What about other Constants in the Message Lane Module Configuration Trait](#What-about-other-Constants-in-the-Message-Lane-Module-Configuration-Trait) for explanation). +(see [What about other Constants in the Messages Module Configuration Trait](#What-about-other-Constants-in-the-Messages-Module-Configuration-Trait) for explanation). So at some point, the target chain may stop accepting new messages until relayers confirm some of these. The second is that if the relayer wants to be rewarded for delivery, he must prove the fact that he has actually delivered the message. And this proof may only be generated after the delivery transaction is mined. So relayer crafts the `receive_messages_delivery_proof()` transaction (aka -confirmation transaction) for the message lane module instance, deployed at the source chain. Once +confirmation transaction) for the messages module instance, deployed at the source chain. Once this transaction is mined, the message is considered "confirmed". The "confirmed" state is the final state of the message. But there's one last thing related to the @@ -69,21 +69,21 @@ the limit of "unconfirmed" messages at the target chain and it will stop accepti relayer sometimes includes a nonce of the latest "confirmed" message in the next `receive_messages_proof()` transaction, proving that some messages have been confirmed. -## Integrating Message Lane Module into Runtime +## Integrating Messages Module into Runtime -As it has been said above, the message lane module supports both outbound and inbound message lanes. +As it has been said above, the messages module supports both outbound and inbound message lanes. So if we will integrate a module in some runtime, it may act as the source chain runtime for outbound messages and as the target chain runtime for inbound messages. In this section, we'll sometimes refer to the chain we're currently integrating with, as this chain and the other chain as bridged chain. -Message lane module doesn't simply accept transactions that are claiming that the bridged chain has +Messages module doesn't simply accept transactions that are claiming that the bridged chain has some updated data for us. Instead of this, the module assumes that the bridged chain is able to prove that updated data in some way. The proof is abstracted from the module and may be of any kind. In our Substrate-to-Substrate bridge we're using runtime storage proofs. Other bridges may use transaction proofs, Substrate header digests or anything else that may be proved. -**IMPORTANT NOTE**: everything below in this chapter describes details of the message lane module +**IMPORTANT NOTE**: everything below in this chapter describes details of the messages module configuration. But if you interested in well-probed and relatively easy integration of two Substrate-based chains, you may want to look at the [bridge-runtime-common](../../bin/runtime-common/README.md) crate. This crate is providing a lot of @@ -92,7 +92,7 @@ to change something in this scheme, get back here for detailed information. ### General Information -The message lane module supports instances. Every module instance is supposed to bridge this chain +The messages module supports instances. Every module instance is supposed to bridge this chain and some bridged chain. To bridge with another chain, using another instance is suggested (this isn't forced anywhere in the code, though). @@ -103,10 +103,10 @@ to the target chain, the `MessagesDelivered` event is emitted from the `receive_messages_delivery_proof()` transaction. The `MessagesDelivered` contains the message lane identifier and inclusive range of delivered message nonces. -### How to plug-in Message Lane Module to Send Messages to the Bridged Chain? +### How to plug-in Messages Module to Send Messages to the Bridged Chain? -The `pallet_message_lane::Config` trait has 3 main associated types that are used to work with -outbound messages. The `pallet_message_lane::Config::TargetHeaderChain` defines how we see the +The `pallet_bridge_messages::Config` trait has 3 main associated types that are used to work with +outbound messages. The `pallet_bridge_messages::Config::TargetHeaderChain` defines how we see the bridged chain as the target for our outbound messages. It must be able to check that the bridged chain may accept our message - like that the message has size below maximal possible transaction size of the chain and so on. And when the relayer sends us a confirmation transaction, this @@ -114,7 +114,7 @@ implementation must be able to parse and verify the proof of messages delivery. reuse the same (configurable) type on all chains that are sending messages to the same bridged chain. -The `pallet_message_lane::Config::LaneMessageVerifier` defines a single callback to verify outbound +The `pallet_bridge_messages::Config::LaneMessageVerifier` defines a single callback to verify outbound messages. The simplest callback may just accept all messages. But in this case you'll need to answer many questions first. Who will pay for the delivery and confirmation transaction? Are we sure that someone will ever deliver this message to the bridged chain? Are we sure that we don't bloat our @@ -123,15 +123,15 @@ fields set to invalid values? Answering all those (and similar) questions would implementation. There's another thing to consider when implementing type for use in -`pallet_message_lane::Config::LaneMessageVerifier`. It is whether we treat all message lanes +`pallet_bridge_messages::Config::LaneMessageVerifier`. It is whether we treat all message lanes identically, or they'll have different sets of verification rules? For example, you may reserve lane#1 for messages coming from some 'wrapped-token' pallet - then you may verify in your implementation that the origin is associated with this pallet. Lane#2 may be reserved for 'system' messages and you may charge zero fee for such messages. You may have some rate limiting for messages sent over the lane#3. Or you may just verify the same rules set for all outbound messages - it is -all up to the `pallet_message_lane::Config::LaneMessageVerifier` implementation. +all up to the `pallet_bridge_messages::Config::LaneMessageVerifier` implementation. -The last type is the `pallet_message_lane::Config::MessageDeliveryAndDispatchPayment`. When all +The last type is the `pallet_bridge_messages::Config::MessageDeliveryAndDispatchPayment`. When all checks are made and we have decided to accept the message, we're calling the `pay_delivery_and_dispatch_fee()` callback, passing the corresponding argument of the `send_message` function. Later, when message delivery is confirmed, we're calling `pay_relayers_rewards()` @@ -140,41 +140,41 @@ implementation of this trait is in the [`instant_payments.rs`](./src/instant_pay simply calls `Currency::transfer()` when those callbacks are called. So `Currency` units are transferred between submitter, 'relayers fund' and relayers accounts. Other implementations may use more or less sophisticated techniques - the whole relayers incentivization scheme is not a part of -the message lane module. +the messages module. -### I have a Message Lane Module in my Runtime, but I Want to Reject all Outbound Messages. What shall I do? +### I have a Messages Module in my Runtime, but I Want to Reject all Outbound Messages. What shall I do? -You should be looking at the `bp_message_lane::source_chain::ForbidOutboundMessages` structure -[`bp_message_lane::source_chain`](../../primitives/message-lane/src/source_chain.rs). It implements +You should be looking at the `bp_messages::source_chain::ForbidOutboundMessages` structure +[`bp_messages::source_chain`](../../primitives/messages/src/source_chain.rs). It implements all required traits and will simply reject all transactions, related to outbound messages. -### How to plug-in Message Lane Module to Receive Messages from the Bridged Chain? +### How to plug-in Messages Module to Receive Messages from the Bridged Chain? -The `pallet_message_lane::Config` trait has 2 main associated types that are used to work with -inbound messages. The `pallet_message_lane::Config::SourceHeaderChain` defines how we see the +The `pallet_bridge_messages::Config` trait has 2 main associated types that are used to work with +inbound messages. The `pallet_bridge_messages::Config::SourceHeaderChain` defines how we see the bridged chain as the source or our inbound messages. When relayer sends us a delivery transaction, this implementation must be able to parse and verify the proof of messages wrapped in this transaction. Normally, you would reuse the same (configurable) type on all chains that are sending messages to the same bridged chain. -The `pallet_message_lane::Config::MessageDispatch` defines a way on how to dispatch delivered +The `pallet_bridge_messages::Config::MessageDispatch` defines a way on how to dispatch delivered messages. Apart from actually dispatching the message, the implementation must return the correct dispatch weight of the message before dispatch is called. -### I have a Message Lane Module in my Runtime, but I Want to Reject all Inbound Messages. What +### I have a Messages Module in my Runtime, but I Want to Reject all Inbound Messages. What shall I do? -You should be looking at the `bp_message_lane::target_chain::ForbidInboundMessages` structure from -the [`bp_message_lane::target_chain`](../../primitives/message-lane/src/target_chain.rs) module. It +You should be looking at the `bp_messages::target_chain::ForbidInboundMessages` structure from +the [`bp_messages::target_chain`](../../primitives/messages/src/target_chain.rs) module. It implements all required traits and will simply reject all transactions, related to inbound messages. -### What about other Constants in the Message Lane Module Configuration Trait? +### What about other Constants in the Messages Module Configuration Trait? Message is being stored in the source chain storage until its delivery will be confirmed. After that, we may safely remove the message from the storage. Lane messages are removed (pruned) when someone sends a new message using the same lane. So the message submitter pays for that pruning. To avoid pruning too many messages in a single transaction, there's -`pallet_message_lane::Config::MaxMessagesToPruneAtOnce` configuration parameter. We will never prune +`pallet_bridge_messages::Config::MaxMessagesToPruneAtOnce` configuration parameter. We will never prune more than this number of messages in the single transaction. That said, the value should not be too big to avoid waste of resources when there are no messages to prune. @@ -186,10 +186,10 @@ chain to confirm delivery and pay rewards. So to make sure we are able to craft transaction, we need to: (1) keep the size of this map below a certain limit and (2) make sure that the weight of processing this map is below a certain limit. Both size and processing weight mostly depend on the number of entries. The number of entries is limited with the -`pallet_message_lane::ConfigMaxUnrewardedRelayerEntriesAtInboundLane` parameter. Processing weight +`pallet_bridge_messages::ConfigMaxUnrewardedRelayerEntriesAtInboundLane` parameter. Processing weight also depends on the total number of messages that are being confirmed, because every confirmed message needs to be read. So there's another -`pallet_message_lane::Config::MaxUnconfirmedMessagesAtInboundLane` parameter for that. +`pallet_bridge_messages::Config::MaxUnconfirmedMessagesAtInboundLane` parameter for that. When choosing values for these parameters, you must also keep in mind that if proof in your scheme is based on finality of headers (and it is the most obvious option for Substrate-based chains with @@ -215,7 +215,7 @@ large maps, at the same time keeping reserve for future source chain upgrades. Apart from the message related calls, the module exposes a set of auxiliary calls. They fall in two groups, described in the next two paragraphs. -There may be a special account in every runtime where the message lane module is deployed. This +There may be a special account in every runtime where the messages module is deployed. This account, named 'module owner', is like a module-level sudo account - he's able to halt all and result all module operations without requiring runtime upgrade. The module may have no message owner, but we suggest to use it at least for initial deployment. To calls that are related to this @@ -242,7 +242,7 @@ The main assumptions behind weight formulas is: - all possible costs are paid in advance by the message submitter; - whenever possible, relayer tries to minimize cost of its transactions. So e.g. even though sender always pays for delivering outbound lane state proof, relayer may not include it in the delivery - transaction (unless message lane module on target chain requires that); + transaction (unless messages module on target chain requires that); - weight formula should incentivize relayer to not to submit any redundant data in the extrinsics arguments; - the extrinsic shall never be executing slower (i.e. has larger actual weight) than defined by the @@ -343,8 +343,8 @@ hardcoded into runtime. Adequate relayer would only include required trie nodes if message size would be maximal (`2/3` of `MaximalExtrinsicSize`), then the extra proof size would be `MaximalExtrinsicSize / 3 * 2 - EXPECTED_DEFAULT_MESSAGE_LENGTH`. -Both conditions are verified by `pallet_message_lane::ensure_weights_are_correct` and -`pallet_message_lane::ensure_able_to_receive_messages` functions, which must be called from every +Both conditions are verified by `pallet_bridge_messages::ensure_weights_are_correct` and +`pallet_bridge_messages::ensure_able_to_receive_messages` functions, which must be called from every runtime's tests. ### Weight of `receive_messages_delivery_proof` call @@ -381,11 +381,11 @@ Where: #### Why we're always able to craft `receive_messages_delivery_proof` transaction? -There can be at most `::MaxUnconfirmedMessagesAtInboundLane` +There can be at most `::MaxUnconfirmedMessagesAtInboundLane` messages and at most -`::MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded +`::MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers in the single delivery confirmation transaction. We're checking that this transaction may be crafted in the -`pallet_message_lane::ensure_able_to_receive_confirmation` function, which must be called from every +`pallet_bridge_messages::ensure_able_to_receive_confirmation` function, which must be called from every runtime' tests. diff --git a/bridges/modules/message-lane/rpc/Cargo.toml b/bridges/modules/messages/rpc/Cargo.toml similarity index 83% rename from bridges/modules/message-lane/rpc/Cargo.toml rename to bridges/modules/messages/rpc/Cargo.toml index 23dac80b40..bb0d1e0c54 100644 --- a/bridges/modules/message-lane/rpc/Cargo.toml +++ b/bridges/modules/messages/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "pallet-message-lane-rpc" -description = "Module that provides RPC methods specific to message-lane pallet." +name = "pallet-bridge-messages-rpc" +description = "Module that provides RPC methods specific to pallet-bridge-messages pallet." version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" @@ -17,7 +17,7 @@ log = "0.4.11" # Bridge dependencies bp-runtime = { path = "../../../primitives/runtime" } -bp-message-lane = { path = "../../../primitives/message-lane" } +bp-messages = { path = "../../../primitives/messages" } # Substrate Dependencies diff --git a/bridges/modules/message-lane/rpc/src/error.rs b/bridges/modules/messages/rpc/src/error.rs similarity index 96% rename from bridges/modules/message-lane/rpc/src/error.rs rename to bridges/modules/messages/rpc/src/error.rs index 74fd829fcd..ce70397055 100644 --- a/bridges/modules/message-lane/rpc/src/error.rs +++ b/bridges/modules/messages/rpc/src/error.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Possible errors and results of message-lane RPC calls. +//! Possible errors and results of messages pallet RPC calls. /// Future Result type. pub type FutureResult = jsonrpc_core::BoxFuture; diff --git a/bridges/modules/message-lane/rpc/src/lib.rs b/bridges/modules/messages/rpc/src/lib.rs similarity index 90% rename from bridges/modules/message-lane/rpc/src/lib.rs rename to bridges/modules/messages/rpc/src/lib.rs index 8532ed0c5d..3fd1ffdb82 100644 --- a/bridges/modules/message-lane/rpc/src/lib.rs +++ b/bridges/modules/messages/rpc/src/lib.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Module that provides RPC methods specific to message-lane pallet. +//! Module that provides RPC methods specific to messages pallet. use crate::error::{Error, FutureResult}; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::InstanceId; use futures::{FutureExt, TryFutureExt}; use jsonrpc_core::futures::Future as _; @@ -51,12 +51,12 @@ pub trait Runtime: Send + Sync + 'static { fn inbound_lane_data_key(&self, instance: &InstanceId, lane: &LaneId) -> Option; } -/// Provides RPC methods for interacting with message-lane pallet. +/// Provides RPC methods for interacting with messages pallet. #[rpc] -pub trait MessageLaneApi { +pub trait MessagesApi { /// Returns storage proof of messages in given inclusive range. The state of outbound /// lane is included in the proof if `include_outbound_lane_state` is true. - #[rpc(name = "messageLane_proveMessages")] + #[rpc(name = "messages_proveMessages")] fn prove_messages( &self, instance: InstanceId, @@ -68,7 +68,7 @@ pub trait MessageLaneApi { ) -> FutureResult; /// Returns proof-of-message(s) delivery. - #[rpc(name = "messageLane_proveMessagesDelivery")] + #[rpc(name = "messages_proveMessagesDelivery")] fn prove_messages_delivery( &self, instance: InstanceId, @@ -77,14 +77,14 @@ pub trait MessageLaneApi { ) -> FutureResult; } -/// Implements the MessageLaneApi trait for interacting with message lanes. -pub struct MessageLaneRpcHandler { +/// Implements the MessagesApi trait for interacting with message lanes. +pub struct MessagesRpcHandler { backend: Arc, runtime: Arc, _phantom: std::marker::PhantomData, } -impl MessageLaneRpcHandler { +impl MessagesRpcHandler { /// Creates new mesage lane RPC handler. pub fn new(backend: Arc, runtime: Arc) -> Self { Self { @@ -95,7 +95,7 @@ impl MessageLaneRpcHandler { } } -impl MessageLaneApi for MessageLaneRpcHandler +impl MessagesApi for MessagesRpcHandler where Block: BlockT, Backend: BackendT + 'static, diff --git a/bridges/modules/message-lane/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs similarity index 99% rename from bridges/modules/message-lane/src/benchmarking.rs rename to bridges/modules/messages/src/benchmarking.rs index cd59d1347f..0265db0429 100644 --- a/bridges/modules/message-lane/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Message lane pallet benchmarking. +//! Messages pallet benchmarking. use crate::weights_ext::EXPECTED_DEFAULT_MESSAGE_LENGTH; use crate::{inbound_lane::InboundLaneStorage, inbound_lane_storage, outbound_lane, Call, Instance}; -use bp_message_lane::{ +use bp_messages::{ source_chain::TargetHeaderChain, target_chain::SourceHeaderChain, InboundLaneData, LaneId, MessageData, MessageNonce, OutboundLaneData, UnrewardedRelayersState, }; diff --git a/bridges/modules/message-lane/src/inbound_lane.rs b/bridges/modules/messages/src/inbound_lane.rs similarity index 99% rename from bridges/modules/message-lane/src/inbound_lane.rs rename to bridges/modules/messages/src/inbound_lane.rs index 7359aa4ed1..a2ec02b74d 100644 --- a/bridges/modules/message-lane/src/inbound_lane.rs +++ b/bridges/modules/messages/src/inbound_lane.rs @@ -16,7 +16,7 @@ //! Everything about incoming messages receival. -use bp_message_lane::{ +use bp_messages::{ target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, InboundLaneData, LaneId, MessageKey, MessageNonce, OutboundLaneData, }; diff --git a/bridges/modules/message-lane/src/instant_payments.rs b/bridges/modules/messages/src/instant_payments.rs similarity index 98% rename from bridges/modules/message-lane/src/instant_payments.rs rename to bridges/modules/messages/src/instant_payments.rs index 4dffc35935..c6d30950be 100644 --- a/bridges/modules/message-lane/src/instant_payments.rs +++ b/bridges/modules/messages/src/instant_payments.rs @@ -19,7 +19,7 @@ //! The payment is first transferred to a special `relayers-fund` account and only transferred //! to the actual relayer in case confirmation is received. -use bp_message_lane::{ +use bp_messages::{ source_chain::{MessageDeliveryAndDispatchPayment, RelayersRewards, Sender}, MessageNonce, }; @@ -168,13 +168,13 @@ fn pay_relayer_reward( match pay_result { Ok(_) => log::trace!( - target: "runtime", + target: "runtime::bridge-messages", "Rewarded relayer {:?} with {:?}", relayer_account, reward, ), Err(error) => log::trace!( - target: "runtime", + target: "runtime::bridge-messages", "Failed to pay relayer {:?} reward {:?}: {:?}", relayer_account, reward, @@ -187,7 +187,7 @@ fn pay_relayer_reward( mod tests { use super::*; use crate::mock::{run_test, AccountId as TestAccountId, Balance as TestBalance, TestRuntime}; - use bp_message_lane::source_chain::RelayerRewards; + use bp_messages::source_chain::RelayerRewards; type Balances = pallet_balances::Module; diff --git a/bridges/modules/message-lane/src/lib.rs b/bridges/modules/messages/src/lib.rs similarity index 94% rename from bridges/modules/message-lane/src/lib.rs rename to bridges/modules/messages/src/lib.rs index 3132773ead..c134b2ebaf 100644 --- a/bridges/modules/message-lane/src/lib.rs +++ b/bridges/modules/messages/src/lib.rs @@ -44,11 +44,11 @@ use crate::inbound_lane::{InboundLane, InboundLaneStorage}; use crate::outbound_lane::{OutboundLane, OutboundLaneStorage}; use crate::weights::WeightInfo; -use bp_message_lane::{ +use bp_messages::{ source_chain::{LaneMessageVerifier, MessageDeliveryAndDispatchPayment, RelayersRewards, TargetHeaderChain}, target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain}, total_unrewarded_messages, InboundLaneData, LaneId, MessageData, MessageKey, MessageNonce, MessagePayload, - OutboundLaneData, Parameter as MessageLaneParameter, UnrewardedRelayersState, + OutboundLaneData, Parameter as MessagesParameter, UnrewardedRelayersState, }; use bp_runtime::Size; use codec::{Decode, Encode}; @@ -88,7 +88,7 @@ pub trait Config: frame_system::Config { /// for integrating the pallet. /// /// All pallet parameters may only be updated either by the root, or by the pallet owner. - type Parameter: MessageLaneParameter; + type Parameter: MessagesParameter; /// Maximal number of messages that may be pruned during maintenance. Maintenance occurs /// whenever new message is sent. The reason is that if you want to use lane, you should @@ -188,7 +188,7 @@ decl_error! { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as MessageLane { + trait Store for Module, I: Instance = DefaultInstance> as BridgeMessages { /// Optional pallet owner. /// /// Pallet owner has a right to halt all pallet operations and then resume it. If it is @@ -255,11 +255,11 @@ decl_module! { match new_owner { Some(new_owner) => { ModuleOwner::::put(&new_owner); - log::info!("Setting pallet Owner to: {:?}", new_owner); + log::info!(target: "runtime::bridge-messages", "Setting pallet Owner to: {:?}", new_owner); }, None => { ModuleOwner::::kill(); - log::info!("Removed Owner of pallet."); + log::info!(target: "runtime::bridge-messages", "Removed Owner of pallet."); }, } } @@ -273,9 +273,9 @@ decl_module! { >::put(operational); if operational { - log::info!("Resuming pallet operations."); + log::info!(target: "runtime::bridge-messages", "Resuming pallet operations."); } else { - log::warn!("Stopping pallet operations."); + log::warn!(target: "runtime::bridge-messages", "Stopping pallet operations."); } } @@ -306,6 +306,7 @@ decl_module! { T::TargetHeaderChain::verify_message(&payload) .map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Message to lane {:?} is rejected by target chain: {:?}", lane_id, err, @@ -324,6 +325,7 @@ decl_module! { &payload, ).map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Message to lane {:?} is rejected by lane verifier: {:?}", lane_id, err, @@ -339,6 +341,7 @@ decl_module! { &Self::relayer_fund_account_id(), ).map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Message to lane {:?} is rejected because submitter {:?} is unable to pay fee {:?}: {:?}", lane_id, submitter, @@ -359,6 +362,7 @@ decl_module! { lane.prune_messages(T::MaxMessagesToPruneAtOnce::get()); log::trace!( + target: "runtime::bridge-messages", "Accepted message {} to lane {:?}. Message size: {:?}", nonce, lane_id, @@ -395,6 +399,7 @@ decl_module! { &Self::relayer_fund_account_id(), ).map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Submitter {:?} can't pay additional fee {:?} for the message {:?}/{:?}: {:?}", submitter, additional_fee, @@ -451,6 +456,7 @@ decl_module! { >(proof, messages_count) .map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Rejecting invalid messages proof: {:?}", err, ); @@ -470,6 +476,7 @@ decl_module! { .fold(0, |sum, weight| sum.saturating_add(weight)); if dispatch_weight < actual_dispatch_weight { log::trace!( + target: "runtime::bridge-messages", "Rejecting messages proof because of dispatch weight mismatch: declared={}, expected={}", dispatch_weight, actual_dispatch_weight, @@ -488,6 +495,7 @@ decl_module! { let updated_latest_confirmed_nonce = lane.receive_state_update(lane_state); if let Some(updated_latest_confirmed_nonce) = updated_latest_confirmed_nonce { log::trace!( + target: "runtime::bridge-messages", "Received lane {:?} state update: latest_confirmed_nonce={}", lane_id, updated_latest_confirmed_nonce, @@ -506,6 +514,7 @@ decl_module! { } log::trace!( + target: "runtime::bridge-messages", "Received messages: total={}, valid={}", total_messages, valid_messages, @@ -526,6 +535,7 @@ decl_module! { let confirmation_relayer = ensure_signed(origin)?; let (lane_id, lane_data) = T::TargetHeaderChain::verify_messages_delivery_proof(proof).map_err(|err| { log::trace!( + target: "runtime::bridge-messages", "Rejecting invalid messages delivery proof: {:?}", err, ); @@ -581,6 +591,7 @@ decl_module! { } log::trace!( + target: "runtime::bridge-messages", "Received messages delivery proof up to (and including) {} at lane {:?}", last_delivered_nonce, lane_id, @@ -618,11 +629,9 @@ impl, I: Instance> Module { } /// Get state of unrewarded relayers set. - pub fn inbound_unrewarded_relayers_state( - lane: bp_message_lane::LaneId, - ) -> bp_message_lane::UnrewardedRelayersState { + pub fn inbound_unrewarded_relayers_state(lane: bp_messages::LaneId) -> bp_messages::UnrewardedRelayersState { let relayers = InboundLanes::::get(&lane).relayers; - bp_message_lane::UnrewardedRelayersState { + bp_messages::UnrewardedRelayersState { unrewarded_relayer_entries: relayers.len() as _, messages_in_oldest_entry: relayers.front().map(|(begin, end, _)| 1 + end - begin).unwrap_or(0), total_messages: total_unrewarded_messages(&relayers).unwrap_or(MessageNonce::MAX), @@ -838,11 +847,12 @@ fn verify_and_decode_messages_proof, Fee, Dispatch mod tests { use super::*; use crate::mock::{ - message, run_test, Event as TestEvent, Origin, TestMessageDeliveryAndDispatchPayment, TestMessageLaneParameter, - TestMessagesDeliveryProof, TestMessagesProof, TestPayload, TestRuntime, TokenConversionRate, - PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID, TEST_RELAYER_A, TEST_RELAYER_B, + message, run_test, Event as TestEvent, Origin, TestMessageDeliveryAndDispatchPayment, + TestMessagesDeliveryProof, TestMessagesParameter, TestMessagesProof, TestPayload, TestRuntime, + TokenConversionRate, PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID, TEST_RELAYER_A, + TEST_RELAYER_B, }; - use bp_message_lane::UnrewardedRelayersState; + use bp_messages::UnrewardedRelayersState; use frame_support::{assert_noop, assert_ok}; use frame_system::{EventRecord, Module as System, Phase}; use hex_literal::hex; @@ -868,7 +878,7 @@ mod tests { System::::events(), vec![EventRecord { phase: Phase::Initialization, - event: TestEvent::pallet_message_lane(RawEvent::MessageAccepted(TEST_LANE_ID, 1)), + event: TestEvent::pallet_bridge_messages(RawEvent::MessageAccepted(TEST_LANE_ID, 1)), topics: vec![], }], ); @@ -897,7 +907,7 @@ mod tests { System::::events(), vec![EventRecord { phase: Phase::Initialization, - event: TestEvent::pallet_message_lane(RawEvent::MessagesDelivered(TEST_LANE_ID, 1, 1)), + event: TestEvent::pallet_bridge_messages(RawEvent::MessagesDelivered(TEST_LANE_ID, 1, 1)), topics: vec![], }], ); @@ -966,7 +976,7 @@ mod tests { run_test(|| { get_ready_for_events(); - let parameter = TestMessageLaneParameter::TokenConversionRate(10.into()); + let parameter = TestMessagesParameter::TokenConversionRate(10.into()); assert_ok!(Module::::update_pallet_parameter( Origin::root(), parameter.clone(), @@ -977,7 +987,7 @@ mod tests { System::::events(), vec![EventRecord { phase: Phase::Initialization, - event: TestEvent::pallet_message_lane(RawEvent::ParameterUpdated(parameter)), + event: TestEvent::pallet_bridge_messages(RawEvent::ParameterUpdated(parameter)), topics: vec![], }], ); @@ -990,7 +1000,7 @@ mod tests { ModuleOwner::::put(2); get_ready_for_events(); - let parameter = TestMessageLaneParameter::TokenConversionRate(10.into()); + let parameter = TestMessagesParameter::TokenConversionRate(10.into()); assert_ok!(Module::::update_pallet_parameter( Origin::signed(2), parameter.clone(), @@ -1001,7 +1011,7 @@ mod tests { System::::events(), vec![EventRecord { phase: Phase::Initialization, - event: TestEvent::pallet_message_lane(RawEvent::ParameterUpdated(parameter)), + event: TestEvent::pallet_bridge_messages(RawEvent::ParameterUpdated(parameter)), topics: vec![], }], ); @@ -1014,7 +1024,7 @@ mod tests { assert_noop!( Module::::update_pallet_parameter( Origin::signed(2), - TestMessageLaneParameter::TokenConversionRate(10.into()), + TestMessagesParameter::TokenConversionRate(10.into()), ), DispatchError::BadOrigin, ); @@ -1024,7 +1034,7 @@ mod tests { assert_noop!( Module::::update_pallet_parameter( Origin::signed(1), - TestMessageLaneParameter::TokenConversionRate(10.into()), + TestMessagesParameter::TokenConversionRate(10.into()), ), DispatchError::BadOrigin, ); @@ -1469,9 +1479,12 @@ mod tests { fn storage_message_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking all // previously crafted messages proofs. + let storage_key = storage_keys::message_key::(&*b"test", 42).0; assert_eq!( - storage_keys::message_key::(&*b"test", 42).0, - hex!("87f1ffe31b52878f09495ca7482df1a48a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(), + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), ); } @@ -1479,9 +1492,12 @@ mod tests { fn outbound_lane_data_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking all // previously crafted outbound lane state proofs. + let storage_key = storage_keys::outbound_lane_data_key::(&*b"test").0; assert_eq!( - storage_keys::outbound_lane_data_key::(&*b"test").0, - hex!("87f1ffe31b52878f09495ca7482df1a496c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(), + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), ); } @@ -1489,9 +1505,12 @@ mod tests { fn inbound_lane_data_key_computed_properly() { // If this test fails, then something has been changed in module storage that is breaking all // previously crafted inbound lane state proofs. + let storage_key = storage_keys::inbound_lane_data_key::(&*b"test").0; assert_eq!( - storage_keys::inbound_lane_data_key::(&*b"test").0, - hex!("87f1ffe31b52878f09495ca7482df1a4e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(), + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), ); } diff --git a/bridges/modules/message-lane/src/mock.rs b/bridges/modules/messages/src/mock.rs similarity index 96% rename from bridges/modules/message-lane/src/mock.rs rename to bridges/modules/messages/src/mock.rs index cf14ca105c..836aedf3a6 100644 --- a/bridges/modules/message-lane/src/mock.rs +++ b/bridges/modules/messages/src/mock.rs @@ -19,13 +19,13 @@ use crate::Config; -use bp_message_lane::{ +use bp_messages::{ source_chain::{ LaneMessageVerifier, MessageDeliveryAndDispatchPayment, RelayersRewards, Sender, TargetHeaderChain, }, target_chain::{DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, SourceHeaderChain}, InboundLaneData, LaneId, Message, MessageData, MessageKey, MessageNonce, OutboundLaneData, - Parameter as MessageLaneParameter, + Parameter as MessagesParameter, }; use bp_runtime::Size; use codec::{Decode, Encode}; @@ -56,7 +56,7 @@ impl sp_runtime::traits::Convert for AccountIdConverter { type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -use crate as pallet_message_lane; +use crate as pallet_bridge_messages; frame_support::construct_runtime! { pub enum TestRuntime where @@ -66,7 +66,7 @@ frame_support::construct_runtime! { { System: frame_system::{Module, Call, Config, Storage, Event}, Balances: pallet_balances::{Module, Call, Event}, - MessageLane: pallet_message_lane::{Module, Call, Event}, + Messages: pallet_bridge_messages::{Module, Call, Event}, } } @@ -124,16 +124,14 @@ parameter_types! { } #[derive(Debug, Clone, Encode, Decode, PartialEq, Eq)] -pub enum TestMessageLaneParameter { +pub enum TestMessagesParameter { TokenConversionRate(FixedU128), } -impl MessageLaneParameter for TestMessageLaneParameter { +impl MessagesParameter for TestMessagesParameter { fn save(&self) { match *self { - TestMessageLaneParameter::TokenConversionRate(conversion_rate) => { - TokenConversionRate::set(&conversion_rate) - } + TestMessagesParameter::TokenConversionRate(conversion_rate) => TokenConversionRate::set(&conversion_rate), } } } @@ -141,7 +139,7 @@ impl MessageLaneParameter for TestMessageLaneParameter { impl Config for TestRuntime { type Event = Event; type WeightInfo = (); - type Parameter = TestMessageLaneParameter; + type Parameter = TestMessagesParameter; type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce; type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; @@ -390,7 +388,7 @@ pub fn message_data(payload: TestPayload) -> MessageData { } } -/// Run message lane test. +/// Run pallet test. pub fn run_test(test: impl FnOnce() -> T) -> T { let mut t = frame_system::GenesisConfig::default() .build_storage::() diff --git a/bridges/modules/message-lane/src/outbound_lane.rs b/bridges/modules/messages/src/outbound_lane.rs similarity index 98% rename from bridges/modules/message-lane/src/outbound_lane.rs rename to bridges/modules/messages/src/outbound_lane.rs index 8496d7f8c0..0a6dd5670c 100644 --- a/bridges/modules/message-lane/src/outbound_lane.rs +++ b/bridges/modules/messages/src/outbound_lane.rs @@ -16,7 +16,7 @@ //! Everything about outgoing messages sending. -use bp_message_lane::{LaneId, MessageData, MessageNonce, OutboundLaneData}; +use bp_messages::{LaneId, MessageData, MessageNonce, OutboundLaneData}; /// Outbound lane storage. pub trait OutboundLaneStorage { diff --git a/bridges/modules/message-lane/src/weights.rs b/bridges/modules/messages/src/weights.rs similarity index 97% rename from bridges/modules/message-lane/src/weights.rs rename to bridges/modules/messages/src/weights.rs index b0ec6522b2..2ccb03c4c9 100644 --- a/bridges/modules/message-lane/src/weights.rs +++ b/bridges/modules/messages/src/weights.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Autogenerated weights for pallet_message_lane +//! Autogenerated weights for pallet_bridge_messages //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.1 //! DATE: 2021-02-11, STEPS: [50, ], REPEAT: 20 @@ -28,12 +28,12 @@ // --chain=local // --steps=50 // --repeat=20 -// --pallet=pallet_message_lane +// --pallet=pallet_bridge_messages // --extrinsic=* // --execution=wasm // --wasm-execution=Compiled // --heap-pages=4096 -// --output=./modules/message-lane/src/weights.rs +// --output=./modules/messages/src/weights.rs // --template=./.maintain/rialto-weight-template.hbs #![allow(clippy::all)] @@ -46,7 +46,7 @@ use frame_support::{ }; use sp_std::marker::PhantomData; -/// Weight functions needed for pallet_message_lane. +/// Weight functions needed for pallet_bridge_messages. pub trait WeightInfo { fn send_minimal_message_worst_case() -> Weight; fn send_1_kb_message_worst_case() -> Weight; @@ -69,7 +69,7 @@ pub trait WeightInfo { fn receive_delivery_proof_for_multiple_messages_by_multiple_relayers(i: u32) -> Weight; } -/// Weights for pallet_message_lane using the Rialto node and recommended hardware. +/// Weights for pallet_bridge_messages using the Rialto node and recommended hardware. pub struct RialtoWeight(PhantomData); impl WeightInfo for RialtoWeight { fn send_minimal_message_worst_case() -> Weight { diff --git a/bridges/modules/message-lane/src/weights_ext.rs b/bridges/modules/messages/src/weights_ext.rs similarity index 99% rename from bridges/modules/message-lane/src/weights_ext.rs rename to bridges/modules/messages/src/weights_ext.rs index bc75cd5ba0..89dbea8949 100644 --- a/bridges/modules/message-lane/src/weights_ext.rs +++ b/bridges/modules/messages/src/weights_ext.rs @@ -18,7 +18,7 @@ use crate::weights::WeightInfo; -use bp_message_lane::{MessageNonce, UnrewardedRelayersState}; +use bp_messages::{MessageNonce, UnrewardedRelayersState}; use bp_runtime::{PreComputedSize, Size}; use frame_support::weights::Weight; diff --git a/bridges/primitives/chains/kusama/Cargo.toml b/bridges/primitives/chains/kusama/Cargo.toml index bb65292883..15614a922b 100644 --- a/bridges/primitives/chains/kusama/Cargo.toml +++ b/bridges/primitives/chains/kusama/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-polkadot-core = { path = "../../polkadot-core", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } @@ -20,7 +20,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", "sp-api/std", diff --git a/bridges/primitives/chains/kusama/src/lib.rs b/bridges/primitives/chains/kusama/src/lib.rs index 4e1134f162..7163d15ef1 100644 --- a/bridges/primitives/chains/kusama/src/lib.rs +++ b/bridges/primitives/chains/kusama/src/lib.rs @@ -20,7 +20,7 @@ // Runtime-generated DecodeLimit::decode_all_with_depth_limit #![allow(clippy::unnecessary_mut_passed)] -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; use sp_std::prelude::*; pub use bp_polkadot_core::*; diff --git a/bridges/primitives/chains/millau/Cargo.toml b/bridges/primitives/chains/millau/Cargo.toml index a7df6f6bbd..ae27d2ce62 100644 --- a/bridges/primitives/chains/millau/Cargo.toml +++ b/bridges/primitives/chains/millau/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } fixed-hash = { version = "0.7.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } @@ -33,7 +33,7 @@ sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" , [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-runtime/std", "fixed-hash/std", "frame-support/std", diff --git a/bridges/primitives/chains/millau/src/lib.rs b/bridges/primitives/chains/millau/src/lib.rs index 7397fcf474..a8fa00af3f 100644 --- a/bridges/primitives/chains/millau/src/lib.rs +++ b/bridges/primitives/chains/millau/src/lib.rs @@ -22,7 +22,7 @@ mod millau_hash; -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState}; use bp_runtime::Chain; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight}, @@ -76,21 +76,21 @@ pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 1024; /// Weight of single regular message delivery transaction on Millau chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_proof_weight()` call -/// for the case when single message of `pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. +/// This value is a result of `pallet_bridge_messages::Module::receive_messages_proof_weight()` call +/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. /// The message must have dispatch weight set to zero. The result then must be rounded up to account /// possible future runtime upgrades. pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; /// Increase of delivery transaction weight on Millau chain with every additional message byte. /// -/// This value is a result of `pallet_message_lane::WeightInfoExt::storage_proof_size_overhead(1)` call. The +/// This value is a result of `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The /// result then must be rounded up to account possible future runtime upgrades. pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Millau chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_delivery_proof` weight formula computation +/// This value is a result of `pallet_bridge_messages::Module::receive_messages_delivery_proof` weight formula computation /// for the case when single message is confirmed. The result then must be rounded up to account possible future /// runtime upgrades. pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000; diff --git a/bridges/primitives/chains/polkadot/Cargo.toml b/bridges/primitives/chains/polkadot/Cargo.toml index e1e646d5a1..595fb149f4 100644 --- a/bridges/primitives/chains/polkadot/Cargo.toml +++ b/bridges/primitives/chains/polkadot/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-polkadot-core = { path = "../../polkadot-core", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } @@ -21,7 +21,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", "sp-api/std", diff --git a/bridges/primitives/chains/polkadot/src/lib.rs b/bridges/primitives/chains/polkadot/src/lib.rs index 53fe1917ea..8e0d30cdb6 100644 --- a/bridges/primitives/chains/polkadot/src/lib.rs +++ b/bridges/primitives/chains/polkadot/src/lib.rs @@ -20,7 +20,7 @@ // Runtime-generated DecodeLimit::decode_all_with_depth_limit #![allow(clippy::unnecessary_mut_passed)] -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; use sp_std::prelude::*; pub use bp_polkadot_core::*; diff --git a/bridges/primitives/chains/rialto/Cargo.toml b/bridges/primitives/chains/rialto/Cargo.toml index a225f79b34..6dbbe7549a 100644 --- a/bridges/primitives/chains/rialto/Cargo.toml +++ b/bridges/primitives/chains/rialto/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } # Substrate Based Dependencies @@ -25,7 +25,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" , [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-runtime/std", "frame-support/std", "frame-system/std", diff --git a/bridges/primitives/chains/rialto/src/lib.rs b/bridges/primitives/chains/rialto/src/lib.rs index ccb2154ee4..b373bbe9a0 100644 --- a/bridges/primitives/chains/rialto/src/lib.rs +++ b/bridges/primitives/chains/rialto/src/lib.rs @@ -20,7 +20,7 @@ // Runtime-generated DecodeLimit::decode_all_With_depth_limit #![allow(clippy::unnecessary_mut_passed)] -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState}; use bp_runtime::Chain; use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, DispatchClass, Weight}, @@ -67,21 +67,21 @@ pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 128; /// Weight of single regular message delivery transaction on Rialto chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_proof_weight()` call -/// for the case when single message of `pallet_message_lane::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. +/// This value is a result of `pallet_bridge_messages::Module::receive_messages_proof_weight()` call +/// for the case when single message of `pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH` bytes is delivered. /// The message must have dispatch weight set to zero. The result then must be rounded up to account /// possible future runtime upgrades. pub const DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT: Weight = 1_000_000_000; /// Increase of delivery transaction weight on Rialto chain with every additional message byte. /// -/// This value is a result of `pallet_message_lane::WeightInfoExt::storage_proof_size_overhead(1)` call. The +/// This value is a result of `pallet_bridge_messages::WeightInfoExt::storage_proof_size_overhead(1)` call. The /// result then must be rounded up to account possible future runtime upgrades. pub const ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT: Weight = 25_000; /// Maximal weight of single message delivery confirmation transaction on Rialto chain. /// -/// This value is a result of `pallet_message_lane::Module::receive_messages_delivery_proof` weight formula computation +/// This value is a result of `pallet_bridge_messages::Module::receive_messages_delivery_proof` weight formula computation /// for the case when single message is confirmed. The result then must be rounded up to account possible future /// runtime upgrades. pub const MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT: Weight = 2_000_000_000; diff --git a/bridges/primitives/chains/rococo/Cargo.toml b/bridges/primitives/chains/rococo/Cargo.toml index dc09d1a3bf..db6bc12156 100644 --- a/bridges/primitives/chains/rococo/Cargo.toml +++ b/bridges/primitives/chains/rococo/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-polkadot-core = { path = "../../polkadot-core", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } @@ -20,7 +20,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", "sp-api/std", diff --git a/bridges/primitives/chains/rococo/src/lib.rs b/bridges/primitives/chains/rococo/src/lib.rs index ef372540a3..b52049cd63 100644 --- a/bridges/primitives/chains/rococo/src/lib.rs +++ b/bridges/primitives/chains/rococo/src/lib.rs @@ -20,7 +20,7 @@ // Runtime-generated DecodeLimit::decode_all_with_depth_limit #![allow(clippy::unnecessary_mut_passed)] -use bp_message_lane::{LaneId, Weight, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, Weight, MessageNonce, UnrewardedRelayersState}; use sp_std::prelude::*; pub use bp_polkadot_core::*; diff --git a/bridges/primitives/chains/westend/Cargo.toml b/bridges/primitives/chains/westend/Cargo.toml index 6253f4bef9..654f029146 100644 --- a/bridges/primitives/chains/westend/Cargo.toml +++ b/bridges/primitives/chains/westend/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] # Bridge Dependencies -bp-message-lane = { path = "../../message-lane", default-features = false } +bp-messages = { path = "../../messages", default-features = false } bp-polkadot-core = { path = "../../polkadot-core", default-features = false } bp-runtime = { path = "../../runtime", default-features = false } @@ -20,7 +20,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", "sp-api/std", diff --git a/bridges/primitives/chains/westend/src/lib.rs b/bridges/primitives/chains/westend/src/lib.rs index 5b43eeeae5..0596da1b7d 100644 --- a/bridges/primitives/chains/westend/src/lib.rs +++ b/bridges/primitives/chains/westend/src/lib.rs @@ -20,7 +20,7 @@ // Runtime-generated DecodeLimit::decode_all_with_depth_limit #![allow(clippy::unnecessary_mut_passed)] -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; use sp_std::prelude::*; pub use bp_polkadot_core::*; diff --git a/bridges/primitives/message-lane/Cargo.toml b/bridges/primitives/messages/Cargo.toml similarity index 91% rename from bridges/primitives/message-lane/Cargo.toml rename to bridges/primitives/messages/Cargo.toml index cbddcb1614..9cb037a34c 100644 --- a/bridges/primitives/message-lane/Cargo.toml +++ b/bridges/primitives/messages/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "bp-message-lane" -description = "Primitives of message lane module." +name = "bp-messages" +description = "Primitives of messages module." version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/bridges/primitives/message-lane/src/lib.rs b/bridges/primitives/messages/src/lib.rs similarity index 98% rename from bridges/primitives/message-lane/src/lib.rs rename to bridges/primitives/messages/src/lib.rs index de2dbd9ae6..83bd902a1e 100644 --- a/bridges/primitives/message-lane/src/lib.rs +++ b/bridges/primitives/messages/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Primitives of message lane module. +//! Primitives of messages module. #![cfg_attr(not(feature = "std"), no_std)] // RuntimeApi generated functions @@ -29,10 +29,10 @@ use sp_std::{collections::vec_deque::VecDeque, prelude::*}; pub mod source_chain; pub mod target_chain; -// Weight is reexported to avoid additional frame-support dependencies in message-lane related crates. +// Weight is reexported to avoid additional frame-support dependencies in related crates. pub use frame_support::weights::Weight; -/// Message lane pallet parameter. +/// Messages pallet parameter. pub trait Parameter: frame_support::Parameter { /// Save parameter value in the runtime storage. fn save(&self); diff --git a/bridges/primitives/message-lane/src/source_chain.rs b/bridges/primitives/messages/src/source_chain.rs similarity index 99% rename from bridges/primitives/message-lane/src/source_chain.rs rename to bridges/primitives/messages/src/source_chain.rs index d0dc36bb69..8cc62a0090 100644 --- a/bridges/primitives/message-lane/src/source_chain.rs +++ b/bridges/primitives/messages/src/source_chain.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Primitives of message lane module, that are used on the source chain. +//! Primitives of messages module, that are used on the source chain. use crate::{InboundLaneData, LaneId, MessageNonce, OutboundLaneData}; diff --git a/bridges/primitives/message-lane/src/target_chain.rs b/bridges/primitives/messages/src/target_chain.rs similarity index 98% rename from bridges/primitives/message-lane/src/target_chain.rs rename to bridges/primitives/messages/src/target_chain.rs index 765ce64f63..530a228022 100644 --- a/bridges/primitives/message-lane/src/target_chain.rs +++ b/bridges/primitives/messages/src/target_chain.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Primitives of message lane module, that are used on the target chain. +//! Primitives of messages module, that are used on the target chain. use crate::{LaneId, Message, MessageData, MessageKey, OutboundLaneData}; diff --git a/bridges/primitives/polkadot-core/Cargo.toml b/bridges/primitives/polkadot-core/Cargo.toml index 0a19bad97a..8df209ca67 100644 --- a/bridges/primitives/polkadot-core/Cargo.toml +++ b/bridges/primitives/polkadot-core/Cargo.toml @@ -10,7 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" # Bridge Dependencies -bp-message-lane = { path = "../message-lane", default-features = false } +bp-messages = { path = "../messages", default-features = false } bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies @@ -25,7 +25,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", d [features] default = ["std"] std = [ - "bp-message-lane/std", + "bp-messages/std", "bp-runtime/std", "frame-support/std", "frame-system/std", diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index f56d4c52aa..f3f9563774 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -16,7 +16,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use bp_runtime::Chain; use frame_support::{ parameter_types, diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 862edf7b97..9e6e878bf4 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -56,9 +56,6 @@ pub const WESTEND_BRIDGE_INSTANCE: InstanceId = *b"wend"; /// Call-dispatch module prefix. pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/call-dispatch"; -/// Message-lane module prefix. -pub const MESSAGE_LANE_MODULE_PREFIX: &[u8] = b"pallet-bridge/message-lane"; - /// A unique prefix for entropy when generating cross-chain account IDs. pub const ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/account"; @@ -66,7 +63,7 @@ pub const ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/ pub const ROOT_ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/root"; /// Id of deployed module instance. We have a bunch of pallets that may be used in -/// different bridges. E.g. message-lane pallet may be deployed twice in the same +/// different bridges. E.g. messages pallet may be deployed twice in the same /// runtime to bridge ThisChain with Chain1 and Chain2. Sometimes we need to be able /// to identify deployed instance dynamically. This type is used for that. pub type InstanceId = [u8; 4]; @@ -108,7 +105,7 @@ where /// /// This account is used to collect fees for relayers that are passing messages across the bridge. /// -/// The account ID can be the same across different instances of `message-lane` if the same +/// The account ID can be the same across different instances of `pallet-bridge-messages` if the same /// `bridge_id` is used. pub fn derive_relayer_fund_account_id(bridge_id: InstanceId) -> H256 { ("relayer-fund-account", bridge_id).using_encoded(blake2_256).into() diff --git a/bridges/relays/clients/substrate/Cargo.toml b/bridges/relays/clients/substrate/Cargo.toml index 13eb51c8f5..3f62731d52 100644 --- a/bridges/relays/clients/substrate/Cargo.toml +++ b/bridges/relays/clients/substrate/Cargo.toml @@ -19,7 +19,7 @@ rand = "0.7" # Bridge dependencies bp-header-chain = { path = "../../../primitives/header-chain" } -bp-message-lane = { path = "../../../primitives/message-lane" } +bp-messages = { path = "../../../primitives/messages" } bp-runtime = { path = "../../../primitives/runtime" } finality-relay = { path = "../../generic/finality" } headers-relay = { path = "../../generic/headers" } diff --git a/bridges/relays/clients/substrate/src/client.rs b/bridges/relays/clients/substrate/src/client.rs index 8332813042..56fcb33bf9 100644 --- a/bridges/relays/clients/substrate/src/client.rs +++ b/bridges/relays/clients/substrate/src/client.rs @@ -17,10 +17,10 @@ //! Substrate node client. use crate::chain::{Chain, ChainWithBalances}; -use crate::rpc::{Substrate, SubstrateMessageLane}; +use crate::rpc::{Substrate, SubstrateMessages}; use crate::{ConnectionParams, Error, Result}; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::InstanceId; use codec::Decode; use frame_system::AccountInfo; @@ -228,7 +228,7 @@ impl Client { include_outbound_lane_state: bool, at_block: C::Hash, ) -> Result { - let encoded_trie_nodes = SubstrateMessageLane::::prove_messages( + let encoded_trie_nodes = SubstrateMessages::::prove_messages( &self.client, instance, lane, @@ -252,7 +252,7 @@ impl Client { at_block: C::Hash, ) -> Result>> { let encoded_trie_nodes = - SubstrateMessageLane::::prove_messages_delivery(&self.client, instance, lane, Some(at_block)) + SubstrateMessages::::prove_messages_delivery(&self.client, instance, lane, Some(at_block)) .await .map_err(Error::RpcError)?; let decoded_trie_nodes: Vec> = diff --git a/bridges/relays/clients/substrate/src/rpc.rs b/bridges/relays/clients/substrate/src/rpc.rs index 98b9575002..fcc3e9dd89 100644 --- a/bridges/relays/clients/substrate/src/rpc.rs +++ b/bridges/relays/clients/substrate/src/rpc.rs @@ -18,7 +18,7 @@ use crate::chain::Chain; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::InstanceId; use sc_rpc_api::system::Health; use sp_core::{ @@ -51,8 +51,8 @@ jsonrpsee_proc_macros::rpc_client_api! { fn runtime_version() -> RuntimeVersion; } - pub(crate) SubstrateMessageLane { - #[rpc(method = "messageLane_proveMessages", positional_params)] + pub(crate) SubstrateMessages { + #[rpc(method = "messages_proveMessages", positional_params)] fn prove_messages( instance: InstanceId, lane: LaneId, @@ -62,7 +62,7 @@ jsonrpsee_proc_macros::rpc_client_api! { block: Option, ) -> Bytes; - #[rpc(method = "messageLane_proveMessagesDelivery", positional_params)] + #[rpc(method = "messages_proveMessagesDelivery", positional_params)] fn prove_messages_delivery( instance: InstanceId, lane: LaneId, diff --git a/bridges/relays/generic/messages/Cargo.toml b/bridges/relays/generic/messages/Cargo.toml index 427fe4829d..e5bd7efaca 100644 --- a/bridges/relays/generic/messages/Cargo.toml +++ b/bridges/relays/generic/messages/Cargo.toml @@ -15,5 +15,5 @@ parking_lot = "0.11.0" # Bridge Dependencies -bp-message-lane = { path = "../../../primitives/message-lane" } +bp-messages = { path = "../../../primitives/messages" } relay-utils = { path = "../utils" } diff --git a/bridges/relays/generic/messages/src/lib.rs b/bridges/relays/generic/messages/src/lib.rs index 99222f0e02..facb82ac8e 100644 --- a/bridges/relays/generic/messages/src/lib.rs +++ b/bridges/relays/generic/messages/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Relaying [`message-lane`](../pallet_message_lane/index.html) application specific +//! Relaying [`pallet-bridge-messages`](../pallet_bridge_messages/index.html) application specific //! data. Message lane allows sending arbitrary messages between bridged chains. This //! module provides entrypoint that starts reading messages from given message lane //! of source chain and submits proof-of-message-at-source-chain transactions to the diff --git a/bridges/relays/generic/messages/src/message_lane_loop.rs b/bridges/relays/generic/messages/src/message_lane_loop.rs index afbaf7a015..dd4cd176df 100644 --- a/bridges/relays/generic/messages/src/message_lane_loop.rs +++ b/bridges/relays/generic/messages/src/message_lane_loop.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! Message delivery loop. Designed to work with message-lane pallet. +//! Message delivery loop. Designed to work with messages pallet. //! //! Single relay instance delivers messages of single lane in single direction. //! To serve two-way lane, you would need two instances of relay. @@ -30,7 +30,7 @@ use crate::message_race_receiving::run as run_message_receiving_race; use crate::metrics::MessageLaneLoopMetrics; use async_trait::async_trait; -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState, Weight}; use futures::{channel::mpsc::unbounded, future::FutureExt, stream::StreamExt}; use relay_utils::{ interval, diff --git a/bridges/relays/generic/messages/src/message_race_delivery.rs b/bridges/relays/generic/messages/src/message_race_delivery.rs index c7e308fee1..1ee39c9c9f 100644 --- a/bridges/relays/generic/messages/src/message_race_delivery.rs +++ b/bridges/relays/generic/messages/src/message_race_delivery.rs @@ -26,7 +26,7 @@ use crate::message_race_strategy::BasicStrategy; use crate::metrics::MessageLaneLoopMetrics; use async_trait::async_trait; -use bp_message_lane::{MessageNonce, UnrewardedRelayersState, Weight}; +use bp_messages::{MessageNonce, UnrewardedRelayersState, Weight}; use futures::stream::FusedStream; use relay_utils::FailedClient; use std::{ diff --git a/bridges/relays/generic/messages/src/message_race_loop.rs b/bridges/relays/generic/messages/src/message_race_loop.rs index a11a1d7ff5..2c04466f1f 100644 --- a/bridges/relays/generic/messages/src/message_race_loop.rs +++ b/bridges/relays/generic/messages/src/message_race_loop.rs @@ -23,7 +23,7 @@ use crate::message_lane_loop::ClientState; use async_trait::async_trait; -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use futures::{ future::FutureExt, stream::{FusedStream, StreamExt}, diff --git a/bridges/relays/generic/messages/src/message_race_receiving.rs b/bridges/relays/generic/messages/src/message_race_receiving.rs index cba6ee3858..0fc025abb7 100644 --- a/bridges/relays/generic/messages/src/message_race_receiving.rs +++ b/bridges/relays/generic/messages/src/message_race_receiving.rs @@ -25,7 +25,7 @@ use crate::message_race_strategy::BasicStrategy; use crate::metrics::MessageLaneLoopMetrics; use async_trait::async_trait; -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use futures::stream::FusedStream; use relay_utils::FailedClient; use std::{marker::PhantomData, ops::RangeInclusive, time::Duration}; diff --git a/bridges/relays/generic/messages/src/message_race_strategy.rs b/bridges/relays/generic/messages/src/message_race_strategy.rs index dcbcbc4d37..fbc7877a3a 100644 --- a/bridges/relays/generic/messages/src/message_race_strategy.rs +++ b/bridges/relays/generic/messages/src/message_race_strategy.rs @@ -19,7 +19,7 @@ use crate::message_race_loop::{NoncesRange, RaceState, RaceStrategy, SourceClientNonces, TargetClientNonces}; -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use relay_utils::HeaderId; use std::{collections::VecDeque, fmt::Debug, marker::PhantomData, ops::RangeInclusive}; diff --git a/bridges/relays/generic/messages/src/metrics.rs b/bridges/relays/generic/messages/src/metrics.rs index b001d32926..3f4cbfa304 100644 --- a/bridges/relays/generic/messages/src/metrics.rs +++ b/bridges/relays/generic/messages/src/metrics.rs @@ -19,7 +19,7 @@ use crate::message_lane::MessageLane; use crate::message_lane_loop::{SourceClientState, TargetClientState}; -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use relay_utils::metrics::{register, GaugeVec, Metrics, Opts, Registry, U64}; /// Message lane relay metrics. diff --git a/bridges/relays/substrate/Cargo.toml b/bridges/relays/substrate/Cargo.toml index e9e969930d..be4f74fb3d 100644 --- a/bridges/relays/substrate/Cargo.toml +++ b/bridges/relays/substrate/Cargo.toml @@ -21,7 +21,7 @@ structopt = "0.3" bp-header-chain = { path = "../../primitives/header-chain" } bp-kusama = { path = "../../primitives/chains/kusama" } -bp-message-lane = { path = "../../primitives/message-lane" } +bp-messages = { path = "../../primitives/messages" } bp-millau = { path = "../../primitives/chains/millau" } bp-polkadot = { path = "../../primitives/chains/polkadot" } bp-runtime = { path = "../../primitives/runtime" } @@ -35,7 +35,7 @@ messages-relay = { path = "../generic/messages" } millau-runtime = { path = "../../bin/millau/runtime" } pallet-bridge-call-dispatch = { path = "../../modules/call-dispatch" } pallet-finality-verifier = { path = "../../modules/finality-verifier" } -pallet-message-lane = { path = "../../modules/message-lane" } +pallet-bridge-messages = { path = "../../modules/messages" } relay-kusama-client = { path = "../clients/kusama" } relay-millau-client = { path = "../clients/millau" } relay-polkadot-client = { path = "../clients/polkadot" } diff --git a/bridges/relays/substrate/src/cli.rs b/bridges/relays/substrate/src/cli.rs index a4296226e2..d6623b671d 100644 --- a/bridges/relays/substrate/src/cli.rs +++ b/bridges/relays/substrate/src/cli.rs @@ -16,7 +16,7 @@ //! Deal with CLI args of substrate-to-substrate relay. -use bp_message_lane::LaneId; +use bp_messages::LaneId; use codec::{Decode, Encode}; use sp_runtime::app_crypto::Ss58Codec; use structopt::{clap::arg_enum, StructOpt}; @@ -39,7 +39,7 @@ pub enum Command { RelayHeaders(RelayHeaders), /// Start messages relay between two chains. /// - /// Ties up to `MessageLane` pallets on both chains and starts relaying messages. + /// Ties up to `Messages` pallets on both chains and starts relaying messages. /// Requires the header relay to be already running. RelayMessages(RelayMessages), /// Initialize on-chain bridge pallet with current header data. @@ -48,7 +48,7 @@ pub enum Command { InitBridge(InitBridge), /// Send custom message over the bridge. /// - /// Allows interacting with the bridge by sending messages over `MessageLane` component. + /// Allows interacting with the bridge by sending messages over `Messages` component. /// The message is being sent to the source chain, delivered to the target chain and dispatched /// there. SendMessage(SendMessage), @@ -59,10 +59,10 @@ pub enum Command { EncodeCall(EncodeCall), /// Generate SCALE-encoded `MessagePayload` object that can be sent over selected bridge. /// - /// The `MessagePayload` can be then fed to `MessageLane::send_message` function and sent over + /// The `MessagePayload` can be then fed to `Messages::send_message` function and sent over /// the bridge. EncodeMessagePayload(EncodeMessagePayload), - /// Estimate Delivery and Dispatch Fee required for message submission to message lane. + /// Estimate Delivery and Dispatch Fee required for message submission to messages pallet. EstimateFee(EstimateFee), /// Given a source chain `AccountId`, derive the corresponding `AccountId` for the target chain. DeriveAccount(DeriveAccount), diff --git a/bridges/relays/substrate/src/messages_lane.rs b/bridges/relays/substrate/src/messages_lane.rs index 78b5f5c024..372b47f2a2 100644 --- a/bridges/relays/substrate/src/messages_lane.rs +++ b/bridges/relays/substrate/src/messages_lane.rs @@ -18,7 +18,7 @@ use crate::messages_source::SubstrateMessagesProof; use crate::messages_target::SubstrateMessagesReceivingProof; use async_trait::async_trait; -use bp_message_lane::MessageNonce; +use bp_messages::MessageNonce; use codec::Encode; use frame_support::weights::Weight; use messages_relay::message_lane::{MessageLane, SourceHeaderIdOf, TargetHeaderIdOf}; @@ -121,7 +121,7 @@ where /// Returns maximal number of messages and their maximal cumulative dispatch weight, based /// on given chain parameters. -pub fn select_delivery_transaction_limits( +pub fn select_delivery_transaction_limits( max_extrinsic_weight: Weight, max_unconfirmed_messages_at_inbound_lane: MessageNonce, ) -> (MessageNonce, Weight) { @@ -161,11 +161,11 @@ pub fn select_delivery_transaction_limits mod tests { use super::*; - type RialtoToMillauMessageLaneWeights = pallet_message_lane::weights::RialtoWeight; + type RialtoToMillauMessagesWeights = pallet_bridge_messages::weights::RialtoWeight; #[test] fn select_delivery_transaction_limits_works() { - let (max_count, max_weight) = select_delivery_transaction_limits::( + let (max_count, max_weight) = select_delivery_transaction_limits::( bp_millau::max_extrinsic_weight(), bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE, ); diff --git a/bridges/relays/substrate/src/messages_source.rs b/bridges/relays/substrate/src/messages_source.rs index db894df8c7..607247f8c0 100644 --- a/bridges/relays/substrate/src/messages_source.rs +++ b/bridges/relays/substrate/src/messages_source.rs @@ -21,7 +21,7 @@ use crate::messages_lane::SubstrateMessageLane; use async_trait::async_trait; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::InstanceId; use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; use codec::{Decode, Encode}; diff --git a/bridges/relays/substrate/src/messages_target.rs b/bridges/relays/substrate/src/messages_target.rs index db12be361f..ec2d751d37 100644 --- a/bridges/relays/substrate/src/messages_target.rs +++ b/bridges/relays/substrate/src/messages_target.rs @@ -22,7 +22,7 @@ use crate::messages_lane::SubstrateMessageLane; use crate::messages_source::read_client_state; use async_trait::async_trait; -use bp_message_lane::{LaneId, MessageNonce, UnrewardedRelayersState}; +use bp_messages::{LaneId, MessageNonce, UnrewardedRelayersState}; use bp_runtime::InstanceId; use bridge_runtime_common::messages::source::FromBridgedChainMessagesDeliveryProof; use codec::{Decode, Encode}; diff --git a/bridges/relays/substrate/src/rialto_millau/cli.rs b/bridges/relays/substrate/src/rialto_millau/cli.rs index 86693331de..9c89e82343 100644 --- a/bridges/relays/substrate/src/rialto_millau/cli.rs +++ b/bridges/relays/substrate/src/rialto_millau/cli.rs @@ -323,7 +323,7 @@ fn format_err(err: String) -> anyhow::Error { anyhow::anyhow!(err) } -/// MessagePayload that can be delivered to message lane pallet on Millau. +/// MessagePayload that can be delivered to messages pallet on Millau. #[derive(StructOpt, Debug)] pub enum MillauToRialtoMessagePayload { /// Raw, SCALE-encoded `MessagePayload`. @@ -342,7 +342,7 @@ pub enum MillauToRialtoMessagePayload { }, } -/// MessagePayload that can be delivered to message lane pallet on Rialto. +/// MessagePayload that can be delivered to messages pallet on Rialto. #[derive(StructOpt, Debug)] pub enum RialtoToMillauMessagePayload { /// Raw, SCALE-encoded `MessagePayload`. @@ -384,12 +384,12 @@ pub enum ToRialtoMessage { #[structopt(long)] amount: bp_rialto::Balance, }, - /// A call to the Millau Bridge Message Lane pallet to send a message over the bridge. + /// A call to the Millau Bridge Messages pallet to send a message over the bridge. MillauSendMessage { /// Hex-encoded lane id that should be served by the relay. Defaults to `00000000`. #[structopt(long, default_value = "00000000")] lane: HexLaneId, - /// Raw SCALE-encoded Message Payload to submit to the message lane pallet. + /// Raw SCALE-encoded Message Payload to submit to the messages pallet. #[structopt(long)] payload: HexBytes, /// Declared delivery and dispatch fee in base source-chain currency units. @@ -421,12 +421,12 @@ pub enum ToMillauMessage { #[structopt(long)] amount: bp_millau::Balance, }, - /// A call to the Rialto Bridge Message Lane pallet to send a message over the bridge. + /// A call to the Rialto Bridge Messages pallet to send a message over the bridge. RialtoSendMessage { /// Hex-encoded lane id that should be served by the relay. Defaults to `00000000`. #[structopt(long, default_value = "00000000")] lane: HexLaneId, - /// Raw SCALE-encoded Message Payload to submit to the message lane pallet. + /// Raw SCALE-encoded Message Payload to submit to the messages pallet. #[structopt(long)] payload: HexBytes, /// Declared delivery and dispatch fee in base source-chain currency units. diff --git a/bridges/relays/substrate/src/rialto_millau/millau_messages_to_rialto.rs b/bridges/relays/substrate/src/rialto_millau/millau_messages_to_rialto.rs index 08a0fe9c08..5b6d080d5a 100644 --- a/bridges/relays/substrate/src/rialto_millau/millau_messages_to_rialto.rs +++ b/bridges/relays/substrate/src/rialto_millau/millau_messages_to_rialto.rs @@ -22,7 +22,7 @@ use crate::messages_source::SubstrateMessagesSource; use crate::messages_target::SubstrateMessagesTarget; use async_trait::async_trait; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::{MILLAU_BRIDGE_INSTANCE, RIALTO_BRIDGE_INSTANCE}; use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; use codec::Encode; @@ -66,7 +66,7 @@ impl SubstrateMessageLane for MillauMessagesToRialto { let account_id = self.source_sign.signer.public().as_array_ref().clone().into(); let nonce = self.source_client.next_account_index(account_id).await?; let call: millau_runtime::Call = - millau_runtime::MessageLaneCall::receive_messages_delivery_proof(proof, relayers_state).into(); + millau_runtime::MessagesCall::receive_messages_delivery_proof(proof, relayers_state).into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.source_client.genesis_hash(); let transaction = Millau::sign_transaction(genesis_hash, &self.source_sign.signer, nonce, call); @@ -96,7 +96,7 @@ impl SubstrateMessageLane for MillauMessagesToRialto { let messages_count = nonces_end - nonces_start + 1; let account_id = self.target_sign.signer.public().as_array_ref().clone().into(); let nonce = self.target_client.next_account_index(account_id).await?; - let call: rialto_runtime::Call = rialto_runtime::MessageLaneCall::receive_messages_proof( + let call: rialto_runtime::Call = rialto_runtime::MessagesCall::receive_messages_proof( self.relayer_id_at_source.clone(), proof, messages_count as _, @@ -148,7 +148,7 @@ pub async fn run( let max_messages_size_in_single_batch = bp_rialto::max_extrinsic_size() as usize / 3; // TODO: use Millau weights after https://github.com/paritytech/parity-bridges-common/issues/390 let (max_messages_in_single_batch, max_messages_weight_in_single_batch) = - select_delivery_transaction_limits::>( + select_delivery_transaction_limits::>( bp_rialto::max_extrinsic_weight(), bp_rialto::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE, ); diff --git a/bridges/relays/substrate/src/rialto_millau/mod.rs b/bridges/relays/substrate/src/rialto_millau/mod.rs index 45ef7e322a..82402d71d4 100644 --- a/bridges/relays/substrate/src/rialto_millau/mod.rs +++ b/bridges/relays/substrate/src/rialto_millau/mod.rs @@ -261,9 +261,9 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> { }) .await?; - let millau_call = millau_runtime::Call::BridgeRialtoMessageLane( - millau_runtime::MessageLaneCall::send_message(lane, payload, fee), - ); + let millau_call = millau_runtime::Call::BridgeRialtoMessages(millau_runtime::MessagesCall::send_message( + lane, payload, fee, + )); let signed_millau_call = Millau::sign_transaction( *millau_client.genesis_hash(), @@ -317,9 +317,9 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> { }) .await?; - let rialto_call = rialto_runtime::Call::BridgeMillauMessageLane( - rialto_runtime::MessageLaneCall::send_message(lane, payload, fee), - ); + let rialto_call = rialto_runtime::Call::BridgeMillauMessages(rialto_runtime::MessagesCall::send_message( + lane, payload, fee, + )); let signed_rialto_call = Rialto::sign_transaction( *rialto_client.genesis_hash(), @@ -442,7 +442,7 @@ async fn run_derive_account(cmd: cli::DeriveAccount) -> Result<(), String> { async fn estimate_message_delivery_and_dispatch_fee( client: &relay_substrate_client::Client, estimate_fee_method: &str, - lane: bp_message_lane::LaneId, + lane: bp_messages::LaneId, payload: P, ) -> Result, relay_substrate_client::Error> { let encoded_response = client @@ -747,7 +747,7 @@ impl cli::ToRialtoMessage { cli::ToRialtoMessage::MillauSendMessage { lane, payload, fee } => { let payload = cli::RialtoToMillauMessagePayload::Raw { data: payload }.into_payload()?; let lane = lane.into(); - rialto_runtime::Call::BridgeMillauMessageLane(rialto_runtime::MessageLaneCall::send_message( + rialto_runtime::Call::BridgeMillauMessages(rialto_runtime::MessagesCall::send_message( lane, payload, fee, )) } @@ -784,7 +784,7 @@ impl cli::ToMillauMessage { cli::ToMillauMessage::RialtoSendMessage { lane, payload, fee } => { let payload = cli::MillauToRialtoMessagePayload::Raw { data: payload }.into_payload()?; let lane = lane.into(); - millau_runtime::Call::BridgeRialtoMessageLane(millau_runtime::MessageLaneCall::send_message( + millau_runtime::Call::BridgeRialtoMessages(millau_runtime::MessagesCall::send_message( lane, payload, fee, )) } @@ -801,7 +801,7 @@ impl cli::ToMillauMessage { #[cfg(test)] mod tests { use super::*; - use bp_message_lane::source_chain::TargetHeaderChain; + use bp_messages::source_chain::TargetHeaderChain; use sp_core::Pair; use sp_runtime::traits::{IdentifyAccount, Verify}; diff --git a/bridges/relays/substrate/src/rialto_millau/rialto_messages_to_millau.rs b/bridges/relays/substrate/src/rialto_millau/rialto_messages_to_millau.rs index b0ce256aa7..df94c25f3c 100644 --- a/bridges/relays/substrate/src/rialto_millau/rialto_messages_to_millau.rs +++ b/bridges/relays/substrate/src/rialto_millau/rialto_messages_to_millau.rs @@ -22,7 +22,7 @@ use crate::messages_source::SubstrateMessagesSource; use crate::messages_target::SubstrateMessagesTarget; use async_trait::async_trait; -use bp_message_lane::{LaneId, MessageNonce}; +use bp_messages::{LaneId, MessageNonce}; use bp_runtime::{MILLAU_BRIDGE_INSTANCE, RIALTO_BRIDGE_INSTANCE}; use bridge_runtime_common::messages::target::FromBridgedChainMessagesProof; use codec::Encode; @@ -66,7 +66,7 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { let account_id = self.source_sign.signer.public().as_array_ref().clone().into(); let nonce = self.source_client.next_account_index(account_id).await?; let call: rialto_runtime::Call = - rialto_runtime::MessageLaneCall::receive_messages_delivery_proof(proof, relayers_state).into(); + rialto_runtime::MessagesCall::receive_messages_delivery_proof(proof, relayers_state).into(); let call_weight = call.get_dispatch_info().weight; let genesis_hash = *self.source_client.genesis_hash(); let transaction = Rialto::sign_transaction(genesis_hash, &self.source_sign.signer, nonce, call); @@ -96,7 +96,7 @@ impl SubstrateMessageLane for RialtoMessagesToMillau { let messages_count = nonces_end - nonces_start + 1; let account_id = self.target_sign.signer.public().as_array_ref().clone().into(); let nonce = self.target_client.next_account_index(account_id).await?; - let call: millau_runtime::Call = millau_runtime::MessageLaneCall::receive_messages_proof( + let call: millau_runtime::Call = millau_runtime::MessagesCall::receive_messages_proof( self.relayer_id_at_source.clone(), proof, messages_count as _, @@ -147,7 +147,7 @@ pub async fn run( // 2/3 is reserved for proofs and tx overhead let max_messages_size_in_single_batch = bp_millau::max_extrinsic_size() as usize / 3; let (max_messages_in_single_batch, max_messages_weight_in_single_batch) = - select_delivery_transaction_limits::>( + select_delivery_transaction_limits::>( bp_millau::max_extrinsic_weight(), bp_millau::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE, );