From 8d122b03f1d9a074962bf11a6f4ab66d50f6a508 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 23 Mar 2021 11:37:41 -0400 Subject: [PATCH] Rename Finality Verifier and Call Dispatch Pallets (#838) * Rename `pallet-finality-verifier` to `pallet-bridge-grandpa` * Missed some CamelCase ones * Update logging target in GRANDPA pallet * Rename `pallet-bridge-call-dispatch` to `pallet-bridge-dispatch` * Rename the dispatch pallet folder * Update logging target in Dispatch pallet * Missed a couple * Format the repo * Stop listing individual pallets in Compose logs * Use correct pallet name in module doc comments * Add `pallet-bridge-dispatch` to README project layout * Sort crate names in TOML files * Rename `pallet-bridge-grandpa` runtime Call alias --- bridges/README.md | 3 +- bridges/bin/millau/node/src/chain_spec.rs | 4 +- bridges/bin/millau/runtime/Cargo.toml | 20 +++--- bridges/bin/millau/runtime/src/lib.rs | 30 ++++---- .../bin/millau/runtime/src/rialto_messages.rs | 2 +- bridges/bin/rialto/runtime/Cargo.toml | 18 ++--- bridges/bin/rialto/runtime/src/lib.rs | 22 +++--- .../bin/rialto/runtime/src/millau_messages.rs | 2 +- bridges/bin/runtime-common/Cargo.toml | 10 +-- bridges/bin/runtime-common/README.md | 12 ++-- bridges/bin/runtime-common/src/messages.rs | 70 +++++++++---------- .../src/messages_benchmarking.rs | 8 +-- bridges/docs/high-level-overview.md | 4 +- .../{call-dispatch => dispatch}/Cargo.toml | 2 +- .../{call-dispatch => dispatch}/README.md | 6 +- .../{call-dispatch => dispatch}/src/lib.rs | 40 ++++++----- .../{finality-verifier => grandpa}/Cargo.toml | 2 +- .../{finality-verifier => grandpa}/src/lib.rs | 18 ++--- .../src/mock.rs | 6 +- bridges/primitives/runtime/src/lib.rs | 2 +- bridges/relays/bin-substrate/Cargo.toml | 4 +- .../bin-substrate/src/headers_initialize.rs | 6 +- .../rialto_millau/millau_headers_to_rialto.rs | 2 +- .../bin-substrate/src/rialto_millau/mod.rs | 24 +++---- .../rialto_millau/rialto_headers_to_millau.rs | 4 +- .../westend_headers_to_millau.rs | 4 +- 26 files changed, 165 insertions(+), 160 deletions(-) rename bridges/modules/{call-dispatch => dispatch}/Cargo.toml (97%) rename bridges/modules/{call-dispatch => dispatch}/README.md (93%) rename bridges/modules/{call-dispatch => dispatch}/src/lib.rs (95%) rename bridges/modules/{finality-verifier => grandpa}/Cargo.toml (98%) rename bridges/modules/{finality-verifier => grandpa}/src/lib.rs (97%) rename bridges/modules/{finality-verifier => grandpa}/src/mock.rs (96%) diff --git a/bridges/README.md b/bridges/README.md index 7258eb6c5d..c122b8af6d 100644 --- a/bridges/README.md +++ b/bridges/README.md @@ -86,8 +86,9 @@ 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 +│ ├── grandpa // On-Chain GRANDPA Light Client │ ├── messages // Cross Chain Message Passing +│ ├── dispatch // Target Chain Message Execution │ └── ... ├── primitives // Code shared between modules, runtimes, and relays │ └── ... diff --git a/bridges/bin/millau/node/src/chain_spec.rs b/bridges/bin/millau/node/src/chain_spec.rs index a9f977f637..22f1827e35 100644 --- a/bridges/bin/millau/node/src/chain_spec.rs +++ b/bridges/bin/millau/node/src/chain_spec.rs @@ -16,7 +16,7 @@ use bp_millau::derive_account_from_rialto_id; use millau_runtime::{ - AccountId, AuraConfig, BalancesConfig, BridgeRialtoConfig, BridgeWestendFinalityVerifierConfig, GenesisConfig, + AccountId, AuraConfig, BalancesConfig, BridgeRialtoConfig, BridgeWestendGrandpaConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, }; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -179,7 +179,7 @@ fn testnet_genesis( .map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone()))) .collect::>(), }), - pallet_finality_verifier_Instance1: Some(BridgeWestendFinalityVerifierConfig { + pallet_bridge_grandpa_Instance1: Some(BridgeWestendGrandpaConfig { // for our deployments to avoid multiple same-nonces transactions: // //Alice is already used to initialize Rialto<->Millau bridge // => let's use //George to initialize Westend->Millau bridge diff --git a/bridges/bin/millau/runtime/Cargo.toml b/bridges/bin/millau/runtime/Cargo.toml index 8dc08d3336..a1406d69d8 100644 --- a/bridges/bin/millau/runtime/Cargo.toml +++ b/bridges/bin/millau/runtime/Cargo.toml @@ -21,9 +21,9 @@ bp-rialto = { path = "../../../primitives/chain-rialto", default-features = fals bp-runtime = { path = "../../../primitives/runtime", default-features = false } bp-westend = { path = "../../../primitives/chain-westend", default-features = false } bridge-runtime-common = { path = "../../runtime-common", default-features = false } -pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default-features = false } +pallet-bridge-dispatch = { path = "../../../modules/dispatch", default-features = false } +pallet-bridge-grandpa = { path = "../../../modules/grandpa", default-features = false } pallet-bridge-messages = { path = "../../../modules/messages", default-features = false } -pallet-finality-verifier = { path = "../../../modules/finality-verifier", default-features = false } pallet-shift-session-manager = { path = "../../../modules/shift-session-manager", default-features = false } pallet-substrate-bridge = { path = "../../../modules/substrate", default-features = false } @@ -46,8 +46,8 @@ sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" , sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" , default-features = false } @@ -72,29 +72,29 @@ std = [ "codec/std", "frame-executive/std", "frame-support/std", - "frame-system/std", "frame-system-rpc-runtime-api/std", + "frame-system/std", "pallet-aura/std", "pallet-balances/std", - "pallet-bridge-call-dispatch/std", - "pallet-finality-verifier/std", - "pallet-grandpa/std", + "pallet-bridge-dispatch/std", + "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", + "pallet-grandpa/std", "pallet-randomness-collective-flip/std", - "pallet-shift-session-manager/std", "pallet-session/std", + "pallet-shift-session-manager/std", "pallet-substrate-bridge/std", "pallet-sudo/std", "pallet-timestamp/std", - "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", "serde", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", "sp-core/std", - "sp-inherents/std", "sp-finality-grandpa/std", + "sp-inherents/std", "sp-offchain/std", "sp-runtime/std", "sp-session/std", diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index f9c534bf56..693543fa1c 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_grandpa::Call as BridgeGrandpaRialtoCall; +pub use pallet_bridge_grandpa::Call as BridgeGrandpaWestendCall; 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_substrate_bridge::Call as BridgeRialtoCall; pub use pallet_sudo::Call as SudoCall; pub use pallet_timestamp::Call as TimestampCall; @@ -207,7 +207,7 @@ impl frame_system::Config for Runtime { impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; } -impl pallet_bridge_call_dispatch::Config for Runtime { +impl pallet_bridge_dispatch::Config for Runtime { type Event = Event; type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; @@ -313,14 +313,14 @@ parameter_types! { pub const MaxRequests: u32 = 50; } -pub type RialtoFinalityVerifierInstance = (); -impl pallet_finality_verifier::Config for Runtime { +pub type RialtoGrandpaInstance = (); +impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_rialto::Rialto; type MaxRequests = MaxRequests; } -pub type WestendFinalityVerifierInstance = pallet_finality_verifier::Instance1; -impl pallet_finality_verifier::Config for Runtime { +pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1; +impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_westend::Westend; type MaxRequests = MaxRequests; } @@ -378,9 +378,9 @@ construct_runtime!( { BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config}, 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, Config}, + BridgeDispatch: pallet_bridge_dispatch::{Module, Event}, + BridgeRialtoGrandpa: pallet_bridge_grandpa::{Module, Call}, + BridgeWestendGrandpa: pallet_bridge_grandpa::::{Module, Call, Config}, System: frame_system::{Module, Call, Config, Storage, Event}, RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, @@ -581,23 +581,23 @@ impl_runtime_apis! { impl bp_rialto::RialtoFinalityApi for Runtime { fn best_finalized() -> (bp_rialto::BlockNumber, bp_rialto::Hash) { - let header = BridgeRialtoFinalityVerifier::best_finalized(); + let header = BridgeRialtoGrandpa::best_finalized(); (header.number, header.hash()) } fn is_known_header(hash: bp_rialto::Hash) -> bool { - BridgeRialtoFinalityVerifier::is_known_header(hash) + BridgeRialtoGrandpa::is_known_header(hash) } } impl bp_westend::WestendFinalityApi for Runtime { fn best_finalized() -> (bp_westend::BlockNumber, bp_westend::Hash) { - let header = BridgeWestendFinalityVerifier::best_finalized(); + let header = BridgeWestendGrandpa::best_finalized(); (header.number, header.hash()) } fn is_known_header(hash: bp_westend::Hash) -> bool { - BridgeWestendFinalityVerifier::is_known_header(hash) + BridgeWestendGrandpa::is_known_header(hash) } } @@ -666,7 +666,7 @@ where AccountId: codec::Encode, SpecVersion: codec::Encode, { - pallet_bridge_call_dispatch::account_ownership_digest( + pallet_bridge_dispatch::account_ownership_digest( rialto_call, millau_account_id, rialto_spec_version, diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index 48908432b6..842fcdf6c0 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -84,7 +84,7 @@ type ToRialtoMessagesDeliveryProof = messages::source::FromBridgedChainMessagesD pub type FromRialtoMessageDispatch = messages::target::FromBridgedChainMessageDispatch< WithRialtoMessageBridge, crate::Runtime, - pallet_bridge_call_dispatch::DefaultInstance, + pallet_bridge_dispatch::DefaultInstance, >; /// Millau <-> Rialto message bridge. diff --git a/bridges/bin/rialto/runtime/Cargo.toml b/bridges/bin/rialto/runtime/Cargo.toml index 3824f9cbc5..74365eec89 100644 --- a/bridges/bin/rialto/runtime/Cargo.toml +++ b/bridges/bin/rialto/runtime/Cargo.toml @@ -25,13 +25,13 @@ bp-millau = { path = "../../../primitives/chain-millau", default-features = fals bp-rialto = { path = "../../../primitives/chain-rialto", default-features = false } bp-runtime = { path = "../../../primitives/runtime", default-features = false } bridge-runtime-common = { path = "../../runtime-common", default-features = false } -pallet-bridge-eth-poa = { path = "../../../modules/ethereum", default-features = false } -pallet-bridge-call-dispatch = { path = "../../../modules/call-dispatch", default-features = false } 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-bridge-dispatch = { path = "../../../modules/dispatch", default-features = false } +pallet-bridge-eth-poa = { path = "../../../modules/ethereum", default-features = false } +pallet-bridge-grandpa = { path = "../../../modules/grandpa", 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 } # Substrate Dependencies @@ -92,19 +92,19 @@ std = [ "log/std", "pallet-aura/std", "pallet-balances/std", - "pallet-bridge-eth-poa/std", - "pallet-bridge-call-dispatch/std", "pallet-bridge-currency-exchange/std", - "pallet-finality-verifier/std", - "pallet-grandpa/std", + "pallet-bridge-dispatch/std", + "pallet-bridge-eth-poa/std", + "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", + "pallet-grandpa/std", "pallet-randomness-collective-flip/std", "pallet-shift-session-manager/std", "pallet-substrate-bridge/std", "pallet-sudo/std", "pallet-timestamp/std", - "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", "serde", "sp-api/std", "sp-block-builder/std", diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 4aa8126900..dcbb3510e1 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_grandpa::Call as BridgeGrandpaMillauCall; pub use pallet_bridge_messages::Call as MessagesCall; -pub use pallet_finality_verifier::Call as FinalityBridgeMillauCall; pub use pallet_substrate_bridge::Call as BridgeMillauCall; pub use pallet_sudo::Call as SudoCall; pub use pallet_timestamp::Call as TimestampCall; @@ -257,7 +257,7 @@ impl pallet_bridge_currency_exchange::Config for Runtime type DepositInto = DepositInto; } -impl pallet_bridge_call_dispatch::Config for Runtime { +impl pallet_bridge_dispatch::Config for Runtime { type Event = Event; type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce); type Call = Call; @@ -419,7 +419,7 @@ parameter_types! { pub const MaxRequests: u32 = 50; } -impl pallet_finality_verifier::Config for Runtime { +impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_millau::Millau; type MaxRequests = MaxRequests; } @@ -480,8 +480,8 @@ construct_runtime!( BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::::{Module, Call}, BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::::{Module, Call}, BridgeMillau: pallet_substrate_bridge::{Module, Call, Storage, Config}, - BridgeFinalityVerifier: pallet_finality_verifier::{Module, Call}, - BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event}, + BridgeGrandpa: pallet_bridge_grandpa::{Module, Call}, + BridgeDispatch: pallet_bridge_dispatch::{Module, 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}, @@ -643,12 +643,12 @@ impl_runtime_apis! { impl bp_millau::MillauFinalityApi for Runtime { fn best_finalized() -> (bp_millau::BlockNumber, bp_millau::Hash) { - let header = BridgeFinalityVerifier::best_finalized(); + let header = BridgeGrandpa::best_finalized(); (header.number, header.hash()) } fn is_known_header(hash: bp_millau::Hash) -> bool { - BridgeFinalityVerifier::is_known_header(hash) + BridgeGrandpa::is_known_header(hash) } } @@ -890,7 +890,7 @@ impl_runtime_apis! { params: MessageParams, ) -> (millau_messages::ToMillauMessagePayload, Balance) { let message_payload = vec![0; params.size as usize]; - let dispatch_origin = pallet_bridge_call_dispatch::CallOrigin::SourceAccount( + let dispatch_origin = pallet_bridge_dispatch::CallOrigin::SourceAccount( params.sender_account, ); @@ -959,10 +959,10 @@ impl_runtime_apis! { make_millau_outbound_lane_data_key, make_millau_header, call_weight, - pallet_bridge_call_dispatch::MessagePayload { + pallet_bridge_dispatch::MessagePayload { spec_version: VERSION.spec_version, weight: call_weight, - origin: pallet_bridge_call_dispatch::CallOrigin::< + origin: pallet_bridge_dispatch::CallOrigin::< bp_millau::AccountId, MultiSigner, Signature, @@ -1040,7 +1040,7 @@ where AccountId: codec::Encode, SpecVersion: codec::Encode, { - pallet_bridge_call_dispatch::account_ownership_digest( + pallet_bridge_dispatch::account_ownership_digest( millau_call, rialto_account_id, millau_spec_version, diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index 8b0aaea994..2cd7d787ea 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -78,7 +78,7 @@ pub type FromMillauEncodedCall = messages::target::FromBridgedChainEncodedMessag pub type FromMillauMessageDispatch = messages::target::FromBridgedChainMessageDispatch< WithMillauMessageBridge, crate::Runtime, - pallet_bridge_call_dispatch::DefaultInstance, + pallet_bridge_dispatch::DefaultInstance, >; /// Messages proof for Millau -> Rialto messages. diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml index 2bbf942180..83803d06de 100644 --- a/bridges/bin/runtime-common/Cargo.toml +++ b/bridges/bin/runtime-common/Cargo.toml @@ -17,9 +17,9 @@ hash-db = { version = "0.15.2", default-features = false } bp-message-dispatch = { path = "../../primitives/message-dispatch", 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-bridge-dispatch = { path = "../../modules/dispatch", default-features = false } +pallet-bridge-grandpa = { path = "../../modules/grandpa", default-features = false } pallet-bridge-messages = { path = "../../modules/messages", default-features = false } -pallet-finality-verifier = { path = "../../modules/finality-verifier", default-features = false } # Substrate dependencies @@ -39,8 +39,8 @@ std = [ "codec/std", "frame-support/std", "hash-db/std", - "pallet-bridge-call-dispatch/std", - "pallet-finality-verifier/std", + "pallet-bridge-dispatch/std", + "pallet-bridge-grandpa/std", "pallet-bridge-messages/std", "sp-core/std", "sp-runtime/std", @@ -50,7 +50,7 @@ std = [ ] runtime-benchmarks = [ "ed25519-dalek/u64_backend", - "pallet-finality-verifier/runtime-benchmarks", + "pallet-bridge-grandpa/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 90ebc8976d..b375f48309 100644 --- a/bridges/bin/runtime-common/README.md +++ b/bridges/bin/runtime-common/README.md @@ -4,11 +4,11 @@ The [`messages`](./src/messages.rs) module of this crate contains a bunch of hel 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 [messages module](../../modules/messages/README.md), Substrate bridge - module and the [call dispatch module](../../modules/call-dispatch/README.md); + module and the [call dispatch module](../../modules/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 + [call dispatch module](../../modules/dispatch/README.md); +- the messages are `pallet_bridge_dispatch::MessagePayload` structures, where `call` field is encoded `Call` of the target chain. This means that the `Call` is opaque to the [messages module](../../modules/messages/README.md) instance at the source chain. It is pre-encoded by the message submitter; @@ -118,7 +118,7 @@ are: `maximal_message_size`, `verify_chain_message`, `verify_messages_delivery_p `estimate_message_dispatch_and_delivery_fee`. `FromThisChainMessagePayload` is a message that the sender sends through our bridge. It is the -`pallet_bridge_call_dispatch::MessagePayload`, where `call` field is encoded target chain call. So +`pallet_bridge_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_messages::LaneMessageVerifier`. It @@ -131,8 +131,8 @@ has following checks in its `verify_message` method: 1. it'll reject a message if it has the wrong dispatch origin declared. Like if the submitter is not the root of this chain, but it tries to dispatch the message at the target chain using - `pallet_bridge_call_dispatch::CallOrigin::SourceRoot` origin. Or he has provided wrong signature - in the `pallet_bridge_call_dispatch::CallOrigin::TargetAccount` origin; + `pallet_bridge_dispatch::CallOrigin::SourceRoot` origin. Or he has provided wrong signature + in the `pallet_bridge_dispatch::CallOrigin::TargetAccount` origin; 1. it'll reject a message if the delivery and dispatch fee that the submitter wants to pay is lesser than the fee that is computed using the `estimate_message_dispatch_and_delivery_fee` function. diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 26c087ac69..c25f7091d9 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -54,7 +54,7 @@ pub trait MessageBridge { fn bridged_balance_to_this_balance(bridged_balance: BalanceOf>) -> BalanceOf>; } -/// Chain that has `pallet-bridge-messages` and `call-dispatch` modules. +/// Chain that has `pallet-bridge-messages` and `dispatch` modules. pub trait ChainWithMessages { /// Hash used in the chain. type Hash: Decode; @@ -85,7 +85,7 @@ pub struct MessageTransaction { pub size: u32, } -/// This chain that has `pallet-bridge-messages` and `call-dispatch` modules. +/// This chain that has `pallet-bridge-messages` and `dispatch` modules. pub trait ThisChainWithMessages: ChainWithMessages { /// Call type on the chain. type Call: Encode + Decode; @@ -105,7 +105,7 @@ pub trait ThisChainWithMessages: ChainWithMessages { fn transaction_payment(transaction: MessageTransaction>) -> BalanceOf; } -/// Bridged chain that has `pallet-bridge-messages` and `call-dispatch` modules. +/// Bridged chain that has `pallet-bridge-messages` and `dispatch` modules. pub trait BridgedChainWithMessages: ChainWithMessages { /// Maximal extrinsic size at Bridged chain. fn maximal_extrinsic_size() -> u32; @@ -180,7 +180,7 @@ pub mod source { pub type BridgedChainOpaqueCall = Vec; /// Message payload for This -> Bridged chain messages. - pub type FromThisChainMessagePayload = pallet_bridge_call_dispatch::MessagePayload< + pub type FromThisChainMessagePayload = pallet_bridge_dispatch::MessagePayload< AccountIdOf>, SignerOf>, SignatureOf>, @@ -221,7 +221,7 @@ pub mod source { /// This verifier assumes following: /// /// - all message lanes are equivalent, so all checks are the same; - /// - messages are being dispatched using `pallet-bridge-call-dispatch` pallet on the target chain. + /// - messages are being dispatched using `pallet-bridge-dispatch` pallet on the target chain. /// /// Following checks are made: /// @@ -267,8 +267,8 @@ pub mod source { } // Do the dispatch-specific check. We assume that the target chain uses - // `CallDispatch`, so we verify the message accordingly. - pallet_bridge_call_dispatch::verify_message_origin(submitter, payload).map_err(|_| BAD_ORIGIN)?; + // `Dispatch`, so we verify the message accordingly. + pallet_bridge_dispatch::verify_message_origin(submitter, payload).map_err(|_| BAD_ORIGIN)?; let minimal_fee_in_this_tokens = estimate_message_dispatch_and_delivery_fee::(payload, B::RELAYER_FEE_PERCENT)?; @@ -356,17 +356,16 @@ pub mod source { proof: FromBridgedChainMessagesDeliveryProof>>, ) -> Result, &'static str> where - ThisRuntime: pallet_finality_verifier::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: - Into::BridgedChain>>, + HashOf>: Into::BridgedChain>>, { let FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane, } = proof; - pallet_finality_verifier::Module::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Module::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(storage_proof), |storage| { @@ -395,14 +394,14 @@ pub mod target { use super::*; /// Call origin for Bridged -> This chain messages. - pub type FromBridgedChainMessageCallOrigin = pallet_bridge_call_dispatch::CallOrigin< + pub type FromBridgedChainMessageCallOrigin = pallet_bridge_dispatch::CallOrigin< AccountIdOf>, SignerOf>, SignatureOf>, >; /// Decoded Bridged -> This message payload. - pub type FromBridgedChainMessagePayload = pallet_bridge_call_dispatch::MessagePayload< + pub type FromBridgedChainMessagePayload = pallet_bridge_dispatch::MessagePayload< AccountIdOf>, SignerOf>, SignatureOf>, @@ -457,19 +456,19 @@ pub mod target { /// Dispatching Bridged -> This chain messages. #[derive(RuntimeDebug, Clone, Copy)] - pub struct FromBridgedChainMessageDispatch { - _marker: PhantomData<(B, ThisRuntime, ThisCallDispatchInstance)>, + pub struct FromBridgedChainMessageDispatch { + _marker: PhantomData<(B, ThisRuntime, ThisDispatchInstance)>, } - impl + impl MessageDispatch< as ChainWithMessages>::Balance> - for FromBridgedChainMessageDispatch + for FromBridgedChainMessageDispatch where - ThisCallDispatchInstance: frame_support::traits::Instance, - ThisRuntime: pallet_bridge_call_dispatch::Config, - >::Event: - From>, - pallet_bridge_call_dispatch::Module: + ThisDispatchInstance: frame_support::traits::Instance, + ThisRuntime: pallet_bridge_dispatch::Config, + >::Event: + From>, + pallet_bridge_dispatch::Module: bp_message_dispatch::MessageDispatch<(LaneId, MessageNonce), Message = FromBridgedChainMessagePayload>, { type DispatchPayload = FromBridgedChainMessagePayload; @@ -482,7 +481,7 @@ pub mod target { fn dispatch(message: DispatchMessage>>) { let message_id = (message.key.lane_id, message.key.nonce); - pallet_bridge_call_dispatch::Module::::dispatch( + pallet_bridge_dispatch::Module::::dispatch( B::INSTANCE, message_id, message.data.payload.map_err(drop), @@ -510,16 +509,15 @@ pub mod target { messages_count: u32, ) -> Result>>>, &'static str> where - ThisRuntime: pallet_finality_verifier::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: - Into::BridgedChain>>, + HashOf>: Into::BridgedChain>>, { verify_messages_proof_with_parser::( proof, messages_count, |bridged_header_hash, bridged_storage_proof| { - pallet_finality_verifier::Module::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Module::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(bridged_storage_proof), |storage_adapter| storage_adapter, @@ -931,7 +929,7 @@ mod tests { let message_on_bridged_chain = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: ThisChainCall::Transfer.encode(), } .encode(); @@ -945,7 +943,7 @@ mod tests { target::FromBridgedChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: target::FromBridgedChainEncodedMessageCall:: { encoded_call: ThisChainCall::Transfer.encode(), _marker: PhantomData::default(), @@ -962,7 +960,7 @@ mod tests { source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![42], } } @@ -1012,7 +1010,7 @@ mod tests { let payload = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![42], }; @@ -1055,7 +1053,7 @@ mod tests { let payload = source::FromThisChainMessagePayload:: { spec_version: 1, weight: 100, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceAccount(ThisChainAccountId(1)), + origin: pallet_bridge_dispatch::CallOrigin::SourceAccount(ThisChainAccountId(1)), call: vec![42], }; @@ -1122,7 +1120,7 @@ mod tests { > { spec_version: 1, weight: 5, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![1, 2, 3, 4, 5, 6], },) .is_err() @@ -1137,7 +1135,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT + 1, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![1, 2, 3, 4, 5, 6], },) .is_err() @@ -1152,7 +1150,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![0; source::maximal_message_size::() as usize + 1], },) .is_err() @@ -1167,7 +1165,7 @@ mod tests { > { spec_version: 1, weight: BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT, - origin: pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + origin: pallet_bridge_dispatch::CallOrigin::SourceRoot, call: vec![0; source::maximal_message_size::() as _], },), Ok(()), diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs index 39d3ec9262..5694b9a05c 100644 --- a/bridges/bin/runtime-common/src/messages_benchmarking.rs +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -73,7 +73,7 @@ pub fn prepare_message_proof( where B: MessageBridge, H: Hasher, - R: pallet_finality_verifier::Config, + R: pallet_bridge_grandpa::Config, FI: 'static, ::Hash: Into>>, MM: Fn(MessageKey) -> Vec, @@ -130,7 +130,7 @@ where // prepare Bridged chain header and insert it into the Substrate pallet let bridged_header = make_bridged_header(root); let bridged_header_hash = bridged_header.hash(); - pallet_finality_verifier::initialize_for_benchmarks::(bridged_header); + pallet_bridge_grandpa::initialize_for_benchmarks::(bridged_header); ( FromBridgedChainMessagesProof { @@ -155,7 +155,7 @@ pub fn prepare_message_delivery_proof( where B: MessageBridge, H: Hasher, - R: pallet_finality_verifier::Config, + R: pallet_bridge_grandpa::Config, FI: 'static, ::Hash: Into>>, ML: Fn(LaneId) -> Vec, @@ -183,7 +183,7 @@ where // prepare Bridged chain header and insert it into the Substrate pallet let bridged_header = make_bridged_header(root); let bridged_header_hash = bridged_header.hash(); - pallet_finality_verifier::initialize_for_benchmarks::(bridged_header); + pallet_bridge_grandpa::initialize_for_benchmarks::(bridged_header); FromBridgedChainMessagesDeliveryProof { bridged_header_hash: bridged_header_hash.into(), diff --git a/bridges/docs/high-level-overview.md b/bridges/docs/high-level-overview.md index e7dba6c65c..14b1eee6d4 100644 --- a/bridges/docs/high-level-overview.md +++ b/bridges/docs/high-level-overview.md @@ -131,7 +131,7 @@ require bi-directional header sync (i.e. you can't use message delivery with one #### Dispatching Messages -The [Message dispatch pallet](../modules/call-dispatch/src/lib.rs) is used to perform the actions +The [Message dispatch pallet](../modules/dispatch/src/lib.rs) is used to perform the actions specified by messages which have come over the bridge. For Substrate-based chains this means interpreting the source chain's message as a `Call` on the target chain. @@ -172,6 +172,6 @@ source chain needs to prove ownership of this account by using their target chai sign: `(Call, SourceChainAccountId).encode()`. This will be included in the message payload and verified by the target chain before dispatch. -See [`CallOrigin` documentation](../modules/call-dispatch/src/lib.rs) for more details. +See [`CallOrigin` documentation](../modules/dispatch/src/lib.rs) for more details. #### Message Relayers Strategy diff --git a/bridges/modules/call-dispatch/Cargo.toml b/bridges/modules/dispatch/Cargo.toml similarity index 97% rename from bridges/modules/call-dispatch/Cargo.toml rename to bridges/modules/dispatch/Cargo.toml index 3c5fb6cba0..6170af272a 100644 --- a/bridges/modules/call-dispatch/Cargo.toml +++ b/bridges/modules/dispatch/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-bridge-call-dispatch" +name = "pallet-bridge-dispatch" description = "A Substrate Runtime module that dispatches a bridge message, treating it simply as encoded Call" version = "0.1.0" authors = ["Parity Technologies "] diff --git a/bridges/modules/call-dispatch/README.md b/bridges/modules/dispatch/README.md similarity index 93% rename from bridges/modules/call-dispatch/README.md rename to bridges/modules/dispatch/README.md index d870193e0e..f2ee04beaf 100644 --- a/bridges/modules/call-dispatch/README.md +++ b/bridges/modules/dispatch/README.md @@ -1,7 +1,7 @@ # Call Dispatch Module The call dispatch module has a single internal (only callable by other runtime modules) entry point -for dispatching encoded calls (`pallet_bridge_call_dispatch::Module::dispatch`). Every dispatch +for dispatching encoded calls (`pallet_bridge_dispatch::Module::dispatch`). Every dispatch (successful or not) emits a corresponding module event. The module doesn't have any call-related requirements - they may come from the bridged chain over some message lane, or they may be crafted locally. But in this document we'll mostly talk about this module in the context of bridges. @@ -13,7 +13,7 @@ Every message that is being dispatched has three main characteristics: - `id` is the unique id of the message within the given bridge. For messages coming from the [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 +- `message` is the `pallet_bridge_dispatch::MessagePayload` structure. The `call` field is set to the (potentially) encoded `Call` of this chain. The easiest way to understand what is happening when a `Call` is being dispatched, is to look at the @@ -33,7 +33,7 @@ module events set: chain storage has been corrupted. The `Call` is decoded after `spec_version` check, so we'll never try to decode `Call` from other runtime version; - `MessageSignatureMismatch` event is emitted if submitter has chose to dispatch message using - specified this chain account (`pallet_bridge_call_dispatch::CallOrigin::TargetAccount` origin), + specified this chain account (`pallet_bridge_dispatch::CallOrigin::TargetAccount` origin), but he has failed to prove that he owns the private key for this account; - `MessageCallRejected` event is emitted if the module has been deployed with some call filter and this filter has rejected the `Call`. In your bridge you may choose to reject all messages except diff --git a/bridges/modules/call-dispatch/src/lib.rs b/bridges/modules/dispatch/src/lib.rs similarity index 95% rename from bridges/modules/call-dispatch/src/lib.rs rename to bridges/modules/dispatch/src/lib.rs index 9e6fb9e531..b2fdf2b706 100644 --- a/bridges/modules/call-dispatch/src/lib.rs +++ b/bridges/modules/dispatch/src/lib.rs @@ -89,7 +89,7 @@ pub enum CallOrigin { /// Runtime specification version. We only dispatch messages that have the same @@ -153,7 +153,7 @@ pub trait Config: frame_system::Config { } decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as CallDispatch {} + trait Store for Module, I: Instance = DefaultInstance> as Dispatch {} } decl_event!( @@ -202,7 +202,7 @@ impl, I: Instance> MessageDispatch for Module { let message = match message { Ok(message) => message, Err(_) => { - log::trace!("Message {:?}/{:?}: rejected before actual dispatch", bridge, id); + log::trace!(target: "runtime::bridge-dispatch", "Message {:?}/{:?}: rejected before actual dispatch", bridge, id); Self::deposit_event(RawEvent::MessageRejected(bridge, id)); return; } @@ -232,7 +232,7 @@ impl, I: Instance> MessageDispatch for Module { let call = match message.call.into() { Ok(call) => call, Err(_) => { - log::trace!("Failed to decode Call from message {:?}/{:?}", bridge, id,); + log::trace!(target: "runtime::bridge-dispatch", "Failed to decode Call from message {:?}/{:?}", bridge, id,); Self::deposit_event(RawEvent::MessageCallDecodeFailed(bridge, id)); return; } @@ -243,7 +243,7 @@ impl, I: Instance> MessageDispatch for Module { CallOrigin::SourceRoot => { let hex_id = derive_account_id::(bridge, SourceAccount::Root); let target_id = T::AccountIdConverter::convert(hex_id); - log::trace!("Root Account: {:?}", &target_id); + log::trace!(target: "runtime::bridge-dispatch", "Root Account: {:?}", &target_id); target_id } CallOrigin::TargetAccount(source_account_id, target_public, target_signature) => { @@ -252,6 +252,7 @@ impl, I: Instance> MessageDispatch for Module { let target_account = target_public.into_account(); if !target_signature.verify(&digest[..], &target_account) { log::trace!( + target: "runtime::bridge-dispatch", "Message {:?}/{:?}: origin proof is invalid. Expected account: {:?} from signature: {:?}", bridge, id, @@ -262,13 +263,13 @@ impl, I: Instance> MessageDispatch for Module { return; } - log::trace!("Target Account: {:?}", &target_account); + log::trace!(target: "runtime::bridge-dispatch", "Target Account: {:?}", &target_account); target_account } CallOrigin::SourceAccount(source_account_id) => { let hex_id = derive_account_id(bridge, SourceAccount::Account(source_account_id)); let target_id = T::AccountIdConverter::convert(hex_id); - log::trace!("Source Account: {:?}", &target_id); + log::trace!(target: "runtime::bridge-dispatch", "Source Account: {:?}", &target_id); target_id } }; @@ -276,6 +277,7 @@ impl, I: Instance> MessageDispatch for Module { // filter the call if !T::CallFilter::filter(&call) { log::trace!( + target: "runtime::bridge-dispatch", "Message {:?}/{:?}: the call ({:?}) is rejected by filter", bridge, id, @@ -292,6 +294,7 @@ impl, I: Instance> MessageDispatch for Module { let expected_weight = dispatch_info.weight; if message.weight < expected_weight { log::trace!( + target: "runtime::bridge-dispatch", "Message {:?}/{:?}: passed weight is too low. Expected at least {:?}, got {:?}", bridge, id, @@ -310,11 +313,12 @@ impl, I: Instance> MessageDispatch for Module { // finally dispatch message let origin = RawOrigin::Signed(origin_account).into(); - log::trace!("Message being dispatched is: {:?}", &call); + log::trace!(target: "runtime::bridge-dispatch", "Message being dispatched is: {:?}", &call); let dispatch_result = call.dispatch(origin); let actual_call_weight = extract_actual_weight(&dispatch_result, &dispatch_info); log::trace!( + target: "runtime::bridge-dispatch", "Message {:?}/{:?} has been dispatched. Weight: {} of {}. Result: {:?}", bridge, id, @@ -452,7 +456,7 @@ mod tests { UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Module, Call, Config, Storage, Event}, - CallDispatch: call_dispatch::{Module, Call, Event}, + Dispatch: call_dispatch::{Module, Call, Event}, } } @@ -571,7 +575,7 @@ mod tests { message.spec_version = BAD_SPEC_VERSION; System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -599,7 +603,7 @@ mod tests { message.weight = 0; System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -627,7 +631,7 @@ mod tests { ); System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -649,7 +653,7 @@ mod tests { let id = [0; 4]; System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Err(())); + Dispatch::dispatch(bridge, id, Err(())); assert_eq!( System::events(), @@ -673,7 +677,7 @@ mod tests { message.call.0 = vec![]; System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -700,7 +704,7 @@ mod tests { message.weight = weight; System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -721,7 +725,7 @@ mod tests { let message = prepare_root_message(Call::System(>::remark(vec![1, 2, 3]))); System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -748,7 +752,7 @@ mod tests { let message = prepare_target_message(call); System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), @@ -775,7 +779,7 @@ mod tests { let message = prepare_source_message(call); System::set_block_number(1); - CallDispatch::dispatch(bridge, id, Ok(message)); + Dispatch::dispatch(bridge, id, Ok(message)); assert_eq!( System::events(), diff --git a/bridges/modules/finality-verifier/Cargo.toml b/bridges/modules/grandpa/Cargo.toml similarity index 98% rename from bridges/modules/finality-verifier/Cargo.toml rename to bridges/modules/grandpa/Cargo.toml index e4af91d753..4b35905ecb 100644 --- a/bridges/modules/finality-verifier/Cargo.toml +++ b/bridges/modules/grandpa/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-finality-verifier" +name = "pallet-bridge-grandpa" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/bridges/modules/finality-verifier/src/lib.rs b/bridges/modules/grandpa/src/lib.rs similarity index 97% rename from bridges/modules/finality-verifier/src/lib.rs rename to bridges/modules/grandpa/src/lib.rs index 7e6b8a8353..21ec2d6528 100644 --- a/bridges/modules/finality-verifier/src/lib.rs +++ b/bridges/modules/grandpa/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 . -//! Substrate Finality Verifier Pallet +//! Substrate GRANDPA Pallet //! //! This pallet is an on-chain GRANDPA light client for Substrate based chains. //! @@ -122,7 +122,7 @@ pub mod pallet { ); let (hash, number) = (finality_target.hash(), finality_target.number()); - log::trace!("Going to try and finalize header {:?}", finality_target); + log::trace!(target: "runtime::bridge-grandpa", "Going to try and finalize header {:?}", finality_target); let best_finalized = >::get(>::get()).expect( "In order to reach this point the bridge must have been initialized. Afterwards, @@ -141,7 +141,7 @@ pub mod pallet { >::insert(hash, finality_target); >::mutate(|count| *count += 1); - log::info!("Succesfully imported finalized header with hash {:?}!", hash); + log::info!(target: "runtime::bridge-grandpa", "Succesfully imported finalized header with hash {:?}!", hash); Ok(().into()) } @@ -167,6 +167,7 @@ pub mod pallet { initialize_bridge::(init_data.clone()); log::info!( + target: "runtime::bridge-grandpa", "Pallet has been initialized with the following parameters: {:?}", init_data ); @@ -183,11 +184,11 @@ pub mod pallet { match new_owner { Some(new_owner) => { ModuleOwner::::put(&new_owner); - log::info!("Setting pallet Owner to: {:?}", new_owner); + log::info!(target: "runtime::bridge-grandpa", "Setting pallet Owner to: {:?}", new_owner); } None => { ModuleOwner::::kill(); - log::info!("Removed Owner of pallet."); + log::info!(target: "runtime::bridge-grandpa", "Removed Owner of pallet."); } } @@ -203,9 +204,9 @@ pub mod pallet { >::put(operational); if operational { - log::info!("Resuming pallet operations."); + log::info!(target: "runtime::bridge-grandpa", "Resuming pallet operations."); } else { - log::warn!("Stopping pallet operations."); + log::warn!(target: "runtime::bridge-grandpa", "Stopping pallet operations."); } Ok(().into()) @@ -343,6 +344,7 @@ pub mod pallet { >::put(&next_authorities); log::info!( + target: "runtime::bridge-grandpa", "Transitioned from authority set {} to {}! New authorities are: {:?}", current_set_id, current_set_id + 1, @@ -370,7 +372,7 @@ pub mod pallet { Ok( verify_justification::>((hash, number), set_id, &voter_set, &justification).map_err( |e| { - log::error!("Received invalid justification for {:?}: {:?}", hash, e); + log::error!(target: "runtime::bridge-grandpa", "Received invalid justification for {:?}: {:?}", hash, e); >::InvalidJustification }, )?, diff --git a/bridges/modules/finality-verifier/src/mock.rs b/bridges/modules/grandpa/src/mock.rs similarity index 96% rename from bridges/modules/finality-verifier/src/mock.rs rename to bridges/modules/grandpa/src/mock.rs index 59f658e539..8deca8ae85 100644 --- a/bridges/modules/finality-verifier/src/mock.rs +++ b/bridges/modules/grandpa/src/mock.rs @@ -33,7 +33,7 @@ pub type TestHash = crate::BridgedBlockHash; type Block = frame_system::mocking::MockBlock; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -use crate as finality_verifier; +use crate as grandpa; construct_runtime! { pub enum TestRuntime where @@ -42,7 +42,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Module, Call, Config, Storage, Event}, - FinalityVerifier: finality_verifier::{Module}, + Grandpa: grandpa::{Module}, } } @@ -82,7 +82,7 @@ parameter_types! { pub const MaxRequests: u32 = 2; } -impl finality_verifier::Config for TestRuntime { +impl grandpa::Config for TestRuntime { type BridgedChain = TestBridgedChain; type MaxRequests = MaxRequests; } diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs index 9e6e878bf4..c776944fb3 100644 --- a/bridges/primitives/runtime/src/lib.rs +++ b/bridges/primitives/runtime/src/lib.rs @@ -54,7 +54,7 @@ pub const ROCOCO_BRIDGE_INSTANCE: InstanceId = *b"roco"; pub const WESTEND_BRIDGE_INSTANCE: InstanceId = *b"wend"; /// Call-dispatch module prefix. -pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/call-dispatch"; +pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/dispatch"; /// A unique prefix for entropy when generating cross-chain account IDs. pub const ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/account"; diff --git a/bridges/relays/bin-substrate/Cargo.toml b/bridges/relays/bin-substrate/Cargo.toml index ff2a7fc6a2..a94d6d09ef 100644 --- a/bridges/relays/bin-substrate/Cargo.toml +++ b/bridges/relays/bin-substrate/Cargo.toml @@ -33,9 +33,9 @@ finality-relay = { path = "../finality" } headers-relay = { path = "../headers" } messages-relay = { path = "../messages" } millau-runtime = { path = "../../bin/millau/runtime" } -pallet-bridge-call-dispatch = { path = "../../modules/call-dispatch" } +pallet-bridge-dispatch = { path = "../../modules/dispatch" } +pallet-bridge-grandpa = { path = "../../modules/grandpa" } pallet-bridge-messages = { path = "../../modules/messages" } -pallet-finality-verifier = { path = "../../modules/finality-verifier" } relay-kusama-client = { path = "../client-kusama" } relay-millau-client = { path = "../client-millau" } relay-polkadot-client = { path = "../client-polkadot" } diff --git a/bridges/relays/bin-substrate/src/headers_initialize.rs b/bridges/relays/bin-substrate/src/headers_initialize.rs index 0fb05ad4a9..768d299acd 100644 --- a/bridges/relays/bin-substrate/src/headers_initialize.rs +++ b/bridges/relays/bin-substrate/src/headers_initialize.rs @@ -17,7 +17,7 @@ //! Initialize Substrate -> Substrate headers bridge. //! //! Initialization is a transaction that calls `initialize()` function of the -//! `pallet-finality-verifier` pallet. This transaction brings initial header +//! `pallet-bridge-grandpa` pallet. This transaction brings initial header //! and authorities set from source to target chain. The headers sync starts //! with this header. @@ -28,7 +28,7 @@ use bp_header_chain::{ use codec::Decode; use finality_grandpa::voter_set::VoterSet; use num_traits::{One, Zero}; -use pallet_finality_verifier::InitializationData; +use pallet_bridge_grandpa::InitializationData; use relay_substrate_client::{Chain, Client}; use sp_core::Bytes; use sp_finality_grandpa::AuthorityList as GrandpaAuthoritiesSet; @@ -83,7 +83,7 @@ async fn do_initialize( Ok(initialization_tx_hash) } -/// Prepare initialization data for the finality-verifier pallet. +/// Prepare initialization data for the GRANDPA verifier pallet. async fn prepare_initialization_data( source_client: Client, ) -> Result, String> { diff --git a/bridges/relays/bin-substrate/src/rialto_millau/millau_headers_to_rialto.rs b/bridges/relays/bin-substrate/src/rialto_millau/millau_headers_to_rialto.rs index de03fead20..934c77830a 100644 --- a/bridges/relays/bin-substrate/src/rialto_millau/millau_headers_to_rialto.rs +++ b/bridges/relays/bin-substrate/src/rialto_millau/millau_headers_to_rialto.rs @@ -42,7 +42,7 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto { 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::FinalityBridgeMillauCall::submit_finality_proof(header.into_inner(), proof.into_inner()) + rialto_runtime::BridgeGrandpaMillauCall::submit_finality_proof(header.into_inner(), proof.into_inner()) .into(); let genesis_hash = *self.target_client.genesis_hash(); diff --git a/bridges/relays/bin-substrate/src/rialto_millau/mod.rs b/bridges/relays/bin-substrate/src/rialto_millau/mod.rs index be7d20debf..d3e85ca14e 100644 --- a/bridges/relays/bin-substrate/src/rialto_millau/mod.rs +++ b/bridges/relays/bin-substrate/src/rialto_millau/mod.rs @@ -33,7 +33,7 @@ pub type WestendClient = relay_substrate_client::Client; use crate::cli::{ExplicitOrMaximal, HexBytes, Origins}; use codec::{Decode, Encode}; use frame_support::weights::{GetDispatchInfo, Weight}; -use pallet_bridge_call_dispatch::{CallOrigin, MessagePayload}; +use pallet_bridge_dispatch::{CallOrigin, MessagePayload}; use relay_millau_client::{Millau, SigningParams as MillauSigningParams}; use relay_rialto_client::{Rialto, SigningParams as RialtoSigningParams}; use relay_substrate_client::{Chain, ConnectionParams, TransactionSignScheme}; @@ -64,7 +64,7 @@ async fn run_init_bridge(command: cli::InitBridge) -> Result<(), String> { &rialto_sign.signer, rialto_signer_next_index, rialto_runtime::SudoCall::sudo(Box::new( - rialto_runtime::FinalityBridgeMillauCall::initialize(initialization_data).into(), + rialto_runtime::BridgeGrandpaMillauCall::initialize(initialization_data).into(), )) .into(), ) @@ -86,9 +86,9 @@ async fn run_init_bridge(command: cli::InitBridge) -> Result<(), String> { .await?; crate::headers_initialize::initialize(rialto_client, millau_client.clone(), move |initialization_data| { - let initialize_call = millau_runtime::FinalityBridgeRialtoCall::< + let initialize_call = millau_runtime::BridgeGrandpaRialtoCall::< millau_runtime::Runtime, - millau_runtime::RialtoFinalityVerifierInstance, + millau_runtime::RialtoGrandpaInstance, >::initialize(initialization_data); Ok(Bytes( @@ -119,9 +119,9 @@ async fn run_init_bridge(command: cli::InitBridge) -> Result<(), String> { // may fail, because we need to initialize both Rialto -> Millau and Westend -> Millau bridge. // => since there's single possible sudo account, one of transaction may fail with duplicate nonce error crate::headers_initialize::initialize(westend_client, millau_client.clone(), move |initialization_data| { - let initialize_call = millau_runtime::FinalityBridgeWestendCall::< + let initialize_call = millau_runtime::BridgeGrandpaWestendCall::< millau_runtime::Runtime, - millau_runtime::WestendFinalityVerifierInstance, + millau_runtime::WestendGrandpaInstance, >::initialize(initialization_data); Ok(Bytes( @@ -861,7 +861,7 @@ mod tests { let payload = message_payload( Default::default(), call.get_dispatch_info().weight, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Millau::verify_message(&payload), Ok(())); @@ -871,7 +871,7 @@ mod tests { let payload = message_payload( Default::default(), call.get_dispatch_info().weight, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Millau::verify_message(&payload).is_err()); @@ -897,7 +897,7 @@ mod tests { let payload = message_payload( Default::default(), maximal_dispatch_weight, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Millau::verify_message(&payload), Ok(())); @@ -905,7 +905,7 @@ mod tests { let payload = message_payload( Default::default(), maximal_dispatch_weight + 1, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Millau::verify_message(&payload).is_err()); @@ -921,7 +921,7 @@ mod tests { let payload = message_payload( Default::default(), maximal_dispatch_weight, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert_eq!(Rialto::verify_message(&payload), Ok(())); @@ -929,7 +929,7 @@ mod tests { let payload = message_payload( Default::default(), maximal_dispatch_weight + 1, - pallet_bridge_call_dispatch::CallOrigin::SourceRoot, + pallet_bridge_dispatch::CallOrigin::SourceRoot, &call, ); assert!(Rialto::verify_message(&payload).is_err()); diff --git a/bridges/relays/bin-substrate/src/rialto_millau/rialto_headers_to_millau.rs b/bridges/relays/bin-substrate/src/rialto_millau/rialto_headers_to_millau.rs index f16b37ad54..046883f11c 100644 --- a/bridges/relays/bin-substrate/src/rialto_millau/rialto_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/rialto_millau/rialto_headers_to_millau.rs @@ -42,9 +42,9 @@ impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau { 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::FinalityBridgeRialtoCall::< + let call = millau_runtime::BridgeGrandpaRialtoCall::< millau_runtime::Runtime, - millau_runtime::RialtoFinalityVerifierInstance, + millau_runtime::RialtoGrandpaInstance, >::submit_finality_proof(header.into_inner(), proof.into_inner()) .into(); diff --git a/bridges/relays/bin-substrate/src/rialto_millau/westend_headers_to_millau.rs b/bridges/relays/bin-substrate/src/rialto_millau/westend_headers_to_millau.rs index c32f262218..ded1df32ce 100644 --- a/bridges/relays/bin-substrate/src/rialto_millau/westend_headers_to_millau.rs +++ b/bridges/relays/bin-substrate/src/rialto_millau/westend_headers_to_millau.rs @@ -42,9 +42,9 @@ impl SubstrateFinalitySyncPipeline for WestendFinalityToMillau { 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::FinalityBridgeWestendCall::< + let call = millau_runtime::BridgeGrandpaWestendCall::< millau_runtime::Runtime, - millau_runtime::WestendFinalityVerifierInstance, + millau_runtime::WestendGrandpaInstance, >::submit_finality_proof(header.into_inner(), proof.into_inner()) .into();