Include the contract information in the report

This commit is contained in:
Omar Abdulla
2025-10-22 15:12:46 +03:00
parent a5853f86b7
commit 3c10f5d2f3
3 changed files with 55 additions and 1 deletions
@@ -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(),
+29 -1
View File
@@ -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<Metrics>,
/// Information related to the execution on one of the platforms.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub platform_execution: PlatformKeyedInformation<Option<ExecutionInformation>>,
/// Information on the compiled contracts.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub compiled_contracts: BTreeMap<PathBuf, BTreeMap<String, ContractInformation>>,
/// Information tracked for each step that was executed.
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
pub steps: BTreeMap<StepPath, StepReport>,
}
@@ -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<T> {
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<PlatformKeyedInformation<T>>,
@@ -626,5 +648,11 @@ pub struct Metric<T> {
pub sum: Option<PlatformKeyedInformation<T>>,
}
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct ContractInformation {
/// The size of the contract on the various platforms.
pub contract_size: PlatformKeyedInformation<usize>,
}
/// Information keyed by the platform identifier.
pub type PlatformKeyedInformation<T> = BTreeMap<PlatformIdentifier, T>;
+10
View File
@@ -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<ExecutionSpecifier>,
/// 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
}
}
}