From 3c10f5d2f3e4be69f291023be4b1e2ed7e1e5ee6 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Wed, 22 Oct 2025 15:12:46 +0300 Subject: [PATCH] Include the contract information in the report --- .../src/differential_benchmarks/driver.rs | 16 ++++++++++ crates/report/src/aggregator.rs | 30 ++++++++++++++++++- crates/report/src/runner_event.rs | 10 +++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/crates/core/src/differential_benchmarks/driver.rs b/crates/core/src/differential_benchmarks/driver.rs index 84d5915..1d13b69 100644 --- a/crates/core/src/differential_benchmarks/driver.rs +++ b/crates/core/src/differential_benchmarks/driver.rs @@ -218,6 +218,22 @@ where .inspect_err(|err| error!(?err, "Post-linking compilation failed")) .context("Failed to compile the post-link contracts")?; + for (contract_path, contract_name_to_info_mapping) in compiler_output.contracts.iter() { + for (contract_name, (contract_bytecode, _)) in contract_name_to_info_mapping.iter() { + let contract_bytecode = hex::decode(contract_bytecode) + .expect("Impossible for us to get an undecodable bytecode after linking"); + + self.platform_information + .reporter + .report_contract_information_event( + contract_path.to_path_buf(), + contract_name.clone(), + contract_bytecode.len(), + ) + .expect("Should not fail"); + } + } + self.execution_state = ExecutionState::new( compiler_output.contracts, deployed_libraries.unwrap_or_default(), diff --git a/crates/report/src/aggregator.rs b/crates/report/src/aggregator.rs index dee8ba5..3793cb0 100644 --- a/crates/report/src/aggregator.rs +++ b/crates/report/src/aggregator.rs @@ -111,6 +111,9 @@ impl ReportAggregator { RunnerEvent::StepTransactionInformation(event) => { self.handle_step_transaction_information(*event) } + RunnerEvent::ContractInformation(event) => { + self.handle_contract_information(*event); + } } } debug!("Report aggregation completed"); @@ -400,6 +403,20 @@ impl ReportAggregator { .push(event.transaction_information); } + fn handle_contract_information(&mut self, event: ContractInformationEvent) { + self.test_case_report(&event.execution_specifier.test_specifier) + .compiled_contracts + .entry(event.source_code_path) + .or_default() + .entry(event.contract_name) + .or_default() + .contract_size + .insert( + event.execution_specifier.platform_identifier, + event.contract_size, + ); + } + fn test_case_report(&mut self, specifier: &TestSpecifier) -> &mut ExecutionReport { self.report .execution_information @@ -480,8 +497,13 @@ pub struct ExecutionReport { #[serde(skip_serializing_if = "Option::is_none")] pub metrics: Option, /// Information related to the execution on one of the platforms. + #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub platform_execution: PlatformKeyedInformation>, + /// Information on the compiled contracts. + #[serde(skip_serializing_if = "BTreeMap::is_empty")] + pub compiled_contracts: BTreeMap>, /// Information tracked for each step that was executed. + #[serde(skip_serializing_if = "BTreeMap::is_empty")] pub steps: BTreeMap, } @@ -612,7 +634,7 @@ pub struct Metrics { } /// The data that we store for a given metric (e.g., TPS). -#[derive(Clone, Debug, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Metric { #[serde(skip_serializing_if = "Option::is_none")] pub minimum: Option>, @@ -626,5 +648,11 @@ pub struct Metric { pub sum: Option>, } +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct ContractInformation { + /// The size of the contract on the various platforms. + pub contract_size: PlatformKeyedInformation, +} + /// 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 bcce3f1..eba163a 100644 --- a/crates/report/src/runner_event.rs +++ b/crates/report/src/runner_event.rs @@ -623,6 +623,16 @@ define_event! { step_path: StepPath, /// Information about the transaction transaction_information: TransactionInformation + }, + ContractInformation { + /// A specifier for the execution that's taking place. + execution_specifier: Arc, + /// The path of the solidity source code that contains the contract. + source_code_path: PathBuf, + /// The name of the contract + contract_name: String, + /// The size of the contract + contract_size: usize } } }