Skip to content

Commit

Permalink
Rename Finality Verifier and Call Dispatch Pallets (paritytech#838)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HCastano authored and serban300 committed Apr 9, 2024
1 parent d8c314b commit d7bfecf
Show file tree
Hide file tree
Showing 26 changed files with 165 additions and 160 deletions.
3 changes: 2 additions & 1 deletion bridges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
│ └── ...
Expand Down
4 changes: 2 additions & 2 deletions bridges/bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -179,7 +179,7 @@ fn testnet_genesis(
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone())))
.collect::<Vec<_>>(),
}),
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
Expand Down
20 changes: 10 additions & 10 deletions bridges/bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -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 }
Expand All @@ -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",
Expand Down
30 changes: 15 additions & 15 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<WestendFinalityVerifierInstance> for Runtime {
pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1;
impl pallet_bridge_grandpa::Config<WestendGrandpaInstance> for Runtime {
type BridgedChain = bp_westend::Westend;
type MaxRequests = MaxRequests;
}
Expand Down Expand Up @@ -378,9 +378,9 @@ construct_runtime!(
{
BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config<T>},
BridgeRialtoMessages: pallet_bridge_messages::{Module, Call, Storage, Event<T>},
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
BridgeRialtoFinalityVerifier: pallet_finality_verifier::{Module, Call},
BridgeWestendFinalityVerifier: pallet_finality_verifier::<Instance1>::{Module, Call, Config<T>},
BridgeDispatch: pallet_bridge_dispatch::{Module, Event<T>},
BridgeRialtoGrandpa: pallet_bridge_grandpa::{Module, Call},
BridgeWestendGrandpa: pallet_bridge_grandpa::<Instance1>::{Module, Call, Config<T>},
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
Expand Down Expand Up @@ -581,23 +581,23 @@ impl_runtime_apis! {

impl bp_rialto::RialtoFinalityApi<Block> 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<Block> 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)
}
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/millau/runtime/src/rialto_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions bridges/bin/rialto/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
22 changes: 11 additions & 11 deletions bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -257,7 +257,7 @@ impl pallet_bridge_currency_exchange::Config<KovanCurrencyExchange> 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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -480,8 +480,8 @@ construct_runtime!(
BridgeRialtoCurrencyExchange: pallet_bridge_currency_exchange::<Instance1>::{Module, Call},
BridgeKovanCurrencyExchange: pallet_bridge_currency_exchange::<Instance2>::{Module, Call},
BridgeMillau: pallet_substrate_bridge::{Module, Call, Storage, Config<T>},
BridgeFinalityVerifier: pallet_finality_verifier::{Module, Call},
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
BridgeGrandpa: pallet_bridge_grandpa::{Module, Call},
BridgeDispatch: pallet_bridge_dispatch::{Module, Event<T>},
BridgeMillauMessages: pallet_bridge_messages::{Module, Call, Storage, Event<T>},
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
Expand Down Expand Up @@ -643,12 +643,12 @@ impl_runtime_apis! {

impl bp_millau::MillauFinalityApi<Block> 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)
}
}

Expand Down Expand Up @@ -890,7 +890,7 @@ impl_runtime_apis! {
params: MessageParams<Self::AccountId>,
) -> (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,
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/rialto/runtime/src/millau_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions bridges/bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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",
Expand All @@ -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",
]
12 changes: 6 additions & 6 deletions bridges/bin/runtime-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down
Loading

0 comments on commit d7bfecf

Please sign in to comment.