Add the block information to the report

This commit is contained in:
Omar Abdulla
2025-10-22 15:36:42 +03:00
parent 3c10f5d2f3
commit 03b09d49ec
11 changed files with 90 additions and 53 deletions
Generated
+2
View File
@@ -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]]
@@ -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()
+1
View File
@@ -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 }
+2 -40
View File
@@ -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<Box<dyn Future<Output = anyhow::Result<DynProvider<Ethereum>>> + '_>>;
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MinedBlockInformation {
pub ethereum_block_information: EthereumMinedBlockInformation,
pub substrate_block_information: Option<SubstrateMinedBlockInformation>,
}
#[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<TxHash>,
}
#[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,
}
+1
View File
@@ -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 }
+2 -3
View File
@@ -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,
@@ -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,
@@ -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;
@@ -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;
+63 -2
View File
@@ -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<PathBuf, BTreeMap<String, ContractInformation>>,
/// The addresses of the deployed contracts
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub contract_addresses: BTreeMap<ContractInstance, PlatformKeyedInformation<Vec<Address>>>,
/// Information on the mined blocks as part of this execution.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub mined_block_information: PlatformKeyedInformation<Vec<MinedBlockInformation>>,
/// Information tracked for each step that was executed.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub steps: BTreeMap<StepPath, StepReport>,
@@ -654,5 +676,44 @@ pub struct ContractInformation {
pub contract_size: PlatformKeyedInformation<usize>,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct MinedBlockInformation {
pub ethereum_block_information: EthereumMinedBlockInformation,
pub substrate_block_information: Option<SubstrateMinedBlockInformation>,
}
#[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<TxHash>,
}
#[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<T> = BTreeMap<PlatformIdentifier, T>;
+7
View File
@@ -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<ExecutionSpecifier>,
/// Information on the mined block,
mined_block_information: MinedBlockInformation
}
}
}