diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-01-17 18:50:07 +0200 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-01-17 18:50:07 +0200 |
| commit | 1bb44c826b745daad6ccbb48f2e91550a9c4ec00 (patch) | |
| tree | b27dfb1fbd46ac6bc17f1bf2bc4bc9c3cfdd8155 /zkvms/nexus/guest | |
| parent | 3f532203df67bfc0839416962ac9c012b127105d (diff) | |
| download | zkVMs-benchmarks-1bb44c826b745daad6ccbb48f2e91550a9c4ec00.tar zkVMs-benchmarks-1bb44c826b745daad6ccbb48f2e91550a9c4ec00.tar.gz zkVMs-benchmarks-1bb44c826b745daad6ccbb48f2e91550a9c4ec00.zip | |
feat(zkvms): Add nexus guest and it's macro
Diffstat (limited to 'zkvms/nexus/guest')
| -rw-r--r-- | zkvms/nexus/guest/Cargo.toml | 13 | ||||
| -rw-r--r-- | zkvms/nexus/guest/guest.ld | 73 | ||||
| l--------- | zkvms/nexus/guest/guests | 1 | ||||
| l--------- | zkvms/nexus/guest/guests_macro | 1 | ||||
| -rw-r--r-- | zkvms/nexus/guest/src/main.rs | 17 |
5 files changed, 105 insertions, 0 deletions
diff --git a/zkvms/nexus/guest/Cargo.toml b/zkvms/nexus/guest/Cargo.toml new file mode 100644 index 0000000..1d91504 --- /dev/null +++ b/zkvms/nexus/guest/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "guest" +version = "0.1.0" +edition = "2021" + +[workspace] + +[dependencies] +nexus-rt = { path = "/nix/store/krlanfap664k4g88qgsssxi0818z92r8-Nexus-zkVM-unstable-2024-12-18/runtime" } +postcard = { version = "1.0.10", default-features = false, features = ["alloc"] } + +zkp = { path = "./src/zkp" } +wrapper_macro = { version = "0.1.0", path = "../wrapper_macro" } diff --git a/zkvms/nexus/guest/guest.ld b/zkvms/nexus/guest/guest.ld new file mode 100644 index 0000000..5a4dd4a --- /dev/null +++ b/zkvms/nexus/guest/guest.ld @@ -0,0 +1,73 @@ +ENTRY(_start); + +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; + + .text : ALIGN(4) + { + KEEP(*(.init)); + . = ALIGN(4); + KEEP(*(.init.rust)); + *(.text .text.*); + } + + . = ALIGN(8); + . = .* 2; + + .data : ALIGN(4) + { + /* Must be called __global_pointer$ for linker relaxations to work. */ + __global_pointer$ = . + 0x800; + *(.srodata .srodata.*); + *(.rodata .rodata.*); + *(.sdata .sdata.* .sdata2 .sdata2.*); + *(.data .data.*); + + /* this is used by the global allocator (see:src/lib.rs) */ + . = ALIGN(4); + _heap = .; + LONG(_ebss); + } + + .bss (NOLOAD) : ALIGN(4) + { + *(.sbss .sbss.* .bss .bss.*); + . = ALIGN(4); + _ebss = .; + _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*) + *(.debug*) + } + + /* Stack unwinding is not supported, but we will keep these for now */ + .eh_frame (INFO) : { KEEP(*(.eh_frame)) } + .eh_frame_hdr (INFO) : { *(.eh_frame_hdr) } +} + +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/guests b/zkvms/nexus/guest/guests new file mode 120000 index 0000000..69bc8ed --- /dev/null +++ b/zkvms/nexus/guest/guests @@ -0,0 +1 @@ +../../../guests
\ No newline at end of file diff --git a/zkvms/nexus/guest/guests_macro b/zkvms/nexus/guest/guests_macro new file mode 120000 index 0000000..143a0b5 --- /dev/null +++ b/zkvms/nexus/guest/guests_macro @@ -0,0 +1 @@ +../../../guests_macro
\ No newline at end of file diff --git a/zkvms/nexus/guest/src/main.rs b/zkvms/nexus/guest/src/main.rs new file mode 100644 index 0000000..eb82cde --- /dev/null +++ b/zkvms/nexus/guest/src/main.rs @@ -0,0 +1,17 @@ +#![cfg_attr(target_arch = "riscv32", no_std, no_main, allow(unused_imports))] + +use nexus_rt::{ postcard, println, read_private_input, write_output }; + +extern crate alloc; +use alloc::vec::Vec; +use wrapper_macro::make_wrapper; + +type Input = (Vec<Vec<bool>>, u32, Vec<Vec<u32>>); +type Output = bool; + +const VERTICES: usize = 100; + +#[nexus_rt::main] +fn main() { + zkp::entrypoint_expr!() +} |
