Skip to content

Commit

Permalink
Add run_with_call_header field to CallTrace (#2180)
Browse files Browse the repository at this point in the history
<!-- Reference any GitHub issues resolved by this PR -->

Related software-mansion/cairo-profiler#75

## Introduced changes

<!-- A brief description of the changes -->

- Updated profiler related code to align with the changes from
software-mansion/cairo-profiler#92

## Checklist

<!-- Make sure all of these are complete -->

- [X] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added relevant tests
- [X] Performed self-review of the code
- [ ] Added changes to `CHANGELOG.md`
  • Loading branch information
ddoktorski authored Jun 10, 2024
1 parent b05b605 commit 0af6d8b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ serde = { version = "1.0.199", features = ["derive"] }
serde_json = "1.0.116"
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "d980869" }
starknet-crypto = { 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 = "e031b09" }
tempfile = "3.10.1"
thiserror = "1.0.59"
ctor = "0.2.8"
Expand Down
4 changes: 4 additions & 0 deletions crates/cheatnet/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl<T> CheatStatus<T> {

/// 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<CallTraceNode>,
Expand Down Expand Up @@ -186,6 +187,7 @@ impl CairoSerialize for CallTrace {
impl CallTrace {
fn default_successful_call() -> Self {
Self {
run_with_call_header: Default::default(),
entry_point: Default::default(),
used_execution_resources: Default::default(),
used_l1_resources: Default::default(),
Expand Down Expand Up @@ -331,6 +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,
run_with_call_header: true,
..CallTrace::default_successful_call()
}));
Self {
Expand Down Expand Up @@ -459,6 +462,7 @@ impl TraceData {
) {
let new_call = Rc::new(RefCell::new(CallTrace {
entry_point,
run_with_call_header: false,
..CallTrace::default_successful_call()
}));
let current_call = self.current_call_stack.top();
Expand Down
11 changes: 8 additions & 3 deletions crates/forge-runner/src/build_trace_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -57,6 +57,7 @@ pub fn build_profiler_call_trace(
vm_trace,
contracts_data,
maybe_versioned_program_path,
value.run_with_call_header,
);

ProfilerCallTrace {
Expand All @@ -82,6 +83,7 @@ fn build_cairo_execution_info(
vm_trace: Option<Vec<ProfilerTraceEntry>>,
contracts_data: &ContractsData,
maybe_test_sierra_program_path: &Option<VersionedProgramPath>,
run_with_call_header: bool,
) -> Option<CairoExecutionInfo> {
let contract_name = get_contract_name(entry_point.class_hash, contracts_data);
let source_sierra_path = contract_name.and_then(|name| {
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions crates/forge/tests/e2e/build_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 0af6d8b

Please sign in to comment.