Rename ZombienetConfiguration to PolkadotParachainConfiguration and update related usage

This commit is contained in:
Marios Christou
2025-10-06 14:18:31 +03:00
parent bdff2902c2
commit 7fb3c9a00a
3 changed files with 78 additions and 44 deletions
+22 -22
View File
@@ -107,8 +107,8 @@ impl AsRef<KurtosisConfiguration> for Context {
} }
} }
impl AsRef<ZombienetConfiguration> for Context { impl AsRef<PolkadotParachainConfiguration> for Context {
fn as_ref(&self) -> &ZombienetConfiguration { fn as_ref(&self) -> &PolkadotParachainConfiguration {
match self { match self {
Self::Test(context) => context.as_ref().as_ref(), Self::Test(context) => context.as_ref().as_ref(),
Self::Benchmark(context) => context.as_ref().as_ref(), Self::Benchmark(context) => context.as_ref().as_ref(),
@@ -235,9 +235,9 @@ pub struct TestExecutionContext {
#[clap(flatten, next_help_heading = "Resolc Configuration")] #[clap(flatten, next_help_heading = "Resolc Configuration")]
pub resolc_configuration: ResolcConfiguration, pub resolc_configuration: ResolcConfiguration,
/// Configuration parameters for the Zombienet. /// Configuration parameters for the Polkadot Parachain.
#[clap(flatten, next_help_heading = "Zombienet Configuration")] #[clap(flatten, next_help_heading = "Polkadot Parachain Configuration")]
pub zombienet_configuration: ZombienetConfiguration, pub polkadot_parachain_configuration: PolkadotParachainConfiguration,
/// Configuration parameters for the geth node. /// Configuration parameters for the geth node.
#[clap(flatten, next_help_heading = "Geth Configuration")] #[clap(flatten, next_help_heading = "Geth Configuration")]
@@ -332,9 +332,9 @@ pub struct BenchmarkingContext {
#[clap(flatten, next_help_heading = "Kitchensink Configuration")] #[clap(flatten, next_help_heading = "Kitchensink Configuration")]
pub kitchensink_configuration: KitchensinkConfiguration, pub kitchensink_configuration: KitchensinkConfiguration,
/// Configuration parameters for the Zombienet. /// Configuration parameters for the Polkadot Parachain.
#[clap(flatten, next_help_heading = "Zombienet Configuration")] #[clap(flatten, next_help_heading = "Polkadot Parachain Configuration")]
pub zombienet_configuration: ZombienetConfiguration, pub polkadot_parachain_configuration: PolkadotParachainConfiguration,
/// Configuration parameters for the Revive Dev Node. /// Configuration parameters for the Revive Dev Node.
#[clap(flatten, next_help_heading = "Revive Dev Node Configuration")] #[clap(flatten, next_help_heading = "Revive Dev Node Configuration")]
@@ -397,9 +397,9 @@ impl AsRef<GethConfiguration> for TestExecutionContext {
} }
} }
impl AsRef<ZombienetConfiguration> for TestExecutionContext { impl AsRef<PolkadotParachainConfiguration> for TestExecutionContext {
fn as_ref(&self) -> &ZombienetConfiguration { fn as_ref(&self) -> &PolkadotParachainConfiguration {
&self.zombienet_configuration &self.polkadot_parachain_configuration
} }
} }
@@ -499,9 +499,9 @@ impl AsRef<KurtosisConfiguration> for BenchmarkingContext {
} }
} }
impl AsRef<ZombienetConfiguration> for BenchmarkingContext { impl AsRef<PolkadotParachainConfiguration> for BenchmarkingContext {
fn as_ref(&self) -> &ZombienetConfiguration { fn as_ref(&self) -> &PolkadotParachainConfiguration {
&self.zombienet_configuration &self.polkadot_parachain_configuration
} }
} }
@@ -575,24 +575,24 @@ pub struct ResolcConfiguration {
pub path: PathBuf, pub path: PathBuf,
} }
/// A set of configuration parameters for Zombienet. /// A set of configuration parameters for Polkadot Parachain.
#[derive(Clone, Debug, Parser, Serialize)] #[derive(Clone, Debug, Parser, Serialize)]
pub struct ZombienetConfiguration { pub struct PolkadotParachainConfiguration {
/// Specifies the path of the zombienet node to be used by the tool. /// Specifies the path of the polkadot-parachain node to be used by the tool.
/// ///
/// If this is not specified, then the tool assumes that it should use the zombienet binary /// If this is not specified, then the tool assumes that it should use the polkadot-parachain binary
/// that's provided in the user's $PATH. /// that's provided in the user's $PATH.
#[clap( #[clap(
id = "zombienet.path", id = "polkadot-parachain.path",
long = "zombienet.path", long = "polkadot-parachain.path",
default_value = "polkadot-parachain" default_value = "polkadot-parachain"
)] )]
pub path: PathBuf, pub path: PathBuf,
/// The amount of time to wait upon startup before considering that the node timed out. /// The amount of time to wait upon startup before considering that the node timed out.
#[clap( #[clap(
id = "zombienet.start-timeout-ms", id = "polkadot-parachain.start-timeout-ms",
long = "zombienet.start-timeout-ms", long = "polkadot-parachain.start-timeout-ms",
default_value = "5000", default_value = "5000",
value_parser = parse_duration value_parser = parse_duration
)] )]
+4 -4
View File
@@ -384,12 +384,12 @@ impl Platform for ZombienetPolkavmResolcPlatform {
context: Context, context: Context,
) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> { ) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> {
let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context); let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context);
let zombienet_path = AsRef::<ZombienetConfiguration>::as_ref(&context) let polkadot_parachain_path = AsRef::<PolkadotParachainConfiguration>::as_ref(&context)
.path .path
.clone(); .clone();
let genesis = genesis_configuration.genesis()?.clone(); let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || { Ok(thread::spawn(move || {
let node = ZombieNode::new(zombienet_path, context); let node = ZombieNode::new(polkadot_parachain_path, context);
let node = spawn_node(node, genesis)?; let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>) Ok(Box::new(node) as Box<_>)
})) }))
@@ -432,12 +432,12 @@ impl Platform for ZombienetRevmSolcPlatform {
context: Context, context: Context,
) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> { ) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> {
let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context); let genesis_configuration = AsRef::<GenesisConfiguration>::as_ref(&context);
let zombie_net_path = AsRef::<ZombienetConfiguration>::as_ref(&context) let polkadot_parachain_path = AsRef::<PolkadotParachainConfiguration>::as_ref(&context)
.path .path
.clone(); .clone();
let genesis = genesis_configuration.genesis()?.clone(); let genesis = genesis_configuration.genesis()?.clone();
Ok(thread::spawn(move || { Ok(thread::spawn(move || {
let node = ZombieNode::new(zombie_net_path, context); let node = ZombieNode::new(polkadot_parachain_path, context);
let node = spawn_node(node, genesis)?; let node = spawn_node(node, genesis)?;
Ok(Box::new(node) as Box<_>) Ok(Box::new(node) as Box<_>)
})) }))
@@ -83,18 +83,30 @@ static NODE_COUNT: AtomicU32 = AtomicU32::new(0);
/// an interface to interact with the parachain's Ethereum RPC. /// an interface to interact with the parachain's Ethereum RPC.
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct ZombieNode { pub struct ZombieNode {
/* Node Identifier */
id: u32, id: u32,
node_binary: PathBuf,
connection_string: String, connection_string: String,
node_rpc_port: Option<u16>,
/* Directory Paths */
base_directory: PathBuf, base_directory: PathBuf,
logs_directory: PathBuf, logs_directory: PathBuf,
/* Binary Paths & Timeouts */
eth_proxy_binary: PathBuf, eth_proxy_binary: PathBuf,
wallet: Arc<EthereumWallet>, polkadot_parachain_path: PathBuf,
nonce_manager: CachedNonceManager,
/* Spawned Processes */
eth_rpc_process: Option<Process>,
/* Zombienet Network */
network_config: Option<zombienet_sdk::NetworkConfig>, network_config: Option<zombienet_sdk::NetworkConfig>,
network: Option<zombienet_sdk::Network<LocalFileSystem>>, network: Option<zombienet_sdk::Network<LocalFileSystem>>,
eth_rpc_process: Option<Process>,
node_rpc_port: Option<u16>, /* Provider Related Fields */
wallet: Arc<EthereumWallet>,
nonce_manager: CachedNonceManager,
provider: OnceCell<ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>>, provider: OnceCell<ConcreteProvider<ReviveNetwork, Arc<EthereumWallet>>>,
} }
@@ -113,7 +125,7 @@ impl ZombieNode {
const CHAIN_SPEC_JSON_FILE: &str = "template_chainspec.json"; const CHAIN_SPEC_JSON_FILE: &str = "template_chainspec.json";
pub fn new( pub fn new(
node_path: PathBuf, polkadot_parachain_path: PathBuf,
context: impl AsRef<WorkingDirectoryConfiguration> context: impl AsRef<WorkingDirectoryConfiguration>
+ AsRef<EthRpcConfiguration> + AsRef<EthRpcConfiguration>
+ AsRef<WalletConfiguration>, + AsRef<WalletConfiguration>,
@@ -134,7 +146,7 @@ impl ZombieNode {
base_directory, base_directory,
logs_directory, logs_directory,
wallet, wallet,
node_binary: node_path, polkadot_parachain_path,
eth_proxy_binary, eth_proxy_binary,
nonce_manager: CachedNonceManager::default(), nonce_manager: CachedNonceManager::default(),
network_config: None, network_config: None,
@@ -157,10 +169,10 @@ impl ZombieNode {
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE); let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
self.prepare_chainspec(template_chainspec_path.clone(), genesis)?; self.prepare_chainspec(template_chainspec_path.clone(), genesis)?;
let node_binary = self let polkadot_parachain_path = self
.node_binary .polkadot_parachain_path
.to_str() .to_str()
.context("Invalid node binary path")?; .context("Invalid polkadot parachain path")?;
let node_rpc_port = Self::NODE_BASE_RPC_PORT + self.id as u16; let node_rpc_port = Self::NODE_BASE_RPC_PORT + self.id as u16;
@@ -178,7 +190,7 @@ impl ZombieNode {
.with_chain("asset-hub-westend-local") .with_chain("asset-hub-westend-local")
.with_collator(|n| { .with_collator(|n| {
n.with_name("Collator") n.with_name("Collator")
.with_command(node_binary) .with_command(polkadot_parachain_path)
.with_rpc_port(node_rpc_port) .with_rpc_port(node_rpc_port)
}) })
}) })
@@ -259,7 +271,7 @@ impl ZombieNode {
template_chainspec_path: PathBuf, template_chainspec_path: PathBuf,
mut genesis: Genesis, mut genesis: Genesis,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let mut cmd: Command = std::process::Command::new(&self.node_binary); let mut cmd: Command = std::process::Command::new(&self.polkadot_parachain_path);
cmd.arg(Self::EXPORT_CHAINSPEC_COMMAND) cmd.arg(Self::EXPORT_CHAINSPEC_COMMAND)
.arg("--chain") .arg("--chain")
.arg("asset-hub-westend-local"); .arg("asset-hub-westend-local");
@@ -735,7 +747,7 @@ impl Node for ZombieNode {
} }
fn version(&self) -> anyhow::Result<String> { fn version(&self) -> anyhow::Result<String> {
let output = Command::new(&self.node_binary) let output = Command::new(&self.polkadot_parachain_path)
.arg("--version") .arg("--version")
.stdin(Stdio::null()) .stdin(Stdio::null())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
@@ -775,7 +787,10 @@ mod tests {
pub async fn new_node() -> (TestExecutionContext, ZombieNode) { pub async fn new_node() -> (TestExecutionContext, ZombieNode) {
let context = test_config(); let context = test_config();
let mut node = ZombieNode::new(context.zombienet_configuration.path.clone(), &context); let mut node = ZombieNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
);
let genesis = context.genesis_configuration.genesis().unwrap().clone(); let genesis = context.genesis_configuration.genesis().unwrap().clone();
node.init(genesis).unwrap(); node.init(genesis).unwrap();
@@ -840,7 +855,10 @@ mod tests {
"#; "#;
let context = test_config(); let context = test_config();
let mut node = ZombieNode::new(context.zombienet_configuration.path.clone(), &context); let mut node = ZombieNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
);
// Call `init()` // Call `init()`
node.init(serde_json::from_str(genesis_content).unwrap()) node.init(serde_json::from_str(genesis_content).unwrap())
@@ -885,7 +903,10 @@ mod tests {
"#; "#;
let context = test_config(); let context = test_config();
let node = ZombieNode::new(context.zombienet_configuration.path.clone(), &context); let node = ZombieNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
);
let result = node let result = node
.extract_balance_from_genesis_file(&serde_json::from_str(genesis_json).unwrap()) .extract_balance_from_genesis_file(&serde_json::from_str(genesis_json).unwrap())
@@ -958,7 +979,10 @@ mod tests {
fn eth_rpc_version_works() { fn eth_rpc_version_works() {
// Arrange // Arrange
let context = test_config(); let context = test_config();
let node = ZombieNode::new(context.zombienet_configuration.path.clone(), &context); let node = ZombieNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
);
// Act // Act
let version = node.eth_rpc_version().unwrap(); let version = node.eth_rpc_version().unwrap();
@@ -974,7 +998,10 @@ mod tests {
fn version_works() { fn version_works() {
// Arrange // Arrange
let context = test_config(); let context = test_config();
let node = ZombieNode::new(context.zombienet_configuration.path.clone(), &context); let node = ZombieNode::new(
context.polkadot_parachain_configuration.path.clone(),
&context,
);
// Act // Act
let version = node.version().unwrap(); let version = node.version().unwrap();
@@ -987,6 +1014,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn get_chain_id_from_node_should_succeed() { async fn get_chain_id_from_node_should_succeed() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1005,6 +1033,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_gas_limit_from_node() { async fn can_get_gas_limit_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1022,6 +1051,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_coinbase_from_node() { async fn can_get_coinbase_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1039,6 +1069,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_difficulty_from_node() { async fn can_get_block_difficulty_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1056,6 +1087,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_hash_from_node() { async fn can_get_block_hash_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1073,6 +1105,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_timestamp_from_node() { async fn can_get_block_timestamp_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;
@@ -1090,6 +1123,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_number_from_node() { async fn can_get_block_number_from_node() {
// Arrange // Arrange
let node = shared_node().await; let node = shared_node().await;