-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR allows for free runtime data besides free compile time data, based on `initial_memory`. - Replaces `cbor` by `bincode` in prover queries (bincode is more efficient and cbor crashed with `u128`) - Allows the prover to pass a runtime initial memory, only possible with continuations (from #2251, was already merged into here, see commits list) - Changes the `powdr` lib, which already always uses continuations, to always use this mechanism for prover data - Provides a new stdin-stream-like function to read inputs in sequence, like other zkVMs. - The function above is called `read_stdin` which I'm not super happy with, ideally it'd just be called `read` but the QueryCalldata function is already called `read`. I think we could just keep this as is and change later. --------- Co-authored-by: Lucas Clemente Vella <[email protected]>
- Loading branch information
1 parent
816e8c7
commit c8d2703
Showing
31 changed files
with
551 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "fibonacci" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
default = [] | ||
simd = ["powdr/plonky3-simd"] | ||
|
||
[dependencies] | ||
powdr = { path = "../../../powdr", features = ["plonky3"] } | ||
|
||
serde = { version = "1.0", default-features = false, features = [ | ||
"alloc", | ||
"derive", | ||
"rc", | ||
] } | ||
serde_cbor = { version = "0.11.2", default-features = false, features = [ | ||
"alloc", | ||
] } | ||
|
||
env_logger = "0.10.2" | ||
log = "0.4.17" | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "powdr-guest" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
powdr-riscv-runtime = { path = "../../../../riscv-runtime", features = ["std"]} | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use powdr_riscv_runtime; | ||
use powdr_riscv_runtime::commit; | ||
use powdr_riscv_runtime::io::{read, write}; | ||
|
||
fn fib(n: u32) -> u32 { | ||
if n <= 1 { | ||
return n; | ||
} | ||
fib(n - 1) + fib(n - 2) | ||
} | ||
|
||
fn main() { | ||
// Read input from stdin. | ||
let n: u32 = read(); | ||
let r = fib(n); | ||
// Write result to stdout. | ||
write(1, r); | ||
// Commit the result as a public. | ||
commit::commit(r); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[toolchain] | ||
channel = "nightly-2024-09-21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "serialized-inputs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
default = [] | ||
simd = ["powdr/plonky3-simd"] | ||
|
||
[dependencies] | ||
powdr = { path = "../../../powdr", features = ["plonky3"] } | ||
|
||
serde = { version = "1.0", default-features = false, features = [ | ||
"alloc", | ||
"derive", | ||
"rc", | ||
] } | ||
|
||
env_logger = "0.10.2" | ||
log = "0.4.17" | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "powdr-guest" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
powdr-riscv-runtime = { path = "../../../../riscv-runtime", features = ["std"]} | ||
|
||
serde = { version = "1.0", default-features = false, features = [ | ||
"alloc", | ||
"derive", | ||
"rc", | ||
] } | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use powdr_riscv_runtime; | ||
use powdr_riscv_runtime::io::read; | ||
|
||
#[derive(serde::Serialize, serde::Deserialize)] | ||
struct Data { | ||
numbers: Vec<u32>, | ||
sum: u32, | ||
} | ||
|
||
fn main() { | ||
let data: Data = read(); | ||
let s: String = read(); | ||
|
||
assert_eq!(data.numbers.iter().sum::<u32>(), data.sum); | ||
assert_eq!(s, "test"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[toolchain] | ||
channel = "nightly-2024-09-21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use powdr::Session; | ||
|
||
#[derive(serde::Serialize, serde::Deserialize)] | ||
struct Data { | ||
numbers: Vec<u32>, | ||
sum: u32, | ||
} | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let some_data = Data { | ||
numbers: vec![1, 2, 3, 4, 5], | ||
sum: 15, | ||
}; | ||
|
||
let s: String = "test".to_string(); | ||
|
||
let mut session = Session::builder() | ||
.guest_path("./guest") | ||
.out_path("powdr-target") | ||
.chunk_size_log2(18) | ||
.build() | ||
.write(&some_data) | ||
.write(&s); | ||
|
||
// Fast dry run to test execution. | ||
session.run(); | ||
|
||
// Uncomment to compute the proof. | ||
//session.prove(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.