diff --git a/crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3h.json b/crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3h.json index cba26cd265..286aa4d1e6 100644 --- a/crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3h.json +++ b/crates/sc-subspace-chain-specs/res/chain-spec-raw-gemini-3h.json @@ -33,7 +33,7 @@ "/dns/bootstrap-0.gemini-3h.subspace.network/tcp/30533/p2p/12D3KooWK7NuL4S6aEdy5gELnvhCGo6EyrWVARnBy7W4AJTVkaF1", "/dns/bootstrap-1.gemini-3h.subspace.network/tcp/30533/p2p/12D3KooWQK33n2raSXzjH8JyqbFtczBmbwZiK9Tpicdw3rveJesj" ], - "potExternalEntropy": null, + "potExternalEntropy": "000000000000000000037bbc7fae1cd2c91dba8312b65f71352630e938cc4dda", "ss58Format": 2254, "tokenDecimals": 18, "tokenSymbol": "tSSC" diff --git a/crates/subspace-malicious-operator/src/bin/subspace-malicious-operator.rs b/crates/subspace-malicious-operator/src/bin/subspace-malicious-operator.rs index 813e7437b5..55338d4161 100644 --- a/crates/subspace-malicious-operator/src/bin/subspace-malicious-operator.rs +++ b/crates/subspace-malicious-operator/src/bin/subspace-malicious-operator.rs @@ -24,6 +24,7 @@ use sc_consensus_slots::SlotProportion; use sc_network::config::MultiaddrWithPeerId; use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sc_utils::mpsc::tracing_unbounded; +use serde_json::Value; use sp_core::crypto::Ss58AddressFormat; use sp_core::traits::SpawnEssentialNamed; use sp_domains::DomainId; @@ -133,12 +134,13 @@ fn main() -> Result<(), Error> { .chain_spec .properties() .get("potExternalEntropy") - .map(|d| serde_json::from_value(d.clone())) - .transpose() - .map_err(|error| { - sc_service::Error::Other(format!("Failed to decode PoT initial key: {error:?}")) - })? - .flatten() + .map(|d| match d.clone() { + Value::String(s) => Ok(s.into_bytes()), + _ => Err(sc_service::Error::Other( + "Failed to decode PoT initial key".to_string(), + )), + }) + .transpose()? .unwrap_or_default(); let dsn_config = { diff --git a/crates/subspace-node/src/commands/run/consensus.rs b/crates/subspace-node/src/commands/run/consensus.rs index ee5d1f6b2d..3c1d0e0e60 100644 --- a/crates/subspace-node/src/commands/run/consensus.rs +++ b/crates/subspace-node/src/commands/run/consensus.rs @@ -24,10 +24,6 @@ use subspace_service::dsn::DsnConfig; use tempfile::TempDir; use tracing::warn; -fn parse_pot_external_entropy(s: &str) -> Result, hex::FromHexError> { - hex::decode(s) -} - fn parse_timekeeper_cpu_cores( s: &str, ) -> Result, Box> { @@ -276,8 +272,8 @@ pub(super) struct ConsensusChainOptions { force_authoring: bool, /// External entropy, used initially when PoT chain starts to derive the first seed - #[arg(long, value_parser = parse_pot_external_entropy)] - pot_external_entropy: Option>, + #[arg(long)] + pot_external_entropy: Option, /// Options for DSN #[clap(flatten)] diff --git a/crates/subspace-node/src/main.rs b/crates/subspace-node/src/main.rs index 7311feee57..982de69886 100644 --- a/crates/subspace-node/src/main.rs +++ b/crates/subspace-node/src/main.rs @@ -33,6 +33,7 @@ use frame_benchmarking_cli::BenchmarkCmd; use futures::future::TryFutureExt; use sc_cli::{ChainSpec, SubstrateCli}; use sc_service::{Configuration, PartialComponents}; +use serde_json::Value; use sp_core::crypto::Ss58AddressFormat; use subspace_proof_of_space::chia::ChiaTable; use subspace_runtime::{Block, RuntimeApi}; @@ -95,18 +96,19 @@ where fn derive_pot_external_entropy( consensus_chain_config: &Configuration, - maybe_pot_external_entropy: Option>, + maybe_pot_external_entropy: Option, ) -> Result, sc_service::Error> { let maybe_chain_spec_pot_external_entropy = consensus_chain_config .chain_spec .properties() .get("potExternalEntropy") - .map(|d| serde_json::from_value(d.clone())) - .transpose() - .map_err(|error| { - sc_service::Error::Other(format!("Failed to decode PoT initial key: {error:?}")) - })? - .flatten(); + .map(|d| match d.clone() { + Value::String(s) => Ok(s), + _ => Err(sc_service::Error::Other( + "Failed to decode PoT initial key".to_string(), + )), + }) + .transpose()?; if maybe_chain_spec_pot_external_entropy.is_some() && maybe_pot_external_entropy.is_some() && maybe_chain_spec_pot_external_entropy != maybe_pot_external_entropy @@ -118,7 +120,8 @@ fn derive_pot_external_entropy( } Ok(maybe_chain_spec_pot_external_entropy .or(maybe_pot_external_entropy) - .unwrap_or_default()) + .unwrap_or_default() + .into_bytes()) } fn main() -> Result<(), Error> {