Skip to content

Commit 94b04c0

Browse files
authored
Change the input for the polkadot-omni-node to be a path to chain-spec (#223)
* Change the input for the polkadot-omni-node to be a path to chain-spec * Remove unneeded dependency
1 parent 2d3602a commit 94b04c0

File tree

5 files changed

+19
-61
lines changed

5 files changed

+19
-61
lines changed

.github/actions/run-differential-tests/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ inputs:
3333
description: "The identifier of the platform to run the tests on (e.g., geth-evm-solc, revive-dev-node-revm-solc)"
3434
required: true
3535
type: string
36-
polkadot-omnichain-node-runtime-path:
37-
description: "The path of the WASM runtime to use with the polkadot-omni-node. This is only required if the polkadot-omni-node is one of the selected platforms."
36+
polkadot-omnichain-node-chain-spec-path:
37+
description: "The path of the chain-spec of the chain we're spawning'. This is only required if the polkadot-omni-node is one of the selected platforms."
3838
required: false
3939
type: string
4040
polkadot-omnichain-node-parachain-id:
@@ -89,10 +89,10 @@ runs:
8989
"${{ inputs['polkadot-omnichain-node-parachain-id'] }}"
9090
)
9191
fi
92-
if [[ -n "${{ inputs['polkadot-omnichain-node-runtime-path'] }}" ]]; then
92+
if [[ -n "${{ inputs['polkadot-omnichain-node-chain-spec-path'] }}" ]]; then
9393
OMNI_ARGS+=(
94-
--polkadot-omni-node.runtime-wasm-path
95-
"${{ inputs['polkadot-omnichain-node-runtime-path'] }}"
94+
--polkadot-omni-node.chain-spec-path
95+
"${{ inputs['polkadot-omnichain-node-chain-spec-path'] }}"
9696
)
9797
fi
9898

crates/config/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -943,13 +943,12 @@ pub struct PolkadotOmnichainNodeConfiguration {
943943
)]
944944
pub block_time: Duration,
945945

946-
/// The path of the WASM runtime to use for the polkadot-omni-node. This argument is required if
947-
/// the polkadot-omni-node is one of the selected platforms for running the tests or benchmarks.
946+
/// The path of the chainspec of the chain that we're spawning
948947
#[clap(
949-
id = "polkadot-omni-node.runtime-wasm-path",
950-
long = "polkadot-omni-node.runtime-wasm-path"
948+
id = "polkadot-omni-node.chain-spec-path",
949+
long = "polkadot-omni-node.chain-spec-path"
951950
)]
952-
pub runtime_wasm_path: Option<PathBuf>,
951+
pub chain_spec_path: Option<PathBuf>,
953952

954953
/// The ID of the parachain that the polkadot-omni-node will spawn. This argument is required if
955954
/// the polkadot-omni-node is one of the selected platforms for running the tests or benchmarks.

crates/core/src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,9 @@ impl Platform for PolkadotOmniNodePolkavmResolcPlatform {
486486
let wallet = AsRef::<WalletConfiguration>::as_ref(&context).wallet();
487487

488488
PolkadotOmnichainNode::node_genesis(
489-
&polkadot_omnichain_node_configuration.path,
490489
&wallet,
491490
polkadot_omnichain_node_configuration
492-
.parachain_id
493-
.context("No parachain id found in the configuration of the polkadot-omni-node")?,
494-
polkadot_omnichain_node_configuration
495-
.runtime_wasm_path
491+
.chain_spec_path
496492
.as_ref()
497493
.context("No WASM runtime path found in the polkadot-omni-node configuration")?,
498494
)
@@ -550,13 +546,9 @@ impl Platform for PolkadotOmniNodeRevmSolcPlatform {
550546
let wallet = AsRef::<WalletConfiguration>::as_ref(&context).wallet();
551547

552548
PolkadotOmnichainNode::node_genesis(
553-
&polkadot_omnichain_node_configuration.path,
554549
&wallet,
555550
polkadot_omnichain_node_configuration
556-
.parachain_id
557-
.context("No parachain id found in the configuration of the polkadot-omni-node")?,
558-
polkadot_omnichain_node_configuration
559-
.runtime_wasm_path
551+
.chain_spec_path
560552
.as_ref()
561553
.context("No WASM runtime path found in the polkadot-omni-node configuration")?,
562554
)

crates/node/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ serde_yaml_ng = { workspace = true }
3131
sp-core = { workspace = true }
3232
sp-runtime = { workspace = true }
3333
subxt = { workspace = true }
34-
temp-dir = { workspace = true }
3534
zombienet-sdk = { workspace = true }
3635

3736
[dev-dependencies]

crates/node/src/node_implementations/polkadot_omni_node.rs

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use revive_dt_report::{
4242
EthereumMinedBlockInformation, MinedBlockInformation, SubstrateMinedBlockInformation,
4343
};
4444
use subxt::{OnlineClient, SubstrateConfig};
45-
use temp_dir::TempDir;
4645
use tokio::sync::OnceCell;
4746
use tracing::{instrument, trace};
4847

@@ -70,7 +69,7 @@ pub struct PolkadotOmnichainNode {
7069
/// The path of the eth-rpc binary.
7170
eth_rpc_binary_path: PathBuf,
7271
/// The path of the runtime's WASM that this node will be spawned with.
73-
runtime_wasm_path: Option<PathBuf>,
72+
chain_spec_path: Option<PathBuf>,
7473
/// The path of the base directory which contains all of the stored data for this node.
7574
base_directory_path: PathBuf,
7675
/// The path of the logs directory which contains all of the stored logs.
@@ -144,8 +143,8 @@ impl PolkadotOmnichainNode {
144143
.path
145144
.to_path_buf(),
146145
eth_rpc_binary_path: eth_rpc_path.to_path_buf(),
147-
runtime_wasm_path: polkadot_omnichain_node_configuration
148-
.runtime_wasm_path
146+
chain_spec_path: polkadot_omnichain_node_configuration
147+
.chain_spec_path
149148
.clone(),
150149
base_directory_path: base_directory,
151150
logs_directory_path: logs_directory,
@@ -177,10 +176,8 @@ impl PolkadotOmnichainNode {
177176
let template_chainspec_path = self.base_directory_path.join(Self::CHAIN_SPEC_JSON_FILE);
178177

179178
let chainspec_json = Self::node_genesis(
180-
&self.polkadot_omnichain_node_binary_path,
181179
&self.wallet,
182-
self.parachain_id.context("No parachain id provided")?,
183-
self.runtime_wasm_path
180+
self.chain_spec_path
184181
.as_ref()
185182
.context("No runtime path provided")?,
186183
)
@@ -199,7 +196,7 @@ impl PolkadotOmnichainNode {
199196
fn spawn_process(&mut self) -> anyhow::Result<()> {
200197
// Error out if the runtime's path or the parachain id are not set which means that the
201198
// arguments we require were not provided.
202-
self.runtime_wasm_path
199+
self.chain_spec_path
203200
.as_ref()
204201
.context("No WASM path provided for the runtime")?;
205202
self.parachain_id
@@ -358,40 +355,11 @@ impl PolkadotOmnichainNode {
358355
}
359356

360357
pub fn node_genesis(
361-
node_path: &Path,
362358
wallet: &EthereumWallet,
363-
parachain_id: usize,
364-
runtime_wasm_path: &Path,
359+
chain_spec_path: &Path,
365360
) -> anyhow::Result<serde_json::Value> {
366-
let tempdir = TempDir::new().context("Failed to create a temporary directory")?;
367-
let unmodified_chainspec_path = tempdir.path().join("chainspec.json");
368-
369-
let output = Command::new(node_path)
370-
.arg("chain-spec-builder")
371-
.arg("-c")
372-
.arg(unmodified_chainspec_path.as_path())
373-
.arg("create")
374-
.arg("--para-id")
375-
.arg(parachain_id.to_string())
376-
.arg("--relay-chain")
377-
.arg("dontcare")
378-
.arg("--runtime")
379-
.arg(runtime_wasm_path)
380-
.arg("named-preset")
381-
.arg("development")
382-
.env_remove("RUST_LOG")
383-
.output()
384-
.context("Failed to export the chain-spec")?;
385-
386-
if !output.status.success() {
387-
anyhow::bail!(
388-
"Exporting chainspec from polkadot-omni-node failed: {}",
389-
String::from_utf8_lossy(&output.stderr)
390-
);
391-
}
392-
393-
let unmodified_chainspec_file = File::open(unmodified_chainspec_path.as_path())
394-
.context("Failed to open the unmodified chainspec file")?;
361+
let unmodified_chainspec_file =
362+
File::open(chain_spec_path).context("Failed to open the unmodified chainspec file")?;
395363
let mut chainspec_json =
396364
serde_json::from_reader::<_, serde_json::Value>(&unmodified_chainspec_file)
397365
.context("Failed to read the unmodified chainspec JSON")?;

0 commit comments

Comments
 (0)