diff --git a/core/src/runtime/syscall.rs b/core/src/runtime/syscall.rs index 513ed2a20..af579a2bb 100644 --- a/core/src/runtime/syscall.rs +++ b/core/src/runtime/syscall.rs @@ -118,6 +118,10 @@ pub enum SyscallCode { /// Execute the `MEMCPY_64` precompile. MEMCPY_64 = 0x00_00_01_31, + + /// Just a debug marker + #[cfg(feature = "debug-syscall")] + DEBUG = 0x00_00_00_FF, } impl SyscallCode { @@ -152,6 +156,8 @@ impl SyscallCode { 0x00_01_01_21 => SyscallCode::BN254_SCALAR_MAC, 0x00_00_01_30 => SyscallCode::MEMCPY_32, 0x00_00_01_31 => SyscallCode::MEMCPY_64, + #[cfg(feature = "debug-syscall")] + 0x00_00_00_FF => SyscallCode::DEBUG, _ => panic!("invalid syscall number: {}", value), } } @@ -383,6 +389,12 @@ pub fn default_syscall_map() -> HashMap> { Arc::new(MemCopyChip::::new()), ); + #[cfg(feature = "debug-syscall")] + syscall_map.insert( + SyscallCode::DEBUG, + Arc::new(crate::syscall::SyscallDebug::new()), + ); + syscall_map } @@ -485,6 +497,8 @@ mod tests { SyscallCode::BN254_SCALAR_MAC => { assert_eq!(code as u32, sp1_zkvm::syscalls::BN254_SCALAR_MAC) } + #[cfg(feature = "debug-syscall")] + SyscallCode::DEBUG => assert_eq!(code as u32, sp1_zkvm::syscalls::DEBUG), } } } diff --git a/core/src/syscall/debug.rs b/core/src/syscall/debug.rs new file mode 100644 index 000000000..f61b9f829 --- /dev/null +++ b/core/src/syscall/debug.rs @@ -0,0 +1,15 @@ +use crate::runtime::{Syscall, SyscallContext}; + +pub struct SyscallDebug; + +impl SyscallDebug { + pub const fn new() -> Self { + Self + } +} + +impl Syscall for SyscallDebug { + fn execute(&self, _: &mut SyscallContext, _: u32, _: u32) -> Option { + None + } +} diff --git a/core/src/syscall/mod.rs b/core/src/syscall/mod.rs index 4b106fbbc..11a3c9ad9 100644 --- a/core/src/syscall/mod.rs +++ b/core/src/syscall/mod.rs @@ -1,4 +1,6 @@ mod commit; +#[cfg(feature = "debug-syscall")] +mod debug; mod halt; mod hint; mod memcpy; @@ -8,6 +10,8 @@ mod verify; mod write; pub use commit::*; +#[cfg(feature = "debug-syscall")] +pub use debug::*; pub use halt::*; pub use hint::*; pub use memcpy::*;