aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-03-21 13:04:30 +0200
committerKamen Mladenov <kamen@syndamia.com>2025-04-04 11:03:00 +0300
commite7018851c4b5c44c7e6b7e907ffc186b1da5c9f4 (patch)
treeaf4aad265dc10a5a6973c9b8f7e76c30686bafa6
parent023070de2dde4df9b809cf04ff09ab1a3af3e01c (diff)
downloadzkVMs-benchmarks-e7018851c4b5c44c7e6b7e907ffc186b1da5c9f4.tar
zkVMs-benchmarks-e7018851c4b5c44c7e6b7e907ffc186b1da5c9f4.tar.gz
zkVMs-benchmarks-e7018851c4b5c44c7e6b7e907ffc186b1da5c9f4.zip
feat(zkvms/nexus): Update SDK usage
Update according to their new methods.
-rw-r--r--zkvms/nexus/guest/Cargo.toml2
-rw-r--r--zkvms/nexus/guest/guest.ld28
-rw-r--r--zkvms/nexus/guest/src/main.rs2
-rw-r--r--zkvms/nexus/host/Cargo.toml2
-rw-r--r--zkvms/nexus/host/src/main.rs46
-rw-r--r--zkvms/nexus/wrapper_macro/src/lib.rs17
6 files changed, 30 insertions, 67 deletions
diff --git a/zkvms/nexus/guest/Cargo.toml b/zkvms/nexus/guest/Cargo.toml
index 9bfbf7c..de7f745 100644
--- a/zkvms/nexus/guest/Cargo.toml
+++ b/zkvms/nexus/guest/Cargo.toml
@@ -5,7 +5,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-nexus-rt = { path = "/nix/store/crj1vza7idyckr20y72ai3cv2fkc0ia8-Nexus-zkVM-unstable-2025-03-11/runtime" }
+nexus-rt = { path = "/nix/store/63pzywhap3cxlqf74wjdwxxc66w7f29w-Nexus-zkVM-unstable-2025-03-11/runtime" }
postcard = { version = "1.0.10", default-features = false, features = ["alloc"] }
wrapper_macro = { version = "0.1.0", path = "../wrapper_macro" }
diff --git a/zkvms/nexus/guest/guest.ld b/zkvms/nexus/guest/guest.ld
index 5a4dd4a..384c76c 100644
--- a/zkvms/nexus/guest/guest.ld
+++ b/zkvms/nexus/guest/guest.ld
@@ -1,14 +1,12 @@
ENTRY(_start);
+/* nb: when proving we will rebuild the memory model based on the first
+ pass' usages, so there is no cost for a "suboptimal" layout here */
+
SECTIONS
{
- /* Set the default size of the stack. */
- /* */
- /* Because the stack will grow down from this point, and if the heap requests memory */
- /* being used by the stack then the runtime will panic, this value also functions as */
- /* the memory limit for the guest program execution more generally. */
- __memory_top = 0x6400000;
- . = 0;
+ __memory_top = 0x80400000;
+ . = 0x1000;
.text : ALIGN(4)
{
@@ -19,7 +17,6 @@ SECTIONS
}
. = ALIGN(8);
- . = .* 2;
.data : ALIGN(4)
{
@@ -44,14 +41,6 @@ SECTIONS
_end = .;
}
- /* Dynamic relocations are unsupported. This section is only used to detect
- relocatable code in the input files and raise an error if relocatable code
- is found */
- .got (INFO) :
- {
- KEEP(*(.got .got.*));
- }
-
/DISCARD/ :
{
*(.comment*)
@@ -64,10 +53,3 @@ SECTIONS
}
ASSERT(. < __memory_top, "Program is too large for the VM memory.");
-
-ASSERT(SIZEOF(.got) == 0, "
-.got section detected in the input files. Dynamic relocations are not
-supported. If you are linking to C code compiled using the `gcc` crate
-then modify your build script to compile the C code _without_ the
--fPIC flag. See the documentation of the `gcc::Config.fpic` method for
-details.");
diff --git a/zkvms/nexus/guest/src/main.rs b/zkvms/nexus/guest/src/main.rs
index fd7c1d5..75b4d7d 100644
--- a/zkvms/nexus/guest/src/main.rs
+++ b/zkvms/nexus/guest/src/main.rs
@@ -1,6 +1,6 @@
#![cfg_attr(target_arch = "riscv32", no_std, no_main, allow(unused_imports))]
-use nexus_rt::{postcard, println, read_private_input, write_output};
+use nexus_rt::{postcard, println, read_private_input, write_public_output};
extern crate alloc;
use alloc::{collections::*, vec::*};
diff --git a/zkvms/nexus/host/Cargo.toml b/zkvms/nexus/host/Cargo.toml
index 29b3533..bfa9818 100644
--- a/zkvms/nexus/host/Cargo.toml
+++ b/zkvms/nexus/host/Cargo.toml
@@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-nexus-sdk = { path = "/nix/store/crj1vza7idyckr20y72ai3cv2fkc0ia8-Nexus-zkVM-unstable-2025-03-11/sdk" }
+nexus-sdk = { path = "/nix/store/63pzywhap3cxlqf74wjdwxxc66w7f29w-Nexus-zkVM-unstable-2025-03-11/sdk" }
zkvms_host_io = { path = "../../../zkvms_host_io" }
diff --git a/zkvms/nexus/host/src/main.rs b/zkvms/nexus/host/src/main.rs
index 1a3f05a..0ef044d 100644
--- a/zkvms/nexus/host/src/main.rs
+++ b/zkvms/nexus/host/src/main.rs
@@ -1,10 +1,9 @@
use nexus_sdk::{
- compile::CompileOpts,
- nova::seq::{Generate, Nova, PP},
- Local, Prover, Verifiable,
+ stwo::seq::Stwo,
+ Local, Prover, Verifiable, Viewable,
};
use zkvms_host_io::{
- benchmarkable, read_args, Input, Output,
+ benchmarkable, read_args, Input, Return,
RunType::{Execute, Prove, Verify},
};
@@ -16,53 +15,50 @@ fn main() {
let elf_path = std::env::var("ELF_PATH").expect("ELF PATH is missing");
- println!("Setting up Nova public parameters...");
- let pp: PP = PP::generate().expect("failed to generate parameters");
-
match run_info.run_type {
Execute => unreachable!(),
Prove => benchmarkable! {
- // Nova<T> doesn't derive Clone
+ // Stwo<T> doesn't derive Clone
println!("Loading guest...");
- let prover: Nova<Local> = Nova::new_from_file(&elf_path).expect("failed to load guest program");
+ let prover: Stwo<Local> = Stwo::new_from_file(&elf_path).expect("failed to load guest program");
println!("Proving execution of vm...");
- let proof = prover
- .prove_with_input::<Input>(&pp, &run_info.input)
+ let (view, _) = prover
+ .prove_with_input(&run_info.private_input, &run_info.public_input)
.expect("failed to prove program");
println!(
" output is {:?}!",
- proof
- .output::<Output>()
+ view
+ .public_output::<Return>()
.expect("failed to deserialize output")
);
- println!(">>>>> Logging\n{}<<<<<", proof.logs().join(""));
+ println!(">>>>> Logging\n{}<<<<<", view.logs().expect("failed to retrieve debug logs").join(""));
},
Verify => {
- // Nova<T> doesn't derive Clone
+ // Stwo<T> doesn't derive Clone
println!("Loading guest...");
- let prover: Nova<Local> =
- Nova::new_from_file(&elf_path).expect("failed to load guest program");
+ let prover: Stwo<Local> = Stwo::new_from_file(&elf_path).expect("failed to load guest program");
println!("Proving execution of vm...");
- let proof = prover
- .prove_with_input::<Input>(&pp, &run_info.input)
+ let (view, proof) = prover
+ .prove_with_input(&run_info.private_input, &run_info.public_input)
.expect("failed to prove program");
println!(
" output is {:?}!",
- proof
- .output::<Output>()
- .expect("failed to deserialize output")
- );
+ view
+ .public_output::<Return>()
+ .expect("failed to deserialize output")
+ );
- println!(">>>>> Logging\n{}<<<<<", proof.logs().join(""));
+ println!(">>>>> Logging\n{}<<<<<", view.logs().expect("failed to retrieve debug logs").join(""));
benchmarkable! {
print!("Verifying execution...");
- proof.verify(&pp).expect("failed to verify proof");
+ proof.verify(&view).expect("failed to verify proof");
+ println!(" Succeeded!");
}
}
}
diff --git a/zkvms/nexus/wrapper_macro/src/lib.rs b/zkvms/nexus/wrapper_macro/src/lib.rs
index 324ace8..1441d0d 100644
--- a/zkvms/nexus/wrapper_macro/src/lib.rs
+++ b/zkvms/nexus/wrapper_macro/src/lib.rs
@@ -45,23 +45,8 @@ pub fn make_wrapper(item: TokenStream) -> TokenStream {
.parse::<TokenStream>(),
);
- let public_inputs = toml::from_str::<toml::Table>(include_str!(concat!(
- env!("INPUTS_DIR"),
- "/default_public_input.toml"
- )))
- .unwrap();
- let (public_patterns, public_types) =
- args_divide_public(&args, &public_inputs.keys().collect()).0;
- let public_patterns: Vec<(TokenStream, TokenStream)> = public_patterns
- .into_iter()
- .zip(public_types.into_iter())
- .collect();
- for (pattern, ptype) in public_patterns {
- out.extend(format!("write_output::<{}>(&{});", ptype, pattern).parse::<TokenStream>());
- }
-
out.extend(
- format!("write_output::<{}>(&zkp::{}{});", ret, name, ts_patterns).parse::<TokenStream>(),
+ format!("write_public_output::<{}>(&zkp::{}{});", ret, name, ts_patterns).parse::<TokenStream>(),
);
let mut block = TokenStream::new();