pub trait Syscall: Send + Sync {
// Required method
fn execute(
&self,
ctx: &mut SyscallContext<'_, '_>,
syscall_code: SyscallCode,
arg1: u32,
arg2: u32,
) -> Option<u32>;
// Provided method
fn num_extra_cycles(&self) -> u32 { ... }
}Expand description
A system call in the SP1 RISC-V zkVM.
This trait implements methods needed to execute a system call inside the crate::Executor.
Required Methods§
Sourcefn execute(
&self,
ctx: &mut SyscallContext<'_, '_>,
syscall_code: SyscallCode,
arg1: u32,
arg2: u32,
) -> Option<u32>
fn execute( &self, ctx: &mut SyscallContext<'_, '_>, syscall_code: SyscallCode, arg1: u32, arg2: u32, ) -> Option<u32>
Executes the syscall.
Returns the resulting value of register a0. arg1 and arg2 are the values in registers
X10 and X11, respectively. While not a hard requirement, the convention is that the return
value is only for system calls such as HALT. Most precompiles use arg1 and arg2 to
denote the addresses of the input data, and write the result to the memory at arg1.
Provided Methods§
Sourcefn num_extra_cycles(&self) -> u32
fn num_extra_cycles(&self) -> u32
The number of extra cycles that the syscall takes to execute.
Unless this syscall is complex and requires many cycles, this should be zero.