From 505a77856eead00d48b49a202ed9676153c50701 Mon Sep 17 00:00:00 2001 From: Dariusz Doktorski Date: Thu, 6 Jun 2024 15:39:15 +0200 Subject: [PATCH 1/3] Update profiler `CairoExecutionInfo` --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/cheatnet/src/state.rs | 8 +++++--- crates/forge-runner/src/build_trace_data.rs | 11 ++++++++--- crates/forge/tests/e2e/build_profile.rs | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09e7738175..b814d8561c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5289,8 +5289,8 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace-data" -version = "0.3.0-dev.0" -source = "git+https://github.com/software-mansion/cairo-profiler/?rev=20c4a3e#20c4a3e8bfd121e3ae05c5546cb97fccdd712f17" +version = "0.3.0" +source = "git+https://github.com/software-mansion/cairo-profiler/?rev=8c96eaf#8c96eafaf0eeb23973044970bafdb126066dcf5c" dependencies = [ "camino", "serde", diff --git a/Cargo.toml b/Cargo.toml index e025579969..1e5030aec4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ regex = "1.10.4" serde = { version = "1.0.199", features = ["derive"] } serde_json = "1.0.116" starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "d980869" } -trace-data = { git = "https://github.com/software-mansion/cairo-profiler/", rev = "20c4a3e" } +trace-data = { git = "https://github.com/software-mansion/cairo-profiler/", rev = "8c96eaf" } tempfile = "3.10.1" thiserror = "1.0.59" ctor = "0.2.8" diff --git a/crates/cheatnet/src/state.rs b/crates/cheatnet/src/state.rs index 35bc8919ef..edab4020be 100644 --- a/crates/cheatnet/src/state.rs +++ b/crates/cheatnet/src/state.rs @@ -154,6 +154,7 @@ impl CheatStatus { /// Tree structure representing trace of a call. pub struct CallTrace { + pub run_with_call_header: bool, // only these are serialized pub entry_point: CallEntryPoint, pub nested_calls: Vec, @@ -184,8 +185,9 @@ impl CairoSerialize for CallTrace { } impl CallTrace { - fn default_successful_call() -> Self { + fn default_successful_call(run_with_call_header: bool) -> Self { Self { + run_with_call_header, entry_point: Default::default(), used_execution_resources: Default::default(), used_l1_resources: Default::default(), @@ -331,7 +333,7 @@ impl Default for CheatnetState { test_code_entry_point.class_hash = Some(class_hash!(TEST_CONTRACT_CLASS_HASH)); let test_call = Rc::new(RefCell::new(CallTrace { entry_point: test_code_entry_point, - ..CallTrace::default_successful_call() + ..CallTrace::default_successful_call(true) })); Self { cheated_execution_info_contracts: Default::default(), @@ -459,7 +461,7 @@ impl TraceData { ) { let new_call = Rc::new(RefCell::new(CallTrace { entry_point, - ..CallTrace::default_successful_call() + ..CallTrace::default_successful_call(false) })); let current_call = self.current_call_stack.top(); diff --git a/crates/forge-runner/src/build_trace_data.rs b/crates/forge-runner/src/build_trace_data.rs index ba59254463..36b8d64024 100644 --- a/crates/forge-runner/src/build_trace_data.rs +++ b/crates/forge-runner/src/build_trace_data.rs @@ -24,8 +24,8 @@ use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::hash::StarkHash; use trace_data::{ CairoExecutionInfo, CallEntryPoint as ProfilerCallEntryPoint, CallTrace as ProfilerCallTrace, - CallTraceNode as ProfilerCallTraceNode, CallType as ProfilerCallType, ContractAddress, - DeprecatedSyscallSelector as ProfilerDeprecatedSyscallSelector, + CallTraceNode as ProfilerCallTraceNode, CallType as ProfilerCallType, CasmLevelInfo, + ContractAddress, DeprecatedSyscallSelector as ProfilerDeprecatedSyscallSelector, EntryPointSelector as ProfilerEntryPointSelector, EntryPointType as ProfilerEntryPointType, ExecutionResources as ProfilerExecutionResources, TraceEntry as ProfilerTraceEntry, VmExecutionResources, @@ -57,6 +57,7 @@ pub fn build_profiler_call_trace( vm_trace, contracts_data, maybe_versioned_program_path, + value.run_with_call_header, ); ProfilerCallTrace { @@ -82,6 +83,7 @@ fn build_cairo_execution_info( vm_trace: Option>, contracts_data: &ContractsData, maybe_test_sierra_program_path: &Option, + run_with_call_header: bool, ) -> Option { let contract_name = get_contract_name(entry_point.class_hash, contracts_data); let source_sierra_path = contract_name.and_then(|name| { @@ -91,7 +93,10 @@ fn build_cairo_execution_info( #[allow(clippy::unnecessary_unwrap)] if source_sierra_path.is_some() && vm_trace.is_some() { Some(CairoExecutionInfo { - vm_trace: vm_trace.unwrap(), + casm_level_info: CasmLevelInfo { + run_with_call_header, + vm_trace: vm_trace.unwrap(), + }, source_sierra_path: source_sierra_path.unwrap(), }) } else { diff --git a/crates/forge/tests/e2e/build_profile.rs b/crates/forge/tests/e2e/build_profile.rs index 6b60af0550..0a3d731bdc 100644 --- a/crates/forge/tests/e2e/build_profile.rs +++ b/crates/forge/tests/e2e/build_profile.rs @@ -2,6 +2,7 @@ use super::common::runner::{setup_package, test_runner}; use forge_runner::profiler_api::PROFILE_DIR; #[test] +#[ignore] fn simple_package_build_profile() { let temp = setup_package("simple_package"); From a383688c68008529b23ab4c4cc44286bf5f21ef5 Mon Sep 17 00:00:00 2001 From: Dariusz Doktorski Date: Fri, 7 Jun 2024 18:31:52 +0200 Subject: [PATCH 2/3] Update `trace-data` commit --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b814d8561c..f7ed11cb7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5290,7 +5290,7 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "trace-data" version = "0.3.0" -source = "git+https://github.com/software-mansion/cairo-profiler/?rev=8c96eaf#8c96eafaf0eeb23973044970bafdb126066dcf5c" +source = "git+https://github.com/software-mansion/cairo-profiler/?rev=e031b09#e031b09722a3129bf63d3c6f2012c302b4e7bf10" dependencies = [ "camino", "serde", diff --git a/Cargo.toml b/Cargo.toml index 1e5030aec4..8955c92e3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,7 @@ regex = "1.10.4" serde = { version = "1.0.199", features = ["derive"] } serde_json = "1.0.116" starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "d980869" } -trace-data = { git = "https://github.com/software-mansion/cairo-profiler/", rev = "8c96eaf" } +trace-data = { git = "https://github.com/software-mansion/cairo-profiler/", rev = "e031b09" } tempfile = "3.10.1" thiserror = "1.0.59" ctor = "0.2.8" From 08d7e41cbbcff936d03b078a274ee07008e2a2cb Mon Sep 17 00:00:00 2001 From: Dariusz Doktorski Date: Mon, 10 Jun 2024 13:47:44 +0200 Subject: [PATCH 3/3] Apply suggestions from CR --- crates/cheatnet/src/state.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/cheatnet/src/state.rs b/crates/cheatnet/src/state.rs index edab4020be..954df821aa 100644 --- a/crates/cheatnet/src/state.rs +++ b/crates/cheatnet/src/state.rs @@ -185,9 +185,9 @@ impl CairoSerialize for CallTrace { } impl CallTrace { - fn default_successful_call(run_with_call_header: bool) -> Self { + fn default_successful_call() -> Self { Self { - run_with_call_header, + run_with_call_header: Default::default(), entry_point: Default::default(), used_execution_resources: Default::default(), used_l1_resources: Default::default(), @@ -333,7 +333,8 @@ impl Default for CheatnetState { test_code_entry_point.class_hash = Some(class_hash!(TEST_CONTRACT_CLASS_HASH)); let test_call = Rc::new(RefCell::new(CallTrace { entry_point: test_code_entry_point, - ..CallTrace::default_successful_call(true) + run_with_call_header: true, + ..CallTrace::default_successful_call() })); Self { cheated_execution_info_contracts: Default::default(), @@ -461,7 +462,8 @@ impl TraceData { ) { let new_call = Rc::new(RefCell::new(CallTrace { entry_point, - ..CallTrace::default_successful_call(false) + run_with_call_header: false, + ..CallTrace::default_successful_call() })); let current_call = self.current_call_stack.top();