Skip to content

Commit 3b3e5af

Browse files
avi-starkwareclaude
andcommitted
document StubSyscallHandler stubs with rationale per reviewer
Per @orizi: each `unimplemented!()` in StubSyscallHandler should say *why* it's not implemented. Adds: - A scope doc-comment on the type explaining what is and isn't modeled. - A one-line rationale on each stub (deploy needs constructor execution, call_contract needs address-to-class resolution, etc.). No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 611e33a commit 3b3e5af

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

debug_utils/sierra-emu/src/starknet.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ use starknet_types_core::felt::Felt;
1717

1818
pub mod value_conv;
1919

20-
/// A (somewhat) usable implementation of the starknet syscall handler trait.
20+
/// A minimal in-memory implementation of [`StarknetSyscallHandler`] for tests and
21+
/// debug-runner harnesses. Storage / events / execution info are modeled; syscalls
22+
/// that would require contract-class lookups, deployment, cross-call routing, or
23+
/// real cryptography (other than secp256k1/r1 arithmetic) panic via `unimplemented!()`.
24+
/// Tests that need those should drive sierra-emu through a richer handler (e.g.
25+
/// blockifier's `NativeSyscallHandler`).
2126
///
22-
/// Currently gas is not deducted.
27+
/// Gas is not deducted by this stub.
2328
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
2429
pub struct StubSyscallHandler {
2530
pub storage: BTreeMap<(u32, Felt), Felt>,
@@ -150,10 +155,12 @@ impl StarknetSyscallHandler for StubSyscallHandler {
150155
_deploy_from_zero: bool,
151156
_remaining_gas: &mut u64,
152157
) -> SyscallResult<(Felt, Vec<Felt>)> {
158+
// Deployment requires constructor execution, which the stub doesn't model.
153159
unimplemented!()
154160
}
155161

156162
fn replace_class(&mut self, _class_hash: Felt, _remaining_gas: &mut u64) -> SyscallResult<()> {
163+
// Class replacement updates a registry the stub doesn't track.
157164
unimplemented!()
158165
}
159166

@@ -164,6 +171,7 @@ impl StarknetSyscallHandler for StubSyscallHandler {
164171
_calldata: &[Felt],
165172
_remaining_gas: &mut u64,
166173
) -> SyscallResult<Vec<Felt>> {
174+
// Resolving the target function requires class-hash lookup the stub doesn't model.
167175
unimplemented!()
168176
}
169177

@@ -174,6 +182,7 @@ impl StarknetSyscallHandler for StubSyscallHandler {
174182
_calldata: &[Felt],
175183
_remaining_gas: &mut u64,
176184
) -> SyscallResult<Vec<Felt>> {
185+
// Cross-contract calls require address → class-hash → function resolution.
177186
unimplemented!()
178187
}
179188

@@ -220,6 +229,7 @@ impl StarknetSyscallHandler for StubSyscallHandler {
220229
_payload: &[Felt],
221230
_remaining_gas: &mut u64,
222231
) -> SyscallResult<()> {
232+
// L1 message queue isn't modeled — extend ContractLogs if a test needs it.
223233
unimplemented!()
224234
}
225235

0 commit comments

Comments
 (0)