Skip to content
Snippets Groups Projects
Unverified Commit 814b938d authored by Dónal Murray's avatar Dónal Murray Committed by GitHub
Browse files

Remove `testnets-common` (#2620)

`testnets-common` was introduced recently to start to separate testnet
parachain configurations from those of Polkadot and Kusama.

The `locks-review` and `polkadot-review` requirements are removed from
`parachains-common` in
https://github.com/paritytech/polkadot-sdk/pull/2564 and there are
[plans](https://github.com/paritytech/polkadot-sdk/pull/2564#discussion_r1410882115)
to move the Polkadot and Kusama contents of that package to the
fellowship, `testnets-common` is no longer needed.

This PR removes the crate and replaces uses of it in
`collectives-westend`, the only place it is currently used.
parent 7e7fe990
Branches
No related merge requests found
Pipeline #423443 failed with stages
in 1 hour, 32 minutes, and 13 seconds
......@@ -2668,7 +2668,6 @@ dependencies = [
"staging-xcm-builder",
"staging-xcm-executor",
"substrate-wasm-builder",
"testnets-common",
"westend-runtime-constants",
]
......@@ -19182,19 +19181,6 @@ dependencies = [
"sp-weights",
]
[[package]]
name = "testnets-common"
version = "1.0.0"
dependencies = [
"frame-support",
"polkadot-core-primitives",
"rococo-runtime-constants",
"smallvec",
"sp-runtime",
"substrate-wasm-builder",
"westend-runtime-constants",
]
[[package]]
name = "textwrap"
version = "0.16.0"
......
......@@ -95,7 +95,6 @@ members = [
"cumulus/parachains/runtimes/test-utils",
"cumulus/parachains/runtimes/testing/penpal",
"cumulus/parachains/runtimes/testing/rococo-parachain",
"cumulus/parachains/testnets-common",
"cumulus/polkadot-parachain",
"cumulus/primitives/aura",
"cumulus/primitives/core",
......
......@@ -13,6 +13,24 @@
// See the License for the specific language governing permissions and
// limitations under the License.
/// Universally recognized accounts.
pub mod account {
use frame_support::PalletId;
/// Westend treasury pallet id, used to convert into AccountId - in Westend as a destination for
/// slashed funds.
pub const WESTEND_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Alliance pallet ID - used as a temporary place to deposit a slashed imbalance before the
/// teleport to the Treasury.
pub const ALLIANCE_PALLET_ID: PalletId = PalletId(*b"py/allia");
/// Referenda pallet ID - used as a temporary place to deposit a slashed imbalance before the
/// teleport to the Treasury.
pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer");
/// Ambassador Referenda pallet ID - used as a temporary place to deposit a slashed imbalance
/// before the teleport to the Treasury.
pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref");
}
pub mod currency {
use polkadot_core_primitives::Balance;
use westend_runtime_constants as constants;
......@@ -21,6 +39,7 @@ pub mod currency {
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
pub const UNITS: Balance = constants::currency::UNITS;
pub const DOLLARS: Balance = UNITS; // 1_000_000_000_000
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;
pub const GRAND: Balance = constants::currency::GRAND;
......@@ -44,7 +63,7 @@ pub mod fee {
use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value.
/// The block saturation level. Fees will be updated based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
......@@ -110,11 +129,11 @@ pub mod fee {
/// Consensus-related.
pub mod consensus {
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the
/// relay chain.
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
/// How many parachain blocks are processed by the relay chain per parent. Limits the number of
/// blocks authored per slot.
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
......
......@@ -77,7 +77,6 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d
pallet-collective-content = { path = "../../../pallets/collective-content", default-features = false }
parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }
testnets-common = { path = "../../../testnets-common", default-features = false }
[build-dependencies]
substrate-wasm-builder = { path = "../../../../../substrate/utils/wasm-builder", optional = true }
......@@ -118,7 +117,6 @@ runtime-benchmarks = [
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"testnets-common/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]
......@@ -216,7 +214,6 @@ std = [
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"testnets-common/std",
"westend-runtime-constants/std",
"xcm-builder/std",
"xcm-executor/std",
......
......@@ -81,12 +81,14 @@ use frame_system::{
};
pub use parachains_common as common;
use parachains_common::{
impls::DealWithFees, message_queue::*, AccountId, AuraId, Balance, BlockNumber, Hash, Header,
Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
impls::DealWithFees,
message_queue::*,
westend::{account::*, consensus::*, currency::*, fee::WeightToFee},
AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO,
SLOT_DURATION,
};
use sp_runtime::RuntimeDebug;
use testnets_common::westend::{account::*, consensus::*, currency::*, fee::WeightToFee};
use xcm_config::{GovernanceLocation, XcmOriginToTransactDispatchOrigin};
#[cfg(any(feature = "std", test))]
......
[package]
name = "testnets-common"
version = "1.0.0"
authors.workspace = true
edition.workspace = true
description = "Logic and configuration specific to testnet parachain runtimes"
license = "Apache-2.0"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
smallvec = "1.11.0"
# Substrate
frame-support = { path = "../../../substrate/frame/support", default-features = false }
sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false }
# Polkadot
rococo-runtime-constants = { path = "../../../polkadot/runtime/rococo/constants", default-features = false }
westend-runtime-constants = { path = "../../../polkadot/runtime/westend/constants", default-features = false }
polkadot-core-primitives = { path = "../../../polkadot/core-primitives", default-features = false }
# Cumulus
[dev-dependencies]
[build-dependencies]
substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder" }
[features]
default = ["std"]
std = [
"frame-support/std",
"polkadot-core-primitives/std",
"rococo-runtime-constants/std",
"sp-runtime/std",
"westend-runtime-constants/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg_attr(not(feature = "std"), no_std)]
/// Since the parachains-common package is now published to crates.io, SP runtimes for testnets
/// will be adapted to use this package, and their config removed from the published common
/// package. Only the configs specific to rococo, westend and wococo will be moved here, and the
/// truly common logic will still be sourced from the parachains-common package.
///
/// In practice this just means that instead of using e.g. `[parachains_common::westend::*]`, now
/// the westend configs will be in `[testnets_common::westend::*]`.
///
/// TODO: edit all runtimes to remove the testnet configs as part of PR #1737
/// <https://github.com/paritytech/polkadot-sdk/pull/1737>
pub mod rococo;
pub mod westend;
pub mod wococo;
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
pub mod currency {
use polkadot_core_primitives::Balance;
use rococo_runtime_constants as constants;
/// The existential deposit. Set to 1/10 of its parent Relay Chain (v9010).
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
pub const UNITS: Balance = constants::currency::UNITS;
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
// map to 1/100 of what the rococo relay chain charges
constants::currency::deposit(items, bytes) / 100
}
}
pub mod fee {
use frame_support::{
pallet_prelude::Weight,
weights::{
constants::ExtrinsicBaseWeight, FeePolynomial, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
};
use polkadot_core_primitives::Balance;
use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
/// This should typically create a mapping between the following ranges:
/// - `[0, MAXIMUM_BLOCK_WEIGHT]`
/// - `[Balance::min, Balance::max]`
///
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
/// - Setting it to `0` will essentially disable the weight fee.
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
pub struct WeightToFee;
impl frame_support::weights::WeightToFee for WeightToFee {
type Balance = Balance;
fn weight_to_fee(weight: &Weight) -> Self::Balance {
let time_poly: FeePolynomial<Balance> = RefTimeToFee::polynomial().into();
let proof_poly: FeePolynomial<Balance> = ProofSizeToFee::polynomial().into();
// Take the maximum instead of the sum to charge by the more scarce resource.
time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size()))
}
}
/// Maps the reference time component of `Weight` to a fee.
pub struct RefTimeToFee;
impl WeightToFeePolynomial for RefTimeToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// In Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
let p = super::currency::CENTS;
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
/// Maps the proof size component of `Weight` to a fee.
pub struct ProofSizeToFee;
impl WeightToFeePolynomial for ProofSizeToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// Map 10kb proof to 1 CENT.
let p = super::currency::CENTS;
let q = 10_000;
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
}
/// Consensus-related.
pub mod consensus {
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
}
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/// Universally recognized accounts.
pub mod account {
use frame_support::PalletId;
/// Westend treasury pallet id, used to convert into AccountId - in Westend as a destination for
/// slashed funds.
pub const WESTEND_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry");
/// Alliance pallet ID - used as a temporary place to deposit a slashed imbalance before the
/// teleport to the Treasury.
pub const ALLIANCE_PALLET_ID: PalletId = PalletId(*b"py/allia");
/// Referenda pallet ID - used as a temporary place to deposit a slashed imbalance before the
/// teleport to the Treasury.
pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer");
/// Ambassador Referenda pallet ID - used as a temporary place to deposit a slashed imbalance
/// before the teleport to the Treasury.
pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref");
}
pub mod currency {
use polkadot_core_primitives::Balance;
use westend_runtime_constants as constants;
/// The existential deposit. Set to 1/10 of its parent Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = constants::currency::EXISTENTIAL_DEPOSIT / 10;
pub const UNITS: Balance = constants::currency::UNITS;
pub const DOLLARS: Balance = UNITS; // 1_000_000_000_000
pub const CENTS: Balance = constants::currency::CENTS;
pub const MILLICENTS: Balance = constants::currency::MILLICENTS;
pub const GRAND: Balance = constants::currency::GRAND;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
// 1/100 of Westend testnet
constants::currency::deposit(items, bytes) / 100
}
}
/// Fee-related.
pub mod fee {
use frame_support::{
pallet_prelude::Weight,
weights::{
constants::ExtrinsicBaseWeight, FeePolynomial, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
};
use polkadot_core_primitives::Balance;
use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updated based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
/// This should typically create a mapping between the following ranges:
/// - [0, MAXIMUM_BLOCK_WEIGHT]
/// - [Balance::min, Balance::max]
///
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
/// - Setting it to `0` will essentially disable the weight fee.
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
pub struct WeightToFee;
impl frame_support::weights::WeightToFee for WeightToFee {
type Balance = Balance;
fn weight_to_fee(weight: &Weight) -> Self::Balance {
let time_poly: FeePolynomial<Balance> = RefTimeToFee::polynomial().into();
let proof_poly: FeePolynomial<Balance> = ProofSizeToFee::polynomial().into();
// Take the maximum instead of the sum to charge by the more scarce resource.
time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size()))
}
}
/// Maps the reference time component of `Weight` to a fee.
pub struct RefTimeToFee;
impl WeightToFeePolynomial for RefTimeToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// In Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
// The standard system parachain configuration is 1/10 of that, as in 1/100 CENT.
let p = super::currency::CENTS;
let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
/// Maps the proof size component of `Weight` to a fee.
pub struct ProofSizeToFee;
impl WeightToFeePolynomial for ProofSizeToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// Map 10kb proof to 1 CENT.
let p = super::currency::CENTS;
let q = 10_000;
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
}
/// Consensus-related.
pub mod consensus {
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the
/// relay chain.
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1;
/// How many parachain blocks are processed by the relay chain per parent. Limits the number of
/// blocks authored per slot.
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
}
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// re-export rococo
pub use crate::rococo::{consensus, currency, fee};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment