diff --git a/Cargo.lock b/Cargo.lock
index 2e88055583..9ec07a69e9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -11421,7 +11421,6 @@ dependencies = [
"sp-std",
"sp-transaction-pool",
"sp-version",
- "static_assertions",
"subspace-core-primitives",
"subspace-runtime-primitives",
"subspace-verification",
diff --git a/crates/subspace-node/src/bin/subspace-node.rs b/crates/subspace-node/src/bin/subspace-node.rs
index bb61400e9b..a6de3d866e 100644
--- a/crates/subspace-node/src/bin/subspace-node.rs
+++ b/crates/subspace-node/src/bin/subspace-node.rs
@@ -346,6 +346,7 @@ fn main() -> Result<(), Error> {
}
})?;
}
+ DomainSubcommand::BuildGenesisConfig(cmd) => cmd.run()?,
_ => unimplemented!("Domain subcommand"),
},
None => {
diff --git a/crates/subspace-node/src/domain/cli.rs b/crates/subspace-node/src/domain/cli.rs
index 29b9b3cc78..7857303f41 100644
--- a/crates/subspace-node/src/domain/cli.rs
+++ b/crates/subspace-node/src/domain/cli.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::domain::evm_chain_spec;
+use crate::domain::evm_chain_spec::{self, SpecId};
use clap::Parser;
use domain_service::DomainConfiguration;
use sc_cli::{
@@ -27,6 +27,7 @@ use sc_service::BasePath;
use sp_core::crypto::AccountId32;
use sp_domains::DomainId;
use sp_runtime::traits::Convert;
+use std::io::Write;
use std::net::SocketAddr;
use std::num::ParseIntError;
use std::path::PathBuf;
@@ -45,6 +46,9 @@ pub enum Subcommand {
/// Sub-commands concerned with benchmarking.
#[clap(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
+
+ /// Build the genesis config of the evm domain chain in json format
+ BuildGenesisConfig(BuildGenesisConfigCmd),
}
fn parse_domain_id(s: &str) -> std::result::Result {
@@ -316,3 +320,51 @@ impl CliConfiguration for DomainCli {
self.run.telemetry_endpoints(chain_spec)
}
}
+
+// TODO: make the command generic over different runtime type instead of just the evm domain runtime
+/// The `build-genesis-config` command used to build the genesis config of the evm domain chain.
+#[derive(Debug, Clone, Parser)]
+pub struct BuildGenesisConfigCmd {
+ /// Whether output the WASM runtime code
+ #[arg(long, default_value_t = false)]
+ pub with_wasm_code: bool,
+
+ /// The base struct of the build-genesis-config command.
+ #[clap(flatten)]
+ pub shared_params: SharedParams,
+}
+
+impl BuildGenesisConfigCmd {
+ /// Run the build-genesis-config command
+ pub fn run(&self) -> sc_cli::Result<()> {
+ let is_dev = self.shared_params.is_dev();
+ let chain_id = self.shared_params.chain_id(is_dev);
+ let mut domain_genesis_config = match chain_id.as_str() {
+ "gemini-3f" => evm_chain_spec::get_testnet_genesis_by_spec_id(SpecId::Gemini).0,
+ "devnet" => evm_chain_spec::get_testnet_genesis_by_spec_id(SpecId::DevNet).0,
+ "dev" => evm_chain_spec::get_testnet_genesis_by_spec_id(SpecId::Dev).0,
+ "" | "local" => evm_chain_spec::get_testnet_genesis_by_spec_id(SpecId::Local).0,
+ unknown_id => {
+ eprintln!(
+ "unknown chain {unknown_id:?}, expected gemini-3f, devnet, dev, or local",
+ );
+ return Ok(());
+ }
+ };
+
+ if !self.with_wasm_code {
+ // Clear the WASM code of the genesis config
+ domain_genesis_config.system.code = Default::default();
+ }
+ let raw_domain_genesis_config = serde_json::to_vec(&domain_genesis_config)
+ .expect("Genesis config serialization never fails; qed");
+
+ if std::io::stdout()
+ .write_all(raw_domain_genesis_config.as_ref())
+ .is_err()
+ {
+ let _ = std::io::stderr().write_all(b"Error writing to stdout\n");
+ }
+ Ok(())
+ }
+}
diff --git a/crates/subspace-runtime/Cargo.toml b/crates/subspace-runtime/Cargo.toml
index 8faa0bb079..703c8e5687 100644
--- a/crates/subspace-runtime/Cargo.toml
+++ b/crates/subspace-runtime/Cargo.toml
@@ -55,7 +55,6 @@ sp-session = { version = "4.0.0-dev", default-features = false, git = "https://g
sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
sp-version = { version = "22.0.0", default-features = false, git = "https://github.com/subspace/substrate", rev = "55c157cff49b638a59d81a9f971f0f9a66829c71" }
-static_assertions = "1.1.0"
subspace-core-primitives = { version = "0.1.0", default-features = false, path = "../subspace-core-primitives" }
subspace-runtime-primitives = { version = "0.1.0", default-features = false, path = "../subspace-runtime-primitives" }
subspace-verification = { version = "0.1.0", default-features = false, path = "../subspace-verification" }