From 3d5feea4a40f5bc58739278845a6b71c50950293 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Mon, 20 Oct 2025 09:24:33 +0300 Subject: [PATCH] Modify the structure of the `MinedBlockInformation` --- .../src/differential_benchmarks/watcher.rs | 40 ++++++++++++------- crates/node-interaction/src/lib.rs | 9 +++++ crates/node/src/node_implementations/geth.rs | 31 +++++++------- .../node_implementations/lighthouse_geth.rs | 31 +++++++------- .../src/node_implementations/substrate.rs | 37 ++++++++++------- .../src/node_implementations/zombienet.rs | 34 +++++++++------- 6 files changed, 108 insertions(+), 74 deletions(-) diff --git a/crates/core/src/differential_benchmarks/watcher.rs b/crates/core/src/differential_benchmarks/watcher.rs index 473f134..0430912 100644 --- a/crates/core/src/differential_benchmarks/watcher.rs +++ b/crates/core/src/differential_benchmarks/watcher.rs @@ -113,7 +113,7 @@ impl Watcher { while let Some(block) = blocks_information_stream.next().await { // If the block number is equal to or less than the last block before the // repetition then we ignore it and continue on to the next block. - if block.block_number <= ignore_block_before { + if block.ethereum_block_information.block_number <= ignore_block_before { continue; } @@ -124,8 +124,8 @@ impl Watcher { } info!( - block_number = block.block_number, - block_tx_count = block.transaction_hashes.len(), + block_number = block.ethereum_block_information.block_number, + block_tx_count = block.ethereum_block_information.transaction_hashes.len(), remaining_transactions = watch_for_transaction_hashes.read().await.len(), "Observed a block" ); @@ -134,7 +134,7 @@ impl Watcher { // are currently watching for. let mut watch_for_transaction_hashes = watch_for_transaction_hashes.write().await; - for tx_hash in block.transaction_hashes.iter() { + for tx_hash in block.ethereum_block_information.transaction_hashes.iter() { watch_for_transaction_hashes.remove(tx_hash); } @@ -143,16 +143,28 @@ impl Watcher { // reporting in place and then it can be removed. This serves as as way of doing // some very simple reporting for the time being. eprintln!( - "\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",\"{}\"", - block.block_number, - block.block_timestamp, - block.mined_gas, - block.block_gas_limit, - block.transaction_hashes.len(), - block.ref_time, - block.max_ref_time, - block.proof_size, - block.max_proof_size, + "\"{}\",\"{}\",\"{}\",\"{}\",\"{}\",\"{:?}\",\"{:?}\",\"{:?}\",\"{:?}\"", + block.ethereum_block_information.block_number, + block.ethereum_block_information.block_timestamp, + block.ethereum_block_information.mined_gas, + block.ethereum_block_information.block_gas_limit, + block.ethereum_block_information.transaction_hashes.len(), + block + .substrate_block_information + .as_ref() + .map(|block| block.ref_time), + block + .substrate_block_information + .as_ref() + .map(|block| block.max_ref_time), + block + .substrate_block_information + .as_ref() + .map(|block| block.proof_size), + block + .substrate_block_information + .as_ref() + .map(|block| block.max_proof_size), ); // endregion:TEMPORARY diff --git a/crates/node-interaction/src/lib.rs b/crates/node-interaction/src/lib.rs index 54796a6..b3237d5 100644 --- a/crates/node-interaction/src/lib.rs +++ b/crates/node-interaction/src/lib.rs @@ -83,6 +83,12 @@ pub trait EthereumNode { #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct MinedBlockInformation { + pub ethereum_block_information: EthereumMinedBlockInformation, + pub substrate_block_information: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct EthereumMinedBlockInformation { /// The block number. pub block_number: BlockNumber, @@ -97,7 +103,10 @@ pub struct MinedBlockInformation { /// The hashes of the transactions that were mined as part of the block. pub transaction_hashes: Vec, +} +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct SubstrateMinedBlockInformation { /// The ref time for substrate based chains. pub ref_time: u128, diff --git a/crates/node/src/node_implementations/geth.rs b/crates/node/src/node_implementations/geth.rs index 9e2a5c0..17ca78c 100644 --- a/crates/node/src/node_implementations/geth.rs +++ b/crates/node/src/node_implementations/geth.rs @@ -43,7 +43,9 @@ use revive_dt_common::{ }; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; -use revive_dt_node_interaction::{EthereumNode, MinedBlockInformation}; +use revive_dt_node_interaction::{ + EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, +}; use crate::{ Node, @@ -526,20 +528,19 @@ impl EthereumNode for GethNode { let mined_block_information_stream = block_stream.filter_map(|block| async { let block = block.ok()?; Some(MinedBlockInformation { - block_number: block.number(), - block_timestamp: block.header.timestamp, - mined_gas: block.header.gas_used as _, - block_gas_limit: block.header.gas_limit as _, - transaction_hashes: block - .transactions - .into_hashes() - .as_hashes() - .expect("Must be hashes") - .to_vec(), - ref_time: 0, - max_ref_time: 0, - proof_size: 0, - max_proof_size: 0, + ethereum_block_information: EthereumMinedBlockInformation { + block_number: block.number(), + block_timestamp: block.header.timestamp, + mined_gas: block.header.gas_used as _, + block_gas_limit: block.header.gas_limit as _, + transaction_hashes: block + .transactions + .into_hashes() + .as_hashes() + .expect("Must be hashes") + .to_vec(), + }, + substrate_block_information: None, }) }); diff --git a/crates/node/src/node_implementations/lighthouse_geth.rs b/crates/node/src/node_implementations/lighthouse_geth.rs index bd8ceab..5e12aeb 100644 --- a/crates/node/src/node_implementations/lighthouse_geth.rs +++ b/crates/node/src/node_implementations/lighthouse_geth.rs @@ -56,7 +56,9 @@ use revive_dt_common::{ }; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; -use revive_dt_node_interaction::{EthereumNode, MinedBlockInformation}; +use revive_dt_node_interaction::{ + EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, +}; use crate::{ Node, @@ -757,20 +759,19 @@ impl EthereumNode for LighthouseGethNode { let mined_block_information_stream = block_stream.filter_map(|block| async { let block = block.ok()?; Some(MinedBlockInformation { - block_number: block.number(), - block_timestamp: block.header.timestamp, - mined_gas: block.header.gas_used as _, - block_gas_limit: block.header.gas_limit as _, - transaction_hashes: block - .transactions - .into_hashes() - .as_hashes() - .expect("Must be hashes") - .to_vec(), - ref_time: 0, - max_ref_time: 0, - proof_size: 0, - max_proof_size: 0, + ethereum_block_information: EthereumMinedBlockInformation { + block_number: block.number(), + block_timestamp: block.header.timestamp, + mined_gas: block.header.gas_used as _, + block_gas_limit: block.header.gas_limit as _, + transaction_hashes: block + .transactions + .into_hashes() + .as_hashes() + .expect("Must be hashes") + .to_vec(), + }, + substrate_block_information: None, }) }); diff --git a/crates/node/src/node_implementations/substrate.rs b/crates/node/src/node_implementations/substrate.rs index 8617823..fc02da9 100644 --- a/crates/node/src/node_implementations/substrate.rs +++ b/crates/node/src/node_implementations/substrate.rs @@ -37,7 +37,10 @@ use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; use revive_dt_config::*; -use revive_dt_node_interaction::{EthereumNode, MinedBlockInformation}; +use revive_dt_node_interaction::{ + EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, + SubstrateMinedBlockInformation, +}; use subxt::{OnlineClient, SubstrateConfig}; use tokio::sync::OnceCell; use tracing::{instrument, trace}; @@ -557,20 +560,24 @@ impl EthereumNode for SubstrateNode { let max_proof_size = limits.max_block.proof_size; Some(MinedBlockInformation { - block_number: substrate_block.number() as _, - block_timestamp: revive_block.header.timestamp, - mined_gas: revive_block.header.gas_used as _, - block_gas_limit: revive_block.header.gas_limit as _, - transaction_hashes: revive_block - .transactions - .into_hashes() - .as_hashes() - .expect("Must be hashes") - .to_vec(), - ref_time: block_ref_time, - max_ref_time, - proof_size: block_proof_size, - max_proof_size, + ethereum_block_information: EthereumMinedBlockInformation { + block_number: revive_block.number(), + block_timestamp: revive_block.header.timestamp, + mined_gas: revive_block.header.gas_used as _, + block_gas_limit: revive_block.header.gas_limit as _, + transaction_hashes: revive_block + .transactions + .into_hashes() + .as_hashes() + .expect("Must be hashes") + .to_vec(), + }, + substrate_block_information: Some(SubstrateMinedBlockInformation { + ref_time: block_ref_time, + max_ref_time, + proof_size: block_proof_size, + max_proof_size, + }), }) } }); diff --git a/crates/node/src/node_implementations/zombienet.rs b/crates/node/src/node_implementations/zombienet.rs index 0803e63..0b2b5b0 100644 --- a/crates/node/src/node_implementations/zombienet.rs +++ b/crates/node/src/node_implementations/zombienet.rs @@ -60,7 +60,7 @@ use revive_common::EVMVersion; use revive_dt_common::fs::clear_directory; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; -use revive_dt_node_interaction::{EthereumNode, MinedBlockInformation}; +use revive_dt_node_interaction::*; use serde_json::json; use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; @@ -578,20 +578,24 @@ impl EthereumNode for ZombienetNode { let max_proof_size = limits.max_block.proof_size; Some(MinedBlockInformation { - block_number: substrate_block.number() as _, - block_timestamp: revive_block.header.timestamp, - mined_gas: revive_block.header.gas_used as _, - block_gas_limit: revive_block.header.gas_limit as _, - transaction_hashes: revive_block - .transactions - .into_hashes() - .as_hashes() - .expect("Must be hashes") - .to_vec(), - ref_time: block_ref_time, - max_ref_time, - proof_size: block_proof_size, - max_proof_size, + ethereum_block_information: EthereumMinedBlockInformation { + block_number: revive_block.number(), + block_timestamp: revive_block.header.timestamp, + mined_gas: revive_block.header.gas_used as _, + block_gas_limit: revive_block.header.gas_limit as _, + transaction_hashes: revive_block + .transactions + .into_hashes() + .as_hashes() + .expect("Must be hashes") + .to_vec(), + }, + substrate_block_information: Some(SubstrateMinedBlockInformation { + ref_time: block_ref_time, + max_ref_time, + proof_size: block_proof_size, + max_proof_size, + }), }) } });