blockifier_reexecution: compile Sierra to Casm in-process via library call#14406
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Artifacts upload workflows: |
AvivYossef-starkware
left a comment
There was a problem hiding this comment.
Can we remove the binary from the replay andstarknet_transaction_prover images?
@AvivYossef-starkware reviewed 4 files and all commit messages, and made 2 comments.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on Yoni-Starkware).
crates/blockifier_reexecution/src/compile.rs line 84 at r1 (raw file):
let extracted_sierra_program = contract_class_for_compilation .extract_sierra_program(false) .unwrap_or_else(|err| panic!("Failed to extract the Sierra program: {err}"));
not in the scope of this PR ( since it was the behavior before )
But should we avoid panicking? ( we use it in the transaction prover )
Code quote:
.unwrap_or_else
PR SummaryMedium Risk Overview The The sequencer gateway path ( Reviewed by Cursor Bugbot for commit dc87fbd. Bugbot is set up for automated code reviews on this repo. Configure here. |
… call Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
07e378f to
dc87fbd
Compare
|
Previously, AvivYossef-starkware wrote…
Done. |
AvivYossef-starkware
left a comment
There was a problem hiding this comment.
@AvivYossef-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on Yoni-Starkware).

Why
blockifier_reexecution(and through it,starknet_transaction_prover) compiles Sierra classes by shelling out to thestarknet-sierra-compilesidecar binary. That binary is the only external runtime dependency of the prover: native (non-Docker) deployments fail at the first Sierra-class compilation unless the operator pre-installs it at the exact pinned version (the macOS pain point behind #14379, #14389, #14402).The subprocess exists for the sequencer gateway, where Sierra classes are user-submitted adversarial input requiring resource-limited process isolation. Re-execution has no such input: every class compiled here is fetched from the chain — already declared, already compiled once by the sequencer under limits. The isolation buys nothing on this path.
What
sierra_to_versioned_contract_class_v1now compiles in-process viacairo-lang-starknet-classes— the same crate thestarknet-sierra-compilebinary is a thin CLI wrapper around, already pinned in the workspace at the identical version (2.19.0-rc.2, bumped in lockstep withcairo_compiler_version.txt). Compilation parameters are unchanged: pythonic hints on,alllibfuncs list,10 * DEFAULT_MAX_BYTECODE_SIZE. TheSIERRA_COMPILERLazyLock, the subprocess plumbing, and theapollo_compile_to_casm/apollo_compile_to_casm_typesdependencies are removed;cairo-lang-starknet-classesmoves from dev-dependencies to dependencies. No new external dependencies.Result: the prover (and the replay tool) become single self-contained binaries — no sidecar to install, no version-mismatch failure mode, and no JSON/tempfile/subprocess round trip per class.
The sequencer node path (
apollo_node→SierraCompilercomponent →apollo_compile_to_casm) is untouched and keeps the subprocess model.Determinism
New test
compiled_fixture_class_matches_expected_compiled_class_hashpins the in-process output to the fixture's known compiled class hash — the hash the gateway's subprocess-based flow verifies for the same class — guarding against divergence from the compiler used elsewhere in the system.Validation
cargo test -p blockifier_reexecution— 20 passed (incl. the new determinism test), 0 failed.cargo clippy -p blockifier_reexecution --no-deps --all-targets— clean.cargo build -p starknet_transaction_prover --features stwo_proving— passes.CARGO_TOOLS_ROOT=/nonexistentandHOMEpointing at an empty dir — starts cleanly and stays up, no compiler binary anywhere on the machine path.Note on #14402
Touches the same function as #14402 (which adds startup verification of the sidecar). If this PR lands, that verification — and the sidecar itself — become unnecessary for the prover; whichever lands second needs a trivial rebase.
🤖 Generated with Claude Code