diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs index 7837afe690e4a578f10faad4e118f023a3e4ad2d..27d5f125ee2666b30fe526ac364bede89867bee0 100644 --- a/bridges/primitives/chain-kusama/src/lib.rs +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis; /// Kusama Chain pub type Kusama = PolkadotLike; -/// The target length of a session (how often authorities change) on Kusama measured in of number of -/// blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = time_units::HOURS; - /// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa"; diff --git a/bridges/primitives/chain-polkadot/Cargo.toml b/bridges/primitives/chain-polkadot/Cargo.toml index 8be9b25c77f5a3397bb7b0f1672400d44d1d2796..b26093a05706e28c0089e9c3f12d2de7151dc6ce 100644 --- a/bridges/primitives/chain-polkadot/Cargo.toml +++ b/bridges/primitives/chain-polkadot/Cargo.toml @@ -7,8 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -smallvec = "1.7" - # Bridge Dependencies bp-polkadot-core = { path = "../polkadot-core", default-features = false } diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs index cfcbacb0d1a76021d32f32f2e6337dde4d8c92a3..0cada4e49a9be996f79a782cb7eb8938feaf8f01 100644 --- a/bridges/primitives/chain-polkadot/src/lib.rs +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis; /// Polkadot Chain pub type Polkadot = PolkadotLike; -/// The target length of a session (how often authorities change) on Polkadot measured in of number -/// of blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = 4 * time_units::HOURS; - /// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa"; diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs index 39188066dca4b44802d76609b42aee6308871ffa..dd5be65dd866b058f08f764ddb5d588764b12205 100644 --- a/bridges/primitives/chain-rococo/src/lib.rs +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis; /// Rococo Chain pub type Rococo = PolkadotLike; -/// The target length of a session (how often authorities change) on Rococo measured in of number -/// of blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = time_units::HOURS; - /// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa"; diff --git a/bridges/primitives/chain-statemine/Cargo.toml b/bridges/primitives/chain-statemine/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..18d186ba41ef5ea88fed90cf7b2691d321ed5f37 --- /dev/null +++ b/bridges/primitives/chain-statemine/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "bp-statemine" +description = "Primitives of Statemine runtime." +version = "0.1.0" +authors = ["Parity Technologies <admin@parity.io>"] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-polkadot-core = { path = "../polkadot-core", default-features = false } + +# Substrate Based Dependencies + +sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-polkadot-core/std", + "sp-version/std", +] diff --git a/bridges/primitives/chain-statemine/src/lib.rs b/bridges/primitives/chain-statemine/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..613e4a4f4501a5816ad9dfec0a0511bda9d76b00 --- /dev/null +++ b/bridges/primitives/chain-statemine/src/lib.rs @@ -0,0 +1,38 @@ +// 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/>. + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +pub use bp_polkadot_core::*; + +use sp_version::RuntimeVersion; + +/// Statemine Chain. +pub type Statemine = PolkadotLike; + +/// Known Statemine runtime version. +pub const VERSION: RuntimeVersion = RuntimeVersion { + spec_name: sp_version::create_runtime_str!("statemine"), + impl_name: sp_version::create_runtime_str!("statemine"), + authoring_version: 1, + spec_version: 9300, + impl_version: 0, + apis: sp_version::create_apis_vec![[]], + transaction_version: 8, + state_version: 1, +}; diff --git a/bridges/primitives/chain-westend/Cargo.toml b/bridges/primitives/chain-westend/Cargo.toml index e5f7bf89565b69330085b71f24fa3812bdad24d4..7d74362b09a1ae0341f33e1146799f013833f447 100644 --- a/bridges/primitives/chain-westend/Cargo.toml +++ b/bridges/primitives/chain-westend/Cargo.toml @@ -7,8 +7,6 @@ edition = "2021" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" [dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } -scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } # Bridge Dependencies @@ -18,15 +16,11 @@ bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] std = [ "bp-polkadot-core/std", "bp-runtime/std", - "codec/std", - "scale-info/std", "sp-api/std", - "sp-runtime/std", ] diff --git a/bridges/primitives/chain-westend/src/lib.rs b/bridges/primitives/chain-westend/src/lib.rs index 8d5d8d9a924d1fcee40171a95a3951eb821b8184..9f4a98baedc3747d0588b7d1fc68d0be5a3c201e 100644 --- a/bridges/primitives/chain-westend/src/lib.rs +++ b/bridges/primitives/chain-westend/src/lib.rs @@ -18,34 +18,12 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use scale_info::TypeInfo; - pub use bp_polkadot_core::*; use bp_runtime::decl_bridge_finality_runtime_apis; /// Westend Chain pub type Westend = PolkadotLike; -/// Westend Runtime `Call` enum. -/// -/// We are not currently submitting any Westend transactions => it is empty. -#[derive(codec::Encode, codec::Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum Call {} - -impl sp_runtime::traits::Dispatchable for Call { - type RuntimeOrigin = (); - type Config = (); - type Info = (); - type PostInfo = (); - - fn dispatch( - self, - _origin: Self::RuntimeOrigin, - ) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> { - unimplemented!("The Call is not expected to be dispatched.") - } -} - /// Name of the parachains pallet at the Westend runtime. pub const PARAS_PALLET_NAME: &str = "Paras"; @@ -54,13 +32,6 @@ pub const WITH_WESTEND_GRANDPA_PALLET_NAME: &str = "BridgeWestendGrandpa"; /// Name of the With-Westend parachains bridge pallet instance that is deployed at bridged chains. pub const WITH_WESTEND_BRIDGE_PARAS_PALLET_NAME: &str = "BridgeWestendParachains"; -/// The target length of a session (how often authorities change) on Westend measured in of number -/// of blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = 10 * time_units::MINUTES; - /// Maximal number of GRANDPA authorities at Westend. /// /// Corresponds to the `MaxAuthorities` constant value from the Westend runtime configuration. diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs index 2a417479d3b2fe5e3f9114587f7083691e8dc4a6..f3fe0196dc591d153556bdf64f5fb7dddac0953e 100644 --- a/bridges/primitives/chain-wococo/src/lib.rs +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -24,13 +24,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis; /// Wococo Chain pub type Wococo = PolkadotLike; -/// The target length of a session (how often authorities change) on Wococo measured in of number -/// of blocks. -/// -/// Note that since this is a target sessions may change before/after this time depending on network -/// conditions. -pub const SESSION_LENGTH: BlockNumber = time_units::MINUTES; - /// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa"; diff --git a/bridges/relays/bin-substrate/Cargo.toml b/bridges/relays/bin-substrate/Cargo.toml index a3b5ef9213ca79884309060bb0e432e34b5d5791..90adaf7e6529c49556662dc6572db8abff01d0d6 100644 --- a/bridges/relays/bin-substrate/Cargo.toml +++ b/bridges/relays/bin-substrate/Cargo.toml @@ -26,6 +26,7 @@ bp-polkadot-core = { path = "../../primitives/polkadot-core" } bp-rialto = { path = "../../primitives/chain-rialto" } bp-rialto-parachain = { path = "../../primitives/chain-rialto-parachain" } bp-runtime = { path = "../../primitives/runtime" } +bp-statemine = { path = "../../primitives/chain-statemine" } bp-westend = { path = "../../primitives/chain-westend" } bridge-runtime-common = { path = "../../bin/runtime-common" } messages-relay = { path = "../messages" } @@ -36,6 +37,7 @@ parachains-relay = { path = "../parachains" } relay-millau-client = { path = "../client-millau" } relay-rialto-client = { path = "../client-rialto" } relay-rialto-parachain-client = { path = "../client-rialto-parachain" } +relay-statemine-client = { path = "../client-statemine" } relay-substrate-client = { path = "../client-substrate" } relay-utils = { path = "../utils" } relay-westend-client = { path = "../client-westend" } diff --git a/bridges/relays/bin-substrate/src/chains/millau.rs b/bridges/relays/bin-substrate/src/chains/millau.rs index 55c48bee3efa11e7bda08caed9b3bb526c3484e1..92fc43fbe36fe339e60510c41ec172dcb86f25ba 100644 --- a/bridges/relays/bin-substrate/src/chains/millau.rs +++ b/bridges/relays/bin-substrate/src/chains/millau.rs @@ -93,7 +93,6 @@ impl CliChain for Millau { const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = Vec<u8>; fn ss58_format() -> u16 { millau_runtime::SS58Prefix::get() as u16 diff --git a/bridges/relays/bin-substrate/src/chains/mod.rs b/bridges/relays/bin-substrate/src/chains/mod.rs index 13aca0651ae529baa5223a164a2cf3e143b8b52c..5d7171691bffbeb48d988f601a001d05a0296c3e 100644 --- a/bridges/relays/bin-substrate/src/chains/mod.rs +++ b/bridges/relays/bin-substrate/src/chains/mod.rs @@ -30,6 +30,7 @@ pub mod westend_parachains_to_millau; mod millau; mod rialto; mod rialto_parachain; +mod statemine; mod westend; #[cfg(test)] diff --git a/bridges/relays/bin-substrate/src/chains/rialto.rs b/bridges/relays/bin-substrate/src/chains/rialto.rs index 6a322d889cb9bfd0897718724ad41e4df5f5d24c..43ec9dbd224e4fb1958850c1acd45af09d708466 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto.rs @@ -76,7 +76,6 @@ impl CliChain for Rialto { const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = Vec<u8>; fn ss58_format() -> u16 { rialto_runtime::SS58Prefix::get() as u16 diff --git a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs b/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs index 08cc38d90d78064a64090eb96d4362a84a4b05a4..546cd04bdde152d3d5a31bf80fe699ade63a8f66 100644 --- a/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/bridges/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -79,7 +79,6 @@ impl CliChain for RialtoParachain { const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = Vec<u8>; fn ss58_format() -> u16 { rialto_parachain_runtime::SS58Prefix::get() as u16 diff --git a/bridges/relays/bin-substrate/src/chains/statemine.rs b/bridges/relays/bin-substrate/src/chains/statemine.rs new file mode 100644 index 0000000000000000000000000000000000000000..0c0edd2f3e4841fb8c1a0aeb13fc6eb0b5007b5a --- /dev/null +++ b/bridges/relays/bin-substrate/src/chains/statemine.rs @@ -0,0 +1,34 @@ +// 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/>. + +//! Statemine chain specification for CLI. + +use crate::cli::CliChain; +use relay_statemine_client::Statemine; +use sp_version::RuntimeVersion; + +impl CliChain for Statemine { + const RUNTIME_VERSION: Option<RuntimeVersion> = Some(bp_statemine::VERSION); + + type KeyPair = sp_core::sr25519::Pair; + + fn ss58_format() -> u16 { + sp_core::crypto::Ss58AddressFormat::from( + sp_core::crypto::Ss58AddressFormatRegistry::KusamaAccount, + ) + .into() + } +} diff --git a/bridges/relays/bin-substrate/src/chains/westend.rs b/bridges/relays/bin-substrate/src/chains/westend.rs index 8d43d6a5ab70908c3e1cd9e0dde990f4f3785246..1627bc015d3234a5e3c9dc23e859c1a2bd73b21d 100644 --- a/bridges/relays/bin-substrate/src/chains/westend.rs +++ b/bridges/relays/bin-substrate/src/chains/westend.rs @@ -24,7 +24,6 @@ impl CliChain for Westend { const RUNTIME_VERSION: Option<RuntimeVersion> = None; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = Vec<u8>; fn ss58_format() -> u16 { sp_core::crypto::Ss58AddressFormat::from( @@ -38,7 +37,6 @@ impl CliChain for Westmint { const RUNTIME_VERSION: Option<RuntimeVersion> = None; type KeyPair = sp_core::sr25519::Pair; - type MessagePayload = Vec<u8>; fn ss58_format() -> u16 { sp_core::crypto::Ss58AddressFormat::from( diff --git a/bridges/relays/bin-substrate/src/cli/mod.rs b/bridges/relays/bin-substrate/src/cli/mod.rs index 2369bb60dda752200591d82207ce5f173fdafcb0..2f2f1f227b70bd9ea1e7b42bf108833e24a1bd15 100644 --- a/bridges/relays/bin-substrate/src/cli/mod.rs +++ b/bridges/relays/bin-substrate/src/cli/mod.rs @@ -172,11 +172,6 @@ pub trait CliChain: relay_substrate_client::Chain { /// In case of chains supporting multiple cryptos, pick one used by the CLI. type KeyPair: sp_core::crypto::Pair; - /// Bridge Message Payload type. - /// - /// TODO [#854] This should be removed in favor of target-specifc types. - type MessagePayload; - /// Numeric value of SS58 format. fn ss58_format() -> u16; } diff --git a/bridges/relays/client-statemine/Cargo.toml b/bridges/relays/client-statemine/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..249f9fd6f43055a7eadfc685df095b9e27a8d420 --- /dev/null +++ b/bridges/relays/client-statemine/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "relay-statemine-client" +version = "0.1.0" +authors = ["Parity Technologies <admin@parity.io>"] +edition = "2021" +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", features = ["derive"] } + +# Bridge dependencies + +bp-polkadot-core = { path = "../../primitives/polkadot-core" } +bp-statemine = { path = "../../primitives/chain-statemine" } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/bridges/relays/client-statemine/src/lib.rs b/bridges/relays/client-statemine/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..a5f6fed79f434dc342452cfecbdfdd0865cc0c1e --- /dev/null +++ b/bridges/relays/client-statemine/src/lib.rs @@ -0,0 +1,112 @@ +// 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 used to connect to the Statemine chain. + +use codec::Encode; +use frame_support::weights::Weight; +use relay_substrate_client::{ + Chain, ChainBase, ChainWithTransactions, Error as SubstrateError, SignParam, + UnsignedTransaction, +}; +use sp_core::Pair; +use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; +use std::time::Duration; + +pub mod runtime; + +/// Statemine chain definition +#[derive(Debug, Clone, Copy)] +pub struct Statemine; + +impl ChainBase for Statemine { + type BlockNumber = bp_statemine::BlockNumber; + type Hash = bp_statemine::Hash; + type Hasher = bp_statemine::Hasher; + type Header = bp_statemine::Header; + + type AccountId = bp_statemine::AccountId; + type Balance = bp_statemine::Balance; + type Index = bp_statemine::Nonce; + type Signature = bp_statemine::Signature; + + fn max_extrinsic_size() -> u32 { + bp_statemine::Statemine::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + bp_statemine::Statemine::max_extrinsic_weight() + } +} + +impl Chain for Statemine { + const NAME: &'static str = "Statemine"; + const TOKEN_ID: Option<&'static str> = Some("kusama"); + const BEST_FINALIZED_HEADER_ID_METHOD: &'static str = "<unused>"; + const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(6); + const STORAGE_PROOF_OVERHEAD: u32 = bp_statemine::EXTRA_STORAGE_PROOF_SIZE; + + type SignedBlock = bp_statemine::SignedBlock; + type Call = runtime::Call; +} + +impl ChainWithTransactions for Statemine { + type AccountKeyPair = sp_core::sr25519::Pair; + type SignedTransaction = runtime::UncheckedExtrinsic; + + fn sign_transaction( + param: SignParam<Self>, + unsigned: UnsignedTransaction<Self>, + ) -> Result<Self::SignedTransaction, SubstrateError> { + let raw_payload = SignedPayload::new( + unsigned.call.clone(), + bp_statemine::SignedExtensions::new( + param.spec_version, + param.transaction_version, + unsigned.era, + param.genesis_hash, + unsigned.nonce, + unsigned.tip, + ), + ) + .expect("SignedExtension never fails."); + 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(runtime::UncheckedExtrinsic::new_signed( + call, + signer.into_account().into(), + signature.into(), + extra, + )) + } + + fn is_signed(tx: &Self::SignedTransaction) -> bool { + tx.signature.is_some() + } + + fn is_signed_by(signer: &Self::AccountKeyPair, tx: &Self::SignedTransaction) -> bool { + tx.signature + .as_ref() + .map(|(address, _, _)| *address == bp_statemine::Address::Id(signer.public().into())) + .unwrap_or(false) + } + + fn parse_transaction(_tx: Self::SignedTransaction) -> Option<UnsignedTransaction<Self>> { + unimplemented!("not used on Statemine") + } +} diff --git a/bridges/relays/client-statemine/src/runtime.rs b/bridges/relays/client-statemine/src/runtime.rs new file mode 100644 index 0000000000000000000000000000000000000000..92924555769e4ccad0bec10a5cf290e8a9b18721 --- /dev/null +++ b/bridges/relays/client-statemine/src/runtime.rs @@ -0,0 +1,68 @@ +// 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 Statemine runtime. + +use codec::{Decode, Encode}; +use scale_info::TypeInfo; +use sp_runtime::FixedU128; + +/// Unchecked Statemine extrinsic. +pub type UncheckedExtrinsic = bp_polkadot_core::UncheckedExtrinsic<Call>; + +/// Statemine Runtime `Call` enum. +/// +/// The enum represents a subset of possible `Call`s we can send to Statemine chain. +/// Ideally this code would be auto-generated from metadata, because we want to +/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s. +/// +/// All entries here (like pretty much in the entire file) must be kept in sync with Statemine +/// `construct_runtime`, so that we maintain SCALE-compatibility. +/// +/// See: [link](https://github.com/paritytech/cumulus/blob/master/parachains/runtimes/assets/statemine/src/lib.rs) +#[allow(clippy::large_enum_variant)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub enum Call { + /// With-Statemint bridge pallet. + // TODO (https://github.com/paritytech/parity-bridges-common/issues/1626): + // must be updated when we'll make appropriate changes in the Statemine runtime + #[codec(index = 42)] + WithStatemintBridgePallet(WithStatemintBridgePalletCall), +} + +/// Calls of the with-Statemint bridge pallet. +// TODO (https://github.com/paritytech/parity-bridges-common/issues/1626): +// must be updated when we'll make appropriate changes in the Statemine runtime +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum WithStatemintBridgePalletCall { + #[codec(index = 42)] + update_dot_to_ksm_conversion_rate(FixedU128), +} + +impl sp_runtime::traits::Dispatchable for Call { + type RuntimeOrigin = (); + type Config = (); + type Info = (); + type PostInfo = (); + + fn dispatch( + self, + _origin: Self::RuntimeOrigin, + ) -> sp_runtime::DispatchResultWithInfo<Self::PostInfo> { + unimplemented!("The Call is not expected to be dispatched.") + } +} diff --git a/bridges/relays/client-westend/src/lib.rs b/bridges/relays/client-westend/src/lib.rs index f6a4220c618a4c1bbe7a4f93d6c3bb81e0adc113..0f650e9e2847fe92a3f78f1f271efbe66edaf78f 100644 --- a/bridges/relays/client-westend/src/lib.rs +++ b/bridges/relays/client-westend/src/lib.rs @@ -60,7 +60,7 @@ impl Chain for Westend { const STORAGE_PROOF_OVERHEAD: u32 = bp_westend::EXTRA_STORAGE_PROOF_SIZE; type SignedBlock = bp_westend::SignedBlock; - type Call = bp_westend::Call; + type Call = (); } impl RelayChain for Westend { @@ -117,5 +117,5 @@ impl Chain for Westmint { const STORAGE_PROOF_OVERHEAD: u32 = bp_westend::EXTRA_STORAGE_PROOF_SIZE; type SignedBlock = bp_westend::SignedBlock; - type Call = bp_westend::Call; + type Call = (); }