add ContractExecutor dispatch enum (Aot + Emu)#1608
Open
avi-starkware wants to merge 1 commit into
Open
Conversation
Adds a public dispatch enum that lets a single call site choose between
the AOT executor and the sierra-emu interpreter at runtime, without
forcing every caller to maintain its own match.
- `pub enum ContractExecutor { Aot(AotContractExecutor), Emu(EmuContractInfo) }`,
with `Emu` gated on the `sierra-emu` feature added in the previous PR.
- `From` impls for both variants.
- `ContractExecutor::run` dispatches: the `Aot` arm calls
`AotContractExecutor::run` directly; the `Emu` arm constructs a
`sierra_emu::VirtualMachine`, wraps the cairo-native syscall handler in
`SierraEmuSyscallBridge`, and converts the result.
- `EmuContractInfo` carries `Arc<Program>` so the program is shared across
invocations rather than cloned per call.
This is the same dispatch shape that downstream consumers (e.g. the
blockifier in starkware-libs/sequencer) currently maintain locally; with
this PR they can drop their copy and import `cairo_native::ContractExecutor`.
3 tasks
|
❌ Code is not formatted! Please run |
This was referenced May 10, 2026
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 a public dispatch enum that lets a single call site choose between the AOT executor and the sierra-emu interpreter at runtime, without forcing every caller to maintain its own match.
Important
Stacked on top of #1607 (SierraEmuSyscallBridge). Merge #1607 first; the diff for this PR will then narrow to just the new
contract_executormodule.Changes
src/executor/contract_executor.rs— new module:pub enum ContractExecutor { Aot(AotContractExecutor), Emu(EmuContractInfo) }, withEmugated on thesierra-emufeature added in add SierraEmuSyscallBridge for cairo-native ↔ sierra-emu interop #1607.Fromimpls for both variants.ContractExecutor::rundispatches: theAotarm callsAotContractExecutor::rundirectly; theEmuarm constructs asierra_emu::VirtualMachine, wraps the cairo-native syscall handler inSierraEmuSyscallBridge, and converts the result.EmuContractInfocarriesArc<Program>so the program is shared across invocations rather than cloned per call.Test plan
--features sierra-emuContext
This is the dispatch shape that downstream consumers (e.g. the blockifier in
starkware-libs/sequencer) currently maintain locally; with this PR they can drop their copy and importcairo_native::ContractExecutor.