Use indirect runtime calls for RialtoParachain (#1753)

* Use indirect runtime calls for RialtoParachain

* Code review fixes
This commit is contained in:
Serban Iorga
2023-01-10 17:05:00 +02:00
committed by Bastian Köcher
parent e0e84b734b
commit 444dbe7173
20 changed files with 168 additions and 95 deletions
-1
View File
@@ -47,7 +47,6 @@ pub use storage_types::BoundedStorageValue;
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub use storage_proof::craft_valid_storage_proof; pub use storage_proof::craft_valid_storage_proof;
pub mod calls;
pub mod messages; pub mod messages;
mod chain; mod chain;
-1
View File
@@ -51,7 +51,6 @@ relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" } relay-utils = { path = "../utils" }
relay-westend-client = { path = "../client-westend" } relay-westend-client = { path = "../client-westend" }
relay-wococo-client = { path = "../client-wococo" } relay-wococo-client = { path = "../client-wococo" }
rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" }
rialto-runtime = { path = "../../bin/rialto/runtime" } rialto-runtime = { path = "../../bin/rialto/runtime" }
substrate-relay-helper = { path = "../lib-substrate-relay" } substrate-relay-helper = { path = "../lib-substrate-relay" }
@@ -17,7 +17,6 @@
//! BridgeHubRococo-to-BridgeHubWococo messages sync entrypoint. //! BridgeHubRococo-to-BridgeHubWococo messages sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
use bp_messages::Weight;
use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_bridge_hub_rococo_client::BridgeHubRococo;
use relay_bridge_hub_wococo_client::BridgeHubWococo; use relay_bridge_hub_wococo_client::BridgeHubWococo;
use substrate_relay_helper::messages_lane::SubstrateMessageLane; use substrate_relay_helper::messages_lane::SubstrateMessageLane;
@@ -17,7 +17,6 @@
//! BridgeHubWococo-to-BridgeHubRococo messages sync entrypoint. //! BridgeHubWococo-to-BridgeHubRococo messages sync entrypoint.
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge};
use bp_messages::Weight;
use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_bridge_hub_rococo_client::BridgeHubRococo;
use relay_bridge_hub_wococo_client::BridgeHubWococo; use relay_bridge_hub_wococo_client::BridgeHubWococo;
use substrate_relay_helper::messages_lane::SubstrateMessageLane; use substrate_relay_helper::messages_lane::SubstrateMessageLane;
@@ -36,10 +36,16 @@
use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge}; use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge};
use substrate_relay_helper::finality::{ use substrate_relay_helper::finality::{
engine::Grandpa as GrandpaFinalityEngine, DirectSubmitGrandpaFinalityProofCallBuilder, engine::Grandpa as GrandpaFinalityEngine, SubstrateFinalitySyncPipeline,
SubstrateFinalitySyncPipeline,
}; };
substrate_relay_helper::generate_mocked_submit_finality_proof_call_builder!(
MillauFinalityToRialtoParachain,
MillauFinalityToRialtoParachainCallBuilder,
relay_rialto_parachain_client::runtime::Call::BridgeMillauGrandpa,
relay_rialto_parachain_client::runtime::BridgeMillauGrandpaCall::submit_finality_proof
);
/// Description of Millau -> Rialto finalized headers bridge. /// Description of Millau -> Rialto finalized headers bridge.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MillauFinalityToRialtoParachain; pub struct MillauFinalityToRialtoParachain;
@@ -49,11 +55,7 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialtoParachain {
type TargetChain = relay_rialto_parachain_client::RialtoParachain; type TargetChain = relay_rialto_parachain_client::RialtoParachain;
type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>; type FinalityEngine = GrandpaFinalityEngine<Self::SourceChain>;
type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder< type SubmitFinalityProofCallBuilder = MillauFinalityToRialtoParachainCallBuilder;
Self,
rialto_parachain_runtime::Runtime,
rialto_parachain_runtime::MillauGrandpaInstance,
>;
} }
//// `Millau` to `RialtoParachain` bridge definition. //// `Millau` to `RialtoParachain` bridge definition.
@@ -19,10 +19,16 @@
use relay_millau_client::Millau; use relay_millau_client::Millau;
use relay_rialto_parachain_client::RialtoParachain; use relay_rialto_parachain_client::RialtoParachain;
use substrate_relay_helper::messages_lane::{ use substrate_relay_helper::messages_lane::{
DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, DirectReceiveMessagesDeliveryProofCallBuilder, SubstrateMessageLane,
SubstrateMessageLane,
}; };
substrate_relay_helper::generate_mocked_receive_message_proof_call_builder!(
MillauMessagesToRialtoParachain,
MillauMessagesToRialtoParachainReceiveMessagesProofCallBuilder,
relay_rialto_parachain_client::runtime::Call::BridgeMillauMessages,
relay_rialto_parachain_client::runtime::BridgeMillauMessagesCall::receive_messages_proof
);
/// Description of Millau -> RialtoParachain messages bridge. /// Description of Millau -> RialtoParachain messages bridge.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MillauMessagesToRialtoParachain; pub struct MillauMessagesToRialtoParachain;
@@ -31,11 +37,8 @@ impl SubstrateMessageLane for MillauMessagesToRialtoParachain {
type SourceChain = Millau; type SourceChain = Millau;
type TargetChain = RialtoParachain; type TargetChain = RialtoParachain;
type ReceiveMessagesProofCallBuilder = DirectReceiveMessagesProofCallBuilder< type ReceiveMessagesProofCallBuilder =
Self, MillauMessagesToRialtoParachainReceiveMessagesProofCallBuilder;
rialto_parachain_runtime::Runtime,
rialto_parachain_runtime::WithMillauMessagesInstance,
>;
type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder<
Self, Self,
millau_runtime::Runtime, millau_runtime::Runtime,
@@ -18,7 +18,9 @@
use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain}; use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain};
use bp_runtime::EncodedOrDecodedCall; use bp_runtime::EncodedOrDecodedCall;
use bridge_runtime_common::CustomNetworkId;
use relay_rialto_parachain_client::RialtoParachain; use relay_rialto_parachain_client::RialtoParachain;
use relay_substrate_client::calls::XcmCall;
use sp_version::RuntimeVersion; use sp_version::RuntimeVersion;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
@@ -29,23 +31,19 @@ impl CliEncodeMessage for RialtoParachain {
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> { ) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
let dest = match bridge_instance_index { let dest = match bridge_instance_index {
bridge::RIALTO_PARACHAIN_TO_MILLAU_INDEX => bridge::RIALTO_PARACHAIN_TO_MILLAU_INDEX =>
(Parent, X1(GlobalConsensus(rialto_parachain_runtime::MillauNetwork::get()))), (Parent, X1(GlobalConsensus(CustomNetworkId::Millau.as_network_id()))),
_ => anyhow::bail!( _ => anyhow::bail!(
"Unsupported target bridge pallet with instance index: {}", "Unsupported target bridge pallet with instance index: {}",
bridge_instance_index bridge_instance_index
), ),
}; };
Ok(rialto_parachain_runtime::RuntimeCall::PolkadotXcm( let xcm_call = XcmCall::send(Box::new(dest.into()), Box::new(message));
rialto_parachain_runtime::XcmCall::send {
dest: Box::new(dest.into()), Ok(relay_rialto_parachain_client::runtime::Call::PolkadotXcm(xcm_call).into())
message: Box::new(message),
},
)
.into())
} }
} }
impl CliChain for RialtoParachain { impl CliChain for RialtoParachain {
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION); const RUNTIME_VERSION: Option<RuntimeVersion> = None;
} }
@@ -19,13 +19,17 @@
use relay_millau_client::Millau; use relay_millau_client::Millau;
use relay_rialto_parachain_client::RialtoParachain; use relay_rialto_parachain_client::RialtoParachain;
use substrate_relay_helper::{ use substrate_relay_helper::{
messages_lane::{ messages_lane::{DirectReceiveMessagesProofCallBuilder, SubstrateMessageLane},
DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder,
SubstrateMessageLane,
},
UtilityPalletBatchCallBuilder, UtilityPalletBatchCallBuilder,
}; };
substrate_relay_helper::generate_mocked_receive_message_delivery_proof_call_builder!(
RialtoParachainMessagesToMillau,
RialtoParachainMessagesToMillauReceiveMessagesDeliveryProofCallBuilder,
relay_rialto_parachain_client::runtime::Call::BridgeMillauMessages,
relay_rialto_parachain_client::runtime::BridgeMillauMessagesCall::receive_messages_delivery_proof
);
/// Description of RialtoParachain -> Millau messages bridge. /// Description of RialtoParachain -> Millau messages bridge.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct RialtoParachainMessagesToMillau; pub struct RialtoParachainMessagesToMillau;
@@ -39,11 +43,8 @@ impl SubstrateMessageLane for RialtoParachainMessagesToMillau {
millau_runtime::Runtime, millau_runtime::Runtime,
millau_runtime::WithRialtoParachainMessagesInstance, millau_runtime::WithRialtoParachainMessagesInstance,
>; >;
type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< type ReceiveMessagesDeliveryProofCallBuilder =
Self, RialtoParachainMessagesToMillauReceiveMessagesDeliveryProofCallBuilder;
rialto_parachain_runtime::Runtime,
rialto_parachain_runtime::WithMillauMessagesInstance,
>;
type SourceBatchCallBuilder = (); type SourceBatchCallBuilder = ();
type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<Millau>; type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder<Millau>;
@@ -29,7 +29,7 @@ use crate::{
cli::{bridge::CliBridgeBase, chain_schema::*}, cli::{bridge::CliBridgeBase, chain_schema::*},
}; };
use bp_runtime::Chain as ChainBase; use bp_runtime::Chain as ChainBase;
use relay_substrate_client::{AccountKeyPairOf, Chain, UnsignedTransaction}; use relay_substrate_client::{calls::SudoCall, AccountKeyPairOf, Chain, UnsignedTransaction};
use sp_core::Pair; use sp_core::Pair;
use structopt::StructOpt; use structopt::StructOpt;
use strum::{EnumString, EnumVariantNames, VariantNames}; use strum::{EnumString, EnumVariantNames, VariantNames};
@@ -123,13 +123,13 @@ impl BridgeInitializer for MillauToRialtoParachainCliBridge {
fn encode_init_bridge( fn encode_init_bridge(
init_data: <Self::Engine as Engine<Self::Source>>::InitializationData, init_data: <Self::Engine as Engine<Self::Source>>::InitializationData,
) -> <Self::Target as Chain>::Call { ) -> <Self::Target as Chain>::Call {
let initialize_call = rialto_parachain_runtime::BridgeGrandpaCall::< use relay_rialto_parachain_client::runtime;
rialto_parachain_runtime::Runtime,
rialto_parachain_runtime::MillauGrandpaInstance, let initialize_call = runtime::Call::BridgeMillauGrandpa(
>::initialize { runtime::BridgeMillauGrandpaCall::initialize(init_data),
init_data, );
}; let sudo_call = SudoCall::sudo(Box::new(initialize_call));
rialto_parachain_runtime::SudoCall::sudo { call: Box::new(initialize_call.into()) }.into() runtime::Call::Sudo(sudo_call)
} }
} }
@@ -22,6 +22,7 @@ bp-runtime = { path = "../../primitives/runtime" }
bp-wococo = { path = "../../primitives/chain-wococo" } bp-wococo = { path = "../../primitives/chain-wococo" }
bridge-runtime-common = { path = "../../bin/runtime-common" } bridge-runtime-common = { path = "../../bin/runtime-common" }
# Substrate Dependencies # Substrate Dependencies
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -132,7 +132,7 @@ mod tests {
#[test] #[test]
fn parse_transaction_works() { fn parse_transaction_works() {
let unsigned = UnsignedTransaction { let unsigned = UnsignedTransaction {
call: runtime::Call::System(bp_runtime::calls::SystemCall::remark( call: runtime::Call::System(relay_substrate_client::calls::SystemCall::remark(
b"Hello world!".to_vec(), b"Hello world!".to_vec(),
)) ))
.into(), .into(),
@@ -23,8 +23,8 @@ use scale_info::TypeInfo;
pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_header_chain::BridgeGrandpaCallOf;
pub use bp_parachains::BridgeParachainCall; pub use bp_parachains::BridgeParachainCall;
pub use bp_runtime::calls::SystemCall;
pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
pub use relay_substrate_client::calls::SystemCall;
// TODO:check-parameter - check SignedExtension // TODO:check-parameter - check SignedExtension
/// Unchecked BridgeHubRococo extrinsic. /// Unchecked BridgeHubRococo extrinsic.
@@ -21,8 +21,8 @@ use scale_info::TypeInfo;
pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_header_chain::BridgeGrandpaCallOf;
pub use bp_parachains::BridgeParachainCall; pub use bp_parachains::BridgeParachainCall;
pub use bp_runtime::calls::SystemCall;
pub use bridge_runtime_common::messages::BridgeMessagesCallOf; pub use bridge_runtime_common::messages::BridgeMessagesCallOf;
pub use relay_substrate_client::calls::SystemCall;
// TODO:check-parameter - check SignedExtension // TODO:check-parameter - check SignedExtension
/// Unchecked BridgeHubWococo extrinsic. /// Unchecked BridgeHubWococo extrinsic.
@@ -7,14 +7,20 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5" } codec = { package = "parity-scale-codec", version = "3.1.5" }
relay-substrate-client = { path = "../client-substrate" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
relay-utils = { path = "../utils" }
# Bridge dependencies # Bridge dependencies
bp-header-chain = { path = "../../primitives/header-chain" }
bp-messages = { path = "../../primitives/messages" } bp-messages = { path = "../../primitives/messages" }
bp-millau = { path = "../../primitives/chain-millau" }
bp-polkadot-core = { path = "../../primitives/polkadot-core" }
bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" }
rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" } bp-runtime = { path = "../../primitives/runtime" }
bridge-runtime-common = { path = "../../bin/runtime-common" }
relay-substrate-client = { path = "../client-substrate" }
relay-utils = { path = "../utils" }
# Substrate Dependencies # Substrate Dependencies
@@ -16,6 +16,8 @@
//! Types used to connect to the Rialto-Substrate chain. //! Types used to connect to the Rialto-Substrate chain.
pub mod runtime_wrapper;
use bp_messages::MessageNonce; use bp_messages::MessageNonce;
use codec::Encode; use codec::Encode;
use relay_substrate_client::{ use relay_substrate_client::{
@@ -23,12 +25,13 @@ use relay_substrate_client::{
SignParam, UnderlyingChainProvider, UnsignedTransaction, SignParam, UnderlyingChainProvider, UnsignedTransaction,
}; };
use sp_core::{storage::StorageKey, Pair}; use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount, MultiAddress};
use std::time::Duration; use std::time::Duration;
/// Rialto header id. pub use runtime_wrapper as runtime;
pub type HeaderId =
relay_utils::HeaderId<rialto_parachain_runtime::Hash, rialto_parachain_runtime::BlockNumber>; /// The address format for describing accounts.
pub type Address = MultiAddress<bp_rialto_parachain::AccountId, ()>;
/// Rialto parachain definition /// Rialto parachain definition
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
@@ -46,18 +49,13 @@ impl Chain for RialtoParachain {
bp_rialto_parachain::BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD; bp_rialto_parachain::BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD;
const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5); const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5);
type SignedBlock = rialto_parachain_runtime::SignedBlock; type SignedBlock = bp_polkadot_core::SignedBlock;
type Call = rialto_parachain_runtime::RuntimeCall; type Call = runtime::Call;
} }
impl ChainWithBalances for RialtoParachain { impl ChainWithBalances for RialtoParachain {
fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey {
use frame_support::storage::generator::StorageMap; bp_polkadot_core::AccountInfoStorageMapKeyProvider::final_key(account_id)
StorageKey(
frame_system::Account::<rialto_parachain_runtime::Runtime>::storage_map_final_key(
account_id,
),
)
} }
} }
@@ -77,45 +75,30 @@ impl ChainWithMessages for RialtoParachain {
impl ChainWithTransactions for RialtoParachain { impl ChainWithTransactions for RialtoParachain {
type AccountKeyPair = sp_core::sr25519::Pair; type AccountKeyPair = sp_core::sr25519::Pair;
type SignedTransaction = rialto_parachain_runtime::UncheckedExtrinsic; type SignedTransaction = bp_polkadot_core::UncheckedExtrinsic<Self::Call>;
fn sign_transaction( fn sign_transaction(
param: SignParam<Self>, param: SignParam<Self>,
unsigned: UnsignedTransaction<Self>, unsigned: UnsignedTransaction<Self>,
) -> Result<Self::SignedTransaction, SubstrateError> { ) -> Result<Self::SignedTransaction, SubstrateError> {
let raw_payload = SignedPayload::from_raw( let raw_payload = SignedPayload::new(
unsigned.call, unsigned.call,
( bp_polkadot_core::SignedExtensions::new(
frame_system::CheckNonZeroSender::<rialto_parachain_runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<rialto_parachain_runtime::Runtime>::new(),
frame_system::CheckTxVersion::<rialto_parachain_runtime::Runtime>::new(),
frame_system::CheckGenesis::<rialto_parachain_runtime::Runtime>::new(),
frame_system::CheckEra::<rialto_parachain_runtime::Runtime>::from(
unsigned.era.frame_era(),
),
frame_system::CheckNonce::<rialto_parachain_runtime::Runtime>::from(unsigned.nonce),
frame_system::CheckWeight::<rialto_parachain_runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<
rialto_parachain_runtime::Runtime,
>::from(unsigned.tip),
),
(
(),
param.spec_version, param.spec_version,
param.transaction_version, param.transaction_version,
unsigned.era,
param.genesis_hash, param.genesis_hash,
unsigned.era.signed_payload(param.genesis_hash), unsigned.nonce,
(), unsigned.tip,
(),
(),
), ),
); )?;
let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload)); let signature = raw_payload.using_encoded(|payload| param.signer.sign(payload));
let signer: sp_runtime::MultiSigner = param.signer.public().into(); let signer: sp_runtime::MultiSigner = param.signer.public().into();
let (call, extra, _) = raw_payload.deconstruct(); let (call, extra, _) = raw_payload.deconstruct();
Ok(rialto_parachain_runtime::UncheckedExtrinsic::new_signed( Ok(Self::SignedTransaction::new_signed(
call.into_decoded()?, call,
signer.into_account().into(), signer.into_account().into(),
signature.into(), signature.into(),
extra, extra,
@@ -129,14 +112,13 @@ impl ChainWithTransactions for RialtoParachain {
fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool {
tx.signature tx.signature
.as_ref() .as_ref()
.map(|(address, _, _)| { .map(|(address, _, _)| *address == Address::Id(signer.public().into()))
*address == rialto_parachain_runtime::Address::Id(signer.public().into())
})
.unwrap_or(false) .unwrap_or(false)
} }
fn parse_transaction(_tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { fn parse_transaction(tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> {
None let extra = &tx.signature.as_ref()?.2;
Some(UnsignedTransaction::new(tx.function, extra.nonce()).tip(extra.tip()))
} }
} }
@@ -144,4 +126,4 @@ impl ChainWithTransactions for RialtoParachain {
pub type SigningParams = sp_core::sr25519::Pair; pub type SigningParams = sp_core::sr25519::Pair;
/// RialtoParachain header type used in headers sync. /// RialtoParachain header type used in headers sync.
pub type SyncHeader = relay_substrate_client::SyncHeader<rialto_parachain_runtime::Header>; pub type SyncHeader = relay_substrate_client::SyncHeader<bp_rialto_parachain::Header>;
@@ -0,0 +1,57 @@
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Types that are specific to the `RialtoParachain` runtime. Normally we could use the full
//! `RialtoParachain` runtime here, since it is constructed in this repo and we have access to it.
//! However we use a wrapped runtime instead in order to test the indirect runtime calls
//! functionality.
use codec::{Decode, Encode};
use scale_info::TypeInfo;
use bp_header_chain::BridgeGrandpaCallOf;
use bridge_runtime_common::messages::BridgeMessagesCallOf;
use relay_substrate_client::calls::{SudoCall, XcmCall};
// The indirect pallet call used to sync `Millau` GRANDPA finality to `RialtoParachain`.
pub type BridgeMillauGrandpaCall = BridgeGrandpaCallOf<bp_millau::Millau>;
// The indirect pallet call used to sync `Millau` messages to `RialtoParachain`.
pub type BridgeMillauMessagesCall = BridgeMessagesCallOf<bp_millau::Millau>;
/// `RialtoParachain` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `RialtoParachain` chain.
///
/// All entries here (like pretty much in the entire file) must be kept in sync with
/// `RialtoParachain` `construct_runtime`, so that we maintain SCALE-compatibility.
#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum Call {
/// `Sudo` pallet.
#[codec(index = 2)]
Sudo(SudoCall<Call>),
/// `Xcm` pallet.
#[codec(index = 51)]
PolkadotXcm(XcmCall),
/// Millau GRANDPA bridge pallet.
#[codec(index = 55)]
BridgeMillauGrandpa(BridgeMillauGrandpaCall),
/// Millau messages bridge pallet.
#[codec(index = 56)]
BridgeMillauMessages(BridgeMillauMessagesCall),
}
@@ -14,6 +14,7 @@ jsonrpsee = { version = "0.15", features = ["macros", "ws-client"] }
log = "0.4.17" log = "0.4.17"
num-traits = "0.2" num-traits = "0.2"
rand = "0.7" rand = "0.7"
scale-info = { version = "2.1.1", features = ["derive"] }
tokio = { version = "1.8", features = ["rt-multi-thread"] } tokio = { version = "1.8", features = ["rt-multi-thread"] }
thiserror = "1.0.26" thiserror = "1.0.26"
@@ -42,10 +43,15 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-version = { git = "https://github.com/paritytech/substrate", branch = "master" }
# Polkadot Dependencies
xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false }
[features] [features]
default = [] default = []
test-helpers = [] test-helpers = []
@@ -18,7 +18,9 @@
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_std::vec::Vec; use sp_std::{boxed::Box, vec::Vec};
use xcm::{VersionedMultiLocation, VersionedXcm};
/// A minimized version of `frame-system::Call` that can be used without a runtime. /// A minimized version of `frame-system::Call` that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
@@ -28,3 +30,21 @@ pub enum SystemCall {
#[codec(index = 1)] #[codec(index = 1)]
remark(Vec<u8>), remark(Vec<u8>),
} }
/// A minimized version of `pallet-sudo::Call` that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[allow(non_camel_case_types)]
pub enum SudoCall<Call> {
/// `pallet-sudo::Call::sudo`
#[codec(index = 0)]
sudo(Box<Call>),
}
/// A minimized version of `pallet-xcm::Call`, that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[allow(non_camel_case_types)]
pub enum XcmCall {
/// `pallet-xcm::Call::send`
#[codec(index = 0)]
send(Box<VersionedMultiLocation>, Box<VersionedXcm<()>>),
}
@@ -25,6 +25,7 @@ mod rpc;
mod sync_header; mod sync_header;
mod transaction_tracker; mod transaction_tracker;
pub mod calls;
pub mod guard; pub mod guard;
pub mod metrics; pub mod metrics;
pub mod test_chain; pub mod test_chain;
@@ -330,7 +330,7 @@ macro_rules! generate_mocked_receive_message_proof_call_builder {
<$pipeline as $crate::messages_lane::SubstrateMessageLane>::SourceChain <$pipeline as $crate::messages_lane::SubstrateMessageLane>::SourceChain
>, >,
messages_count: u32, messages_count: u32,
dispatch_weight: Weight, dispatch_weight: bp_messages::Weight,
_trace_call: bool, _trace_call: bool,
) -> relay_substrate_client::CallOf< ) -> relay_substrate_client::CallOf<
<$pipeline as $crate::messages_lane::SubstrateMessageLane>::TargetChain <$pipeline as $crate::messages_lane::SubstrateMessageLane>::TargetChain