mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 15:51:04 +00:00
Versi chainspec based on Rococo. (#4485)
* Versi chainspec based on Rococo. * Fix. * Fix compilation without features. * Spelling * Another typo. * Support versi in native version * 🤦 * Regenerated genesis for versi. * Update cli/src/command.rs Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -71,7 +71,7 @@ impl SubstrateCli for Cli {
|
|||||||
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||||
let id = if id == "" {
|
let id = if id == "" {
|
||||||
let n = get_exec_name().unwrap_or_default();
|
let n = get_exec_name().unwrap_or_default();
|
||||||
["polkadot", "kusama", "westend", "rococo"]
|
["polkadot", "kusama", "westend", "rococo", "versi"]
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.find(|&chain| n.starts_with(chain))
|
.find(|&chain| n.starts_with(chain))
|
||||||
@@ -125,6 +125,14 @@ impl SubstrateCli for Cli {
|
|||||||
#[cfg(not(feature = "rococo-native"))]
|
#[cfg(not(feature = "rococo-native"))]
|
||||||
name if name.starts_with("wococo-") =>
|
name if name.starts_with("wococo-") =>
|
||||||
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
|
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
|
||||||
|
"versi" => Box::new(service::chain_spec::versi_config()?),
|
||||||
|
#[cfg(feature = "rococo-native")]
|
||||||
|
"versi-dev" => Box::new(service::chain_spec::versi_development_config()?),
|
||||||
|
#[cfg(feature = "rococo-native")]
|
||||||
|
"versi-local" => Box::new(service::chain_spec::versi_local_testnet_config()?),
|
||||||
|
#[cfg(not(feature = "rococo-native"))]
|
||||||
|
name if name.starts_with("versi-") =>
|
||||||
|
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
|
||||||
path => {
|
path => {
|
||||||
let path = std::path::PathBuf::from(path);
|
let path = std::path::PathBuf::from(path);
|
||||||
|
|
||||||
@@ -133,7 +141,11 @@ impl SubstrateCli for Cli {
|
|||||||
|
|
||||||
// When `force_*` is given or the file name starts with the name of one of the known chains,
|
// When `force_*` is given or the file name starts with the name of one of the known chains,
|
||||||
// we use the chain spec for the specific chain.
|
// we use the chain spec for the specific chain.
|
||||||
if self.run.force_rococo || chain_spec.is_rococo() || chain_spec.is_wococo() {
|
if self.run.force_rococo ||
|
||||||
|
chain_spec.is_rococo() ||
|
||||||
|
chain_spec.is_wococo() ||
|
||||||
|
chain_spec.is_versi()
|
||||||
|
{
|
||||||
Box::new(service::RococoChainSpec::from_json_file(path)?)
|
Box::new(service::RococoChainSpec::from_json_file(path)?)
|
||||||
} else if self.run.force_kusama || chain_spec.is_kusama() {
|
} else if self.run.force_kusama || chain_spec.is_kusama() {
|
||||||
Box::new(service::KusamaChainSpec::from_json_file(path)?)
|
Box::new(service::KusamaChainSpec::from_json_file(path)?)
|
||||||
@@ -158,7 +170,7 @@ impl SubstrateCli for Cli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
if spec.is_rococo() || spec.is_wococo() {
|
if spec.is_rococo() || spec.is_wococo() || spec.is_versi() {
|
||||||
return &service::rococo_runtime::VERSION
|
return &service::rococo_runtime::VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -106,6 +106,11 @@ pub type WestendChainSpec = DummyChainSpec;
|
|||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
pub type RococoChainSpec = service::GenericChainSpec<RococoGenesisExt, Extensions>;
|
pub type RococoChainSpec = service::GenericChainSpec<RococoGenesisExt, Extensions>;
|
||||||
|
|
||||||
|
/// The `ChainSpec` parameterized for the `versi` runtime.
|
||||||
|
///
|
||||||
|
/// As of now `Versi` will just be a clone of `Rococo`, until we need it to differ.
|
||||||
|
pub type VersiChainSpec = RococoChainSpec;
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||||
#[cfg(not(feature = "rococo-native"))]
|
#[cfg(not(feature = "rococo-native"))]
|
||||||
@@ -151,6 +156,10 @@ pub fn rococo_config() -> Result<RococoChainSpec, String> {
|
|||||||
RococoChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
|
RococoChainSpec::from_json_bytes(&include_bytes!("../res/rococo.json")[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn versi_config() -> Result<VersiChainSpec, String> {
|
||||||
|
VersiChainSpec::from_json_bytes(&include_bytes!("../res/versi.json")[..])
|
||||||
|
}
|
||||||
|
|
||||||
/// This is a temporary testnet that uses the same runtime as rococo.
|
/// This is a temporary testnet that uses the same runtime as rococo.
|
||||||
pub fn wococo_config() -> Result<RococoChainSpec, String> {
|
pub fn wococo_config() -> Result<RococoChainSpec, String> {
|
||||||
RococoChainSpec::from_json_bytes(&include_bytes!("../res/wococo.json")[..])
|
RococoChainSpec::from_json_bytes(&include_bytes!("../res/wococo.json")[..])
|
||||||
@@ -1690,6 +1699,28 @@ pub fn rococo_development_config() -> Result<RococoChainSpec, String> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Versi` development config (single validator Alice)
|
||||||
|
#[cfg(feature = "rococo-native")]
|
||||||
|
pub fn versi_development_config() -> Result<RococoChainSpec, String> {
|
||||||
|
let wasm_binary = rococo::WASM_BINARY.ok_or("Versi development wasm not available")?;
|
||||||
|
|
||||||
|
Ok(RococoChainSpec::from_genesis(
|
||||||
|
"Development",
|
||||||
|
"versi_dev",
|
||||||
|
ChainType::Development,
|
||||||
|
move || RococoGenesisExt {
|
||||||
|
runtime_genesis_config: rococo_development_config_genesis(wasm_binary),
|
||||||
|
// Use 1 minute session length.
|
||||||
|
session_length_in_blocks: Some(10),
|
||||||
|
},
|
||||||
|
vec![],
|
||||||
|
None,
|
||||||
|
Some("versi"),
|
||||||
|
None,
|
||||||
|
Default::default(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
/// Wococo development config (single validator Alice)
|
/// Wococo development config (single validator Alice)
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
pub fn wococo_development_config() -> Result<RococoChainSpec, String> {
|
pub fn wococo_development_config() -> Result<RococoChainSpec, String> {
|
||||||
@@ -1854,6 +1885,22 @@ fn wococo_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisCo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Versi` is a temporary testnet that uses the same runtime as rococo.
|
||||||
|
#[cfg(feature = "rococo-native")]
|
||||||
|
fn versi_local_testnet_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig {
|
||||||
|
rococo_testnet_genesis(
|
||||||
|
wasm_binary,
|
||||||
|
vec![
|
||||||
|
get_authority_keys_from_seed("Alice"),
|
||||||
|
get_authority_keys_from_seed("Bob"),
|
||||||
|
get_authority_keys_from_seed("Charlie"),
|
||||||
|
get_authority_keys_from_seed("Dave"),
|
||||||
|
],
|
||||||
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// Wococo local testnet config (multivalidator Alice + Bob + Charlie + Dave)
|
/// Wococo local testnet config (multivalidator Alice + Bob + Charlie + Dave)
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
pub fn wococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
pub fn wococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
||||||
@@ -1875,3 +1922,25 @@ pub fn wococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
|||||||
Default::default(),
|
Default::default(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Versi` local testnet config (multivalidator Alice + Bob + Charlie + Dave)
|
||||||
|
#[cfg(feature = "rococo-native")]
|
||||||
|
pub fn versi_local_testnet_config() -> Result<RococoChainSpec, String> {
|
||||||
|
let wasm_binary = rococo::WASM_BINARY.ok_or("Versi development wasm not available")?;
|
||||||
|
|
||||||
|
Ok(RococoChainSpec::from_genesis(
|
||||||
|
"Versi Local Testnet",
|
||||||
|
"versi_local_testnet",
|
||||||
|
ChainType::Local,
|
||||||
|
move || RococoGenesisExt {
|
||||||
|
runtime_genesis_config: versi_local_testnet_genesis(wasm_binary),
|
||||||
|
// Use 1 minute session length.
|
||||||
|
session_length_in_blocks: Some(10),
|
||||||
|
},
|
||||||
|
vec![],
|
||||||
|
None,
|
||||||
|
Some(DEFAULT_PROTOCOL_ID),
|
||||||
|
None,
|
||||||
|
Default::default(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|||||||
@@ -250,6 +250,9 @@ pub trait IdentifyVariant {
|
|||||||
/// Returns if this is a configuration for the `Wococo` test network.
|
/// Returns if this is a configuration for the `Wococo` test network.
|
||||||
fn is_wococo(&self) -> bool;
|
fn is_wococo(&self) -> bool;
|
||||||
|
|
||||||
|
/// Returns if this is a configuration for the `Versi` test network.
|
||||||
|
fn is_versi(&self) -> bool;
|
||||||
|
|
||||||
/// Returns true if this configuration is for a development network.
|
/// Returns true if this configuration is for a development network.
|
||||||
fn is_dev(&self) -> bool;
|
fn is_dev(&self) -> bool;
|
||||||
}
|
}
|
||||||
@@ -267,6 +270,9 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
|
|||||||
fn is_wococo(&self) -> bool {
|
fn is_wococo(&self) -> bool {
|
||||||
self.id().starts_with("wococo") || self.id().starts_with("wco")
|
self.id().starts_with("wococo") || self.id().starts_with("wco")
|
||||||
}
|
}
|
||||||
|
fn is_versi(&self) -> bool {
|
||||||
|
self.id().starts_with("versi") || self.id().starts_with("vrs")
|
||||||
|
}
|
||||||
fn is_dev(&self) -> bool {
|
fn is_dev(&self) -> bool {
|
||||||
self.id().ends_with("dev")
|
self.id().ends_with("dev")
|
||||||
}
|
}
|
||||||
@@ -682,7 +688,10 @@ where
|
|||||||
let backoff_authoring_blocks = {
|
let backoff_authoring_blocks = {
|
||||||
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();
|
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();
|
||||||
|
|
||||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
if config.chain_spec.is_rococo() ||
|
||||||
|
config.chain_spec.is_wococo() ||
|
||||||
|
config.chain_spec.is_versi()
|
||||||
|
{
|
||||||
// it's a testnet that's in flux, finality has stalled sometimes due
|
// it's a testnet that's in flux, finality has stalled sometimes due
|
||||||
// to operational issues and it's annoying to slow down block
|
// to operational issues and it's annoying to slow down block
|
||||||
// production to 1 block per hour.
|
// production to 1 block per hour.
|
||||||
@@ -748,7 +757,7 @@ where
|
|||||||
// Substrate nodes.
|
// Substrate nodes.
|
||||||
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
|
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
|
||||||
|
|
||||||
if chain_spec.is_rococo() || chain_spec.is_wococo() {
|
if chain_spec.is_rococo() || chain_spec.is_wococo() || chain_spec.is_versi() {
|
||||||
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
config.network.extra_sets.push(beefy_gadget::beefy_peers_set_config());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,7 +1063,7 @@ where
|
|||||||
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
||||||
|
|
||||||
// We currently only run the BEEFY gadget on the Rococo and Wococo testnets.
|
// We currently only run the BEEFY gadget on the Rococo and Wococo testnets.
|
||||||
if enable_beefy && (chain_spec.is_rococo() || chain_spec.is_wococo()) {
|
if enable_beefy && (chain_spec.is_rococo() || chain_spec.is_wococo() || chain_spec.is_versi()) {
|
||||||
let beefy_params = beefy_gadget::BeefyParams {
|
let beefy_params = beefy_gadget::BeefyParams {
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
backend: backend.clone(),
|
backend: backend.clone(),
|
||||||
@@ -1185,7 +1194,10 @@ pub fn new_chain_ops(
|
|||||||
let telemetry_worker_handle = None;
|
let telemetry_worker_handle = None;
|
||||||
|
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
if config.chain_spec.is_rococo() ||
|
||||||
|
config.chain_spec.is_wococo() ||
|
||||||
|
config.chain_spec.is_versi()
|
||||||
|
{
|
||||||
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; rococo_runtime, RococoExecutorDispatch, Rococo)
|
return chain_ops!(config, jaeger_agent, telemetry_worker_handle; rococo_runtime, RococoExecutorDispatch, Rococo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1218,7 +1230,10 @@ pub fn build_full(
|
|||||||
overseer_gen: impl OverseerGen,
|
overseer_gen: impl OverseerGen,
|
||||||
) -> Result<NewFull<Client>, Error> {
|
) -> Result<NewFull<Client>, Error> {
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() {
|
if config.chain_spec.is_rococo() ||
|
||||||
|
config.chain_spec.is_wococo() ||
|
||||||
|
config.chain_spec.is_versi()
|
||||||
|
{
|
||||||
return new_full::<rococo_runtime::RuntimeApi, RococoExecutorDispatch, _>(
|
return new_full::<rococo_runtime::RuntimeApi, RococoExecutorDispatch, _>(
|
||||||
config,
|
config,
|
||||||
is_collator,
|
is_collator,
|
||||||
|
|||||||
Reference in New Issue
Block a user