Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A more user-friendly test environment #1540

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 23 additions & 18 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,23 @@ default = [
"darwinia-native",
]

fast-runtime = [
all-natives = [
# darwinia
"crab-runtime?/fast-runtime",
"darwinia-runtime?/fast-runtime",
"koi-runtime?/fast-runtime",
"crab-native",
"darwinia-native",
"koi-native",
]
crab-native = [
# darwinia
"crab-runtime",
]
darwinia-native = [
# darwinia
"darwinia-runtime",
]
koi-native = [
# darwinia
"koi-runtime",
]

evm-tracing = [
Expand Down Expand Up @@ -134,21 +146,14 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]

all-natives = [
# darwinia
"crab-native",
"darwinia-native",
"koi-native",
]
crab-native = [
dev = [
# darwinia
"crab-runtime",
"crab-runtime?/dev",
"darwinia-runtime?/dev",
]
darwinia-native = [
# darwinia
"darwinia-runtime",
]
koi-native = [
fast-runtime = [
# darwinia
"koi-runtime",
"crab-runtime?/fast-runtime",
"darwinia-runtime?/fast-runtime",
"koi-runtime?/fast-runtime",
]
23 changes: 17 additions & 6 deletions node/src/chain_spec/crab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use std::{
str::FromStr,
time::{SystemTime, UNIX_EPOCH},
};
// crates.io
#[cfg(feature = "dev")]
use serde_json::Value;
// darwinia
use super::*;
use crab_runtime::*;
Expand Down Expand Up @@ -103,17 +106,25 @@ pub fn development_config() -> ChainSpec {
)
}
});
#[cfg(feature = "dev")]
let genesis_config_patch = if let Value::Object(mut m) = genesis_config_patch {
m.insert(
"sudo".into(),
serde_json::json!({ "key": Some(array_bytes::hex_n_into_unchecked::<_, AccountId, 20>(ALITH)) }),
);

Value::Object(m)
} else {
unreachable!();
};

ChainSpec::builder(
WASM_BINARY.unwrap(),
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: PARA_ID,
},
Extensions { relay_chain: "rococo-local".into(), para_id: PARA_ID },
)
.with_name("Crab2 D")
.with_id("crab2-d")
.with_chain_type(ChainType::Live)
.with_chain_type(ChainType::Development)
.with_protocol_id(PROTOCOL_ID)
.with_properties(properties())
.with_genesis_config_patch(genesis_config_patch)
Expand Down Expand Up @@ -241,7 +252,7 @@ pub fn genesis_config() -> ChainSpec {
});

ChainSpec::builder(WASM_BINARY.unwrap(), Extensions {
relay_chain: "kusama".into(), // You MUST set this to the correct network!
relay_chain: "kusama".into(),
para_id: PARA_ID,
})
.with_name("Crab2")
Expand Down
23 changes: 17 additions & 6 deletions node/src/chain_spec/darwinia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ use std::{
str::FromStr,
time::{SystemTime, UNIX_EPOCH},
};
// crates.io
#[cfg(feature = "dev")]
use serde_json::Value;
// darwinia
use super::*;
use darwinia_runtime::*;
Expand Down Expand Up @@ -103,17 +106,25 @@ pub fn development_config() -> ChainSpec {
)
}
});
#[cfg(feature = "dev")]
let genesis_config_patch = if let Value::Object(mut m) = genesis_config_patch {
m.insert(
"sudo".into(),
serde_json::json!({ "key": Some(array_bytes::hex_n_into_unchecked::<_, AccountId, 20>(ALITH)) }),
);

Value::Object(m)
} else {
unreachable!();
};

ChainSpec::builder(
WASM_BINARY.unwrap(),
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: PARA_ID,
},
Extensions { relay_chain: "rococo-local".into(), para_id: PARA_ID },
)
.with_name("Darwinia2 D")
.with_id("darwinia2-d")
.with_chain_type(ChainType::Live)
.with_chain_type(ChainType::Development)
.with_protocol_id(PROTOCOL_ID)
.with_properties(properties())
.with_genesis_config_patch(genesis_config_patch)
Expand Down Expand Up @@ -230,7 +241,7 @@ pub fn genesis_config() -> ChainSpec {
});

ChainSpec::builder(WASM_BINARY.unwrap(), Extensions {
relay_chain: "polkadot".into(), // You MUST set this to the correct network!
relay_chain: "polkadot".into(),
para_id: PARA_ID,
})
.with_name("Darwinia2")
Expand Down
9 changes: 3 additions & 6 deletions node/src/chain_spec/koi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,11 @@ pub fn development_config() -> ChainSpec {

ChainSpec::builder(
WASM_BINARY.unwrap(),
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
para_id: PARA_ID,
},
Extensions { relay_chain: "rococo-local".into(), para_id: PARA_ID },
)
.with_name("Darwinia Koi D")
.with_id("darwinia-koi-d")
.with_chain_type(ChainType::Live)
.with_chain_type(ChainType::Development)
.with_protocol_id(PROTOCOL_ID)
.with_properties(properties())
.with_genesis_config_patch(genesis_config_patch)
Expand Down Expand Up @@ -204,7 +201,7 @@ pub fn genesis_config() -> ChainSpec {
ChainSpec::builder(
WASM_BINARY.unwrap(),
Extensions {
relay_chain: "paseo".into(), // You MUST set this to the correct network!
relay_chain: "paseo".into(),
para_id: PARA_ID,
},
)
Expand Down
10 changes: 5 additions & 5 deletions node/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use sp_core::{Pair, Public};

pub type ChainSpec = sc_service::GenericChainSpec<(), Extensions>;

const TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit";
const PROTOCOL_ID: &str = "dar";

const ALITH: &str = "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac";
const BALTATHAR: &str = "0x3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0";
Expand All @@ -64,15 +64,15 @@ const DOROTHY: &str = "0x773539d4Ac0e786233D90A233654ccEE26a613D9";
const ETHAN: &str = "0xFf64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB";
const FAITH: &str = "0xC0F0f4ab324C46e55D02D0033343B4Be8A55532d";

// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

// This is the simplest bytecode to revert without returning any data.
// We will pre-deploy it under all of our precompiles to ensure they can be called from within
// contracts. (PUSH1 0x00 PUSH1 0x00 REVERT)
const REVERT_BYTECODE: [u8; 5] = [0x60, 0x00, 0x60, 0x00, 0xFD];

// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

const PROTOCOL_ID: &str = "dar";
const TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit";

/// The extensions for the [`ChainSpec`].
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
Expand Down
63 changes: 34 additions & 29 deletions runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ log = { workspace = true }
scale-info = { workspace = true }
strum = { workspace = true, features = ["derive"] }
# crates.io optional
# TODO: optional
array-bytes = { workspace = true }

# darwinia
Expand Down Expand Up @@ -45,11 +44,12 @@ pallet-evm-precompile-modexp = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }

# moonbeam
moonbeam-evm-tracer = { workspace = true, optional = true }
moonbeam-rpc-primitives-debug = { workspace = true }
pallet-evm-precompile-conviction-voting = { workspace = true }
precompile-utils = { workspace = true }
xcm-primitives = { workspace = true }
# moonbeam optional
moonbeam-evm-tracer = { workspace = true, optional = true }

# polkadot-sdk
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -91,7 +91,6 @@ sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-debug-derive = { workspace = true, optional = true, features = ["force-debug"] }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
Expand All @@ -109,6 +108,8 @@ cumulus-pallet-session-benchmarking = { workspace = true, optional = true }
frame-benchmarking = { workspace = true, optional = true }
frame-system-benchmarking = { workspace = true, optional = true }
frame-try-runtime = { workspace = true, optional = true }
pallet-sudo = { optional = true, workspace = true }
sp-debug-derive = { workspace = true, optional = true, features = ["force-debug"] }

[dev-dependencies]
# darwinia
Expand Down Expand Up @@ -152,11 +153,12 @@ std = [
"pallet-evm/std",

# moonbeam
"moonbeam-evm-tracer/std",
"moonbeam-rpc-primitives-debug/std",
"pallet-evm-precompile-conviction-voting/std",
"precompile-utils/std",
"xcm-primitives/std",
# moonbeam optional
"moonbeam-evm-tracer?/std",

# polkadot-sdk
"cumulus-pallet-aura-ext/std",
Expand Down Expand Up @@ -198,7 +200,6 @@ std = [
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-debug-derive?/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-offchain/std",
Expand All @@ -216,34 +217,12 @@ std = [
"frame-benchmarking?/std",
"frame-system-benchmarking?/std",
"frame-try-runtime?/std",
"pallet-sudo?/std",
"sp-debug-derive?/std",
"substrate-wasm-builder",
]

evm-tracing = [
# moonbeam
"moonbeam-evm-tracer",
]

force-debug = [
# polkadot-sdk
"sp-debug-derive",
]

fast-runtime = []

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
# polkadot-sdk
"sp-api/disable-logging",
]

runtime-benchmarks = [
# crates.io
# TODO: optional
# "array-bytes

# darwinia
"darwinia-account-migration/runtime-benchmarks",
"darwinia-common-runtime/runtime-benchmarks",
Expand Down Expand Up @@ -290,6 +269,7 @@ runtime-benchmarks = [
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"pallet-sudo?/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
]

Expand Down Expand Up @@ -338,4 +318,29 @@ try-runtime = [
"sp-runtime/try-runtime",
# polkadot-sdk optional
"frame-try-runtime/try-runtime",
"pallet-sudo?/try-runtime",
]

# A feature that should be enabled when the runtime should be build for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
on-chain-release-build = [
# polkadot-sdk
"sp-api/disable-logging",
]

evm-tracing = [
# moonbeam optional
"moonbeam-evm-tracer",
]

force-debug = [
# polkadot-sdk optional
"sp-debug-derive",
]

dev = [
# polkadot-sdk optional
"pallet-sudo",
]
fast-runtime = []
Loading