Skip to content

blockifier: add sierra-emu execution behind feature flag#13543

Open
avi-starkware wants to merge 1 commit intoavi/blockifier/contract-executor-abstractionfrom
avi/blockifier/sierra-emu-integration
Open

blockifier: add sierra-emu execution behind feature flag#13543
avi-starkware wants to merge 1 commit intoavi/blockifier/contract-executor-abstractionfrom
avi/blockifier/sierra-emu-integration

Conversation

@avi-starkware
Copy link
Copy Markdown
Collaborator

@avi-starkware avi-starkware commented Mar 26, 2026

Adds sierra-emu as an alternative execution backend, gated behind the
`sierra-emu` feature flag. Also adds `with-trace-dump` and
`with-libfunc-profiling` feature flags for execution tracing and
profiling support.

When no new flags are enabled, behavior is identical to upstream.


Note

Medium Risk
Execution-path changes and new unsafe/IO-based instrumentation are introduced, but they are gated behind feature flags so default behavior should remain unchanged. Risk is mainly in correctness/compatibility when enabling sierra-emu, with-trace-dump, or with-libfunc-profiling.

Overview
Adds an alternative contract execution backend in blockifier behind the sierra-emu feature flag by extending ContractExecutor to run via sierra-emu::VirtualMachine and wiring a syscall-handler adapter plus type conversions.

Introduces optional instrumentation features: with-trace-dump (writes execution traces to traces/native or traces/emu) and with-libfunc-profiling (collects libfunc profiles into a global LIBFUNC_PROFILES_MAP keyed by tx hash), enabled by using an AotWithProgram executor variant.

Updates workspace/crate manifests and lockfile to add the sierra-emu dependency and related transitive crypto deps, and adds NativeCompiledClassV1::new_from_executor to support constructing compiled classes from the new executor variants.

Reviewed by Cursor Bugbot for commit f83e2b7. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Collaborator Author

avi-starkware commented Mar 26, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@avi-starkware avi-starkware marked this pull request as ready for review March 26, 2026 17:23
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

y: convert_from_u256(x.y),
is_infinity: false,
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hardcoded is_infinity: false loses point-at-infinity state

Medium Severity

The convert_from_secp_256_k1_point and convert_from_secp_256_r1_point functions hardcode is_infinity: false when converting from sierra-emu to cairo-native point types. Since sierra-emu's point types only have x and y fields (no infinity flag), the point at infinity is represented as (0, 0). When this is converted back to a cairo_native point with is_infinity: false, the downstream ark-ec operations will treat it as the literal finite point (0, 0) — which is not on the secp256k1/r1 curves — rather than the identity element. This causes incorrect results for elliptic curve add and mul operations involving the point at infinity.

Additional Locations (1)
Fix in Cursor Fix in Web

@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 350d48a to 3816a9e Compare March 26, 2026 17:37
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from 103c31b to bc8a9d8 Compare March 26, 2026 17:37
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 3816a9e to 8470659 Compare March 26, 2026 17:45
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from bc8a9d8 to 830c7a4 Compare March 26, 2026 17:45
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 8470659 to efa9bd7 Compare March 26, 2026 19:16
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from 830c7a4 to bd48103 Compare March 26, 2026 19:16
Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

Are you sure this must be in our repo?

@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on avi-starkware, noaov1, and TomerStarkware).

@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from bd48103 to b327019 Compare April 6, 2026 16:31
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from efa9bd7 to 05d7201 Compare April 6, 2026 16:31
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from b327019 to e40fc15 Compare April 6, 2026 20:32
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch 3 times, most recently from f16bb25 to f83e2b7 Compare April 8, 2026 05:04
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from e40fc15 to 992d84c Compare April 8, 2026 05:05
Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment.
Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on avi-starkware, noaov1, and TomerStarkware).


crates/blockifier/src/execution/native/executor.rs line 1 at r3 (raw file):

#[cfg(feature = "with-trace-dump")]

I think that this logic could be implemented on Native repo. Please try this approach.

@avi-starkware avi-starkware changed the base branch from avi/blockifier/contract-executor-abstraction to graphite-base/13543 April 14, 2026 10:59
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from f83e2b7 to 0a80afe Compare April 14, 2026 10:59
@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

PR Summary

Medium Risk
Adds new execution backends and syscall bridging code in blockifier (plus optional trace-dump instrumentation), which could change contract execution behavior or introduce runtime panics when the new feature flags are enabled; default behavior remains unchanged when flags are off.

Overview
Introduces an alternative contract execution path in blockifier behind the new sierra-emu feature flag, extending ContractExecutor to run via sierra-emu and wiring a syscall-handler adapter plus type conversions to reuse the existing native syscall implementation.

Adds optional trace dumping via with-trace-dump (for both AOT and emulated execution) that writes per-run JSON traces (and Sierra sources for emu) under traces/, and updates workspace/crate dependencies and features to include sierra-emu (plus its transitive lockfile changes).

Reviewed by Cursor Bugbot for commit db24055. Bugbot is set up for automated code reviews on this repo. Configure here.

@avi-starkware avi-starkware changed the base branch from graphite-base/13543 to avi/blockifier/libfunc-profiling April 14, 2026 11:00
@avi-starkware avi-starkware force-pushed the avi/blockifier/libfunc-profiling branch from 6a272ae to ceacfac Compare April 14, 2026 11:06
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 0a80afe to 09dda81 Compare April 14, 2026 11:06
@avi-starkware avi-starkware force-pushed the avi/blockifier/libfunc-profiling branch from ceacfac to eab2995 Compare April 14, 2026 11:33
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 09dda81 to 7d75d71 Compare April 14, 2026 11:33
@avi-starkware avi-starkware changed the base branch from avi/blockifier/libfunc-profiling to graphite-base/13543 April 14, 2026 12:36
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 7d75d71 to 5be30be Compare April 14, 2026 12:37
@avi-starkware avi-starkware changed the base branch from graphite-base/13543 to avi/blockifier/contract-executor-abstraction April 14, 2026 12:37
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from 2628a2d to eb1a633 Compare April 14, 2026 12:42
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 5be30be to 73734ae Compare April 14, 2026 12:42
Adds sierra-emu as an alternative execution backend, gated behind the
\`sierra-emu\` feature flag. Also adds \`with-trace-dump\` and
\`with-libfunc-profiling\` feature flags for execution tracing and
profiling support.

When no new flags are enabled, behavior is identical to upstream.
@avi-starkware avi-starkware force-pushed the avi/blockifier/sierra-emu-integration branch from 73734ae to db24055 Compare April 19, 2026 09:29
@avi-starkware avi-starkware force-pushed the avi/blockifier/contract-executor-abstraction branch from eb1a633 to db5d4f9 Compare April 19, 2026 09:29
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.

3 participants