Skip to content

Commit

Permalink
debug marker
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsing committed Jun 14, 2024
1 parent c7d0a5e commit dac67ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/src/runtime/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
}
}
Expand Down Expand Up @@ -383,6 +389,12 @@ pub fn default_syscall_map() -> HashMap<SyscallCode, Arc<dyn Syscall>> {
Arc::new(MemCopyChip::<U16, U64>::new()),
);

#[cfg(feature = "debug-syscall")]
syscall_map.insert(
SyscallCode::DEBUG,
Arc::new(crate::syscall::SyscallDebug::new()),
);

syscall_map
}

Expand Down Expand Up @@ -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),
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions core/src/syscall/debug.rs
Original file line number Diff line number Diff line change
@@ -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<u32> {
None
}
}
4 changes: 4 additions & 0 deletions core/src/syscall/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
mod commit;
#[cfg(feature = "debug-syscall")]
mod debug;
mod halt;
mod hint;
mod memcpy;
Expand All @@ -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::*;
Expand Down

0 comments on commit dac67ae

Please sign in to comment.