Skip to content

Commit

Permalink
feat: add zkvm target for io (#394)
Browse files Browse the repository at this point in the history
* recreate old zkvm io

* lint
  • Loading branch information
zobront authored Jul 23, 2024
1 parent af67350 commit 5c30c4c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/common/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ cfg_if! {
} else if #[cfg(target_arch = "riscv64")] {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `riscv64` target architecture."]
pub type ClientIO = crate::asterisc::io::AsteriscIO;
} else if #[cfg(target_os = "zkvm")] {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `SP1` target architecture."]
pub type ClientIO = crate::zkvm::io::ZkvmIO;
} else {
#[doc = "Concrete implementation of the [BasicKernelInterface] trait for the `native` target architecture."]
pub type ClientIO = native_io::NativeIO;
Expand Down Expand Up @@ -54,7 +57,7 @@ pub fn exit(code: usize) -> ! {
ClientIO::exit(code)
}

#[cfg(not(any(target_arch = "mips", target_arch = "riscv64")))]
#[cfg(not(any(target_arch = "mips", target_arch = "riscv64", target_os = "zkvm")))]
mod native_io {
extern crate std;

Expand Down
3 changes: 3 additions & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ pub(crate) mod cannon;

#[cfg(target_arch = "riscv64")]
pub(crate) mod asterisc;

#[cfg(target_os = "zkvm")]
pub(crate) mod zkvm;
20 changes: 20 additions & 0 deletions crates/common/src/zkvm/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::{BasicKernelInterface, FileDescriptor};
use anyhow::Result;

/// Concrete implementation of the [`KernelIO`] trait for the `SP1` target architecture.
#[derive(Debug)]
pub struct ZkvmIO;

impl BasicKernelInterface for ZkvmIO {
fn write(_fd: FileDescriptor, _buf: &[u8]) -> Result<usize> {
unimplemented!();
}

fn read(_fd: FileDescriptor, _buf: &mut [u8]) -> Result<usize> {
unimplemented!();
}

fn exit(_code: usize) -> ! {
unimplemented!();
}
}
3 changes: 3 additions & 0 deletions crates/common/src/zkvm/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! This module contains raw syscall bindings for the `ZKVM` compilation context.

pub(crate) mod io;

0 comments on commit 5c30c4c

Please sign in to comment.