add SierraEmuSyscallBridge for cairo-native ↔ sierra-emu interop#1597
Open
avi-starkware wants to merge 1 commit into
Open
add SierraEmuSyscallBridge for cairo-native ↔ sierra-emu interop#1597avi-starkware wants to merge 1 commit into
avi-starkware wants to merge 1 commit into
Conversation
Adds an adapter type and feature flag that lets a cairo-native
StarknetSyscallHandler drive the sierra-emu virtual machine, removing
the need for downstream consumers (e.g. blockifier in starknet-libs/sequencer)
to maintain their own copy of the conversion glue between the two crates.
- New `sierra-emu` feature flag in Cargo.toml that enables `dep:sierra-emu`
and the new `sierra_emu_bridge` module. `with-trace-dump` now depends on
the new feature instead of pulling in `dep:sierra-emu` directly.
- `SierraEmuSyscallBridge<'a, H>` wraps any `&mut H` where
`H: cairo_native::starknet::StarknetSyscallHandler` and implements
`sierra_emu::starknet::StarknetSyscallHandler` for it.
- Conversion helpers (`convert_u256`, `convert_secp_*_point`,
`convert_execution_info{,_v2}`, etc.) handle the type-level translation
between the two crates' overlapping but distinct syscall surfaces.
- The Secp256k1 / Secp256r1 conversion treats `(0, 0)` as the point at
infinity when going from sierra-emu (which has no `is_infinity` flag)
to cairo-native — sierra-emu represents the identity element as `(0, 0)`
but cairo-native expects an explicit flag.
This was referenced May 10, 2026
avi-starkware
added a commit
that referenced
this pull request
May 14, 2026
Adds a public dispatch enum so a single call site can pick between the
AOT executor and the sierra-emu interpreter at runtime, without forcing
every caller to maintain its own match.
- ContractExecutor { Aot(AotContractExecutor), Emu(EmuContractInfo) },
with Emu gated on the new sierra-emu cargo feature.
- EmuContractInfo carries Arc<Program> so the program is shared across
invocations rather than cloned per call.
- ContractExecutor::run dispatches: Aot delegates to
AotContractExecutor::run; Emu constructs a sierra_emu::VirtualMachine
and runs it with the caller's syscall handler directly. No adapter is
needed: the trait is shared via the cairo-native-syscalls crate.
- Cargo: new `sierra-emu` feature (= ["dep:sierra-emu"]). The existing
`with-trace-dump` feature now activates `sierra-emu` instead of the
optional dep directly.
Companion to the bridge-free design: with cairo-native and sierra-emu
sharing one trait, the SierraEmuSyscallBridge that PR #1597 / #1607
introduced is no longer necessary.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
avi-starkware
added a commit
that referenced
this pull request
May 14, 2026
Adds a public dispatch enum so a single call site can pick between the
AOT executor and the sierra-emu interpreter at runtime, without forcing
every caller to maintain its own match.
- ContractExecutor { Aot(AotContractExecutor), Emu(EmuContractInfo) },
with Emu gated on the new sierra-emu cargo feature.
- EmuContractInfo carries Arc<Program> so the program is shared across
invocations rather than cloned per call.
- ContractExecutor::run dispatches: Aot delegates to
AotContractExecutor::run; Emu constructs a sierra_emu::VirtualMachine
and runs it with the caller's syscall handler directly. No adapter is
needed: the trait is shared via the cairo-native-syscalls crate.
- Cargo: new `sierra-emu` feature (= ["dep:sierra-emu"]). The existing
`with-trace-dump` feature now activates `sierra-emu` instead of the
optional dep directly.
Companion to the bridge-free design: with cairo-native and sierra-emu
sharing one trait, the SierraEmuSyscallBridge that PR #1597 / #1607
introduced is no longer necessary.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an adapter type and feature flag that lets a cairo-native
StarknetSyscallHandlerdrive the sierra-emu virtual machine, removing the need for downstream consumers (e.g. blockifier instarkware-libs/sequencer) to maintain their own copy of the conversion glue between the two crates.Changes
Cargo.toml— newsierra-emufeature flag that enablesdep:sierra-emuand the new module.with-trace-dumpnow depends onsierra-emuinstead of pulling indep:sierra-emudirectly.src/sierra_emu_bridge.rs—SierraEmuSyscallBridge<'a, H>wraps any&mut HwhereH: cairo_native::starknet::StarknetSyscallHandlerand implementssierra_emu::starknet::StarknetSyscallHandlerfor it.convert_u256,convert_secp_*_point,convert_execution_info{,_v2}, etc.) handle the type-level translation between the two crates' overlapping but distinct syscall surfaces.(0, 0)as the point at infinity when going from sierra-emu (which has nois_infinityflag) to cairo-native — sierra-emu represents the identity element as(0, 0)but cairo-native expects an explicit flag.Stack
This is the first of two cairo_native PRs:
SierraEmuSyscallBridgeContractExecutordispatch enum (consumes the bridge)Companion sequencer PR that drops the local sierra-emu glue and imports from cairo-native: starkware-libs/sequencer#13880.
Test plan
--features sierra-emu--features with-trace-dump(which now transitively activatessierra-emu)