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 {
fn as_ref(&self) -> &ZombienetConfiguration {
impl AsRef<PolkadotParachainConfiguration> for Context {
fn as_ref(&self) -> &PolkadotParachainConfiguration {
match self {
Self::Test(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")]
pub resolc_configuration: ResolcConfiguration,
/// Configuration parameters for the Zombienet.
#[clap(flatten, next_help_heading = "Zombienet Configuration")]
pub zombienet_configuration: ZombienetConfiguration,
/// Configuration parameters for the Polkadot Parachain.
#[clap(flatten, next_help_heading = "Polkadot Parachain Configuration")]
pub polkadot_parachain_configuration: PolkadotParachainConfiguration,
/// Configuration parameters for the geth node.
#[clap(flatten, next_help_heading = "Geth Configuration")]
@@ -332,9 +332,9 @@ pub struct BenchmarkingContext {
#[clap(flatten, next_help_heading = "Kitchensink Configuration")]
pub kitchensink_configuration: KitchensinkConfiguration,
/// Configuration parameters for the Zombienet.
#[clap(flatten, next_help_heading = "Zombienet Configuration")]
pub zombienet_configuration: ZombienetConfiguration,
/// Configuration parameters for the Polkadot Parachain.
#[clap(flatten, next_help_heading = "Polkadot Parachain Configuration")]
pub polkadot_parachain_configuration: PolkadotParachainConfiguration,
/// Configuration parameters for the Revive Dev Node.
#[clap(flatten, next_help_heading = "Revive Dev Node Configuration")]
@@ -397,9 +397,9 @@ impl AsRef<GethConfiguration> for TestExecutionContext {
}
}
impl AsRef<ZombienetConfiguration> for TestExecutionContext {
fn as_ref(&self) -> &ZombienetConfiguration {
&self.zombienet_configuration
impl AsRef<PolkadotParachainConfiguration> for TestExecutionContext {
fn as_ref(&self) -> &PolkadotParachainConfiguration {
&self.polkadot_parachain_configuration
}
}
@@ -499,9 +499,9 @@ impl AsRef<KurtosisConfiguration> for BenchmarkingContext {
}
}
impl AsRef<ZombienetConfiguration> for BenchmarkingContext {
fn as_ref(&self) -> &ZombienetConfiguration {
&self.zombienet_configuration
impl AsRef<PolkadotParachainConfiguration> for BenchmarkingContext {
fn as_ref(&self) -> &PolkadotParachainConfiguration {
&self.polkadot_parachain_configuration
}
}
@@ -575,24 +575,24 @@ pub struct ResolcConfiguration {
pub path: PathBuf,
}
/// A set of configuration parameters for Zombienet.
/// A set of configuration parameters for Polkadot Parachain.
#[derive(Clone, Debug, Parser, Serialize)]
pub struct ZombienetConfiguration {
/// Specifies the path of the zombienet node to be used by the tool.
pub struct PolkadotParachainConfiguration {
/// 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.
#[clap(
id = "zombienet.path",
long = "zombienet.path",
id = "polkadot-parachain.path",
long = "polkadot-parachain.path",
default_value = "polkadot-parachain"
)]
pub path: PathBuf,
/// The amount of time to wait upon startup before considering that the node timed out.
#[clap(
id = "zombienet.start-timeout-ms",
long = "zombienet.start-timeout-ms",
id = "polkadot-parachain.start-timeout-ms",
long = "polkadot-parachain.start-timeout-ms",
default_value = "5000",
value_parser = parse_duration
)]
+4 -4
View File
@@ -384,12 +384,12 @@ impl Platform for ZombienetPolkavmResolcPlatform {
context: Context,
) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> {
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
.clone();
let genesis = genesis_configuration.genesis()?.clone();
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)?;
Ok(Box::new(node) as Box<_>)
}))
@@ -432,12 +432,12 @@ impl Platform for ZombienetRevmSolcPlatform {
context: Context,
) -> anyhow::Result<JoinHandle<anyhow::Result<Box<dyn EthereumNode + Send + Sync>>>> {
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
.clone();
let genesis = genesis_configuration.genesis()?.clone();
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)?;
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.
#[derive(Debug, Default)]
pub struct ZombieNode {
/* Node Identifier */
id: u32,
node_binary: PathBuf,
connection_string: String,
node_rpc_port: Option<u16>,
/* Directory Paths */
base_directory: PathBuf,
logs_directory: PathBuf,
/* Binary Paths & Timeouts */
eth_proxy_binary: PathBuf,
wallet: Arc<EthereumWallet>,
nonce_manager: CachedNonceManager,
polkadot_parachain_path: PathBuf,
/* Spawned Processes */
eth_rpc_process: Option<Process>,
/* Zombienet Network */
network_config: Option<zombienet_sdk::NetworkConfig>,
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>>>,
}
@@ -113,7 +125,7 @@ impl ZombieNode {
const CHAIN_SPEC_JSON_FILE: &str = "template_chainspec.json";
pub fn new(
node_path: PathBuf,
polkadot_parachain_path: PathBuf,
context: impl AsRef<WorkingDirectoryConfiguration>
+ AsRef<EthRpcConfiguration>
+ AsRef<WalletConfiguration>,
@@ -134,7 +146,7 @@ impl ZombieNode {
base_directory,
logs_directory,
wallet,
node_binary: node_path,
polkadot_parachain_path,
eth_proxy_binary,
nonce_manager: CachedNonceManager::default(),
network_config: None,
@@ -157,10 +169,10 @@ impl ZombieNode {
let template_chainspec_path = self.base_directory.join(Self::CHAIN_SPEC_JSON_FILE);
self.prepare_chainspec(template_chainspec_path.clone(), genesis)?;
let node_binary = self
.node_binary
let polkadot_parachain_path = self
.polkadot_parachain_path
.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;
@@ -178,7 +190,7 @@ impl ZombieNode {
.with_chain("asset-hub-westend-local")
.with_collator(|n| {
n.with_name("Collator")
.with_command(node_binary)
.with_command(polkadot_parachain_path)
.with_rpc_port(node_rpc_port)
})
})
@@ -259,7 +271,7 @@ impl ZombieNode {
template_chainspec_path: PathBuf,
mut genesis: Genesis,
) -> 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)
.arg("--chain")
.arg("asset-hub-westend-local");
@@ -735,7 +747,7 @@ impl Node for ZombieNode {
}
fn version(&self) -> anyhow::Result<String> {
let output = Command::new(&self.node_binary)
let output = Command::new(&self.polkadot_parachain_path)
.arg("--version")
.stdin(Stdio::null())
.stdout(Stdio::piped())
@@ -775,7 +787,10 @@ mod tests {
pub async fn new_node() -> (TestExecutionContext, ZombieNode) {
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();
node.init(genesis).unwrap();
@@ -840,7 +855,10 @@ mod tests {
"#;
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()`
node.init(serde_json::from_str(genesis_content).unwrap())
@@ -885,7 +903,10 @@ mod tests {
"#;
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
.extract_balance_from_genesis_file(&serde_json::from_str(genesis_json).unwrap())
@@ -958,7 +979,10 @@ mod tests {
fn eth_rpc_version_works() {
// Arrange
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
let version = node.eth_rpc_version().unwrap();
@@ -974,7 +998,10 @@ mod tests {
fn version_works() {
// Arrange
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
let version = node.version().unwrap();
@@ -987,6 +1014,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn get_chain_id_from_node_should_succeed() {
// Arrange
let node = shared_node().await;
@@ -1005,6 +1033,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_gas_limit_from_node() {
// Arrange
let node = shared_node().await;
@@ -1022,6 +1051,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_coinbase_from_node() {
// Arrange
let node = shared_node().await;
@@ -1039,6 +1069,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_difficulty_from_node() {
// Arrange
let node = shared_node().await;
@@ -1056,6 +1087,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_hash_from_node() {
// Arrange
let node = shared_node().await;
@@ -1073,6 +1105,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_timestamp_from_node() {
// Arrange
let node = shared_node().await;
@@ -1090,6 +1123,7 @@ mod tests {
}
#[tokio::test]
#[ignore = "Ignored since they take a long time to run"]
async fn can_get_block_number_from_node() {
// Arrange
let node = shared_node().await;