From 03b09d49ec40356bf918aa4f5d2f0ad96103dee7 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Wed, 22 Oct 2025 15:36:42 +0300 Subject: [PATCH] Add the block information to the report --- Cargo.lock | 2 + .../src/differential_benchmarks/watcher.rs | 6 +- crates/node-interaction/Cargo.toml | 1 + crates/node-interaction/src/lib.rs | 42 +----------- crates/node/Cargo.toml | 1 + crates/node/src/node_implementations/geth.rs | 5 +- .../node_implementations/lighthouse_geth.rs | 5 +- .../src/node_implementations/substrate.rs | 6 +- .../src/node_implementations/zombienet.rs | 3 + crates/report/src/aggregator.rs | 65 ++++++++++++++++++- crates/report/src/runner_event.rs | 7 ++ 11 files changed, 90 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3253ee3..745a76b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5692,6 +5692,7 @@ dependencies = [ "revive-dt-config", "revive-dt-format", "revive-dt-node-interaction", + "revive-dt-report", "serde", "serde_json", "serde_with", @@ -5715,6 +5716,7 @@ dependencies = [ "futures", "revive-common", "revive-dt-format", + "revive-dt-report", ] [[package]] diff --git a/crates/core/src/differential_benchmarks/watcher.rs b/crates/core/src/differential_benchmarks/watcher.rs index 603ebca..6b58e30 100644 --- a/crates/core/src/differential_benchmarks/watcher.rs +++ b/crates/core/src/differential_benchmarks/watcher.rs @@ -10,8 +10,7 @@ use anyhow::Result; use futures::{Stream, StreamExt}; use revive_dt_common::types::PlatformIdentifier; use revive_dt_format::steps::StepPath; -use revive_dt_node_interaction::MinedBlockInformation; -use revive_dt_report::{ExecutionSpecificReporter, TransactionInformation}; +use revive_dt_report::{ExecutionSpecificReporter, MinedBlockInformation, TransactionInformation}; use tokio::sync::{ RwLock, mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}, @@ -133,6 +132,9 @@ impl Watcher { if block.ethereum_block_information.block_number <= ignore_block_before { continue; } + reporter + .report_block_mined_event(block.clone()) + .expect("Can't fail"); if *all_transactions_submitted.read().await && watch_for_transaction_hashes.read().await.is_empty() diff --git a/crates/node-interaction/Cargo.toml b/crates/node-interaction/Cargo.toml index f9c9261..3886177 100644 --- a/crates/node-interaction/Cargo.toml +++ b/crates/node-interaction/Cargo.toml @@ -12,6 +12,7 @@ rust-version.workspace = true revive-common = { workspace = true } revive-dt-format = { workspace = true } +revive-dt-report = { workspace = true } alloy = { workspace = true } anyhow = { workspace = true } diff --git a/crates/node-interaction/src/lib.rs b/crates/node-interaction/src/lib.rs index b3237d5..7e05c78 100644 --- a/crates/node-interaction/src/lib.rs +++ b/crates/node-interaction/src/lib.rs @@ -4,7 +4,7 @@ use std::pin::Pin; use std::sync::Arc; use alloy::network::Ethereum; -use alloy::primitives::{Address, BlockNumber, BlockTimestamp, StorageKey, TxHash, U256}; +use alloy::primitives::{Address, StorageKey, TxHash, U256}; use alloy::providers::DynProvider; use alloy::rpc::types::trace::geth::{DiffMode, GethDebugTracingOptions, GethTrace}; use alloy::rpc::types::{EIP1186AccountProofResponse, TransactionReceipt, TransactionRequest}; @@ -13,6 +13,7 @@ use anyhow::Result; use futures::Stream; use revive_common::EVMVersion; use revive_dt_format::traits::ResolverApi; +use revive_dt_report::MinedBlockInformation; /// An interface for all interactions with Ethereum compatible nodes. #[allow(clippy::type_complexity)] @@ -80,42 +81,3 @@ pub trait EthereumNode { fn provider(&self) -> Pin>> + '_>>; } - -#[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, - - /// The block timestamp. - pub block_timestamp: BlockTimestamp, - - /// The amount of gas mined in the block. - pub mined_gas: u128, - - /// The gas limit of the block. - pub block_gas_limit: u128, - - /// 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, - - /// The max ref time for substrate based chains. - pub max_ref_time: u64, - - /// The proof size for substrate based chains. - pub proof_size: u128, - - /// The max proof size for substrate based chains. - pub max_proof_size: u64, -} diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index cffca52..739ce8b 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -21,6 +21,7 @@ revive-dt-common = { workspace = true } revive-dt-config = { workspace = true } revive-dt-format = { workspace = true } revive-dt-node-interaction = { workspace = true } +revive-dt-report = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/crates/node/src/node_implementations/geth.rs b/crates/node/src/node_implementations/geth.rs index 17ca78c..04bb697 100644 --- a/crates/node/src/node_implementations/geth.rs +++ b/crates/node/src/node_implementations/geth.rs @@ -43,9 +43,8 @@ use revive_dt_common::{ }; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; -use revive_dt_node_interaction::{ - EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, -}; +use revive_dt_node_interaction::EthereumNode; +use revive_dt_report::{EthereumMinedBlockInformation, MinedBlockInformation}; use crate::{ Node, diff --git a/crates/node/src/node_implementations/lighthouse_geth.rs b/crates/node/src/node_implementations/lighthouse_geth.rs index 5e12aeb..4021727 100644 --- a/crates/node/src/node_implementations/lighthouse_geth.rs +++ b/crates/node/src/node_implementations/lighthouse_geth.rs @@ -56,9 +56,8 @@ use revive_dt_common::{ }; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; -use revive_dt_node_interaction::{ - EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, -}; +use revive_dt_node_interaction::EthereumNode; +use revive_dt_report::{EthereumMinedBlockInformation, MinedBlockInformation}; use crate::{ Node, diff --git a/crates/node/src/node_implementations/substrate.rs b/crates/node/src/node_implementations/substrate.rs index aa298e7..faa551f 100644 --- a/crates/node/src/node_implementations/substrate.rs +++ b/crates/node/src/node_implementations/substrate.rs @@ -37,9 +37,9 @@ use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; use revive_dt_config::*; -use revive_dt_node_interaction::{ - EthereumMinedBlockInformation, EthereumNode, MinedBlockInformation, - SubstrateMinedBlockInformation, +use revive_dt_node_interaction::EthereumNode; +use revive_dt_report::{ + EthereumMinedBlockInformation, MinedBlockInformation, SubstrateMinedBlockInformation, }; use subxt::{OnlineClient, SubstrateConfig}; use tokio::sync::OnceCell; diff --git a/crates/node/src/node_implementations/zombienet.rs b/crates/node/src/node_implementations/zombienet.rs index 0b2b5b0..5ed3624 100644 --- a/crates/node/src/node_implementations/zombienet.rs +++ b/crates/node/src/node_implementations/zombienet.rs @@ -61,6 +61,9 @@ use revive_dt_common::fs::clear_directory; use revive_dt_config::*; use revive_dt_format::traits::ResolverApi; use revive_dt_node_interaction::*; +use revive_dt_report::{ + EthereumMinedBlockInformation, MinedBlockInformation, SubstrateMinedBlockInformation, +}; use serde_json::json; use sp_core::crypto::Ss58Codec; use sp_runtime::AccountId32; diff --git a/crates/report/src/aggregator.rs b/crates/report/src/aggregator.rs index 3793cb0..fd4b4cb 100644 --- a/crates/report/src/aggregator.rs +++ b/crates/report/src/aggregator.rs @@ -8,7 +8,7 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; -use alloy::primitives::{Address, BlockNumber, TxHash}; +use alloy::primitives::{Address, BlockNumber, BlockTimestamp, TxHash}; use anyhow::{Context as _, Result}; use indexmap::IndexMap; use revive_dt_common::types::PlatformIdentifier; @@ -114,6 +114,7 @@ impl ReportAggregator { RunnerEvent::ContractInformation(event) => { self.handle_contract_information(*event); } + RunnerEvent::BlockMined(event) => self.handle_block_mined(*event), } } debug!("Report aggregation completed"); @@ -385,7 +386,14 @@ impl ReportAggregator { self.execution_information(&event.execution_specifier) .deployed_contracts .get_or_insert_default() - .insert(event.contract_instance, event.address); + .insert(event.contract_instance.clone(), event.address); + self.test_case_report(&event.execution_specifier.test_specifier) + .contract_addresses + .entry(event.contract_instance) + .or_default() + .entry(event.execution_specifier.platform_identifier) + .or_default() + .push(event.address); } fn handle_completion(&mut self, _: CompletionEvent) { @@ -417,6 +425,14 @@ impl ReportAggregator { ); } + fn handle_block_mined(&mut self, event: BlockMinedEvent) { + self.test_case_report(&event.execution_specifier.test_specifier) + .mined_block_information + .entry(event.execution_specifier.platform_identifier) + .or_default() + .push(event.mined_block_information); + } + fn test_case_report(&mut self, specifier: &TestSpecifier) -> &mut ExecutionReport { self.report .execution_information @@ -502,6 +518,12 @@ pub struct ExecutionReport { /// Information on the compiled contracts. #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub compiled_contracts: BTreeMap>, + /// The addresses of the deployed contracts + #[serde(skip_serializing_if = "BTreeMap::is_empty")] + pub contract_addresses: BTreeMap>>, + /// Information on the mined blocks as part of this execution. + #[serde(skip_serializing_if = "BTreeMap::is_empty")] + pub mined_block_information: PlatformKeyedInformation>, /// Information tracked for each step that was executed. #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub steps: BTreeMap, @@ -654,5 +676,44 @@ pub struct ContractInformation { pub contract_size: PlatformKeyedInformation, } +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct MinedBlockInformation { + pub ethereum_block_information: EthereumMinedBlockInformation, + pub substrate_block_information: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct EthereumMinedBlockInformation { + /// The block number. + pub block_number: BlockNumber, + + /// The block timestamp. + pub block_timestamp: BlockTimestamp, + + /// The amount of gas mined in the block. + pub mined_gas: u128, + + /// The gas limit of the block. + pub block_gas_limit: u128, + + /// The hashes of the transactions that were mined as part of the block. + pub transaction_hashes: Vec, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct SubstrateMinedBlockInformation { + /// The ref time for substrate based chains. + pub ref_time: u128, + + /// The max ref time for substrate based chains. + pub max_ref_time: u64, + + /// The proof size for substrate based chains. + pub proof_size: u128, + + /// The max proof size for substrate based chains. + pub max_proof_size: u64, +} + /// Information keyed by the platform identifier. pub type PlatformKeyedInformation = BTreeMap; diff --git a/crates/report/src/runner_event.rs b/crates/report/src/runner_event.rs index eba163a..0a142b9 100644 --- a/crates/report/src/runner_event.rs +++ b/crates/report/src/runner_event.rs @@ -14,6 +14,7 @@ use revive_dt_format::steps::StepPath; use semver::Version; use tokio::sync::{broadcast, oneshot}; +use crate::MinedBlockInformation; use crate::TransactionInformation; use crate::{ExecutionSpecifier, ReporterEvent, TestSpecifier, common::MetadataFilePath}; @@ -633,6 +634,12 @@ define_event! { contract_name: String, /// The size of the contract contract_size: usize + }, + BlockMined { + /// A specifier for the execution that's taking place. + execution_specifier: Arc, + /// Information on the mined block, + mined_block_information: MinedBlockInformation } } }