Skip to content

Commit 4e80562

Browse files
avi-starkwareclaude
andcommitted
extract shared cairo-starknet-syscalls crate
Both cairo-native and sierra-emu now re-export the StarknetSyscallHandler trait and supporting types (U256, Block/Tx/Execution Info v{1,2,3}, ResourceBounds, Secp256{k1,r1}Point) from the new `cairo-starknet-syscalls` crate. The crate is workspace-local at the top level (sibling to `test_utils/`). The two crates' types are now nominally identical, so a single handler impl can drive both runtimes without an adapter / bridge. Notes: - `cairo-starknet-syscalls` rather than `cairo-native-syscalls`: the crate's content doesn't depend on cairo-native semantically; the cairo-native prefix would imply ownership it doesn't have. - StubSyscallHandler's `unimplemented!()` stubs now carry a one-line rationale each (deploy needs constructor execution, call_contract needs address-to-class resolution, send_message_to_l1 needs an L1 queue, etc.), plus a scope doc-comment on the type itself. - sierra-emu's previous inherent into_value/from_value methods (which depend on sierra-emu's `Value` enum and can't follow the moved types) become free functions in the new sub-module `sierra_emu::starknet::value_conv`, each with a doc comment. - `cheatcode` trait method's default impl returns an error felt instead of panicking with unimplemented!(). On the sierra-emu path, a contract invoking the cheatcode libfunc against a handler that didn't override it would otherwise unwind through the VM and abort the host; production handlers (e.g. blockifier's NativeSyscallHandler) don't implement cheatcode, so the default is what runs. - The per-type files under debug_utils/sierra-emu/src/starknet/* are deleted now that the struct definitions live in the shared crate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 26d9249 commit 4e80562

21 files changed

Lines changed: 692 additions & 901 deletions

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ exclude = [
33
"debug_utils/casm-data-flow",
44
]
55
members = [
6+
"cairo-starknet-syscalls",
67
"debug_utils",
78
"debug_utils/sierra-emu",
89
"debug_utils/cairo-native-stress",
@@ -53,6 +54,7 @@ cairo-lang-test-runner = "~2.17.0-rc.4"
5354
cairo-lang-utils = "~2.17.0-rc.4"
5455
cairo-native-bin-utils.path = "binaries/cairo-native-bin-utils"
5556
cairo-native = { path = ".", version = "0.9.0-rc.6" }
57+
cairo-starknet-syscalls = { path = "cairo-starknet-syscalls", version = "0.9.0-rc.6" }
5658
clap = "4.5.23"
5759
colored = "2.1.0"
5860
criterion = "0.5.1"
@@ -128,6 +130,7 @@ testing = ["dep:cairo-lang-compiler", "dep:cairo-lang-filesystem"]
128130
[dependencies]
129131
aquamarine.workspace = true
130132
bumpalo.workspace = true
133+
cairo-starknet-syscalls.workspace = true
131134
cairo-lang-compiler = { workspace = true, optional = true }
132135
cairo-lang-filesystem = { workspace = true, optional = true }
133136
cairo-lang-lowering.workspace = true

cairo-starknet-syscalls/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "cairo-starknet-syscalls"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
7+
description = "Shared StarknetSyscallHandler trait and supporting types for cairo-native and sierra-emu"
8+
9+
[dependencies]
10+
serde = { workspace = true, features = ["derive"] }
11+
starknet-types-core = { workspace = true, features = ["std", "serde", "num-traits"] }

0 commit comments

Comments
 (0)