From 0c6370e11549195d0415969819720513d23c2fa4 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Fri, 30 Sep 2022 15:42:55 +0300 Subject: [PATCH] remove unnecessary consts (#1586) --- Cargo.lock | 23 ------- primitives/chain-kusama/Cargo.toml | 10 --- primitives/chain-kusama/src/lib.rs | 61 +------------------ primitives/chain-polkadot/Cargo.toml | 10 --- primitives/chain-polkadot/src/lib.rs | 61 +------------------ primitives/chain-rococo/Cargo.toml | 12 ---- primitives/chain-rococo/src/lib.rs | 57 +---------------- primitives/chain-westend/Cargo.toml | 6 -- primitives/chain-westend/src/lib.rs | 35 ----------- primitives/chain-wococo/Cargo.toml | 8 --- primitives/chain-wococo/src/lib.rs | 14 +---- relays/bin-substrate/src/chains/millau.rs | 2 +- relays/bin-substrate/src/chains/rialto.rs | 2 +- .../src/chains/rialto_parachain.rs | 2 +- relays/bin-substrate/src/chains/westend.rs | 4 +- relays/bin-substrate/src/cli/chain_schema.rs | 2 +- relays/bin-substrate/src/cli/mod.rs | 4 +- relays/client-kusama/src/lib.rs | 1 - relays/client-millau/src/lib.rs | 2 +- relays/client-polkadot/src/lib.rs | 1 - relays/client-rialto-parachain/src/lib.rs | 2 +- relays/client-rialto/src/lib.rs | 2 +- relays/client-rococo/src/lib.rs | 1 - relays/client-substrate/src/chain.rs | 7 +-- relays/client-substrate/src/test_chain.rs | 3 +- relays/client-westend/src/lib.rs | 2 - relays/client-wococo/src/lib.rs | 1 - .../src/messages_target.rs | 10 +-- 28 files changed, 29 insertions(+), 316 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57ab37088ccd..6fafc443e9c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -710,15 +710,10 @@ dependencies = [ name = "bp-kusama" version = "0.1.0" dependencies = [ - "bp-messages", "bp-polkadot-core", "bp-runtime", - "frame-support", "smallvec", "sp-api", - "sp-runtime", - "sp-std", - "sp-version", ] [[package]] @@ -779,15 +774,10 @@ dependencies = [ name = "bp-polkadot" version = "0.1.0" dependencies = [ - "bp-messages", "bp-polkadot-core", "bp-runtime", - "frame-support", "smallvec", "sp-api", - "sp-runtime", - "sp-std", - "sp-version", ] [[package]] @@ -853,16 +843,10 @@ dependencies = [ name = "bp-rococo" version = "0.1.0" dependencies = [ - "bp-messages", "bp-polkadot-core", "bp-runtime", - "frame-support", - "parity-scale-codec", "smallvec", "sp-api", - "sp-runtime", - "sp-std", - "sp-version", ] [[package]] @@ -907,28 +891,21 @@ dependencies = [ "bp-header-chain", "bp-polkadot-core", "bp-runtime", - "frame-support", "parity-scale-codec", "scale-info", "smallvec", "sp-api", "sp-runtime", - "sp-std", - "sp-version", ] [[package]] name = "bp-wococo" version = "0.1.0" dependencies = [ - "bp-messages", "bp-polkadot-core", "bp-rococo", "bp-runtime", - "parity-scale-codec", "sp-api", - "sp-runtime", - "sp-std", ] [[package]] diff --git a/primitives/chain-kusama/Cargo.toml b/primitives/chain-kusama/Cargo.toml index a676b565c33d..ef902fef824c 100644 --- a/primitives/chain-kusama/Cargo.toml +++ b/primitives/chain-kusama/Cargo.toml @@ -11,27 +11,17 @@ smallvec = "1.7" # Bridge Dependencies -bp-messages = { path = "../messages", default-features = false } bp-polkadot-core = { path = "../polkadot-core", default-features = false } bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies -frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } 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 } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] std = [ - "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", - "frame-support/std", "sp-api/std", - "sp-runtime/std", - "sp-std/std", - "sp-version/std", ] diff --git a/primitives/chain-kusama/src/lib.rs b/primitives/chain-kusama/src/lib.rs index 0b218b22250f..7837afe690e4 100644 --- a/primitives/chain-kusama/src/lib.rs +++ b/primitives/chain-kusama/src/lib.rs @@ -18,58 +18,12 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use bp_messages::{ - InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, -}; -use frame_support::weights::{ - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, -}; -use sp_runtime::FixedU128; -use sp_std::prelude::*; -use sp_version::RuntimeVersion; - pub use bp_polkadot_core::*; -use bp_runtime::decl_bridge_runtime_apis; +use bp_runtime::decl_bridge_finality_runtime_apis; /// Kusama Chain pub type Kusama = PolkadotLike; -// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo. -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: sp_version::create_runtime_str!("kusama"), - impl_name: sp_version::create_runtime_str!("parity-kusama"), - authoring_version: 2, - spec_version: 9180, - impl_version: 0, - apis: sp_version::create_apis_vec![[]], - transaction_version: 11, - state_version: 0, -}; - -// NOTE: This needs to be kept up to date with the Kusama runtime found in the Polkadot repo. -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - const CENTS: Balance = 1_000_000_000_000 / 30_000; - // in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - let p = CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); - smallvec::smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - -/// Per-byte fee for Kusama transactions. -pub const TRANSACTION_BYTE_FEE: Balance = 10 * 1_000_000_000_000 / 30_000 / 1_000; - -/// Existential deposit on Kusama. -pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 30_000; - /// The target length of a session (how often authorities change) on Kusama measured in of number of /// blocks. /// @@ -79,16 +33,5 @@ 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"; -/// Name of the With-Kusama messages pallet instance that is deployed at bridged chains. -pub const WITH_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages"; - -/// Name of the transaction payment pallet at the Kusama runtime. -pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; - -/// Name of the DOT->KSM conversion rate stored in the Kusama runtime. -pub const POLKADOT_TO_KUSAMA_CONVERSION_RATE_PARAMETER_NAME: &str = - "PolkadotToKusamaConversionRate"; -/// Name of the Polkadot fee multiplier parameter, stored in the Polkadot runtime. -pub const POLKADOT_FEE_MULTIPLIER_PARAMETER_NAME: &str = "PolkadotFeeMultiplier"; -decl_bridge_runtime_apis!(kusama); +decl_bridge_finality_runtime_apis!(kusama); diff --git a/primitives/chain-polkadot/Cargo.toml b/primitives/chain-polkadot/Cargo.toml index 738899b658cd..8be9b25c77f5 100644 --- a/primitives/chain-polkadot/Cargo.toml +++ b/primitives/chain-polkadot/Cargo.toml @@ -11,27 +11,17 @@ smallvec = "1.7" # Bridge Dependencies -bp-messages = { path = "../messages", default-features = false } bp-polkadot-core = { path = "../polkadot-core", default-features = false } bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies -frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } 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 } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] std = [ - "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", - "frame-support/std", "sp-api/std", - "sp-runtime/std", - "sp-std/std", - "sp-version/std", ] diff --git a/primitives/chain-polkadot/src/lib.rs b/primitives/chain-polkadot/src/lib.rs index 6f584f5526a2..cfcbacb0d1a7 100644 --- a/primitives/chain-polkadot/src/lib.rs +++ b/primitives/chain-polkadot/src/lib.rs @@ -18,58 +18,12 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use bp_messages::{ - InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, -}; -use frame_support::weights::{ - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, -}; -use sp_runtime::FixedU128; -use sp_std::prelude::*; -use sp_version::RuntimeVersion; - pub use bp_polkadot_core::*; -use bp_runtime::decl_bridge_runtime_apis; +use bp_runtime::decl_bridge_finality_runtime_apis; /// Polkadot Chain pub type Polkadot = PolkadotLike; -// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo. -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: sp_version::create_runtime_str!("polkadot"), - impl_name: sp_version::create_runtime_str!("parity-polkadot"), - authoring_version: 0, - spec_version: 9180, - impl_version: 0, - apis: sp_version::create_apis_vec![[]], - transaction_version: 12, - state_version: 0, -}; - -// NOTE: This needs to be kept up to date with the Polkadot runtime found in the Polkadot repo. -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - const CENTS: Balance = 10_000_000_000 / 100; - // in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - let p = CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); - smallvec::smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - -/// Per-byte fee for Polkadot transactions. -pub const TRANSACTION_BYTE_FEE: Balance = 10 * 10_000_000_000 / 100 / 1_000; - -/// Existential deposit on Polkadot. -pub const EXISTENTIAL_DEPOSIT: Balance = 10_000_000_000; - /// The target length of a session (how often authorities change) on Polkadot measured in of number /// of blocks. /// @@ -79,16 +33,5 @@ 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"; -/// Name of the With-Polkadot messages pallet instance that is deployed at bridged chains. -pub const WITH_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages"; - -/// Name of the transaction payment pallet at the Polkadot runtime. -pub const TRANSACTION_PAYMENT_PALLET_NAME: &str = "TransactionPayment"; - -/// Name of the KSM->DOT conversion rate parameter, stored in the Polkadot runtime. -pub const KUSAMA_TO_POLKADOT_CONVERSION_RATE_PARAMETER_NAME: &str = - "KusamaToPolkadotConversionRate"; -/// Name of the Kusama fee multiplier parameter, stored in the Polkadot runtime. -pub const KUSAMA_FEE_MULTIPLIER_PARAMETER_NAME: &str = "KusamaFeeMultiplier"; -decl_bridge_runtime_apis!(polkadot); +decl_bridge_finality_runtime_apis!(polkadot); diff --git a/primitives/chain-rococo/Cargo.toml b/primitives/chain-rococo/Cargo.toml index fe6b07eeb766..730fad599bb1 100644 --- a/primitives/chain-rococo/Cargo.toml +++ b/primitives/chain-rococo/Cargo.toml @@ -7,31 +7,19 @@ 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"] } smallvec = "1.7" # Bridge Dependencies -bp-messages = { path = "../messages", default-features = false } bp-polkadot-core = { path = "../polkadot-core", default-features = false } bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies -frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } 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 } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] std = [ - "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", - "frame-support/std", - "codec/std", "sp-api/std", - "sp-runtime/std", - "sp-std/std", - "sp-version/std", ] diff --git a/primitives/chain-rococo/src/lib.rs b/primitives/chain-rococo/src/lib.rs index aa1d40ce92e2..39188066dca4 100644 --- a/primitives/chain-rococo/src/lib.rs +++ b/primitives/chain-rococo/src/lib.rs @@ -18,18 +18,8 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use bp_messages::{ - InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, -}; -use frame_support::weights::{ - Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, -}; -use sp_runtime::FixedU128; -use sp_std::prelude::*; -use sp_version::RuntimeVersion; - pub use bp_polkadot_core::*; -use bp_runtime::decl_bridge_runtime_apis; +use bp_runtime::decl_bridge_finality_runtime_apis; /// Rococo Chain pub type Rococo = PolkadotLike; @@ -41,50 +31,7 @@ pub type Rococo = PolkadotLike; /// conditions. pub const SESSION_LENGTH: BlockNumber = time_units::HOURS; -// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo. -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: sp_version::create_runtime_str!("rococo"), - impl_name: sp_version::create_runtime_str!("parity-rococo-v2.0"), - authoring_version: 0, - spec_version: 9200, - impl_version: 0, - apis: sp_version::create_apis_vec![[]], - transaction_version: 0, - state_version: 0, -}; - -// NOTE: This needs to be kept up to date with the Rococo runtime found in the Polkadot repo. -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - const CENTS: Balance = 1_000_000_000_000 / 100; - let p = CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); - smallvec::smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - /// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains. pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa"; -/// Name of the With-Rococo messages pallet instance that is deployed at bridged chains. -pub const WITH_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages"; - -/// Existential deposit on Rococo. -pub const EXISTENTIAL_DEPOSIT: Balance = 1_000_000_000_000 / 100; - -/// Weight of pay-dispatch-fee operation for inbound messages at Rococo chain. -/// -/// This value corresponds to the result of -/// `pallet_bridge_messages::WeightInfoExt::pay_inbound_dispatch_fee_overhead()` call for your -/// chain. Don't put too much reserve there, because it is used to **decrease** -/// `DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT` cost. So putting large reserve would make delivery -/// transactions cheaper. -pub const PAY_INBOUND_DISPATCH_FEE_WEIGHT: Weight = 600_000_000; -decl_bridge_runtime_apis!(rococo); +decl_bridge_finality_runtime_apis!(rococo); diff --git a/primitives/chain-westend/Cargo.toml b/primitives/chain-westend/Cargo.toml index f37aa3b0e397..ca5840b9dea5 100644 --- a/primitives/chain-westend/Cargo.toml +++ b/primitives/chain-westend/Cargo.toml @@ -19,11 +19,8 @@ bp-runtime = { path = "../runtime", default-features = false } # Substrate Based Dependencies -frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } 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 } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] @@ -31,11 +28,8 @@ std = [ "bp-header-chain/std", "bp-polkadot-core/std", "bp-runtime/std", - "frame-support/std", "codec/std", "scale-info/std", "sp-api/std", "sp-runtime/std", - "sp-std/std", - "sp-version/std", ] diff --git a/primitives/chain-westend/src/lib.rs b/primitives/chain-westend/src/lib.rs index 1e023295a8a0..08803b7a3dd3 100644 --- a/primitives/chain-westend/src/lib.rs +++ b/primitives/chain-westend/src/lib.rs @@ -18,12 +18,7 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use frame_support::weights::{ - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, -}; use scale_info::TypeInfo; -use sp_std::prelude::*; -use sp_version::RuntimeVersion; pub use bp_polkadot_core::*; use bp_runtime::decl_bridge_finality_runtime_apis; @@ -31,36 +26,6 @@ use bp_runtime::decl_bridge_finality_runtime_apis; /// Westend Chain pub type Westend = PolkadotLike; -// NOTE: This needs to be kept up to date with the Westend runtime found in the Polkadot repo. -pub struct WeightToFee; -impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - const CENTS: Balance = 1_000_000_000_000 / 1_000; - // in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - let p = CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); - smallvec::smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - -// NOTE: This needs to be kept up to date with the Westend runtime found in the Polkadot repo. -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: sp_version::create_runtime_str!("westend"), - impl_name: sp_version::create_runtime_str!("parity-westend"), - authoring_version: 2, - spec_version: 9140, - impl_version: 0, - apis: sp_version::create_apis_vec![[]], - transaction_version: 8, - state_version: 0, -}; - /// Westend Runtime `Call` enum. /// /// We are not currently submitting any Westend transactions => it is empty. diff --git a/primitives/chain-wococo/Cargo.toml b/primitives/chain-wococo/Cargo.toml index 92e7c9e80e27..27297fe98543 100644 --- a/primitives/chain-wococo/Cargo.toml +++ b/primitives/chain-wococo/Cargo.toml @@ -7,28 +7,20 @@ 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"] } # Bridge Dependencies -bp-messages = { path = "../messages", default-features = false } bp-polkadot-core = { path = "../polkadot-core", default-features = false } bp-rococo = { path = "../chain-rococo", default-features = false } 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 } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } [features] default = ["std"] std = [ - "bp-messages/std", "bp-polkadot-core/std", "bp-runtime/std", "bp-rococo/std", - "codec/std", "sp-api/std", - "sp-runtime/std", - "sp-std/std", ] diff --git a/primitives/chain-wococo/src/lib.rs b/primitives/chain-wococo/src/lib.rs index c1626b0dc67d..2a417479d3b2 100644 --- a/primitives/chain-wococo/src/lib.rs +++ b/primitives/chain-wococo/src/lib.rs @@ -18,16 +18,8 @@ // RuntimeApi generated functions #![allow(clippy::too_many_arguments)] -use bp_messages::{ - InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, -}; -use sp_runtime::FixedU128; -use sp_std::prelude::*; - pub use bp_polkadot_core::*; -// Rococo runtime = Wococo runtime -pub use bp_rococo::{WeightToFee, EXISTENTIAL_DEPOSIT, PAY_INBOUND_DISPATCH_FEE_WEIGHT, VERSION}; -use bp_runtime::decl_bridge_runtime_apis; +use bp_runtime::decl_bridge_finality_runtime_apis; /// Wococo Chain pub type Wococo = PolkadotLike; @@ -41,7 +33,5 @@ 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"; -/// Name of the With-Wococo messages pallet instance that is deployed at bridged chains. -pub const WITH_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages"; -decl_bridge_runtime_apis!(wococo); +decl_bridge_finality_runtime_apis!(wococo); diff --git a/relays/bin-substrate/src/chains/millau.rs b/relays/bin-substrate/src/chains/millau.rs index b71ecb288e9d..59d53edf997e 100644 --- a/relays/bin-substrate/src/chains/millau.rs +++ b/relays/bin-substrate/src/chains/millau.rs @@ -90,7 +90,7 @@ impl CliEncodeMessage for Millau { } impl CliChain for Millau { - const RUNTIME_VERSION: RuntimeVersion = millau_runtime::VERSION; + const RUNTIME_VERSION: Option = Some(millau_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; type MessagePayload = Vec; diff --git a/relays/bin-substrate/src/chains/rialto.rs b/relays/bin-substrate/src/chains/rialto.rs index 9dd86c9d9533..285476a33129 100644 --- a/relays/bin-substrate/src/chains/rialto.rs +++ b/relays/bin-substrate/src/chains/rialto.rs @@ -73,7 +73,7 @@ impl CliEncodeMessage for Rialto { } impl CliChain for Rialto { - const RUNTIME_VERSION: RuntimeVersion = rialto_runtime::VERSION; + const RUNTIME_VERSION: Option = Some(rialto_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; type MessagePayload = Vec; diff --git a/relays/bin-substrate/src/chains/rialto_parachain.rs b/relays/bin-substrate/src/chains/rialto_parachain.rs index 8cd7135c27a3..c359c42087d4 100644 --- a/relays/bin-substrate/src/chains/rialto_parachain.rs +++ b/relays/bin-substrate/src/chains/rialto_parachain.rs @@ -74,7 +74,7 @@ impl CliEncodeMessage for RialtoParachain { } impl CliChain for RialtoParachain { - const RUNTIME_VERSION: RuntimeVersion = rialto_parachain_runtime::VERSION; + const RUNTIME_VERSION: Option = Some(rialto_parachain_runtime::VERSION); type KeyPair = sp_core::sr25519::Pair; type MessagePayload = Vec; diff --git a/relays/bin-substrate/src/chains/westend.rs b/relays/bin-substrate/src/chains/westend.rs index ae5294470748..8d43d6a5ab70 100644 --- a/relays/bin-substrate/src/chains/westend.rs +++ b/relays/bin-substrate/src/chains/westend.rs @@ -21,7 +21,7 @@ use relay_westend_client::{Westend, Westmint}; use sp_version::RuntimeVersion; impl CliChain for Westend { - const RUNTIME_VERSION: RuntimeVersion = bp_westend::VERSION; + const RUNTIME_VERSION: Option = None; type KeyPair = sp_core::sr25519::Pair; type MessagePayload = Vec; @@ -35,7 +35,7 @@ impl CliChain for Westend { } impl CliChain for Westmint { - const RUNTIME_VERSION: RuntimeVersion = bp_westend::VERSION; + const RUNTIME_VERSION: Option = None; type KeyPair = sp_core::sr25519::Pair; type MessagePayload = Vec; diff --git a/relays/bin-substrate/src/cli/chain_schema.rs b/relays/bin-substrate/src/cli/chain_schema.rs index 0f108aed6de5..8023fd9b0f7f 100644 --- a/relays/bin-substrate/src/cli/chain_schema.rs +++ b/relays/bin-substrate/src/cli/chain_schema.rs @@ -115,7 +115,7 @@ macro_rules! declare_chain_connection_params_cli_schema { ) -> anyhow::Result> { let chain_runtime_version = self .[<$chain_prefix _runtime_version>] - .into_runtime_version(Some(Chain::RUNTIME_VERSION))?; + .into_runtime_version(Chain::RUNTIME_VERSION)?; Ok(relay_substrate_client::Client::new(relay_substrate_client::ConnectionParams { host: self.[<$chain_prefix _host>], port: self.[<$chain_prefix _port>], diff --git a/relays/bin-substrate/src/cli/mod.rs b/relays/bin-substrate/src/cli/mod.rs index 44bfce9f384e..42a073bd4f65 100644 --- a/relays/bin-substrate/src/cli/mod.rs +++ b/relays/bin-substrate/src/cli/mod.rs @@ -163,7 +163,9 @@ impl Balance { /// Used to abstract away CLI commands. pub trait CliChain: relay_substrate_client::Chain { /// Current version of the chain runtime, known to relay. - const RUNTIME_VERSION: sp_version::RuntimeVersion; + /// + /// can be `None` if relay is not going to submit transactions to that chain. + const RUNTIME_VERSION: Option; /// Crypto KeyPair type used to send messages. /// diff --git a/relays/client-kusama/src/lib.rs b/relays/client-kusama/src/lib.rs index b076da7ab750..cdf7213df9bb 100644 --- a/relays/client-kusama/src/lib.rs +++ b/relays/client-kusama/src/lib.rs @@ -58,7 +58,6 @@ impl Chain for Kusama { type SignedBlock = bp_kusama::SignedBlock; type Call = (); - type WeightToFee = bp_kusama::WeightToFee; } impl ChainWithGrandpa for Kusama { diff --git a/relays/client-millau/src/lib.rs b/relays/client-millau/src/lib.rs index 7bab3669c4d0..3c861214df4c 100644 --- a/relays/client-millau/src/lib.rs +++ b/relays/client-millau/src/lib.rs @@ -71,6 +71,7 @@ impl ChainWithMessages for Millau { bp_millau::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; + type WeightToFee = bp_millau::WeightToFee; type WeightInfo = (); } @@ -85,7 +86,6 @@ impl Chain for Millau { type SignedBlock = millau_runtime::SignedBlock; type Call = millau_runtime::Call; - type WeightToFee = bp_millau::WeightToFee; } impl ChainWithBalances for Millau { diff --git a/relays/client-polkadot/src/lib.rs b/relays/client-polkadot/src/lib.rs index 9327c76c4ef3..bb3867fda531 100644 --- a/relays/client-polkadot/src/lib.rs +++ b/relays/client-polkadot/src/lib.rs @@ -58,7 +58,6 @@ impl Chain for Polkadot { type SignedBlock = bp_polkadot::SignedBlock; type Call = (); - type WeightToFee = bp_polkadot::WeightToFee; } impl ChainWithGrandpa for Polkadot { diff --git a/relays/client-rialto-parachain/src/lib.rs b/relays/client-rialto-parachain/src/lib.rs index c678a21420fd..489baa4be5aa 100644 --- a/relays/client-rialto-parachain/src/lib.rs +++ b/relays/client-rialto-parachain/src/lib.rs @@ -66,7 +66,6 @@ impl Chain for RialtoParachain { type SignedBlock = rialto_parachain_runtime::SignedBlock; type Call = rialto_parachain_runtime::Call; - type WeightToFee = bp_rialto_parachain::WeightToFee; } impl ChainWithBalances for RialtoParachain { @@ -93,6 +92,7 @@ impl ChainWithMessages for RialtoParachain { bp_rialto_parachain::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = bp_rialto_parachain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; + type WeightToFee = bp_rialto_parachain::WeightToFee; type WeightInfo = (); } diff --git a/relays/client-rialto/src/lib.rs b/relays/client-rialto/src/lib.rs index b2984336cd26..816a21baf0c5 100644 --- a/relays/client-rialto/src/lib.rs +++ b/relays/client-rialto/src/lib.rs @@ -66,7 +66,6 @@ impl Chain for Rialto { type SignedBlock = rialto_runtime::SignedBlock; type Call = rialto_runtime::Call; - type WeightToFee = bp_rialto::WeightToFee; } impl RelayChain for Rialto { @@ -92,6 +91,7 @@ impl ChainWithMessages for Rialto { bp_rialto::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = bp_rialto::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; + type WeightToFee = bp_rialto::WeightToFee; type WeightInfo = (); } diff --git a/relays/client-rococo/src/lib.rs b/relays/client-rococo/src/lib.rs index c33af96aedf6..f4905d52dc7e 100644 --- a/relays/client-rococo/src/lib.rs +++ b/relays/client-rococo/src/lib.rs @@ -61,7 +61,6 @@ impl Chain for Rococo { type SignedBlock = bp_rococo::SignedBlock; type Call = (); - type WeightToFee = bp_rococo::WeightToFee; } impl ChainWithGrandpa for Rococo { diff --git a/relays/client-substrate/src/chain.rs b/relays/client-substrate/src/chain.rs index 9562d68d4611..3f483078cac7 100644 --- a/relays/client-substrate/src/chain.rs +++ b/relays/client-substrate/src/chain.rs @@ -59,9 +59,6 @@ pub trait Chain: ChainBase + Clone { type SignedBlock: Member + Serialize + DeserializeOwned + BlockWithJustification; /// The aggregated `Call` type. type Call: Clone + Codec + Dispatchable + Debug + Send; - - /// Type that is used by the chain, to convert from weight to fee. - type WeightToFee: WeightToFee; } /// Substrate-based relay chain that supports parachains. @@ -120,6 +117,8 @@ pub trait ChainWithMessages: Chain { /// `ChainWithMessages`. const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce; + /// Type that is used by the chain, to convert from weight to fee. + type WeightToFee: WeightToFee; /// Weights of message pallet calls. type WeightInfo: pallet_bridge_messages::WeightInfoExt; } @@ -127,7 +126,7 @@ pub trait ChainWithMessages: Chain { /// Call type used by the chain. pub type CallOf = ::Call; /// Weight-to-Fee type used by the chain. -pub type WeightToFeeOf = ::WeightToFee; +pub type WeightToFeeOf = ::WeightToFee; /// Transaction status of the chain. pub type TransactionStatusOf = TransactionStatus, HashOf>; diff --git a/relays/client-substrate/src/test_chain.rs b/relays/client-substrate/src/test_chain.rs index f9a9e2455ed9..8e1832db0845 100644 --- a/relays/client-substrate/src/test_chain.rs +++ b/relays/client-substrate/src/test_chain.rs @@ -22,7 +22,7 @@ #![cfg(any(feature = "test-helpers", test))] use crate::{Chain, ChainWithBalances}; -use frame_support::weights::{IdentityFee, Weight}; +use frame_support::weights::Weight; use std::time::Duration; /// Chain that may be used in tests. @@ -60,7 +60,6 @@ impl Chain for TestChain { sp_runtime::generic::Block, >; type Call = (); - type WeightToFee = IdentityFee; } impl ChainWithBalances for TestChain { diff --git a/relays/client-westend/src/lib.rs b/relays/client-westend/src/lib.rs index 4b27bfeb82d8..f6a4220c618a 100644 --- a/relays/client-westend/src/lib.rs +++ b/relays/client-westend/src/lib.rs @@ -61,7 +61,6 @@ impl Chain for Westend { type SignedBlock = bp_westend::SignedBlock; type Call = bp_westend::Call; - type WeightToFee = bp_westend::WeightToFee; } impl RelayChain for Westend { @@ -119,5 +118,4 @@ impl Chain for Westmint { type SignedBlock = bp_westend::SignedBlock; type Call = bp_westend::Call; - type WeightToFee = bp_westend::WeightToFee; } diff --git a/relays/client-wococo/src/lib.rs b/relays/client-wococo/src/lib.rs index 06a63e7d2b46..87da6fb83679 100644 --- a/relays/client-wococo/src/lib.rs +++ b/relays/client-wococo/src/lib.rs @@ -61,7 +61,6 @@ impl Chain for Wococo { type SignedBlock = bp_wococo::SignedBlock; type Call = (); - type WeightToFee = bp_wococo::WeightToFee; } impl ChainWithGrandpa for Wococo { diff --git a/relays/lib-substrate-relay/src/messages_target.rs b/relays/lib-substrate-relay/src/messages_target.rs index 4e5ba6ae087b..21a43112f81c 100644 --- a/relays/lib-substrate-relay/src/messages_target.rs +++ b/relays/lib-substrate-relay/src/messages_target.rs @@ -497,7 +497,7 @@ where /// **WARNING**: this functions will only be accurate if weight-to-fee conversion function /// is linear. For non-linear polynomials the error will grow with `weight_difference` growth. /// So better to use smaller differences. -fn compute_fee_multiplier( +fn compute_fee_multiplier( smaller_adjusted_weight_fee: BalanceOf, smaller_tx_weight: Weight, larger_adjusted_weight_fee: BalanceOf, @@ -563,17 +563,17 @@ mod tests { #[test] fn compute_fee_multiplier_returns_sane_results() { - let multiplier: FixedU128 = bp_rococo::WeightToFee::weight_to_fee(&1).into(); + let multiplier: FixedU128 = bp_rialto::WeightToFee::weight_to_fee(&1).into(); let smaller_weight = 1_000_000; let smaller_adjusted_weight_fee = - multiplier.saturating_mul_int(WeightToFeeOf::::weight_to_fee(&smaller_weight)); + multiplier.saturating_mul_int(WeightToFeeOf::::weight_to_fee(&smaller_weight)); let larger_weight = smaller_weight + 200_000; let larger_adjusted_weight_fee = - multiplier.saturating_mul_int(WeightToFeeOf::::weight_to_fee(&larger_weight)); + multiplier.saturating_mul_int(WeightToFeeOf::::weight_to_fee(&larger_weight)); assert_eq!( - compute_fee_multiplier::( + compute_fee_multiplier::( smaller_adjusted_weight_fee, smaller_weight, larger_adjusted_weight_fee,