blockifier: adopt cairo-native executors via cfg-resolved NativeContractExecutor#13880
blockifier: adopt cairo-native executors via cfg-resolved NativeContractExecutor#13880avi-starkware wants to merge 7 commits into
Conversation
PR SummaryMedium Risk Overview
Native entry points go through Reviewed by Cursor Bugbot for commit bc12844. Bugbot is set up for automated code reviews on this repo. Configure here. |
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 8 files reviewed, 2 unresolved discussions (waiting on avi-starkware and TomerStarkware).
crates/blockifier/src/execution/native/entry_point_execution.rs line 104 at r2 (raw file):
#[cfg(not(feature = "with-libfunc-profiling"))] let execution_result = compiled_class.executor.run( selector,
Suggestion:
let selector = entry_point.selector.0;
let calldata = syscall_handler.base.call.calldata.0.clone();
#[cfg(feature = "with-libfunc-profiling")]
let execution_result = run_with_profile(
selector,
&calldata,
call_initial_gas,
Some(builtin_costs),
&mut syscall_handler,
on_profile
)
}
#[cfg(not(feature = "with-libfunc-profiling"))]
let execution_result = compiled_class.executor.run(
selector,9630be2 to
88f60d0
Compare
|
I extracted the entire logic (including the feature gate) into |
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware partially reviewed 5 files, made 1 comment, and resolved 1 discussion.
Reviewable status: 2 of 9 files reviewed, 1 unresolved discussion (waiting on avi-starkware and TomerStarkware).
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware partially reviewed 7 files and made 1 comment.
Reviewable status: 8 of 9 files reviewed, 1 unresolved discussion (waiting on avi-starkware and TomerStarkware).
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware reviewed 1 file and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on avi-starkware and TomerStarkware).
88f60d0 to
7f89015
Compare
| # (starkware-libs/cairo_native#1610 → #1611 → #1612 → #1613) containing | ||
| # `ContractExecutor`, `EmuContractInfo`, `AotWithProgram`, and `run_with_profile`. | ||
| # Switch back to a crates.io version once those land in a published cairo-native release. | ||
| cairo-native = { git = "https://github.com/starkware-libs/cairo_native.git", rev = "78bf3e4b01a085261f61367c29391e98deb98460" } |
There was a problem hiding this comment.
Unpublished git dependency committed for production use
Medium Severity
The cairo-native dependency is pinned to a specific git revision from an unreleased PR stack instead of a published crates.io version. The comment says "TEMP" and the PR description warns not to merge until upstream lands, but this temporary git dep could easily be forgotten and shipped. A production dependency on an unpublished git rev risks reproducibility issues and blocks downstream consumers who can't resolve the git source.
Reviewed by Cursor Bugbot for commit 7f89015. Configure here.
There was a problem hiding this comment.
Acknowledged — this is the intended merge gate, not a forgotten TEMP. The git rev pins the tip of the cairo_native PR stack (#1610 → #1611 → #1607 → #1612 → #1613); merge of this PR is blocked on that stack landing in a published cairo-native release. The # TEMP: block above the dep line names the upstream PRs and the planned crates.io swap.
7f89015 to
8d7bbc6
Compare
8d7bbc6 to
bfe58c8
Compare
Yoni-Starkware
left a comment
There was a problem hiding this comment.
Rebase over main?
@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 9 files reviewed, 2 unresolved discussions (waiting on avi-starkware and TomerStarkware).
bfe58c8 to
c7a3fac
Compare
a962748 to
441098f
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
|
Done. |
c7a3fac to
52cfdf6
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c8cca67. Configure here.
baa8bad to
a184916
Compare
|
There hasn't been any activity on this pull request recently, and in order to prioritize active work, it has been marked as stale. |
…utor + libfunc profiling Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cargo accepts both git+rev and a version field together; the field is a SemVer constraint on the package at the git rev. The rev's Cargo.toml already pins 0.9.0-rc.6, matching native_compiler_version.txt, so the constants test required_cairo_native_version_test parses the version and succeeds. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Drop unused `NativeCompiledClassV1::new_from_emu`; it had no in-tree callers, and the sierra-emu construction path will be re-added when the benchmarking/replay tool that needs it lands. - Revert `process_compilation_request`'s `.map(...)` shape to a direct `match`, moving `casm` into `NativeCompiledClassV1::new(_with_program)` in the `Ok` arm at zero cost instead of cloning it. - Bump pinned cairo-native rev to pick up `cargo fmt` fix on starkware-libs/cairo_native#1613. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`new_from_emu` was deleted in 88b68af after Cursor flagged it as unused. Restore it (with a doc comment naming the planned consumer) so the benchmarking / replay tooling — which will live as a feature branch and is not expected to merge here — can reach it without patching this file. No `#[expect(dead_code)]` needed: `dead_code` doesn't fire on `pub fn` in a library crate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…r libfunc profiling The with-libfunc-profiling feature only enables profiling in the linked cairo-native library; the profiler symbol that run_with_libfunc_profile resolves is emitted by the compiler binary. Document that starknet-native-compile must itself be built with with-libfunc-profiling (and that compiler_binary_path can point at such a binary), otherwise every profiled native call fails on a missing symbol. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tractExecutor The enum dispatched between executor backends that are always selected at compile time, never at runtime. NativeCompiledClassV1 now stores a NativeContractExecutor type alias resolved per build: AotContractExecutor in production, EmuContractExecutor under sierra-emu (which now skips native compilation in the class manager and runs the interpreter), AotWithProgram under with-libfunc-profiling. All three expose the same run() shape, so call sites are unchanged across builds; sierra-emu takes precedence over profiling in the resolution. Pulls the reworked cairo-native stack (no ContractExecutor enum; EmuContractExecutor + AotWithProgram with inherent run methods). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a184916 to
536db23
Compare
The previous head SHA carried a permanently-completed check-run (failure) from before that job was removed from main's workflow. merge-gatekeeper-new no longer ignores that context, so it polls forever waiting on a check that will never update, until it times out. A new SHA has no such stale check-run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>



Summary
Replaces the local
AotContractExecutorfield onNativeCompiledClassV1Innerwith a cfg-resolvedNativeContractExecutortype alias and adopts cairo-native's new libfunc-profiling APIs. There is no dispatch enum anywhere: the executor backend is always selected at compile time, so production builds store literallyAotContractExecutor, and the special backends exist only inside their feature gates.NativeContractExecutorresolution (all three types expose the samerunshape, so call sites are identical across builds):cairo_native)AotContractExecutorsierra-emu(testing / benchmarking; takes precedence)EmuContractExecutor— the class manager skips native compilation entirely and the sierra-emu interpreter consumes the Sierra program directlywith-libfunc-profilingAotWithProgram— AOT executor paired with its Sierra program so libfunc samples can be resolvedThe conversion glue between cairo-native and sierra-emu syscall traits, and the libfunc profiling instrumentation — both previously maintained in blockifier — live in cairo-native.
Important
Depends on the unreleased cairo_native PR stack (in order):
StarknetSyscallHandlertrait/types with cairo-native (released in0.9.0-rc.7)cairo-native-syscallscrate (released in0.9.0-rc.7)EmuContractExecutor+sierra_emu::VirtualMachine::run_contractrun_with_libfunc_profile+AotWithProgramwith inherentrun/run_with_profileThe workspace
Cargo.tomluses agit/revdep pinned to the tip of #1613 (rev6184f7a6, package version0.9.0-rc.7). Do not merge until that stack lands and a cairo-native release is published, then swap thegit/revdep back to a publishedversion = "...".Commits
blockifier,apollo_compile_to_native: adopt cairo_native::ContractExecutor + libfunc profiling— the original enum-based adoption; switchesexecutor: AotContractExecutor→ cairo-native'sContractExecutor; addssierra-emu+with-libfunc-profilingfeatures; addsSierraToNativeCompiler::compile_with_program; routesentry_point_executionthroughrun_dispatch::run_native_executor.workspace: declare cairo-native version on git dep for version sync test.blockifier: address review feedback on native compilation path—casmmoves into the constructor at zero cost.blockifier: re-add new_from_emu for out-of-tree benchmarking branch.apollo_compile_to_native: document instrumented-binary requirement for libfunc profiling.blockifier: replace ContractExecutor enum with cfg-resolved NativeContractExecutor— removes the enum from production code (revert this commit to restore the enum-based design). Collapsesnew/new_from_emu/new_with_programinto a singlenew(executor: NativeContractExecutor, _); the class manager and test utils construct the matching backend per build;sierra-emunow actually executes in-tree instead of gating a dead constructor.Branch is rebased over main (cairo-lang
2.19.0-rc.3), per review.Replaces
The (still-open) #13542 / #13543 / #13755 stack. The sierra-emu syscall conversions and the libfunc profiling primitive moved to cairo-native (per @Yoni-Starkware's review on #13543); the executor-backend selection is now a compile-time type resolution rather than an enum in production code (per @orizi's review on the cairo-native stack).
Test plan
cargo check -p blockifier --features cairo_native,testingcargo check -p blockifier --features cairo_native,sierra-emu,testingcargo check -p blockifier --features cairo_native,with-libfunc-profiling,testingcargo check -p blockifier --features cairo_native,sierra-emu,with-libfunc-profiling,testinggit/revdep back to a crates.ioversion = "..."and re-run CI🤖 Generated with Claude Code