mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
[cumulus] parachains-common testnet constants cleaning (#3134)
The `parachains-common` contains a lots of constants and type definitions which are used for `polkadot-sdk`'s testnet runtimes and also for `polkadot-fellows`'s production [SP runtimes](https://github.com/polkadot-fellows/runtimes/tree/main/system-parachains/constants). This PR cleans `parachains-common` module to contain only common and generic functionality. Testnet-specific constants have been moved to the separate module dedicated just for testnets: `polkadot-sdk/cumulus/parachains/runtimes/constants/` Part of: https://github.com/paritytech/polkadot-sdk/issues/3054 --------- Co-authored-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
[package]
|
||||
name = "testnet-parachains-constants"
|
||||
version = "1.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
description = "Common constants for Testnet Parachains runtimes"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[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
|
||||
polkadot-core-primitives = { path = "../../../../polkadot/core-primitives", default-features = false }
|
||||
rococo-runtime-constants = { path = "../../../../polkadot/runtime/rococo/constants", default-features = false, optional = true }
|
||||
westend-runtime-constants = { path = "../../../../polkadot/runtime/westend/constants", default-features = false, optional = true }
|
||||
xcm = { package = "staging-xcm", path = "../../../../polkadot/xcm", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"frame-support/std",
|
||||
"polkadot-core-primitives/std",
|
||||
"rococo-runtime-constants?/std",
|
||||
"sp-runtime/std",
|
||||
"westend-runtime-constants?/std",
|
||||
"xcm/std",
|
||||
]
|
||||
|
||||
# Test runtimes specific features.
|
||||
rococo = ["rococo-runtime-constants"]
|
||||
westend = ["westend-runtime-constants"]
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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)]
|
||||
|
||||
#[cfg(feature = "rococo")]
|
||||
pub mod rococo;
|
||||
#[cfg(feature = "westend")]
|
||||
pub mod westend;
|
||||
@@ -0,0 +1,135 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
pub mod snowbridge {
|
||||
use frame_support::parameter_types;
|
||||
use xcm::opaque::lts::NetworkId;
|
||||
|
||||
/// The pallet index of the Ethereum inbound queue pallet in the bridge hub runtime.
|
||||
pub const INBOUND_QUEUE_PALLET_INDEX: u8 = 80;
|
||||
|
||||
parameter_types! {
|
||||
/// Network and location for the Ethereum chain. On Rococo, the Ethereum chain bridged
|
||||
/// to is the Sepolia Ethereum testnet, with chain ID 11155111.
|
||||
/// <https://chainlist.org/chain/11155111>
|
||||
/// <https://ethereum.org/en/developers/docs/apis/json-rpc/#net_version>
|
||||
pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
// 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");
|
||||
/// Fellowship treasury pallet ID.
|
||||
pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user