mirror of
https://github.com/eth-act/ere.git
synced 2026-02-19 11:54:42 -05:00
Refactor crate ere-io (#233)
This commit is contained in:
2
.github/workflows/test-common.yml
vendored
2
.github/workflows/test-common.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
run_test: true
|
||||
- crate: ere-dockerized
|
||||
run_test: false # They are run in per-zkVM workflows
|
||||
- crate: ere-io-serde
|
||||
- crate: ere-io
|
||||
run_test: true
|
||||
- crate: ere-build-utils
|
||||
run_test: true
|
||||
|
||||
134
Cargo.lock
generated
134
Cargo.lock
generated
@@ -2066,6 +2066,29 @@ version = "1.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d"
|
||||
|
||||
[[package]]
|
||||
name = "bytecheck"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0caa33a2c0edca0419d15ac723dff03f1956f7978329b1e3b5fdaaaed9d3ca8b"
|
||||
dependencies = [
|
||||
"bytecheck_derive",
|
||||
"ptr_meta",
|
||||
"rancor",
|
||||
"simdutf8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytecheck_derive"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89385e82b5d1821d2219e0b095efa2cc1f246cbf99080f3be46a1a85c0d392d9"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.23.1"
|
||||
@@ -3721,10 +3744,11 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ere-io-serde"
|
||||
name = "ere-io"
|
||||
version = "0.0.15"
|
||||
dependencies = [
|
||||
"bincode 2.0.1",
|
||||
"rkyv",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -3912,7 +3936,7 @@ dependencies = [
|
||||
"borsh",
|
||||
"ere-build-utils",
|
||||
"ere-compile-utils",
|
||||
"ere-io-serde",
|
||||
"ere-io",
|
||||
"ere-test-utils",
|
||||
"ere-zkvm-interface",
|
||||
"risc0-binfmt",
|
||||
@@ -3975,11 +3999,12 @@ dependencies = [
|
||||
name = "ere-test-utils"
|
||||
version = "0.0.15"
|
||||
dependencies = [
|
||||
"ere-io-serde",
|
||||
"ere-io",
|
||||
"ere-platform-trait",
|
||||
"ere-zkvm-interface",
|
||||
"rand 0.9.2",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
@@ -6997,6 +7022,26 @@ version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084"
|
||||
|
||||
[[package]]
|
||||
name = "munge"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e17401f259eba956ca16491461b6e8f72913a0a114e39736ce404410f915a0c"
|
||||
dependencies = [
|
||||
"munge_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "munge_macro"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4568f25ccbd45ab5d5603dc34318c1ec56b117531781260002151b8530a9f931"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nanorand"
|
||||
version = "0.7.0"
|
||||
@@ -10777,6 +10822,26 @@ dependencies = [
|
||||
"worker",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptr_meta"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b9a0cf95a1196af61d4f1cbdab967179516d9a4a4312af1f31948f8f6224a79"
|
||||
dependencies = [
|
||||
"ptr_meta_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptr_meta_derive"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7347867d0a7e1208d93b46767be83e2b8f978c3dad35f775ac8d8847551d6fe1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "puffin"
|
||||
version = "0.19.1"
|
||||
@@ -10907,6 +10972,15 @@ dependencies = [
|
||||
"nibble_vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rancor"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a063ea72381527c2a0561da9c80000ef822bdd7c3241b1cc1b12100e3df081ee"
|
||||
dependencies = [
|
||||
"ptr_meta",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@@ -11152,6 +11226,15 @@ version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rend"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cadadef317c2f20755a64d7fdc48f9e7178ee6b0e1f7fce33fa60f1d68a276e6"
|
||||
dependencies = [
|
||||
"bytecheck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.27"
|
||||
@@ -11722,7 +11805,7 @@ dependencies = [
|
||||
"field",
|
||||
"inferno",
|
||||
"memmap2",
|
||||
"object 0.35.0",
|
||||
"object 0.37.3",
|
||||
"poseidon2",
|
||||
"rand 0.9.2",
|
||||
"ringbuffer",
|
||||
@@ -11738,6 +11821,33 @@ dependencies = [
|
||||
"heapless",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35a640b26f007713818e9a9b65d34da1cf58538207b052916a83d80e43f3ffa4"
|
||||
dependencies = [
|
||||
"bytecheck",
|
||||
"hashbrown 0.15.3",
|
||||
"munge",
|
||||
"ptr_meta",
|
||||
"rancor",
|
||||
"rend",
|
||||
"rkyv_derive",
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rkyv_derive"
|
||||
version = "0.8.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd83f5f173ff41e00337d97f6572e416d022ef8a19f371817259ae960324c482"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rlp"
|
||||
version = "0.5.2"
|
||||
@@ -12398,6 +12508,16 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.11.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.221"
|
||||
@@ -12638,6 +12758,12 @@ version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "simdutf8"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "simple_asn1"
|
||||
version = "0.6.3"
|
||||
|
||||
@@ -28,7 +28,7 @@ members = [
|
||||
"crates/dockerized/compiler",
|
||||
"crates/dockerized/server",
|
||||
# Utils
|
||||
"crates/io-serde",
|
||||
"crates/io",
|
||||
"crates/build-utils",
|
||||
"crates/compile-utils",
|
||||
"crates/test-utils",
|
||||
@@ -62,7 +62,9 @@ postcard = { version = "1.0.8", default-features = false }
|
||||
prost = "0.13"
|
||||
prost-build = "0.13"
|
||||
rand = "0.9.2"
|
||||
rkyv = { version = "0.8.12", default-features = false }
|
||||
serde = { version = "1.0.219", default-features = false }
|
||||
serde_bytes = { version = "0.11.19", default-features = false }
|
||||
serde_json = "1.0.142"
|
||||
serde_yaml = "0.9.34"
|
||||
sha2 = { version = "0.10.9", default-features = false }
|
||||
@@ -162,7 +164,7 @@ ere-dockerized = { path = "crates/dockerized" }
|
||||
ere-compiler = { path = "crates/dockerized/compiler" }
|
||||
ere-server = { path = "crates/dockerized/server" }
|
||||
|
||||
ere-io-serde = { path = "crates/io-serde" }
|
||||
ere-io = { path = "crates/io" }
|
||||
ere-build-utils = { path = "crates/build-utils" }
|
||||
ere-compile-utils = { path = "crates/compile-utils" }
|
||||
ere-test-utils = { path = "crates/test-utils" }
|
||||
|
||||
@@ -351,7 +351,9 @@ mod test {
|
||||
zkVMKind,
|
||||
zkvm::{DockerizedzkVM, Error},
|
||||
};
|
||||
use ere_test_utils::{host::*, program::basic::BasicProgramInput};
|
||||
use ere_test_utils::{
|
||||
host::*, io::serde::bincode::BincodeLegacy, program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::zkvm::{ProofKind, ProverResourceType, zkVM};
|
||||
|
||||
fn zkvm(
|
||||
@@ -405,8 +407,11 @@ mod test {
|
||||
Airbender,
|
||||
Rust,
|
||||
"basic",
|
||||
[BasicProgramInput::valid().into_output_sha256()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -416,8 +421,11 @@ mod test {
|
||||
Jolt,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -427,8 +435,11 @@ mod test {
|
||||
Nexus,
|
||||
Rust,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -438,8 +449,11 @@ mod test {
|
||||
OpenVM,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid().into_output_sha256()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -449,8 +463,11 @@ mod test {
|
||||
Pico,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -460,8 +477,11 @@ mod test {
|
||||
Risc0,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -471,8 +491,11 @@ mod test {
|
||||
SP1,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -482,8 +505,11 @@ mod test {
|
||||
Ziren,
|
||||
RustCustomized,
|
||||
"basic",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -493,8 +519,11 @@ mod test {
|
||||
Zisk,
|
||||
RustCustomized,
|
||||
"basic_rust",
|
||||
[BasicProgramInput::valid()],
|
||||
[Vec::new(), BasicProgramInput::invalid().serialized_input()]
|
||||
[BasicProgram::<BincodeLegacy>::valid_test_case()],
|
||||
[
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
[package]
|
||||
name = "ere-io-serde"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
bincode = { workspace = true, features = ["alloc", "serde"] }
|
||||
serde.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -1,62 +0,0 @@
|
||||
use crate::IoSerde;
|
||||
use alloc::vec::Vec;
|
||||
use bincode::config::{Config, Configuration, Fixint, LittleEndian, NoLimit, Varint};
|
||||
use core::{
|
||||
error::Error,
|
||||
fmt::{self, Display, Formatter},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use bincode::{
|
||||
config,
|
||||
error::{DecodeError, EncodeError},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BincodeError {
|
||||
Encode(EncodeError),
|
||||
Decode(DecodeError),
|
||||
}
|
||||
|
||||
impl Display for BincodeError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Encode(err) => write!(f, "{err:?}"),
|
||||
Self::Decode(err) => write!(f, "{err:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for BincodeError {}
|
||||
|
||||
/// IO de/serialization implementation with [`bincode`].
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Bincode<O>(pub O);
|
||||
|
||||
impl Bincode<Configuration<LittleEndian, Fixint, NoLimit>> {
|
||||
/// `Bincode` with legacy configuration, same as the default of `bincode@1`.
|
||||
pub fn legacy() -> Self {
|
||||
Self(bincode::config::legacy())
|
||||
}
|
||||
}
|
||||
|
||||
impl Bincode<Configuration<LittleEndian, Varint, NoLimit>> {
|
||||
/// `Bincode` with standard configuration.
|
||||
pub fn standard() -> Self {
|
||||
Self(bincode::config::standard())
|
||||
}
|
||||
}
|
||||
|
||||
impl<O: Config> IoSerde for Bincode<O> {
|
||||
type Error = BincodeError;
|
||||
|
||||
fn serialize<T: Serialize>(&self, value: &T) -> Result<Vec<u8>, Self::Error> {
|
||||
bincode::serde::encode_to_vec(value, self.0).map_err(BincodeError::Encode)
|
||||
}
|
||||
|
||||
fn deserialize<'a, T: Deserialize<'a>>(&self, bytes: &'a [u8]) -> Result<T, Self::Error> {
|
||||
let (value, _) = bincode::serde::borrow_decode_from_slice(bytes, self.0)
|
||||
.map_err(BincodeError::Decode)?;
|
||||
Ok(value)
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
//! This crate provides IO de/serialization implementation to be shared between
|
||||
//! host and guest, if the guest is also written in Rust.
|
||||
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::error::Error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod bincode;
|
||||
|
||||
/// IO de/serialization to be shared between host and guest.
|
||||
pub trait IoSerde {
|
||||
type Error: Error;
|
||||
|
||||
fn serialize<T: Serialize>(&self, value: &T) -> Result<Vec<u8>, Self::Error>;
|
||||
|
||||
fn deserialize<'a, T: Deserialize<'a>>(&self, bytes: &'a [u8]) -> Result<T, Self::Error>;
|
||||
}
|
||||
22
crates/io/Cargo.toml
Normal file
22
crates/io/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "ere-io"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
bincode = { workspace = true, features = ["alloc", "serde"], optional = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
rkyv = { workspace = true, features = ["alloc", "bytecheck", "unaligned"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
serde = ["dep:serde"]
|
||||
bincode = ["dep:bincode", "serde"]
|
||||
rkyv = ["dep:rkyv"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
31
crates/io/src/lib.rs
Normal file
31
crates/io/src/lib.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
//! This crate provides IO de/serialization implementation to be shared between
|
||||
//! host and guest, if the guest is also written in Rust.
|
||||
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![no_std]
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::{error::Error, fmt::Debug};
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
pub mod serde;
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
pub mod rkyv;
|
||||
|
||||
/// IO de/serialization to be shared between host and guest.
|
||||
pub trait Io {
|
||||
type Input: Clone + Debug + Send + Sync;
|
||||
type Output: Clone + Debug + Send + Sync + PartialEq;
|
||||
type Error: 'static + Error + Send + Sync;
|
||||
|
||||
fn serialize_input(input: &Self::Input) -> Result<Vec<u8>, Self::Error>;
|
||||
|
||||
fn deserialize_input(bytes: &[u8]) -> Result<Self::Input, Self::Error>;
|
||||
|
||||
fn serialize_output(output: &Self::Output) -> Result<Vec<u8>, Self::Error>;
|
||||
|
||||
fn deserialize_output(bytes: &[u8]) -> Result<Self::Output, Self::Error>;
|
||||
}
|
||||
57
crates/io/src/rkyv.rs
Normal file
57
crates/io/src/rkyv.rs
Normal file
@@ -0,0 +1,57 @@
|
||||
use crate::Io;
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt::Debug, marker::PhantomData};
|
||||
use rkyv::{
|
||||
Archive, Deserialize, Serialize,
|
||||
api::high::{HighSerializer, HighValidator},
|
||||
bytecheck::CheckBytes,
|
||||
de::Pool,
|
||||
rancor::{Error, Strategy},
|
||||
ser::allocator::ArenaHandle,
|
||||
util::AlignedVec,
|
||||
};
|
||||
|
||||
pub use rkyv;
|
||||
|
||||
pub struct IoRkyv<I, O>(PhantomData<(I, O)>);
|
||||
|
||||
impl<I, O> Io for IoRkyv<I, O>
|
||||
where
|
||||
I: Clone
|
||||
+ Debug
|
||||
+ Send
|
||||
+ Sync
|
||||
+ for<'a> Serialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>
|
||||
+ Archive,
|
||||
I::Archived:
|
||||
for<'a> CheckBytes<HighValidator<'a, Error>> + Deserialize<I, Strategy<Pool, Error>>,
|
||||
O: Clone
|
||||
+ Debug
|
||||
+ Send
|
||||
+ Sync
|
||||
+ PartialEq
|
||||
+ for<'a> Serialize<HighSerializer<AlignedVec, ArenaHandle<'a>, Error>>
|
||||
+ Archive,
|
||||
O::Archived:
|
||||
for<'a> CheckBytes<HighValidator<'a, Error>> + Deserialize<O, Strategy<Pool, Error>>,
|
||||
{
|
||||
type Input = I;
|
||||
type Output = O;
|
||||
type Error = Error;
|
||||
|
||||
fn serialize_input(input: &Self::Input) -> Result<Vec<u8>, Self::Error> {
|
||||
rkyv::to_bytes(input).map(|vec| vec.to_vec())
|
||||
}
|
||||
|
||||
fn deserialize_input(bytes: &[u8]) -> Result<Self::Input, Self::Error> {
|
||||
rkyv::from_bytes(bytes)
|
||||
}
|
||||
|
||||
fn serialize_output(output: &Self::Output) -> Result<Vec<u8>, Self::Error> {
|
||||
rkyv::to_bytes(output).map(|vec| vec.to_vec())
|
||||
}
|
||||
|
||||
fn deserialize_output(bytes: &[u8]) -> Result<Self::Output, Self::Error> {
|
||||
rkyv::from_bytes(bytes)
|
||||
}
|
||||
}
|
||||
44
crates/io/src/serde.rs
Normal file
44
crates/io/src/serde.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use crate::Io;
|
||||
use alloc::vec::Vec;
|
||||
use core::{error::Error, fmt::Debug, marker::PhantomData};
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
#[cfg(feature = "bincode")]
|
||||
pub mod bincode;
|
||||
|
||||
pub trait Serde: Clone + Default + Send + Sync {
|
||||
type Error: 'static + Error + Send + Sync;
|
||||
|
||||
fn serialize<T: Serialize>(&self, value: &T) -> Result<Vec<u8>, Self::Error>;
|
||||
|
||||
fn deserialize<T: DeserializeOwned>(&self, bytes: &[u8]) -> Result<T, Self::Error>;
|
||||
}
|
||||
|
||||
pub struct IoSerde<I, O, T>(PhantomData<(I, O, T)>);
|
||||
|
||||
impl<I, O, T> Io for IoSerde<I, O, T>
|
||||
where
|
||||
I: Clone + Debug + Send + Sync + Serialize + DeserializeOwned,
|
||||
O: Clone + Debug + Send + Sync + PartialEq + Serialize + DeserializeOwned,
|
||||
T: Serde,
|
||||
{
|
||||
type Input = I;
|
||||
type Output = O;
|
||||
type Error = T::Error;
|
||||
|
||||
fn serialize_input(input: &Self::Input) -> Result<Vec<u8>, Self::Error> {
|
||||
T::default().serialize(input)
|
||||
}
|
||||
|
||||
fn deserialize_input(bytes: &[u8]) -> Result<Self::Input, Self::Error> {
|
||||
T::default().deserialize(bytes)
|
||||
}
|
||||
|
||||
fn serialize_output(output: &Self::Output) -> Result<Vec<u8>, Self::Error> {
|
||||
T::default().serialize(output)
|
||||
}
|
||||
|
||||
fn deserialize_output(bytes: &[u8]) -> Result<Self::Output, Self::Error> {
|
||||
T::default().deserialize(bytes)
|
||||
}
|
||||
}
|
||||
67
crates/io/src/serde/bincode.rs
Normal file
67
crates/io/src/serde/bincode.rs
Normal file
@@ -0,0 +1,67 @@
|
||||
use crate::serde::Serde;
|
||||
use alloc::vec::Vec;
|
||||
use bincode::config::{Config, Configuration, Fixint, LittleEndian, NoLimit, Varint};
|
||||
use core::{
|
||||
error::Error,
|
||||
fmt::{self, Debug, Display, Formatter},
|
||||
};
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
pub use bincode::{
|
||||
config,
|
||||
error::{DecodeError, EncodeError},
|
||||
};
|
||||
|
||||
pub type BincodeLegacyConfig = Configuration<LittleEndian, Fixint, NoLimit>;
|
||||
pub type BincodeLegacy = Bincode<BincodeLegacyConfig>;
|
||||
pub type BincodeStandardConfig = Configuration<LittleEndian, Varint, NoLimit>;
|
||||
pub type BincodeStandard = Bincode<BincodeStandardConfig>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BincodeError {
|
||||
Serialize(EncodeError),
|
||||
Deserialize(DecodeError),
|
||||
}
|
||||
|
||||
impl Display for BincodeError {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Serialize(err) => write!(f, "Bincode serialize error: {err:?}"),
|
||||
Self::Deserialize(err) => write!(f, "Bincode deserialize error: {err:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for BincodeError {}
|
||||
|
||||
/// IO de/serialization implementation with [`bincode`].
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct Bincode<O>(pub O);
|
||||
|
||||
impl Bincode<BincodeLegacyConfig> {
|
||||
/// `Bincode` with legacy configuration, same as the default of `bincode@1`.
|
||||
pub fn legacy() -> Self {
|
||||
Self(bincode::config::legacy())
|
||||
}
|
||||
}
|
||||
|
||||
impl Bincode<BincodeStandardConfig> {
|
||||
/// `Bincode` with standard configuration.
|
||||
pub fn standard() -> Self {
|
||||
Self(bincode::config::standard())
|
||||
}
|
||||
}
|
||||
|
||||
impl<O: Default + Send + Sync + Config> Serde for Bincode<O> {
|
||||
type Error = BincodeError;
|
||||
|
||||
fn serialize<T: Serialize>(&self, value: &T) -> Result<Vec<u8>, Self::Error> {
|
||||
bincode::serde::encode_to_vec(value, self.0).map_err(BincodeError::Serialize)
|
||||
}
|
||||
|
||||
fn deserialize<T: DeserializeOwned>(&self, bytes: &[u8]) -> Result<T, Self::Error> {
|
||||
let (value, _) =
|
||||
bincode::serde::decode_from_slice(bytes, self.0).map_err(BincodeError::Deserialize)?;
|
||||
Ok(value)
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,13 @@ license.workspace = true
|
||||
[dependencies]
|
||||
rand = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_bytes = { workspace = true, features = ["alloc"] }
|
||||
sha2.workspace = true
|
||||
|
||||
# Local dependencies
|
||||
ere-zkvm-interface = { workspace = true, optional = true }
|
||||
ere-platform-trait.workspace = true
|
||||
ere-io-serde.workspace = true
|
||||
ere-io = { workspace = true, features = ["bincode"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::program::{Program, ProgramInput};
|
||||
use ere_io_serde::IoSerde;
|
||||
use crate::program::Program;
|
||||
use core::ops::Deref;
|
||||
use ere_io::Io;
|
||||
use ere_zkvm_interface::zkvm::{ProofKind, PublicValues, zkVM};
|
||||
use sha2::Digest;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{marker::PhantomData, path::PathBuf};
|
||||
|
||||
fn workspace() -> PathBuf {
|
||||
@@ -50,48 +51,74 @@ pub trait TestCase {
|
||||
fn assert_output(&self, public_values: &[u8]);
|
||||
}
|
||||
|
||||
/// Auto-implementation [`TestCase`] for [`ProgramInput`] that can be shared
|
||||
/// between host and guest, if the guest is also written in Rust.
|
||||
impl<T: ProgramInput> TestCase for T {
|
||||
/// Wrapper for [`ProgramInput`] that implements [`TestCase`].
|
||||
pub struct ProgramTestCase<P: Program> {
|
||||
input: <P::Io as Io>::Input,
|
||||
_marker: PhantomData<P>,
|
||||
}
|
||||
|
||||
impl<P: Program> ProgramTestCase<P> {
|
||||
pub fn new(input: <P::Io as Io>::Input) -> Self {
|
||||
Self {
|
||||
input,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrap into [`OutputHashedProgramTestCase`] with [`Sha256`].
|
||||
pub fn into_output_sha256(self) -> impl TestCase {
|
||||
OutputHashedProgramTestCase::<_, Sha256>::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Program> Deref for ProgramTestCase<P> {
|
||||
type Target = <P::Io as Io>::Input;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.input
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: Program> TestCase for ProgramTestCase<P> {
|
||||
fn serialized_input(&self) -> Vec<u8> {
|
||||
T::Program::io_serde().serialize(&self.clone()).unwrap()
|
||||
P::Io::serialize_input(&self.input).unwrap()
|
||||
}
|
||||
|
||||
fn assert_output(&self, public_values: &[u8]) {
|
||||
assert_eq!(
|
||||
T::Program::compute(self.clone()),
|
||||
T::Program::io_serde().deserialize(public_values).unwrap()
|
||||
P::compute(self.input.clone()),
|
||||
P::Io::deserialize_output(public_values).unwrap()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper for [`TestCase`] that asserts output to be hashed.
|
||||
pub struct OutputHashedTestCase<T, D> {
|
||||
inner: T,
|
||||
/// Wrapper for [`ProgramTestCase`] that asserts output to be hashed.
|
||||
pub struct OutputHashedProgramTestCase<P: Program, D> {
|
||||
test_case: ProgramTestCase<P>,
|
||||
_marker: PhantomData<D>,
|
||||
}
|
||||
|
||||
impl<T, D> OutputHashedTestCase<T, D> {
|
||||
pub fn new(inner: T) -> Self {
|
||||
impl<P: Program, D> OutputHashedProgramTestCase<P, D> {
|
||||
pub fn new(test_case: ProgramTestCase<P>) -> Self {
|
||||
Self {
|
||||
inner,
|
||||
test_case,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, D> TestCase for OutputHashedTestCase<T, D>
|
||||
impl<P, D> TestCase for OutputHashedProgramTestCase<P, D>
|
||||
where
|
||||
T: ProgramInput,
|
||||
P: Program,
|
||||
D: Digest,
|
||||
{
|
||||
fn serialized_input(&self) -> Vec<u8> {
|
||||
self.inner.serialized_input()
|
||||
self.test_case.serialized_input()
|
||||
}
|
||||
|
||||
fn assert_output(&self, public_values: &[u8]) {
|
||||
let output = T::Program::compute(self.inner.clone());
|
||||
let digest = D::digest(T::Program::io_serde().serialize(&output).unwrap());
|
||||
let output = P::compute(self.test_case.clone());
|
||||
let digest = D::digest(P::Io::serialize_output(&output).unwrap());
|
||||
assert_eq!(&*digest, public_values)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,3 +7,5 @@ pub mod program;
|
||||
|
||||
#[cfg(feature = "host")]
|
||||
pub mod host;
|
||||
|
||||
pub use ere_io as io;
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
use core::fmt::Debug;
|
||||
use ere_io_serde::IoSerde;
|
||||
use ere_io::Io;
|
||||
use ere_platform_trait::Platform;
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
pub mod basic;
|
||||
|
||||
/// Program that can be ran given [`Platform`] implementation.
|
||||
pub trait Program {
|
||||
type Input: Serialize + DeserializeOwned;
|
||||
type Output: Debug + PartialEq + Serialize + DeserializeOwned;
|
||||
type Io: Io;
|
||||
|
||||
fn io_serde() -> impl IoSerde;
|
||||
|
||||
fn compute(input: Self::Input) -> Self::Output;
|
||||
fn compute(input: <Self::Io as Io>::Input) -> <Self::Io as Io>::Output;
|
||||
|
||||
fn run<P: Platform>() {
|
||||
let io_serde = Self::io_serde();
|
||||
let input = io_serde.deserialize(&P::read_whole_input()).unwrap();
|
||||
let output = io_serde.serialize(&Self::compute(input)).unwrap();
|
||||
P::write_whole_output(&output);
|
||||
let input_bytes = P::read_whole_input();
|
||||
let input = Self::Io::deserialize_input(&input_bytes).unwrap();
|
||||
let output = Self::compute(input);
|
||||
let output_bytes = Self::Io::serialize_output(&output).unwrap();
|
||||
P::write_whole_output(&output_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/// [`Program::Input`] that has [`TestCase`] auto-implemented.
|
||||
pub trait ProgramInput: Clone + Serialize {
|
||||
type Program: Program<Input = Self>;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
use crate::program::Program;
|
||||
use alloc::vec::Vec;
|
||||
use core::panic;
|
||||
use ere_io_serde::{IoSerde, bincode::Bincode};
|
||||
use core::{marker::PhantomData, panic};
|
||||
use ere_io::serde::{IoSerde, Serde, bincode::BincodeLegacy};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// The basic program takes `BasicProgramInput` as input, and computes
|
||||
/// `BasicProgramOutput` as output.
|
||||
pub struct BasicProgram;
|
||||
pub struct BasicProgram<S>(PhantomData<S>);
|
||||
|
||||
impl Program for BasicProgram {
|
||||
type Input = BasicProgramInput;
|
||||
type Output = BasicProgramOutput;
|
||||
|
||||
fn io_serde() -> impl IoSerde {
|
||||
Bincode::legacy()
|
||||
}
|
||||
impl<S> Program for BasicProgram<S>
|
||||
where
|
||||
S: Serde,
|
||||
{
|
||||
type Io = IoSerde<BasicProgramInput, BasicProgramOutput, BincodeLegacy>;
|
||||
|
||||
fn compute(input: BasicProgramInput) -> BasicProgramOutput {
|
||||
if input.should_panic {
|
||||
@@ -37,11 +35,13 @@ pub struct BasicProgramInput {
|
||||
pub b: u16,
|
||||
pub c: u32,
|
||||
pub d: u64,
|
||||
#[serde(with = "serde_bytes")]
|
||||
pub e: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BasicProgramOutput {
|
||||
#[serde(with = "serde_bytes")]
|
||||
pub e: Vec<u8>,
|
||||
pub d: u64,
|
||||
pub c: u32,
|
||||
@@ -52,44 +52,32 @@ pub struct BasicProgramOutput {
|
||||
#[cfg(feature = "host")]
|
||||
mod host {
|
||||
use crate::{
|
||||
host::{OutputHashedTestCase, TestCase},
|
||||
program::{
|
||||
ProgramInput,
|
||||
basic::{BasicProgram, BasicProgramInput},
|
||||
},
|
||||
host::ProgramTestCase,
|
||||
program::basic::{BasicProgram, BasicProgramInput},
|
||||
};
|
||||
use ere_io::serde::Serde;
|
||||
use rand::{Rng, rng};
|
||||
use sha2::Sha256;
|
||||
|
||||
impl ProgramInput for BasicProgramInput {
|
||||
type Program = BasicProgram;
|
||||
}
|
||||
|
||||
impl BasicProgramInput {
|
||||
pub fn valid() -> Self {
|
||||
impl<S: Serde> BasicProgram<S> {
|
||||
pub fn valid_test_case() -> ProgramTestCase<Self> {
|
||||
let mut rng = rng();
|
||||
let n = rng.random_range(16..32);
|
||||
Self {
|
||||
ProgramTestCase::new(BasicProgramInput {
|
||||
should_panic: false,
|
||||
a: rng.random(),
|
||||
b: rng.random(),
|
||||
c: rng.random(),
|
||||
d: rng.random(),
|
||||
e: rng.random_iter().take(n).collect(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Invalid input that causes panic in guest program.
|
||||
pub fn invalid() -> Self {
|
||||
Self {
|
||||
pub fn invalid_test_case() -> ProgramTestCase<Self> {
|
||||
ProgramTestCase::new(BasicProgramInput {
|
||||
should_panic: true,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrap into [`OutputHashedTestCase`] with [`Sha256`].
|
||||
pub fn into_output_sha256(self) -> impl TestCase {
|
||||
OutputHashedTestCase::<_, Sha256>::new(self)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,27 +25,32 @@ pub trait Platform {
|
||||
|
||||
/// Returns the current cycle count.
|
||||
///
|
||||
/// Note that this function will return `None` if the platform doesn't support.
|
||||
fn cycle_count() -> Option<u64> {
|
||||
None
|
||||
/// Note that this function will return `0` if the platform doesn't support.
|
||||
#[inline]
|
||||
fn cycle_count() -> u64 {
|
||||
0
|
||||
}
|
||||
|
||||
/// Enters a cycle scope of `name`.
|
||||
///
|
||||
/// Note that this function will be a no-op if the platform doesn't support.
|
||||
#[inline]
|
||||
fn cycle_scope_start(_name: &str) {}
|
||||
|
||||
/// Exits a cycle scope of `name`.
|
||||
///
|
||||
/// Note that this function will be a no-op if the platform doesn't support.
|
||||
#[inline]
|
||||
fn cycle_scope_end(_name: &str) {}
|
||||
|
||||
/// Runs a given function `f` within a cycle scope `name`.
|
||||
///
|
||||
/// Note that this function will be a no-op if the platform doesn't support.
|
||||
fn cycle_scope(name: &str, f: impl Fn()) {
|
||||
#[inline]
|
||||
fn cycle_scope<T>(name: &str, f: impl FnOnce() -> T) -> T {
|
||||
Self::cycle_scope_start(name);
|
||||
f();
|
||||
let t = f();
|
||||
Self::cycle_scope_end(name);
|
||||
t
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv32ima, program::AirbenderProgram, zkvm::EreAirbender};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -131,16 +132,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreAirbender::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid().into_output_sha256();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreAirbender::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -150,16 +154,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreAirbender::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid().into_output_sha256();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreAirbender::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv64imacCustomized, program::JoltProgram, zkvm::EreJolt};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -133,16 +134,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreJolt::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreJolt::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -154,18 +158,21 @@ mod tests {
|
||||
|
||||
let _guard = PROVE_LOCK.lock().unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreJolt::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let _guard = PROVE_LOCK.lock().unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_input() {
|
||||
fn test_invalid_test_case() {
|
||||
let program = load_miden_program("add");
|
||||
let zkvm = EreMiden::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
|
||||
@@ -160,7 +160,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv32i, program::NexusProgram, zkvm::EreNexus};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -184,16 +185,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreNexus::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreNexus::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -203,16 +207,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreNexus::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreNexus::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +250,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv32imaCustomized, program::OpenVMProgram, zkvm::EreOpenVM};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -274,16 +275,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreOpenVM::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid().into_output_sha256();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreOpenVM::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -293,16 +297,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreOpenVM::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid().into_output_sha256();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case().into_output_sha256();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreOpenVM::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv32imaCustomized, program::PicoProgram, zkvm::ErePico};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -207,16 +208,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = ErePico::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = ErePico::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -226,16 +230,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = ErePico::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = ErePico::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ ere-compile-utils = { workspace = true, optional = true }
|
||||
ere-zkvm-interface.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
ere-io-serde.workspace = true
|
||||
ere-io.workspace = true
|
||||
ere-test-utils = { workspace = true, features = ["host"] }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
@@ -37,7 +37,7 @@ impl<H: OutputHasher> Platform for Risc0Platform<H> {
|
||||
risc0_zkvm::guest::env::stdout().write_slice(message.as_bytes());
|
||||
}
|
||||
|
||||
fn cycle_count() -> Option<u64> {
|
||||
Some(risc0_zkvm::guest::env::cycle_count())
|
||||
fn cycle_count() -> u64 {
|
||||
risc0_zkvm::guest::env::cycle_count()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,9 +218,10 @@ impl zkVMProgramDigest for EreRisc0 {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{compiler::RustRv32imaCustomized, program::Risc0Program, zkvm::EreRisc0};
|
||||
use ere_io::serde::bincode::BincodeLegacy;
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -244,16 +245,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreRisc0::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreRisc0::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -263,16 +267,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreRisc0::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreRisc0::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv32imaCustomized, program::SP1Program, zkvm::EreSP1};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -204,16 +205,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreSP1::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreSP1::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -223,16 +227,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreSP1::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreSP1::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -254,7 +261,7 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreSP1::new(program, ProverResourceType::Network(network_config)).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,8 @@ mod tests {
|
||||
use crate::{compiler::RustMips32r2Customized, program::ZirenProgram, zkvm::EreZiren};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -170,16 +171,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZiren::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZiren::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -189,16 +193,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZiren::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZiren::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,8 @@ mod tests {
|
||||
use crate::{compiler::RustRv64imaCustomized, program::ZiskProgram, zkvm::EreZisk};
|
||||
use ere_test_utils::{
|
||||
host::{TestCase, run_zkvm_execute, run_zkvm_prove, testing_guest_directory},
|
||||
program::basic::BasicProgramInput,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::basic::BasicProgram,
|
||||
};
|
||||
use ere_zkvm_interface::{
|
||||
compiler::Compiler,
|
||||
@@ -170,16 +171,19 @@ mod tests {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZisk::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_execute(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_execute_invalid_input() {
|
||||
fn test_execute_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZisk::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.execute(&input).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -191,18 +195,21 @@ mod tests {
|
||||
|
||||
let _guard = PROVE_LOCK.lock().unwrap();
|
||||
|
||||
let test_case = BasicProgramInput::valid();
|
||||
let test_case = BasicProgram::<BincodeLegacy>::valid_test_case();
|
||||
run_zkvm_prove(&zkvm, &test_case);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prove_invalid_input() {
|
||||
fn test_prove_invalid_test_case() {
|
||||
let program = basic_program();
|
||||
let zkvm = EreZisk::new(program, ProverResourceType::Cpu).unwrap();
|
||||
|
||||
let _guard = PROVE_LOCK.lock().unwrap();
|
||||
|
||||
for input in [Vec::new(), BasicProgramInput::invalid().serialized_input()] {
|
||||
for input in [
|
||||
Vec::new(),
|
||||
BasicProgram::<BincodeLegacy>::invalid_test_case().serialized_input(),
|
||||
] {
|
||||
zkvm.prove(&input, ProofKind::default()).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
use ere_platform_airbender::AirbenderPlatform;
|
||||
use ere_test_utils::{
|
||||
guest::Sha256,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
@@ -15,5 +16,5 @@ mod airbender_rt;
|
||||
|
||||
#[inline(never)]
|
||||
fn main() {
|
||||
BasicProgram::run::<AirbenderPlatform<Sha256>>();
|
||||
BasicProgram::<BincodeLegacy>::run::<AirbenderPlatform<Sha256>>();
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
extern crate alloc;
|
||||
|
||||
use ere_platform_jolt::{jolt, JoltPlatform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
#[jolt::provable(guest_only)]
|
||||
fn main() {
|
||||
BasicProgram::run::<JoltPlatform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<JoltPlatform>();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#![cfg_attr(target_arch = "riscv32", no_std, no_main)]
|
||||
|
||||
use ere_platform_nexus::{nexus_rt, NexusPlatform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
#[nexus_rt::main]
|
||||
fn main() {
|
||||
BasicProgram::run::<NexusPlatform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<NexusPlatform>();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use ere_platform_openvm::OpenVMPlatform;
|
||||
use ere_test_utils::{
|
||||
guest::Sha256,
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
BasicProgram::run::<OpenVMPlatform<Sha256>>();
|
||||
BasicProgram::<BincodeLegacy>::run::<OpenVMPlatform<Sha256>>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#![no_main]
|
||||
|
||||
use ere_platform_pico::{pico_sdk, PicoPlatform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
pico_sdk::entrypoint!(main);
|
||||
|
||||
pub fn main() {
|
||||
BasicProgram::run::<PicoPlatform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<PicoPlatform>();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use ere_platform_risc0::Risc0Platform;
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
BasicProgram::run::<Risc0Platform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<Risc0Platform>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#![no_main]
|
||||
|
||||
use ere_platform_sp1::{sp1_zkvm, SP1Platform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
sp1_zkvm::entrypoint!(main);
|
||||
|
||||
pub fn main() {
|
||||
BasicProgram::run::<SP1Platform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<SP1Platform>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#![no_main]
|
||||
|
||||
use ere_platform_ziren::{zkm_zkvm, ZirenPlatform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
zkm_zkvm::entrypoint!(main);
|
||||
|
||||
pub fn main() {
|
||||
BasicProgram::run::<ZirenPlatform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<ZirenPlatform>();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#![no_main]
|
||||
|
||||
use ere_platform_zisk::{ziskos, ZiskPlatform};
|
||||
use ere_test_utils::program::{basic::BasicProgram, Program};
|
||||
use ere_test_utils::{
|
||||
io::serde::bincode::BincodeLegacy,
|
||||
program::{basic::BasicProgram, Program},
|
||||
};
|
||||
|
||||
ziskos::entrypoint!(main);
|
||||
|
||||
fn main() {
|
||||
BasicProgram::run::<ZiskPlatform>();
|
||||
BasicProgram::<BincodeLegacy>::run::<ZiskPlatform>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user