Skip to content

Commit 6730722

Browse files
Add basic tracing (#3739)
<!-- Reference any GitHub issues resolved by this PR --> Closes # ## Introduced changes <!-- A brief description of the changes --> - ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [ ] Updated relevant documentation - [ ] Added relevant tests - [ ] Performed self-review of the code - [ ] Added changes to `CHANGELOG.md` --------- Co-authored-by: Franciszek Job <[email protected]>
1 parent eda9f08 commit 6730722

File tree

17 files changed

+133
-4
lines changed

17 files changed

+133
-4
lines changed

Cargo.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ license = "MIT"
3333
license-file = "LICENSE"
3434

3535
[workspace.dependencies]
36-
blockifier = { version = "0.15.0-rc.3", features = ["testing", "tracing"]}
36+
blockifier = { version = "0.15.0-rc.3", features = ["testing", "tracing"] }
3737
bigdecimal = "0.4.8"
3838
starknet_api = "0.15.0-rc.3"
3939
cairo-lang-casm = { version = "2.12.0", features = ["serde"] }
@@ -68,7 +68,7 @@ rayon = "1.10"
6868
regex = "1.11.1"
6969
serde = { version = "1.0.219", features = ["derive"] }
7070
serde_json = "1.0.140"
71-
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "ea064f0b51655e4c7b3d382315f0d83cfa17393b"}
71+
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "ea064f0b51655e4c7b3d382315f0d83cfa17393b" }
7272
starknet-crypto = "0.7.4"
7373
tempfile = "3.20.0"
7474
thiserror = "2.0.12"
@@ -121,3 +121,7 @@ paste = "1.0.15"
121121
strum = "0.27"
122122
strum_macros = "0.27"
123123
scarb-oracle-hint-service = { git = "https://github.com/software-mansion/scarb", rev = "210da8dfd0b370f0f1970b33a373f1a7afe6ae33" }
124+
chrono = "0.4.41"
125+
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
126+
tracing = "0.1.41"
127+
tracing-chrome = "0.7.2"

crates/forge-runner/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ foundry-ui = { path = "../foundry-ui" }
4848
strum = "0.27"
4949
strum_macros = "0.27"
5050
scarb-oracle-hint-service.workspace = true
51+
tracing.workspace = true

crates/forge-runner/src/gas.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use starknet_api::execution_resources::{GasAmount, GasVector};
1818
use starknet_api::transaction::EventContent;
1919
use starknet_api::transaction::fields::GasVectorComputationMode;
2020

21+
#[tracing::instrument(skip_all, level = "debug")]
2122
pub fn calculate_used_gas(
2223
transaction_context: &TransactionContext,
2324
state: &mut CachedState<ExtendedStateReader>,

crates/forge-runner/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub fn maybe_generate_coverage(
103103
}
104104

105105
#[must_use]
106+
#[tracing::instrument(skip_all, level = "debug")]
106107
pub fn run_for_test_case(
107108
case: Arc<TestCaseWithResolvedConfig>,
108109
casm_program: Arc<AssembledProgramWithDebugInfo>,
@@ -137,6 +138,7 @@ pub fn run_for_test_case(
137138
}
138139
}
139140

141+
#[tracing::instrument(skip_all, level = "debug")]
140142
fn run_with_fuzzing(
141143
case: Arc<TestCaseWithResolvedConfig>,
142144
casm_program: Arc<AssembledProgramWithDebugInfo>,

crates/forge-runner/src/running.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub use syscall_handler::has_segment_arena;
5858
pub use syscall_handler::syscall_handler_offset;
5959

6060
#[must_use]
61+
#[tracing::instrument(skip_all, level = "debug")]
6162
pub fn run_test(
6263
case: Arc<TestCaseWithResolvedConfig>,
6364
casm_program: Arc<AssembledProgramWithDebugInfo>,
@@ -87,6 +88,7 @@ pub fn run_test(
8788
})
8889
}
8990

91+
#[tracing::instrument(skip_all, level = "debug")]
9092
pub(crate) fn run_fuzz_test(
9193
case: Arc<TestCaseWithResolvedConfig>,
9294
casm_program: Arc<AssembledProgramWithDebugInfo>,
@@ -151,6 +153,7 @@ pub enum RunResult {
151153
}
152154

153155
#[expect(clippy::too_many_lines)]
156+
#[tracing::instrument(skip_all, level = "debug")]
154157
pub fn run_test_case(
155158
case: &TestCaseWithResolvedConfig,
156159
casm_program: &AssembledProgramWithDebugInfo,

crates/forge-runner/src/running/execution.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use blockifier::transaction::objects::ExecutionResourcesTraits;
1010
use cairo_vm::vm::runners::cairo_runner::{CairoRunner, ExecutionResources};
1111

1212
// Based on the code from blockifer
13+
#[tracing::instrument(skip_all, level = "debug")]
1314
pub fn finalize_execution(
1415
// region: Modified blockifier code
1516
runner: &mut CairoRunner,

crates/forge-runner/src/running/setup.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub struct VmExecutionContext<'a> {
3030

3131
// Based on code from https://github.com/starkware-libs/sequencer/blob/e417a9e7d50cbd78065d357763df2fbc2ad41f7c/crates/blockifier/src/execution/entry_point_execution.rs#L122
3232
// Enough of the logic of this had to be changed that probably it won't be possible to upstream it
33+
#[tracing::instrument(skip_all, level = "debug")]
3334
pub fn initialize_execution_context<'a>(
3435
call: ExecutableCallEntryPoint,
3536
hints: &'a HashMap<String, Hint>,

crates/forge-runner/src/running/with_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use rayon::iter::ParallelIterator;
2121
use std::{collections::HashMap, sync::Arc};
2222
use universal_sierra_compiler_api::{SierraType, compile_sierra_at_path};
2323

24+
#[tracing::instrument(skip_all, level = "debug")]
2425
pub fn test_target_with_config(
2526
test_target_raw: TestTargetRaw,
2627
tracked_resource: &ForgeTrackedResource,

crates/forge/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ url.workspace = true
5252
indoc.workspace = true
5353
derive_more.workspace = true
5454
foundry-ui = { path = "../foundry-ui" }
55+
chrono.workspace = true
56+
tracing-subscriber.workspace = true
57+
tracing.workspace = true
58+
tracing-chrome.workspace = true
5559

5660
[[bin]]
5761
name = "snforge"

0 commit comments

Comments
 (0)