diff --git a/Cargo.lock b/Cargo.lock index 43fc2dc8c2e6a..69005f86e8452 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8554,15 +8554,20 @@ dependencies = [ name = "relay-rialto-parachain-client" version = "0.1.0" dependencies = [ + "bp-header-chain", "bp-messages", + "bp-millau", + "bp-polkadot-core", "bp-rialto-parachain", + "bp-runtime", + "bridge-runtime-common", "frame-support", "frame-system", "pallet-transaction-payment", "parity-scale-codec", "relay-substrate-client", "relay-utils", - "rialto-parachain-runtime", + "scale-info", "sp-core", "sp-runtime", ] @@ -8606,15 +8611,18 @@ dependencies = [ "sc-chain-spec", "sc-rpc-api", "sc-transaction-pool-api", + "scale-info", "sp-core", "sp-finality-grandpa", "sp-rpc", "sp-runtime", + "sp-std", "sp-storage", "sp-trie", "sp-version", "thiserror", "tokio", + "xcm", ] [[package]] @@ -11670,7 +11678,6 @@ dependencies = [ "relay-utils", "relay-westend-client", "relay-wococo-client", - "rialto-parachain-runtime", "rialto-runtime", "signal-hook", "signal-hook-async-std", diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 4c3fb152fa736..340088a85b122 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -47,7 +47,6 @@ pub use storage_types::BoundedStorageValue; #[cfg(feature = "std")] pub use storage_proof::craft_valid_storage_proof; -pub mod calls; pub mod messages; mod chain; diff --git a/relays/bin-substrate/Cargo.toml b/relays/bin-substrate/Cargo.toml index c88b930cbb07b..0ab3bd5634f1a 100644 --- a/relays/bin-substrate/Cargo.toml +++ b/relays/bin-substrate/Cargo.toml @@ -51,7 +51,6 @@ relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } relay-westend-client = { path = "../client-westend" } relay-wococo-client = { path = "../client-wococo" } -rialto-parachain-runtime = { path = "../../bin/rialto-parachain/runtime" } rialto-runtime = { path = "../../bin/rialto/runtime" } substrate-relay-helper = { path = "../lib-substrate-relay" } diff --git a/relays/bin-substrate/src/chains/bridge_hub_rococo_messages_to_bridge_hub_wococo.rs b/relays/bin-substrate/src/chains/bridge_hub_rococo_messages_to_bridge_hub_wococo.rs index 339be92063e21..8422569d009af 100644 --- a/relays/bin-substrate/src/chains/bridge_hub_rococo_messages_to_bridge_hub_wococo.rs +++ b/relays/bin-substrate/src/chains/bridge_hub_rococo_messages_to_bridge_hub_wococo.rs @@ -17,7 +17,6 @@ //! BridgeHubRococo-to-BridgeHubWococo messages sync entrypoint. use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; -use bp_messages::Weight; use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_bridge_hub_wococo_client::BridgeHubWococo; use substrate_relay_helper::messages_lane::SubstrateMessageLane; diff --git a/relays/bin-substrate/src/chains/bridge_hub_wococo_messages_to_bridge_hub_rococo.rs b/relays/bin-substrate/src/chains/bridge_hub_wococo_messages_to_bridge_hub_rococo.rs index 3bb2aabde06ba..96df83cd0b217 100644 --- a/relays/bin-substrate/src/chains/bridge_hub_wococo_messages_to_bridge_hub_rococo.rs +++ b/relays/bin-substrate/src/chains/bridge_hub_wococo_messages_to_bridge_hub_rococo.rs @@ -17,7 +17,6 @@ //! BridgeHubWococo-to-BridgeHubRococo messages sync entrypoint. use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge}; -use bp_messages::Weight; use relay_bridge_hub_rococo_client::BridgeHubRococo; use relay_bridge_hub_wococo_client::BridgeHubWococo; use substrate_relay_helper::messages_lane::SubstrateMessageLane; diff --git a/relays/bin-substrate/src/chains/millau_headers_to_rialto_parachain.rs b/relays/bin-substrate/src/chains/millau_headers_to_rialto_parachain.rs index b830ce7fcc4e4..6496167cf7ca9 100644 --- a/relays/bin-substrate/src/chains/millau_headers_to_rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/millau_headers_to_rialto_parachain.rs @@ -36,10 +36,16 @@ use crate::cli::bridge::{CliBridgeBase, MessagesCliBridge, RelayToRelayHeadersCliBridge}; use substrate_relay_helper::finality::{ - engine::Grandpa as GrandpaFinalityEngine, DirectSubmitGrandpaFinalityProofCallBuilder, - SubstrateFinalitySyncPipeline, + engine::Grandpa as GrandpaFinalityEngine, 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. #[derive(Clone, Debug)] pub struct MillauFinalityToRialtoParachain; @@ -49,11 +55,7 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialtoParachain { type TargetChain = relay_rialto_parachain_client::RialtoParachain; type FinalityEngine = GrandpaFinalityEngine; - type SubmitFinalityProofCallBuilder = DirectSubmitGrandpaFinalityProofCallBuilder< - Self, - rialto_parachain_runtime::Runtime, - rialto_parachain_runtime::MillauGrandpaInstance, - >; + type SubmitFinalityProofCallBuilder = MillauFinalityToRialtoParachainCallBuilder; } //// `Millau` to `RialtoParachain` bridge definition. diff --git a/relays/bin-substrate/src/chains/millau_messages_to_rialto_parachain.rs b/relays/bin-substrate/src/chains/millau_messages_to_rialto_parachain.rs index 0b1d3afb797ce..817d0098d9b76 100644 --- a/relays/bin-substrate/src/chains/millau_messages_to_rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/millau_messages_to_rialto_parachain.rs @@ -19,10 +19,16 @@ use relay_millau_client::Millau; use relay_rialto_parachain_client::RialtoParachain; use substrate_relay_helper::messages_lane::{ - DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, - SubstrateMessageLane, + DirectReceiveMessagesDeliveryProofCallBuilder, 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. #[derive(Clone, Debug)] pub struct MillauMessagesToRialtoParachain; @@ -31,11 +37,8 @@ impl SubstrateMessageLane for MillauMessagesToRialtoParachain { type SourceChain = Millau; type TargetChain = RialtoParachain; - type ReceiveMessagesProofCallBuilder = DirectReceiveMessagesProofCallBuilder< - Self, - rialto_parachain_runtime::Runtime, - rialto_parachain_runtime::WithMillauMessagesInstance, - >; + type ReceiveMessagesProofCallBuilder = + MillauMessagesToRialtoParachainReceiveMessagesProofCallBuilder; type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< Self, millau_runtime::Runtime, diff --git a/relays/bin-substrate/src/chains/rialto_parachain.rs b/relays/bin-substrate/src/chains/rialto_parachain.rs index 7105dc2b7d7c8..4d1e1b02e3741 100644 --- a/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -18,7 +18,9 @@ use crate::cli::{bridge, encode_message::CliEncodeMessage, CliChain}; use bp_runtime::EncodedOrDecodedCall; +use bridge_runtime_common::CustomNetworkId; use relay_rialto_parachain_client::RialtoParachain; +use relay_substrate_client::calls::XcmCall; use sp_version::RuntimeVersion; use xcm::latest::prelude::*; @@ -29,23 +31,19 @@ impl CliEncodeMessage for RialtoParachain { ) -> anyhow::Result> { let dest = match bridge_instance_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!( "Unsupported target bridge pallet with instance index: {}", bridge_instance_index ), }; - Ok(rialto_parachain_runtime::RuntimeCall::PolkadotXcm( - rialto_parachain_runtime::XcmCall::send { - dest: Box::new(dest.into()), - message: Box::new(message), - }, - ) - .into()) + let xcm_call = XcmCall::send(Box::new(dest.into()), Box::new(message)); + + Ok(relay_rialto_parachain_client::runtime::Call::PolkadotXcm(xcm_call).into()) } } impl CliChain for RialtoParachain { - const RUNTIME_VERSION: Option = Some(rialto_parachain_runtime::VERSION); + const RUNTIME_VERSION: Option = None; } diff --git a/relays/bin-substrate/src/chains/rialto_parachain_messages_to_millau.rs b/relays/bin-substrate/src/chains/rialto_parachain_messages_to_millau.rs index 74db3738e6b00..0000a0a754a53 100644 --- a/relays/bin-substrate/src/chains/rialto_parachain_messages_to_millau.rs +++ b/relays/bin-substrate/src/chains/rialto_parachain_messages_to_millau.rs @@ -19,13 +19,17 @@ use relay_millau_client::Millau; use relay_rialto_parachain_client::RialtoParachain; use substrate_relay_helper::{ - messages_lane::{ - DirectReceiveMessagesDeliveryProofCallBuilder, DirectReceiveMessagesProofCallBuilder, - SubstrateMessageLane, - }, + messages_lane::{DirectReceiveMessagesProofCallBuilder, SubstrateMessageLane}, 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. #[derive(Clone, Debug)] pub struct RialtoParachainMessagesToMillau; @@ -39,11 +43,8 @@ impl SubstrateMessageLane for RialtoParachainMessagesToMillau { millau_runtime::Runtime, millau_runtime::WithRialtoParachainMessagesInstance, >; - type ReceiveMessagesDeliveryProofCallBuilder = DirectReceiveMessagesDeliveryProofCallBuilder< - Self, - rialto_parachain_runtime::Runtime, - rialto_parachain_runtime::WithMillauMessagesInstance, - >; + type ReceiveMessagesDeliveryProofCallBuilder = + RialtoParachainMessagesToMillauReceiveMessagesDeliveryProofCallBuilder; type SourceBatchCallBuilder = (); type TargetBatchCallBuilder = UtilityPalletBatchCallBuilder; diff --git a/relays/bin-substrate/src/cli/init_bridge.rs b/relays/bin-substrate/src/cli/init_bridge.rs index 322cca1bef52c..8f4080b338cee 100644 --- a/relays/bin-substrate/src/cli/init_bridge.rs +++ b/relays/bin-substrate/src/cli/init_bridge.rs @@ -29,7 +29,7 @@ use crate::{ cli::{bridge::CliBridgeBase, chain_schema::*}, }; 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 structopt::StructOpt; use strum::{EnumString, EnumVariantNames, VariantNames}; @@ -123,13 +123,13 @@ impl BridgeInitializer for MillauToRialtoParachainCliBridge { fn encode_init_bridge( init_data: >::InitializationData, ) -> ::Call { - let initialize_call = rialto_parachain_runtime::BridgeGrandpaCall::< - rialto_parachain_runtime::Runtime, - rialto_parachain_runtime::MillauGrandpaInstance, - >::initialize { - init_data, - }; - rialto_parachain_runtime::SudoCall::sudo { call: Box::new(initialize_call.into()) }.into() + use relay_rialto_parachain_client::runtime; + + let initialize_call = runtime::Call::BridgeMillauGrandpa( + runtime::BridgeMillauGrandpaCall::initialize(init_data), + ); + let sudo_call = SudoCall::sudo(Box::new(initialize_call)); + runtime::Call::Sudo(sudo_call) } } diff --git a/relays/client-bridge-hub-rococo/Cargo.toml b/relays/client-bridge-hub-rococo/Cargo.toml index 6872c59f7602b..e650ba9da7679 100644 --- a/relays/client-bridge-hub-rococo/Cargo.toml +++ b/relays/client-bridge-hub-rococo/Cargo.toml @@ -22,6 +22,7 @@ bp-runtime = { path = "../../primitives/runtime" } bp-wococo = { path = "../../primitives/chain-wococo" } bridge-runtime-common = { path = "../../bin/runtime-common" } + # Substrate Dependencies sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/relays/client-bridge-hub-rococo/src/lib.rs b/relays/client-bridge-hub-rococo/src/lib.rs index 08a9e688487e0..653c5af2c5e3f 100644 --- a/relays/client-bridge-hub-rococo/src/lib.rs +++ b/relays/client-bridge-hub-rococo/src/lib.rs @@ -132,7 +132,7 @@ mod tests { #[test] fn parse_transaction_works() { 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(), )) .into(), diff --git a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs index e7136117360a8..2c50128201bc1 100644 --- a/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-rococo/src/runtime_wrapper.rs @@ -23,8 +23,8 @@ use scale_info::TypeInfo; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; -pub use bp_runtime::calls::SystemCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; +pub use relay_substrate_client::calls::SystemCall; // TODO:check-parameter - check SignedExtension /// Unchecked BridgeHubRococo extrinsic. diff --git a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs index 5c11d8c7ebf79..0d73a91029df5 100644 --- a/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs +++ b/relays/client-bridge-hub-wococo/src/runtime_wrapper.rs @@ -21,8 +21,8 @@ use scale_info::TypeInfo; pub use bp_header_chain::BridgeGrandpaCallOf; pub use bp_parachains::BridgeParachainCall; -pub use bp_runtime::calls::SystemCall; pub use bridge_runtime_common::messages::BridgeMessagesCallOf; +pub use relay_substrate_client::calls::SystemCall; // TODO:check-parameter - check SignedExtension /// Unchecked BridgeHubWococo extrinsic. diff --git a/relays/client-rialto-parachain/Cargo.toml b/relays/client-rialto-parachain/Cargo.toml index 915d0e786cc75..8ecc915f95347 100644 --- a/relays/client-rialto-parachain/Cargo.toml +++ b/relays/client-rialto-parachain/Cargo.toml @@ -7,14 +7,20 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.1.5" } -relay-substrate-client = { path = "../client-substrate" } -relay-utils = { path = "../utils" } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } # Bridge dependencies +bp-header-chain = { path = "../../primitives/header-chain" } 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" } -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 diff --git a/relays/client-rialto-parachain/src/lib.rs b/relays/client-rialto-parachain/src/lib.rs index 16abd6e880881..c3fb0da741877 100644 --- a/relays/client-rialto-parachain/src/lib.rs +++ b/relays/client-rialto-parachain/src/lib.rs @@ -16,6 +16,8 @@ //! Types used to connect to the Rialto-Substrate chain. +pub mod runtime_wrapper; + use bp_messages::MessageNonce; use codec::Encode; use relay_substrate_client::{ @@ -23,12 +25,13 @@ use relay_substrate_client::{ SignParam, UnderlyingChainProvider, UnsignedTransaction, }; 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; -/// Rialto header id. -pub type HeaderId = - relay_utils::HeaderId; +pub use runtime_wrapper as runtime; + +/// The address format for describing accounts. +pub type Address = MultiAddress; /// Rialto parachain definition #[derive(Debug, Clone, Copy)] @@ -46,18 +49,13 @@ impl Chain for RialtoParachain { bp_rialto_parachain::BEST_FINALIZED_RIALTO_PARACHAIN_HEADER_METHOD; const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(5); - type SignedBlock = rialto_parachain_runtime::SignedBlock; - type Call = rialto_parachain_runtime::RuntimeCall; + type SignedBlock = bp_polkadot_core::SignedBlock; + type Call = runtime::Call; } impl ChainWithBalances for RialtoParachain { fn account_info_storage_key(account_id: &Self::AccountId) -> StorageKey { - use frame_support::storage::generator::StorageMap; - StorageKey( - frame_system::Account::::storage_map_final_key( - account_id, - ), - ) + bp_polkadot_core::AccountInfoStorageMapKeyProvider::final_key(account_id) } } @@ -77,45 +75,30 @@ impl ChainWithMessages for RialtoParachain { impl ChainWithTransactions for RialtoParachain { type AccountKeyPair = sp_core::sr25519::Pair; - type SignedTransaction = rialto_parachain_runtime::UncheckedExtrinsic; + type SignedTransaction = bp_polkadot_core::UncheckedExtrinsic; fn sign_transaction( param: SignParam, unsigned: UnsignedTransaction, ) -> Result { - let raw_payload = SignedPayload::from_raw( + let raw_payload = SignedPayload::new( unsigned.call, - ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from( - unsigned.era.frame_era(), - ), - frame_system::CheckNonce::::from(unsigned.nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::< - rialto_parachain_runtime::Runtime, - >::from(unsigned.tip), - ), - ( - (), + bp_polkadot_core::SignedExtensions::new( param.spec_version, param.transaction_version, + unsigned.era, 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 signer: sp_runtime::MultiSigner = param.signer.public().into(); let (call, extra, _) = raw_payload.deconstruct(); - Ok(rialto_parachain_runtime::UncheckedExtrinsic::new_signed( - call.into_decoded()?, + Ok(Self::SignedTransaction::new_signed( + call, signer.into_account().into(), signature.into(), extra, @@ -129,14 +112,13 @@ impl ChainWithTransactions for RialtoParachain { fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { tx.signature .as_ref() - .map(|(address, _, _)| { - *address == rialto_parachain_runtime::Address::Id(signer.public().into()) - }) + .map(|(address, _, _)| *address == Address::Id(signer.public().into())) .unwrap_or(false) } - fn parse_transaction(_tx: Self::SignedTransaction) -> Option> { - None + fn parse_transaction(tx: Self::SignedTransaction) -> Option> { + 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; /// RialtoParachain header type used in headers sync. -pub type SyncHeader = relay_substrate_client::SyncHeader; +pub type SyncHeader = relay_substrate_client::SyncHeader; diff --git a/relays/client-rialto-parachain/src/runtime_wrapper.rs b/relays/client-rialto-parachain/src/runtime_wrapper.rs new file mode 100644 index 0000000000000..b595d145d012d --- /dev/null +++ b/relays/client-rialto-parachain/src/runtime_wrapper.rs @@ -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 . + +//! 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; +// The indirect pallet call used to sync `Millau` messages to `RialtoParachain`. +pub type BridgeMillauMessagesCall = BridgeMessagesCallOf; + +/// `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), + + /// `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), +} diff --git a/relays/client-substrate/Cargo.toml b/relays/client-substrate/Cargo.toml index 29b910c11bd7e..f9760a32603e9 100644 --- a/relays/client-substrate/Cargo.toml +++ b/relays/client-substrate/Cargo.toml @@ -14,6 +14,7 @@ jsonrpsee = { version = "0.15", features = ["macros", "ws-client"] } log = "0.4.17" num-traits = "0.2" rand = "0.7" +scale-info = { version = "2.1.1", features = ["derive"] } tokio = { version = "1.8", features = ["rt-multi-thread"] } 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-rpc = { 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-trie = { 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] default = [] test-helpers = [] diff --git a/primitives/runtime/src/calls.rs b/relays/client-substrate/src/calls.rs similarity index 62% rename from primitives/runtime/src/calls.rs rename to relays/client-substrate/src/calls.rs index 194c2126ba3b2..89fc49a209aeb 100644 --- a/primitives/runtime/src/calls.rs +++ b/relays/client-substrate/src/calls.rs @@ -18,7 +18,9 @@ use codec::{Decode, Encode}; 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. #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] @@ -28,3 +30,21 @@ pub enum SystemCall { #[codec(index = 1)] remark(Vec), } + +/// 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 { + /// `pallet-sudo::Call::sudo` + #[codec(index = 0)] + sudo(Box), +} + +/// 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, Box>), +} diff --git a/relays/client-substrate/src/lib.rs b/relays/client-substrate/src/lib.rs index e576aca1119d8..599d9c658b56f 100644 --- a/relays/client-substrate/src/lib.rs +++ b/relays/client-substrate/src/lib.rs @@ -25,6 +25,7 @@ mod rpc; mod sync_header; mod transaction_tracker; +pub mod calls; pub mod guard; pub mod metrics; pub mod test_chain; diff --git a/relays/lib-substrate-relay/src/messages_lane.rs b/relays/lib-substrate-relay/src/messages_lane.rs index 22ff3e7215b68..61ea72853f43c 100644 --- a/relays/lib-substrate-relay/src/messages_lane.rs +++ b/relays/lib-substrate-relay/src/messages_lane.rs @@ -330,7 +330,7 @@ macro_rules! generate_mocked_receive_message_proof_call_builder { <$pipeline as $crate::messages_lane::SubstrateMessageLane>::SourceChain >, messages_count: u32, - dispatch_weight: Weight, + dispatch_weight: bp_messages::Weight, _trace_call: bool, ) -> relay_substrate_client::CallOf< <$pipeline as $crate::messages_lane::SubstrateMessageLane>::TargetChain