Extract Runtime Constants into Separate Crates (#4456)

* kusama-runtime-constants created

* polkadot_runtime_constants added

* runtime constants extracted

* update node

* cargo +nightly fmt

* Delete constants.rs

* update Cargo.toml

* 2021

* runtime constants update

* utils

* utils

* node test service

* Update runtime/rococo/constants/Cargo.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* runtime-native

* bridge messages

* re-export DOLLARS

* Update runtime/westend/Cargo.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update runtime/test-runtime/Cargo.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* std feature

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Doordashcon
2021-12-11 08:10:32 +01:00
committed by GitHub
parent 7c5249c951
commit 11d343e258
28 changed files with 238 additions and 36 deletions
+10 -4
View File
@@ -84,6 +84,12 @@ polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-runtime-parachains = { path = "../../runtime/parachains" }
polkadot-node-network-protocol = { path = "../network/protocol" }
# Polkadot Runtime Constants
polkadot-runtime-constants = { path = "../../runtime/polkadot/constants", optional = true }
kusama-runtime-constants = { path = "../../runtime/kusama/constants", optional = true }
rococo-runtime-constants = { path = "../../runtime/rococo/constants", optional = true }
westend-runtime-constants = { path = "../../runtime/westend/constants", optional = true }
# Polkadot Runtimes
polkadot-runtime = { path = "../../runtime/polkadot", optional = true }
kusama-runtime = { path = "../../runtime/kusama", optional = true }
@@ -154,10 +160,10 @@ full-node = [
# Configure the native runtimes to use. Polkadot is enabled by default.
#
# Validators require the native runtime currently
polkadot-native = [ "polkadot-runtime", "polkadot-client/polkadot" ]
kusama-native = [ "kusama-runtime", "polkadot-client/kusama" ]
westend-native = [ "westend-runtime", "polkadot-client/westend" ]
rococo-native = [ "rococo-runtime", "polkadot-client/rococo" ]
polkadot-native = [ "polkadot-runtime", "polkadot-runtime-constants", "polkadot-client/polkadot" ]
kusama-native = [ "kusama-runtime", "kusama-runtime-constants", "polkadot-client/kusama" ]
westend-native = [ "westend-runtime", "westend-runtime-constants", "polkadot-client/westend" ]
rococo-native = [ "rococo-runtime", "rococo-runtime-constants", "polkadot-client/rococo" ]
runtime-benchmarks = [
"polkadot-runtime/runtime-benchmarks",
+6 -6
View File
@@ -21,21 +21,21 @@ use grandpa::AuthorityId as GrandpaId;
#[cfg(feature = "kusama-native")]
use kusama_runtime as kusama;
#[cfg(feature = "kusama-native")]
use kusama_runtime::constants::currency::UNITS as KSM;
use kusama_runtime_constants::currency::UNITS as KSM;
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_staking::Forcing;
#[cfg(feature = "polkadot-native")]
use polkadot::constants::currency::UNITS as DOT;
use polkadot_primitives::v1::{AccountId, AccountPublic, AssignmentId, ValidatorId};
#[cfg(feature = "polkadot-native")]
use polkadot_runtime as polkadot;
#[cfg(feature = "polkadot-native")]
use polkadot_runtime_constants::currency::UNITS as DOT;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
#[cfg(feature = "rococo-native")]
use rococo_runtime as rococo;
#[cfg(feature = "rococo-native")]
use rococo_runtime::constants::currency::UNITS as ROC;
use rococo_runtime_constants::currency::UNITS as ROC;
use sc_chain_spec::{ChainSpecExtension, ChainType};
use serde::{Deserialize, Serialize};
use sp_core::{sr25519, Pair, Public};
@@ -44,7 +44,7 @@ use telemetry::TelemetryEndpoints;
#[cfg(feature = "westend-native")]
use westend_runtime as westend;
#[cfg(feature = "westend-native")]
use westend_runtime::constants::currency::UNITS as WND;
use westend_runtime_constants::currency::UNITS as WND;
#[cfg(feature = "polkadot-native")]
const POLKADOT_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@@ -128,7 +128,7 @@ impl sp_runtime::BuildStorage for RococoGenesisExt {
fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> {
sp_state_machine::BasicExternalities::execute_with_storage(storage, || {
if let Some(length) = self.session_length_in_blocks.as_ref() {
rococo::constants::time::EpochDurationInBlocks::set(length);
rococo_runtime_constants::time::EpochDurationInBlocks::set(length);
}
});
self.runtime_genesis_config.assimilate_storage(storage)
+1
View File
@@ -23,6 +23,7 @@ polkadot-service = { path = "../../service" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-test-runtime = { path = "../../../runtime/test-runtime" }
test-runtime-constants = { path = "../../../runtime/test-runtime/constants" }
polkadot-runtime-parachains = { path = "../../../runtime/parachains" }
# Substrate dependencies
+2 -1
View File
@@ -21,11 +21,12 @@ use grandpa::AuthorityId as GrandpaId;
use pallet_staking::Forcing;
use polkadot_primitives::v1::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE};
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
use polkadot_test_runtime::{constants::currency::DOTS, BABE_GENESIS_EPOCH_CONFIG};
use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG;
use sc_chain_spec::{ChainSpec, ChainType};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_core::sr25519;
use sp_runtime::Perbill;
use test_runtime_constants::currency::DOTS;
const DEFAULT_PROTOCOL_ID: &str = "dot";