Skip to content

Commit

Permalink
Apply chain_ids from core_primitives (#2999)
Browse files Browse the repository at this point in the history
* Apply chain_ids from core_primitives

* fix test

* fix syntax
  • Loading branch information
Kailai-Wang authored Aug 18, 2024
1 parent 9c522eb commit 808902c
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion bitacross-worker/scripts/litentry/release/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function stop_services {
function register_parachain {
echo "Register parathread now ..."
cd "$ROOTDIR" || exit
export PARACHAIN_ID=$(grep DEFAULT_PARA_ID node/src/chain_specs/$CHAIN.rs | grep u32 | sed 's/.* = //;s/\;//')
export PARACHAIN_ID=$(grep -i "${CHAIN}_para_id" primitives/core/src/lib.rs | sed 's/.* = //;s/\;.*//')
cd "$ROOTDIR/ts-tests" || exit
if [[ -z "$NODE_ENV" ]]; then
echo "NODE_ENV=ci" > .env
Expand Down
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ run_relay_bob(){
register_parachain(){
echo "Register parathread now ..."
cd "$REPO_DIR" || exit
export PARACHAIN_ID=$(grep DEFAULT_PARA_ID node/src/chain_specs/$CHAIN.rs | grep u32 | sed 's/.* = //;s/\;//')
export PARACHAIN_ID=$(grep -i "${CHAIN}_para_id" primitives/core/src/lib.rs | sed 's/.* = //;s/\;.*//')
cd "$REPO_DIR/ts-tests" || exit
if [[ -z "$NODE_ENV" ]]; then
echo "NODE_ENV=ci" > .env
Expand Down
12 changes: 5 additions & 7 deletions node/src/chain_specs/litentry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ use litentry_parachain_runtime::{
AccountId, AuraId, Balance, BalancesConfig, BitacrossConfig, CouncilMembershipConfig,
DeveloperCommitteeMembershipConfig, GenesisConfig, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, SessionConfig, SystemConfig, TechnicalCommitteeMembershipConfig,
TeebagConfig, TeebagOperationalMode, VCManagementConfig, UNIT, WASM_BINARY,
TeebagConfig, TeebagOperationalMode, VCManagementConfig, LITENTRY_PARA_ID, UNIT, WASM_BINARY,
};
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
use serde::Deserialize;
use sp_core::sr25519;

const DEFAULT_PARA_ID: u32 = 2013;

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

Expand Down Expand Up @@ -90,15 +88,15 @@ pub fn get_chain_spec_dev() -> ChainSpec {
],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
DEFAULT_PARA_ID.into(),
LITENTRY_PARA_ID.into(),
)
},
Vec::new(),
None,
Some("litentry"),
None,
default_parachain_properties(),
Extensions { relay_chain: "rococo-local".into(), para_id: DEFAULT_PARA_ID },
Extensions { relay_chain: "rococo-local".into(), para_id: LITENTRY_PARA_ID },
)
}

Expand All @@ -114,7 +112,7 @@ pub fn get_chain_spec_staging() -> ChainSpec {
"litentry-staging",
ChainType::Local,
"rococo-local".into(),
DEFAULT_PARA_ID.into(),
LITENTRY_PARA_ID.into(),
)
}

Expand All @@ -125,7 +123,7 @@ pub fn get_chain_spec_prod() -> ChainSpec {
"litentry",
ChainType::Live,
"polkadot".into(),
DEFAULT_PARA_ID.into(),
LITENTRY_PARA_ID.into(),
)
}

Expand Down
14 changes: 6 additions & 8 deletions node/src/chain_specs/litmus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ use cumulus_primitives_core::ParaId;
use litmus_parachain_runtime::{
AccountId, AuraId, Balance, BalancesConfig, BitacrossConfig, CollatorSelectionConfig,
CouncilMembershipConfig, GenesisConfig, ParachainInfoConfig, PolkadotXcmConfig, SessionConfig,
SystemConfig, TechnicalCommitteeMembershipConfig, TeebagConfig, TeebagOperationalMode, UNIT,
WASM_BINARY,
SystemConfig, TechnicalCommitteeMembershipConfig, TeebagConfig, TeebagOperationalMode,
LITMUS_PARA_ID, UNIT, WASM_BINARY,
};
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
use serde::Deserialize;
use sp_core::sr25519;

const DEFAULT_PARA_ID: u32 = 2106;

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

Expand Down Expand Up @@ -93,15 +91,15 @@ pub fn get_chain_spec_dev() -> ChainSpec {
get_account_id_from_seed::<sr25519::Public>("Bob"),
],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
DEFAULT_PARA_ID.into(),
LITMUS_PARA_ID.into(),
)
},
Vec::new(),
None,
Some("litmus"),
None,
default_parachain_properties(),
Extensions { relay_chain: "rococo-local".into(), para_id: DEFAULT_PARA_ID },
Extensions { relay_chain: "rococo-local".into(), para_id: LITMUS_PARA_ID },
)
}

Expand All @@ -117,7 +115,7 @@ pub fn get_chain_spec_staging() -> ChainSpec {
"litmus-staging",
ChainType::Local,
"rococo-local".into(),
DEFAULT_PARA_ID.into(),
LITMUS_PARA_ID.into(),
)
}

Expand All @@ -128,7 +126,7 @@ pub fn get_chain_spec_prod() -> ChainSpec {
"litmus",
ChainType::Live,
"kusama".into(),
DEFAULT_PARA_ID.into(),
LITMUS_PARA_ID.into(),
)
}

Expand Down
12 changes: 5 additions & 7 deletions node/src/chain_specs/rococo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ use rococo_parachain_runtime::{
AccountId, AuraId, Balance, BalancesConfig, BitacrossConfig, CouncilMembershipConfig,
DeveloperCommitteeMembershipConfig, GenesisConfig, ParachainInfoConfig, ParachainStakingConfig,
PolkadotXcmConfig, SessionConfig, SudoConfig, SystemConfig, TechnicalCommitteeMembershipConfig,
TeebagConfig, TeebagOperationalMode, VCManagementConfig, UNIT, WASM_BINARY,
TeebagConfig, TeebagOperationalMode, VCManagementConfig, ROCOCO_PARA_ID, UNIT, WASM_BINARY,
};
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
use serde::Deserialize;
use sp_core::sr25519;

const DEFAULT_PARA_ID: u32 = 2106;

/// Specialized `ChainSpec` for the normal parachain runtime.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig, Extensions>;

Expand Down Expand Up @@ -94,15 +92,15 @@ pub fn get_chain_spec_dev(is_standalone: bool) -> ChainSpec {
],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
vec![get_account_id_from_seed::<sr25519::Public>("Alice")],
DEFAULT_PARA_ID.into(),
ROCOCO_PARA_ID.into(),
)
},
Vec::new(),
None,
Some("litentry-rococo"),
None,
default_parachain_properties(),
Extensions { relay_chain: "rococo-local".into(), para_id: DEFAULT_PARA_ID },
Extensions { relay_chain: "rococo-local".into(), para_id: ROCOCO_PARA_ID },
)
}

Expand All @@ -118,7 +116,7 @@ pub fn get_chain_spec_staging() -> ChainSpec {
"litentry-rococo-staging",
ChainType::Local,
"rococo-local".into(),
DEFAULT_PARA_ID.into(),
ROCOCO_PARA_ID.into(),
)
}

Expand All @@ -129,7 +127,7 @@ pub fn get_chain_spec_prod() -> ChainSpec {
"litentry-rococo",
ChainType::Live,
"rococo".into(),
DEFAULT_PARA_ID.into(),
ROCOCO_PARA_ID.into(),
)
}

Expand Down
4 changes: 4 additions & 0 deletions primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ mod types {
mod constants {
use super::types::BlockNumber;

pub const LITENTRY_PARA_ID: u32 = 2013;
pub const LITMUS_PARA_ID: u32 = 2106; // will be deprecated soon
pub const ROCOCO_PARA_ID: u32 = 2106; // will be replaced by paseo

/// This determines the average expected block time that we are targeting.
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
Expand Down
5 changes: 2 additions & 3 deletions runtime/litentry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use xcm_executor::XcmExecutor;
pub use constants::currency::deposit;
pub use core_primitives::{
opaque, AccountId, Amount, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, DAYS,
HOURS, MINUTES, SLOT_DURATION,
HOURS, LITENTRY_PARA_ID, MINUTES, SLOT_DURATION,
};
pub use runtime_common::currency::*;
use runtime_common::{
Expand Down Expand Up @@ -1062,8 +1062,7 @@ impl FeeCalculator for TransactionPaymentAsGasPrice {

parameter_types! {
pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0);
// It will be the best if we can implement this in a more professional way
pub ChainId: u64 = 2106u64;
pub ChainId: u64 = LITENTRY_PARA_ID.into();
pub BlockGasLimit: U256 = U256::from(
NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS
);
Expand Down
2 changes: 1 addition & 1 deletion runtime/litmus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use xcm_executor::XcmExecutor;
pub use constants::currency::deposit;
pub use core_primitives::{
opaque, AccountId, Amount, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, DAYS,
HOURS, MINUTES, SLOT_DURATION,
HOURS, LITMUS_PARA_ID, MINUTES, SLOT_DURATION,
};
pub use runtime_common::currency::*;
use runtime_common::{
Expand Down
5 changes: 2 additions & 3 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use xcm_executor::XcmExecutor;
pub use constants::currency::deposit;
pub use core_primitives::{
opaque, AccountId, Amount, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, DAYS,
HOURS, MINUTES, SLOT_DURATION,
HOURS, MINUTES, ROCOCO_PARA_ID, SLOT_DURATION,
};
pub use runtime_common::currency::*;

Expand Down Expand Up @@ -1099,8 +1099,7 @@ impl FeeCalculator for TransactionPaymentAsGasPrice {

parameter_types! {
pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0);
// It will be the best if we can implement this in a more professional way
pub ChainId: u64 = 2106u64;
pub ChainId: u64 = ROCOCO_PARA_ID.into();
pub BlockGasLimit: U256 = U256::from(
NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS
);
Expand Down
2 changes: 1 addition & 1 deletion scripts/launch-local-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LITENTRY_PARACHAIN_DIR=${LITENTRY_PARACHAIN_DIR:-"/tmp/parachain_dev"}
ROOTDIR=$(git rev-parse --show-toplevel)

cd "$ROOTDIR"
PARACHAIN_ID=$(grep DEFAULT_PARA_ID node/src/chain_specs/$CHAIN.rs | grep u32 | sed 's/.* = //;s/\;//')
PARACHAIN_ID=$(grep -i "${CHAIN}_para_id" primitives/core/src/lib.rs | sed 's/.* = //;s/\;.*//')
export PARACHAIN_ID

function print_divider() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/launch-local-custom-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LITENTRY_PARACHAIN_DIR=${LITENTRY_PARACHAIN_DIR:-"/tmp/parachain_dev"}
ROOTDIR=$(git rev-parse --show-toplevel)

cd "$ROOTDIR"
PARACHAIN_ID=$(grep DEFAULT_PARA_ID node/src/chain_specs/$CHAIN.rs | grep u32 | sed 's/.* = //;s/\;//')
PARACHAIN_ID=$(grep -i "${CHAIN}_para_id" primitives/core/src/lib.rs | sed 's/.* = //;s/\;.*//')
export PARACHAIN_ID

function print_divider() {
Expand Down
2 changes: 1 addition & 1 deletion scripts/launch-local-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function print_divider() {
ROOTDIR=$(git rev-parse --show-toplevel)

cd "$ROOTDIR"
PARACHAIN_ID=$(grep DEFAULT_PARA_ID node/src/chain_specs/$CHAIN.rs | grep u32 | sed 's/.* = //;s/\;//')
PARACHAIN_ID=$(grep -i "${CHAIN}_para_id" primitives/core/src/lib.rs | sed 's/.* = //;s/\;.*//')
export PARACHAIN_ID

cd "$ROOTDIR/docker/generated-$CHAIN/"
Expand Down

0 comments on commit 808902c

Please sign in to comment.