Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zkvm target for io #394

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading