Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add run_with_call_header field to CallTrace #2180

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
piotmag769 marked this conversation as resolved.
Show resolved Hide resolved
fn simple_package_build_profile() {
let temp = setup_package("simple_package");

Expand Down
Loading