Skip to content

feat(avm)!: optionally use TS logger in C++ simulation#19305

Merged
fcarreiro merged 3 commits into
merge-train/avmfrom
fc/cpp-log-through-ts
Jan 7, 2026
Merged

feat(avm)!: optionally use TS logger in C++ simulation#19305
fcarreiro merged 3 commits into
merge-train/avmfrom
fc/cpp-log-through-ts

Conversation

@fcarreiro

@fcarreiro fcarreiro commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

This PR

  • Makes BB's info/vinfo/etc customizable by a logging function
  • Updates the TS side of CPP simulation to optionally take a logger function.

The TS-side of the CPP simulator now uses the pino logger.

image.png

I've also refactored the avm_simulate_napi.cpp file to avoid referencing the parameter indices many times, and using them in a very "local" way. Otherwise it was getting a bit dangerous that we would use some magic index in places many lines away.

This shouldn't cause any overhead if logging is not active (as expected in block building, because ANY logging might take a ms - e.g., showing the transaction hash). If you are doing any logging, you will pay dearly.

Closes AVM-182.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fcarreiro fcarreiro marked this pull request as ready for review January 5, 2026 13:11
@fcarreiro fcarreiro requested review from ludamad and removed request for sirasistant January 5, 2026 13:11
@fcarreiro fcarreiro changed the title feat(avm)!: use TS logger in C++ feat(avm)!: optionally use TS logger in C++ simulation Jan 5, 2026
@fcarreiro fcarreiro force-pushed the fc/cpp-log-through-ts branch from 80956ce to b2a20fc Compare January 5, 2026 13:24
@AztecBot

AztecBot commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Flakey Tests

🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (\0338;;http://ci.aztec-labs.com/16afd795f8ce4066�16afd795f8ce40668;;�\033): barretenberg/acir_tests/scripts/browser_prove.sh verify_honk_proof webkit (18s) (code: 1) (\033fcarreiro\033: change some logging levels)

enum class LogLevel : int {
DEBUG = 0,
INFO = 1,
VERBOSE = 2,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: move VERBOSE, reorder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we simply don't have logging functions for all levels in C++, but the asymmetry in log-levels between TS and C++ is unfortunate.

@dbanks12 dbanks12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple comments

enum class LogLevel : int {
DEBUG = 0,
INFO = 1,
VERBOSE = 2,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we simply don't have logging functions for all levels in C++, but the asymmetry in log-levels between TS and C++ is unfortunate.

Comment on lines 30 to +50
debug_logging = (log_level >= LOG_LEVEL_TRACE);
}

// Map C++ LogLevel enum to TypeScript log level string
// C++ LogLevel: DEBUG=0, INFO=1, VERBOSE=2, IMPORTANT=3
// TS LogLevels: ['silent', 'fatal', 'error', 'warn', 'info', 'verbose', 'debug', 'trace']
inline const char* cpp_log_level_to_ts(LogLevel level)
{
switch (level) {
case LogLevel::DEBUG:
return "debug";
case LogLevel::INFO:
return "info";
case LogLevel::VERBOSE:
return "verbose";
case LogLevel::IMPORTANT:
return "warn";
default:
return "info";
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work oddly because above we set debug_logging = (log_level >= TRACE) and then later we set treat debug() and then in this switch-case we map DEBUG->debug? I'd suggest we just have debug == DEBUG, but then I think we need "trace" for per-execution-iteration prints (like the debug that prints the pc & opcode).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. I think I'll leave it as it is right now, and try to convince @ludamad to let me align BB and TS log levels.

fcarreiro commented Jan 7, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jan 7, 10:25 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 7, 10:26 AM UTC: @fcarreiro merged this pull request with Graphite.

@fcarreiro fcarreiro merged commit d64da2a into merge-train/avm Jan 7, 2026
11 checks passed
@fcarreiro fcarreiro deleted the fc/cpp-log-through-ts branch January 7, 2026 10:26
@AztecBot AztecBot mentioned this pull request Jan 7, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 8, 2026
BEGIN_COMMIT_OVERRIDE
feat(avm)!: optionally use TS logger in C++ simulation (#19305)
chore(avm): bytecode caching comments
chore(avm): disable VK hash checking in tests
fix(avm)!: instr_fetching soundness bug (#19381)
fix(avm): dont catch wide exceptions (#19388)
refactor(avm): Refactor get contract instance fuzzer backfill (#19387)
feat(avm): mutate enqueued calls (#19315)
chore(avm): migrate to BB asserts (#19395)
fix!: more missing boolean constraints in calldata, calldata hashing,
sha256 mem PILs (#19367)
feat(avm): defensively assert cd hashes (#19346)
chore: annotate booleans in PIL, and add some missing boolean
constraints (#19371)
fix!: missing boolean constraints on zero checks targets (#19401)
fix!: context did not constrain returndata size to 0 at start, and had a
misnamed relation (#19404)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants