Skip to content

Commit 319a6be

Browse files
avi-starkwareclaude
andcommitted
make StarknetSyscallHandler::cheatcode default return error felt
Default impl previously panicked with unimplemented!(). On the sierra-emu path, a contract that invokes the `cheatcode` libfunc against a handler that didn't override the method would unwind through the VM and abort the host. Production handlers (e.g. the blockifier's NativeSyscallHandler) don't implement cheatcode at all, so the default impl is what runs. Soft-fail with a single error felt instead, so misuse manifests as a normal syscall error rather than an unhandled panic. Test handlers that implement cheatcode override the default and are unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4960d6a commit 319a6be

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • cairo-native-syscalls/src

cairo-native-syscalls/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,11 @@ pub trait StarknetSyscallHandler {
365365
remaining_gas: &mut u64,
366366
) -> SyscallResult<Vec<Felt>>;
367367

368+
/// Test-only Starknet syscall. Production handlers don't implement it; the default
369+
/// returns a single error felt rather than panicking, so a malicious contract that
370+
/// invokes `cheatcode` against a handler that didn't override the method can't crash
371+
/// the host. Test handlers should override.
368372
fn cheatcode(&mut self, _selector: Felt, _input: &[Felt]) -> Vec<Felt> {
369-
unimplemented!();
373+
vec![Felt::from_bytes_be_slice(b"cheatcode unsupported")]
370374
}
371375
}

0 commit comments

Comments
 (0)