diff --git a/.gitignore b/.gitignore index e67ec1ef1b..020a50c25a 100644 --- a/.gitignore +++ b/.gitignore @@ -40,11 +40,12 @@ crates/prover/semaphore-gnark-11 crates/prover/trusted-setup crates/prover/vk -<<<<<<< Updated upstream # Example legacy elf examples/elf -======= + # Example fibonacci groth16 / plonk proofs examples/fibonacci/fibonacci-groth16.bin examples/fibonacci/fibonacci-plonk.bin ->>>>>>> Stashed changes + +# C++ +.vscode/c_cpp_properties.json \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3ec8df2d2d..103eb41a64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ "alloy-sol-types", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "tracing", ] @@ -210,7 +210,7 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -317,7 +317,7 @@ dependencies = [ "auto_impl", "elliptic-curve", "k256", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -333,7 +333,7 @@ dependencies = [ "async-trait", "k256", "rand 0.8.5", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -494,54 +494,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "ark-bn254" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" -dependencies = [ - "ark-ec", - "ark-ff 0.4.2", - "ark-std 0.4.0", -] - -[[package]] -name = "ark-crypto-primitives" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3a13b34da09176a8baba701233fdffbaa7c1b1192ce031a3da4e55ce1f1a56" -dependencies = [ - "ark-ec", - "ark-ff 0.4.2", - "ark-relations", - "ark-serialize 0.4.2", - "ark-snark", - "ark-std 0.4.0", - "blake2", - "derivative", - "digest 0.10.7", - "rayon", - "sha2 0.10.8", -] - -[[package]] -name = "ark-ec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" -dependencies = [ - "ark-ff 0.4.2", - "ark-poly", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "derivative", - "hashbrown 0.13.2", - "itertools 0.10.5", - "num-traits", - "rayon", - "zeroize", -] - [[package]] name = "ark-ff" version = "0.3.0" @@ -576,7 +528,6 @@ dependencies = [ "num-bigint 0.4.6", "num-traits", "paste", - "rayon", "rustc_version 0.4.1", "zeroize", ] @@ -626,48 +577,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ark-groth16" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ceafa83848c3e390f1cbf124bc3193b3e639b3f02009e0e290809a501b95fc" -dependencies = [ - "ark-crypto-primitives", - "ark-ec", - "ark-ff 0.4.2", - "ark-poly", - "ark-relations", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "rayon", -] - -[[package]] -name = "ark-poly" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" -dependencies = [ - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "derivative", - "hashbrown 0.13.2", - "rayon", -] - -[[package]] -name = "ark-relations" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00796b6efc05a3f48225e59cb6a2cda78881e7c390872d5786aaf112f31fb4f0" -dependencies = [ - "ark-ff 0.4.2", - "ark-std 0.4.0", - "tracing", - "tracing-subscriber 0.2.25", -] - [[package]] name = "ark-serialize" version = "0.3.0" @@ -684,35 +593,11 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ - "ark-serialize-derive", "ark-std 0.4.0", "digest 0.10.7", "num-bigint 0.4.6", ] -[[package]] -name = "ark-serialize-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-snark" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84d3cc6833a335bb8a600241889ead68ee89a3cf8448081fb7694c0fe503da63" -dependencies = [ - "ark-ff 0.4.2", - "ark-relations", - "ark-serialize 0.4.2", - "ark-std 0.4.0", -] - [[package]] name = "ark-std" version = "0.3.0" @@ -731,7 +616,6 @@ checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", "rand 0.8.5", - "rayon", ] [[package]] @@ -1308,7 +1192,7 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -1734,32 +1618,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "fiat-crypto", - "rustc_version 0.4.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "darling" version = "0.13.4" @@ -2233,12 +2091,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "fiat-crypto" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" - [[package]] name = "fixed-hash" version = "0.8.0" @@ -2653,15 +2505,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -4179,7 +4022,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror 1.0.69", + "thiserror", "ucd-trie", ] @@ -4525,7 +4368,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls 0.23.16", "socket2", - "thiserror 1.0.69", + "thiserror", "tokio", "tracing", ] @@ -4542,7 +4385,7 @@ dependencies = [ "rustc-hash 2.0.0", "rustls 0.23.16", "slab", - "thiserror 1.0.69", + "thiserror", "tinyvec", "tracing", ] @@ -4703,7 +4546,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom 0.2.15", "libredox", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -4811,7 +4654,7 @@ dependencies = [ "http 1.1.0", "reqwest", "serde", - "thiserror 1.0.69", + "thiserror", "tower-service", ] @@ -5295,7 +5138,7 @@ checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" dependencies = [ "percent-encoding", "serde", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -5541,7 +5384,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "cargo_metadata", @@ -5552,7 +5395,7 @@ dependencies = [ [[package]] name = "sp1-cli" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anstyle", "anyhow", @@ -5581,7 +5424,7 @@ dependencies = [ [[package]] name = "sp1-core-executor" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "bytemuck", @@ -5611,7 +5454,7 @@ dependencies = [ "strum", "strum_macros", "test-artifacts", - "thiserror 1.0.69", + "thiserror", "tiny-keccak", "tracing", "typenum", @@ -5620,7 +5463,7 @@ dependencies = [ [[package]] name = "sp1-core-machine" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "cfg-if", @@ -5659,18 +5502,18 @@ dependencies = [ "strum_macros", "tempfile", "test-artifacts", - "thiserror 1.0.69", + "thiserror", "tiny-keccak", "tracing", "tracing-forest", - "tracing-subscriber 0.3.18", + "tracing-subscriber", "typenum", "web-time", ] [[package]] name = "sp1-cuda" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "ctrlc", @@ -5688,10 +5531,9 @@ dependencies = [ [[package]] name = "sp1-curves" -version = "3.0.0" +version = "3.4.0" dependencies = [ "cfg-if", - "curve25519-dalek", "dashu", "elliptic-curve", "generic-array 1.1.0", @@ -5711,7 +5553,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "3.0.0" +version = "3.4.0" dependencies = [ "quote", "syn 1.0.109", @@ -5719,7 +5561,7 @@ dependencies = [ [[package]] name = "sp1-eval" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "bincode", @@ -5737,14 +5579,16 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "3.0.0" +version = "3.4.0" dependencies = [ "sp1-build", ] [[package]] name = "sp1-lib" -version = "3.0.0" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c8744af050832df5ca44fcd63979a83b93ca3010b2d5a5ce2a2b91f7438065c" dependencies = [ "bincode", "serde", @@ -5752,9 +5596,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "3.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c8744af050832df5ca44fcd63979a83b93ca3010b2d5a5ce2a2b91f7438065c" +version = "3.4.0" dependencies = [ "bincode", "serde", @@ -5762,7 +5604,7 @@ dependencies = [ [[package]] name = "sp1-perf" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "clap", @@ -5778,7 +5620,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "hex", @@ -5794,7 +5636,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "bincode", @@ -5823,15 +5665,15 @@ dependencies = [ "sp1-recursion-gnark-ffi", "sp1-stark", "test-artifacts", - "thiserror 1.0.69", + "thiserror", "tracing", "tracing-appender", - "tracing-subscriber 0.3.18", + "tracing-subscriber", ] [[package]] name = "sp1-recursion-circuit" -version = "3.0.0" +version = "3.4.0" dependencies = [ "ff 0.13.0", "hashbrown 0.14.5", @@ -5868,7 +5710,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "3.0.0" +version = "3.4.0" dependencies = [ "backtrace", "criterion", @@ -5893,7 +5735,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "3.0.0" +version = "3.4.0" dependencies = [ "backtrace", "ff 0.13.0", @@ -5920,7 +5762,7 @@ dependencies = [ "sp1-primitives", "sp1-stark", "static_assertions", - "thiserror 1.0.69", + "thiserror", "tracing", "vec_map", "zkhash", @@ -5928,7 +5770,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "3.0.0" +version = "3.4.0" dependencies = [ "quote", "syn 1.0.109", @@ -5936,7 +5778,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-cli" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "clap", @@ -5945,7 +5787,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "bincode", @@ -5969,7 +5811,7 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "3.0.0" +version = "3.4.0" dependencies = [ "alloy-primitives", "alloy-signer", @@ -6006,7 +5848,7 @@ dependencies = [ "strum_macros", "tempfile", "test-artifacts", - "thiserror 1.0.69", + "thiserror", "tokio", "tonic", "tracing", @@ -6016,7 +5858,7 @@ dependencies = [ [[package]] name = "sp1-stark" -version = "3.0.0" +version = "3.4.0" dependencies = [ "arrayref", "hashbrown 0.14.5", @@ -6049,13 +5891,8 @@ dependencies = [ [[package]] name = "sp1-verifier" -version = "3.0.0" +version = "3.4.0" dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff 0.4.2", - "ark-groth16", - "ark-serialize 0.4.2", "hex", "lazy_static", "num-bigint 0.4.6", @@ -6063,12 +5900,12 @@ dependencies = [ "sha2 0.10.8", "sp1-sdk", "substrate-bn-succinct", - "thiserror 2.0.3", + "thiserror-no-std", ] [[package]] name = "sp1-zkvm" -version = "3.0.1" +version = "3.4.0" dependencies = [ "cfg-if", "getrandom 0.2.15", @@ -6078,7 +5915,7 @@ dependencies = [ "p3-field", "rand 0.8.5", "sha2 0.10.8", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-primitives", ] @@ -6397,7 +6234,7 @@ dependencies = [ [[package]] name = "test-artifacts" -version = "3.0.0" +version = "3.4.0" dependencies = [ "sp1-build", ] @@ -6419,16 +6256,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" -dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl", ] [[package]] @@ -6443,14 +6271,23 @@ dependencies = [ ] [[package]] -name = "thiserror-impl" -version = "2.0.3" +name = "thiserror-impl-no-std" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", ] [[package]] @@ -6789,9 +6626,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" dependencies = [ "crossbeam-channel", - "thiserror 1.0.69", + "thiserror", "time 0.3.36", - "tracing-subscriber 0.3.18", + "tracing-subscriber", ] [[package]] @@ -6823,9 +6660,9 @@ checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" dependencies = [ "ansi_term", "smallvec", - "thiserror 1.0.69", + "thiserror", "tracing", - "tracing-subscriber 0.3.18", + "tracing-subscriber", ] [[package]] @@ -6849,15 +6686,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "tracing-subscriber" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" -dependencies = [ - "tracing-core", -] - [[package]] name = "tracing-subscriber" version = "0.3.18" @@ -6896,7 +6724,7 @@ dependencies = [ "log", "rand 0.8.5", "sha1 0.10.6", - "thiserror 1.0.69", + "thiserror", "url", "utf-8", ] @@ -6926,7 +6754,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror", "tokio", "tower 0.5.1", "url", diff --git a/Cargo.toml b/Cargo.toml index 58e56265fc..14885539d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "3.0.0" +version = "3.4.0" edition = "2021" license = "MIT OR Apache-2.0" rust-version = "1.79" @@ -30,6 +30,7 @@ members = [ "crates/cuda", "crates/verifier", "crates/stark", + "crates/verifier", "crates/zkvm/*", "crates/test-artifacts", ] @@ -49,31 +50,28 @@ debug-assertions = true [workspace.dependencies] # sp1 -sp1-build = { path = "crates/build", version = "3.0.0" } -sp1-cli = { path = "crates/cli", version = "3.0.0", default-features = false } -sp1-core-machine = { path = "crates/core/machine", version = "3.0.0" } -sp1-core-executor = { path = "crates/core/executor", version = "3.0.0" } -sp1-curves = { path = "crates/curves", version = "3.0.0" } -sp1-derive = { path = "crates/derive", version = "3.0.0" } -sp1-eval = { path = "crates/eval", version = "3.0.0" } -sp1-helper = { path = "crates/helper", version = "3.0.0", default-features = false } -sp1-primitives = { path = "crates/primitives", version = "3.0.0" } -sp1-prover = { path = "crates/prover", version = "3.0.0" } -sp1-recursion-compiler = { path = "crates/recursion/compiler", version = "3.0.0" } -sp1-recursion-core = { path = "crates/recursion/core", version = "3.0.0", default-features = false } -sp1-recursion-derive = { path = "crates/recursion/derive", version = "3.0.0", default-features = false } -sp1-recursion-gnark-ffi = { path = "crates/recursion/gnark-ffi", version = "3.0.0", default-features = false } -sp1-recursion-circuit = { path = "crates/recursion/circuit", version = "3.0.0", default-features = false } -sp1-sdk = { path = "crates/sdk", version = "3.0.0" } -sp1-cuda = { path = "crates/cuda", version = "3.0.0" } -sp1-stark = { path = "crates/stark", version = "3.0.0" } -sp1-lib = { path = "crates/zkvm/lib", version = "3.0.0", default-features = false } -# NOTE: The version in this crate is manually set to 3.0.1 right now. When upgrading SP1 versions, -# make sure to update this crate. -sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.0.1", default-features = false } - -# For testing. -test-artifacts = { path = "crates/test-artifacts", version = "3.0.0" } +sp1-build = { path = "crates/build", version = "3.4.0" } +sp1-cli = { path = "crates/cli", version = "3.4.0", default-features = false } +sp1-core-machine = { path = "crates/core/machine", version = "3.4.0" } +sp1-core-executor = { path = "crates/core/executor", version = "3.4.0" } +sp1-curves = { path = "crates/curves", version = "3.4.0" } +sp1-derive = { path = "crates/derive", version = "3.4.0" } +sp1-eval = { path = "crates/eval", version = "3.4.0" } +sp1-helper = { path = "crates/helper", version = "3.4.0", default-features = false } +sp1-primitives = { path = "crates/primitives", version = "3.4.0" } +sp1-prover = { path = "crates/prover", version = "3.4.0" } +sp1-recursion-compiler = { path = "crates/recursion/compiler", version = "3.4.0" } +sp1-recursion-core = { path = "crates/recursion/core", version = "3.4.0", default-features = false } +sp1-recursion-derive = { path = "crates/recursion/derive", version = "3.4.0", default-features = false } +sp1-recursion-gnark-ffi = { path = "crates/recursion/gnark-ffi", version = "3.4.0", default-features = false } +sp1-recursion-circuit = { path = "crates/recursion/circuit", version = "3.4.0", default-features = false } +sp1-sdk = { path = "crates/sdk", version = "3.4.0" } +sp1-cuda = { path = "crates/cuda", version = "3.4.0" } +sp1-stark = { path = "crates/stark", version = "3.4.0" } +sp1-lib = { path = "crates/zkvm/lib", version = "3.4.0", default-features = false } +sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.4.0", default-features = false } +sp1-verifier = { path = "crates/verifier", version = "3.4.0" } +test-artifacts = { path = "crates/test-artifacts", version = "3.4.0" } # p3 # p3-air = "0.1.4-succinct" diff --git a/book/docs/generating-proofs/proof-types.md b/book/docs/generating-proofs/proof-types.md index 1e0db699b4..581a751d3c 100644 --- a/book/docs/generating-proofs/proof-types.md +++ b/book/docs/generating-proofs/proof-types.md @@ -11,8 +11,8 @@ For a full list of options, see the following [docs](https://docs.rs/sp1-sdk/lat The default prover mode generates a list of STARK proofs that in aggregate have size proportional to the size of the execution. Use this in settings where you don't care about **verification cost / proof size**. -```rust -let client = ProverClient::new(); +```rust,noplayground +let client = ProverClient::from_env(); client.prove(&pk, stdin).run().unwrap(); ``` @@ -21,19 +21,19 @@ client.prove(&pk, stdin).run().unwrap(); The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you care about **verification cost / proof size**, but not onchain verification. Compressed proofs are also useful because they can be cheaply recursively verified within SP1 itself (see the [proof aggregation](../writing-programs/proof-aggregation.md) section). -```rust -let client = ProverClient::new(); +```rust,noplayground +let client = ProverClient::from_env(); client.prove(&pk, stdin).compressed().run().unwrap(); ``` ## Groth16 (Recommended) -The Groth16 prover mode generates a SNARK proof that is ~260 bytes large and can be verified onchain for around ~270k gas. +The Groth16 prover mode generates a SNARK proof that is ~260 bytes large and can be verified onchain for around ~270k gas. The trusted setup for the Groth16 circuit keys uses the [Aztec Ignition ceremony](https://github.com/AztecProtocol/ignition-verification) + entropy contributions from members of the Succinct team. If you are uncomfortable with the security assumptions of the ceremony, you can use the PLONK proof type instead. -```rust -let client = ProverClient::new(); +```rust,noplayground +let client = ProverClient::from_env(); client.prove(&pk, stdin).groth16().run().unwrap(); ``` @@ -43,7 +43,7 @@ The PLONK prover mode generates a SNARK proof that is ~868 bytes large and can a PLONK does not require a trusted setup and reuses contributions from the Aztec Ignition ceremony. -```rust -let client = ProverClient::new(); +```rust,noplayground +let client = ProverClient::from_env(); client.prove(&pk, stdin).plonk().run().unwrap(); ``` diff --git a/book/docs/generating-proofs/prover-network/usage.md b/book/docs/generating-proofs/prover-network/usage.md index 12ef4ac4e6..388c61efdb 100644 --- a/book/docs/generating-proofs/prover-network/usage.md +++ b/book/docs/generating-proofs/prover-network/usage.md @@ -8,7 +8,7 @@ To use the prover network to generate a proof, you can run your script that uses ```rust // Generate the proof for the given program. -let client = ProverClient::new(); +let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let mut proof = client.prove(&pk, stdin).run().unwrap(); ``` diff --git a/book/docs/verification/onchain/solidity-sdk.md b/book/docs/verification/onchain/solidity-sdk.md index 822ab620b9..93a241ed96 100644 --- a/book/docs/verification/onchain/solidity-sdk.md +++ b/book/docs/verification/onchain/solidity-sdk.md @@ -81,7 +81,7 @@ fn main() { sp1_sdk::utils::setup_logger(); // Setup the prover client. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Setup the program. let (_, vk) = client.setup(FIBONACCI_ELF); diff --git a/book/docs/writing-programs/patched-crates.md b/book/docs/writing-programs/patched-crates.md index 8b250e5c5c..0ebda21693 100644 --- a/book/docs/writing-programs/patched-crates.md +++ b/book/docs/writing-programs/patched-crates.md @@ -44,6 +44,18 @@ secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "secp substrate-bn = { git = "https://github.com/sp1-patches/bn", tag = "substrate_bn-v0.6.0-patch-v1" } bls12_381 = { git = "https://github.com/sp1-patches/bls12_381", tag = "bls12_381-v0.8.0-patch-v1" } +# For sp1 versions >= 3.4.0 +curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", tag = "patch-v4.1.3-v3.4.0" } +# For sp1 versions < 3.4.0 +curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", tag = "curve25519_dalek-v4.1.3-patch-v1" } +curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", tag = "curve25519_dalek_ng-v4.1.1-patch-v1" } +ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", tag = "ed25519_consensus-v2.1.0-patch-v1" } +# For sp1 versions >= 3.3.0 +ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", tag = "ecdsa-v0.16.9-patch-v3.3.0" } +secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "secp256k1-v0.29.0-patch-v3.3.0" } +# For sp1 versions < 3.3.0 +ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", tag = "ecdsa-v0.16.9-patch-v1" } +secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "secp256k1-v0.29.0-patch-v1" } ``` If you are patching a crate from Github instead of from crates.io, you need to specify the diff --git a/book/docs/writing-programs/proof-aggregation.md b/book/docs/writing-programs/proof-aggregation.md index dc13d6e42c..a6780af1f6 100644 --- a/book/docs/writing-programs/proof-aggregation.md +++ b/book/docs/writing-programs/proof-aggregation.md @@ -17,7 +17,7 @@ Note that by itself, SP1 can already prove arbitrarily large programs by chunkin To verify a proof inside the zkVM, you can use the `sp1_zkvm::lib::verify::verify_sp1_proof` function. -```rust +```rust,noplayground sp1_zkvm::lib::verify::verify_sp1_proof(vkey, public_values_digest); ``` diff --git a/book/sp1.png b/book/sp1.png new file mode 100644 index 0000000000..78576befe3 Binary files /dev/null and b/book/sp1.png differ diff --git a/book/verification/off-chain-verification.md b/book/verification/off-chain-verification.md new file mode 100644 index 0000000000..9250b6021a --- /dev/null +++ b/book/verification/off-chain-verification.md @@ -0,0 +1,49 @@ +# Offchain Verification + +## Rust `no_std` Verification + +You can verify SP1 Groth16 and Plonk proofs in `no_std` environments with [`sp1-verifier`](https://docs.rs/sp1-verifier/latest/sp1_verifier/). + +`sp1-verifier` is also patched to verify Groth16 and Plonk proofs within the SP1 ZKVM, using +[bn254](https://blog.succinct.xyz/succinctshipsprecompiles/) precompiles. For an example of this, see +the [Groth16 Example](https://github.com/succinctlabs/sp1/tree/main/examples/groth16/). + +### Installation + +Import the following dependency in your `Cargo.toml`: + +```toml +sp1-verifier = {version = "3.0.0", default-features = false} +``` + +### Usage + +`sp1-verifier`'s interface is very similar to the solidity verifier's. It exposes two public functions: +[`Groth16Verifier::verify_proof`](https://docs.rs/sp1-verifier/latest/src/sp1_verifier/groth16.rs.html) +and [`PlonkVerifier::verify_proof`](https://docs.rs/sp1-verifier/latest/src/sp1_verifier/plonk.rs.html). + +`sp1-verifier` also exposes the Groth16 and Plonk verifying keys as constants, `GROTH16_VK_BYTES` and `PLONK_VK_BYTES`. These +keys correspond to the current SP1 version's official Groth16 and Plonk verifying keys, which are used for verifying proofs generated +using docker or the prover network. + +First, generate your groth16/plonk proof with the SP1 SDK. See [here](./onchain/getting-started.md#generating-sp1-proofs-for-onchain-verification) +for more information -- `sp1-verifier` and the solidity verifier expect inputs in the same format. + +Next, verify the proof with `sp1-verifier`. The following snippet is from the [Groth16 example program](https://github.com/succinctlabs/sp1/tree/dev/examples/groth16/), which verifies a Groth16 proof within SP1 using `sp1-verifier`. + +```rust,noplayground +{{#include ../../examples/groth16/program/src/main.rs}} +``` + +Here, the proof, public inputs, and vkey hash are read from stdin. See the following snippet to see how these values are generated. + +```rust,noplayground +{{#include ../../examples/groth16/script/src/main.rs:12:34}} +``` + +> Note that the SP1 SDK itself is *not* `no_std` compatible. + +## Wasm Verification + +The [`example-sp1-wasm-verifier`](https://github.com/succinctlabs/example-sp1-wasm-verifier) demonstrates how to +verify SP1 proofs in wasm. For a more detailed explanation of the process, please see the [README](https://github.com/succinctlabs/example-sp1-wasm-verifier/blob/main/README.md). diff --git a/book/verification/onchain/contract-addresses.md b/book/verification/onchain/contract-addresses.md new file mode 100644 index 0000000000..0a23f6ab2e --- /dev/null +++ b/book/verification/onchain/contract-addresses.md @@ -0,0 +1,101 @@ +# Contract Addresses + +To verify SP1 proofs on-chain, we recommend using our deployed canonical verifier gateways. The +[SP1VerifierGateway](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol) +will automatically route your SP1 proof to the correct verifier based on the SP1 version used. + +## Canonical Verifier Gateways + +There are different verifier gateway for each proof system: Groth16 and PLONK. This means that you +must use the correct verifier gateway depending on if you are verifying a Groth16 or PLONK proof. + +### Groth16 + +| Chain ID | Chain | Gateway | +| -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | Mainnet | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://etherscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 11155111 | Sepolia | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://sepolia.etherscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 17000 | Holesky | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://holesky.etherscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 42161 | Arbitrum One | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://arbiscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 421614 | Arbitrum Sepolia | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://sepolia.arbiscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 8453 | Base | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://basescan.org/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 84532 | Base Sepolia | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://sepolia.basescan.org/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 10 | Optimism | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://optimistic.etherscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 11155420 | Optimism Sepolia | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://sepolia-optimism.etherscan.io/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 534351 | Scroll Sepolia | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://sepolia.scrollscan.com/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | +| 534352 | Scroll | [0x397A5f7f3dBd538f23DE225B51f532c34448dA9B](https://scrollscan.com/address/0x397A5f7f3dBd538f23DE225B51f532c34448dA9B) | + +### PLONK + +| Chain ID | Chain | Gateway | +| -------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------- | +| 1 | Mainnet | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 11155111 | Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 17000 | Holesky | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://holesky.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 42161 | Arbitrum One | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://arbiscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 421614 | Arbitrum Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.arbiscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 8453 | Base | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 84532 | Base Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.basescan.org/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 10 | Optimism | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://optimistic.etherscan.io/address/0x3b6041173b80e77f038f3f2c0f9744f04837185e) | +| 11155420 | Optimism Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia-optimism.etherscan.io/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 534351 | Scroll Sepolia | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://sepolia.scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | +| 534352 | Scroll | [0x3B6041173B80E77f038f3F2C0f9744f04837185e](https://scrollscan.com/address/0x3B6041173B80E77f038f3F2C0f9744f04837185e) | + +The most up-to-date reference on each chain can be found in the +[deployments](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/deployments) +directory in the +SP1 contracts repository, where each chain has a dedicated JSON file with each verifier's address. + +## Versioning Policy + +Whenever a verifier for a new SP1 version is deployed, the gateway contract will be updated to +support it with +[addRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L65). +If a verifier for an SP1 version has an issue, the route will be frozen with +[freezeRoute()](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1VerifierGateway.sol#L71). + +On mainnets, only official versioned releases are deployed and added to the gateway. Testnets have +`rc` versions of the verifier deployed supported in addition to the official versions. + +## Deploying to other Chains + +In the case that you need to use a chain that is not listed above, you can deploy your own +verifier contract by following the instructions in the +[SP1 Contracts Repo](https://github.com/succinctlabs/sp1-contracts/blob/main/README.md#deployments). + +Since both the `SP1VerifierGateway` and each `SP1Verifier` implement the [ISP1Verifier +interface](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1Verifier.sol), you can choose to either: + +* Deploy the `SP1VerifierGateway` and add `SP1Verifier` contracts to it. Then point to the + `SP1VerifierGateway` address in your contracts. +* Deploy just the `SP1Verifier` contract that you want to use. Then point to the `SP1Verifier` + address in + your contracts. + +If you want support for a canonical verifier on your chain, contact us [here](https://t.me/+AzG4ws-kD24yMGYx). We often deploy canonical verifiers on new chains if there's enough demand. + +## ISP1Verifier Interface + +All verifiers implement the [ISP1Verifier](https://github.com/succinctlabs/sp1-contracts/blob/main/contracts/src/ISP1Verifier.sol) interface. + +```c++ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +/// @title SP1 Verifier Interface +/// @author Succinct Labs +/// @notice This contract is the interface for the SP1 Verifier. +interface ISP1Verifier { + /// @notice Verifies a proof with given public values and vkey. + /// @dev It is expected that the first 4 bytes of proofBytes must match the first 4 bytes of + /// target verifier's VERIFIER_HASH. + /// @param programVKey The verification key for the RISC-V program. + /// @param publicValues The public values encoded as bytes. + /// @param proofBytes The proof of the program execution the SP1 zkVM encoded as bytes. + function verifyProof( + bytes32 programVKey, + bytes calldata publicValues, + bytes calldata proofBytes + ) external view; +} +``` diff --git a/book/verification/onchain/getting-started.md b/book/verification/onchain/getting-started.md new file mode 100644 index 0000000000..834a23dc18 --- /dev/null +++ b/book/verification/onchain/getting-started.md @@ -0,0 +1,33 @@ +# Onchain Verification: Setup + +The best way to get started with verifying SP1 proofs on-chain is to refer to the [SP1 Project Template](https://github.com/succinctlabs/sp1-project-template/tree/main). + +- The template [program](https://github.com/succinctlabs/sp1-project-template/blob/main/program/src/main.rs) shows how to write outputs that can be decoded in Solidity. +- The template [script](https://github.com/succinctlabs/sp1-project-template/blob/main/script/src/bin/prove.rs) shows how to generate the proof using the SDK and save it to a file. +- The template [contract](https://github.com/succinctlabs/sp1-project-template/blob/main/contracts/src/Fibonacci.sol) shows how to verify the proof onchain using Solidity. + +Refer to the section on [Contract Addresses](./contract-addresses.md#contract-addresses) for the addresses of the deployed verifiers. + +## Generating SP1 Proofs for Onchain Verification + +By default, the proofs generated by SP1 are not verifiable onchain, as they are non-constant size and STARK verification on Ethereum is very expensive. To generate a proof that can be verified onchain, we use performant STARK recursion to combine SP1 shard proofs into a single STARK proof and then wrap that in a SNARK proof. Our `ProverClient` has a prover option for this called `plonk`. Behind the scenes, this function will first generate a normal SP1 proof, then recursively combine all of them into a single proof using the STARK recursion protocol. Finally, the proof is wrapped in a SNARK proof using PLONK. + +> WARNING: The Groth16 and PLONK provers are only guaranteed to work on official releases of SP1. To +> use Groth16 or PLONK proving & verification locally, ensure that you have Docker installed and have +> at least 128GB of RAM. + +### Example + +```rust,noplayground +{{#include ../../examples/fibonacci/script/bin/groth16_bn254.rs}} +``` + +You can run the above script with `RUST_LOG=info cargo run --bin groth16_bn254 --release` in `examples/fibonacci/script`. + +#### Using Groth16 and PLONK without Docker (Advanced) + +If you would like to run the Groth16 or PLONK prover directly without Docker, you must have Go 1.22 installed and enable the `native-gnark` feature in `sp1-sdk`. This path is not recommended and may require additional native dependencies. + +```toml +sp1-sdk = { version = "2.0.0", features = ["native-gnark"] } +``` diff --git a/book/verification/onchain/solidity-sdk.md b/book/verification/onchain/solidity-sdk.md new file mode 100644 index 0000000000..822ab620b9 --- /dev/null +++ b/book/verification/onchain/solidity-sdk.md @@ -0,0 +1,122 @@ +# Solidity Verifier + +We maintain a suite of [contracts](https://github.com/succinctlabs/sp1-contracts/tree/main) used for verifying SP1 proofs onchain. We highly recommend using [Foundry](https://book.getfoundry.sh/). + +## Installation + +To install the latest release version: + +```bash +forge install succinctlabs/sp1-contracts +``` + +To install a specific version: + +```bash +forge install succinctlabs/sp1-contracts@ +``` + +Finally, add `@sp1-contracts/=lib/sp1-contracts/contracts/src/` in `remappings.txt.` + +### Usage + +Once installed, you can use the contracts in the library by importing them: + +```c++ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol"; + +/// @title Fibonacci. +/// @author Succinct Labs +/// @notice This contract implements a simple example of verifying the proof of a computing a +/// fibonacci number. +contract Fibonacci { + /// @notice The address of the SP1 verifier contract. + /// @dev This can either be a specific SP1Verifier for a specific version, or the + /// SP1VerifierGateway which can be used to verify proofs for any version of SP1. + /// For the list of supported verifiers on each chain, see: + /// https://docs.succinct.xyz/onchain-verification/contract-addresses + address public verifier; + + /// @notice The verification key for the fibonacci program. + bytes32 public fibonacciProgramVKey; + + constructor(address _verifier, bytes32 _fibonacciProgramVKey) { + verifier = _verifier; + fibonacciProgramVKey = _fibonacciProgramVKey; + } + + /// @notice The entrypoint for verifying the proof of a fibonacci number. + /// @param _proofBytes The encoded proof. + /// @param _publicValues The encoded public values. + function verifyFibonacciProof(bytes calldata _publicValues, bytes calldata _proofBytes) + public + view + returns (uint32, uint32, uint32) + { + ISP1Verifier(verifier).verifyProof(fibonacciProgramVKey, _publicValues, _proofBytes); + (uint32 n, uint32 a, uint32 b) = abi.decode(_publicValues, (uint32, uint32, uint32)); + return (n, a, b); + } +} + +``` + +### Finding your program vkey + +The program vkey (`fibonacciProgramVKey` in the example above) is passed into the `ISP1Verifier` along with the public values and proof bytes. You +can find your program vkey by going through the following steps: + +1. Find what version of SP1 crates you are using. +2. Use the version from step to run this command: `sp1up --version ` +3. Use the vkey command to get the program vkey: `cargo prove vkey -elf ` + +Alternatively, you can set up a simple script to do this using the `sp1-sdk` crate: + +```rust +fn main() { + // Setup the logger. + sp1_sdk::utils::setup_logger(); + + // Setup the prover client. + let client = ProverClient::new(); + + // Setup the program. + let (_, vk) = client.setup(FIBONACCI_ELF); + + // Print the verification key. + println!("Program Verification Key: {}", vk.bytes32()); +} +``` + +### Testing + +To test the contract, we recommend setting up [Foundry +Tests](https://book.getfoundry.sh/forge/tests). We have an example of such a test in the [SP1 +Project +Template](https://github.com/succinctlabs/sp1-project-template/blob/dev/contracts/test/Fibonacci.t.sol). + +### Solidity Versions + +The officially deployed contracts are built using Solidity 0.8.20 and exist on the +[sp1-contracts main](https://github.com/succinctlabs/sp1-contracts/tree/main) branch. + +If you need to use different versions that are compatible with your contracts, there are also other +branches you can install that contain different versions. For +example for branch [main-0.8.15](https://github.com/succinctlabs/sp1-contracts/tree/main-0.8.15) +contains the contracts with: + +```c++ +pragma solidity ^0.8.15; +``` + +and you can install it with: + +```sh +forge install succinctlabs/sp1-contracts@main-0.8.15 +``` + +If there is different versions that you need but there aren't branches for them yet, please ask in +the [SP1 Telegram](https://t.me/+AzG4ws-kD24yMGYx). diff --git a/crates/cli/src/commands/install_toolchain.rs b/crates/cli/src/commands/install_toolchain.rs index de09773cef..e027729f26 100644 --- a/crates/cli/src/commands/install_toolchain.rs +++ b/crates/cli/src/commands/install_toolchain.rs @@ -1,15 +1,16 @@ -use anyhow::Result; -use clap::Parser; -use dirs::home_dir; -use rand::{distributions::Alphanumeric, Rng}; -use reqwest::Client; -use sp1_sdk::artifacts::download_file; use std::{ fs::{self}, io::Read, process::Command, }; +use anyhow::Result; +use clap::Parser; +use dirs::home_dir; +use rand::{distributions::Alphanumeric, Rng}; +use reqwest::Client; +use sp1_sdk::install::download_file; + #[cfg(target_family = "unix")] use std::os::unix::fs::PermissionsExt; diff --git a/crates/cli/src/commands/vkey.rs b/crates/cli/src/commands/vkey.rs index 734b470970..b69e91c986 100644 --- a/crates/cli/src/commands/vkey.rs +++ b/crates/cli/src/commands/vkey.rs @@ -48,7 +48,7 @@ impl VkeyCmd { file.read_to_end(&mut elf)?; // Get the verification key - let prover = ProverClient::new(); + let prover = ProverClient::from_env(); let (_, vk) = prover.setup(&elf); // Print the verification key hash diff --git a/crates/core/executor/src/hook.rs b/crates/core/executor/src/hook.rs index e5479f623f..a2ce720bf0 100644 --- a/crates/core/executor/src/hook.rs +++ b/crates/core/executor/src/hook.rs @@ -11,11 +11,20 @@ use crate::Executor; /// A runtime hook, wrapped in a smart pointer. pub type BoxedHook<'a> = Arc>; -/// The file descriptor through which to access `hook_k1_ecrecover`. -pub const K1_ECRECOVER_HOOK: u32 = 5; +/// The file descriptor through which to access `hook_ecrecover`. +pub const FD_ECRECOVER_HOOK: u32 = 5; + /// The file descriptor through which to access `hook_r1_ecrecover`. pub const R1_ECRECOVER_HOOK: u32 = 6; +// Note: we skip 6 because we have an eddsa hook in dev. + +/// The file descriptor through which to access `hook_ecrecover_2`. +pub const FD_ECRECOVER_HOOK_2: u32 = 7; + +/// The file descriptor through which to access `hook_ed_decompress`. +pub const FD_EDDECOMPRESS: u32 = 8; + /// A runtime hook. May be called during execution by writing to a specified file descriptor, /// accepting and returning arbitrary data. pub trait Hook { @@ -78,8 +87,10 @@ impl<'a> Default for HookRegistry<'a> { let table = HashMap::from([ // Note: To ensure any `fd` value is synced with `zkvm/precompiles/src/io.rs`, // add an assertion to the test `hook_fds_match` below. - (K1_ECRECOVER_HOOK, hookify(hook_k1_ecrecover)), + (FD_ECRECOVER_HOOK, hookify(hook_ecrecover)), (R1_ECRECOVER_HOOK, hookify(hook_r1_ecrecover)), + (FD_ECRECOVER_HOOK_2, hookify(hook_ecrecover_v2)), + (FD_EDDECOMPRESS, hookify(hook_ed_decompress)), ]); Self { table } @@ -121,7 +132,7 @@ pub struct HookEnv<'a, 'b: 'a> { /// WARNING: This function is used to recover the public key outside of the zkVM context. These /// values must be constrained by the zkVM for correctness. #[must_use] -pub fn hook_k1_ecrecover(_: HookEnv, buf: &[u8]) -> Vec> { +pub fn hook_ecrecover(_: HookEnv, buf: &[u8]) -> Vec> { assert_eq!(buf.len(), 65 + 32, "ecrecover input should have length 65 + 32"); let (sig, msg_hash) = buf.split_at(65); let sig: &[u8; 65] = sig.try_into().unwrap(); @@ -166,14 +177,87 @@ pub fn hook_r1_ecrecover(_: HookEnv, buf: &[u8]) -> Vec> { vec![s_inverse.to_bytes().to_vec()] } +/// Recovers the public key from the signature and message hash using the k256 crate. +/// +/// # Arguments +/// +/// * `env` - The environment in which the hook is invoked. +/// * `buf` - The buffer containing the signature and message hash. +/// - The signature is 65 bytes, the first 64 bytes are the signature and the last byte is the +/// recovery ID. +/// - The message hash is 32 bytes. +/// +/// The result is returned as a status and a pair of bytes, where the first 32 bytes are the X coordinate +/// and the second 32 bytes are the Y coordinate of the decompressed point. +/// +/// A status of 0 indicates that the public key could not be recovered. +/// +/// WARNING: This function is used to recover the public key outside of the zkVM context. These +/// values must be constrained by the zkVM for correctness. +#[must_use] +pub fn hook_ecrecover_v2(_: HookEnv, buf: &[u8]) -> Vec> { + assert_eq!(buf.len(), 65 + 32, "ecrecover input should have length 65 + 32, this is a bug."); + let (sig, msg_hash) = buf.split_at(65); + let sig: &[u8; 65] = sig.try_into().unwrap(); + let msg_hash: &[u8; 32] = msg_hash.try_into().unwrap(); + + let mut recovery_id = sig[64]; + let mut sig = Signature::from_slice(&sig[..64]).unwrap(); + + if let Some(sig_normalized) = sig.normalize_s() { + sig = sig_normalized; + recovery_id ^= 1; + }; + let recid = RecoveryId::from_byte(recovery_id) + .expect("Computed recovery ID is invalid, this is a bug."); + + // Attempting to recvover the public key has failed, write a 0 to indicate to the caller. + let Ok(recovered_key) = VerifyingKey::recover_from_prehash(&msg_hash[..], &sig, recid) else { + return vec![vec![0]]; + }; + + let bytes = recovered_key.to_sec1_bytes(); + + let (_, s) = sig.split_scalars(); + let s_inverse = s.invert(); + + vec![vec![1], bytes.to_vec(), s_inverse.to_bytes().to_vec()] +} + +/// Checks if a compressed Edwards point can be decompressed. +/// +/// # Arguments +/// * `env` - The environment in which the hook is invoked. +/// * `buf` - The buffer containing the compressed Edwards point. +/// - The compressed Edwards point is 32 bytes. +/// - The high bit of the last byte is the sign bit. +/// +/// The result is either `0` if the point cannot be decompressed, or `1` if it can. +/// +/// WARNING: This function merely hints at the validity of the compressed point. These values must +/// be constrained by the zkVM for correctness. +#[must_use] +pub fn hook_ed_decompress(_: HookEnv, buf: &[u8]) -> Vec> { + let Ok(point) = sp1_curves::curve25519_dalek::CompressedEdwardsY::from_slice(buf) else { + return vec![vec![0]]; + }; + + if sp1_curves::edwards::ed25519::decompress(&point).is_some() { + vec![vec![1]] + } else { + vec![vec![0]] + } +} + #[cfg(test)] pub mod tests { + use super::*; #[test] pub fn hook_fds_match() { use sp1_zkvm::lib::io; - assert_eq!(K1_ECRECOVER_HOOK, io::K1_ECRECOVER_HOOK); + assert_eq!(FD_ECRECOVER_HOOK, io::K1_ECRECOVER_HOOK); assert_eq!(R1_ECRECOVER_HOOK, io::R1_ECRECOVER_HOOK); } diff --git a/crates/core/executor/src/profiler.rs b/crates/core/executor/src/profiler.rs index a3066455cb..416993bb3c 100644 --- a/crates/core/executor/src/profiler.rs +++ b/crates/core/executor/src/profiler.rs @@ -197,31 +197,32 @@ impl Profiler { } /// Simple check to makes sure we have valid main function that lasts - /// for most of the exeuction time. + /// for most of the execution time. fn check_samples(&self) { let Some(main_idx) = self.main_idx else { - eprintln!("Warning: The `main` function is not present in the Elf file, this is likely caused by using the wrong Elf file"); + eprintln!( + "Warning: The `main` function is not present in the Elf file, this is likely caused by using the wrong Elf file" + ); return; }; - let main_count = - self.samples - .iter() - .filter(|s| { - s.stack.iter().any(|f| { - if let Frame::Label(idx) = f { - *idx == main_idx - } else { - false - } - }) - }) - .count(); + let main_count = self + .samples + .iter() + .filter(|s| { + s.stack + .iter() + .any(|f| if let Frame::Label(idx) = f { *idx == main_idx } else { false }) + }) + .count(); #[allow(clippy::cast_precision_loss)] let main_ratio = main_count as f64 / self.samples.len() as f64; if main_ratio < 0.9 { - eprintln!("Warning: This trace appears to be invalid. The `main` function is present in only {:.2}% of the samples, this is likely caused by the using the wrong Elf file", main_ratio * 100.0); + eprintln!( + "Warning: This trace appears to be invalid. The `main` function is present in only {:.2}% of the samples, this is likely caused by the using the wrong Elf file", + main_ratio * 100.0 + ); } } } diff --git a/crates/core/executor/src/syscalls/precompiles/edwards/decompress.rs b/crates/core/executor/src/syscalls/precompiles/edwards/decompress.rs index 6e790ab133..12276aa181 100644 --- a/crates/core/executor/src/syscalls/precompiles/edwards/decompress.rs +++ b/crates/core/executor/src/syscalls/precompiles/edwards/decompress.rs @@ -53,7 +53,8 @@ impl Syscall for EdwardsDecompressSyscall { // Compute actual decompressed X let compressed_y = CompressedEdwardsY(compressed_edwards_y); - let decompressed = decompress(&compressed_y); + let decompressed = + decompress(&compressed_y).expect("Decompression failed, syscall invariant violated."); let mut decompressed_x_bytes = decompressed.x.to_bytes_le(); decompressed_x_bytes.resize(32, 0u8); diff --git a/crates/core/machine/src/operations/field/field_sqrt.rs b/crates/core/machine/src/operations/field/field_sqrt.rs index a0f40c6a48..dbe4e4806a 100644 --- a/crates/core/machine/src/operations/field/field_sqrt.rs +++ b/crates/core/machine/src/operations/field/field_sqrt.rs @@ -224,7 +224,11 @@ mod tests { let mut row = [F::zero(); NUM_TEST_COLS]; let cols: &mut TestCols = row.as_mut_slice().borrow_mut(); cols.a = P::to_limbs_field::(a); - cols.sqrt.populate(&mut blu_events, 1, a, ed25519_sqrt); + cols.sqrt.populate(&mut blu_events, 1, a, |p| { + ed25519_sqrt(p).expect( + "By now we should have validated the sqrt exists, this is a bug", + ) + }); output.add_byte_lookup_events(blu_events); row }) diff --git a/crates/core/machine/src/syscall/precompiles/edwards/ed_decompress.rs b/crates/core/machine/src/syscall/precompiles/edwards/ed_decompress.rs index 51b3f32e59..e38d9fcaa7 100644 --- a/crates/core/machine/src/syscall/precompiles/edwards/ed_decompress.rs +++ b/crates/core/machine/src/syscall/precompiles/edwards/ed_decompress.rs @@ -99,7 +99,9 @@ impl EdDecompressCols { let dyy = self.dyy.populate(blu_events, shard, &E::d_biguint(), &yy, FieldOperation::Mul); let v = self.v.populate(blu_events, shard, &one, &dyy, FieldOperation::Add); let u_div_v = self.u_div_v.populate(blu_events, shard, &u, &v, FieldOperation::Div); - let x = self.x.populate(blu_events, shard, &u_div_v, ed25519_sqrt); + let x = self.x.populate(blu_events, shard, &u_div_v, |p| { + ed25519_sqrt(p).expect("ed25519_sqrt failed, syscall invariant violated") + }); self.neg_x.populate(blu_events, shard, &BigUint::zero(), &x, FieldOperation::Sub); } } diff --git a/crates/cuda/src/lib.rs b/crates/cuda/src/lib.rs index 3493f6a58c..63495c6129 100644 --- a/crates/cuda/src/lib.rs +++ b/crates/cuda/src/lib.rs @@ -367,7 +367,7 @@ impl Middleware for LoggingMiddleware { #[cfg(test)] mod tests { use sp1_core_machine::{reduce::SP1ReduceProof, utils::setup_logger}; - use sp1_prover::{components::DefaultProverComponents, InnerSC, SP1CoreProof, SP1Prover}; + use sp1_prover::{components::CpuProverComponents, InnerSC, SP1CoreProof, SP1Prover}; use test_artifacts::FIBONACCI_ELF; use twirp::{url::Url, Client}; @@ -380,7 +380,7 @@ mod tests { fn test_client() { setup_logger(); - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); let client = SP1CudaProver::new().expect("Failed to create SP1CudaProver"); let (pk, vk) = prover.setup(FIBONACCI_ELF); @@ -414,7 +414,7 @@ mod tests { let client = Client::from_base_url(Url::parse("http://localhost:3000/twirp/").unwrap()).unwrap(); - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); let (pk, vk) = prover.setup(FIBONACCI_ELF); let payload = ProveCoreRequestPayload { pk, stdin: SP1Stdin::new() }; let request = diff --git a/crates/curves/Cargo.toml b/crates/curves/Cargo.toml index c656dbd02b..8242decfaf 100644 --- a/crates/curves/Cargo.toml +++ b/crates/curves/Cargo.toml @@ -13,7 +13,6 @@ categories = { workspace = true } num = "0.4.3" serde = { workspace = true, features = ["derive"] } typenum = "1.17.0" -curve25519-dalek = { version = "4.1.2" } k256 = { version = "0.13.3", features = ["expose-field"] } p256 = { version = "0.13.2", features = ["expose-field"] } generic-array = { version = "1.1.0", features = ["alloc", "serde"] } diff --git a/crates/curves/src/edwards/ed25519.rs b/crates/curves/src/edwards/ed25519.rs index c2a823c603..4d1be91ac0 100644 --- a/crates/curves/src/edwards/ed25519.rs +++ b/crates/curves/src/edwards/ed25519.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use curve25519_dalek::edwards::CompressedEdwardsY; +use crate::curve25519_dalek::CompressedEdwardsY; use generic_array::GenericArray; use num::{BigUint, Num, One}; use serde::{Deserialize, Serialize}; @@ -72,7 +72,7 @@ impl EdwardsParameters for Ed25519Parameters { /// /// This function always returns the nonnegative square root, in the sense that the least /// significant bit of the result is always 0. -pub fn ed25519_sqrt(a: &BigUint) -> BigUint { +pub fn ed25519_sqrt(a: &BigUint) -> Option { // Here is a description of how to calculate sqrt in the Curve25519 base field: // ssh://git@github.com/succinctlabs/curve25519-dalek/blob/ // e2d1bd10d6d772af07cac5c8161cd7655016af6d/curve25519-dalek/src/field.rs#L256 @@ -108,7 +108,7 @@ pub fn ed25519_sqrt(a: &BigUint) -> BigUint { let flipped_sign_sqrt = beta_squared == neg_a; if !correct_sign_sqrt && !flipped_sign_sqrt { - panic!("a is not a square"); + return None; } let beta_bytes = beta.to_bytes_le(); @@ -116,10 +116,10 @@ pub fn ed25519_sqrt(a: &BigUint) -> BigUint { beta = (&modulus - &beta) % &modulus; } - beta + Some(beta) } -pub fn decompress(compressed_point: &CompressedEdwardsY) -> AffinePoint { +pub fn decompress(compressed_point: &CompressedEdwardsY) -> Option> { let mut point_bytes = *compressed_point.as_bytes(); let sign = point_bytes[31] >> 7 == 1; // mask out the sign bit @@ -134,7 +134,7 @@ pub fn decompress(compressed_point: &CompressedEdwardsY) -> AffinePoint let v_inv = v.modpow(&(modulus - BigUint::from(2u64)), modulus); let u_div_v = (u * &v_inv) % modulus; - let mut x = ed25519_sqrt(&u_div_v); + let mut x = ed25519_sqrt(&u_div_v)?; // sqrt always returns the nonnegative square root, // so we negate according to the supplied sign bit. @@ -142,7 +142,7 @@ pub fn decompress(compressed_point: &CompressedEdwardsY) -> AffinePoint x = modulus - &x; } - AffinePoint::new(x, y.clone()) + Some(AffinePoint::new(x, y.clone())) } #[cfg(test)] @@ -178,7 +178,7 @@ mod tests { CompressedEdwardsY(compressed) }; - assert_eq!(point, decompress(&compressed_point)); + assert_eq!(point, decompress(&compressed_point).unwrap()); // Double the point to create a "random" point for the next iteration. point = point.clone() + point.clone(); diff --git a/crates/curves/src/lib.rs b/crates/curves/src/lib.rs index c3f66d9eac..84a1aad0b8 100644 --- a/crates/curves/src/lib.rs +++ b/crates/curves/src/lib.rs @@ -7,7 +7,39 @@ pub mod utils; pub mod weierstrass; pub mod curve25519_dalek { - pub use curve25519_dalek::edwards::CompressedEdwardsY; + /// In "Edwards y" / "Ed25519" format, the curve point \\((x,y)\\) is + /// determined by the \\(y\\)-coordinate and the sign of \\(x\\). + /// + /// The first 255 bits of a `CompressedEdwardsY` represent the + /// \\(y\\)-coordinate. The high bit of the 32nd byte gives the sign of \\(x\\). + /// + /// Note: This is taken from the `curve25519-dalek` crate. + #[derive(Copy, Clone, Eq, PartialEq, Hash)] + pub struct CompressedEdwardsY(pub [u8; 32]); + + impl CompressedEdwardsY { + /// View this `CompressedEdwardsY` as a byte array. + pub fn as_bytes(&self) -> &[u8; 32] { + &self.0 + } + + /// Consume this `CompressedEdwardsY` and return the underlying byte array. + pub fn to_bytes(&self) -> [u8; 32] { + self.0 + } + + /// Construct a `CompressedEdwardsY` from a slice of bytes. + /// + /// # Errors + /// + /// Returns [`TryFromSliceError`] if the input `bytes` slice does not have + /// a length of 32. + pub fn from_slice( + bytes: &[u8], + ) -> Result { + bytes.try_into().map(CompressedEdwardsY) + } + } } pub mod k256 { diff --git a/crates/eval/src/main.rs b/crates/eval/src/main.rs index ca0e75a37b..8c7ca4e00d 100644 --- a/crates/eval/src/main.rs +++ b/crates/eval/src/main.rs @@ -1,10 +1,10 @@ use anyhow::Result; use sp1_eval::evaluate_performance; -use sp1_prover::components::DefaultProverComponents; +use sp1_prover::components::CpuProverComponents; use sp1_stark::SP1ProverOpts; #[tokio::main] async fn main() -> Result<(), Box> { let opts = SP1ProverOpts::default(); - evaluate_performance::(opts).await + evaluate_performance::(opts).await } diff --git a/crates/perf/Cargo.toml b/crates/perf/Cargo.toml index 38300783fe..c9ffb2970d 100644 --- a/crates/perf/Cargo.toml +++ b/crates/perf/Cargo.toml @@ -24,4 +24,4 @@ time = "0.3.26" [features] native-gnark = ["sp1-sdk/native-gnark"] -network-v2 = ["sp1-sdk/network-v2"] +network = ["sp1-sdk/network"] diff --git a/crates/perf/src/main.rs b/crates/perf/src/main.rs index 31a34c52ed..04ca613173 100644 --- a/crates/perf/src/main.rs +++ b/crates/perf/src/main.rs @@ -1,13 +1,10 @@ -use std::{ - env, - time::{Duration, Instant}, -}; +use std::time::{Duration, Instant}; use clap::{command, Parser}; use sp1_cuda::SP1CudaProver; use sp1_prover::HashableKey; -use sp1_prover::{components::DefaultProverComponents, ProverMode}; -use sp1_sdk::{self, ProverClient, SP1Context, SP1Prover, SP1Stdin}; +use sp1_prover::{components::CpuProverComponents, ProverMode}; +use sp1_sdk::{self, Prover, ProverClient, SP1Context, SP1Prover, SP1Stdin}; use sp1_stark::SP1ProverOpts; use test_artifacts::VERIFY_PROOF_ELF; @@ -52,7 +49,7 @@ fn main() { let stdin = std::fs::read(args.stdin).expect("failed to read stdin"); let stdin: SP1Stdin = bincode::deserialize(&stdin).expect("failed to deserialize stdin"); - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); let (pk, vk) = prover.setup(&elf); let cycles = sp1_prover::utils::get_cycles(&elf, &stdin); let opts = SP1ProverOpts::default(); @@ -176,31 +173,18 @@ fn main() { println!("{:?}", result); } ProverMode::Network => { - let private_key = env::var("SP1_PRIVATE_KEY") - .expect("SP1_PRIVATE_KEY must be set for remote proving"); - let rpc_url = env::var("PROVER_NETWORK_RPC").ok(); - let skip_simulation = - env::var("SKIP_SIMULATION").map(|val| val == "true").unwrap_or_default(); + let prover = ProverClient::builder().network().build(); + let (_, _) = time_operation(|| prover.execute(&elf, &stdin)); - let mut prover_builder = ProverClient::builder().mode(ProverMode::Network); - - if let Some(rpc_url) = rpc_url { - prover_builder = prover_builder.rpc_url(rpc_url); - } - - if skip_simulation { - prover_builder = prover_builder.skip_simulation(); - } - - let prover = prover_builder.private_key(private_key).build(); - let (_, _) = time_operation(|| prover.execute(&elf, stdin.clone())); - - let (proof, _) = - time_operation(|| prover.prove(&pk, stdin.clone()).groth16().run().unwrap()); + let (proof, _) = time_operation(|| { + prover.prove(&pk, stdin.clone()).groth16().skip_simulation(true).run().unwrap() + }); let (_, _) = time_operation(|| prover.verify(&proof, &vk)); - let (proof, _) = time_operation(|| prover.prove(&pk, stdin).plonk().run().unwrap()); + let (proof, _) = time_operation(|| { + prover.prove(&pk, stdin).plonk().skip_simulation(true).run().unwrap() + }); let (_, _) = time_operation(|| prover.verify(&proof, &vk)); } diff --git a/crates/prover/scripts/build_compress_vks.rs b/crates/prover/scripts/build_compress_vks.rs index 0f8c5a0d08..2b700369f5 100644 --- a/crates/prover/scripts/build_compress_vks.rs +++ b/crates/prover/scripts/build_compress_vks.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use clap::Parser; use sp1_core_machine::utils::setup_logger; use sp1_prover::{ - components::DefaultProverComponents, shapes::build_vk_map_to_file, REDUCE_BATCH_SIZE, + components::CpuProverComponents, shapes::build_vk_map_to_file, REDUCE_BATCH_SIZE, }; #[derive(Parser, Debug)] @@ -37,7 +37,7 @@ fn main() { let range_start = args.start; let range_end = args.end; - build_vk_map_to_file::( + build_vk_map_to_file::( build_dir, reduce_batch_size, dummy, diff --git a/crates/prover/scripts/fibonacci_groth16.rs b/crates/prover/scripts/fibonacci_groth16.rs index 4ca51b00af..cbbc068593 100644 --- a/crates/prover/scripts/fibonacci_groth16.rs +++ b/crates/prover/scripts/fibonacci_groth16.rs @@ -5,7 +5,7 @@ use std::time::Instant; use itertools::iproduct; use sp1_core_executor::SP1Context; use sp1_core_machine::io::SP1Stdin; -use sp1_prover::components::DefaultProverComponents; +use sp1_prover::components::CpuProverComponents; use sp1_prover::SP1Prover; use sp1_stark::SP1ProverOpts; use tracing_subscriber::fmt::format::FmtSpan; @@ -38,7 +38,7 @@ fn main() { std::env::set_var("RECONSTRUCT_COMMITMENTS", "false"); // Initialize prover. - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); // Setup sweep. let iterations = [480000u32]; diff --git a/crates/prover/scripts/fibonacci_sweep.rs b/crates/prover/scripts/fibonacci_sweep.rs index 5321d4cf71..6d09967a54 100644 --- a/crates/prover/scripts/fibonacci_sweep.rs +++ b/crates/prover/scripts/fibonacci_sweep.rs @@ -5,7 +5,7 @@ use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; use sp1_core_executor::SP1Context; use sp1_core_machine::io::SP1Stdin; -use sp1_prover::components::DefaultProverComponents; +use sp1_prover::components::CpuProverComponents; use sp1_prover::SP1Prover; use sp1_stark::SP1ProverOpts; use tracing_subscriber::EnvFilter; @@ -37,7 +37,7 @@ fn main() { std::env::set_var("RECONSTRUCT_COMMITMENTS", "false"); // Initialize prover. - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); // Setup sweep. let iterations = [480000u32]; diff --git a/crates/prover/scripts/tendermint_sweep.rs b/crates/prover/scripts/tendermint_sweep.rs index bb80f848ea..184e188dd5 100644 --- a/crates/prover/scripts/tendermint_sweep.rs +++ b/crates/prover/scripts/tendermint_sweep.rs @@ -5,7 +5,7 @@ use std::{fs::File, io::BufWriter, io::Write, time::Instant}; use itertools::iproduct; use sp1_core_executor::SP1Context; use sp1_core_machine::io::SP1Stdin; -use sp1_prover::components::DefaultProverComponents; +use sp1_prover::components::CpuProverComponents; use sp1_prover::SP1Prover; use sp1_stark::SP1ProverOpts; use tracing_subscriber::EnvFilter; @@ -37,7 +37,7 @@ fn main() { std::env::set_var("RECONSTRUCT_COMMITMENTS", "false"); // Initialize prover. - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); // Setup sweep. let iterations = [480000u32]; diff --git a/crates/prover/src/components.rs b/crates/prover/src/components.rs index e88dd87ceb..12bd26e56e 100644 --- a/crates/prover/src/components.rs +++ b/crates/prover/src/components.rs @@ -25,9 +25,9 @@ pub trait SP1ProverComponents: Send + Sync { + Sync; } -pub struct DefaultProverComponents; +pub struct CpuProverComponents; -impl SP1ProverComponents for DefaultProverComponents { +impl SP1ProverComponents for CpuProverComponents { type CoreProver = CpuProver::Val>>; type CompressProver = CpuProver::Val>>; type ShrinkProver = CpuProver::Val>>; diff --git a/crates/prover/src/lib.rs b/crates/prover/src/lib.rs index 844a5feb3c..f1d517ebd0 100644 --- a/crates/prover/src/lib.rs +++ b/crates/prover/src/lib.rs @@ -81,7 +81,7 @@ use tracing::instrument; pub use types::*; use utils::{sp1_committed_values_digest_bn254, sp1_vkey_digest_bn254, words_to_bytes}; -use components::{DefaultProverComponents, SP1ProverComponents}; +use components::{CpuProverComponents, SP1ProverComponents}; pub use sp1_core_machine::SP1_CIRCUIT_VERSION; @@ -114,8 +114,20 @@ pub type CompressAir = RecursionAir; pub type ShrinkAir = RecursionAir; pub type WrapAir = RecursionAir; +#[allow(clippy::type_complexity)] +enum TracesOrInput { + ProgramRecordTraces( + Box<( + Arc>, + ExecutionRecord, + Vec<(String, RowMajorMatrix)>, + )>, + ), + CircuitWitness(Box), +} + /// A end-to-end prover implementation for the SP1 RISC-V zkVM. -pub struct SP1Prover { +pub struct SP1Prover { /// The machine used for proving the core step. pub core_prover: C::CoreProver, @@ -667,7 +679,7 @@ impl SP1Prover { // Spawn a worker that sends the first layer inputs to a bounded channel. let input_sync = Arc::new(TurnBasedSync::new()); - let (input_tx, input_rx) = sync_channel::<(usize, usize, SP1CircuitWitness)>( + let (input_tx, input_rx) = sync_channel::<(usize, usize, SP1CircuitWitness, bool)>( opts.recursion_opts.checkpoints_channel_capacity, ); let input_tx = Arc::new(Mutex::new(input_tx)); @@ -677,7 +689,7 @@ impl SP1Prover { s.spawn(move || { for (index, input) in first_layer_inputs.into_iter().enumerate() { input_sync.wait_for_turn(index); - input_tx.lock().unwrap().send((index, 0, input)).unwrap(); + input_tx.lock().unwrap().send((index, 0, input, false)).unwrap(); input_sync.advance_turn(); } }); @@ -686,13 +698,9 @@ impl SP1Prover { // Spawn workers who generate the records and traces. let record_and_trace_sync = Arc::new(TurnBasedSync::new()); let (record_and_trace_tx, record_and_trace_rx) = - sync_channel::<( - usize, - usize, - Arc>, - ExecutionRecord, - Vec<(String, RowMajorMatrix)>, - )>(opts.recursion_opts.records_and_traces_channel_capacity); + sync_channel::<(usize, usize, TracesOrInput)>( + opts.recursion_opts.records_and_traces_channel_capacity, + ); let record_and_trace_tx = Arc::new(Mutex::new(record_and_trace_tx)); let record_and_trace_rx = Arc::new(Mutex::new(record_and_trace_rx)); let input_rx = Arc::new(Mutex::new(input_rx)); @@ -705,7 +713,7 @@ impl SP1Prover { let _span = span.enter(); loop { let received = { input_rx.lock().unwrap().recv() }; - if let Ok((index, height, input)) = received { + if let Ok((index, height, input, false)) = received { // Get the program and witness stream. let (program, witness_stream) = tracing::debug_span!( "get program and witness stream" @@ -776,7 +784,29 @@ impl SP1Prover { record_and_trace_tx .lock() .unwrap() - .send((index, height, program, record, traces)) + .send(( + index, + height, + TracesOrInput::ProgramRecordTraces(Box::new(( + program, record, traces, + ))), + )) + .unwrap(); + + // Advance the turn. + record_and_trace_sync.advance_turn(); + } else if let Ok((index, height, input, true)) = received { + record_and_trace_sync.wait_for_turn(index); + + // Send the record and traces to the worker. + record_and_trace_tx + .lock() + .unwrap() + .send(( + index, + height, + TracesOrInput::CircuitWitness(Box::new(input)), + )) .unwrap(); // Advance the turn. @@ -806,7 +836,8 @@ impl SP1Prover { let _span = span.enter(); loop { let received = { record_and_trace_rx.lock().unwrap().recv() }; - if let Ok((index, height, program, record, traces)) = received { + if let Ok((index, height, TracesOrInput::ProgramRecordTraces(boxed_prt))) = received { + let (program, record, traces) = *boxed_prt; tracing::debug_span!("batch").in_scope(|| { // Get the keys. let (pk, vk) = tracing::debug_span!("Setup compress program") @@ -874,7 +905,22 @@ impl SP1Prover { // Advance the turn. prover_sync.advance_turn(); }); - } else { + } else if let Ok((index, height, TracesOrInput::CircuitWitness(witness_box))) = received { + let witness = *witness_box; + if let SP1CircuitWitness::Compress(inner_witness) = witness { + let SP1CompressWitnessValues { vks_and_proofs, is_complete: _ } = inner_witness; + assert!(vks_and_proofs.len()==1); + let (vk, proof) = vks_and_proofs.last().unwrap(); + // Wait for our turn to update the state. + prover_sync.wait_for_turn(index); + + // Send the proof. + proofs_tx.lock().unwrap().send((index, height, vk.clone(), proof.clone())).unwrap(); + + // Advance the turn. + prover_sync.advance_turn(); + } + } else { break; } } @@ -934,7 +980,7 @@ impl SP1Prover { input_tx .lock() .unwrap() - .send((count, next_input_height, input)) + .send((count, next_input_height, input, is_last)) .unwrap(); input_sync.advance_turn(); count += 1; @@ -1516,14 +1562,8 @@ pub mod tests { // TODO(mattstam): We should Test::Plonk here, but this uses the existing // docker image which has a different API than the current. So we need to wait until the // next release (v1.2.0+), and then switch it back. - let prover = SP1Prover::::new(); - test_e2e_prover::( - &prover, - elf, - SP1Stdin::default(), - opts, - Test::All, - ) + let prover = SP1Prover::::new(); + test_e2e_prover::(&prover, elf, SP1Stdin::default(), opts, Test::All) } /// Tests an end-to-end workflow of proving a program across the entire proof generation @@ -1532,13 +1572,13 @@ pub mod tests { #[serial] fn test_e2e_with_deferred_proofs() -> Result<()> { setup_logger(); - test_e2e_with_deferred_proofs_prover::(SP1ProverOpts::default()) + test_e2e_with_deferred_proofs_prover::(SP1ProverOpts::default()) } #[test] fn test_deterministic_setup() { setup_logger(); - let prover = SP1Prover::::new(); + let prover = SP1Prover::::new(); let program = test_artifacts::FIBONACCI_ELF; let (pk, _) = prover.setup(program); let pk2 = prover.setup(program).0; diff --git a/crates/recursion/gnark-ffi/src/proof.rs b/crates/recursion/gnark-ffi/src/proof.rs index ab4345241a..fa71022f42 100644 --- a/crates/recursion/gnark-ffi/src/proof.rs +++ b/crates/recursion/gnark-ffi/src/proof.rs @@ -6,7 +6,6 @@ pub enum ProofBn254 { Groth16(Groth16Bn254Proof), } -/// A zero-knowledge proof generated by the PLONK protocol with a Base64 encoded gnark PLONK proof. #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct PlonkBn254Proof { pub public_inputs: [String; 2], @@ -15,8 +14,6 @@ pub struct PlonkBn254Proof { pub plonk_vkey_hash: [u8; 32], } -/// A zero-knowledge proof generated by the Groth16 protocol with a Base64 encoded gnark Groth16 -/// proof. #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct Groth16Bn254Proof { pub public_inputs: [String; 2], diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 64e102189c..36a186db97 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -58,21 +58,11 @@ backoff = { version = "0.4", features = ["tokio"], optional = true } test-artifacts = { workspace = true } [features] -default = ["network"] +default = ["cuda", "network"] native-gnark = ["sp1-prover/native-gnark"] # TODO: Once alloy has a 1.* release, we can likely remove this feature flag, as there will be less # dependency resolution issues. network = [ - "dep:prost", - "dep:alloy-sol-types", - "dep:tokio", - "dep:alloy-signer", - "dep:alloy-signer-local", - "dep:reqwest", - "dep:twirp", - "dep:reqwest-middleware", -] -network-v2 = [ "dep:prost", "dep:alloy-sol-types", "dep:alloy-signer", diff --git a/crates/sdk/src/action.rs b/crates/sdk/src/action.rs deleted file mode 100644 index 58b38da010..0000000000 --- a/crates/sdk/src/action.rs +++ /dev/null @@ -1,232 +0,0 @@ -use sp1_core_executor::{ExecutionReport, HookEnv, SP1ContextBuilder}; -use sp1_core_machine::io::SP1Stdin; -use sp1_primitives::io::SP1PublicValues; -use sp1_prover::{components::DefaultProverComponents, SP1ProvingKey}; - -use anyhow::{Ok, Result}; -use sp1_stark::{SP1CoreOpts, SP1ProverOpts}; -use std::time::Duration; - -use crate::{provers::ProofOpts, Prover, SP1ProofKind, SP1ProofWithPublicValues}; - -/// Builder to prepare and configure execution of a program on an input. -/// May be run with [Self::run]. -pub struct Execute<'a> { - prover: &'a dyn Prover, - context_builder: SP1ContextBuilder<'a>, - elf: &'a [u8], - stdin: SP1Stdin, -} - -impl<'a> Execute<'a> { - /// Prepare to execute the given program on the given input (without generating a proof). - /// - /// Prefer using [ProverClient::execute](super::ProverClient::execute). - /// See there for more documentation. - pub fn new( - prover: &'a dyn Prover, - elf: &'a [u8], - stdin: SP1Stdin, - ) -> Self { - Self { prover, elf, stdin, context_builder: Default::default() } - } - - /// Execute the program on the input, consuming the built action `self`. - pub fn run(self) -> Result<(SP1PublicValues, ExecutionReport)> { - let Self { prover, elf, stdin, mut context_builder } = self; - let context = context_builder.build(); - Ok(prover.sp1_prover().execute(elf, &stdin, context)?) - } - - /// Add a runtime [Hook](super::Hook) into the context. - /// - /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` - /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read - /// with successive calls to [`sp1_zkvm::io::read`]. - pub fn with_hook( - mut self, - fd: u32, - f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, - ) -> Self { - self.context_builder.hook(fd, f); - self - } - - /// Avoid registering the default hooks in the runtime. - /// - /// It is not necessary to call this to override hooks --- instead, simply - /// register a hook with the same value of `fd` by calling [`Self::with_hook`]. - pub fn without_default_hooks(mut self) -> Self { - self.context_builder.without_default_hooks(); - self - } - - /// Set the maximum number of cpu cycles to use for execution. - /// - /// If the cycle limit is exceeded, execution will return - /// [`sp1_core_executor::ExecutionError::ExceededCycleLimit`]. - pub fn max_cycles(mut self, max_cycles: u64) -> Self { - self.context_builder.max_cycles(max_cycles); - self - } - - /// Skip deferred proof verification. - pub fn set_skip_deferred_proof_verification(mut self, value: bool) -> Self { - self.context_builder.set_skip_deferred_proof_verification(value); - self - } -} - -/// Builder to prepare and configure proving execution of a program on an input. -/// May be run with [Self::run]. -pub struct Prove<'a> { - prover: &'a dyn Prover, - kind: SP1ProofKind, - context_builder: SP1ContextBuilder<'a>, - pk: &'a SP1ProvingKey, - stdin: SP1Stdin, - core_opts: SP1CoreOpts, - recursion_opts: SP1CoreOpts, - timeout: Option, -} - -impl<'a> Prove<'a> { - /// Prepare to prove the execution of the given program with the given input. - /// - /// Prefer using [ProverClient::prove](super::ProverClient::prove). - /// See there for more documentation. - pub fn new( - prover: &'a dyn Prover, - pk: &'a SP1ProvingKey, - stdin: SP1Stdin, - ) -> Self { - Self { - prover, - kind: Default::default(), - pk, - stdin, - context_builder: Default::default(), - core_opts: SP1CoreOpts::default(), - recursion_opts: SP1CoreOpts::recursion(), - timeout: None, - } - } - - /// Prove the execution of the program on the input, consuming the built action `self`. - pub fn run(self) -> Result { - let Self { - prover, - kind, - pk, - stdin, - mut context_builder, - core_opts, - recursion_opts, - timeout, - } = self; - let opts = SP1ProverOpts { core_opts, recursion_opts }; - let proof_opts = ProofOpts { sp1_prover_opts: opts, timeout }; - let context = context_builder.build(); - - // Dump the program and stdin to files for debugging if `SP1_DUMP` is set. - if std::env::var("SP1_DUMP") - .map(|v| v == "1" || v.to_lowercase() == "true") - .unwrap_or(false) - { - let program = pk.elf.clone(); - std::fs::write("program.bin", program).unwrap(); - let stdin = bincode::serialize(&stdin).unwrap(); - std::fs::write("stdin.bin", stdin.clone()).unwrap(); - } - - prover.prove(pk, stdin, proof_opts, context, kind) - } - - /// Set the proof kind to the core mode. This is the default. - pub fn core(mut self) -> Self { - self.kind = SP1ProofKind::Core; - self - } - - /// Set the proof kind to the compressed mode. - pub fn compressed(mut self) -> Self { - self.kind = SP1ProofKind::Compressed; - self - } - - /// Set the proof mode to the plonk bn254 mode. - pub fn plonk(mut self) -> Self { - self.kind = SP1ProofKind::Plonk; - self - } - - /// Set the proof mode to the groth16 bn254 mode. - pub fn groth16(mut self) -> Self { - self.kind = SP1ProofKind::Groth16; - self - } - - /// Add a runtime [Hook](super::Hook) into the context. - /// - /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` - /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read - /// with successive calls to [`sp1_zkvm::io::read`]. - pub fn with_hook( - mut self, - fd: u32, - f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, - ) -> Self { - self.context_builder.hook(fd, f); - self - } - - /// Avoid registering the default hooks in the runtime. - /// - /// It is not necessary to call this to override hooks --- instead, simply - /// register a hook with the same value of `fd` by calling [`Self::with_hook`]. - pub fn without_default_hooks(mut self) -> Self { - self.context_builder.without_default_hooks(); - self - } - - /// Set the shard size for proving. - pub fn shard_size(mut self, value: usize) -> Self { - self.core_opts.shard_size = value; - self - } - - /// Set the shard batch size for proving. - pub fn shard_batch_size(mut self, value: usize) -> Self { - self.core_opts.shard_batch_size = value; - self - } - - /// Set whether we should reconstruct commitments while proving. - pub fn reconstruct_commitments(mut self, value: bool) -> Self { - self.core_opts.reconstruct_commitments = value; - self - } - - /// Set the maximum number of cpu cycles to use for execution. - /// - /// If the cycle limit is exceeded, execution will return - /// [`sp1_core_executor::ExecutionError::ExceededCycleLimit`]. - pub fn cycle_limit(mut self, cycle_limit: u64) -> Self { - self.context_builder.max_cycles(cycle_limit); - self - } - - /// Set the timeout for the proof's generation. - /// - /// This parameter is only used when the prover is run in network mode. - pub fn timeout(mut self, timeout: Duration) -> Self { - self.timeout = Some(timeout); - self - } - - /// Set the skip deferred proof verification flag. - pub fn set_skip_deferred_proof_verification(mut self, value: bool) -> Self { - self.context_builder.set_skip_deferred_proof_verification(value); - self - } -} diff --git a/crates/sdk/src/artifacts.rs b/crates/sdk/src/artifacts.rs index 2ed25462c0..f287e9a874 100644 --- a/crates/sdk/src/artifacts.rs +++ b/crates/sdk/src/artifacts.rs @@ -1,18 +1,13 @@ +//! # SP1 Artifacts +//! +//! A library for exporting the SP1 artifacts to the specified output directory. + use std::path::PathBuf; use anyhow::{Context, Result}; -#[cfg(any(feature = "network", feature = "network-v2"))] -use { - futures::StreamExt, - indicatif::{ProgressBar, ProgressStyle}, - reqwest::Client, - std::{cmp::min, fs::File, io::Write}, -}; - -pub use sp1_prover::build::build_plonk_bn254_artifacts_with_dummy; - use crate::install::try_install_circuit_artifacts; +pub use sp1_prover::build::build_plonk_bn254_artifacts_with_dummy; /// Exports the solidity verifier for PLONK proofs to the specified output directory. /// @@ -71,35 +66,3 @@ pub fn export_solidity_groth16_bn254_verifier(output_dir: impl Into) -> Ok(()) } - -#[cfg(any(feature = "network", feature = "network-v2"))] -pub async fn download_file( - client: &Client, - url: &str, - file: &mut File, -) -> std::result::Result<(), String> { - let res = client.get(url).send().await.or(Err(format!("Failed to GET from '{}'", &url)))?; - let total_size = - res.content_length().ok_or(format!("Failed to get content length from '{}'", &url))?; - - let pb = ProgressBar::new(total_size); - pb.set_style(ProgressStyle::default_bar() - .template("{msg}\n{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta})").unwrap() - .progress_chars("#>-")); - println!("Downloading {}", url); - - let mut downloaded: u64 = 0; - let mut stream = res.bytes_stream(); - - while let Some(item) = stream.next().await { - let chunk = item.or(Err("Error while downloading file"))?; - file.write_all(&chunk).or(Err("Error while writing to file"))?; - let new = min(downloaded + (chunk.len() as u64), total_size); - downloaded = new; - pb.set_position(new); - } - - let msg = format!("Downloaded {} to {:?}", url, file); - pb.finish_with_message(msg); - Ok(()) -} diff --git a/crates/sdk/src/client.rs b/crates/sdk/src/client.rs new file mode 100644 index 0000000000..b0d20c6dc9 --- /dev/null +++ b/crates/sdk/src/client.rs @@ -0,0 +1,136 @@ +//! # SP1 Prover Client +//! +//! A client for interacting with the prover for the SP1 RISC-V zkVM. + +use crate::cpu::builder::CpuProverBuilder; +use crate::cuda::builder::CudaProverBuilder; +use crate::env::EnvProver; +use crate::network::builder::NetworkProverBuilder; + +/// An entrypoint for interacting with the prover for the SP1 RISC-V zkVM. +pub struct ProverClient; + +impl ProverClient { + /// Creates a new [`EnvProver`] from the environment. + /// + /// # Example + /// ```no_run + /// use sp1_sdk::ProverClient; + /// + /// std::env::set_var("SP1_PROVER", "network"); + /// std::env::set_var("NETWORK_PRIVATE_KEY", "..."); + /// std::env::set_var("NETWORK_RPC_URL", "..."); + /// let prover = ProverClient::from_env(); + /// ``` + #[deprecated(since = "4.0.0", note = "use `ProverClient::from_env()` instead")] + #[allow(clippy::new_ret_no_self)] + #[must_use] + pub fn new() -> EnvProver { + Self::from_env() + } + + /// Builds an [`EnvProver`], which loads the mode and any settings from the environment. + /// + /// # Usage + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// std::env::set_var("SP1_PROVER", "network"); + /// std::env::set_var("NETWORK_PRIVATE_KEY", "..."); + /// let prover = ProverClient::from_env(); + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let (pk, vk) = prover.setup(elf); + /// let proof = prover.prove(&pk, &stdin).compressed().run().unwrap(); + /// ``` + #[must_use] + pub fn from_env() -> EnvProver { + EnvProver::new() + } + + /// Creates a new [`ProverClientBuilder`] so that you can configure the prover client. + #[must_use] + pub fn builder() -> ProverClientBuilder { + ProverClientBuilder + } +} + +/// A builder to define which proving client to use. +pub struct ProverClientBuilder; + +impl ProverClientBuilder { + /// Builds a [`CpuProver`] specifically for mock proving. + /// + /// # Example + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let prover = ProverClient::builder().mock().build(); + /// let (pk, vk) = prover.setup(elf); + /// let proof = prover.prove(&pk, &stdin).compressed().run().unwrap(); + /// ``` + #[must_use] + pub fn mock(&self) -> CpuProverBuilder { + CpuProverBuilder { mock: true } + } + + /// Builds a [`CpuProver`] specifically for local CPU proving. + /// + /// # Usage + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let prover = ProverClient::builder().cpu().build(); + /// let (pk, vk) = prover.setup(elf); + /// let proof = prover.prove(&pk, &stdin).compressed().run().unwrap(); + /// ``` + #[must_use] + pub fn cpu(&self) -> CpuProverBuilder { + CpuProverBuilder { mock: false } + } + + /// Builds a [`CudaProver`] specifically for local proving on NVIDIA GPUs. + /// + /// # Example + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let prover = ProverClient::builder().cuda().build(); + /// let (pk, vk) = prover.setup(elf); + /// let proof = prover.prove(&pk, &stdin).compressed().run().unwrap(); + /// ``` + #[must_use] + pub fn cuda(&self) -> CudaProverBuilder { + CudaProverBuilder + } + + /// Builds a [`NetworkProver`] specifically for proving on the network. + /// + /// # Example + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let prover = ProverClient::builder().network().build(); + /// let (pk, vk) = prover.setup(elf); + /// let proof = prover.prove(&pk, &stdin).compressed().run().unwrap(); + /// ``` + #[cfg(feature = "network")] + #[must_use] + pub fn network(&self) -> NetworkProverBuilder { + NetworkProverBuilder { private_key: None, rpc_url: None } + } +} diff --git a/crates/sdk/src/cpu/builder.rs b/crates/sdk/src/cpu/builder.rs new file mode 100644 index 0000000000..3bd17ebc2f --- /dev/null +++ b/crates/sdk/src/cpu/builder.rs @@ -0,0 +1,31 @@ +//! # CPU Prover Builder +//! +//! This module provides a builder for the [`CpuProver`]. + +use super::CpuProver; + +/// A builder for the [`CpuProver`]. +/// +/// The builder is used to configure the [`CpuProver`] before it is built. +pub struct CpuProverBuilder { + pub(crate) mock: bool, +} + +impl CpuProverBuilder { + /// Builds a [`CpuProver`]. + /// + /// # Details + /// This method will build a [`CpuProver`] with the given parameters. In particular, it will + /// build a mock prover if the `mock` flag is set. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::ProverClient; + /// + /// let prover = ProverClient::builder().mock().build(); + /// ``` + #[must_use] + pub fn build(self) -> CpuProver { + if self.mock { CpuProver::mock() } else { CpuProver::new() } + } +} diff --git a/crates/sdk/src/cpu/execute.rs b/crates/sdk/src/cpu/execute.rs new file mode 100644 index 0000000000..4a9ab56b8c --- /dev/null +++ b/crates/sdk/src/cpu/execute.rs @@ -0,0 +1,138 @@ +//! # CPU Execution +//! +//! This module provides a builder for simulating the execution of a program on the CPU. + +use anyhow::Result; +use sp1_core_executor::{ExecutionReport, HookEnv, SP1ContextBuilder}; +use sp1_core_machine::io::SP1Stdin; +use sp1_primitives::io::SP1PublicValues; +use sp1_prover::{components::CpuProverComponents, SP1Prover}; + +/// A builder for simulating the execution of a program on the CPU. +/// +/// This builder providers a typed interface for configuring the SP1 RISC-V executor. The builder +/// is used for all the different variants of the [`crate::ProverClient`]. +pub struct CpuExecuteBuilder<'a> { + pub(crate) elf: &'a [u8], + pub(crate) stdin: SP1Stdin, + pub(crate) prover: &'a SP1Prover, + pub(crate) context_builder: SP1ContextBuilder<'a>, +} + +impl<'a> CpuExecuteBuilder<'a> { + /// Add a executor [`sp1_core_executor::Hook`] into the context. + /// + /// # Arguments + /// * `fd` - The file descriptor that triggers this execution hook. + /// * `f` - The function to invoke when the hook is triggered. + /// + /// # Details + /// Hooks may be invoked from within SP1 by writing to the specified file descriptor `fd` + /// with [`sp1_zkvm::io::write`], returning a list of arbitrary data that may be read + /// with successive calls to [`sp1_zkvm::io::read`]. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let builder = client.execute(elf, &stdin) + /// .with_hook(1, |env, data| { + /// println!("Hook triggered with data: {:?}", data); + /// vec![vec![1, 2, 3]] + /// }) + /// .run(); + /// ``` + #[must_use] + pub fn with_hook( + mut self, + fd: u32, + f: impl FnMut(HookEnv, &[u8]) -> Vec> + Send + Sync + 'a, + ) -> Self { + self.context_builder.hook(fd, f); + self + } + + /// Set the maximum number of cpu cycles to use for execution. + /// + /// # Arguments + /// * `max_cycles` - The maximum number of cycles to use for execution. + /// + /// # Details + /// If the cycle limit is exceeded, execution will fail with the + /// [`sp1_core_executor::ExecutionError::ExceededCycleLimit`]. This is useful for preventing + /// infinite loops in the and limiting the execution time of the program. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let builder = client.execute(elf, &stdin) + /// .cycle_limit(1000000) + /// .run(); + /// ``` + #[must_use] + pub fn cycle_limit(mut self, max_cycles: u64) -> Self { + self.context_builder.max_cycles(max_cycles); + self + } + + /// Whether to skip deferred proof verification in the executor. + /// + /// # Arguments + /// * `value` - Whether to skip deferred proof verification. + /// + /// # Details + /// If set to `true`, the executor will skip the deferred proof verification step. This is useful + /// for reducing the execution time of the program and optimistically assuming that the + /// deferred proofs are correct. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let builder = client.execute(elf, &stdin) + /// .deferred_proof_verification(false) + /// .run(); + /// ``` + #[must_use] + pub fn deferred_proof_verification(mut self, value: bool) -> Self { + self.context_builder.set_skip_deferred_proof_verification(!value); + self + } + + /// Executes the program on the input with the built arguments. + /// + /// # Details + /// This method will execute the program on the input with the built arguments. If the program + /// fails to execute, the method will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (public_values, execution_report) = client.execute(elf, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn run(self) -> Result<(SP1PublicValues, ExecutionReport)> { + let Self { prover, elf, stdin, mut context_builder } = self; + let context = context_builder.build(); + Ok(prover.execute(elf, &stdin, context)?) + } +} diff --git a/crates/sdk/src/cpu/mod.rs b/crates/sdk/src/cpu/mod.rs new file mode 100644 index 0000000000..c4038cae4a --- /dev/null +++ b/crates/sdk/src/cpu/mod.rs @@ -0,0 +1,342 @@ +//! # SP1 CPU Prover +//! +//! A prover that uses the CPU to execute and prove programs. + +pub mod builder; +pub mod execute; +pub mod prove; + +use anyhow::Result; +use execute::CpuExecuteBuilder; +use hashbrown::HashMap; +use p3_baby_bear::BabyBear; +use p3_field::{extension::BinomialExtensionField, AbstractField, PrimeField}; +use p3_fri::{FriProof, TwoAdicFriPcsProof}; +use prove::CpuProveBuilder; +use sp1_core_executor::{SP1Context, SP1ContextBuilder, SP1ReduceProof}; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::{ + components::CpuProverComponents, + verify::{verify_groth16_bn254_public_inputs, verify_plonk_bn254_public_inputs}, + Groth16Bn254Proof, HashableKey, PlonkBn254Proof, SP1CoreProofData, SP1ProofWithMetadata, + SP1Prover, +}; +use sp1_stark::{ + SP1CoreOpts, SP1ProverOpts, ShardCommitment, ShardOpenedValues, ShardProof, StarkVerifyingKey, +}; + +use crate::install::try_install_circuit_artifacts; +use crate::prover::verify_proof; +use crate::SP1VerificationError; +use crate::{ + Prover, SP1Proof, SP1ProofMode, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey, +}; + +/// A prover that uses the CPU to execute and prove programs. +pub struct CpuProver { + pub(crate) prover: SP1Prover, + pub(crate) mock: bool, +} + +impl CpuProver { + /// Creates a new [`CpuProver`]. + #[must_use] + pub fn new() -> Self { + Self::default() + } + + /// Creates a new [`CpuProver`] in mock mode. + #[must_use] + pub fn mock() -> Self { + Self { prover: SP1Prover::new(), mock: true } + } + + /// Creates a new [`CpuExecuteBuilder`] for simulating the execution of a program on the CPU. + /// + /// # Details + /// The builder is used for both the [`crate::cpu::CpuProver`] and [`crate::CudaProver`] client + /// types. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (public_values, execution_report) = client.execute(elf, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn execute<'a>(&'a self, elf: &'a [u8], stdin: &SP1Stdin) -> CpuExecuteBuilder<'a> { + CpuExecuteBuilder { + prover: &self.prover, + elf, + stdin: stdin.clone(), + context_builder: SP1ContextBuilder::default(), + } + } + + /// Creates a new [`CpuProveBuilder`] for proving a program on the CPU. + /// + /// # Details + /// The builder is used for only the [`crate::cpu::CpuProver`] client type. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + pub fn prove<'a>(&'a self, pk: &'a SP1ProvingKey, stdin: &SP1Stdin) -> CpuProveBuilder<'a> { + CpuProveBuilder { + prover: self, + mode: SP1ProofMode::Core, + pk, + stdin: stdin.clone(), + context_builder: SP1ContextBuilder::default(), + core_opts: SP1CoreOpts::default(), + recursion_opts: SP1CoreOpts::recursion(), + mock: self.mock, + } + } + + pub(crate) fn prove_impl<'a>( + &'a self, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + opts: SP1ProverOpts, + context: SP1Context<'a>, + mode: SP1ProofMode, + ) -> Result { + // If we're in mock mode, return a mock proof. + if self.mock { + return self.mock_prove_impl(pk, stdin.clone(), mode); + } + + // Generate the core proof. + let proof: SP1ProofWithMetadata = + self.prover.prove_core(pk, stdin, opts, context)?; + if mode == SP1ProofMode::Core { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Core(proof.proof.0), + public_values: proof.public_values, + sp1_version: self.version().to_string(), + }); + } + + // Generate the compressed proof. + let deferred_proofs = + stdin.proofs.iter().map(|(reduce_proof, _)| reduce_proof.clone()).collect(); + let public_values = proof.public_values.clone(); + let reduce_proof = self.prover.compress(&pk.vk, proof, deferred_proofs, opts)?; + if mode == SP1ProofMode::Compressed { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Compressed(Box::new(reduce_proof)), + public_values, + sp1_version: self.version().to_string(), + }); + } + + // Generate the shrink proof. + let compress_proof = self.prover.shrink(reduce_proof, opts)?; + + // Generate the wrap proof. + let outer_proof = self.prover.wrap_bn254(compress_proof, opts)?; + + // Generate the gnark proof. + match mode { + SP1ProofMode::Groth16 => { + let groth16_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::try_build_groth16_bn254_artifacts_dev( + &outer_proof.vk, + &outer_proof.proof, + ) + } else { + try_install_circuit_artifacts("groth16") + }; + + let proof = self.prover.wrap_groth16_bn254(outer_proof, &groth16_bn254_artifacts); + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Groth16(proof), + public_values, + sp1_version: self.version().to_string(), + }); + } + SP1ProofMode::Plonk => { + let plonk_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::try_build_plonk_bn254_artifacts_dev( + &outer_proof.vk, + &outer_proof.proof, + ) + } else { + try_install_circuit_artifacts("plonk") + }; + let proof = self.prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_artifacts); + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Plonk(proof), + public_values, + sp1_version: self.version().to_string(), + }); + } + _ => unreachable!(), + } + } + + #[allow(clippy::needless_pass_by_value)] + pub(crate) fn mock_prove_impl( + &self, + pk: &SP1ProvingKey, + stdin: SP1Stdin, + mode: SP1ProofMode, + ) -> Result { + let context = SP1Context::default(); + match mode { + SP1ProofMode::Core => { + let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Core(vec![]), + public_values, + sp1_version: self.version().to_string(), + }) + } + SP1ProofMode::Compressed => { + let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; + + let shard_proof = ShardProof { + commitment: ShardCommitment { + global_main_commit: [BabyBear::zero(); 8].into(), + local_main_commit: [BabyBear::zero(); 8].into(), + permutation_commit: [BabyBear::zero(); 8].into(), + quotient_commit: [BabyBear::zero(); 8].into(), + }, + opened_values: ShardOpenedValues { chips: vec![] }, + opening_proof: TwoAdicFriPcsProof { + fri_proof: FriProof { + commit_phase_commits: vec![], + query_proofs: vec![], + final_poly: BinomialExtensionField::default(), + pow_witness: BabyBear::zero(), + }, + query_openings: vec![], + }, + chip_ordering: HashMap::new(), + public_values: vec![], + }; + + let reduce_vk = StarkVerifyingKey { + commit: [BabyBear::zero(); 8].into(), + pc_start: BabyBear::zero(), + chip_information: vec![], + chip_ordering: HashMap::new(), + }; + + let proof = SP1Proof::Compressed(Box::new(SP1ReduceProof { + vk: reduce_vk, + proof: shard_proof, + })); + + Ok(SP1ProofWithPublicValues { + proof, + public_values, + sp1_version: self.version().to_string(), + }) + } + SP1ProofMode::Plonk => { + let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Plonk(PlonkBn254Proof { + public_inputs: [ + pk.vk.hash_bn254().as_canonical_biguint().to_string(), + public_values.hash_bn254().to_string(), + ], + encoded_proof: String::new(), + raw_proof: String::new(), + plonk_vkey_hash: [0; 32], + }), + public_values, + sp1_version: self.version().to_string(), + }) + } + SP1ProofMode::Groth16 => { + let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; + Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Groth16(Groth16Bn254Proof { + public_inputs: [ + pk.vk.hash_bn254().as_canonical_biguint().to_string(), + public_values.hash_bn254().to_string(), + ], + encoded_proof: String::new(), + raw_proof: String::new(), + groth16_vkey_hash: [0; 32], + }), + public_values, + sp1_version: self.version().to_string(), + }) + } + } + } + + fn mock_verify( + bundle: &SP1ProofWithPublicValues, + vkey: &SP1VerifyingKey, + ) -> Result<(), SP1VerificationError> { + match &bundle.proof { + SP1Proof::Plonk(PlonkBn254Proof { public_inputs, .. }) => { + verify_plonk_bn254_public_inputs(vkey, &bundle.public_values, public_inputs) + .map_err(SP1VerificationError::Plonk) + } + SP1Proof::Groth16(Groth16Bn254Proof { public_inputs, .. }) => { + verify_groth16_bn254_public_inputs(vkey, &bundle.public_values, public_inputs) + .map_err(SP1VerificationError::Groth16) + } + _ => Ok(()), + } + } +} + +impl Prover for CpuProver { + fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { + self.prover.setup(elf) + } + + fn inner(&self) -> &SP1Prover { + &self.prover + } + + fn prove( + &self, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + mode: SP1ProofMode, + ) -> Result { + self.prove_impl(pk, stdin, SP1ProverOpts::default(), SP1Context::default(), mode) + } + + fn verify( + &self, + bundle: &SP1ProofWithPublicValues, + vkey: &SP1VerifyingKey, + ) -> Result<(), SP1VerificationError> { + if self.mock { + tracing::warn!("using mock verifier"); + return Self::mock_verify(bundle, vkey); + } + verify_proof(self.inner(), self.version(), bundle, vkey) + } +} + +impl Default for CpuProver { + fn default() -> Self { + let prover = SP1Prover::new(); + Self { prover, mock: false } + } +} diff --git a/crates/sdk/src/cpu/prove.rs b/crates/sdk/src/cpu/prove.rs new file mode 100644 index 0000000000..4101a8071b --- /dev/null +++ b/crates/sdk/src/cpu/prove.rs @@ -0,0 +1,296 @@ +//! # CPU Proving +//! +//! This module provides a builder for proving a program on the CPU. + +use anyhow::Result; +use sp1_core_executor::SP1ContextBuilder; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::SP1ProvingKey; +use sp1_stark::{SP1CoreOpts, SP1ProverOpts}; + +use super::CpuProver; +use crate::{SP1ProofMode, SP1ProofWithPublicValues}; + +/// A builder for proving a program on the CPU. +/// +/// This builder provides a typed interface for configuring the SP1 RISC-V prover. The builder is +/// used for only the [`crate::cpu::CpuProver`] client type. +pub struct CpuProveBuilder<'a> { + pub(crate) prover: &'a CpuProver, + pub(crate) mode: SP1ProofMode, + pub(crate) context_builder: SP1ContextBuilder<'a>, + pub(crate) pk: &'a SP1ProvingKey, + pub(crate) stdin: SP1Stdin, + pub(crate) core_opts: SP1CoreOpts, + pub(crate) recursion_opts: SP1CoreOpts, + pub(crate) mock: bool, +} + +impl<'a> CpuProveBuilder<'a> { + /// Set the proof kind to [`SP1ProofKind::Core`] mode. + /// + /// # Details + /// This is the default mode for the prover. The proofs grow linearly in size with the number + /// of cycles. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + #[must_use] + pub fn core(mut self) -> Self { + self.mode = SP1ProofMode::Core; + self + } + + /// Set the proof kind to [`SP1ProofKind::Compressed`] mode. + /// + /// # Details + /// This mode produces a proof that is of constant size, regardless of the number of cycles. It + /// takes longer to prove than [`SP1ProofKind::Core`] due to the need to recursively aggregate + /// proofs into a single proof. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .compressed() + /// .run(); + /// ``` + #[must_use] + pub fn compressed(mut self) -> Self { + self.mode = SP1ProofMode::Compressed; + self + } + + /// Set the proof mode to [`SP1ProofKind::Plonk`] mode. + /// + /// # Details + /// This mode produces a const size PLONK proof that can be verified on chain for roughly ~300k + /// gas. This mode is useful for producing a maximally small proof that can be verified on + /// chain. For more efficient SNARK wrapping, you can use the [`SP1ProofKind::Groth16`] mode but + /// this mode is more . + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .plonk() + /// .run(); + /// ``` + #[must_use] + pub fn plonk(mut self) -> Self { + self.mode = SP1ProofMode::Plonk; + self + } + + /// Set the proof mode to [`SP1ProofKind::Groth16`] mode. + /// + /// # Details + /// This mode produces a Groth16 proof that can be verified on chain for roughly ~100k gas. This + /// mode is useful for producing a proof that can be verified on chain with minimal gas. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .groth16() + /// .run(); + /// ``` + #[must_use] + pub fn groth16(mut self) -> Self { + self.mode = SP1ProofMode::Groth16; + self + } + + /// Set the proof mode to the given [`SP1ProofKind`]. + /// + /// # Details + /// This method is useful for setting the proof mode to a custom mode. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover, SP1ProofMode}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .mode(SP1ProofMode::Groth16) + /// .run(); + /// ``` + #[must_use] + pub fn mode(mut self, mode: SP1ProofMode) -> Self { + self.mode = mode; + self + } + + /// Set the shard size for proving. + /// + /// # Details + /// The value should be 2^16, 2^17, ..., 2^22. You must be careful to set this value + /// correctly, as it will affect the memory usage of the prover and the recursion/verification + /// complexity. By default, the value is set to some predefined values that are optimized for performance + /// based on the available amount of RAM on the system. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .shard_size(1 << 16) + /// .run(); + /// ``` + #[must_use] + pub fn shard_size(mut self, value: usize) -> Self { + assert!(value.is_power_of_two(), "shard size must be a power of 2"); + self.core_opts.shard_size = value; + self + } + + /// Set the shard batch size for proving. + /// + /// # Details + /// This is the number of shards that are processed in a single batch in the prover. You should + /// probably not change this value unless you know what you are doing. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .shard_batch_size(4) + /// .run(); + /// ``` + #[must_use] + pub fn shard_batch_size(mut self, value: usize) -> Self { + self.core_opts.shard_batch_size = value; + self + } + + /// Set the maximum number of cpu cycles to use for execution. + /// + /// # Details + /// If the cycle limit is exceeded, execution will return + /// [`sp1_core_executor::ExecutionError::ExceededCycleLimit`]. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .cycle_limit(1000000) + /// .run(); + /// ``` + #[must_use] + pub fn cycle_limit(mut self, cycle_limit: u64) -> Self { + self.context_builder.max_cycles(cycle_limit); + self + } + + /// Set the skip deferred proof verification flag. + /// + /// # Details + /// If set to `true`, the prover will skip the deferred proof verification step in the executor. + /// This is useful for reducing the amount of time it takes to execute the program. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .deferred_proof_verification(false) + /// .run(); + /// ``` + #[must_use] + pub fn deferred_proof_verification(mut self, value: bool) -> Self { + self.context_builder.set_skip_deferred_proof_verification(value); + self + } + + /// Run the prover with the built arguments. + /// + /// # Details + /// This method will run the prover with the built arguments. If the prover fails to run, the + /// method will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn run(self) -> Result { + // Get the arguments. + let Self { prover, mode, pk, stdin, mut context_builder, core_opts, recursion_opts, mock } = + self; + let opts = SP1ProverOpts { core_opts, recursion_opts }; + let context = context_builder.build(); + + // Dump the program and stdin to files for debugging if `SP1_DUMP` is set. + crate::utils::sp1_dump(&pk.elf, &stdin); + + // Run the prover. + if mock { + prover.mock_prove_impl(pk, stdin, mode) + } else { + prover.prove_impl(pk, &stdin, opts, context, mode) + } + } +} diff --git a/crates/sdk/src/cuda/builder.rs b/crates/sdk/src/cuda/builder.rs new file mode 100644 index 0000000000..a447d3f78b --- /dev/null +++ b/crates/sdk/src/cuda/builder.rs @@ -0,0 +1,31 @@ +//! # CPU Prover Builder +//! +//! This module provides a builder for the [`CpuProver`]. + +use sp1_prover::SP1Prover; + +use super::CudaProver; + +/// A builder for the [`CudaProver`]. +/// +/// The builder is used to configure the [`CudaProver`] before it is built. +pub struct CudaProverBuilder; + +impl CudaProverBuilder { + /// Builds a [`CudaProver`]. + /// + /// # Details + /// This method will build a [`CudaProver`] with the given parameters. In particular, it will + /// build a mock prover if the `mock` flag is set. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::ProverClient; + /// + /// let prover = ProverClient::builder().cuda().build(); + /// ``` + #[must_use] + pub fn build(self) -> CudaProver { + CudaProver::new(SP1Prover::new()) + } +} diff --git a/crates/sdk/src/cuda/mod.rs b/crates/sdk/src/cuda/mod.rs new file mode 100644 index 0000000000..c20a8e6dfc --- /dev/null +++ b/crates/sdk/src/cuda/mod.rs @@ -0,0 +1,172 @@ +//! # SP1 CUDA Prover +//! +//! A prover that uses the CUDA to execute and prove programs. + +pub mod builder; +pub mod prove; + +use anyhow::Result; +use prove::CudaProveBuilder; +use sp1_core_executor::SP1ContextBuilder; +use sp1_core_machine::io::SP1Stdin; +use sp1_cuda::SP1CudaProver; +use sp1_prover::{components::CpuProverComponents, SP1Prover}; + +use crate::cpu::execute::CpuExecuteBuilder; +use crate::install::try_install_circuit_artifacts; +use crate::{ + Prover, SP1Proof, SP1ProofMode, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey, +}; + +/// A prover that uses the CPU for execution and the CUDA for proving. +pub struct CudaProver { + pub(crate) cpu_prover: SP1Prover, + pub(crate) cuda_prover: SP1CudaProver, +} + +impl CudaProver { + /// Creates a new [`CudaProver`]. + pub fn new(prover: SP1Prover) -> Self { + let cuda_prover = SP1CudaProver::new(); + Self { + cpu_prover: prover, + cuda_prover: cuda_prover.expect("Failed to initialize CUDA prover"), + } + } + + /// Creates a new [`CpuExecuteBuilder`] for simulating the execution of a program on the CPU. + /// + /// # Details + /// The builder is used for both the [`crate::cpu::CpuProver`] and [`crate::CudaProver`] client + /// types. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (public_values, execution_report) = client.execute(elf, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn execute<'a>(&'a self, elf: &'a [u8], stdin: &SP1Stdin) -> CpuExecuteBuilder<'a> { + CpuExecuteBuilder { + prover: &self.cpu_prover, + elf, + stdin: stdin.clone(), + context_builder: SP1ContextBuilder::default(), + } + } + + /// Creates a new [`CudaProveBuilder`] for proving a program on the CUDA. + /// + /// # Details + /// The builder is used for only the [`crate::CudaProver`] client type. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn prove<'a>(&'a self, pk: &'a SP1ProvingKey, stdin: &'a SP1Stdin) -> CudaProveBuilder<'a> { + CudaProveBuilder { prover: self, mode: SP1ProofMode::Core, pk, stdin: stdin.clone() } + } +} + +impl Prover for CudaProver { + fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { + self.cpu_prover.setup(elf) + } + + fn inner(&self) -> &SP1Prover { + &self.cpu_prover + } + + fn prove( + &self, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + kind: SP1ProofMode, + ) -> Result { + // Generate the core proof. + let proof = self.cuda_prover.prove_core(pk, stdin)?; + if kind == SP1ProofMode::Core { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Core(proof.proof.0), + public_values: proof.public_values, + sp1_version: self.version().to_string(), + }); + } + + // Generate the compressed proof. + let deferred_proofs = + stdin.proofs.iter().map(|(reduce_proof, _)| reduce_proof.clone()).collect(); + let public_values = proof.public_values.clone(); + let reduce_proof = self.cuda_prover.compress(&pk.vk, proof, deferred_proofs)?; + if kind == SP1ProofMode::Compressed { + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Compressed(Box::new(reduce_proof)), + public_values, + sp1_version: self.version().to_string(), + }); + } + + // Generate the shrink proof. + let compress_proof = self.cuda_prover.shrink(reduce_proof)?; + + // Genenerate the wrap proof. + let outer_proof = self.cuda_prover.wrap_bn254(compress_proof)?; + + if kind == SP1ProofMode::Plonk { + let plonk_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::try_build_plonk_bn254_artifacts_dev( + &outer_proof.vk, + &outer_proof.proof, + ) + } else { + try_install_circuit_artifacts("plonk") + }; + let proof = self.cpu_prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_artifacts); + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Plonk(proof), + public_values, + sp1_version: self.version().to_string(), + }); + } else if kind == SP1ProofMode::Groth16 { + let groth16_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::try_build_groth16_bn254_artifacts_dev( + &outer_proof.vk, + &outer_proof.proof, + ) + } else { + try_install_circuit_artifacts("groth16") + }; + + let proof = self.cpu_prover.wrap_groth16_bn254(outer_proof, &groth16_bn254_artifacts); + return Ok(SP1ProofWithPublicValues { + proof: SP1Proof::Groth16(proof), + public_values, + sp1_version: self.version().to_string(), + }); + } + + unreachable!() + } +} + +impl Default for CudaProver { + fn default() -> Self { + Self::new(SP1Prover::new()) + } +} diff --git a/crates/sdk/src/cuda/prove.rs b/crates/sdk/src/cuda/prove.rs new file mode 100644 index 0000000000..642dd97535 --- /dev/null +++ b/crates/sdk/src/cuda/prove.rs @@ -0,0 +1,178 @@ +//! # CUDA Proving +//! +//! This module provides a builder for proving a program on the CUDA. + +use anyhow::Result; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::{components::CpuProverComponents, SP1ProvingKey}; + +use super::CudaProver; +use crate::{Prover, SP1ProofMode, SP1ProofWithPublicValues}; + +/// A builder for proving a program on the CUDA. +/// +/// This builder provides a typed interface for configuring the SP1 RISC-V prover. The builder is +/// used for only the [`crate::cuda::CudaProver`] client type. +pub struct CudaProveBuilder<'a> { + pub(crate) prover: &'a CudaProver, + pub(crate) mode: SP1ProofMode, + pub(crate) pk: &'a SP1ProvingKey, + pub(crate) stdin: SP1Stdin, +} + +impl<'a> CudaProveBuilder<'a> { + /// Set the proof kind to [`SP1ProofMode::Core`] mode. + /// + /// # Details + /// This is the default mode for the prover. The proofs grow linearly in size with the number + /// of cycles. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + #[must_use] + pub fn core(mut self) -> Self { + self.mode = SP1ProofMode::Core; + self + } + + /// Set the proof kind to [`SP1ProofMode::Compressed`] mode. + /// + /// # Details + /// This mode produces a proof that is of constant size, regardless of the number of cycles. It + /// takes longer to prove than [`SP1ProofMode::Core`] due to the need to recursively aggregate + /// proofs into a single proof. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .compressed() + /// .run(); + /// ``` + #[must_use] + pub fn compressed(mut self) -> Self { + self.mode = SP1ProofMode::Compressed; + self + } + + /// Set the proof mode to [`SP1ProofMode::Plonk`] mode. + /// + /// # Details + /// This mode produces a const size PLONK proof that can be verified on chain for roughly ~300k + /// gas. This mode is useful for producing a maximally small proof that can be verified on + /// chain. For more efficient SNARK wrapping, you can use the [`SP1ProofMode::Groth16`] mode but + /// this mode is more . + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .plonk() + /// .run(); + /// ``` + #[must_use] + pub fn plonk(mut self) -> Self { + self.mode = SP1ProofMode::Plonk; + self + } + + /// Set the proof mode to [`SP1ProofMode::Groth16`] mode. + /// + /// # Details + /// This mode produces a Groth16 proof that can be verified on chain for roughly ~100k gas. This + /// mode is useful for producing a proof that can be verified on chain with minimal gas. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .groth16() + /// .run(); + /// ``` + #[must_use] + pub fn groth16(mut self) -> Self { + self.mode = SP1ProofMode::Groth16; + self + } + + /// Set the proof mode to the given [`SP1ProofMode`]. + /// + /// # Details + /// This method is useful for setting the proof mode to a custom mode. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, SP1ProofMode, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .mode(SP1ProofMode::Groth16) + /// .run(); + /// ``` + #[must_use] + pub fn mode(mut self, mode: SP1ProofMode) -> Self { + self.mode = mode; + self + } + + /// Run the prover with the built arguments. + /// + /// # Details + /// This method will run the prover with the built arguments. If the prover fails to run, the + /// method will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, include_elf, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cuda().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn run(self) -> Result { + let Self { prover, mode: kind, pk, stdin } = self; + + // Dump the program and stdin to files for debugging if `SP1_DUMP` is set. + crate::utils::sp1_dump(&pk.elf, &stdin); + + Prover::::prove(prover, pk, &stdin, kind) + } +} diff --git a/crates/sdk/src/env/mod.rs b/crates/sdk/src/env/mod.rs new file mode 100644 index 0000000000..26bc967cb3 --- /dev/null +++ b/crates/sdk/src/env/mod.rs @@ -0,0 +1,192 @@ +//! # SP1 Environment Prover +//! +//! A prover that can execute programs and generate proofs with a different implementation based on +//! the value of certain environment variables. + +mod prove; + +use std::env; + +use anyhow::Result; +use prove::EnvProveBuilder; +use sp1_core_executor::SP1ContextBuilder; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::{components::CpuProverComponents, SP1Prover, SP1ProvingKey, SP1VerifyingKey}; + +use super::{Prover, SP1VerificationError}; +use crate::cpu::execute::CpuExecuteBuilder; +use crate::cpu::CpuProver; +use crate::cuda::CudaProver; +use crate::network::builder::NetworkProverBuilder; +use crate::{SP1ProofMode, SP1ProofWithPublicValues}; + +/// A prover that can execute programs and generate proofs with a different implementation based on +/// the value of certain environment variables. +/// +/// The environment variables are described in [`EnvProver::new`]. +pub struct EnvProver { + pub(crate) prover: Box>, +} + +impl EnvProver { + /// Creates a new [`EnvProver`] with the given configuration. + /// + /// The following environment variables are used to configure the prover: + /// - `SP1_PROVER`: The type of prover to use. Must be one of `mock`, `local`, `cuda`, or `network`. + /// - `NETWORK_PRIVATE_KEY`: The private key to use for the network prover. + /// - `NETWORK_RPC_URL`: The RPC URL to use for the network prover. + #[must_use] + pub fn new() -> Self { + let mode = if let Ok(mode) = env::var("SP1_PROVER") { + mode + } else { + log::warn!("SP1_PROVER environment variable not set, defaulting to 'cpu'"); + "cpu".to_string() + }; + + let prover: Box> = match mode.as_str() { + "mock" => Box::new(CpuProver::mock()), + "cpu" => Box::new(CpuProver::new()), + "cuda" => { + #[cfg(not(feature = "cuda"))] + panic!( + "The CUDA prover requires the 'cuda' feature to be enabled. \ + Please enable it in your Cargo.toml with: \ + sp1-sdk = { version = \"...\", features = [\"cuda\"] }" + ); + + #[cfg(feature = "cuda")] + Box::new(CudaProver::new(SP1Prover::new())) + } + "network" => { + #[cfg(not(feature = "network"))] + panic!( + "The network prover requires the 'network' feature to be enabled. \ + Please enable it in your Cargo.toml with: \ + sp1-sdk = { version = \"...\", features = [\"network\"] }" + ); + + #[cfg(feature = "network")] + { + Box::new(NetworkProverBuilder::default().build()) + } + } + _ => panic!( + "Invalid SP1_PROVER value. Expected one of: mock, cpu, cuda, or network. Got: '{mode}'.\n\ + Please set the SP1_PROVER environment variable to one of the supported values." + ), + }; + EnvProver { prover } + } + + /// Creates a new [`CpuExecuteBuilder`] for simulating the execution of a program on the CPU. + /// + /// # Details + /// The builder is used for both the [`crate::cpu::CpuProver`] and [`crate::CudaProver`] client + /// types. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (public_values, execution_report) = client.execute(elf, &stdin) + /// .run() + /// .unwrap(); + /// ``` + #[must_use] + pub fn execute<'a>(&'a self, elf: &'a [u8], stdin: &SP1Stdin) -> CpuExecuteBuilder<'a> { + CpuExecuteBuilder { + prover: self.prover.inner(), + elf, + stdin: stdin.clone(), + context_builder: SP1ContextBuilder::default(), + } + } + + /// Creates a new [`EnvProve`] for proving a program on the CPU. + /// + /// # Details + /// The builder is used for only the [`crate::cpu::CpuProver`] client type. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + #[must_use] + pub fn prove<'a>(&'a self, pk: &'a SP1ProvingKey, stdin: &'a SP1Stdin) -> EnvProveBuilder<'a> { + EnvProveBuilder { + prover: self.prover.as_ref(), + mode: SP1ProofMode::Core, + pk, + stdin: stdin.clone(), + } + } + + /// Verifies that the given proof is valid and matches the given verification key produced by + /// [`Self::setup`]. + /// + /// ### Examples + /// ```no_run + /// use sp1_sdk::{ProverClient, SP1Stdin}; + /// + /// let elf = test_artifacts::FIBONACCI_ELF; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin).run().unwrap(); + /// client.verify(&proof, &vk).unwrap(); + /// ``` + pub fn verify( + &self, + proof: &SP1ProofWithPublicValues, + vk: &SP1VerifyingKey, + ) -> Result<(), SP1VerificationError> { + self.prover.verify(proof, vk) + } + + /// Setup a program to be proven and verified by the SP1 RISC-V zkVM by computing the proving + /// and verifying keys. + #[must_use] + pub fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { + self.prover.setup(elf) + } +} + +impl Default for EnvProver { + fn default() -> Self { + Self::new() + } +} + +impl Prover for EnvProver { + fn inner(&self) -> &SP1Prover { + self.prover.inner() + } + + fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { + self.prover.setup(elf) + } + + fn prove( + &self, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + mode: SP1ProofMode, + ) -> Result { + self.prover.prove(pk, stdin, mode) + } +} diff --git a/crates/sdk/src/env/prove.rs b/crates/sdk/src/env/prove.rs new file mode 100644 index 0000000000..74cc78eba2 --- /dev/null +++ b/crates/sdk/src/env/prove.rs @@ -0,0 +1,166 @@ +use anyhow::Result; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::{components::CpuProverComponents, SP1ProvingKey}; + +use crate::{Prover, SP1ProofMode, SP1ProofWithPublicValues}; + +/// Builder to prepare and configure proving execution of a program on an input. +/// May be run with [`Self::run`]. +pub struct EnvProveBuilder<'a> { + pub(crate) prover: &'a dyn Prover, + pub(crate) mode: SP1ProofMode, + pub(crate) pk: &'a SP1ProvingKey, + pub(crate) stdin: SP1Stdin, +} + +impl<'a> EnvProveBuilder<'a> { + /// Set the proof kind to [`SP1ProofMode::Core`] mode. + /// + /// # Details + /// This is the default mode for the prover. The proofs grow linearly in size with the number + /// of cycles. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + pub fn core(mut self) -> Self { + self.mode = SP1ProofMode::Core; + self + } + + /// Set the proof kind to [`SP1ProofMode::Compressed`] mode. + /// + /// # Details + /// This mode produces a proof that is of constant size, regardless of the number of cycles. It + /// takes longer to prove than [`SP1ProofMode::Core`] due to the need to recursively aggregate + /// proofs into a single proof. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .compressed() + /// .run(); + /// ``` + pub fn compressed(mut self) -> Self { + self.mode = SP1ProofMode::Compressed; + self + } + + /// Set the proof mode to [`SP1ProofMode::Plonk`] mode. + /// + /// # Details + /// This mode produces a const size PLONK proof that can be verified on chain for roughly ~300k + /// gas. This mode is useful for producing a maximally small proof that can be verified on + /// chain. For more efficient SNARK wrapping, you can use the [`SP1ProofMode::Groth16`] mode but + /// this mode is more . + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .plonk() + /// .run(); + /// ``` + pub fn plonk(mut self) -> Self { + self.mode = SP1ProofMode::Plonk; + self + } + + /// Set the proof mode to [`SP1ProofMode::Groth16`] mode. + /// + /// # Details + /// This mode produces a Groth16 proof that can be verified on chain for roughly ~100k gas. This + /// mode is useful for producing a proof that can be verified on chain with minimal gas. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .groth16() + /// .run(); + /// ``` + pub fn groth16(mut self) -> Self { + self.mode = SP1ProofMode::Groth16; + self + } + + /// Set the proof mode to the given [`SP1ProofMode`]. + /// + /// # Details + /// This method is useful for setting the proof mode to a custom mode. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover, SP1ProofMode}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .mode(SP1ProofMode::Groth16) + /// .run(); + /// ``` + pub fn mode(mut self, mode: SP1ProofMode) -> Self { + self.mode = mode; + self + } + + /// Run the prover with the built arguments. + /// + /// # Details + /// This method will run the prover with the built arguments. If the prover fails to run, the + /// method will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::from_env(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn run(self) -> Result { + let Self { prover, mode: kind, pk, stdin } = self; + + // Dump the program and stdin to files for debugging if `SP1_DUMP` is set. + crate::utils::sp1_dump(&pk.elf, &stdin); + + prover.prove(pk, &stdin, kind) + } +} diff --git a/crates/sdk/src/install.rs b/crates/sdk/src/install.rs index b3207664ba..51857f32ca 100644 --- a/crates/sdk/src/install.rs +++ b/crates/sdk/src/install.rs @@ -1,13 +1,17 @@ +//! # SP1 Install +//! +//! A library for installing the SP1 circuit artifacts. + use cfg_if::cfg_if; use std::path::PathBuf; -#[cfg(any(feature = "network", feature = "network-v2"))] +#[cfg(any(feature = "network", feature = "network"))] use { - crate::block_on, + crate::utils::block_on, futures::StreamExt, indicatif::{ProgressBar, ProgressStyle}, reqwest::Client, - std::{cmp::min, io::Write, process::Command}, + std::{cmp::min, process::Command}, }; use crate::SP1_CIRCUIT_VERSION; @@ -16,16 +20,19 @@ use crate::SP1_CIRCUIT_VERSION; pub const CIRCUIT_ARTIFACTS_URL_BASE: &str = "https://sp1-circuits.s3-us-east-2.amazonaws.com"; /// The directory where the groth16 circuit artifacts will be stored. +#[must_use] pub fn groth16_circuit_artifacts_dir() -> PathBuf { dirs::home_dir().unwrap().join(".sp1").join("circuits/groth16").join(SP1_CIRCUIT_VERSION) } /// The directory where the plonk circuit artifacts will be stored. +#[must_use] pub fn plonk_circuit_artifacts_dir() -> PathBuf { dirs::home_dir().unwrap().join(".sp1").join("circuits/plonk").join(SP1_CIRCUIT_VERSION) } /// Tries to install the groth16 circuit artifacts if they are not already installed. +#[must_use] pub fn try_install_circuit_artifacts(artifacts_type: &str) -> PathBuf { let build_dir = if artifacts_type == "groth16" { groth16_circuit_artifacts_dir() @@ -43,7 +50,7 @@ pub fn try_install_circuit_artifacts(artifacts_type: &str) -> PathBuf { ); } else { cfg_if! { - if #[cfg(any(feature = "network", feature = "network-v2"))] { + if #[cfg(any(feature = "network", feature = "network"))] { println!( "[sp1] {} circuit artifacts for version {} do not exist at {}. downloading...", artifacts_type, @@ -60,15 +67,16 @@ pub fn try_install_circuit_artifacts(artifacts_type: &str) -> PathBuf { /// Install the latest circuit artifacts. /// /// This function will download the latest circuit artifacts from the S3 bucket and extract them -/// to the directory specified by [groth16_bn254_artifacts_dir()]. -#[cfg(any(feature = "network", feature = "network-v2"))] +/// to the directory specified by [`groth16_bn254_artifacts_dir()`]. +#[cfg(any(feature = "network", feature = "network"))] +#[allow(clippy::needless_pass_by_value)] pub fn install_circuit_artifacts(build_dir: PathBuf, artifacts_type: &str) { // Create the build directory. std::fs::create_dir_all(&build_dir).expect("failed to create build directory"); // Download the artifacts. let download_url = - format!("{}/{}-{}.tar.gz", CIRCUIT_ARTIFACTS_URL_BASE, SP1_CIRCUIT_VERSION, artifacts_type); + format!("{CIRCUIT_ARTIFACTS_URL_BASE}/{SP1_CIRCUIT_VERSION}-{artifacts_type}.tar.gz"); let mut artifacts_tar_gz_file = tempfile::NamedTempFile::new().expect("failed to create tempfile"); let client = Client::builder().build().expect("failed to create reqwest client"); @@ -91,11 +99,11 @@ pub fn install_circuit_artifacts(build_dir: PathBuf, artifacts_type: &str) { } /// Download the file with a progress bar that indicates the progress. -#[cfg(any(feature = "network", feature = "network-v2"))] +#[cfg(any(feature = "network", feature = "network"))] pub async fn download_file( client: &Client, url: &str, - file: &mut tempfile::NamedTempFile, + file: &mut impl std::io::Write, ) -> std::result::Result<(), String> { let res = client.get(url).send().await.or(Err(format!("Failed to GET from '{}'", &url)))?; diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 7b7bb96f2b..08d3ccecbd 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -2,45 +2,61 @@ //! //! A library for interacting with the SP1 RISC-V zkVM. //! -//! Visit the [Getting Started](https://succinctlabs.github.io/sp1/getting-started.html) section +//! Visit the [Getting Started](https://docs.succinct.xyz/docs/getting-started/install) section //! in the official SP1 documentation for a quick start guide. -pub mod action; +#![warn(clippy::pedantic)] +#![allow(clippy::similar_names)] +#![allow(clippy::cast_possible_wrap)] +#![allow(clippy::cast_possible_truncation)] +#![allow(clippy::cast_sign_loss)] +#![allow(clippy::module_name_repetitions)] +#![allow(clippy::needless_range_loop)] +#![allow(clippy::cast_lossless)] +#![allow(clippy::bool_to_int_with_if)] +#![allow(clippy::should_panic_without_expect)] +#![allow(clippy::field_reassign_with_default)] +#![allow(clippy::manual_assert)] +#![allow(clippy::unreadable_literal)] +#![allow(clippy::match_wildcard_for_single_variants)] +#![allow(clippy::missing_panics_doc)] +#![allow(clippy::missing_errors_doc)] +#![allow(clippy::explicit_iter_loop)] +#![warn(missing_docs)] + pub mod artifacts; +pub mod client; +pub mod cpu; +pub mod cuda; +pub mod env; pub mod install; #[cfg(feature = "network")] pub mod network; -#[cfg(feature = "network-v2")] -#[path = "network-v2/mod.rs"] -pub mod network_v2; +pub mod proof; +pub mod prover; +pub mod utils; -use std::env; +// Re-export the client. +pub use crate::client::ProverClient; +// Re-export the provers. +pub use crate::cpu::CpuProver; +pub use crate::cuda::CudaProver; +pub use crate::env::EnvProver; #[cfg(feature = "network")] -pub use crate::network::prover::NetworkProver as NetworkProverV1; -#[cfg(feature = "network-v2")] -pub use crate::network_v2::prover::NetworkProver as NetworkProverV2; -#[cfg(feature = "cuda")] -pub use crate::provers::CudaProver; - -pub mod proof; -pub mod provers; -pub mod utils { - pub use sp1_core_machine::utils::setup_logger; -} +pub use crate::network::prover::NetworkProver; -use cfg_if::cfg_if; +// Re-export the proof and prover traits. pub use proof::*; -pub use provers::SP1VerificationError; -use sp1_prover::components::DefaultProverComponents; - -#[cfg(any(feature = "network", feature = "network-v2"))] -use {std::future::Future, tokio::task::block_in_place}; - -pub use provers::{CpuProver, MockProver, Prover}; +#[cfg(feature = "network")] +pub use prover::Prover; +pub use prover::SP1VerificationError; +// Re-export the build utilities and executor primitives. pub use sp1_build::include_elf; -pub use sp1_core_executor::{ExecutionReport, HookEnv, SP1Context, SP1ContextBuilder}; +pub use sp1_core_executor::{ExecutionReport, Executor, HookEnv, SP1Context, SP1ContextBuilder}; + +// Re-export the machine/prover primitives. pub use sp1_core_machine::{io::SP1Stdin, riscv::cost::CostEstimator, SP1_CIRCUIT_VERSION}; pub use sp1_primitives::io::SP1PublicValues; pub use sp1_prover::{ @@ -48,424 +64,24 @@ pub use sp1_prover::{ SP1VerifyingKey, }; -/// A client for interacting with SP1. -pub struct ProverClient { - /// The underlying prover implementation. - pub prover: Box>, -} - -impl ProverClient { - /// Creates a new [ProverClient]. - /// - /// Setting the `SP1_PROVER` environment variable can change the prover used under the hood. - /// - `local` (default): Uses [CpuProver] or [CudaProver] if the `cuda` feature is enabled. - /// Recommended for proving end-to-end locally. - /// - `mock`: Uses [MockProver]. Recommended for testing and development. - /// - `network`: Uses [NetworkProver]. Recommended for outsourcing proof generation to an RPC. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// std::env::set_var("SP1_PROVER", "local"); - /// let client = ProverClient::new(); - /// ``` - pub fn new() -> Self { - #[allow(unreachable_code)] - match env::var("SP1_PROVER").unwrap_or("local".to_string()).to_lowercase().as_str() { - "mock" => Self { prover: Box::new(MockProver::new()) }, - "local" => { - #[cfg(debug_assertions)] - eprintln!("Warning: Local prover in dev mode is not recommended. Proof generation may be slow."); - Self { - #[cfg(not(feature = "cuda"))] - prover: Box::new(CpuProver::new()), - #[cfg(feature = "cuda")] - prover: Box::new(CudaProver::new(SP1Prover::new())), - } - } - "network" => { - let private_key = env::var("SP1_PRIVATE_KEY") - .expect("SP1_PRIVATE_KEY must be set for remote proving"); - let rpc_url = env::var("PROVER_NETWORK_RPC").ok(); - let skip_simulation = - env::var("SKIP_SIMULATION").map(|val| val == "true").unwrap_or_default(); - - cfg_if! { - if #[cfg(feature = "network-v2")] { - Self { - prover: Box::new(NetworkProverV2::new(&private_key, rpc_url, skip_simulation)), - } - } else if #[cfg(feature = "network")] { - Self { - prover: Box::new(NetworkProverV1::new(&private_key, rpc_url, skip_simulation)), - } - } else { - panic!("network feature is not enabled") - } - } - } - _ => panic!( - "invalid value for SP1_PROVER environment variable: expected 'local', 'mock', or 'network'" - ), - } - } - - /// Returns a [ProverClientBuilder] to easily create a [ProverClient]. - pub fn builder() -> ProverClientBuilder { - ProverClientBuilder::default() - } - - /// Creates a new [ProverClient] with the mock prover. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// let client = ProverClient::mock(); - /// ``` - pub fn mock() -> Self { - Self { prover: Box::new(MockProver::new()) } - } - - /// Creates a new [ProverClient] with the local prover, using the CPU. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// let client = ProverClient::local(); - /// ``` - #[deprecated(note = "Please use `cpu` instead")] - pub fn local() -> Self { - Self { prover: Box::new(CpuProver::new()) } - } - - /// Creates a new [ProverClient] with the local prover, using the CPU. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// let client = ProverClient::cpu(); - /// ``` - pub fn cpu() -> Self { - Self { prover: Box::new(CpuProver::new()) } - } - - /// Creates a new [ProverClient] with the local prover, using the GPU. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// let client = ProverClient::cuda(); - /// ``` - #[cfg(feature = "cuda")] - pub fn cuda() -> Self { - Self { prover: Box::new(CudaProver::new(SP1Prover::new())) } - } - - /// Creates a new [ProverClient] with the network prover. - /// - /// ### Examples - /// - /// ```no_run - /// use sp1_sdk::ProverClient; - /// - /// let private_key = std::env::var("SP1_PRIVATE_KEY").unwrap(); - /// let rpc_url = std::env::var("PROVER_NETWORK_RPC").ok(); - /// let skip_simulation = - /// std::env::var("SKIP_SIMULATION").map(|val| val == "true").unwrap_or_default(); - /// - /// let client = ProverClient::network(private_key, rpc_url, skip_simulation); - /// ``` - #[cfg(any(feature = "network", feature = "network-v2"))] - pub fn network(private_key: String, rpc_url: Option, skip_simulation: bool) -> Self { - cfg_if! { - if #[cfg(feature = "network-v2")] { - Self { - prover: Box::new(NetworkProverV2::new(&private_key, rpc_url, skip_simulation)), - } - } else if #[cfg(feature = "network")] { - Self { - prover: Box::new(NetworkProverV1::new(&private_key, rpc_url, skip_simulation)), - } - } else { - panic!("network feature is not enabled") - } - } - } - - /// Prepare to execute the given program on the given input (without generating a proof). - /// The returned [action::Execute] may be configured via its methods before running. - /// For example, calling [action::Execute::with_hook] registers hooks for execution. - /// - /// To execute, call [action::Execute::run], which returns - /// the public values and execution report of the program after it has been executed. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Context, SP1Stdin}; - /// - /// // Load the program. - /// let elf = test_artifacts::FIBONACCI_ELF; - /// - /// // Initialize the prover client. - /// let client = ProverClient::new(); - /// - /// // Setup the inputs. - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// - /// // Execute the program on the inputs. - /// let (public_values, report) = client.execute(elf, stdin).run().unwrap(); - /// ``` - pub fn execute<'a>(&'a self, elf: &'a [u8], stdin: SP1Stdin) -> action::Execute<'a> { - action::Execute::new(self.prover.as_ref(), elf, stdin) - } - - /// Prepare to prove the execution of the given program with the given input in the default - /// mode. The returned [action::Prove] may be configured via its methods before running. - /// For example, calling [action::Prove::compressed] sets the mode to compressed mode. - /// - /// To prove, call [action::Prove::run], which returns a proof of the program's execution. - /// By default the proof generated will not be compressed to constant size. - /// To create a more succinct proof, use the [action::Prove::compressed], - /// [action::Prove::plonk], or [action::Prove::groth16] methods. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Context, SP1Stdin}; - /// - /// // Load the program. - /// let elf = test_artifacts::FIBONACCI_ELF; - /// - /// // Initialize the prover client. - /// let client = ProverClient::new(); - /// - /// // Setup the program. - /// let (pk, vk) = client.setup(elf); - /// - /// // Setup the inputs. - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// - /// // Generate the proof. - /// let proof = client.prove(&pk, stdin).run().unwrap(); - /// ``` - pub fn prove<'a>(&'a self, pk: &'a SP1ProvingKey, stdin: SP1Stdin) -> action::Prove<'a> { - action::Prove::new(self.prover.as_ref(), pk, stdin) - } - - /// Verifies that the given proof is valid and matches the given verification key produced by - /// [Self::setup]. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// let elf = test_artifacts::FIBONACCI_ELF; - /// let client = ProverClient::new(); - /// let (pk, vk) = client.setup(elf); - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// let proof = client.prove(&pk, stdin).run().unwrap(); - /// client.verify(&proof, &vk).unwrap(); - /// ``` - pub fn verify( - &self, - proof: &SP1ProofWithPublicValues, - vk: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - self.prover.verify(proof, vk) - } - - /// Gets the current version of the SP1 zkVM. - /// - /// Note: This is not the same as the version of the SP1 SDK. - pub fn version(&self) -> String { - SP1_CIRCUIT_VERSION.to_string() - } - - /// Setup a program to be proven and verified by the SP1 RISC-V zkVM by computing the proving - /// and verifying keys. - /// - /// The proving key and verifying key essentially embed the program, as well as other auxiliary - /// data (such as lookup tables) that are used to prove the program's correctness. - /// - /// ### Examples - /// ```no_run - /// use sp1_sdk::{ProverClient, SP1Stdin}; - /// - /// let elf = test_artifacts::FIBONACCI_ELF; - /// let client = ProverClient::new(); - /// let mut stdin = SP1Stdin::new(); - /// stdin.write(&10usize); - /// let (pk, vk) = client.setup(elf); - /// ``` - pub fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.prover.setup(elf) - } -} - -impl Default for ProverClient { - fn default() -> Self { - Self::new() - } -} - -/// Builder type for [`ProverClient`]. -#[derive(Debug, Default)] -pub struct ProverClientBuilder { - mode: Option, - private_key: Option, - rpc_url: Option, - skip_simulation: bool, -} - -impl ProverClientBuilder { - /// Sets the mode of the prover client being created. - pub fn mode(mut self, mode: ProverMode) -> Self { - self.mode = Some(mode); - self - } - - /// Sets the private key. - pub fn private_key(mut self, private_key: String) -> Self { - self.private_key = Some(private_key); - self - } - - /// Sets the RPC URL. - pub fn rpc_url(mut self, rpc_url: String) -> Self { - self.rpc_url = Some(rpc_url); - self - } - - /// Skips simulation. - pub fn skip_simulation(mut self) -> Self { - self.skip_simulation = true; - self - } - - /// Builds a [ProverClient], using the provided private key. - pub fn build(self) -> ProverClient { - match self.mode.expect("The prover mode is required") { - ProverMode::Cpu => ProverClient::cpu(), - ProverMode::Cuda => { - cfg_if! { - if #[cfg(feature = "cuda")] { - ProverClient::cuda() - } else { - panic!("cuda feature is not enabled") - } - } - } - ProverMode::Network => { - let private_key = self.private_key.expect("The private key is required"); - - cfg_if! { - if #[cfg(feature = "network-v2")] { - ProverClient { - prover: Box::new(NetworkProverV2::new(&private_key, self.rpc_url, self.skip_simulation)), - } - } else if #[cfg(feature = "network")] { - ProverClient { - prover: Box::new(NetworkProverV1::new(&private_key, self.rpc_url, self.skip_simulation)), - } - } else { - panic!("network feature is not enabled") - } - } - } - ProverMode::Mock => ProverClient::mock(), - } - } -} - -/// Builder type for network prover. -#[cfg(any(feature = "network", feature = "network-v2"))] -#[derive(Debug, Default)] -pub struct NetworkProverBuilder { - private_key: Option, - rpc_url: Option, - skip_simulation: bool, -} - -#[cfg(any(feature = "network", feature = "network-v2"))] -impl NetworkProverBuilder { - /// Sets the private key. - pub fn private_key(mut self, private_key: String) -> Self { - self.private_key = Some(private_key); - self - } - - /// Sets the RPC URL. - pub fn rpc_url(mut self, rpc_url: String) -> Self { - self.rpc_url = Some(rpc_url); - self - } - - /// Skips simulation. - pub fn skip_simulation(mut self) -> Self { - self.skip_simulation = true; - self - } - - /// Creates a new [NetworkProverV1]. - #[cfg(feature = "network")] - pub fn build(self) -> NetworkProverV1 { - let private_key = self.private_key.expect("The private key is required"); - - NetworkProverV1::new(&private_key, self.rpc_url, self.skip_simulation) - } - - /// Creates a new [NetworkProverV2]. - #[cfg(feature = "network-v2")] - pub fn build_v2(self) -> NetworkProverV2 { - let private_key = self.private_key.expect("The private key is required"); - - NetworkProverV2::new(&private_key, self.rpc_url, self.skip_simulation) - } -} - -/// Utility method for blocking on an async function. -/// -/// If we're already in a tokio runtime, we'll block in place. Otherwise, we'll create a new -/// runtime. -#[cfg(any(feature = "network", feature = "network-v2"))] -pub fn block_on(fut: impl Future) -> T { - // Handle case if we're already in an tokio runtime. - if let Ok(handle) = tokio::runtime::Handle::try_current() { - block_in_place(|| handle.block_on(fut)) - } else { - // Otherwise create a new runtime. - let rt = tokio::runtime::Runtime::new().expect("Failed to create a new runtime"); - rt.block_on(fut) - } -} +// Re-export the utilities. +pub use utils::setup_logger; #[cfg(test)] mod tests { - + use sp1_core_machine::riscv::cost::CostEstimator; use sp1_primitives::io::SP1PublicValues; - use crate::{utils, CostEstimator, ProverClient, SP1Stdin}; + use crate::{utils, Prover, ProverClient, SP1Stdin}; #[test] fn test_execute() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::FIBONACCI_ELF; let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - let (_, report) = client.execute(elf, stdin).run().unwrap(); + let (_, report) = client.execute(elf, &stdin).run().unwrap(); tracing::info!("gas = {}", report.estimate_gas()); } @@ -473,35 +89,35 @@ mod tests { #[should_panic] fn test_execute_panic() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::PANIC_ELF; let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - client.execute(elf, stdin).run().unwrap(); + client.execute(elf, &stdin).run().unwrap(); } #[should_panic] #[test] fn test_cycle_limit_fail() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::PANIC_ELF; let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - client.execute(elf, stdin).max_cycles(1).run().unwrap(); + client.execute(elf, &stdin).cycle_limit(1).run().unwrap(); } #[test] fn test_e2e_core() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::FIBONACCI_ELF; let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); // Generate proof & verify. - let mut proof = client.prove(&pk, stdin).run().unwrap(); + let mut proof = client.prove(&pk, &stdin).run().unwrap(); client.verify(&proof, &vk).unwrap(); // Test invalid public values. @@ -514,14 +130,14 @@ mod tests { #[test] fn test_e2e_compressed() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::FIBONACCI_ELF; let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); // Generate proof & verify. - let mut proof = client.prove(&pk, stdin).compressed().run().unwrap(); + let mut proof = client.prove(&pk, &stdin).compressed().run().unwrap(); client.verify(&proof, &vk).unwrap(); // Test invalid public values. @@ -534,14 +150,14 @@ mod tests { #[test] fn test_e2e_prove_plonk() { utils::setup_logger(); - let client = ProverClient::cpu(); + let client = ProverClient::builder().cpu().build(); let elf = test_artifacts::FIBONACCI_ELF; let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); // Generate proof & verify. - let mut proof = client.prove(&pk, stdin).plonk().run().unwrap(); + let mut proof = client.prove(&pk, &stdin).plonk().run().unwrap(); client.verify(&proof, &vk).unwrap(); // Test invalid public values. @@ -554,12 +170,12 @@ mod tests { #[test] fn test_e2e_prove_plonk_mock() { utils::setup_logger(); - let client = ProverClient::mock(); + let client = ProverClient::builder().mock().build(); let elf = test_artifacts::FIBONACCI_ELF; let (pk, vk) = client.setup(elf); let mut stdin = SP1Stdin::new(); stdin.write(&10usize); - let proof = client.prove(&pk, stdin).plonk().run().unwrap(); + let proof = client.prove(&pk, &stdin).plonk().run().unwrap(); client.verify(&proof, &vk).unwrap(); } } diff --git a/crates/sdk/src/network-v2/client.rs b/crates/sdk/src/network-v2/client.rs deleted file mode 100644 index 509aaad444..0000000000 --- a/crates/sdk/src/network-v2/client.rs +++ /dev/null @@ -1,280 +0,0 @@ -use std::result::Result::Ok as StdOk; -use std::str::FromStr; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; - -use alloy_signer::SignerSync; -use alloy_signer_local::PrivateKeySigner; -use anyhow::{Context, Ok, Result}; -use reqwest_middleware::ClientWithMiddleware as HttpClientWithMiddleware; -use serde::{de::DeserializeOwned, Serialize}; -use tonic::{ - transport::{channel::ClientTlsConfig, Channel}, - Code, -}; - -use sp1_core_machine::io::SP1Stdin; -use sp1_prover::{HashableKey, SP1VerifyingKey}; - -use crate::network_v2::proto::artifact::{ - artifact_store_client::ArtifactStoreClient, CreateArtifactRequest, -}; -use crate::network_v2::proto::network::{ - prover_network_client::ProverNetworkClient, CreateProgramRequest, CreateProgramRequestBody, - CreateProgramResponse, FulfillmentStatus, FulfillmentStrategy, GetNonceRequest, - GetProgramRequest, GetProgramResponse, GetProofRequestStatusRequest, - GetProofRequestStatusResponse, MessageFormat, ProofMode, RequestProofRequest, - RequestProofRequestBody, RequestProofResponse, -}; -use crate::network_v2::Signable; - -/// The default RPC endpoint for the Succinct prover network. -pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.production.succinct.tools/"; - -pub struct NetworkClient { - signer: PrivateKeySigner, - http: HttpClientWithMiddleware, - rpc_url: String, -} - -impl NetworkClient { - /// Create a new network client with the given private key. - pub fn new(private_key: &str, rpc_url: Option) -> Self { - let signer = PrivateKeySigner::from_str(private_key).unwrap(); - - let http_client = reqwest::Client::builder() - .pool_max_idle_per_host(0) - .pool_idle_timeout(Duration::from_secs(240)) - .build() - .unwrap(); - - Self { - signer, - http: http_client.into(), - rpc_url: rpc_url.unwrap_or_else(|| DEFAULT_PROVER_NETWORK_RPC.to_string()), - } - } - - /// Returns the currently configured RPC endpoint for the Succinct prover network. - pub fn rpc_url(&self) -> String { - self.rpc_url.clone() - } - - /// Get a connected RPC client. - async fn get_rpc(&self) -> Result> { - let rpc_url = self.rpc_url(); - let mut endpoint = Channel::from_shared(rpc_url.clone())?; - - // Check if the URL scheme is HTTPS and configure TLS. - if rpc_url.starts_with("https://") { - let tls_config = ClientTlsConfig::new().with_enabled_roots(); - endpoint = endpoint.tls_config(tls_config)?; - } - - let channel = endpoint.connect().await?; - Ok(ProverNetworkClient::new(channel)) - } - - /// Get a connected artifact store client. - async fn get_store(&self) -> Result> { - let rpc_url = self.rpc_url(); - let mut endpoint = Channel::from_shared(rpc_url.clone())?; - - // Check if the URL scheme is HTTPS and configure TLS. - if rpc_url.starts_with("https://") { - let tls_config = ClientTlsConfig::new().with_enabled_roots(); - endpoint = endpoint.tls_config(tls_config)?; - } - - let channel = endpoint.connect().await?; - Ok(ArtifactStoreClient::new(channel.clone())) - } - - /// Get the latest nonce for this account's address. - pub async fn get_nonce(&self) -> Result { - let mut rpc = self.get_rpc().await?; - let res = - rpc.get_nonce(GetNonceRequest { address: self.signer.address().to_vec() }).await?; - Ok(res.into_inner().nonce) - } - - /// Get the verifying key hash from a verifying key. The verifying key hash is used to identify - /// a program. - pub fn get_vk_hash(vk: &SP1VerifyingKey) -> Result> { - let vk_hash_str = vk.bytes32(); - let vk_hash = hex::decode(vk_hash_str.strip_prefix("0x").unwrap_or(&vk_hash_str))?; - Ok(vk_hash) - } - - /// Registers a program if it is not already registered. - pub async fn register_program(&self, vk: &SP1VerifyingKey, elf: &[u8]) -> Result> { - let vk_hash = Self::get_vk_hash(vk)?; - - // Try to get the existing program. - match self.get_program(&vk_hash).await? { - Some(_) => { - // The program already exists. - Ok(vk_hash) - } - None => { - // The program doesn't exist, create it. - self.create_program(&vk_hash, vk, elf).await?; - log::info!("Registered program 0x{}", hex::encode(vk_hash.clone())); - Ok(vk_hash) - } - } - } - - /// Attempts to get program info, returns None if program doesn't exist. - async fn get_program(&self, vk_hash: &[u8]) -> Result> { - let mut rpc = self.get_rpc().await?; - match rpc.get_program(GetProgramRequest { vk_hash: vk_hash.to_vec() }).await { - StdOk(response) => Ok(Some(response.into_inner())), - Err(status) if status.code() == Code::NotFound => Ok(None), - Err(e) => Err(e.into()), - } - } - - /// Creates a new program. - async fn create_program( - &self, - vk_hash: &[u8], - vk: &SP1VerifyingKey, - elf: &[u8], - ) -> Result { - // Create the program artifact. - let mut store = self.get_store().await?; - let program_uri = self.create_artifact_with_content(&mut store, &elf).await?; - - // Serialize the verifying key. - let vk_encoded = bincode::serialize(&vk)?; - - // Send the request. - let mut rpc = self.get_rpc().await?; - let nonce = self.get_nonce().await?; - let request_body = CreateProgramRequestBody { - nonce, - vk_hash: vk_hash.to_vec(), - vk: vk_encoded, - program_uri, - }; - - Ok(rpc - .create_program(CreateProgramRequest { - format: MessageFormat::Binary.into(), - signature: request_body.sign(&self.signer).into(), - body: Some(request_body), - }) - .await? - .into_inner()) - } - - /// Get the status of a given proof. If the status is Fulfilled, the proof is also returned. - pub async fn get_proof_request_status( - &self, - request_id: &[u8], - ) -> Result<(GetProofRequestStatusResponse, Option

)> { - let mut rpc = self.get_rpc().await?; - let res = rpc - .get_proof_request_status(GetProofRequestStatusRequest { - request_id: request_id.to_vec(), - }) - .await? - .into_inner(); - - let status = FulfillmentStatus::try_from(res.fulfillment_status)?; - let proof = match status { - FulfillmentStatus::Fulfilled => { - let proof_uri = res - .proof_uri - .as_ref() - .ok_or_else(|| anyhow::anyhow!("No proof URI provided"))?; - let proof_bytes = self.download_artifact(proof_uri).await?; - Some(bincode::deserialize(&proof_bytes).context("Failed to deserialize proof")?) - } - _ => None, - }; - - Ok((res, proof)) - } - - /// Creates a proof request with the given verifying key hash and stdin. - #[allow(clippy::too_many_arguments)] - pub async fn request_proof( - &self, - vk_hash: &[u8], - stdin: &SP1Stdin, - mode: ProofMode, - version: &str, - strategy: FulfillmentStrategy, - timeout_secs: u64, - cycle_limit: u64, - ) -> Result { - // Calculate the deadline. - let start = SystemTime::now(); - let since_the_epoch = start.duration_since(UNIX_EPOCH).expect("Invalid start time"); - let deadline = since_the_epoch.as_secs() + timeout_secs; - - // Create the stdin artifact. - let mut store = self.get_store().await?; - let stdin_uri = self.create_artifact_with_content(&mut store, &stdin).await?; - - // Send the request. - let mut rpc = self.get_rpc().await?; - let nonce = self.get_nonce().await?; - let request_body = RequestProofRequestBody { - nonce, - version: format!("sp1-{}", version), - vk_hash: vk_hash.to_vec(), - mode: mode.into(), - strategy: strategy.into(), - stdin_uri, - deadline, - cycle_limit, - }; - let request_response = rpc - .request_proof(RequestProofRequest { - format: MessageFormat::Binary.into(), - signature: request_body.sign(&self.signer).into(), - body: Some(request_body), - }) - .await? - .into_inner(); - - Ok(request_response) - } - - /// Uses the artifact store to to create an artifact, upload the content, and return the URI. - async fn create_artifact_with_content( - &self, - store: &mut ArtifactStoreClient, - item: &T, - ) -> Result { - let signature = self.signer.sign_message_sync("create_artifact".as_bytes())?; - let request = CreateArtifactRequest { signature: signature.as_bytes().to_vec() }; - let response = store.create_artifact(request).await?.into_inner(); - - let presigned_url = response.artifact_presigned_url; - let uri = response.artifact_uri; - - let response = - self.http.put(&presigned_url).body(bincode::serialize::(item)?).send().await?; - - if !response.status().is_success() { - log::debug!("Artifact upload failed with status: {}", response.status()); - } - assert!(response.status().is_success()); - - Ok(uri) - } - - /// Download an artifact from a URI. - async fn download_artifact(&self, uri: &str) -> Result> { - let response = self.http.get(uri).send().await.context("Failed to download from URI")?; - - if !response.status().is_success() { - return Err(anyhow::anyhow!("Failed to download artifact: HTTP {}", response.status())); - } - - Ok(response.bytes().await.context("Failed to read response body")?.to_vec()) - } -} diff --git a/crates/sdk/src/network-v2/mod.rs b/crates/sdk/src/network-v2/mod.rs deleted file mode 100644 index 86f1a82d47..0000000000 --- a/crates/sdk/src/network-v2/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -pub mod client; -mod json; -pub mod prover; -mod sign_message; -#[rustfmt::skip] -pub mod proto; - -use alloy_signer::{Signature, SignerSync}; -use prost::Message; -pub use serde::{Deserialize, Serialize}; - -pub trait Signable: Message { - fn sign(&self, signer: &S) -> Signature; -} - -impl Signable for T { - fn sign(&self, signer: &S) -> Signature { - signer.sign_message_sync(&self.encode_to_vec()).unwrap() - } -} diff --git a/crates/sdk/src/network-v2/proto/mod.rs b/crates/sdk/src/network-v2/proto/mod.rs deleted file mode 100644 index 48eb63675a..0000000000 --- a/crates/sdk/src/network-v2/proto/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod artifact; -pub mod network; diff --git a/crates/sdk/src/network-v2/proto/network.rs b/crates/sdk/src/network-v2/proto/network.rs deleted file mode 100644 index dd0077db9a..0000000000 --- a/crates/sdk/src/network-v2/proto/network.rs +++ /dev/null @@ -1,3932 +0,0 @@ -// This file is @generated by prost-build. -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RequestProofRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RequestProofRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The verification key hash of the program. - #[prost(bytes = "vec", tag = "2")] - pub vk_hash: ::prost::alloc::vec::Vec, - /// The version of the prover to use. - #[prost(string, tag = "3")] - pub version: ::prost::alloc::string::String, - /// The mode for the request. - #[prost(enumeration = "ProofMode", tag = "4")] - pub mode: i32, - /// The strategy for fulfiller assignment. - #[prost(enumeration = "FulfillmentStrategy", tag = "5")] - pub strategy: i32, - /// The stdin resource identifier. - #[prost(string, tag = "6")] - pub stdin_uri: ::prost::alloc::string::String, - /// The deadline for the request. - #[prost(uint64, tag = "7")] - pub deadline: u64, - /// The cycle limit for the request. - #[prost(uint64, tag = "8")] - pub cycle_limit: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RequestProofResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RequestProofResponseBody { - /// The identifier for the request. - #[prost(bytes = "vec", tag = "1")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FulfillProofRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FulfillProofRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The identifier for the request. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, - /// The proof bytes. - #[prost(bytes = "vec", tag = "3")] - pub proof: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FulfillProofResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct FulfillProofResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ExecuteProofRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ExecuteProofRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The identifier for the request. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, - /// The execution status of the request. - #[prost(enumeration = "ExecutionStatus", tag = "3")] - pub execution_status: i32, - /// The optional public values hash of the request execution, only included if - /// the request is valid. - #[prost(bytes = "vec", optional, tag = "4")] - pub public_values_hash: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional cycles used when executing the request, only included if the - /// request is valid. - #[prost(uint64, optional, tag = "5")] - pub cycles: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ExecuteProofResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct ExecuteProofResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailFulfillmentRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailFulfillmentRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The identifier for the request. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailFulfillmentResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct FailFulfillmentResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailExecutionRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailExecutionRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The identifier for the request. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FailExecutionResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct FailExecutionResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ProofRequest { - /// The request identifier. - #[prost(bytes = "vec", tag = "1")] - pub request_id: ::prost::alloc::vec::Vec, - /// The verification key hash of the program. - #[prost(bytes = "vec", tag = "2")] - pub vk_hash: ::prost::alloc::vec::Vec, - /// The version of the prover to use. - #[prost(string, tag = "3")] - pub version: ::prost::alloc::string::String, - /// The mode for the proof. - #[prost(enumeration = "ProofMode", tag = "4")] - pub mode: i32, - /// The strategy for fulfiller assignment. - #[prost(enumeration = "FulfillmentStrategy", tag = "5")] - pub strategy: i32, - /// The program resource identifier. - #[prost(string, tag = "6")] - pub program_uri: ::prost::alloc::string::String, - /// The stdin resource identifier. - #[prost(string, tag = "7")] - pub stdin_uri: ::prost::alloc::string::String, - /// The deadline for the request. - #[prost(uint64, tag = "8")] - pub deadline: u64, - /// The cycle limit for the request. - #[prost(uint64, tag = "9")] - pub cycle_limit: u64, - /// The gas price for the request. - #[prost(uint64, optional, tag = "10")] - pub gas_price: ::core::option::Option, - /// The fulfillment status of the request. - #[prost(enumeration = "FulfillmentStatus", tag = "11")] - pub fulfillment_status: i32, - /// The execution status of the request. - #[prost(enumeration = "ExecutionStatus", tag = "12")] - pub execution_status: i32, - /// The requester address that signed the request. - #[prost(bytes = "vec", tag = "13")] - pub requester: ::prost::alloc::vec::Vec, - /// The fulfiller address that fulfilled the request. - #[prost(bytes = "vec", optional, tag = "14")] - pub fulfiller: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional name to refer to an alias of the program id. - #[prost(string, optional, tag = "15")] - pub program_name: ::core::option::Option<::prost::alloc::string::String>, - /// The optional name to refer to an alias of the requester address. - #[prost(string, optional, tag = "16")] - pub requester_name: ::core::option::Option<::prost::alloc::string::String>, - /// The optional name to refer to an alias of the fulfiller address. - #[prost(string, optional, tag = "17")] - pub fulfiller_name: ::core::option::Option<::prost::alloc::string::String>, - /// The unix timestamp of when the request was created. - #[prost(uint64, tag = "18")] - pub created_at: u64, - /// The unix timestamp of when the request was updated. - #[prost(uint64, tag = "19")] - pub updated_at: u64, - /// The unix timestamp of when the request was fulfilled. - #[prost(uint64, optional, tag = "20")] - pub fulfilled_at: ::core::option::Option, - /// The transaction hash of the request. - #[prost(bytes = "vec", tag = "21")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The cycle count for the request. - #[prost(uint64, optional, tag = "22")] - pub cycles: ::core::option::Option, - /// The amount deducted from the fulfiller's balance. - #[prost(string, optional, tag = "23")] - pub deduction_amount: ::core::option::Option<::prost::alloc::string::String>, - /// The amount refunded to the fulfiller's balance. - #[prost(string, optional, tag = "24")] - pub refund_amount: ::core::option::Option<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestStatusRequest { - /// The identifier for the request. - #[prost(bytes = "vec", tag = "1")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestStatusResponse { - /// The fulfillment status of the request. - #[prost(enumeration = "FulfillmentStatus", tag = "1")] - pub fulfillment_status: i32, - /// The execution status of the request. - #[prost(enumeration = "ExecutionStatus", tag = "2")] - pub execution_status: i32, - /// The transaction hash of the request. - #[prost(bytes = "vec", tag = "3")] - pub request_tx_hash: ::prost::alloc::vec::Vec, - /// The optional transaction hash of the proof fulfill. Only included if the - /// request has a fulfillment status of FULFILLED. - #[prost(bytes = "vec", optional, tag = "4")] - pub fulfill_tx_hash: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional proof URI, where you can download the result of the request. - /// Only included if the request has a fulfillment status of FULFILLED. - #[prost(string, optional, tag = "5")] - pub proof_uri: ::core::option::Option<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestDetailsRequest { - /// The identifier for the request. - #[prost(bytes = "vec", tag = "1")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestDetailsResponse { - /// The detailed request. - #[prost(message, optional, tag = "1")] - pub request: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredProofRequestsRequest { - /// The optional version of the requests to filter for. - #[prost(string, optional, tag = "1")] - pub version: ::core::option::Option<::prost::alloc::string::String>, - /// The optional fulfillment status of the requests to filter for. - #[prost(enumeration = "FulfillmentStatus", optional, tag = "2")] - pub fulfillment_status: ::core::option::Option, - /// The optional execution status of the requests to filter for. - #[prost(enumeration = "ExecutionStatus", optional, tag = "3")] - pub execution_status: ::core::option::Option, - /// The optional minimum unix timestamp deadline of the requests to filter for. - /// Only returns requests with deadlines after this timestamp. - #[prost(uint64, optional, tag = "4")] - pub minimum_deadline: ::core::option::Option, - /// The optional verification key hash of the program to filter for. - #[prost(bytes = "vec", optional, tag = "5")] - pub vk_hash: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional requester address to filter for. - #[prost(bytes = "vec", optional, tag = "6")] - pub requester: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional fulfiller address to filter for. - #[prost(bytes = "vec", optional, tag = "7")] - pub fulfiller: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional minimum creation unix timestamp of the requests to filter for. - #[prost(uint64, optional, tag = "8")] - pub from: ::core::option::Option, - /// The optional maximum creation unix timestamp of the requests to filter for. - #[prost(uint64, optional, tag = "9")] - pub to: ::core::option::Option, - /// The optional maximum number of requests to return (default is 10, - /// maximum is 100). - #[prost(uint32, optional, tag = "10")] - pub limit: ::core::option::Option, - /// The optional page number to return (default is 1). - #[prost(uint32, optional, tag = "11")] - pub page: ::core::option::Option, - /// The optional mode of the requests to filter for. - #[prost(enumeration = "ProofMode", optional, tag = "12")] - pub mode: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredProofRequestsResponse { - /// The requests that matched the filter criteria. - #[prost(message, repeated, tag = "1")] - pub requests: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetSearchResultsRequest { - /// The search query string. - #[prost(string, tag = "1")] - pub query: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SearchResult { - #[prost(bytes = "vec", tag = "1")] - pub id: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "2")] - pub name: ::core::option::Option<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetSearchResultsResponse { - /// List of matching request IDs with optional names. - #[prost(message, repeated, tag = "1")] - pub requests: ::prost::alloc::vec::Vec, - /// List of matching program IDs with optional names. - #[prost(message, repeated, tag = "2")] - pub programs: ::prost::alloc::vec::Vec, - /// List of matching requester IDs with optional names. - #[prost(message, repeated, tag = "3")] - pub requesters: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestMetricsRequest { - /// The optional address to filter for. - #[prost(bytes = "vec", optional, tag = "1")] - pub address: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional interval in days for volume calculation. - #[prost(uint64, optional, tag = "2")] - pub volume_interval_days: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetProofRequestMetricsResponse { - /// The total number of proofs. - #[prost(uint64, tag = "1")] - pub total_proofs: u64, - /// The total number of cycles. - #[prost(uint64, tag = "2")] - pub total_cycles: u64, - /// The volume in the specified interval. - #[prost(uint64, tag = "3")] - pub volume: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestGraphRequest { - /// The optional address to filter for. - #[prost(bytes = "vec", optional, tag = "1")] - pub address: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional interval in days for the graph range. - #[prost(uint64, optional, tag = "2")] - pub range_interval_days: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GraphData { - /// The timestamp of the data point. - #[prost(string, tag = "1")] - pub timestamp: ::prost::alloc::string::String, - /// The value at this timestamp. - #[prost(uint64, tag = "2")] - pub value: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestGraphResponse { - /// The time series data points. - #[prost(message, repeated, tag = "1")] - pub data: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetAnalyticsGraphsRequest { - /// The optional address to filter for. - #[prost(bytes = "vec", optional, tag = "1")] - pub address: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional interval in days for the graph range. - #[prost(uint64, optional, tag = "2")] - pub range_interval_days: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetAnalyticsGraphsResponse { - /// The time series data points for proof count. - #[prost(message, repeated, tag = "1")] - pub proofs: ::prost::alloc::vec::Vec, - /// The time series data points for program count. - #[prost(message, repeated, tag = "2")] - pub programs: ::prost::alloc::vec::Vec, - /// The time series data points for cycle count. - #[prost(message, repeated, tag = "3")] - pub cycles: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetNonceRequest { - /// The address of the account. - #[prost(bytes = "vec", tag = "1")] - pub address: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetNonceResponse { - /// The nonce of the account. - #[prost(uint64, tag = "1")] - pub nonce: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct Delegation { - /// The address of the owner. - #[prost(bytes = "vec", tag = "1")] - pub owner: ::prost::alloc::vec::Vec, - /// The address of the delegate (the account with granted permissions). - #[prost(bytes = "vec", tag = "2")] - pub delegate: ::prost::alloc::vec::Vec, - /// Whether the delegation has been accepted. - #[prost(bool, tag = "3")] - pub accepted: bool, - /// The unix timestamp of when the delegation was created. - #[prost(uint64, tag = "4")] - pub created_at: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredDelegationsRequest { - /// The optional owner address to filter for. - #[prost(bytes = "vec", optional, tag = "1")] - pub owner: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional maximum number of requests to return (default is 10, - /// maximum is 100). - #[prost(uint32, optional, tag = "2")] - pub limit: ::core::option::Option, - /// The optional page number to return (default is 1). - #[prost(uint32, optional, tag = "3")] - pub page: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredDelegationsResponse { - /// The delegations that matched the filter criteria. - #[prost(message, repeated, tag = "1")] - pub delegations: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddDelegationRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddDelegationRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The delegate address to add. - #[prost(bytes = "vec", tag = "2")] - pub delegate: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddDelegationResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct AddDelegationResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveDelegationRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveDelegationRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The delegate address to remove. - #[prost(bytes = "vec", tag = "2")] - pub delegate: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveDelegationResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct RemoveDelegationResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AcceptDelegationRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AcceptDelegationRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the owner who requested the delegation - #[prost(bytes = "vec", tag = "2")] - pub owner: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AcceptDelegationResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct AcceptDelegationResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetAccountNameRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetAccountNameRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the account to update the name of. Only the sender can - /// update the name unless authorized. - #[prost(bytes = "vec", tag = "2")] - pub address: ::prost::alloc::vec::Vec, - /// The name of the account. Must be unique. - #[prost(string, tag = "3")] - pub name: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetAccountNameResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct SetAccountNameResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetAccountNameRequest { - /// The address of the account. - #[prost(bytes = "vec", tag = "1")] - pub address: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetAccountNameResponse { - /// The name of the account. - #[prost(string, optional, tag = "1")] - pub name: ::core::option::Option<::prost::alloc::string::String>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetTermsSignatureRequest { - /// The address of the account. - #[prost(bytes = "vec", tag = "1")] - pub address: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetTermsSignatureResponse { - /// Whether the account has signed the terms. - #[prost(bool, tag = "1")] - pub is_signed: bool, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetTermsSignatureRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetTermsSignatureRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the account. - #[prost(bytes = "vec", tag = "2")] - pub address: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetTermsSignatureResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct SetTermsSignatureResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct Program { - /// The verification key hash. - #[prost(bytes = "vec", tag = "1")] - pub vk_hash: ::prost::alloc::vec::Vec, - /// The verification key. - #[prost(bytes = "vec", tag = "2")] - pub vk: ::prost::alloc::vec::Vec, - /// The program resource identifier. - #[prost(string, tag = "3")] - pub program_uri: ::prost::alloc::string::String, - /// The optional name of the program. - #[prost(string, optional, tag = "4")] - pub name: ::core::option::Option<::prost::alloc::string::String>, - /// The owner of the program. - #[prost(bytes = "vec", tag = "5")] - pub owner: ::prost::alloc::vec::Vec, - /// The unix timestamp of when the program was created. - #[prost(uint64, tag = "6")] - pub created_at: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProgramRequest { - /// The verification key hash of the program. - #[prost(bytes = "vec", tag = "1")] - pub vk_hash: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProgramResponse { - /// The program details. - #[prost(message, optional, tag = "1")] - pub program: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CreateProgramRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CreateProgramRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The verification key hash. - #[prost(bytes = "vec", tag = "2")] - pub vk_hash: ::prost::alloc::vec::Vec, - /// The verification key. - #[prost(bytes = "vec", tag = "3")] - pub vk: ::prost::alloc::vec::Vec, - /// The program resource identifier. - #[prost(string, tag = "4")] - pub program_uri: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CreateProgramResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct CreateProgramResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetProgramNameRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetProgramNameRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The identifier of the program to update the name of. Only the original - /// program creator can update the name unless authorized. - #[prost(bytes = "vec", tag = "2")] - pub vk_hash: ::prost::alloc::vec::Vec, - /// The name of the program. Must be unique. - #[prost(string, tag = "3")] - pub name: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SetProgramNameResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct SetProgramNameResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetBalanceRequest { - /// The address of the account. - #[prost(bytes = "vec", tag = "1")] - pub address: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetBalanceResponse { - /// The amount of credits owned by the account. - #[prost(string, tag = "1")] - pub amount: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BalanceLog { - /// The address of the account. - #[prost(bytes = "vec", tag = "1")] - pub address: ::prost::alloc::vec::Vec, - /// The type of balance change operation. - #[prost(enumeration = "BalanceOperation", tag = "2")] - pub operation: i32, - /// The amount of the change (can be positive or negative). - #[prost(string, tag = "3")] - pub amount: ::prost::alloc::string::String, - /// The transaction hash that caused this change. - #[prost(bytes = "vec", tag = "4")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The unix timestamp of when this change occurred. - #[prost(uint64, tag = "5")] - pub created_at: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredBalanceLogsRequest { - /// The optional address to filter for. - #[prost(bytes = "vec", optional, tag = "1")] - pub address: ::core::option::Option<::prost::alloc::vec::Vec>, - /// The optional type of operations to filter for. - #[prost(enumeration = "BalanceOperation", optional, tag = "2")] - pub operation: ::core::option::Option, - /// The optional minimum unix timestamp to filter logs from. Only returns - /// logs after this timestamp. - #[prost(uint64, optional, tag = "3")] - pub minimum_timestamp: ::core::option::Option, - /// The optional maximum unix timestamp to filter logs to. Only returns - /// logs before this timestamp. - #[prost(uint64, optional, tag = "4")] - pub maximum_timestamp: ::core::option::Option, - /// The optional maximum number of logs to return (default is 10, maximum is 100). - #[prost(uint32, optional, tag = "5")] - pub limit: ::core::option::Option, - /// The optional page number to return (default is 1). - #[prost(uint32, optional, tag = "6")] - pub page: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredBalanceLogsResponse { - /// The balance logs that matched the filter criteria. - #[prost(message, repeated, tag = "1")] - pub logs: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddCreditRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddCreditRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the account to add credits to. - #[prost(bytes = "vec", tag = "2")] - pub address: ::prost::alloc::vec::Vec, - /// The amount of credits to add. - #[prost(string, tag = "3")] - pub amount: ::prost::alloc::string::String, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddCreditResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct AddCreditResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetLatestBridgeBlockRequest { - /// The chain ID of the bridge. - #[prost(uint32, tag = "1")] - pub chain_id: u32, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetLatestBridgeBlockResponse { - /// The latest processed block in the bridge. - #[prost(uint64, tag = "1")] - pub block_number: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetGasPriceEstimateRequest { - #[prost(enumeration = "FulfillmentStrategy", tag = "1")] - pub strategy: i32, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetGasPriceEstimateResponse { - #[prost(uint64, tag = "1")] - pub gas_price: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetTransactionDetailsRequest { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct TransactionDetails { - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "2")] - pub sender: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "3")] - pub signature: ::prost::alloc::vec::Vec, - #[prost(uint64, tag = "4")] - pub nonce: u64, - #[prost(uint64, tag = "5")] - pub created_at: u64, - #[prost(string, optional, tag = "6")] - pub name: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bytes = "vec", optional, tag = "7")] - pub request_id: ::core::option::Option<::prost::alloc::vec::Vec>, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetTransactionDetailsResponse { - #[prost(message, optional, tag = "1")] - pub transaction: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct Reservation { - /// The address of the requester. - #[prost(bytes = "vec", tag = "1")] - pub requester: ::prost::alloc::vec::Vec, - /// The address of the fulfiller. - #[prost(bytes = "vec", tag = "2")] - pub fulfiller: ::prost::alloc::vec::Vec, - /// The optional name to refer to an alias of the requester address. - #[prost(string, optional, tag = "3")] - pub requester_name: ::core::option::Option<::prost::alloc::string::String>, - /// The optional name to refer to an alias of the fulfiller address. - #[prost(string, optional, tag = "4")] - pub fulfiller_name: ::core::option::Option<::prost::alloc::string::String>, - /// The unix timestamp of when the reservation was created. - #[prost(uint64, tag = "5")] - pub created_at: u64, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetFilteredReservationsRequest { - /// The optional maximum number of reservations to return (default is 10, - /// maximum is 100). - #[prost(uint32, optional, tag = "1")] - pub limit: ::core::option::Option, - /// The optional page number to return (default is 1). - #[prost(uint32, optional, tag = "2")] - pub page: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetFilteredReservationsResponse { - /// The reservations that matched the filter criteria. - #[prost(message, repeated, tag = "1")] - pub reservations: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddReservationRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddReservationRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the requester to add reservation for. - #[prost(bytes = "vec", tag = "2")] - pub requester: ::prost::alloc::vec::Vec, - /// The address of the fulfiller to reserve. - #[prost(bytes = "vec", tag = "3")] - pub fulfiller: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct AddReservationResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct AddReservationResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveReservationRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveReservationRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The address of the requester to remove reservation for. - #[prost(bytes = "vec", tag = "2")] - pub requester: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RemoveReservationResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct RemoveReservationResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BidRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BidRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The request ID to bid on. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct BidResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct BidResponseBody {} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SettleRequest { - /// The message format of the body. - #[prost(enumeration = "MessageFormat", tag = "1")] - pub format: i32, - /// The signature of the sender. - #[prost(bytes = "vec", tag = "2")] - pub signature: ::prost::alloc::vec::Vec, - /// The body of the request. - #[prost(message, optional, tag = "3")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SettleRequestBody { - /// The account nonce of the sender. - #[prost(uint64, tag = "1")] - pub nonce: u64, - /// The request ID to settle bids for. - #[prost(bytes = "vec", tag = "2")] - pub request_id: ::prost::alloc::vec::Vec, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SettleResponse { - /// The transaction hash. - #[prost(bytes = "vec", tag = "1")] - pub tx_hash: ::prost::alloc::vec::Vec, - /// The body of the response. - #[prost(message, optional, tag = "2")] - pub body: ::core::option::Option, -} -#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct SettleResponseBody {} -/// Format to help decode signature in backend. -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum MessageFormat { - /// Unspecified message format. - UnspecifiedMessageFormat = 0, - /// The message is in binary format. - Binary = 1, - /// The message is in JSON format. - Json = 2, -} -impl MessageFormat { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedMessageFormat => "UNSPECIFIED_MESSAGE_FORMAT", - Self::Binary => "BINARY", - Self::Json => "JSON", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_MESSAGE_FORMAT" => Some(Self::UnspecifiedMessageFormat), - "BINARY" => Some(Self::Binary), - "JSON" => Some(Self::Json), - _ => None, - } - } -} -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum ProofMode { - UnspecifiedProofMode = 0, - /// The core proof mode. - Core = 1, - /// The compressed proof mode. - Compressed = 2, - /// The plonk proof mode. - Plonk = 3, - /// The groth16 proof mode. - Groth16 = 4, -} -impl ProofMode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedProofMode => "UNSPECIFIED_PROOF_MODE", - Self::Core => "CORE", - Self::Compressed => "COMPRESSED", - Self::Plonk => "PLONK", - Self::Groth16 => "GROTH16", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_PROOF_MODE" => Some(Self::UnspecifiedProofMode), - "CORE" => Some(Self::Core), - "COMPRESSED" => Some(Self::Compressed), - "PLONK" => Some(Self::Plonk), - "GROTH16" => Some(Self::Groth16), - _ => None, - } - } -} -/// The different strategies that can be used for fulfilling requests. -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum FulfillmentStrategy { - UnspecifiedFulfillmentStrategy = 0, - /// The hosted fulfillment strategy. Uses Succinct's on-demand prover to fulfill requests. - Hosted = 1, - /// The reserved fulfillment strategy. Uses an already existing agreement with a - /// fulfiller to fulfill requests. - Reserved = 2, - /// The auction fulfillment strategy. Uses a decentralized proof contest to - /// fulfill requests. - Auction = 3, -} -impl FulfillmentStrategy { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedFulfillmentStrategy => "UNSPECIFIED_FULFILLMENT_STRATEGY", - Self::Hosted => "HOSTED", - Self::Reserved => "RESERVED", - Self::Auction => "AUCTION", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_FULFILLMENT_STRATEGY" => Some(Self::UnspecifiedFulfillmentStrategy), - "HOSTED" => Some(Self::Hosted), - "RESERVED" => Some(Self::Reserved), - "AUCTION" => Some(Self::Auction), - _ => None, - } - } -} -/// The different fulfillment statuses that a request can be in. -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum FulfillmentStatus { - UnspecifiedFulfillmentStatus = 0, - /// The request has been requested. - Requested = 1, - /// The request has been assigned to a fulfiller. - Assigned = 2, - /// The request has been fulfilled. - Fulfilled = 3, - /// The request cannot be fulfilled. - Unfulfillable = 4, -} -impl FulfillmentStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedFulfillmentStatus => "UNSPECIFIED_FULFILLMENT_STATUS", - Self::Requested => "REQUESTED", - Self::Assigned => "ASSIGNED", - Self::Fulfilled => "FULFILLED", - Self::Unfulfillable => "UNFULFILLABLE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_FULFILLMENT_STATUS" => Some(Self::UnspecifiedFulfillmentStatus), - "REQUESTED" => Some(Self::Requested), - "ASSIGNED" => Some(Self::Assigned), - "FULFILLED" => Some(Self::Fulfilled), - "UNFULFILLABLE" => Some(Self::Unfulfillable), - _ => None, - } - } -} -/// The different execution statuses that a request can be in. -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum ExecutionStatus { - UnspecifiedExecutionStatus = 0, - /// The request has not been executed. - Unexecuted = 1, - /// The request has been executed. - Executed = 2, - /// The request cannot be executed. - Unexecutable = 3, -} -impl ExecutionStatus { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedExecutionStatus => "UNSPECIFIED_EXECUTION_STATUS", - Self::Unexecuted => "UNEXECUTED", - Self::Executed => "EXECUTED", - Self::Unexecutable => "UNEXECUTABLE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_EXECUTION_STATUS" => Some(Self::UnspecifiedExecutionStatus), - "UNEXECUTED" => Some(Self::Unexecuted), - "EXECUTED" => Some(Self::Executed), - "UNEXECUTABLE" => Some(Self::Unexecutable), - _ => None, - } - } -} -/// The different types of balance changes that can occur. -#[derive( - serde::Serialize, - serde::Deserialize, - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration, -)] -#[repr(i32)] -pub enum BalanceOperation { - UnspecifiedBalanceChangeOperation = 0, - /// A deposit operation (positive). - Deposit = 1, - /// A withdrawal operation (negative). - Withdrawal = 2, - /// A credit operation (positive). - Credit = 3, - /// A deduction operation (negative). - Deduction = 4, - /// A refund operation (positive). - Refund = 5, - /// A bid operation (negative). - Bid = 6, -} -impl BalanceOperation { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::UnspecifiedBalanceChangeOperation => "UNSPECIFIED_BALANCE_CHANGE_OPERATION", - Self::Deposit => "DEPOSIT", - Self::Withdrawal => "WITHDRAWAL", - Self::Credit => "CREDIT", - Self::Deduction => "DEDUCTION", - Self::Refund => "REFUND", - Self::Bid => "BID", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "UNSPECIFIED_BALANCE_CHANGE_OPERATION" => Some(Self::UnspecifiedBalanceChangeOperation), - "DEPOSIT" => Some(Self::Deposit), - "WITHDRAWAL" => Some(Self::Withdrawal), - "CREDIT" => Some(Self::Credit), - "DEDUCTION" => Some(Self::Deduction), - "REFUND" => Some(Self::Refund), - "BID" => Some(Self::Bid), - _ => None, - } - } -} -/// Generated client implementations. -pub mod prover_network_client { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::http::Uri; - use tonic::codegen::*; - #[derive(Debug, Clone)] - pub struct ProverNetworkClient { - inner: tonic::client::Grpc, - } - impl ProverNetworkClient { - /// Attempt to create a new client by connecting to a given endpoint. - pub async fn connect(dst: D) -> Result - where - D: TryInto, - D::Error: Into, - { - let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; - Ok(Self::new(conn)) - } - } - impl ProverNetworkClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + std::marker::Send, - { - pub fn new(inner: T) -> Self { - let inner = tonic::client::Grpc::new(inner); - Self { inner } - } - pub fn with_origin(inner: T, origin: Uri) -> Self { - let inner = tonic::client::Grpc::with_origin(inner, origin); - Self { inner } - } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> ProverNetworkClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, - { - ProverNetworkClient::new(InterceptedService::new(inner, interceptor)) - } - /// Compress requests with the given encoding. - /// - /// This requires the server to support it otherwise it might respond with an - /// error. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.send_compressed(encoding); - self - } - /// Enable decompressing responses. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.inner = self.inner.accept_compressed(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_decoding_message_size(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.inner = self.inner.max_encoding_message_size(limit); - self - } - /// Creates a proof request. - pub async fn request_proof( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/RequestProof"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "RequestProof")); - self.inner.unary(req, path, codec).await - } - /// Fulfills a proof request. Only callable by the assigned fulfiller. - pub async fn fulfill_proof( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/FulfillProof"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "FulfillProof")); - self.inner.unary(req, path, codec).await - } - /// Executes a proof request. Only callable by the execution oracle. - pub async fn execute_proof( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/ExecuteProof"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "ExecuteProof")); - self.inner.unary(req, path, codec).await - } - /// Fails fulfillment. Only callable by the assigned fulfiller. - pub async fn fail_fulfillment( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/FailFulfillment"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "FailFulfillment")); - self.inner.unary(req, path, codec).await - } - /// Fails execution. Only callable by the execution oracle. - pub async fn fail_execution( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/FailExecution"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "FailExecution")); - self.inner.unary(req, path, codec).await - } - /// Get the status of a proof request. - pub async fn get_proof_request_status( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetProofRequestStatus", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestStatus")); - self.inner.unary(req, path, codec).await - } - /// Get the details of a proof request. - pub async fn get_proof_request_details( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetProofRequestDetails", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestDetails")); - self.inner.unary(req, path, codec).await - } - /// Get the proof requests that meet the filter criteria. - pub async fn get_filtered_proof_requests( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetFilteredProofRequests", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredProofRequests")); - self.inner.unary(req, path, codec).await - } - /// Search for proof requests, programs, and requesters. - pub async fn get_search_results( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetSearchResults"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetSearchResults")); - self.inner.unary(req, path, codec).await - } - /// Get metrics for proof requests. - pub async fn get_proof_request_metrics( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetProofRequestMetrics", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestMetrics")); - self.inner.unary(req, path, codec).await - } - /// Get time series data for proof requests. - pub async fn get_proof_request_graph( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetProofRequestGraph"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestGraph")); - self.inner.unary(req, path, codec).await - } - /// Get analytics graphs for proof requests. - pub async fn get_analytics_graphs( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetAnalyticsGraphs"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetAnalyticsGraphs")); - self.inner.unary(req, path, codec).await - } - /// Get the nonce of the account. - pub async fn get_nonce( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetNonce"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetNonce")); - self.inner.unary(req, path, codec).await - } - /// Get the delegations of the account. - pub async fn get_filtered_delegations( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetFilteredDelegations", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredDelegations")); - self.inner.unary(req, path, codec).await - } - /// Add a delegation. Only callable by the owner of an account. - pub async fn add_delegation( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddDelegation"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddDelegation")); - self.inner.unary(req, path, codec).await - } - /// Remove a delegation. Only callable by the owner of an account. - pub async fn remove_delegation( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/RemoveDelegation"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "RemoveDelegation")); - self.inner.unary(req, path, codec).await - } - /// Accept a delegation. Only callable by the delegate of a delegation. - pub async fn accept_delegation( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/AcceptDelegation"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "AcceptDelegation")); - self.inner.unary(req, path, codec).await - } - /// Set the name of the account. Only callable by the owner of an account. - pub async fn set_account_name( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetAccountName"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "SetAccountName")); - self.inner.unary(req, path, codec).await - } - /// Get the name of the account. - pub async fn get_account_name( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetAccountName"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetAccountName")); - self.inner.unary(req, path, codec).await - } - /// Get whether the account has signed the terms. - pub async fn get_terms_signature( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetTermsSignature"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetTermsSignature")); - self.inner.unary(req, path, codec).await - } - /// Set whether the account has signed the terms. - pub async fn set_terms_signature( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetTermsSignature"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "SetTermsSignature")); - self.inner.unary(req, path, codec).await - } - /// Get metadata about a program. - pub async fn get_program( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetProgram"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetProgram")); - self.inner.unary(req, path, codec).await - } - /// Create a new program. Must be called before requesting proofs. - pub async fn create_program( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/CreateProgram"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "CreateProgram")); - self.inner.unary(req, path, codec).await - } - /// Set the name of the program. Only callable by the owner. - pub async fn set_program_name( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetProgramName"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "SetProgramName")); - self.inner.unary(req, path, codec).await - } - /// Get the available balance of an account. - pub async fn get_balance( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetBalance"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetBalance")); - self.inner.unary(req, path, codec).await - } - /// Get the balance logs that meet the filter criteria. - pub async fn get_filtered_balance_logs( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetFilteredBalanceLogs", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredBalanceLogs")); - self.inner.unary(req, path, codec).await - } - /// Add credit to an account. - pub async fn add_credit( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddCredit"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddCredit")); - self.inner.unary(req, path, codec).await - } - /// Get the latest processed block in the bridge. - pub async fn get_latest_bridge_block( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetLatestBridgeBlock"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetLatestBridgeBlock")); - self.inner.unary(req, path, codec).await - } - /// Get the gas price estimate for a given fulfillment strategy. - pub async fn get_gas_price_estimate( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetGasPriceEstimate"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetGasPriceEstimate")); - self.inner.unary(req, path, codec).await - } - /// Get the details of a transaction. - pub async fn get_transaction_details( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetTransactionDetails", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetTransactionDetails")); - self.inner.unary(req, path, codec).await - } - /// Get the reservations that meet the filter criteria. - pub async fn get_filtered_reservations( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/network.ProverNetwork/GetFilteredReservations", - ); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredReservations")); - self.inner.unary(req, path, codec).await - } - /// Add a reservation for a requester. - pub async fn add_reservation( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddReservation"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddReservation")); - self.inner.unary(req, path, codec).await - } - /// Remove a reservation for a requester. - pub async fn remove_reservation( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = - http::uri::PathAndQuery::from_static("/network.ProverNetwork/RemoveReservation"); - let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("network.ProverNetwork", "RemoveReservation")); - self.inner.unary(req, path, codec).await - } - /// Bid for a proof request. Provers that want to be assigned this request must first - /// bid on it. - pub async fn bid( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/Bid"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "Bid")); - self.inner.unary(req, path, codec).await - } - /// Settle the bids on a proof request to choose the assigned prover. Only callable by - /// the approved settler. - pub async fn settle( - &mut self, - request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::new( - tonic::Code::Unknown, - format!("Service was not ready: {}", e.into()), - ) - })?; - let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/Settle"); - let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "Settle")); - self.inner.unary(req, path, codec).await - } - } -} -/// Generated server implementations. -pub mod prover_network_server { - #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ProverNetworkServer. - #[async_trait] - pub trait ProverNetwork: std::marker::Send + std::marker::Sync + 'static { - /// Creates a proof request. - async fn request_proof( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Fulfills a proof request. Only callable by the assigned fulfiller. - async fn fulfill_proof( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Executes a proof request. Only callable by the execution oracle. - async fn execute_proof( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Fails fulfillment. Only callable by the assigned fulfiller. - async fn fail_fulfillment( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Fails execution. Only callable by the execution oracle. - async fn fail_execution( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the status of a proof request. - async fn get_proof_request_status( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the details of a proof request. - async fn get_proof_request_details( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Get the proof requests that meet the filter criteria. - async fn get_filtered_proof_requests( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Search for proof requests, programs, and requesters. - async fn get_search_results( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get metrics for proof requests. - async fn get_proof_request_metrics( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Get time series data for proof requests. - async fn get_proof_request_graph( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get analytics graphs for proof requests. - async fn get_analytics_graphs( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the nonce of the account. - async fn get_nonce( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the delegations of the account. - async fn get_filtered_delegations( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Add a delegation. Only callable by the owner of an account. - async fn add_delegation( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Remove a delegation. Only callable by the owner of an account. - async fn remove_delegation( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Accept a delegation. Only callable by the delegate of a delegation. - async fn accept_delegation( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Set the name of the account. Only callable by the owner of an account. - async fn set_account_name( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the name of the account. - async fn get_account_name( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get whether the account has signed the terms. - async fn get_terms_signature( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Set whether the account has signed the terms. - async fn set_terms_signature( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get metadata about a program. - async fn get_program( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Create a new program. Must be called before requesting proofs. - async fn create_program( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Set the name of the program. Only callable by the owner. - async fn set_program_name( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the available balance of an account. - async fn get_balance( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the balance logs that meet the filter criteria. - async fn get_filtered_balance_logs( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Add credit to an account. - async fn add_credit( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the latest processed block in the bridge. - async fn get_latest_bridge_block( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the gas price estimate for a given fulfillment strategy. - async fn get_gas_price_estimate( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the details of a transaction. - async fn get_transaction_details( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Get the reservations that meet the filter criteria. - async fn get_filtered_reservations( - &self, - request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; - /// Add a reservation for a requester. - async fn add_reservation( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Remove a reservation for a requester. - async fn remove_reservation( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Bid for a proof request. Provers that want to be assigned this request must first - /// bid on it. - async fn bid( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - /// Settle the bids on a proof request to choose the assigned prover. Only callable by - /// the approved settler. - async fn settle( - &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; - } - #[derive(Debug)] - pub struct ProverNetworkServer { - inner: Arc, - accept_compression_encodings: EnabledCompressionEncodings, - send_compression_encodings: EnabledCompressionEncodings, - max_decoding_message_size: Option, - max_encoding_message_size: Option, - } - impl ProverNetworkServer { - pub fn new(inner: T) -> Self { - Self::from_arc(Arc::new(inner)) - } - pub fn from_arc(inner: Arc) -> Self { - Self { - inner, - accept_compression_encodings: Default::default(), - send_compression_encodings: Default::default(), - max_decoding_message_size: None, - max_encoding_message_size: None, - } - } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService - where - F: tonic::service::Interceptor, - { - InterceptedService::new(Self::new(inner), interceptor) - } - /// Enable decompressing requests with the given encoding. - #[must_use] - pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.accept_compression_encodings.enable(encoding); - self - } - /// Compress responses with the given encoding, if the client supports it. - #[must_use] - pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { - self.send_compression_encodings.enable(encoding); - self - } - /// Limits the maximum size of a decoded message. - /// - /// Default: `4MB` - #[must_use] - pub fn max_decoding_message_size(mut self, limit: usize) -> Self { - self.max_decoding_message_size = Some(limit); - self - } - /// Limits the maximum size of an encoded message. - /// - /// Default: `usize::MAX` - #[must_use] - pub fn max_encoding_message_size(mut self, limit: usize) -> Self { - self.max_encoding_message_size = Some(limit); - self - } - } - impl tonic::codegen::Service> for ProverNetworkServer - where - T: ProverNetwork, - B: Body + std::marker::Send + 'static, - B::Error: Into + std::marker::Send + 'static, - { - type Response = http::Response; - type Error = std::convert::Infallible; - type Future = BoxFuture; - fn poll_ready( - &mut self, - _cx: &mut Context<'_>, - ) -> Poll> { - Poll::Ready(Ok(())) - } - fn call(&mut self, req: http::Request) -> Self::Future { - match req.uri().path() { - "/network.ProverNetwork/RequestProof" => { - #[allow(non_camel_case_types)] - struct RequestProofSvc(pub Arc); - impl tonic::server::UnaryService - for RequestProofSvc - { - type Response = super::RequestProofResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::request_proof(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = RequestProofSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/FulfillProof" => { - #[allow(non_camel_case_types)] - struct FulfillProofSvc(pub Arc); - impl tonic::server::UnaryService - for FulfillProofSvc - { - type Response = super::FulfillProofResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::fulfill_proof(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = FulfillProofSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/ExecuteProof" => { - #[allow(non_camel_case_types)] - struct ExecuteProofSvc(pub Arc); - impl tonic::server::UnaryService - for ExecuteProofSvc - { - type Response = super::ExecuteProofResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::execute_proof(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = ExecuteProofSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/FailFulfillment" => { - #[allow(non_camel_case_types)] - struct FailFulfillmentSvc(pub Arc); - impl - tonic::server::UnaryService - for FailFulfillmentSvc - { - type Response = super::FailFulfillmentResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::fail_fulfillment(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = FailFulfillmentSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/FailExecution" => { - #[allow(non_camel_case_types)] - struct FailExecutionSvc(pub Arc); - impl tonic::server::UnaryService - for FailExecutionSvc - { - type Response = super::FailExecutionResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::fail_execution(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = FailExecutionSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetProofRequestStatus" => { - #[allow(non_camel_case_types)] - struct GetProofRequestStatusSvc(pub Arc); - impl - tonic::server::UnaryService - for GetProofRequestStatusSvc - { - type Response = super::GetProofRequestStatusResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proof_request_status(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetProofRequestStatusSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetProofRequestDetails" => { - #[allow(non_camel_case_types)] - struct GetProofRequestDetailsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetProofRequestDetailsSvc - { - type Response = super::GetProofRequestDetailsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proof_request_details(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetProofRequestDetailsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetFilteredProofRequests" => { - #[allow(non_camel_case_types)] - struct GetFilteredProofRequestsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetFilteredProofRequestsSvc - { - type Response = super::GetFilteredProofRequestsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_filtered_proof_requests(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetFilteredProofRequestsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetSearchResults" => { - #[allow(non_camel_case_types)] - struct GetSearchResultsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetSearchResultsSvc - { - type Response = super::GetSearchResultsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_search_results(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetSearchResultsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetProofRequestMetrics" => { - #[allow(non_camel_case_types)] - struct GetProofRequestMetricsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetProofRequestMetricsSvc - { - type Response = super::GetProofRequestMetricsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proof_request_metrics(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetProofRequestMetricsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetProofRequestGraph" => { - #[allow(non_camel_case_types)] - struct GetProofRequestGraphSvc(pub Arc); - impl - tonic::server::UnaryService - for GetProofRequestGraphSvc - { - type Response = super::GetProofRequestGraphResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_proof_request_graph(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetProofRequestGraphSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetAnalyticsGraphs" => { - #[allow(non_camel_case_types)] - struct GetAnalyticsGraphsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetAnalyticsGraphsSvc - { - type Response = super::GetAnalyticsGraphsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_analytics_graphs(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetAnalyticsGraphsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetNonce" => { - #[allow(non_camel_case_types)] - struct GetNonceSvc(pub Arc); - impl tonic::server::UnaryService for GetNonceSvc { - type Response = super::GetNonceResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_nonce(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetNonceSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetFilteredDelegations" => { - #[allow(non_camel_case_types)] - struct GetFilteredDelegationsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetFilteredDelegationsSvc - { - type Response = super::GetFilteredDelegationsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_filtered_delegations(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetFilteredDelegationsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/AddDelegation" => { - #[allow(non_camel_case_types)] - struct AddDelegationSvc(pub Arc); - impl tonic::server::UnaryService - for AddDelegationSvc - { - type Response = super::AddDelegationResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::add_delegation(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = AddDelegationSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/RemoveDelegation" => { - #[allow(non_camel_case_types)] - struct RemoveDelegationSvc(pub Arc); - impl - tonic::server::UnaryService - for RemoveDelegationSvc - { - type Response = super::RemoveDelegationResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::remove_delegation(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = RemoveDelegationSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/AcceptDelegation" => { - #[allow(non_camel_case_types)] - struct AcceptDelegationSvc(pub Arc); - impl - tonic::server::UnaryService - for AcceptDelegationSvc - { - type Response = super::AcceptDelegationResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::accept_delegation(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = AcceptDelegationSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/SetAccountName" => { - #[allow(non_camel_case_types)] - struct SetAccountNameSvc(pub Arc); - impl tonic::server::UnaryService - for SetAccountNameSvc - { - type Response = super::SetAccountNameResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::set_account_name(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = SetAccountNameSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetAccountName" => { - #[allow(non_camel_case_types)] - struct GetAccountNameSvc(pub Arc); - impl tonic::server::UnaryService - for GetAccountNameSvc - { - type Response = super::GetAccountNameResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_account_name(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetAccountNameSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetTermsSignature" => { - #[allow(non_camel_case_types)] - struct GetTermsSignatureSvc(pub Arc); - impl - tonic::server::UnaryService - for GetTermsSignatureSvc - { - type Response = super::GetTermsSignatureResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_terms_signature(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetTermsSignatureSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/SetTermsSignature" => { - #[allow(non_camel_case_types)] - struct SetTermsSignatureSvc(pub Arc); - impl - tonic::server::UnaryService - for SetTermsSignatureSvc - { - type Response = super::SetTermsSignatureResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::set_terms_signature(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = SetTermsSignatureSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetProgram" => { - #[allow(non_camel_case_types)] - struct GetProgramSvc(pub Arc); - impl tonic::server::UnaryService for GetProgramSvc { - type Response = super::GetProgramResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_program(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetProgramSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/CreateProgram" => { - #[allow(non_camel_case_types)] - struct CreateProgramSvc(pub Arc); - impl tonic::server::UnaryService - for CreateProgramSvc - { - type Response = super::CreateProgramResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::create_program(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = CreateProgramSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/SetProgramName" => { - #[allow(non_camel_case_types)] - struct SetProgramNameSvc(pub Arc); - impl tonic::server::UnaryService - for SetProgramNameSvc - { - type Response = super::SetProgramNameResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::set_program_name(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = SetProgramNameSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetBalance" => { - #[allow(non_camel_case_types)] - struct GetBalanceSvc(pub Arc); - impl tonic::server::UnaryService for GetBalanceSvc { - type Response = super::GetBalanceResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_balance(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetBalanceSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetFilteredBalanceLogs" => { - #[allow(non_camel_case_types)] - struct GetFilteredBalanceLogsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetFilteredBalanceLogsSvc - { - type Response = super::GetFilteredBalanceLogsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_filtered_balance_logs(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetFilteredBalanceLogsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/AddCredit" => { - #[allow(non_camel_case_types)] - struct AddCreditSvc(pub Arc); - impl tonic::server::UnaryService for AddCreditSvc { - type Response = super::AddCreditResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::add_credit(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = AddCreditSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetLatestBridgeBlock" => { - #[allow(non_camel_case_types)] - struct GetLatestBridgeBlockSvc(pub Arc); - impl - tonic::server::UnaryService - for GetLatestBridgeBlockSvc - { - type Response = super::GetLatestBridgeBlockResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_latest_bridge_block(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetLatestBridgeBlockSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetGasPriceEstimate" => { - #[allow(non_camel_case_types)] - struct GetGasPriceEstimateSvc(pub Arc); - impl - tonic::server::UnaryService - for GetGasPriceEstimateSvc - { - type Response = super::GetGasPriceEstimateResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_gas_price_estimate(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetGasPriceEstimateSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetTransactionDetails" => { - #[allow(non_camel_case_types)] - struct GetTransactionDetailsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetTransactionDetailsSvc - { - type Response = super::GetTransactionDetailsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_transaction_details(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetTransactionDetailsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/GetFilteredReservations" => { - #[allow(non_camel_case_types)] - struct GetFilteredReservationsSvc(pub Arc); - impl - tonic::server::UnaryService - for GetFilteredReservationsSvc - { - type Response = super::GetFilteredReservationsResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::get_filtered_reservations(&inner, request) - .await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = GetFilteredReservationsSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/AddReservation" => { - #[allow(non_camel_case_types)] - struct AddReservationSvc(pub Arc); - impl tonic::server::UnaryService - for AddReservationSvc - { - type Response = super::AddReservationResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::add_reservation(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = AddReservationSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/RemoveReservation" => { - #[allow(non_camel_case_types)] - struct RemoveReservationSvc(pub Arc); - impl - tonic::server::UnaryService - for RemoveReservationSvc - { - type Response = super::RemoveReservationResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = async move { - ::remove_reservation(&inner, request).await - }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = RemoveReservationSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/Bid" => { - #[allow(non_camel_case_types)] - struct BidSvc(pub Arc); - impl tonic::server::UnaryService for BidSvc { - type Response = super::BidResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = - async move { ::bid(&inner, request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = BidSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - "/network.ProverNetwork/Settle" => { - #[allow(non_camel_case_types)] - struct SettleSvc(pub Arc); - impl tonic::server::UnaryService for SettleSvc { - type Response = super::SettleResponse; - type Future = BoxFuture, tonic::Status>; - fn call( - &mut self, - request: tonic::Request, - ) -> Self::Future { - let inner = Arc::clone(&self.0); - let fut = - async move { ::settle(&inner, request).await }; - Box::pin(fut) - } - } - let accept_compression_encodings = self.accept_compression_encodings; - let send_compression_encodings = self.send_compression_encodings; - let max_decoding_message_size = self.max_decoding_message_size; - let max_encoding_message_size = self.max_encoding_message_size; - let inner = self.inner.clone(); - let fut = async move { - let method = SettleSvc(inner); - let codec = tonic::codec::ProstCodec::default(); - let mut grpc = tonic::server::Grpc::new(codec) - .apply_compression_config( - accept_compression_encodings, - send_compression_encodings, - ) - .apply_max_message_size_config( - max_decoding_message_size, - max_encoding_message_size, - ); - let res = grpc.unary(method, req).await; - Ok(res) - }; - Box::pin(fut) - } - _ => Box::pin(async move { - Ok(http::Response::builder() - .status(200) - .header("grpc-status", tonic::Code::Unimplemented as i32) - .header(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE) - .body(empty_body()) - .unwrap()) - }), - } - } - } - impl Clone for ProverNetworkServer { - fn clone(&self) -> Self { - let inner = self.inner.clone(); - Self { - inner, - accept_compression_encodings: self.accept_compression_encodings, - send_compression_encodings: self.send_compression_encodings, - max_decoding_message_size: self.max_decoding_message_size, - max_encoding_message_size: self.max_encoding_message_size, - } - } - } - /// Generated gRPC service name - pub const SERVICE_NAME: &str = "network.ProverNetwork"; - impl tonic::server::NamedService for ProverNetworkServer { - const NAME: &'static str = SERVICE_NAME; - } -} diff --git a/crates/sdk/src/network-v2/prover.rs b/crates/sdk/src/network-v2/prover.rs deleted file mode 100644 index 91056adde1..0000000000 --- a/crates/sdk/src/network-v2/prover.rs +++ /dev/null @@ -1,330 +0,0 @@ -use std::time::{Duration, Instant}; - -use crate::network_v2::client::DEFAULT_PROVER_NETWORK_RPC; -use crate::{ - network_v2::client::NetworkClient, - network_v2::proto::network::{ - ExecutionStatus, FulfillmentStatus, FulfillmentStrategy, ProofMode, - }, - NetworkProverBuilder, Prover, SP1Context, SP1ProofKind, SP1ProofWithPublicValues, - SP1ProvingKey, SP1VerifyingKey, -}; -use anyhow::Result; -use backoff::{future::retry, Error as BackoffError, ExponentialBackoff}; -use serde::de::DeserializeOwned; -use sp1_core_machine::io::SP1Stdin; -use sp1_prover::{components::DefaultProverComponents, SP1Prover, SP1_CIRCUIT_VERSION}; -use sp1_stark::SP1ProverOpts; -use tonic::Code; - -use {crate::block_on, tokio::time::sleep}; - -use crate::provers::{CpuProver, ProofOpts, ProverType}; - -/// The timeout for a proof request to be fulfilled. -const TIMEOUT_SECS: u64 = 14400; - -/// The default cycle limit for a proof request if simulation is skipped. -const DEFAULT_CYCLE_LIMIT: u64 = 100_000_000; - -/// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server. -pub struct NetworkProver { - client: NetworkClient, - local_prover: CpuProver, - skip_simulation: bool, - strategy: FulfillmentStrategy, -} - -impl NetworkProver { - /// Creates a new [NetworkProver] with the given private key. - pub fn new(private_key: &str, rpc_url: Option, skip_simulation: bool) -> Self { - let version = SP1_CIRCUIT_VERSION; - log::info!("Client circuit version: {}", version); - let local_prover = CpuProver::new(); - let client = NetworkClient::new(private_key, rpc_url); - Self { client, local_prover, skip_simulation, strategy: FulfillmentStrategy::Hosted } - } - - /// Sets the fulfillment strategy for the client. By default, the strategy is set to `Hosted`. - pub fn with_strategy(&mut self, strategy: FulfillmentStrategy) { - self.strategy = strategy; - } - - /// Creates a new network prover builder. See [`NetworkProverBuilder`] for more details. - pub fn builder() -> NetworkProverBuilder { - NetworkProverBuilder::default() - } - - /// Registers a program if it is not already registered. - pub async fn register_program(&self, vk: &SP1VerifyingKey, elf: &[u8]) -> Result> { - self.client.register_program(vk, elf).await - } - - /// Get the cycle limit, either by simulating or using the default cycle limit. - fn get_cycle_limit(&self, elf: &[u8], stdin: &SP1Stdin) -> Result { - if !self.skip_simulation { - let (_, report) = - self.local_prover.sp1_prover().execute(elf, stdin, Default::default())?; - let cycles = report.total_instruction_count(); - Ok(cycles) - } else { - Ok(DEFAULT_CYCLE_LIMIT) - } - } - - /// Requests a proof from the prover network, returning the request ID. - pub async fn request_proof( - &self, - vk_hash: &[u8], - stdin: &SP1Stdin, - mode: ProofMode, - cycle_limit: u64, - timeout: Option, - ) -> Result> { - // Get the timeout. - let timeout_secs = timeout.map(|dur| dur.as_secs()).unwrap_or(TIMEOUT_SECS); - - log::info!("Requesting proof with cycle limit: {}", cycle_limit); - - // Request the proof with retries. - let response = with_retry( - || async { - self.client - .request_proof( - vk_hash, - stdin, - mode, - SP1_CIRCUIT_VERSION, - self.strategy, - timeout_secs, - cycle_limit, - ) - .await - }, - timeout, - "requesting proof", - ) - .await?; - - // Log the request ID and transaction hash. - let tx_hash_hex = "0x".to_string() + &hex::encode(response.tx_hash); - let request_id = response.body.unwrap().request_id; - let request_id_hex = "0x".to_string() + &hex::encode(request_id.clone()); - log::info!("Created request {} in transaction {}", request_id_hex, tx_hash_hex); - - if self.client.rpc_url() == DEFAULT_PROVER_NETWORK_RPC { - log::info!("View in explorer: https://network.succinct.xyz/request/{}", request_id_hex); - } - - Ok(request_id) - } - - /// Waits for a proof to be generated and returns the proof. If a timeout is supplied, the - /// function will return an error if the proof is not generated within the timeout. - pub async fn wait_proof( - &self, - request_id: &[u8], - timeout: Option, - ) -> Result

{ - let mut is_assigned = false; - let start_time = Instant::now(); - - loop { - // Calculate the remaining timeout. - if let Some(timeout) = timeout { - if start_time.elapsed() > timeout { - return Err(anyhow::anyhow!("Proof request timed out.")); - } - } - let remaining_timeout = timeout.map(|t| { - let elapsed = start_time.elapsed(); - if elapsed < t { - t - elapsed - } else { - Duration::from_secs(0) - } - }); - - // Get status with retries. - let (status, maybe_proof) = with_retry( - || async { self.client.get_proof_request_status::

(request_id).await }, - remaining_timeout, - "getting proof request status", - ) - .await?; - - // Check the execution status. - if status.execution_status == ExecutionStatus::Unexecutable as i32 { - return Err(anyhow::anyhow!("Proof request is unexecutable")); - } - - // Check the fulfillment status. - match FulfillmentStatus::try_from(status.fulfillment_status) { - Ok(FulfillmentStatus::Fulfilled) => { - return Ok(maybe_proof.unwrap()); - } - Ok(FulfillmentStatus::Assigned) => { - if !is_assigned { - log::info!("Proof request assigned, proving..."); - is_assigned = true; - } - } - Ok(FulfillmentStatus::Unfulfillable) => { - return Err(anyhow::anyhow!("Proof request is unfulfillable")); - } - _ => {} - } - - sleep(Duration::from_secs(2)).await; - } - } - - /// Requests a proof from the prover network and waits for it to be generated. - pub async fn prove( - &self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - mode: ProofMode, - timeout: Option, - ) -> Result { - let vk_hash = self.register_program(&pk.vk, &pk.elf).await?; - let cycle_limit = self.get_cycle_limit(&pk.elf, &stdin)?; - let request_id = self.request_proof(&vk_hash, &stdin, mode, cycle_limit, timeout).await?; - self.wait_proof(&request_id, timeout).await - } -} - -impl Prover for NetworkProver { - fn id(&self) -> ProverType { - ProverType::Network - } - - fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.local_prover.setup(elf) - } - - fn sp1_prover(&self) -> &SP1Prover { - self.local_prover.sp1_prover() - } - - fn prove<'a>( - &'a self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - opts: ProofOpts, - context: SP1Context<'a>, - kind: SP1ProofKind, - ) -> Result { - warn_if_not_default(&opts.sp1_prover_opts, &context); - block_on(self.prove(pk, stdin, kind.into(), opts.timeout)) - } -} - -/// Warns if `opts` or `context` are not default values, since they are currently unsupported. -fn warn_if_not_default(opts: &SP1ProverOpts, context: &SP1Context) { - let _guard = tracing::warn_span!("network_prover").entered(); - if opts != &SP1ProverOpts::default() { - tracing::warn!("non-default opts will be ignored: {:?}", opts.core_opts); - tracing::warn!("custom SP1ProverOpts are currently unsupported by the network prover"); - } - // Exhaustive match is done to ensure we update the warnings if the types change. - let SP1Context { hook_registry, subproof_verifier, .. } = context; - if hook_registry.is_some() { - tracing::warn!("non-default context.hook_registry will be ignored: {:?}", hook_registry); - tracing::warn!("custom runtime hooks are currently unsupported by the network prover"); - tracing::warn!("proving may fail due to missing hooks"); - } - if subproof_verifier.is_some() { - tracing::warn!("non-default context.subproof_verifier will be ignored"); - tracing::warn!("custom subproof verifiers are currently unsupported by the network prover"); - } -} - -impl From for ProofMode { - fn from(value: SP1ProofKind) -> Self { - match value { - SP1ProofKind::Core => Self::Core, - SP1ProofKind::Compressed => Self::Compressed, - SP1ProofKind::Plonk => Self::Plonk, - SP1ProofKind::Groth16 => Self::Groth16, - } - } -} - -/// Execute an async operation with exponential backoff retries. -pub async fn with_retry( - operation: F, - timeout: Option, - operation_name: &str, -) -> Result -where - F: Fn() -> Fut, - Fut: std::future::Future>, -{ - let backoff = ExponentialBackoff { - initial_interval: Duration::from_secs(1), - max_interval: Duration::from_secs(120), - max_elapsed_time: timeout, - ..Default::default() - }; - - retry(backoff, || async { - match operation().await { - Ok(result) => Ok(result), - Err(e) => { - // Check for tonic status errors. - if let Some(status) = e.downcast_ref::() { - match status.code() { - Code::Unavailable => { - log::warn!( - "Network temporarily unavailable when {} due to {}, retrying...", - operation_name, - status.message(), - ); - Err(BackoffError::transient(e)) - } - Code::NotFound => { - log::error!( - "{} not found due to {}", - operation_name, - status.message(), - ); - Err(BackoffError::permanent(e)) - } - _ => { - log::error!( - "Permanent error encountered when {}: {} ({})", - operation_name, - status.message(), - status.code() - ); - Err(BackoffError::permanent(e)) - } - } - } else { - // Check for common transport errors. - let error_msg = e.to_string().to_lowercase(); - let is_transient = error_msg.contains("tls handshake") || - error_msg.contains("dns error") || - error_msg.contains("connection reset") || - error_msg.contains("broken pipe") || - error_msg.contains("transport error") || - error_msg.contains("failed to lookup"); - - if is_transient { - log::warn!( - "Transient transport error when {}: {}, retrying...", - operation_name, - error_msg - ); - Err(BackoffError::transient(e)) - } else { - log::error!("Permanent error when {}: {}", operation_name, error_msg); - Err(BackoffError::permanent(e)) - } - } - } - } - }) - .await -} diff --git a/crates/sdk/src/network/auth.rs b/crates/sdk/src/network/auth.rs deleted file mode 100644 index 7786cc4d36..0000000000 --- a/crates/sdk/src/network/auth.rs +++ /dev/null @@ -1,142 +0,0 @@ -use std::{borrow::Cow, str::FromStr}; - -use alloy_signer::SignerSync; -use alloy_signer_local::PrivateKeySigner; - -use alloy_sol_types::{sol, Eip712Domain, SolStruct}; -use anyhow::Result; - -use crate::network::proto::network::UnclaimReason; - -sol! { - struct CreateProof { - uint64 nonce; - uint64 deadline; - uint32 mode; - string version; - } - - struct SubmitProof { - uint64 nonce; - string proof_id; - } - - struct ClaimProof { - uint64 nonce; - string proof_id; - } - - struct UnclaimProof { - uint64 nonce; - string proof_id; - uint8 reason; - string description; - } - - struct ModifyCpuCycles { - uint64 nonce; - string proof_id; - uint64 cycles; - } - - struct FulfillProof { - uint64 nonce; - string proof_id; - } -} - -/// Handles authentication for the Succinct prover network. All interactions that could potentially -/// use computational resources must be authenticated by signing a message with a secp256k1 key. -/// -/// The messages themselves follow EIP-712, where the domain is "succinct" and the TypeStruct -/// changes depending on which endpoint is being used. Documentation for EIP-712 can be found at: -/// https://eips.ethereum.org/EIPS/eip-712 -pub struct NetworkAuth { - // Holds a secp256k1 private key. - wallet: PrivateKeySigner, -} - -impl NetworkAuth { - pub fn new(private_key: &str) -> Self { - let wallet = PrivateKeySigner::from_str(private_key).unwrap(); - Self { wallet } - } - - /// Gets the EIP-712 domain separator for the Succinct prover network. - fn get_domain_separator() -> Eip712Domain { - Eip712Domain { - name: Some(Cow::Borrowed("succinct")), - version: Some(Cow::Borrowed("1")), - ..Default::default() - } - } - - /// Gets the address of the auth's account, derived from the secp256k1 private key. - pub fn get_address(&self) -> [u8; 20] { - self.wallet.address().into() - } - - // Generic function to sign a message based on the SolStruct. - async fn sign_message(&self, type_struct: T) -> Result> { - let domain_separator = Self::get_domain_separator(); - let message_hash = type_struct.eip712_signing_hash(&domain_separator); - let signature = self.wallet.sign_hash_sync(&message_hash)?; - Ok(signature.as_bytes().to_vec()) - } - - /// Signs a message to to request to create a proof. - pub async fn sign_create_proof_message( - &self, - nonce: u64, - deadline: u64, - mode: i32, - version: &str, - ) -> Result> { - let type_struct = - CreateProof { nonce, deadline, mode: mode as u32, version: version.to_string() }; - self.sign_message(type_struct).await - } - - /// Signs a message to mark a proof as ready for proof generation. - pub async fn sign_submit_proof_message(&self, nonce: u64, proof_id: &str) -> Result> { - let type_struct = SubmitProof { nonce, proof_id: proof_id.to_string() }; - self.sign_message(type_struct).await - } - - /// Signs a message to claim a proof that was requested. - pub async fn sign_claim_proof_message(&self, nonce: u64, proof_id: &str) -> Result> { - let type_struct = ClaimProof { nonce, proof_id: proof_id.to_string() }; - self.sign_message(type_struct).await - } - - /// Signs a message to unclaim a proof that was previously claimed. - pub async fn sign_unclaim_proof_message( - &self, - nonce: u64, - proof_id: String, - reason: UnclaimReason, - description: String, - ) -> Result> { - let type_struct = UnclaimProof { nonce, proof_id, reason: reason as u8, description }; - self.sign_message(type_struct).await - } - - /// Signs a message to modify the CPU cycles for a proof. The proof must have been previously - /// claimed by the signer first. - pub async fn sign_modify_cpu_cycles_message( - &self, - nonce: u64, - proof_id: &str, - cycles: u64, - ) -> Result> { - let type_struct = ModifyCpuCycles { nonce, proof_id: proof_id.to_string(), cycles }; - self.sign_message(type_struct).await - } - - /// Signs a message to fulfill a proof. The proof must have been previously claimed by the - /// signer first. - pub async fn sign_fulfill_proof_message(&self, nonce: u64, proof_id: &str) -> Result> { - let type_struct = FulfillProof { nonce, proof_id: proof_id.to_string() }; - self.sign_message(type_struct).await - } -} diff --git a/crates/sdk/src/network/builder.rs b/crates/sdk/src/network/builder.rs new file mode 100644 index 0000000000..5a9585a67a --- /dev/null +++ b/crates/sdk/src/network/builder.rs @@ -0,0 +1,94 @@ +//! # Network Prover Builder +//! +//! This module provides a builder for the [`NetworkProver`]. + +use crate::NetworkProver; + +/// A builder for the [`NetworkProver`]. +/// +/// The builder is used to configure the [`NetworkProver`] before it is built. +#[derive(Default)] +pub struct NetworkProverBuilder { + pub(crate) private_key: Option, + pub(crate) rpc_url: Option, +} + +impl NetworkProverBuilder { + /// Sets the Secp256k1 private key (same format as the one used by Ethereum). + /// + /// # Details + /// Sets the private key that will be used sign requests sent to the network. By default, the + /// private key is read from the `NETWORK_PRIVATE_KEY` environment variable. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient}; + /// + /// let prover = ProverClient::builder().network() + /// .private_key("...") + /// .build(); + /// ``` + #[must_use] + pub fn private_key(mut self, private_key: &str) -> Self { + self.private_key = Some(private_key.to_string()); + self + } + + /// Sets the remote procedure call URL. + /// + /// # Details + /// The URL determines the network that the client will connect to. By default, the URL is + /// read from the `NETWORK_RPC_URL` environment variable. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient}; + /// + /// let prover = ProverClient::builder() + /// .network() + /// .rpc_url("...") + /// .build(); + /// ``` + #[must_use] + pub fn rpc_url(mut self, rpc_url: &str) -> Self { + self.rpc_url = Some(rpc_url.to_string()); + self + } + + /// Builds a [`NetworkProver`]. + /// + /// # Details + /// This method will build a [`NetworkProver`] with the given parameters. If the private key is + /// not provided, the method will look for the `NETWORK_PRIVATE_KEY` environment variable. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient}; + /// + /// let prover = ProverClient::builder() + /// .network() + /// .private_key("...") + /// .rpc_url("...") + /// .build(); + /// ``` + #[must_use] + pub fn build(self) -> NetworkProver { + let private_key = match self.private_key { + Some(private_key) => private_key, + None => std::env::var("NETWORK_PRIVATE_KEY").expect( + "NETWORK_PRIVATE_KEY environment variable is not set. \ + Please set it to your private key or use the .private_key() method.", + ), + }; + + let rpc_url = match self.rpc_url { + Some(rpc_url) => rpc_url, + None => std::env::var("NETWORK_RPC_URL").expect( + "NETWORK_RPC_URL environment variable is not set. \ + Please set it to your rpc url or use the .rpc_url() method.", + ), + }; + + NetworkProver::new(&private_key, &rpc_url) + } +} diff --git a/crates/sdk/src/network/client.rs b/crates/sdk/src/network/client.rs index 2e39f9b08b..880352c5c6 100644 --- a/crates/sdk/src/network/client.rs +++ b/crates/sdk/src/network/client.rs @@ -1,122 +1,159 @@ -use std::time::Duration; - -use crate::{ - network::{ - auth::NetworkAuth, - proto::network::{ - ModifyCpuCyclesRequest, ModifyCpuCyclesResponse, UnclaimProofRequest, UnclaimReason, - }, - }, - SP1ProofWithPublicValues, -}; +//! # Network Client +//! +//! This module provides a client for directly interacting with the network prover service. + +use std::result::Result::Ok as StdOk; +use std::str::FromStr; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; + +use alloy_signer::SignerSync; +use alloy_signer_local::PrivateKeySigner; use anyhow::{Context, Ok, Result}; -use futures::{future::join_all, Future}; -use reqwest::{Client as HttpClient, Url}; use reqwest_middleware::ClientWithMiddleware as HttpClientWithMiddleware; +use serde::{de::DeserializeOwned, Serialize}; use sp1_core_machine::io::SP1Stdin; -use std::{ - result::Result::Ok as StdOk, - time::{SystemTime, UNIX_EPOCH}, +use sp1_prover::{HashableKey, SP1VerifyingKey}; +use tonic::{ + transport::{channel::ClientTlsConfig, Channel}, + Code, }; -use twirp::{Client as TwirpClient, ClientError}; +use super::utils::Signable; +use crate::network::proto::artifact::{ + artifact_store_client::ArtifactStoreClient, CreateArtifactRequest, +}; use crate::network::proto::network::{ - ClaimProofRequest, ClaimProofResponse, CreateProofRequest, FulfillProofRequest, - FulfillProofResponse, GetNonceRequest, GetProofRequestsRequest, GetProofRequestsResponse, - GetProofStatusRequest, GetProofStatusResponse, NetworkServiceClient, ProofMode, ProofStatus, - SubmitProofRequest, + prover_network_client::ProverNetworkClient, CreateProgramRequest, CreateProgramRequestBody, + CreateProgramResponse, FulfillmentStatus, FulfillmentStrategy, GetNonceRequest, + GetProgramRequest, GetProgramResponse, GetProofRequestStatusRequest, + GetProofRequestStatusResponse, MessageFormat, ProofMode, RequestProofRequest, + RequestProofRequestBody, RequestProofResponse, }; -/// The default RPC endpoint for the Succinct prover network. -pub const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.succinct.xyz/"; - -/// The timeout for a proof request to be fulfilled. -const PROOF_TIMEOUT: Duration = Duration::from_secs(60 * 60); - -/// The timeout for a single RPC request. -const REQUEST_TIMEOUT: Duration = Duration::from_secs(30); - +/// A client for interacting with the network. pub struct NetworkClient { - pub rpc: TwirpClient, - pub http: HttpClientWithMiddleware, - pub auth: NetworkAuth, - pub is_using_prover_network: bool, + pub(crate) signer: PrivateKeySigner, + pub(crate) http: HttpClientWithMiddleware, + pub(crate) rpc_url: String, } impl NetworkClient { - /// Create a new NetworkClient with the given private key for authentication. - pub fn new(private_key: &str, rpc_url: Option) -> Self { - let auth = NetworkAuth::new(private_key); - - let twirp_http_client = HttpClient::builder() - .timeout(REQUEST_TIMEOUT) + /// Creates a new [`NetworkClient`] with the given private key and rpc url. + pub fn new(private_key: impl Into, rpc_url: impl Into) -> Self { + let signer = PrivateKeySigner::from_str(&private_key.into()).unwrap(); + let client = reqwest::Client::builder() .pool_max_idle_per_host(0) .pool_idle_timeout(Duration::from_secs(240)) .build() .unwrap(); + Self { signer, http: client.into(), rpc_url: rpc_url.into() } + } - let rpc_url = rpc_url.unwrap_or_else(|| DEFAULT_PROVER_NETWORK_RPC.to_string()); - let rpc = - TwirpClient::new(Url::parse(&rpc_url).unwrap(), twirp_http_client, vec![]).unwrap(); + /// Get the latest nonce for this account's address. + pub async fn get_nonce(&self) -> Result { + let mut rpc = self.prover_network_client().await?; + let res = + rpc.get_nonce(GetNonceRequest { address: self.signer.address().to_vec() }).await?; + Ok(res.into_inner().nonce) + } - let http_client = HttpClient::builder() - .timeout(REQUEST_TIMEOUT) - .pool_max_idle_per_host(0) - .pool_idle_timeout(Duration::from_secs(240)) - .build() - .unwrap(); + /// Get the verifying key hash from a verifying key. + /// + /// # Details + /// The verifying key hash is used to identify a program. + pub fn get_vk_hash(vk: &SP1VerifyingKey) -> Result> { + let vk_hash_str = vk.bytes32(); + let vk_hash = hex::decode(vk_hash_str.strip_prefix("0x").unwrap_or(&vk_hash_str))?; + Ok(vk_hash) + } - Self { - auth, - rpc, - http: http_client.into(), - is_using_prover_network: rpc_url == DEFAULT_PROVER_NETWORK_RPC, + /// Registers a program with the network if it is not already registered. + pub async fn register_program(&self, vk: &SP1VerifyingKey, elf: &[u8]) -> Result> { + let vk_hash = Self::get_vk_hash(vk)?; + + // Try to get the existing program. + if (self.get_program(&vk_hash).await?).is_some() { + // The program already exists. + Ok(vk_hash) + } else { + // The program doesn't exist, create it. + self.create_program(&vk_hash, vk, elf).await?; + log::info!("Registered program 0x{}", hex::encode(vk_hash.clone())); + Ok(vk_hash) } } - /// Gets the latest nonce for this auth's account. - pub async fn get_nonce(&self) -> Result { - let res = self - .with_error_handling( - self.rpc.get_nonce(GetNonceRequest { address: self.auth.get_address().to_vec() }), - ) - .await?; - Ok(res.nonce) + /// Attempts to get the program on the network. + /// + /// # Details + /// Returns `None` if the program does not exist. + pub async fn get_program(&self, vk_hash: &[u8]) -> Result> { + let mut rpc = self.prover_network_client().await?; + match rpc.get_program(GetProgramRequest { vk_hash: vk_hash.to_vec() }).await { + StdOk(response) => Ok(Some(response.into_inner())), + Err(status) if status.code() == Code::NotFound => Ok(None), + Err(e) => Err(e.into()), + } } - /// Upload a file to the specified url. - async fn upload_file(&self, url: &str, data: Vec) -> Result<()> { - self.http.put(url).body(data).send().await?; - Ok(()) + /// Creates a new program on the network. + pub async fn create_program( + &self, + vk_hash: &[u8], + vk: &SP1VerifyingKey, + elf: &[u8], + ) -> Result { + // Create the program artifact. + let mut store = self.artifact_store_client().await?; + let program_uri = self.create_artifact_with_content(&mut store, &elf).await?; + + // Serialize the verifying key. + let vk_encoded = bincode::serialize(&vk)?; + + // Send the request. + let mut rpc = self.prover_network_client().await?; + let nonce = self.get_nonce().await?; + let request_body = CreateProgramRequestBody { + nonce, + vk_hash: vk_hash.to_vec(), + vk: vk_encoded, + program_uri, + }; + + Ok(rpc + .create_program(CreateProgramRequest { + format: MessageFormat::Binary.into(), + signature: request_body.sign(&self.signer).into(), + body: Some(request_body), + }) + .await? + .into_inner()) } - /// Get the status and the proof if available of a given proof request. The proof is returned - /// only if the status is Fulfilled. - pub async fn get_proof_status( + /// Get the status of a given proof. + /// + /// # Details + /// If the status is Fulfilled, the proof is also returned. + pub async fn get_proof_request_status( &self, - proof_id: &str, - ) -> Result<(GetProofStatusResponse, Option)> { - let res = self - .with_error_handling( - self.rpc.get_proof_status(GetProofStatusRequest { proof_id: proof_id.to_string() }), - ) - .await - .context("Failed to get proof status")?; - - let proof = match res.status() { - ProofStatus::ProofFulfilled => { - log::info!("Proof request fulfilled"); - let proof_bytes = self - .http - .get(res.proof_url.as_ref().expect("no proof url")) - .timeout(Duration::from_secs(120)) - .send() - .await - .context("Failed to send HTTP request for proof")? - .bytes() - .await - .context("Failed to load proof bytes")?; - + request_id: &[u8], + ) -> Result<(GetProofRequestStatusResponse, Option

)> { + let mut rpc = self.prover_network_client().await?; + let res = rpc + .get_proof_request_status(GetProofRequestStatusRequest { + request_id: request_id.to_vec(), + }) + .await? + .into_inner(); + + let status = FulfillmentStatus::try_from(res.fulfillment_status)?; + let proof = match status { + FulfillmentStatus::Fulfilled => { + let proof_uri = res + .proof_uri + .as_ref() + .ok_or_else(|| anyhow::anyhow!("No proof URI provided"))?; + let proof_bytes = self.download_artifact(proof_uri).await?; Some(bincode::deserialize(&proof_bytes).context("Failed to deserialize proof")?) } _ => None, @@ -125,167 +162,119 @@ impl NetworkClient { Ok((res, proof)) } - /// Get all the proof requests for a given status. Also filter by circuit version if provided. - pub async fn get_proof_requests( + /// Creates a proof request with the given verifying key hash and stdin. + /// + /// # Details + /// * `vk_hash`: The verifying key hash of the program to prove. Used to identify the program. + /// * `stdin`: The standard input to provide to the program. + /// * `mode`: The [`ProofMode`] to use. + /// * `version`: The version of the SP1 circuits to use. + /// * `strategy`: The [`FulfillmentStrategy`] to use. + /// * `timeout_secs`: The timeout for the proof request in seconds. + /// * `cycle_limit`: The cycle limit for the proof request. + #[allow(clippy::too_many_arguments)] + pub async fn request_proof( &self, - status: ProofStatus, - circuit_version: Option<&str>, - ) -> Result { - self.with_error_handling(self.rpc.get_proof_requests(GetProofRequestsRequest { - status: status.into(), - circuit_version: circuit_version.map(|v| v.to_owned()), - })) - .await - } - - /// Creates a proof request for the given ELF and stdin. - pub async fn create_proof( - &self, - elf: &[u8], + vk_hash: &[u8], stdin: &SP1Stdin, mode: ProofMode, - circuit_version: &str, - ) -> Result { + version: &str, + strategy: FulfillmentStrategy, + timeout_secs: u64, + cycle_limit: u64, + ) -> Result { + // Calculate the deadline. let start = SystemTime::now(); let since_the_epoch = start.duration_since(UNIX_EPOCH).expect("Invalid start time"); - let deadline = since_the_epoch.as_secs() + PROOF_TIMEOUT.as_secs(); + let deadline = since_the_epoch.as_secs() + timeout_secs; - let nonce = self.get_nonce().await?; - let create_proof_signature = self - .auth - .sign_create_proof_message(nonce, deadline, mode.into(), circuit_version) - .await?; - - let res = self - .with_error_handling(self.rpc.create_proof(CreateProofRequest { - signature: create_proof_signature.to_vec(), - nonce, - deadline, - mode: mode.into(), - circuit_version: circuit_version.to_string(), - })) - .await?; - - let program_bytes = bincode::serialize(elf)?; - let stdin_bytes = bincode::serialize(&stdin)?; - let program_promise = self.upload_file(&res.program_url, program_bytes); - let stdin_promise = self.upload_file(&res.stdin_url, stdin_bytes); - let v = vec![program_promise, stdin_promise]; - let mut results = join_all(v).await; - results.pop().expect("Failed to upload stdin")?; - results.pop().expect("Failed to upload program")?; + // Create the stdin artifact. + let mut store = self.artifact_store_client().await?; + let stdin_uri = self.create_artifact_with_content(&mut store, &stdin).await?; + // Send the request. + let mut rpc = self.prover_network_client().await?; let nonce = self.get_nonce().await?; - let submit_proof_signature = - self.auth.sign_submit_proof_message(nonce, &res.proof_id).await?; - - self.with_error_handling(self.rpc.submit_proof(SubmitProofRequest { - signature: submit_proof_signature.to_vec(), + let request_body = RequestProofRequestBody { nonce, - proof_id: res.proof_id.clone(), - })) - .await?; - - Ok(res.proof_id) + version: format!("sp1-{version}"), + vk_hash: vk_hash.to_vec(), + mode: mode.into(), + strategy: strategy.into(), + stdin_uri, + deadline, + cycle_limit, + }; + let request_response = rpc + .request_proof(RequestProofRequest { + format: MessageFormat::Binary.into(), + signature: request_body.sign(&self.signer).into(), + body: Some(request_body), + }) + .await? + .into_inner(); + + Ok(request_response) } - /// Claim a proof that was requested. This commits to generating a proof and fulfilling it. - /// Returns an error if the proof is not in a PROOF_REQUESTED state. - pub async fn claim_proof(&self, proof_id: &str) -> Result { - let nonce = self.get_nonce().await?; - let signature = self.auth.sign_claim_proof_message(nonce, proof_id).await?; + pub(crate) async fn prover_network_client(&self) -> Result> { + let rpc_url = self.rpc_url.clone(); + let mut endpoint = Channel::from_shared(rpc_url.clone())?; - self.with_error_handling(self.rpc.claim_proof(ClaimProofRequest { - signature, - nonce, - proof_id: proof_id.to_string(), - })) - .await + // Check if the URL scheme is HTTPS and configure TLS. + if rpc_url.starts_with("https://") { + let tls_config = ClientTlsConfig::new().with_enabled_roots(); + endpoint = endpoint.tls_config(tls_config)?; + } + + let channel = endpoint.connect().await?; + Ok(ProverNetworkClient::new(channel)) } - /// Unclaim a proof that was claimed. This should only be called if the proof has not been - /// fulfilled yet. Returns an error if the proof is not in a PROOF_CLAIMED state or if the - /// caller is not the claimer. - pub async fn unclaim_proof( - &self, - proof_id: String, - reason: UnclaimReason, - description: String, - ) -> Result<()> { - let nonce = self.get_nonce().await?; - let signature = self - .auth - .sign_unclaim_proof_message(nonce, proof_id.clone(), reason, description.clone()) - .await?; + pub(crate) async fn artifact_store_client(&self) -> Result> { + let rpc_url = self.rpc_url.clone(); + let mut endpoint = Channel::from_shared(rpc_url.clone())?; - self.with_error_handling(self.rpc.unclaim_proof(UnclaimProofRequest { - signature, - nonce, - proof_id, - reason: reason.into(), - description, - })) - .await?; + // Check if the URL scheme is HTTPS and configure TLS. + if rpc_url.starts_with("https://") { + let tls_config = ClientTlsConfig::new().with_enabled_roots(); + endpoint = endpoint.tls_config(tls_config)?; + } - Ok(()) + let channel = endpoint.connect().await?; + Ok(ArtifactStoreClient::new(channel.clone())) } - /// Modifies the CPU cycles for a proof. May be called by the claimer after the proof has been - /// claimed. Returns an error if the proof is not in a PROOF_CLAIMED state or if the caller is - /// not the claimer. - pub async fn modify_cpu_cycles( + pub(crate) async fn create_artifact_with_content( &self, - proof_id: &str, - cycles: u64, - ) -> Result { - let nonce = self.get_nonce().await?; - let signature = self.auth.sign_modify_cpu_cycles_message(nonce, proof_id, cycles).await?; - let res = self - .with_error_handling(self.rpc.modify_cpu_cycles(ModifyCpuCyclesRequest { - signature, - nonce, - proof_id: proof_id.to_string(), - cycles, - })) - .await?; - - Ok(res) - } + store: &mut ArtifactStoreClient, + item: &T, + ) -> Result { + let signature = self.signer.sign_message_sync("create_artifact".as_bytes())?; + let request = CreateArtifactRequest { signature: signature.as_bytes().to_vec() }; + let response = store.create_artifact(request).await?.into_inner(); - /// Fulfill a proof. Should only be called after the proof has been uploaded. Returns an error - /// if the proof is not in a PROOF_CLAIMED state or if the caller is not the claimer. - pub async fn fulfill_proof(&self, proof_id: &str) -> Result { - let nonce = self.get_nonce().await?; - let signature = self.auth.sign_fulfill_proof_message(nonce, proof_id).await?; - let res = self - .with_error_handling(self.rpc.fulfill_proof(FulfillProofRequest { - signature, - nonce, - proof_id: proof_id.to_string(), - })) - .await?; - - Ok(res) - } + let presigned_url = response.artifact_presigned_url; + let uri = response.artifact_uri; - /// Awaits the future, then handles Succinct prover network errors. - async fn with_error_handling(&self, future: F) -> Result - where - F: Future>, - { - let result = future.await; - self.handle_twirp_error(result) + let response = + self.http.put(&presigned_url).body(bincode::serialize::(item)?).send().await?; + + if !response.status().is_success() { + log::debug!("Artifact upload failed with status: {}", response.status()); + } + assert!(response.status().is_success()); + + Ok(uri) } - /// Handles Twirp errors by formatting them into more readable error messages. - fn handle_twirp_error(&self, result: std::result::Result) -> Result { - match result { - StdOk(response) => StdOk(response), - Err(ClientError::TwirpError(err)) => { - let display_err = format!("error: \"{:?}\" message: {:?}", err.code, err.msg); - Err(anyhow::anyhow!(display_err)) - } - Err(err) => Err(err.into()), + pub(crate) async fn download_artifact(&self, uri: &str) -> Result> { + let response = self.http.get(uri).send().await.context("Failed to download from URI")?; + + if !response.status().is_success() { + return Err(anyhow::anyhow!("Failed to download artifact: HTTP {}", response.status())); } + + Ok(response.bytes().await.context("Failed to read response body")?.to_vec()) } } diff --git a/crates/sdk/src/network/mod.rs b/crates/sdk/src/network/mod.rs index 12d9b7b352..6cc201f327 100644 --- a/crates/sdk/src/network/mod.rs +++ b/crates/sdk/src/network/mod.rs @@ -1,6 +1,22 @@ -pub mod auth; +//! # SP1 Network +//! +//! A library for interacting with the SP1 prover over the network. + pub mod client; pub mod prover; - +mod sign_message; #[rustfmt::skip] +#[allow(missing_docs)] +#[allow(clippy::default_trait_access)] +#[allow(clippy::too_many_lines)] pub mod proto; +pub mod builder; +pub mod prove; +pub mod utils; + +pub use crate::network::client::NetworkClient; +pub use crate::network::proto::network::FulfillmentStrategy; + +pub(crate) const DEFAULT_PROVER_NETWORK_RPC: &str = "https://rpc.production.succinct.tools/"; +pub(crate) const DEFAULT_TIMEOUT_SECS: u64 = 14400; +pub(crate) const DEFAULT_CYCLE_LIMIT: u64 = 100_000_000; diff --git a/crates/sdk/src/network-v2/proto/artifact.rs b/crates/sdk/src/network/proto/artifact.rs similarity index 95% rename from crates/sdk/src/network-v2/proto/artifact.rs rename to crates/sdk/src/network/proto/artifact.rs index f635654c39..e1ff3ad034 100644 --- a/crates/sdk/src/network-v2/proto/artifact.rs +++ b/crates/sdk/src/network/proto/artifact.rs @@ -18,7 +18,7 @@ pub struct CreateArtifactResponse { pub mod artifact_store_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] use tonic::codegen::http::Uri; - use tonic::codegen::*; + use tonic::codegen::{Body, Bytes, CompressionEncoding, GrpcMethod, InterceptedService, StdError, http}; #[derive(Debug, Clone)] pub struct ArtifactStoreClient { inner: tonic::client::Grpc, @@ -57,11 +57,11 @@ pub mod artifact_store_client { F: tonic::service::Interceptor, T::ResponseBody: Default, T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, + http::Request, + Response = http::Response< + >::ResponseBody, + >, >, - >, >>::Error: Into + std::marker::Send + std::marker::Sync, { @@ -123,7 +123,7 @@ pub mod artifact_store_client { /// Generated server implementations. pub mod artifact_store_server { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] - use tonic::codegen::*; + use tonic::codegen::{Arc, Body, BoxFuture, CompressionEncoding, Context, EnabledCompressionEncodings, InterceptedService, Poll, StdError, async_trait, empty_body, http}; /// Generated trait containing gRPC methods that should be implemented for use with ArtifactStoreServer. #[async_trait] pub trait ArtifactStore: std::marker::Send + std::marker::Sync + 'static { diff --git a/crates/sdk/src/network/proto/mod.rs b/crates/sdk/src/network/proto/mod.rs index a61610bd4d..48eb63675a 100644 --- a/crates/sdk/src/network/proto/mod.rs +++ b/crates/sdk/src/network/proto/mod.rs @@ -1 +1,2 @@ +pub mod artifact; pub mod network; diff --git a/crates/sdk/src/network/proto/network.rs b/crates/sdk/src/network/proto/network.rs index 545c9db255..52691b93ab 100644 --- a/crates/sdk/src/network/proto/network.rs +++ b/crates/sdk/src/network/proto/network.rs @@ -1,271 +1,1146 @@ // This file is @generated by prost-build. -/// The request to create a proof, the first step in requesting a proof. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CreateProofRequest { - /// The signature of the message. - #[prost(bytes = "vec", tag = "1")] +pub struct RequestProofRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct RequestProofRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The mode for proof generation. - #[prost(enumeration = "ProofMode", tag = "3")] + /// The verification key hash of the program. + #[prost(bytes = "vec", tag = "2")] + pub vk_hash: ::prost::alloc::vec::Vec, + /// The version of the prover to use. + #[prost(string, tag = "3")] + pub version: ::prost::alloc::string::String, + /// The mode for the request. + #[prost(enumeration = "ProofMode", tag = "4")] pub mode: i32, - /// The deadline for the proof request, signifying the latest time a fulfillment would be valid. - #[prost(uint64, tag = "4")] + /// The strategy for fulfiller assignment. + #[prost(enumeration = "FulfillmentStrategy", tag = "5")] + pub strategy: i32, + /// The stdin resource identifier. + #[prost(string, tag = "6")] + pub stdin_uri: ::prost::alloc::string::String, + /// The deadline for the request. + #[prost(uint64, tag = "7")] pub deadline: u64, - /// The SP1 circuit version to use for the proof. - #[prost(string, tag = "5")] - pub circuit_version: ::prost::alloc::string::String, + /// The cycle limit for the request. + #[prost(uint64, tag = "8")] + pub cycle_limit: u64, } -/// The response for creating a proof. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct CreateProofResponse { - /// The proof identifier. - #[prost(string, tag = "1")] - pub proof_id: ::prost::alloc::string::String, - /// The URL to upload the ELF file. - #[prost(string, tag = "2")] - pub program_url: ::prost::alloc::string::String, - /// The URL to upload the standard input (stdin). - #[prost(string, tag = "3")] - pub stdin_url: ::prost::alloc::string::String, +pub struct RequestProofResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The request to submit a proof, the second step in requesting a proof. MUST be called when the -/// proof is in a PROOF_REQUESTED state and MUST be called after uploading the program and stdin to -/// the URLs provided during create proof. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct SubmitProofRequest { - /// The signature of the message. +pub struct RequestProofResponseBody { + /// The identifier for the request. #[prost(bytes = "vec", tag = "1")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FulfillProofRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FulfillProofRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. - #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, + /// The identifier for the request. + #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, + /// The proof bytes. + #[prost(bytes = "vec", tag = "3")] + pub proof: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FulfillProofResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The response for submitting a proof, empty on success. #[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct SubmitProofResponse {} -/// The request to claim a proof, which agrees to fulfill the proof by the deadline. MUST be called -/// when the proof is in a PROOF_REQUESTED state. +pub struct FulfillProofResponseBody {} #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ClaimProofRequest { - /// The signature of the message. +pub struct ExecuteProofRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct ExecuteProofRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The identifier for the request. + #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, + /// The execution status of the request. + #[prost(enumeration = "ExecutionStatus", tag = "3")] + pub execution_status: i32, + /// The optional public values hash of the request execution, only included if + /// the request is valid. + #[prost(bytes = "vec", optional, tag = "4")] + pub public_values_hash: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional cycles used when executing the request, only included if the + /// request is valid. + #[prost(uint64, optional, tag = "5")] + pub cycles: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct ExecuteProofResponse { + /// The transaction hash. #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct ExecuteProofResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailFulfillmentRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailFulfillmentRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. + /// The identifier for the request. + #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailFulfillmentResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct FailFulfillmentResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailExecutionRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailExecutionRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The identifier for the request. + #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct FailExecutionResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct FailExecutionResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct ProofRequest { + /// The request identifier. + #[prost(bytes = "vec", tag = "1")] + pub request_id: ::prost::alloc::vec::Vec, + /// The verification key hash of the program. + #[prost(bytes = "vec", tag = "2")] + pub vk_hash: ::prost::alloc::vec::Vec, + /// The version of the prover to use. #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, + pub version: ::prost::alloc::string::String, + /// The mode for the proof. + #[prost(enumeration = "ProofMode", tag = "4")] + pub mode: i32, + /// The strategy for fulfiller assignment. + #[prost(enumeration = "FulfillmentStrategy", tag = "5")] + pub strategy: i32, + /// The program resource identifier. + #[prost(string, tag = "6")] + pub program_uri: ::prost::alloc::string::String, + /// The stdin resource identifier. + #[prost(string, tag = "7")] + pub stdin_uri: ::prost::alloc::string::String, + /// The deadline for the request. + #[prost(uint64, tag = "8")] + pub deadline: u64, + /// The cycle limit for the request. + #[prost(uint64, tag = "9")] + pub cycle_limit: u64, + /// The gas price for the request. + #[prost(uint64, optional, tag = "10")] + pub gas_price: ::core::option::Option, + /// The fulfillment status of the request. + #[prost(enumeration = "FulfillmentStatus", tag = "11")] + pub fulfillment_status: i32, + /// The execution status of the request. + #[prost(enumeration = "ExecutionStatus", tag = "12")] + pub execution_status: i32, + /// The requester address that signed the request. + #[prost(bytes = "vec", tag = "13")] + pub requester: ::prost::alloc::vec::Vec, + /// The fulfiller address that fulfilled the request. + #[prost(bytes = "vec", optional, tag = "14")] + pub fulfiller: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional name to refer to an alias of the program id. + #[prost(string, optional, tag = "15")] + pub program_name: ::core::option::Option<::prost::alloc::string::String>, + /// The optional name to refer to an alias of the requester address. + #[prost(string, optional, tag = "16")] + pub requester_name: ::core::option::Option<::prost::alloc::string::String>, + /// The optional name to refer to an alias of the fulfiller address. + #[prost(string, optional, tag = "17")] + pub fulfiller_name: ::core::option::Option<::prost::alloc::string::String>, + /// The unix timestamp of when the request was created. + #[prost(uint64, tag = "18")] + pub created_at: u64, + /// The unix timestamp of when the request was updated. + #[prost(uint64, tag = "19")] + pub updated_at: u64, + /// The unix timestamp of when the request was fulfilled. + #[prost(uint64, optional, tag = "20")] + pub fulfilled_at: ::core::option::Option, + /// The transaction hash of the request. + #[prost(bytes = "vec", tag = "21")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The cycle count for the request. + #[prost(uint64, optional, tag = "22")] + pub cycles: ::core::option::Option, + /// The amount deducted from the fulfiller's balance. + #[prost(string, optional, tag = "23")] + pub deduction_amount: ::core::option::Option<::prost::alloc::string::String>, + /// The amount refunded to the fulfiller's balance. + #[prost(string, optional, tag = "24")] + pub refund_amount: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestStatusRequest { + /// The identifier for the request. + #[prost(bytes = "vec", tag = "1")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestStatusResponse { + /// The fulfillment status of the request. + #[prost(enumeration = "FulfillmentStatus", tag = "1")] + pub fulfillment_status: i32, + /// The execution status of the request. + #[prost(enumeration = "ExecutionStatus", tag = "2")] + pub execution_status: i32, + /// The transaction hash of the request. + #[prost(bytes = "vec", tag = "3")] + pub request_tx_hash: ::prost::alloc::vec::Vec, + /// The optional transaction hash of the proof fulfill. Only included if the + /// request has a fulfillment status of FULFILLED. + #[prost(bytes = "vec", optional, tag = "4")] + pub fulfill_tx_hash: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional proof URI, where you can download the result of the request. + /// Only included if the request has a fulfillment status of FULFILLED. + #[prost(string, optional, tag = "5")] + pub proof_uri: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestDetailsRequest { + /// The identifier for the request. + #[prost(bytes = "vec", tag = "1")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestDetailsResponse { + /// The detailed request. + #[prost(message, optional, tag = "1")] + pub request: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredProofRequestsRequest { + /// The optional version of the requests to filter for. + #[prost(string, optional, tag = "1")] + pub version: ::core::option::Option<::prost::alloc::string::String>, + /// The optional fulfillment status of the requests to filter for. + #[prost(enumeration = "FulfillmentStatus", optional, tag = "2")] + pub fulfillment_status: ::core::option::Option, + /// The optional execution status of the requests to filter for. + #[prost(enumeration = "ExecutionStatus", optional, tag = "3")] + pub execution_status: ::core::option::Option, + /// The optional minimum unix timestamp deadline of the requests to filter for. + /// Only returns requests with deadlines after this timestamp. + #[prost(uint64, optional, tag = "4")] + pub minimum_deadline: ::core::option::Option, + /// The optional verification key hash of the program to filter for. + #[prost(bytes = "vec", optional, tag = "5")] + pub vk_hash: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional requester address to filter for. + #[prost(bytes = "vec", optional, tag = "6")] + pub requester: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional fulfiller address to filter for. + #[prost(bytes = "vec", optional, tag = "7")] + pub fulfiller: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional minimum creation unix timestamp of the requests to filter for. + #[prost(uint64, optional, tag = "8")] + pub from: ::core::option::Option, + /// The optional maximum creation unix timestamp of the requests to filter for. + #[prost(uint64, optional, tag = "9")] + pub to: ::core::option::Option, + /// The optional maximum number of requests to return (default is 10, + /// maximum is 100). + #[prost(uint32, optional, tag = "10")] + pub limit: ::core::option::Option, + /// The optional page number to return (default is 1). + #[prost(uint32, optional, tag = "11")] + pub page: ::core::option::Option, + /// The optional mode of the requests to filter for. + #[prost(enumeration = "ProofMode", optional, tag = "12")] + pub mode: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredProofRequestsResponse { + /// The requests that matched the filter criteria. + #[prost(message, repeated, tag = "1")] + pub requests: ::prost::alloc::vec::Vec, } -/// The response for claiming a proof, giving identifiers for the locations to retrieve the program -/// and stdin, as well as the location to upload the proof. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ClaimProofResponse { - /// The artifact identifier for the program location. +pub struct GetSearchResultsRequest { + /// The search query string. #[prost(string, tag = "1")] - pub program_artifact_id: ::prost::alloc::string::String, - /// The artifact identifier for the stdin location. - #[prost(string, tag = "2")] - pub stdin_artifact_id: ::prost::alloc::string::String, - /// The artifact identifier for the proof location. - #[prost(string, tag = "3")] - pub proof_artifact_id: ::prost::alloc::string::String, + pub query: ::prost::alloc::string::String, } -/// The request to unclaim a proof, which cancels the claim to fulfill the proof. MUST be called -/// when the proof is in a PROOF_CLAIMED state and MUST be called by the prover who claimed it. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct UnclaimProofRequest { - /// The signature of the message. +pub struct SearchResult { #[prost(bytes = "vec", tag = "1")] - pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. + pub id: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "2")] + pub name: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetSearchResultsResponse { + /// List of matching request IDs with optional names. + #[prost(message, repeated, tag = "1")] + pub requests: ::prost::alloc::vec::Vec, + /// List of matching program IDs with optional names. + #[prost(message, repeated, tag = "2")] + pub programs: ::prost::alloc::vec::Vec, + /// List of matching requester IDs with optional names. + #[prost(message, repeated, tag = "3")] + pub requesters: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestMetricsRequest { + /// The optional address to filter for. + #[prost(bytes = "vec", optional, tag = "1")] + pub address: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional interval in days for volume calculation. + #[prost(uint64, optional, tag = "2")] + pub volume_interval_days: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetProofRequestMetricsResponse { + /// The total number of proofs. + #[prost(uint64, tag = "1")] + pub total_proofs: u64, + /// The total number of cycles. #[prost(uint64, tag = "2")] + pub total_cycles: u64, + /// The volume in the specified interval. + #[prost(uint64, tag = "3")] + pub volume: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestGraphRequest { + /// The optional address to filter for. + #[prost(bytes = "vec", optional, tag = "1")] + pub address: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional interval in days for the graph range. + #[prost(uint64, optional, tag = "2")] + pub range_interval_days: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GraphData { + /// The timestamp of the data point. + #[prost(string, tag = "1")] + pub timestamp: ::prost::alloc::string::String, + /// The value at this timestamp. + #[prost(uint64, tag = "2")] + pub value: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProofRequestGraphResponse { + /// The time series data points. + #[prost(message, repeated, tag = "1")] + pub data: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetAnalyticsGraphsRequest { + /// The optional address to filter for. + #[prost(bytes = "vec", optional, tag = "1")] + pub address: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional interval in days for the graph range. + #[prost(uint64, optional, tag = "2")] + pub range_interval_days: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetAnalyticsGraphsResponse { + /// The time series data points for proof count. + #[prost(message, repeated, tag = "1")] + pub proofs: ::prost::alloc::vec::Vec, + /// The time series data points for program count. + #[prost(message, repeated, tag = "2")] + pub programs: ::prost::alloc::vec::Vec, + /// The time series data points for cycle count. + #[prost(message, repeated, tag = "3")] + pub cycles: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetNonceRequest { + /// The address of the account. + #[prost(bytes = "vec", tag = "1")] + pub address: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetNonceResponse { + /// The nonce of the account. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. - #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, - /// The reason for unclaiming the proof. - #[prost(enumeration = "UnclaimReason", tag = "4")] - pub reason: i32, - /// The description for the reason. - #[prost(string, tag = "5")] - pub description: ::prost::alloc::string::String, -} -/// The response for unclaiming a proof, empty on success. +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct Delegation { + /// The address of the owner. + #[prost(bytes = "vec", tag = "1")] + pub owner: ::prost::alloc::vec::Vec, + /// The address of the delegate (the account with granted permissions). + #[prost(bytes = "vec", tag = "2")] + pub delegate: ::prost::alloc::vec::Vec, + /// Whether the delegation has been accepted. + #[prost(bool, tag = "3")] + pub accepted: bool, + /// The unix timestamp of when the delegation was created. + #[prost(uint64, tag = "4")] + pub created_at: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredDelegationsRequest { + /// The optional owner address to filter for. + #[prost(bytes = "vec", optional, tag = "1")] + pub owner: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional maximum number of requests to return (default is 10, + /// maximum is 100). + #[prost(uint32, optional, tag = "2")] + pub limit: ::core::option::Option, + /// The optional page number to return (default is 1). + #[prost(uint32, optional, tag = "3")] + pub page: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredDelegationsResponse { + /// The delegations that matched the filter criteria. + #[prost(message, repeated, tag = "1")] + pub delegations: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddDelegationRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddDelegationRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The delegate address to add. + #[prost(bytes = "vec", tag = "2")] + pub delegate: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddDelegationResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} #[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct UnclaimProofResponse {} -/// The request to update a proof's CPU cycle count. +pub struct AddDelegationResponseBody {} #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct ModifyCpuCyclesRequest { - /// The signature of the message. +pub struct RemoveDelegationRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct RemoveDelegationRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The delegate address to remove. + #[prost(bytes = "vec", tag = "2")] + pub delegate: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct RemoveDelegationResponse { + /// The transaction hash. #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct RemoveDelegationResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AcceptDelegationRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AcceptDelegationRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The address of the owner who requested the delegation + #[prost(bytes = "vec", tag = "2")] + pub owner: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AcceptDelegationResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct AcceptDelegationResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetAccountNameRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetAccountNameRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. + /// The address of the account to update the name of. Only the sender can + /// update the name unless authorized. + #[prost(bytes = "vec", tag = "2")] + pub address: ::prost::alloc::vec::Vec, + /// The name of the account. Must be unique. #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, - /// The number of CPU cycles for this proof. - #[prost(uint64, tag = "4")] - pub cycles: u64, + pub name: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetAccountNameResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The response for updating a proof's CPU cycle count, empty on success. #[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct ModifyCpuCyclesResponse {} -/// The request to fulfill a proof. MUST be called after the proof has been uploaded and MUST be called -/// when the proof is in a PROOF_CLAIMED state. +pub struct SetAccountNameResponseBody {} #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct FulfillProofRequest { - /// The signature of the message. +pub struct GetAccountNameRequest { + /// The address of the account. #[prost(bytes = "vec", tag = "1")] + pub address: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetAccountNameResponse { + /// The name of the account. + #[prost(string, optional, tag = "1")] + pub name: ::core::option::Option<::prost::alloc::string::String>, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetTermsSignatureRequest { + /// The address of the account. + #[prost(bytes = "vec", tag = "1")] + pub address: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetTermsSignatureResponse { + /// Whether the account has signed the terms. + #[prost(bool, tag = "1")] + pub is_signed: bool, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetTermsSignatureRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetTermsSignatureRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. - #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, + /// The address of the account. + #[prost(bytes = "vec", tag = "2")] + pub address: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetTermsSignatureResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The response for fulfilling a proof, empty on success. #[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct FulfillProofResponse { - /// The amount of time, in seconds, between proof claim and fulfillment. +pub struct SetTermsSignatureResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct Program { + /// The verification key hash. + #[prost(bytes = "vec", tag = "1")] + pub vk_hash: ::prost::alloc::vec::Vec, + /// The verification key. + #[prost(bytes = "vec", tag = "2")] + pub vk: ::prost::alloc::vec::Vec, + /// The program resource identifier. + #[prost(string, tag = "3")] + pub program_uri: ::prost::alloc::string::String, + /// The optional name of the program. + #[prost(string, optional, tag = "4")] + pub name: ::core::option::Option<::prost::alloc::string::String>, + /// The owner of the program. + #[prost(bytes = "vec", tag = "5")] + pub owner: ::prost::alloc::vec::Vec, + /// The unix timestamp of when the program was created. + #[prost(uint64, tag = "6")] + pub created_at: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProgramRequest { + /// The verification key hash of the program. + #[prost(bytes = "vec", tag = "1")] + pub vk_hash: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetProgramResponse { + /// The program details. + #[prost(message, optional, tag = "1")] + pub program: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct CreateProgramRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct CreateProgramRequestBody { + /// The account nonce of the sender. #[prost(uint64, tag = "1")] - pub proving_seconds: u64, + pub nonce: u64, + /// The verification key hash. + #[prost(bytes = "vec", tag = "2")] + pub vk_hash: ::prost::alloc::vec::Vec, + /// The verification key. + #[prost(bytes = "vec", tag = "3")] + pub vk: ::prost::alloc::vec::Vec, + /// The program resource identifier. + #[prost(string, tag = "4")] + pub program_uri: ::prost::alloc::string::String, } -/// The request to relay a proof through the NetworkGateway on a given chain. MUST be called when the -/// proof is in a PROOF_FULFILLED state. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RelayProofRequest { - /// The signature of the message. +pub struct CreateProgramResponse { + /// The transaction hash. #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct CreateProgramResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetProgramNameRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] pub signature: ::prost::alloc::vec::Vec, - /// The nonce for the account. - #[prost(uint64, tag = "2")] + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetProgramNameRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] pub nonce: u64, - /// The proof identifier. + /// The identifier of the program to update the name of. Only the original + /// program creator can update the name unless authorized. + #[prost(bytes = "vec", tag = "2")] + pub vk_hash: ::prost::alloc::vec::Vec, + /// The name of the program. Must be unique. #[prost(string, tag = "3")] - pub proof_id: ::prost::alloc::string::String, - /// The chain ID for the requested chain. - #[prost(uint32, tag = "4")] - pub chain_id: u32, - /// The address of the verifier for this proof. - #[prost(bytes = "vec", tag = "5")] - pub verifier: ::prost::alloc::vec::Vec, - /// The address of the callback to call after the proof has been verified by the verifier. - #[prost(bytes = "vec", tag = "6")] - pub callback: ::prost::alloc::vec::Vec, - /// The data to send to the callback, including the function selector. - #[prost(bytes = "vec", tag = "7")] - pub callback_data: ::prost::alloc::vec::Vec, -} -/// The response for relaying a proof. -#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RelayProofResponse { - /// The transaction identifier. + pub name: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SetProgramNameResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct SetProgramNameResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetBalanceRequest { + /// The address of the account. + #[prost(bytes = "vec", tag = "1")] + pub address: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetBalanceResponse { + /// The amount of credits owned by the account. #[prost(string, tag = "1")] - pub tx_id: ::prost::alloc::string::String, + pub amount: ::prost::alloc::string::String, } -/// The request for an account nonce. Used to check current nonce for the account, which must match when signing and sending a message. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetNonceRequest { - /// The account's address for which to get the nonce. +pub struct BalanceLog { + /// The address of the account. #[prost(bytes = "vec", tag = "1")] pub address: ::prost::alloc::vec::Vec, + /// The type of balance change operation. + #[prost(enumeration = "BalanceOperation", tag = "2")] + pub operation: i32, + /// The amount of the change (can be positive or negative). + #[prost(string, tag = "3")] + pub amount: ::prost::alloc::string::String, + /// The transaction hash that caused this change. + #[prost(bytes = "vec", tag = "4")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The unix timestamp of when this change occurred. + #[prost(uint64, tag = "5")] + pub created_at: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredBalanceLogsRequest { + /// The optional address to filter for. + #[prost(bytes = "vec", optional, tag = "1")] + pub address: ::core::option::Option<::prost::alloc::vec::Vec>, + /// The optional type of operations to filter for. + #[prost(enumeration = "BalanceOperation", optional, tag = "2")] + pub operation: ::core::option::Option, + /// The optional minimum unix timestamp to filter logs from. Only returns + /// logs after this timestamp. + #[prost(uint64, optional, tag = "3")] + pub minimum_timestamp: ::core::option::Option, + /// The optional maximum unix timestamp to filter logs to. Only returns + /// logs before this timestamp. + #[prost(uint64, optional, tag = "4")] + pub maximum_timestamp: ::core::option::Option, + /// The optional maximum number of logs to return (default is 10, maximum is 100). + #[prost(uint32, optional, tag = "5")] + pub limit: ::core::option::Option, + /// The optional page number to return (default is 1). + #[prost(uint32, optional, tag = "6")] + pub page: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetFilteredBalanceLogsResponse { + /// The balance logs that matched the filter criteria. + #[prost(message, repeated, tag = "1")] + pub logs: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddCreditRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddCreditRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The address of the account to add credits to. + #[prost(bytes = "vec", tag = "2")] + pub address: ::prost::alloc::vec::Vec, + /// The amount of credits to add. + #[prost(string, tag = "3")] + pub amount: ::prost::alloc::string::String, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddCreditResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The response for a nonce request. #[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] -pub struct GetNonceResponse { - /// The nonce for the given address. It should be signed along with the rest of the message. +pub struct AddCreditResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetLatestBridgeBlockRequest { + /// The chain ID of the bridge. + #[prost(uint32, tag = "1")] + pub chain_id: u32, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetLatestBridgeBlockResponse { + /// The latest processed block in the bridge. + #[prost(uint64, tag = "1")] + pub block_number: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetGasPriceEstimateRequest { + #[prost(enumeration = "FulfillmentStrategy", tag = "1")] + pub strategy: i32, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetGasPriceEstimateResponse { #[prost(uint64, tag = "1")] + pub gas_price: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct GetTransactionDetailsRequest { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct TransactionDetails { + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "3")] + pub signature: ::prost::alloc::vec::Vec, + #[prost(uint64, tag = "4")] pub nonce: u64, + #[prost(uint64, tag = "5")] + pub created_at: u64, + #[prost(string, optional, tag = "6")] + pub name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bytes = "vec", optional, tag = "7")] + pub request_id: ::core::option::Option<::prost::alloc::vec::Vec>, } -/// The request to get a proof status by a given proof ID. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofStatusRequest { - /// The proof identifier. - #[prost(string, tag = "1")] - pub proof_id: ::prost::alloc::string::String, +pub struct GetTransactionDetailsResponse { + #[prost(message, optional, tag = "1")] + pub transaction: ::core::option::Option, } -/// The response for a proof status request. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofStatusResponse { - /// The status of the proof request. - #[prost(enumeration = "ProofStatus", tag = "1")] - pub status: i32, - /// Optional proof URL, where you can download the result of the proof request. Only included if - /// the proof has been fulfilled. - #[prost(string, optional, tag = "2")] - pub proof_url: ::core::option::Option<::prost::alloc::string::String>, - /// If the proof was unclaimed, the reason why. - #[prost(enumeration = "UnclaimReason", optional, tag = "3")] - pub unclaim_reason: ::core::option::Option, - /// If the proof was unclaimed, the description detailing why. +pub struct Reservation { + /// The address of the requester. + #[prost(bytes = "vec", tag = "1")] + pub requester: ::prost::alloc::vec::Vec, + /// The address of the fulfiller. + #[prost(bytes = "vec", tag = "2")] + pub fulfiller: ::prost::alloc::vec::Vec, + /// The optional name to refer to an alias of the requester address. + #[prost(string, optional, tag = "3")] + pub requester_name: ::core::option::Option<::prost::alloc::string::String>, + /// The optional name to refer to an alias of the fulfiller address. #[prost(string, optional, tag = "4")] - pub unclaim_description: ::core::option::Option<::prost::alloc::string::String>, + pub fulfiller_name: ::core::option::Option<::prost::alloc::string::String>, + /// The unix timestamp of when the reservation was created. + #[prost(uint64, tag = "5")] + pub created_at: u64, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetFilteredReservationsRequest { + /// The optional maximum number of reservations to return (default is 10, + /// maximum is 100). + #[prost(uint32, optional, tag = "1")] + pub limit: ::core::option::Option, + /// The optional page number to return (default is 1). + #[prost(uint32, optional, tag = "2")] + pub page: ::core::option::Option, } -/// The request to get proof requests by a given status. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestsRequest { - /// The status of the proof requests to filter for. - #[prost(enumeration = "ProofStatus", tag = "1")] - pub status: i32, - /// The SP1 circuit version of the proof requests to filter for. - #[prost(string, optional, tag = "2")] - pub circuit_version: ::core::option::Option<::prost::alloc::string::String>, +pub struct GetFilteredReservationsResponse { + /// The reservations that matched the filter criteria. + #[prost(message, repeated, tag = "1")] + pub reservations: ::prost::alloc::vec::Vec, } -/// A proof request. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct RequestedProof { - /// The proof identifier. - #[prost(string, tag = "1")] - pub proof_id: ::prost::alloc::string::String, - /// The mode for proof generation. - #[prost(enumeration = "ProofMode", tag = "2")] - pub mode: i32, - /// Proof requester's address. +pub struct AddReservationRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddReservationRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The address of the requester to add reservation for. + #[prost(bytes = "vec", tag = "2")] + pub requester: ::prost::alloc::vec::Vec, + /// The address of the fulfiller to reserve. #[prost(bytes = "vec", tag = "3")] + pub fulfiller: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct AddReservationResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct AddReservationResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct RemoveReservationRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct RemoveReservationRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The address of the requester to remove reservation for. + #[prost(bytes = "vec", tag = "2")] pub requester: ::prost::alloc::vec::Vec, - /// The SP1 circuit version to use for the proof. - #[prost(string, tag = "4")] - pub circuit_version: ::prost::alloc::string::String, } -/// The response for getting proof requests by a given status. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetProofRequestsResponse { - /// The proof identifiers of the proof requests. Limited to the 10 most recent proof requests with - /// that status. - #[prost(message, repeated, tag = "1")] - pub proofs: ::prost::alloc::vec::Vec, +pub struct RemoveReservationResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, } -/// The request to get the status of a relay request. +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct RemoveReservationResponseBody {} #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetRelayStatusRequest { - /// The transaction identifier. - #[prost(string, tag = "1")] - pub tx_id: ::prost::alloc::string::String, +pub struct BidRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct BidRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The request ID to bid on. + #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, } -/// The response for getting the status of a relay request. #[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] -pub struct GetRelayStatusResponse { - /// The status of the transaction. - #[prost(enumeration = "TransactionStatus", tag = "1")] - pub status: i32, +pub struct BidResponse { /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] + pub tx_hash: ::prost::alloc::vec::Vec, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct BidResponseBody {} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SettleRequest { + /// The message format of the body. + #[prost(enumeration = "MessageFormat", tag = "1")] + pub format: i32, + /// The signature of the sender. + #[prost(bytes = "vec", tag = "2")] + pub signature: ::prost::alloc::vec::Vec, + /// The body of the request. + #[prost(message, optional, tag = "3")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SettleRequestBody { + /// The account nonce of the sender. + #[prost(uint64, tag = "1")] + pub nonce: u64, + /// The request ID to settle bids for. #[prost(bytes = "vec", tag = "2")] + pub request_id: ::prost::alloc::vec::Vec, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, ::prost::Message)] +pub struct SettleResponse { + /// The transaction hash. + #[prost(bytes = "vec", tag = "1")] pub tx_hash: ::prost::alloc::vec::Vec, - /// The transactionsimulation URL, only present if the transaction failed. - #[prost(string, tag = "3")] - pub simulation_url: ::prost::alloc::string::String, + /// The body of the response. + #[prost(message, optional, tag = "2")] + pub body: ::core::option::Option, +} +#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, PartialEq, ::prost::Message)] +pub struct SettleResponseBody {} +/// Format to help decode signature in backend. +#[derive( + serde::Serialize, + serde::Deserialize, + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration, +)] +#[repr(i32)] +pub enum MessageFormat { + /// Unspecified message format. + UnspecifiedMessageFormat = 0, + /// The message is in binary format. + Binary = 1, + /// The message is in JSON format. + Json = 2, +} +impl MessageFormat { + /// String value of the enum field names used in the `ProtoBuf` definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { + match self { + Self::UnspecifiedMessageFormat => "UNSPECIFIED_MESSAGE_FORMAT", + Self::Binary => "BINARY", + Self::Json => "JSON", + } + } + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED_MESSAGE_FORMAT" => Some(Self::UnspecifiedMessageFormat), + "BINARY" => Some(Self::Binary), + "JSON" => Some(Self::Json), + _ => None, + } + } } -/// The mode used when generating the proof. #[derive( serde::Serialize, serde::Deserialize, @@ -281,44 +1156,43 @@ pub struct GetRelayStatusResponse { )] #[repr(i32)] pub enum ProofMode { - /// Unspecified or invalid proof mode. - Unspecified = 0, - /// The proof mode for an SP1 core proof. + UnspecifiedProofMode = 0, + /// The core proof mode. Core = 1, - /// The proof mode for a compressed proof. + /// The compressed proof mode. Compressed = 2, - /// The proof mode for a PlonK proof. + /// The plonk proof mode. Plonk = 3, - /// The proof mode for a Groth16 proof. + /// The groth16 proof mode. Groth16 = 4, } impl ProofMode { - /// String value of the enum field names used in the ProtoBuf definition. + /// String value of the enum field names used in the `ProtoBuf` definition. /// /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { match self { - Self::Unspecified => "PROOF_MODE_UNSPECIFIED", - Self::Core => "PROOF_MODE_CORE", - Self::Compressed => "PROOF_MODE_COMPRESSED", - Self::Plonk => "PROOF_MODE_PLONK", - Self::Groth16 => "PROOF_MODE_GROTH16", + Self::UnspecifiedProofMode => "UNSPECIFIED_PROOF_MODE", + Self::Core => "CORE", + Self::Compressed => "COMPRESSED", + Self::Plonk => "PLONK", + Self::Groth16 => "GROTH16", } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "PROOF_MODE_UNSPECIFIED" => Some(Self::Unspecified), - "PROOF_MODE_CORE" => Some(Self::Core), - "PROOF_MODE_COMPRESSED" => Some(Self::Compressed), - "PROOF_MODE_PLONK" => Some(Self::Plonk), - "PROOF_MODE_GROTH16" => Some(Self::Groth16), + "UNSPECIFIED_PROOF_MODE" => Some(Self::UnspecifiedProofMode), + "CORE" => Some(Self::Core), + "COMPRESSED" => Some(Self::Compressed), + "PLONK" => Some(Self::Plonk), + "GROTH16" => Some(Self::Groth16), _ => None, } } } -/// The status of a proof request. +/// The different strategies that can be used for fulfilling requests. #[derive( serde::Serialize, serde::Deserialize, @@ -333,49 +1207,42 @@ impl ProofMode { ::prost::Enumeration, )] #[repr(i32)] -pub enum ProofStatus { - /// Unspecified or invalid status. - ProofUnspecifiedStatus = 0, - /// The proof request has been created but is awaiting the requester to submit it. - ProofPreparing = 1, - /// The proof request has been submitted and is awaiting a prover to claim it. - ProofRequested = 2, - /// The proof request has been claimed and is awaiting a prover to fulfill it. - ProofClaimed = 3, - /// The proof request was previously claimed but has now been unclaimed. - ProofUnclaimed = 4, - /// The proof request has been fulfilled and is available for download. - ProofFulfilled = 5, -} -impl ProofStatus { - /// String value of the enum field names used in the ProtoBuf definition. +pub enum FulfillmentStrategy { + UnspecifiedFulfillmentStrategy = 0, + /// The hosted fulfillment strategy. Uses Succinct's on-demand prover to fulfill requests. + Hosted = 1, + /// The reserved fulfillment strategy. Uses an already existing agreement with a + /// fulfiller to fulfill requests. + Reserved = 2, + /// The auction fulfillment strategy. Uses a decentralized proof contest to + /// fulfill requests. + Auction = 3, +} +impl FulfillmentStrategy { + /// String value of the enum field names used in the `ProtoBuf` definition. /// /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { match self { - Self::ProofUnspecifiedStatus => "PROOF_UNSPECIFIED_STATUS", - Self::ProofPreparing => "PROOF_PREPARING", - Self::ProofRequested => "PROOF_REQUESTED", - Self::ProofClaimed => "PROOF_CLAIMED", - Self::ProofUnclaimed => "PROOF_UNCLAIMED", - Self::ProofFulfilled => "PROOF_FULFILLED", + Self::UnspecifiedFulfillmentStrategy => "UNSPECIFIED_FULFILLMENT_STRATEGY", + Self::Hosted => "HOSTED", + Self::Reserved => "RESERVED", + Self::Auction => "AUCTION", } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "PROOF_UNSPECIFIED_STATUS" => Some(Self::ProofUnspecifiedStatus), - "PROOF_PREPARING" => Some(Self::ProofPreparing), - "PROOF_REQUESTED" => Some(Self::ProofRequested), - "PROOF_CLAIMED" => Some(Self::ProofClaimed), - "PROOF_UNCLAIMED" => Some(Self::ProofUnclaimed), - "PROOF_FULFILLED" => Some(Self::ProofFulfilled), + "UNSPECIFIED_FULFILLMENT_STRATEGY" => Some(Self::UnspecifiedFulfillmentStrategy), + "HOSTED" => Some(Self::Hosted), + "RESERVED" => Some(Self::Reserved), + "AUCTION" => Some(Self::Auction), _ => None, } } } -/// The status of a relay request transaction. +/// The different fulfillment statuses that a request can be in. #[derive( serde::Serialize, serde::Deserialize, @@ -390,48 +1257,44 @@ impl ProofStatus { ::prost::Enumeration, )] #[repr(i32)] -pub enum TransactionStatus { - /// Unspecified or invalid status. - TransactionUnspecifiedStatus = 0, - /// The transaction has been scheduled for relay. - TransactionScheduled = 1, - /// The transaction has been broadcast to the requested chain. - TransactionBroadcasted = 2, - /// The transaction was never confirmed as mined. - TransactionTimedout = 3, - /// The transaction failed to be broadcast, likely due to a revert in simulation. - TransactionFailed = 4, - /// The transaction was mined successfully. - TransactionFinalized = 5, -} -impl TransactionStatus { - /// String value of the enum field names used in the ProtoBuf definition. +pub enum FulfillmentStatus { + UnspecifiedFulfillmentStatus = 0, + /// The request has been requested. + Requested = 1, + /// The request has been assigned to a fulfiller. + Assigned = 2, + /// The request has been fulfilled. + Fulfilled = 3, + /// The request cannot be fulfilled. + Unfulfillable = 4, +} +impl FulfillmentStatus { + /// String value of the enum field names used in the `ProtoBuf` definition. /// /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { match self { - Self::TransactionUnspecifiedStatus => "TRANSACTION_UNSPECIFIED_STATUS", - Self::TransactionScheduled => "TRANSACTION_SCHEDULED", - Self::TransactionBroadcasted => "TRANSACTION_BROADCASTED", - Self::TransactionTimedout => "TRANSACTION_TIMEDOUT", - Self::TransactionFailed => "TRANSACTION_FAILED", - Self::TransactionFinalized => "TRANSACTION_FINALIZED", + Self::UnspecifiedFulfillmentStatus => "UNSPECIFIED_FULFILLMENT_STATUS", + Self::Requested => "REQUESTED", + Self::Assigned => "ASSIGNED", + Self::Fulfilled => "FULFILLED", + Self::Unfulfillable => "UNFULFILLABLE", } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "TRANSACTION_UNSPECIFIED_STATUS" => Some(Self::TransactionUnspecifiedStatus), - "TRANSACTION_SCHEDULED" => Some(Self::TransactionScheduled), - "TRANSACTION_BROADCASTED" => Some(Self::TransactionBroadcasted), - "TRANSACTION_TIMEDOUT" => Some(Self::TransactionTimedout), - "TRANSACTION_FAILED" => Some(Self::TransactionFailed), - "TRANSACTION_FINALIZED" => Some(Self::TransactionFinalized), + "UNSPECIFIED_FULFILLMENT_STATUS" => Some(Self::UnspecifiedFulfillmentStatus), + "REQUESTED" => Some(Self::Requested), + "ASSIGNED" => Some(Self::Assigned), + "FULFILLED" => Some(Self::Fulfilled), + "UNFULFILLABLE" => Some(Self::Unfulfillable), _ => None, } } } +/// The different execution statuses that a request can be in. #[derive( serde::Serialize, serde::Deserialize, @@ -446,348 +1309,2624 @@ impl TransactionStatus { ::prost::Enumeration, )] #[repr(i32)] -pub enum UnclaimReason { - /// Unspecified reason. - Unspecified = 0, - /// The prover claims the request is invalid and cannot be fulfilled. - Invalid = 1, - /// The prover is unable to fulfill the proof due to any other reason. - Abandoned = 2, -} -impl UnclaimReason { - /// String value of the enum field names used in the ProtoBuf definition. +pub enum ExecutionStatus { + UnspecifiedExecutionStatus = 0, + /// The request has not been executed. + Unexecuted = 1, + /// The request has been executed. + Executed = 2, + /// The request cannot be executed. + Unexecutable = 3, +} +impl ExecutionStatus { + /// String value of the enum field names used in the `ProtoBuf` definition. /// /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { match self { - Self::Unspecified => "UNCLAIM_REASON_UNSPECIFIED", - Self::Invalid => "UNCLAIM_REASON_INVALID", - Self::Abandoned => "UNCLAIM_REASON_ABANDONED", + Self::UnspecifiedExecutionStatus => "UNSPECIFIED_EXECUTION_STATUS", + Self::Unexecuted => "UNEXECUTED", + Self::Executed => "EXECUTED", + Self::Unexecutable => "UNEXECUTABLE", } } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "UNCLAIM_REASON_UNSPECIFIED" => Some(Self::Unspecified), - "UNCLAIM_REASON_INVALID" => Some(Self::Invalid), - "UNCLAIM_REASON_ABANDONED" => Some(Self::Abandoned), + "UNSPECIFIED_EXECUTION_STATUS" => Some(Self::UnspecifiedExecutionStatus), + "UNEXECUTED" => Some(Self::Unexecuted), + "EXECUTED" => Some(Self::Executed), + "UNEXECUTABLE" => Some(Self::Unexecutable), _ => None, } } } -pub use twirp; -pub const SERVICE_FQN: &str = "/network.NetworkService"; -#[twirp::async_trait::async_trait] -pub trait NetworkService { - async fn create_proof( - &self, - ctx: twirp::Context, - req: CreateProofRequest, - ) -> Result; - async fn submit_proof( - &self, - ctx: twirp::Context, - req: SubmitProofRequest, - ) -> Result; - async fn claim_proof( - &self, - ctx: twirp::Context, - req: ClaimProofRequest, - ) -> Result; - async fn unclaim_proof( - &self, - ctx: twirp::Context, - req: UnclaimProofRequest, - ) -> Result; - async fn modify_cpu_cycles( - &self, - ctx: twirp::Context, - req: ModifyCpuCyclesRequest, - ) -> Result; - async fn fulfill_proof( - &self, - ctx: twirp::Context, - req: FulfillProofRequest, - ) -> Result; - async fn relay_proof( - &self, - ctx: twirp::Context, - req: RelayProofRequest, - ) -> Result; - async fn get_nonce( - &self, - ctx: twirp::Context, - req: GetNonceRequest, - ) -> Result; - async fn get_proof_status( - &self, - ctx: twirp::Context, - req: GetProofStatusRequest, - ) -> Result; - async fn get_proof_requests( - &self, - ctx: twirp::Context, - req: GetProofRequestsRequest, - ) -> Result; - async fn get_relay_status( - &self, - ctx: twirp::Context, - req: GetRelayStatusRequest, - ) -> Result; -} -#[twirp::async_trait::async_trait] -impl NetworkService for std::sync::Arc -where - T: NetworkService + Sync + Send, -{ - async fn create_proof( - &self, - ctx: twirp::Context, - req: CreateProofRequest, - ) -> Result { - T::create_proof(&*self, ctx, req).await - } - async fn submit_proof( - &self, - ctx: twirp::Context, - req: SubmitProofRequest, - ) -> Result { - T::submit_proof(&*self, ctx, req).await - } - async fn claim_proof( - &self, - ctx: twirp::Context, - req: ClaimProofRequest, - ) -> Result { - T::claim_proof(&*self, ctx, req).await - } - async fn unclaim_proof( - &self, - ctx: twirp::Context, - req: UnclaimProofRequest, - ) -> Result { - T::unclaim_proof(&*self, ctx, req).await - } - async fn modify_cpu_cycles( - &self, - ctx: twirp::Context, - req: ModifyCpuCyclesRequest, - ) -> Result { - T::modify_cpu_cycles(&*self, ctx, req).await - } - async fn fulfill_proof( - &self, - ctx: twirp::Context, - req: FulfillProofRequest, - ) -> Result { - T::fulfill_proof(&*self, ctx, req).await - } - async fn relay_proof( - &self, - ctx: twirp::Context, - req: RelayProofRequest, - ) -> Result { - T::relay_proof(&*self, ctx, req).await - } - async fn get_nonce( - &self, - ctx: twirp::Context, - req: GetNonceRequest, - ) -> Result { - T::get_nonce(&*self, ctx, req).await - } - async fn get_proof_status( - &self, - ctx: twirp::Context, - req: GetProofStatusRequest, - ) -> Result { - T::get_proof_status(&*self, ctx, req).await - } - async fn get_proof_requests( - &self, - ctx: twirp::Context, - req: GetProofRequestsRequest, - ) -> Result { - T::get_proof_requests(&*self, ctx, req).await - } - async fn get_relay_status( - &self, - ctx: twirp::Context, - req: GetRelayStatusRequest, - ) -> Result { - T::get_relay_status(&*self, ctx, req).await - } +/// The different types of balance changes that can occur. +#[derive( + serde::Serialize, + serde::Deserialize, + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration, +)] +#[repr(i32)] +pub enum BalanceOperation { + UnspecifiedBalanceChangeOperation = 0, + /// A deposit operation (positive). + Deposit = 1, + /// A withdrawal operation (negative). + Withdrawal = 2, + /// A credit operation (positive). + Credit = 3, + /// A deduction operation (negative). + Deduction = 4, + /// A refund operation (positive). + Refund = 5, + /// A bid operation (negative). + Bid = 6, } -pub fn router(api: T) -> twirp::Router -where - T: NetworkService + Clone + Send + Sync + 'static, -{ - twirp::details::TwirpRouterBuilder::new(api) - .route("/CreateProof", |api: T, ctx: twirp::Context, req: CreateProofRequest| async move { - api.create_proof(ctx, req).await - }) - .route("/SubmitProof", |api: T, ctx: twirp::Context, req: SubmitProofRequest| async move { - api.submit_proof(ctx, req).await - }) - .route("/ClaimProof", |api: T, ctx: twirp::Context, req: ClaimProofRequest| async move { - api.claim_proof(ctx, req).await - }) - .route( - "/UnclaimProof", - |api: T, ctx: twirp::Context, req: UnclaimProofRequest| async move { - api.unclaim_proof(ctx, req).await - }, - ) - .route( - "/ModifyCpuCycles", - |api: T, ctx: twirp::Context, req: ModifyCpuCyclesRequest| async move { - api.modify_cpu_cycles(ctx, req).await - }, - ) - .route( - "/FulfillProof", - |api: T, ctx: twirp::Context, req: FulfillProofRequest| async move { - api.fulfill_proof(ctx, req).await - }, - ) - .route("/RelayProof", |api: T, ctx: twirp::Context, req: RelayProofRequest| async move { - api.relay_proof(ctx, req).await - }) - .route("/GetNonce", |api: T, ctx: twirp::Context, req: GetNonceRequest| async move { - api.get_nonce(ctx, req).await - }) - .route( - "/GetProofStatus", - |api: T, ctx: twirp::Context, req: GetProofStatusRequest| async move { - api.get_proof_status(ctx, req).await - }, - ) - .route( - "/GetProofRequests", - |api: T, ctx: twirp::Context, req: GetProofRequestsRequest| async move { - api.get_proof_requests(ctx, req).await - }, - ) - .route( - "/GetRelayStatus", - |api: T, ctx: twirp::Context, req: GetRelayStatusRequest| async move { - api.get_relay_status(ctx, req).await - }, - ) - .build() -} -#[twirp::async_trait::async_trait] -pub trait NetworkServiceClient: Send + Sync + std::fmt::Debug { - async fn create_proof( - &self, - req: CreateProofRequest, - ) -> Result; - async fn submit_proof( - &self, - req: SubmitProofRequest, - ) -> Result; - async fn claim_proof( - &self, - req: ClaimProofRequest, - ) -> Result; - async fn unclaim_proof( - &self, - req: UnclaimProofRequest, - ) -> Result; - async fn modify_cpu_cycles( - &self, - req: ModifyCpuCyclesRequest, - ) -> Result; - async fn fulfill_proof( - &self, - req: FulfillProofRequest, - ) -> Result; - async fn relay_proof( - &self, - req: RelayProofRequest, - ) -> Result; - async fn get_nonce(&self, req: GetNonceRequest) - -> Result; - async fn get_proof_status( - &self, - req: GetProofStatusRequest, - ) -> Result; - async fn get_proof_requests( - &self, - req: GetProofRequestsRequest, - ) -> Result; - async fn get_relay_status( - &self, - req: GetRelayStatusRequest, - ) -> Result; -} -#[twirp::async_trait::async_trait] -impl NetworkServiceClient for twirp::client::Client { - async fn create_proof( - &self, - req: CreateProofRequest, - ) -> Result { - self.request("network.NetworkService/CreateProof", req).await +impl BalanceOperation { + /// String value of the enum field names used in the `ProtoBuf` definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the `ProtoBuf` definition does not change) and safe for programmatic use. + #[must_use] pub fn as_str_name(&self) -> &'static str { + match self { + Self::UnspecifiedBalanceChangeOperation => "UNSPECIFIED_BALANCE_CHANGE_OPERATION", + Self::Deposit => "DEPOSIT", + Self::Withdrawal => "WITHDRAWAL", + Self::Credit => "CREDIT", + Self::Deduction => "DEDUCTION", + Self::Refund => "REFUND", + Self::Bid => "BID", + } } - async fn submit_proof( - &self, - req: SubmitProofRequest, - ) -> Result { - self.request("network.NetworkService/SubmitProof", req).await + /// Creates an enum from field names used in the `ProtoBuf` definition. + #[must_use] pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNSPECIFIED_BALANCE_CHANGE_OPERATION" => Some(Self::UnspecifiedBalanceChangeOperation), + "DEPOSIT" => Some(Self::Deposit), + "WITHDRAWAL" => Some(Self::Withdrawal), + "CREDIT" => Some(Self::Credit), + "DEDUCTION" => Some(Self::Deduction), + "REFUND" => Some(Self::Refund), + "BID" => Some(Self::Bid), + _ => None, + } } - async fn claim_proof( - &self, - req: ClaimProofRequest, - ) -> Result { - self.request("network.NetworkService/ClaimProof", req).await +} +/// Generated client implementations. +pub mod prover_network_client { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::http::Uri; + use tonic::codegen::{Body, Bytes, CompressionEncoding, GrpcMethod, InterceptedService, StdError, http}; + #[derive(Debug, Clone)] + pub struct ProverNetworkClient { + inner: tonic::client::Grpc, } - async fn unclaim_proof( - &self, - req: UnclaimProofRequest, - ) -> Result { - self.request("network.NetworkService/UnclaimProof", req).await + impl ProverNetworkClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } } - async fn modify_cpu_cycles( - &self, - req: ModifyCpuCyclesRequest, - ) -> Result { - self.request("network.NetworkService/ModifyCpuCycles", req).await + impl ProverNetworkClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> ProverNetworkClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + >>::Error: + Into + std::marker::Send + std::marker::Sync, + { + ProverNetworkClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + /// Creates a proof request. + pub async fn request_proof( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/RequestProof"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "RequestProof")); + self.inner.unary(req, path, codec).await + } + /// Fulfills a proof request. Only callable by the assigned fulfiller. + pub async fn fulfill_proof( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/FulfillProof"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "FulfillProof")); + self.inner.unary(req, path, codec).await + } + /// Executes a proof request. Only callable by the execution oracle. + pub async fn execute_proof( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/ExecuteProof"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "ExecuteProof")); + self.inner.unary(req, path, codec).await + } + /// Fails fulfillment. Only callable by the assigned fulfiller. + pub async fn fail_fulfillment( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/FailFulfillment"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "FailFulfillment")); + self.inner.unary(req, path, codec).await + } + /// Fails execution. Only callable by the execution oracle. + pub async fn fail_execution( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/FailExecution"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "FailExecution")); + self.inner.unary(req, path, codec).await + } + /// Get the status of a proof request. + pub async fn get_proof_request_status( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetProofRequestStatus", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestStatus")); + self.inner.unary(req, path, codec).await + } + /// Get the details of a proof request. + pub async fn get_proof_request_details( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetProofRequestDetails", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestDetails")); + self.inner.unary(req, path, codec).await + } + /// Get the proof requests that meet the filter criteria. + pub async fn get_filtered_proof_requests( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetFilteredProofRequests", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredProofRequests")); + self.inner.unary(req, path, codec).await + } + /// Search for proof requests, programs, and requesters. + pub async fn get_search_results( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetSearchResults"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetSearchResults")); + self.inner.unary(req, path, codec).await + } + /// Get metrics for proof requests. + pub async fn get_proof_request_metrics( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetProofRequestMetrics", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestMetrics")); + self.inner.unary(req, path, codec).await + } + /// Get time series data for proof requests. + pub async fn get_proof_request_graph( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetProofRequestGraph"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetProofRequestGraph")); + self.inner.unary(req, path, codec).await + } + /// Get analytics graphs for proof requests. + pub async fn get_analytics_graphs( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetAnalyticsGraphs"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetAnalyticsGraphs")); + self.inner.unary(req, path, codec).await + } + /// Get the nonce of the account. + pub async fn get_nonce( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetNonce"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetNonce")); + self.inner.unary(req, path, codec).await + } + /// Get the delegations of the account. + pub async fn get_filtered_delegations( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetFilteredDelegations", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredDelegations")); + self.inner.unary(req, path, codec).await + } + /// Add a delegation. Only callable by the owner of an account. + pub async fn add_delegation( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddDelegation"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddDelegation")); + self.inner.unary(req, path, codec).await + } + /// Remove a delegation. Only callable by the owner of an account. + pub async fn remove_delegation( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/RemoveDelegation"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "RemoveDelegation")); + self.inner.unary(req, path, codec).await + } + /// Accept a delegation. Only callable by the delegate of a delegation. + pub async fn accept_delegation( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/AcceptDelegation"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "AcceptDelegation")); + self.inner.unary(req, path, codec).await + } + /// Set the name of the account. Only callable by the owner of an account. + pub async fn set_account_name( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetAccountName"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "SetAccountName")); + self.inner.unary(req, path, codec).await + } + /// Get the name of the account. + pub async fn get_account_name( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetAccountName"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetAccountName")); + self.inner.unary(req, path, codec).await + } + /// Get whether the account has signed the terms. + pub async fn get_terms_signature( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetTermsSignature"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetTermsSignature")); + self.inner.unary(req, path, codec).await + } + /// Set whether the account has signed the terms. + pub async fn set_terms_signature( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetTermsSignature"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "SetTermsSignature")); + self.inner.unary(req, path, codec).await + } + /// Get metadata about a program. + pub async fn get_program( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetProgram"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetProgram")); + self.inner.unary(req, path, codec).await + } + /// Create a new program. Must be called before requesting proofs. + pub async fn create_program( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/CreateProgram"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "CreateProgram")); + self.inner.unary(req, path, codec).await + } + /// Set the name of the program. Only callable by the owner. + pub async fn set_program_name( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/SetProgramName"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "SetProgramName")); + self.inner.unary(req, path, codec).await + } + /// Get the available balance of an account. + pub async fn get_balance( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetBalance"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "GetBalance")); + self.inner.unary(req, path, codec).await + } + /// Get the balance logs that meet the filter criteria. + pub async fn get_filtered_balance_logs( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetFilteredBalanceLogs", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredBalanceLogs")); + self.inner.unary(req, path, codec).await + } + /// Add credit to an account. + pub async fn add_credit( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddCredit"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddCredit")); + self.inner.unary(req, path, codec).await + } + /// Get the latest processed block in the bridge. + pub async fn get_latest_bridge_block( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetLatestBridgeBlock"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetLatestBridgeBlock")); + self.inner.unary(req, path, codec).await + } + /// Get the gas price estimate for a given fulfillment strategy. + pub async fn get_gas_price_estimate( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/GetGasPriceEstimate"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetGasPriceEstimate")); + self.inner.unary(req, path, codec).await + } + /// Get the details of a transaction. + pub async fn get_transaction_details( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetTransactionDetails", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetTransactionDetails")); + self.inner.unary(req, path, codec).await + } + /// Get the reservations that meet the filter criteria. + pub async fn get_filtered_reservations( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/network.ProverNetwork/GetFilteredReservations", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "GetFilteredReservations")); + self.inner.unary(req, path, codec).await + } + /// Add a reservation for a requester. + pub async fn add_reservation( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/AddReservation"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "AddReservation")); + self.inner.unary(req, path, codec).await + } + /// Remove a reservation for a requester. + pub async fn remove_reservation( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = + http::uri::PathAndQuery::from_static("/network.ProverNetwork/RemoveReservation"); + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("network.ProverNetwork", "RemoveReservation")); + self.inner.unary(req, path, codec).await + } + /// Bid for a proof request. Provers that want to be assigned this request must first + /// bid on it. + pub async fn bid( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/Bid"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "Bid")); + self.inner.unary(req, path, codec).await + } + /// Settle the bids on a proof request to choose the assigned prover. Only callable by + /// the approved settler. + pub async fn settle( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::new( + tonic::Code::Unknown, + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static("/network.ProverNetwork/Settle"); + let mut req = request.into_request(); + req.extensions_mut().insert(GrpcMethod::new("network.ProverNetwork", "Settle")); + self.inner.unary(req, path, codec).await + } } - async fn fulfill_proof( - &self, - req: FulfillProofRequest, - ) -> Result { - self.request("network.NetworkService/FulfillProof", req).await +} +/// Generated server implementations. +pub mod prover_network_server { + #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] + use tonic::codegen::{Arc, Body, BoxFuture, CompressionEncoding, Context, EnabledCompressionEncodings, InterceptedService, Poll, StdError, async_trait, empty_body, http}; + /// Generated trait containing gRPC methods that should be implemented for use with ProverNetworkServer. + #[async_trait] + pub trait ProverNetwork: std::marker::Send + std::marker::Sync + 'static { + /// Creates a proof request. + async fn request_proof( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Fulfills a proof request. Only callable by the assigned fulfiller. + async fn fulfill_proof( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Executes a proof request. Only callable by the execution oracle. + async fn execute_proof( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Fails fulfillment. Only callable by the assigned fulfiller. + async fn fail_fulfillment( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Fails execution. Only callable by the execution oracle. + async fn fail_execution( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the status of a proof request. + async fn get_proof_request_status( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the details of a proof request. + async fn get_proof_request_details( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Get the proof requests that meet the filter criteria. + async fn get_filtered_proof_requests( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Search for proof requests, programs, and requesters. + async fn get_search_results( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get metrics for proof requests. + async fn get_proof_request_metrics( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Get time series data for proof requests. + async fn get_proof_request_graph( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get analytics graphs for proof requests. + async fn get_analytics_graphs( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the nonce of the account. + async fn get_nonce( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the delegations of the account. + async fn get_filtered_delegations( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Add a delegation. Only callable by the owner of an account. + async fn add_delegation( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Remove a delegation. Only callable by the owner of an account. + async fn remove_delegation( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Accept a delegation. Only callable by the delegate of a delegation. + async fn accept_delegation( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Set the name of the account. Only callable by the owner of an account. + async fn set_account_name( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the name of the account. + async fn get_account_name( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get whether the account has signed the terms. + async fn get_terms_signature( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Set whether the account has signed the terms. + async fn set_terms_signature( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get metadata about a program. + async fn get_program( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Create a new program. Must be called before requesting proofs. + async fn create_program( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Set the name of the program. Only callable by the owner. + async fn set_program_name( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the available balance of an account. + async fn get_balance( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the balance logs that meet the filter criteria. + async fn get_filtered_balance_logs( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Add credit to an account. + async fn add_credit( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the latest processed block in the bridge. + async fn get_latest_bridge_block( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the gas price estimate for a given fulfillment strategy. + async fn get_gas_price_estimate( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the details of a transaction. + async fn get_transaction_details( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Get the reservations that meet the filter criteria. + async fn get_filtered_reservations( + &self, + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; + /// Add a reservation for a requester. + async fn add_reservation( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Remove a reservation for a requester. + async fn remove_reservation( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Bid for a proof request. Provers that want to be assigned this request must first + /// bid on it. + async fn bid( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; + /// Settle the bids on a proof request to choose the assigned prover. Only callable by + /// the approved settler. + async fn settle( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status>; } - async fn relay_proof( - &self, - req: RelayProofRequest, - ) -> Result { - self.request("network.NetworkService/RelayProof", req).await + #[derive(Debug)] + pub struct ProverNetworkServer { + inner: Arc, + accept_compression_encodings: EnabledCompressionEncodings, + send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } - async fn get_nonce( - &self, - req: GetNonceRequest, - ) -> Result { - self.request("network.NetworkService/GetNonce", req).await + impl ProverNetworkServer { + pub fn new(inner: T) -> Self { + Self::from_arc(Arc::new(inner)) + } + pub fn from_arc(inner: Arc) -> Self { + Self { + inner, + accept_compression_encodings: Default::default(), + send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, + } + } + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + where + F: tonic::service::Interceptor, + { + InterceptedService::new(Self::new(inner), interceptor) + } + /// Enable decompressing requests with the given encoding. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.accept_compression_encodings.enable(encoding); + self + } + /// Compress responses with the given encoding, if the client supports it. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.send_compression_encodings.enable(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } - async fn get_proof_status( - &self, - req: GetProofStatusRequest, - ) -> Result { - self.request("network.NetworkService/GetProofStatus", req).await + impl tonic::codegen::Service> for ProverNetworkServer + where + T: ProverNetwork, + B: Body + std::marker::Send + 'static, + B::Error: Into + std::marker::Send + 'static, + { + type Response = http::Response; + type Error = std::convert::Infallible; + type Future = BoxFuture; + fn poll_ready( + &mut self, + _cx: &mut Context<'_>, + ) -> Poll> { + Poll::Ready(Ok(())) + } + fn call(&mut self, req: http::Request) -> Self::Future { + match req.uri().path() { + "/network.ProverNetwork/RequestProof" => { + #[allow(non_camel_case_types)] + struct RequestProofSvc(pub Arc); + impl tonic::server::UnaryService + for RequestProofSvc + { + type Response = super::RequestProofResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::request_proof(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = RequestProofSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/FulfillProof" => { + #[allow(non_camel_case_types)] + struct FulfillProofSvc(pub Arc); + impl tonic::server::UnaryService + for FulfillProofSvc + { + type Response = super::FulfillProofResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::fulfill_proof(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = FulfillProofSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/ExecuteProof" => { + #[allow(non_camel_case_types)] + struct ExecuteProofSvc(pub Arc); + impl tonic::server::UnaryService + for ExecuteProofSvc + { + type Response = super::ExecuteProofResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::execute_proof(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = ExecuteProofSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/FailFulfillment" => { + #[allow(non_camel_case_types)] + struct FailFulfillmentSvc(pub Arc); + impl + tonic::server::UnaryService + for FailFulfillmentSvc + { + type Response = super::FailFulfillmentResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::fail_fulfillment(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = FailFulfillmentSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/FailExecution" => { + #[allow(non_camel_case_types)] + struct FailExecutionSvc(pub Arc); + impl tonic::server::UnaryService + for FailExecutionSvc + { + type Response = super::FailExecutionResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::fail_execution(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = FailExecutionSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetProofRequestStatus" => { + #[allow(non_camel_case_types)] + struct GetProofRequestStatusSvc(pub Arc); + impl + tonic::server::UnaryService + for GetProofRequestStatusSvc + { + type Response = super::GetProofRequestStatusResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_proof_request_status(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetProofRequestStatusSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetProofRequestDetails" => { + #[allow(non_camel_case_types)] + struct GetProofRequestDetailsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetProofRequestDetailsSvc + { + type Response = super::GetProofRequestDetailsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_proof_request_details(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetProofRequestDetailsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetFilteredProofRequests" => { + #[allow(non_camel_case_types)] + struct GetFilteredProofRequestsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetFilteredProofRequestsSvc + { + type Response = super::GetFilteredProofRequestsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_filtered_proof_requests(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetFilteredProofRequestsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetSearchResults" => { + #[allow(non_camel_case_types)] + struct GetSearchResultsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetSearchResultsSvc + { + type Response = super::GetSearchResultsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_search_results(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetSearchResultsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetProofRequestMetrics" => { + #[allow(non_camel_case_types)] + struct GetProofRequestMetricsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetProofRequestMetricsSvc + { + type Response = super::GetProofRequestMetricsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_proof_request_metrics(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetProofRequestMetricsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetProofRequestGraph" => { + #[allow(non_camel_case_types)] + struct GetProofRequestGraphSvc(pub Arc); + impl + tonic::server::UnaryService + for GetProofRequestGraphSvc + { + type Response = super::GetProofRequestGraphResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_proof_request_graph(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetProofRequestGraphSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetAnalyticsGraphs" => { + #[allow(non_camel_case_types)] + struct GetAnalyticsGraphsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetAnalyticsGraphsSvc + { + type Response = super::GetAnalyticsGraphsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_analytics_graphs(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetAnalyticsGraphsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetNonce" => { + #[allow(non_camel_case_types)] + struct GetNonceSvc(pub Arc); + impl tonic::server::UnaryService for GetNonceSvc { + type Response = super::GetNonceResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_nonce(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetNonceSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetFilteredDelegations" => { + #[allow(non_camel_case_types)] + struct GetFilteredDelegationsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetFilteredDelegationsSvc + { + type Response = super::GetFilteredDelegationsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_filtered_delegations(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetFilteredDelegationsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/AddDelegation" => { + #[allow(non_camel_case_types)] + struct AddDelegationSvc(pub Arc); + impl tonic::server::UnaryService + for AddDelegationSvc + { + type Response = super::AddDelegationResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::add_delegation(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = AddDelegationSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/RemoveDelegation" => { + #[allow(non_camel_case_types)] + struct RemoveDelegationSvc(pub Arc); + impl + tonic::server::UnaryService + for RemoveDelegationSvc + { + type Response = super::RemoveDelegationResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::remove_delegation(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = RemoveDelegationSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/AcceptDelegation" => { + #[allow(non_camel_case_types)] + struct AcceptDelegationSvc(pub Arc); + impl + tonic::server::UnaryService + for AcceptDelegationSvc + { + type Response = super::AcceptDelegationResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::accept_delegation(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = AcceptDelegationSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/SetAccountName" => { + #[allow(non_camel_case_types)] + struct SetAccountNameSvc(pub Arc); + impl tonic::server::UnaryService + for SetAccountNameSvc + { + type Response = super::SetAccountNameResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::set_account_name(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SetAccountNameSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetAccountName" => { + #[allow(non_camel_case_types)] + struct GetAccountNameSvc(pub Arc); + impl tonic::server::UnaryService + for GetAccountNameSvc + { + type Response = super::GetAccountNameResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_account_name(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetAccountNameSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetTermsSignature" => { + #[allow(non_camel_case_types)] + struct GetTermsSignatureSvc(pub Arc); + impl + tonic::server::UnaryService + for GetTermsSignatureSvc + { + type Response = super::GetTermsSignatureResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_terms_signature(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetTermsSignatureSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/SetTermsSignature" => { + #[allow(non_camel_case_types)] + struct SetTermsSignatureSvc(pub Arc); + impl + tonic::server::UnaryService + for SetTermsSignatureSvc + { + type Response = super::SetTermsSignatureResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::set_terms_signature(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SetTermsSignatureSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetProgram" => { + #[allow(non_camel_case_types)] + struct GetProgramSvc(pub Arc); + impl tonic::server::UnaryService for GetProgramSvc { + type Response = super::GetProgramResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_program(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetProgramSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/CreateProgram" => { + #[allow(non_camel_case_types)] + struct CreateProgramSvc(pub Arc); + impl tonic::server::UnaryService + for CreateProgramSvc + { + type Response = super::CreateProgramResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::create_program(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = CreateProgramSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/SetProgramName" => { + #[allow(non_camel_case_types)] + struct SetProgramNameSvc(pub Arc); + impl tonic::server::UnaryService + for SetProgramNameSvc + { + type Response = super::SetProgramNameResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::set_program_name(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SetProgramNameSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetBalance" => { + #[allow(non_camel_case_types)] + struct GetBalanceSvc(pub Arc); + impl tonic::server::UnaryService for GetBalanceSvc { + type Response = super::GetBalanceResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_balance(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetBalanceSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetFilteredBalanceLogs" => { + #[allow(non_camel_case_types)] + struct GetFilteredBalanceLogsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetFilteredBalanceLogsSvc + { + type Response = super::GetFilteredBalanceLogsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_filtered_balance_logs(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetFilteredBalanceLogsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/AddCredit" => { + #[allow(non_camel_case_types)] + struct AddCreditSvc(pub Arc); + impl tonic::server::UnaryService for AddCreditSvc { + type Response = super::AddCreditResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::add_credit(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = AddCreditSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetLatestBridgeBlock" => { + #[allow(non_camel_case_types)] + struct GetLatestBridgeBlockSvc(pub Arc); + impl + tonic::server::UnaryService + for GetLatestBridgeBlockSvc + { + type Response = super::GetLatestBridgeBlockResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_latest_bridge_block(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetLatestBridgeBlockSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetGasPriceEstimate" => { + #[allow(non_camel_case_types)] + struct GetGasPriceEstimateSvc(pub Arc); + impl + tonic::server::UnaryService + for GetGasPriceEstimateSvc + { + type Response = super::GetGasPriceEstimateResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_gas_price_estimate(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetGasPriceEstimateSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetTransactionDetails" => { + #[allow(non_camel_case_types)] + struct GetTransactionDetailsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetTransactionDetailsSvc + { + type Response = super::GetTransactionDetailsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_transaction_details(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetTransactionDetailsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/GetFilteredReservations" => { + #[allow(non_camel_case_types)] + struct GetFilteredReservationsSvc(pub Arc); + impl + tonic::server::UnaryService + for GetFilteredReservationsSvc + { + type Response = super::GetFilteredReservationsResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_filtered_reservations(&inner, request) + .await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = GetFilteredReservationsSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/AddReservation" => { + #[allow(non_camel_case_types)] + struct AddReservationSvc(pub Arc); + impl tonic::server::UnaryService + for AddReservationSvc + { + type Response = super::AddReservationResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::add_reservation(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = AddReservationSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/RemoveReservation" => { + #[allow(non_camel_case_types)] + struct RemoveReservationSvc(pub Arc); + impl + tonic::server::UnaryService + for RemoveReservationSvc + { + type Response = super::RemoveReservationResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = async move { + ::remove_reservation(&inner, request).await + }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = RemoveReservationSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/Bid" => { + #[allow(non_camel_case_types)] + struct BidSvc(pub Arc); + impl tonic::server::UnaryService for BidSvc { + type Response = super::BidResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = + async move { ::bid(&inner, request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = BidSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + "/network.ProverNetwork/Settle" => { + #[allow(non_camel_case_types)] + struct SettleSvc(pub Arc); + impl tonic::server::UnaryService for SettleSvc { + type Response = super::SettleResponse; + type Future = BoxFuture, tonic::Status>; + fn call( + &mut self, + request: tonic::Request, + ) -> Self::Future { + let inner = Arc::clone(&self.0); + let fut = + async move { ::settle(&inner, request).await }; + Box::pin(fut) + } + } + let accept_compression_encodings = self.accept_compression_encodings; + let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; + let inner = self.inner.clone(); + let fut = async move { + let method = SettleSvc(inner); + let codec = tonic::codec::ProstCodec::default(); + let mut grpc = tonic::server::Grpc::new(codec) + .apply_compression_config( + accept_compression_encodings, + send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, + ); + let res = grpc.unary(method, req).await; + Ok(res) + }; + Box::pin(fut) + } + _ => Box::pin(async move { + Ok(http::Response::builder() + .status(200) + .header("grpc-status", tonic::Code::Unimplemented as i32) + .header(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE) + .body(empty_body()) + .unwrap()) + }), + } + } } - async fn get_proof_requests( - &self, - req: GetProofRequestsRequest, - ) -> Result { - self.request("network.NetworkService/GetProofRequests", req).await + impl Clone for ProverNetworkServer { + fn clone(&self) -> Self { + let inner = self.inner.clone(); + Self { + inner, + accept_compression_encodings: self.accept_compression_encodings, + send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, + } + } } - async fn get_relay_status( - &self, - req: GetRelayStatusRequest, - ) -> Result { - self.request("network.NetworkService/GetRelayStatus", req).await + /// Generated gRPC service name + pub const SERVICE_NAME: &str = "network.ProverNetwork"; + impl tonic::server::NamedService for ProverNetworkServer { + const NAME: &'static str = SERVICE_NAME; } } diff --git a/crates/sdk/src/network/prove.rs b/crates/sdk/src/network/prove.rs new file mode 100644 index 0000000000..2d33ea628a --- /dev/null +++ b/crates/sdk/src/network/prove.rs @@ -0,0 +1,301 @@ +//! # Network Prove +//! +//! This module provides a builder for creating a proof request to the network. + +use std::time::Duration; + +use anyhow::Result; +use sp1_core_machine::io::SP1Stdin; +use sp1_prover::SP1ProvingKey; + +use crate::{ + utils::block_on, utils::sp1_dump, NetworkProver, SP1ProofMode, SP1ProofWithPublicValues, +}; + +use super::proto::network::FulfillmentStrategy; + +/// A builder for creating a proof request to the network. +pub struct NetworkProveBuilder<'a> { + pub(crate) prover: &'a NetworkProver, + pub(crate) mode: SP1ProofMode, + pub(crate) pk: &'a SP1ProvingKey, + pub(crate) stdin: SP1Stdin, + pub(crate) timeout: Option, + pub(crate) strategy: FulfillmentStrategy, + pub(crate) skip_simulation: bool, +} + +impl<'a> NetworkProveBuilder<'a> { + /// Set the proof kind to [`SP1ProofMode::Core`] mode. + /// + /// # Details + /// This is the default mode for the prover. The proofs grow linearly in size with the number + /// of cycles. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .core() + /// .run(); + /// ``` + #[must_use] + pub fn core(mut self) -> Self { + self.mode = SP1ProofMode::Core; + self + } + + /// Set the proof kind to [`SP1ProofMode::Compressed`] mode. + /// + /// # Details + /// This mode produces a proof that is of constant size, regardless of the number of cycles. It + /// takes longer to prove than [`SP1ProofMode::Core`] due to the need to recursively aggregate + /// proofs into a single proof. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .compressed() + /// .run(); + /// ``` + #[must_use] + pub fn compressed(mut self) -> Self { + self.mode = SP1ProofMode::Compressed; + self + } + + /// Set the proof mode to [`SP1ProofMode::Plonk`] mode. + /// + /// # Details + /// This mode produces a const size PLONK proof that can be verified on chain for roughly ~300k + /// gas. This mode is useful for producing a maximally small proof that can be verified on + /// chain. For more efficient SNARK wrapping, you can use the [`SP1ProofMode::Groth16`] mode but + /// this mode is more . + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .plonk() + /// .run(); + /// ``` + #[must_use] + pub fn plonk(mut self) -> Self { + self.mode = SP1ProofMode::Plonk; + self + } + + /// Set the proof mode to [`SP1ProofMode::Groth16`] mode. + /// + /// # Details + /// This mode produces a Groth16 proof that can be verified on chain for roughly ~100k gas. This + /// mode is useful for producing a proof that can be verified on chain with minimal gas. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .groth16() + /// .run(); + /// ``` + #[must_use] + pub fn groth16(mut self) -> Self { + self.mode = SP1ProofMode::Groth16; + self + } + + /// Set the proof mode to the given [`SP1ProofMode`]. + /// + /// # Details + /// This method is useful for setting the proof mode to a custom mode. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover, SP1ProofMode}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .mode(SP1ProofMode::Groth16) + /// .run(); + /// ``` + #[must_use] + pub fn mode(mut self, mode: SP1ProofMode) -> Self { + self.mode = mode; + self + } + + /// Set the timeout for the proof's generation. + /// + /// # Details + /// This method sets the timeout for the proof's generation. If the proof is not generated + /// within the timeout, the [`NetworkProveBuilder::run`] will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// use std::time::Duration; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .timeout(Duration::from_secs(60)) + /// .run(); + /// ``` + #[must_use] + pub fn timeout(mut self, timeout: Duration) -> Self { + self.timeout = Some(timeout); + self + } + + /// Set whether to skip the local execution simulation step. + /// + /// # Details + /// This method sets whether to skip the local execution simulation step. If the simulation + /// step is skipped, the request will sent to the network without verifying that the execution + /// succeeds locally (without generating a proof). This feature is recommended for users who + /// want to optimize the latency of the proof generation on the network. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let builder = client.prove(&pk, &stdin) + /// .skip_simulation(true) + /// .run(); + /// ``` + #[must_use] + pub fn skip_simulation(mut self, skip_simulation: bool) -> Self { + self.skip_simulation = skip_simulation; + self + } + + /// Sets the fulfillment strategy for the client. + /// + /// # Details + /// The strategy determines how the client will fulfill requests. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover, network::FulfillmentStrategy}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .strategy(FulfillmentStrategy::Hosted) + /// .run() + /// .unwrap(); + /// ``` + #[must_use] + pub fn strategy(mut self, strategy: FulfillmentStrategy) -> Self { + self.strategy = strategy; + self + } + + /// Run the prover with the built arguments. + /// + /// # Details + /// This method will run the prover with the built arguments. If the prover fails to run, the + /// method will return an error. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn run(self) -> Result { + let Self { prover, mode, pk, stdin, timeout, strategy, mut skip_simulation } = self; + + // Check for deprecated environment variable + if let Ok(val) = std::env::var("SKIP_SIMULATION") { + eprintln!( + "Warning: SKIP_SIMULATION environment variable is deprecated. Please use .skip_simulation() instead." + ); + skip_simulation = matches!(val.to_lowercase().as_str(), "true" | "1"); + } + + sp1_dump(&pk.elf, &stdin); + + block_on(prover.prove_impl(pk, &stdin, mode, strategy, timeout, skip_simulation)) + } + + /// Run the prover with the built arguments asynchronously. + /// + /// # Details + /// This method will run the prover with the built arguments asynchronously. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin) + /// .run_async(); + /// ``` + pub async fn run_async(self) -> Result { + let Self { prover, mode, pk, stdin, timeout, strategy, mut skip_simulation } = self; + + // Check for deprecated environment variable + if let Ok(val) = std::env::var("SKIP_SIMULATION") { + eprintln!( + "Warning: SKIP_SIMULATION environment variable is deprecated. Please use .skip_simulation() instead." + ); + skip_simulation = matches!(val.to_lowercase().as_str(), "true" | "1"); + } + + sp1_dump(&pk.elf, &stdin); + + prover.prove_impl(pk, &stdin, mode, strategy, timeout, skip_simulation).await + } +} diff --git a/crates/sdk/src/network/prover.rs b/crates/sdk/src/network/prover.rs index 70969adf5b..4927acca35 100644 --- a/crates/sdk/src/network/prover.rs +++ b/crates/sdk/src/network/prover.rs @@ -1,211 +1,385 @@ +//! # Network Prover +//! +//! This module provides an implementation of the [`crate::Prover`] trait that can generate proofs +//! on a remote RPC server. + use std::time::{Duration, Instant}; +use super::prove::NetworkProveBuilder; +use super::DEFAULT_CYCLE_LIMIT; +use crate::cpu::execute::CpuExecuteBuilder; +use crate::cpu::CpuProver; +use crate::network::{DEFAULT_PROVER_NETWORK_RPC, DEFAULT_TIMEOUT_SECS}; use crate::{ - network::{ - client::NetworkClient, - proto::network::{ProofMode, ProofStatus}, - }, - NetworkProverBuilder, Prover, SP1Context, SP1ProofKind, SP1ProofWithPublicValues, - SP1ProvingKey, SP1VerifyingKey, + network::client::NetworkClient, + network::proto::network::{ExecutionStatus, FulfillmentStatus, FulfillmentStrategy, ProofMode}, + Prover, SP1ProofMode, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerifyingKey, }; use anyhow::Result; +use backoff::{future::retry, Error as BackoffError, ExponentialBackoff}; +use serde::de::DeserializeOwned; +use sp1_core_executor::{SP1Context, SP1ContextBuilder}; use sp1_core_machine::io::SP1Stdin; -use sp1_prover::{components::DefaultProverComponents, SP1Prover, SP1_CIRCUIT_VERSION}; -use sp1_stark::SP1ProverOpts; - -use super::proto::network::GetProofStatusResponse; - -use {crate::block_on, tokio::time::sleep}; +use sp1_prover::{components::CpuProverComponents, SP1Prover, SP1_CIRCUIT_VERSION}; +use tonic::Code; -use crate::provers::{CpuProver, ProofOpts, ProverType}; +use {crate::utils::block_on, tokio::time::sleep}; -/// Number of consecutive errors to tolerate before returning an error while polling proof status. -const MAX_CONSECUTIVE_ERRORS: usize = 10; - -/// An implementation of [crate::ProverClient] that can generate proofs on a remote RPC server. +/// An implementation of [`crate::ProverClient`] that can generate proofs on a remote RPC server. pub struct NetworkProver { - client: NetworkClient, - local_prover: CpuProver, - skip_simulation: bool, + pub(crate) client: NetworkClient, + pub(crate) prover: CpuProver, } impl NetworkProver { - /// Creates a new [NetworkProver] with the given private key. - pub fn new(private_key: &str, rpc_url: Option, skip_simulation: bool) -> Self { - let version = SP1_CIRCUIT_VERSION; - log::info!("Client circuit version: {}", version); + /// Creates a new [`NetworkProver`] with the given private key. + /// + /// # Details + /// * `private_key`: The Secp256k1 private key to use for signing requests. + /// * `rpc_url`: The rpc url to use for the prover network. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::NetworkProver; + /// + /// let prover = NetworkProver::new("...", "..."); + /// ``` + #[must_use] + pub fn new(private_key: &str, rpc_url: &str) -> Self { + let prover = CpuProver::new(); + let client = NetworkClient::new(private_key, rpc_url); + Self { client, prover } + } - let local_prover = CpuProver::new(); - Self { client: NetworkClient::new(private_key, rpc_url), local_prover, skip_simulation } + /// Creates a new [`CpuExecuteBuilder`] for simulating the execution of a program on the CPU. + /// + /// # Details + /// Note that this does not use the network in any capacity. The method is provided for + /// convenience. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().cpu().build(); + /// let (public_values, execution_report) = client.execute(elf, &stdin) + /// .run() + /// .unwrap(); + /// ``` + pub fn execute<'a>(&'a self, elf: &'a [u8], stdin: &SP1Stdin) -> CpuExecuteBuilder<'a> { + CpuExecuteBuilder { + prover: self.prover.inner(), + elf, + stdin: stdin.clone(), + context_builder: SP1ContextBuilder::default(), + } } - /// Creates a new network prover builder. See [`NetworkProverBuilder`] for more details. - pub fn builder() -> NetworkProverBuilder { - NetworkProverBuilder::default() + /// A request to generate a proof for a given proving key and input. + /// + /// # Details + /// * `pk`: The proving key to use for the proof. + /// * `stdin`: The input to use for the proof. + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let stdin = SP1Stdin::new(); + /// + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// let proof = client.prove(&pk, &stdin).run(); + /// ``` + pub fn prove<'a>( + &'a self, + pk: &'a SP1ProvingKey, + stdin: &'a SP1Stdin, + ) -> NetworkProveBuilder<'a> { + NetworkProveBuilder { + prover: self, + mode: SP1ProofMode::Core, + pk, + stdin: stdin.clone(), + timeout: None, + strategy: FulfillmentStrategy::Hosted, + skip_simulation: false, + } } - /// Requests a proof from the prover network, returning the proof ID. - pub async fn request_proof( + /// Registers a program if it is not already registered. + /// + /// # Details + /// * `vk`: The verifying key to use for the program. + /// * `elf`: The elf to use for the program. + /// + /// Note that this method requires that the user honestly registers the program (i.e., the elf + /// matches the vk). + /// + /// # Example + /// ```rust,no_run + /// use sp1_sdk::{ProverClient, SP1Stdin, Prover}; + /// + /// let elf = &[1, 2, 3]; + /// let client = ProverClient::builder().network().build(); + /// let (pk, vk) = client.setup(elf); + /// + /// let vk_hash = client.register_program(&vk, elf); + /// ``` + pub async fn register_program(&self, vk: &SP1VerifyingKey, elf: &[u8]) -> Result> { + self.client.register_program(vk, elf).await + } + + /// Requests a proof from the prover network, returning the request ID. + pub(crate) async fn request_proof( &self, - elf: &[u8], - stdin: SP1Stdin, + vk_hash: &[u8], + stdin: &SP1Stdin, mode: ProofMode, - ) -> Result { - let client = &self.client; + strategy: FulfillmentStrategy, + cycle_limit: u64, + timeout: Option, + ) -> Result> { + // Get the timeout. + let timeout_secs = timeout.map_or(DEFAULT_TIMEOUT_SECS, |dur| dur.as_secs()); - if !self.skip_simulation { - let (_, report) = - self.local_prover.sp1_prover().execute(elf, &stdin, Default::default())?; - log::info!("Simulation complete, cycles: {}", report.total_instruction_count()); - } else { - log::info!("Skipping simulation"); - } + // Log the request. + log::info!("Requesting proof:"); + log::info!("├─ Cycle limit: {}", cycle_limit); + log::info!("├─ Proof mode: {:?}", mode); + log::info!("├─ Strategy: {:?}", strategy); + log::info!("├─ Timeout: {} seconds", timeout_secs); + log::info!("└─ Circuit version: {}", SP1_CIRCUIT_VERSION); + + // Request the proof with retries. + let response = with_retry( + || async { + self.client + .request_proof( + vk_hash, + stdin, + mode, + SP1_CIRCUIT_VERSION, + strategy, + timeout_secs, + cycle_limit, + ) + .await + }, + timeout, + "requesting proof", + ) + .await?; - let proof_id = client.create_proof(elf, &stdin, mode, SP1_CIRCUIT_VERSION).await?; - log::info!("Created {}", proof_id); + // Log the request ID and transaction hash. + let tx_hash_hex = "0x".to_string() + &hex::encode(response.tx_hash); + let request_id = response.body.unwrap().request_id; + let request_id_hex = "0x".to_string() + &hex::encode(request_id.clone()); + log::info!("Created request {} in transaction {}", request_id_hex, tx_hash_hex); - if self.client.is_using_prover_network { - log::info!("View in explorer: https://explorer.succinct.xyz/{}", proof_id); + if self.client.rpc_url == DEFAULT_PROVER_NETWORK_RPC { + log::info!( + "View request status at: https://network.succinct.xyz/request/{}", + request_id_hex + ); } - Ok(proof_id) + + Ok(request_id) } /// Waits for a proof to be generated and returns the proof. If a timeout is supplied, the /// function will return an error if the proof is not generated within the timeout. - pub async fn wait_proof( + pub(crate) async fn wait_proof( &self, - proof_id: &str, + request_id: &[u8], timeout: Option, - ) -> Result { - let client = &self.client; - let mut is_claimed = false; + ) -> Result

{ + let mut is_assigned = false; let start_time = Instant::now(); - let mut consecutive_errors = 0; + loop { + // Calculate the remaining timeout. if let Some(timeout) = timeout { if start_time.elapsed() > timeout { - return Err(anyhow::anyhow!("Proof generation timed out.")); + return Err(anyhow::anyhow!("proof request timed out.")); } } + let remaining_timeout = timeout.map(|t| { + let elapsed = start_time.elapsed(); + if elapsed < t { t - elapsed } else { Duration::from_secs(0) } + }); - let result = client.get_proof_status(proof_id).await; - - if let Err(e) = result { - consecutive_errors += 1; - log::warn!( - "Failed to get proof status ({}/{}): {:?}", - consecutive_errors, - MAX_CONSECUTIVE_ERRORS, - e - ); - if consecutive_errors == MAX_CONSECUTIVE_ERRORS { - return Err(anyhow::anyhow!( - "Proof generation failed: {} consecutive errors.", - MAX_CONSECUTIVE_ERRORS - )); - } - continue; - } - consecutive_errors = 0; + // Get status with retries. + let (status, maybe_proof) = with_retry( + || async { self.client.get_proof_request_status::

(request_id).await }, + remaining_timeout, + "getting proof request status", + ) + .await?; - let (status, maybe_proof) = result.unwrap(); + // Check the execution status. + if status.execution_status == ExecutionStatus::Unexecutable as i32 { + return Err(anyhow::anyhow!("proof request is unexecutable")); + } - match status.status() { - ProofStatus::ProofFulfilled => { + // Check the fulfillment status. + match FulfillmentStatus::try_from(status.fulfillment_status) { + Ok(FulfillmentStatus::Fulfilled) => { return Ok(maybe_proof.unwrap()); } - ProofStatus::ProofClaimed => { - if !is_claimed { - log::info!("Proof request claimed, proving..."); - is_claimed = true; + Ok(FulfillmentStatus::Assigned) => { + if !is_assigned { + log::info!("proof request assigned, proving..."); + is_assigned = true; } } - ProofStatus::ProofUnclaimed => { - return Err(anyhow::anyhow!( - "Proof generation failed: {}", - status.unclaim_description() - )); + Ok(FulfillmentStatus::Unfulfillable) => { + return Err(anyhow::anyhow!("proof request is unfulfillable")); } _ => {} } + sleep(Duration::from_secs(2)).await; } } - /// Get the status and the proof if available of a given proof request. The proof is returned - /// only if the status is Fulfilled. - pub async fn get_proof_status( - &self, - proof_id: &str, - ) -> Result<(GetProofStatusResponse, Option)> { - self.client.get_proof_status(proof_id).await - } - /// Requests a proof from the prover network and waits for it to be generated. - pub async fn prove( + pub(crate) async fn prove_impl( &self, - elf: &[u8], - stdin: SP1Stdin, - mode: ProofMode, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + mode: SP1ProofMode, + strategy: FulfillmentStrategy, timeout: Option, + skip_simulation: bool, ) -> Result { - let proof_id = self.request_proof(elf, stdin, mode).await?; - self.wait_proof(&proof_id, timeout).await + let vk_hash = self.register_program(&pk.vk, &pk.elf).await?; + let cycle_limit = self.get_cycle_limit(&pk.elf, stdin, skip_simulation)?; + let request_id = self + .request_proof(&vk_hash, stdin, mode.into(), strategy, cycle_limit, timeout) + .await?; + self.wait_proof(&request_id, timeout).await } -} -impl Prover for NetworkProver { - fn id(&self) -> ProverType { - ProverType::Network + fn get_cycle_limit(&self, elf: &[u8], stdin: &SP1Stdin, skip_simulation: bool) -> Result { + if skip_simulation { + Ok(DEFAULT_CYCLE_LIMIT) + } else { + let (_, report) = self.prover.inner().execute(elf, stdin, SP1Context::default())?; + let cycles = report.total_instruction_count(); + Ok(cycles) + } } +} +impl Prover for NetworkProver { fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.local_prover.setup(elf) + self.prover.setup(elf) } - fn sp1_prover(&self) -> &SP1Prover { - self.local_prover.sp1_prover() + fn inner(&self) -> &SP1Prover { + self.prover.inner() } - fn prove<'a>( - &'a self, + fn prove( + &self, pk: &SP1ProvingKey, - stdin: SP1Stdin, - opts: ProofOpts, - context: SP1Context<'a>, - kind: SP1ProofKind, + stdin: &SP1Stdin, + mode: SP1ProofMode, ) -> Result { - warn_if_not_default(&opts.sp1_prover_opts, &context); - block_on(self.prove(&pk.elf, stdin, kind.into(), opts.timeout)) + block_on(self.prove_impl(pk, stdin, mode, FulfillmentStrategy::Hosted, None, false)) } } -/// Warns if `opts` or `context` are not default values, since they are currently unsupported. -fn warn_if_not_default(opts: &SP1ProverOpts, context: &SP1Context) { - if opts != &SP1ProverOpts::default() { - tracing::warn!("non-default opts will be ignored: {:?}", opts.core_opts); - tracing::warn!("custom SP1ProverOpts are currently unsupported by the network prover"); - } - // Exhaustive match is done to ensure we update the warnings if the types change. - let SP1Context { hook_registry, subproof_verifier, .. } = context; - if hook_registry.is_some() { - tracing::warn!("non-default context.hook_registry will be ignored: {:?}", hook_registry); - tracing::warn!("custom runtime hooks are currently unsupported by the network prover"); - tracing::warn!("proving may fail due to missing hooks"); - } - if subproof_verifier.is_some() { - tracing::warn!("non-default context.subproof_verifier will be ignored"); - tracing::warn!("custom subproof verifiers are currently unsupported by the network prover"); +impl From for ProofMode { + fn from(value: SP1ProofMode) -> Self { + match value { + SP1ProofMode::Core => Self::Core, + SP1ProofMode::Compressed => Self::Compressed, + SP1ProofMode::Plonk => Self::Plonk, + SP1ProofMode::Groth16 => Self::Groth16, + } } } -impl From for ProofMode { - fn from(value: SP1ProofKind) -> Self { - match value { - SP1ProofKind::Core => Self::Core, - SP1ProofKind::Compressed => Self::Compressed, - SP1ProofKind::Plonk => Self::Plonk, - SP1ProofKind::Groth16 => Self::Groth16, +/// Execute an async operation with exponential backoff retries. +pub async fn with_retry( + operation: F, + timeout: Option, + operation_name: &str, +) -> Result +where + F: Fn() -> Fut, + Fut: std::future::Future>, +{ + let backoff = ExponentialBackoff { + initial_interval: Duration::from_secs(1), + max_interval: Duration::from_secs(120), + max_elapsed_time: timeout, + ..Default::default() + }; + + retry(backoff, || async { + match operation().await { + Ok(result) => Ok(result), + Err(e) => { + // Check for tonic status errors. + if let Some(status) = e.downcast_ref::() { + match status.code() { + Code::Unavailable => { + log::warn!( + "Network temporarily unavailable when {} due to {}, retrying...", + operation_name, + status.message(), + ); + Err(BackoffError::transient(e)) + } + Code::NotFound => { + log::error!( + "{} not found due to {}", + operation_name, + status.message(), + ); + Err(BackoffError::permanent(e)) + } + _ => { + log::error!( + "Permanent error encountered when {}: {} ({})", + operation_name, + status.message(), + status.code() + ); + Err(BackoffError::permanent(e)) + } + } + } else { + // Check for common transport errors. + let error_msg = e.to_string().to_lowercase(); + let is_transient = error_msg.contains("tls handshake") || + error_msg.contains("dns error") || + error_msg.contains("connection reset") || + error_msg.contains("broken pipe") || + error_msg.contains("transport error") || + error_msg.contains("failed to lookup"); + + if is_transient { + log::warn!( + "Transient transport error when {}: {}, retrying...", + operation_name, + error_msg + ); + Err(BackoffError::transient(e)) + } else { + log::error!("Permanent error when {}: {}", operation_name, error_msg); + Err(BackoffError::permanent(e)) + } + } + } } - } + }) + .await } diff --git a/crates/sdk/src/network-v2/sign_message.rs b/crates/sdk/src/network/sign_message.rs similarity index 94% rename from crates/sdk/src/network-v2/sign_message.rs rename to crates/sdk/src/network/sign_message.rs index a71290e315..9d12891525 100644 --- a/crates/sdk/src/network-v2/sign_message.rs +++ b/crates/sdk/src/network/sign_message.rs @@ -2,8 +2,8 @@ use alloy_primitives::{Address, Signature}; use prost::Message; use thiserror::Error; -use crate::network_v2::json::{format_json_message, JsonFormatError}; -use crate::network_v2::proto::network::{FulfillProofRequest, MessageFormat, RequestProofRequest}; +use crate::network::proto::network::{FulfillProofRequest, MessageFormat, RequestProofRequest}; +use crate::network::utils::{format_json_message, JsonFormatError}; #[allow(dead_code)] pub trait SignedMessage { @@ -83,6 +83,7 @@ macro_rules! impl_signed_message { impl_signed_message!(RequestProofRequest); impl_signed_message!(FulfillProofRequest); +#[allow(clippy::needless_pass_by_value)] pub fn recover_sender_raw( signature: Vec, message: Vec, diff --git a/crates/sdk/src/network-v2/json.rs b/crates/sdk/src/network/utils.rs similarity index 70% rename from crates/sdk/src/network-v2/json.rs rename to crates/sdk/src/network/utils.rs index a0808d9be6..e1b7d749b5 100644 --- a/crates/sdk/src/network-v2/json.rs +++ b/crates/sdk/src/network/utils.rs @@ -1,17 +1,29 @@ +//! # Network Utils +//! +//! This module provides utility functions for the network module. + +use alloy_signer::{Signature, SignerSync}; use prost::Message; -#[allow(unused_imports)] -use serde::{Deserialize, Serialize}; +use serde::Serialize; use thiserror::Error; -/// Errors that can occur during JSON formatting. +pub(crate) trait Signable: Message { + fn sign(&self, signer: &S) -> Signature; +} + +impl Signable for T { + fn sign(&self, signer: &S) -> Signature { + signer.sign_message_sync(&self.encode_to_vec()).unwrap() + } +} + #[derive(Error, Debug)] -pub enum JsonFormatError { +pub(crate) enum JsonFormatError { #[error("Serialization error: {0}")] SerializationError(String), } -/// Formats a Protobuf body into a JSON byte representation. -pub fn format_json_message(body: &T) -> Result, JsonFormatError> +pub(crate) fn format_json_message(body: &T) -> Result, JsonFormatError> where T: Message + Serialize, { @@ -33,6 +45,7 @@ where mod tests { use super::*; use prost::Message as ProstMessage; + use serde::{Deserialize, Serialize}; // Test message for JSON formatting. #[derive(Clone, ProstMessage, Serialize, Deserialize)] diff --git a/crates/sdk/src/proof.rs b/crates/sdk/src/proof.rs index 42d5c92865..0eb556d0d5 100644 --- a/crates/sdk/src/proof.rs +++ b/crates/sdk/src/proof.rs @@ -1,33 +1,45 @@ +#![allow(missing_docs)] + use std::{fmt::Debug, fs::File, path::Path}; use anyhow::Result; use serde::{Deserialize, Serialize}; use sp1_core_executor::SP1ReduceProof; -use sp1_core_machine::io::SP1Stdin; use sp1_primitives::io::SP1PublicValues; -use strum_macros::{EnumDiscriminants, EnumTryAs}; - use sp1_prover::{CoreSC, Groth16Bn254Proof, InnerSC, PlonkBn254Proof}; -use sp1_stark::{MachineVerificationError, ShardProof}; +use sp1_stark::ShardProof; +use strum_macros::{EnumDiscriminants, EnumTryAs}; -/// A proof generated with SP1 of a particular proof mode. +/// A proof generated by the SP1 RISC-V zkVM. #[derive(Debug, Clone, Serialize, Deserialize, EnumDiscriminants, EnumTryAs)] #[strum_discriminants(derive(Default, Hash, PartialOrd, Ord))] -#[strum_discriminants(name(SP1ProofKind))] +#[strum_discriminants(name(SP1ProofMode))] pub enum SP1Proof { + /// A proof generated by the core proof mode. + /// + /// The proof size scales linearly with the number of cycles. #[strum_discriminants(default)] Core(Vec>), + /// A proof generated by the compress proof mode. + /// + /// The proof size is constant, regardless of the number of cycles. Compressed(Box>), + /// A proof generated by the Plonk proof mode. Plonk(PlonkBn254Proof), + /// A proof generated by the Groth16 proof mode. Groth16(Groth16Bn254Proof), } -/// A proof generated with SP1, bundled together with stdin, public values, and the SP1 version. +/// A proof generated by the SP1 RISC-V zkVM bundled together with the public values and the +/// version. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SP1ProofWithPublicValues { + /// The raw proof generated by the SP1 RISC-V zkVM. pub proof: SP1Proof, - pub stdin: SP1Stdin, + /// The public values generated by the SP1 RISC-V zkVM. pub public_values: SP1PublicValues, + /// The version of the SP1 RISC-V zkVM (not necessary but useful for detecting version + /// mismatches). pub sp1_version: String, } @@ -44,24 +56,19 @@ impl SP1ProofWithPublicValues { .map_err(Into::into) } - /// Returns the raw proof as a string. - pub fn raw(&self) -> String { - match &self.proof { - SP1Proof::Plonk(plonk) => plonk.raw_proof.clone(), - SP1Proof::Groth16(groth16) => groth16.raw_proof.clone(), - _ => unimplemented!(), - } - } - - /// For Plonk or Groth16 proofs, returns the proof in a byte encoding the onchain verifier - /// accepts. The bytes consist of the first four bytes of Plonk vkey hash followed by the - /// encoded proof, in a form optimized for onchain verification. + /// The proof in the byte encoding the onchain verifiers accepts for [`SP1ProofMode::Groth16`] and + /// [`SP1ProofMode::Plonk`] proofs. + /// + /// # Details + /// The bytes consist of the first four bytes of Groth16/Plonk vkey hash followed by the encoded + /// proof, in a form optimized for onchain verification. + #[must_use] pub fn bytes(&self) -> Vec { match &self.proof { SP1Proof::Plonk(plonk_proof) => { + // If the proof is empty, then this is a mock proof. The mock SP1 verifier + // expects an empty byte array for verification, so return an empty byte array. if plonk_proof.encoded_proof.is_empty() { - // If the proof is empty, then this is a mock proof. The mock SP1 verifier - // expects an empty byte array for verification, so return an empty byte array. return Vec::new(); } @@ -70,9 +77,9 @@ impl SP1ProofWithPublicValues { [plonk_proof.plonk_vkey_hash[..4].to_vec(), proof_bytes].concat() } SP1Proof::Groth16(groth16_proof) => { + // If the proof is empty, then this is a mock proof. The mock SP1 verifier + // expects an empty byte array for verification, so return an empty byte array. if groth16_proof.encoded_proof.is_empty() { - // If the proof is empty, then this is a mock proof. The mock SP1 verifier - // expects an empty byte array for verification, so return an empty byte array. return Vec::new(); } @@ -80,15 +87,15 @@ impl SP1ProofWithPublicValues { hex::decode(&groth16_proof.encoded_proof).expect("Invalid Groth16 proof"); [groth16_proof.groth16_vkey_hash[..4].to_vec(), proof_bytes].concat() } - _ => unimplemented!("only Plonk and Groth16 proofs are verifiable onchain"), + proof => panic!( + "Proof type {:?} is not supported for onchain verification. \ + Only Plonk and Groth16 proofs are verifiable onchain", + std::mem::discriminant(proof) + ), } } } -pub type SP1CoreProofVerificationError = MachineVerificationError; - -pub type SP1CompressedProofVerificationError = MachineVerificationError; - #[cfg(test)] mod tests { use super::*; @@ -99,12 +106,11 @@ mod tests { proof: SP1Proof::Plonk(PlonkBn254Proof { encoded_proof: "ab".to_string(), plonk_vkey_hash: [0; 32], - public_inputs: ["".to_string(), "".to_string()], - raw_proof: "".to_string(), + public_inputs: [String::new(), String::new()], + raw_proof: String::new(), }), - stdin: SP1Stdin::new(), public_values: SP1PublicValues::new(), - sp1_version: "".to_string(), + sp1_version: String::new(), }; let expected_bytes = [vec![0, 0, 0, 0], hex::decode("ab").unwrap()].concat(); assert_eq!(plonk_proof.bytes(), expected_bytes); @@ -116,12 +122,11 @@ mod tests { proof: SP1Proof::Groth16(Groth16Bn254Proof { encoded_proof: "ab".to_string(), groth16_vkey_hash: [0; 32], - public_inputs: ["".to_string(), "".to_string()], - raw_proof: "".to_string(), + public_inputs: [String::new(), String::new()], + raw_proof: String::new(), }), - stdin: SP1Stdin::new(), public_values: SP1PublicValues::new(), - sp1_version: "".to_string(), + sp1_version: String::new(), }; let expected_bytes = [vec![0, 0, 0, 0], hex::decode("ab").unwrap()].concat(); assert_eq!(groth16_proof.bytes(), expected_bytes); @@ -131,14 +136,13 @@ mod tests { fn test_mock_plonk_proof_bytes() { let mock_plonk_proof = SP1ProofWithPublicValues { proof: SP1Proof::Plonk(PlonkBn254Proof { - encoded_proof: "".to_string(), + encoded_proof: String::new(), plonk_vkey_hash: [0; 32], - public_inputs: ["".to_string(), "".to_string()], - raw_proof: "".to_string(), + public_inputs: [String::new(), String::new()], + raw_proof: String::new(), }), - stdin: SP1Stdin::new(), public_values: SP1PublicValues::new(), - sp1_version: "".to_string(), + sp1_version: String::new(), }; assert_eq!(mock_plonk_proof.bytes(), Vec::::new()); } @@ -147,27 +151,27 @@ mod tests { fn test_mock_groth16_proof_bytes() { let mock_groth16_proof = SP1ProofWithPublicValues { proof: SP1Proof::Groth16(Groth16Bn254Proof { - encoded_proof: "".to_string(), + encoded_proof: String::new(), groth16_vkey_hash: [0; 32], - public_inputs: ["".to_string(), "".to_string()], - raw_proof: "".to_string(), + public_inputs: [String::new(), String::new()], + raw_proof: String::new(), }), - stdin: SP1Stdin::new(), public_values: SP1PublicValues::new(), - sp1_version: "".to_string(), + sp1_version: String::new(), }; assert_eq!(mock_groth16_proof.bytes(), Vec::::new()); } #[test] - #[should_panic(expected = "only Plonk and Groth16 proofs are verifiable onchain")] + #[should_panic( + expected = "Proof type Discriminant(0) is not supported for onchain verification. Only Plonk and Groth16 proofs are verifiable onchain" + )] fn test_core_proof_bytes_unimplemented() { let core_proof = SP1ProofWithPublicValues { proof: SP1Proof::Core(vec![]), - stdin: SP1Stdin::new(), public_values: SP1PublicValues::new(), - sp1_version: "".to_string(), + sp1_version: String::new(), }; - core_proof.bytes(); + println!("{:?}", core_proof.bytes()); } } diff --git a/crates/sdk/src/prover.rs b/crates/sdk/src/prover.rs new file mode 100644 index 0000000000..83f04deb95 --- /dev/null +++ b/crates/sdk/src/prover.rs @@ -0,0 +1,164 @@ +//! # SP1 Prover Trait +//! +//! A trait that each prover variant must implement. + +use std::borrow::Borrow; + +use anyhow::Result; +use itertools::Itertools; +use p3_field::PrimeField32; +use sp1_core_executor::{ExecutionReport, SP1Context}; +use sp1_core_machine::{io::SP1Stdin, SP1_CIRCUIT_VERSION}; +use sp1_primitives::io::SP1PublicValues; +use sp1_prover::{ + components::SP1ProverComponents, CoreSC, InnerSC, SP1CoreProofData, SP1Prover, SP1ProvingKey, + SP1VerifyingKey, +}; +use sp1_stark::{air::PublicValues, MachineVerificationError, Word}; +use thiserror::Error; + +use crate::install::try_install_circuit_artifacts; +use crate::{SP1Proof, SP1ProofMode, SP1ProofWithPublicValues}; + +/// A basic set of primitives that each prover variant must implement. +pub trait Prover: Send + Sync { + /// The inner [`SP1Prover`] struct used by the prover. + fn inner(&self) -> &SP1Prover; + + /// The version of the current SP1 circuit. + fn version(&self) -> &str { + SP1_CIRCUIT_VERSION + } + + /// Generate the proving and verifying keys for the given program. + fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey); + + /// Executes the program on the given input. + fn execute(&self, elf: &[u8], stdin: &SP1Stdin) -> Result<(SP1PublicValues, ExecutionReport)> { + Ok(self.inner().execute(elf, stdin, SP1Context::default())?) + } + + /// Proves the given program on the given input in the given proof mode. + fn prove( + &self, + pk: &SP1ProvingKey, + stdin: &SP1Stdin, + mode: SP1ProofMode, + ) -> Result; + + /// Verify that an SP1 proof is valid given its vkey and metadata. + /// For Plonk proofs, verifies that the public inputs of the `PlonkBn254` proof match + /// the hash of the VK and the committed public values of the `SP1ProofWithPublicValues`. + fn verify( + &self, + bundle: &SP1ProofWithPublicValues, + vkey: &SP1VerifyingKey, + ) -> Result<(), SP1VerificationError> { + verify_proof(self.inner(), self.version(), bundle, vkey) + } +} + +/// An error that occurs when calling [`Prover::verify`]. +#[derive(Error, Debug)] +pub enum SP1VerificationError { + /// An error that occurs when the public values are invalid. + #[error("Invalid public values")] + InvalidPublicValues, + /// An error that occurs when the SP1 version does not match the version of the circuit. + #[error("Version mismatch")] + VersionMismatch(String), + /// An error that occurs when the core machine verification fails. + #[error("Core machine verification error: {0}")] + Core(MachineVerificationError), + /// An error that occurs when the recursion verification fails. + #[error("Recursion verification error: {0}")] + Recursion(MachineVerificationError), + /// An error that occurs when the Plonk verification fails. + #[error("Plonk verification error: {0}")] + Plonk(anyhow::Error), + /// An error that occurs when the Groth16 verification fails. + #[error("Groth16 verification error: {0}")] + Groth16(anyhow::Error), +} + +pub(crate) fn verify_proof( + prover: &SP1Prover, + version: &str, + bundle: &SP1ProofWithPublicValues, + vkey: &SP1VerifyingKey, +) -> Result<(), SP1VerificationError> { + // Check that the SP1 version matches the version of the currentcircuit. + if bundle.sp1_version != version { + return Err(SP1VerificationError::VersionMismatch(bundle.sp1_version.clone())); + } + + match &bundle.proof { + SP1Proof::Core(proof) => { + let public_values: &PublicValues, _> = + proof.last().unwrap().public_values.as_slice().borrow(); + + // Get the committed value digest bytes. + let committed_value_digest_bytes = public_values + .committed_value_digest + .iter() + .flat_map(|w| w.0.iter().map(|x| x.as_canonical_u32() as u8)) + .collect_vec(); + + // Make sure the committed value digest matches the public values hash. + for (a, b) in committed_value_digest_bytes.iter().zip_eq(bundle.public_values.hash()) { + if *a != b { + return Err(SP1VerificationError::InvalidPublicValues); + } + } + + // Verify the core proof. + prover + .verify(&SP1CoreProofData(proof.clone()), vkey) + .map_err(SP1VerificationError::Core) + } + SP1Proof::Compressed(proof) => { + let public_values: &PublicValues, _> = + proof.proof.public_values.as_slice().borrow(); + + // Get the committed value digest bytes. + let committed_value_digest_bytes = public_values + .committed_value_digest + .iter() + .flat_map(|w| w.0.iter().map(|x| x.as_canonical_u32() as u8)) + .collect_vec(); + + // Make sure the committed value digest matches the public values hash. + for (a, b) in committed_value_digest_bytes.iter().zip_eq(bundle.public_values.hash()) { + if *a != b { + return Err(SP1VerificationError::InvalidPublicValues); + } + } + + prover.verify_compressed(proof, vkey).map_err(SP1VerificationError::Recursion) + } + SP1Proof::Plonk(proof) => prover + .verify_plonk_bn254( + proof, + vkey, + &bundle.public_values, + &if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::plonk_bn254_artifacts_dev_dir() + } else { + try_install_circuit_artifacts("plonk") + }, + ) + .map_err(SP1VerificationError::Plonk), + SP1Proof::Groth16(proof) => prover + .verify_groth16_bn254( + proof, + vkey, + &bundle.public_values, + &if sp1_prover::build::sp1_dev_mode() { + sp1_prover::build::groth16_bn254_artifacts_dev_dir() + } else { + try_install_circuit_artifacts("groth16") + }, + ) + .map_err(SP1VerificationError::Groth16), + } +} diff --git a/crates/sdk/src/provers/cpu.rs b/crates/sdk/src/provers/cpu.rs deleted file mode 100644 index 234e663909..0000000000 --- a/crates/sdk/src/provers/cpu.rs +++ /dev/null @@ -1,131 +0,0 @@ -use anyhow::Result; -use sp1_core_executor::SP1Context; -use sp1_core_machine::io::SP1Stdin; -use sp1_prover::{components::DefaultProverComponents, SP1Prover}; - -use crate::install::try_install_circuit_artifacts; -use crate::{ - provers::ProofOpts, Prover, SP1Proof, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, - SP1VerifyingKey, -}; - -use super::ProverType; - -/// An implementation of [crate::ProverClient] that can generate end-to-end proofs locally. -pub struct CpuProver { - prover: SP1Prover, -} - -impl CpuProver { - /// Creates a new [LocalProver]. - pub fn new() -> Self { - let prover = SP1Prover::new(); - Self { prover } - } - - /// Creates a new [LocalProver] from an existing [SP1Prover]. - pub fn from_prover(prover: SP1Prover) -> Self { - Self { prover } - } -} - -impl Prover for CpuProver { - fn id(&self) -> ProverType { - ProverType::Cpu - } - - fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.prover.setup(elf) - } - - fn sp1_prover(&self) -> &SP1Prover { - &self.prover - } - - fn prove<'a>( - &'a self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - opts: ProofOpts, - context: SP1Context<'a>, - kind: SP1ProofKind, - ) -> Result { - // Generate the core proof. - let proof: sp1_prover::SP1ProofWithMetadata = - self.prover.prove_core(pk, &stdin, opts.sp1_prover_opts, context)?; - if kind == SP1ProofKind::Core { - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Core(proof.proof.0), - stdin: proof.stdin, - public_values: proof.public_values, - sp1_version: self.version().to_string(), - }); - } - - let deferred_proofs = - stdin.proofs.iter().map(|(reduce_proof, _)| reduce_proof.clone()).collect(); - let public_values = proof.public_values.clone(); - - // Generate the compressed proof. - let reduce_proof = - self.prover.compress(&pk.vk, proof, deferred_proofs, opts.sp1_prover_opts)?; - if kind == SP1ProofKind::Compressed { - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Compressed(Box::new(reduce_proof)), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } - - // Generate the shrink proof. - let compress_proof = self.prover.shrink(reduce_proof, opts.sp1_prover_opts)?; - - // Genenerate the wrap proof. - let outer_proof = self.prover.wrap_bn254(compress_proof, opts.sp1_prover_opts)?; - - if kind == SP1ProofKind::Plonk { - let plonk_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::try_build_plonk_bn254_artifacts_dev( - &outer_proof.vk, - &outer_proof.proof, - ) - } else { - try_install_circuit_artifacts("plonk") - }; - let proof = self.prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_artifacts); - - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Plonk(proof), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } else if kind == SP1ProofKind::Groth16 { - let groth16_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::try_build_groth16_bn254_artifacts_dev( - &outer_proof.vk, - &outer_proof.proof, - ) - } else { - try_install_circuit_artifacts("groth16") - }; - - let proof = self.prover.wrap_groth16_bn254(outer_proof, &groth16_bn254_artifacts); - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Groth16(proof), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } - - unreachable!() - } -} - -impl Default for CpuProver { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/sdk/src/provers/cuda.rs b/crates/sdk/src/provers/cuda.rs deleted file mode 100644 index 5f8ab983aa..0000000000 --- a/crates/sdk/src/provers/cuda.rs +++ /dev/null @@ -1,125 +0,0 @@ -use anyhow::Result; -use sp1_core_machine::io::SP1Stdin; -use sp1_cuda::SP1CudaProver; -use sp1_prover::{components::DefaultProverComponents, SP1Prover}; - -use super::ProverType; -use crate::install::try_install_circuit_artifacts; -use crate::{ - provers::ProofOpts, Prover, SP1Context, SP1Proof, SP1ProofKind, SP1ProofWithPublicValues, - SP1ProvingKey, SP1VerifyingKey, -}; - -/// An implementation of [crate::ProverClient] that can generate proofs locally using CUDA. -pub struct CudaProver { - prover: SP1Prover, - cuda_prover: SP1CudaProver, -} - -impl CudaProver { - /// Creates a new [CudaProver]. - pub fn new(prover: SP1Prover) -> Self { - let cuda_prover = SP1CudaProver::new(); - Self { prover, cuda_prover: cuda_prover.expect("Failed to initialize CUDA prover") } - } -} - -impl Prover for CudaProver { - fn id(&self) -> ProverType { - ProverType::Cuda - } - - fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.prover.setup(elf) - } - - fn sp1_prover(&self) -> &SP1Prover { - &self.prover - } - - fn prove<'a>( - &'a self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - _opts: ProofOpts, - _context: SP1Context<'a>, - kind: SP1ProofKind, - ) -> Result { - tracing::warn!("opts and context are ignored for the cuda prover"); - - // Generate the core proof. - let proof = self.cuda_prover.prove_core(pk, &stdin)?; - if kind == SP1ProofKind::Core { - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Core(proof.proof.0), - stdin: proof.stdin, - public_values: proof.public_values, - sp1_version: self.version().to_string(), - }); - } - - let deferred_proofs = - stdin.proofs.iter().map(|(reduce_proof, _)| reduce_proof.clone()).collect(); - let public_values = proof.public_values.clone(); - - // Generate the compressed proof. - let reduce_proof = self.cuda_prover.compress(&pk.vk, proof, deferred_proofs)?; - if kind == SP1ProofKind::Compressed { - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Compressed(Box::new(reduce_proof)), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } - - // Generate the shrink proof. - let compress_proof = self.cuda_prover.shrink(reduce_proof)?; - - // Genenerate the wrap proof. - let outer_proof = self.cuda_prover.wrap_bn254(compress_proof)?; - - if kind == SP1ProofKind::Plonk { - let plonk_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::try_build_plonk_bn254_artifacts_dev( - &outer_proof.vk, - &outer_proof.proof, - ) - } else { - try_install_circuit_artifacts("plonk") - }; - let proof = self.prover.wrap_plonk_bn254(outer_proof, &plonk_bn254_artifacts); - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Plonk(proof), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } else if kind == SP1ProofKind::Groth16 { - let groth16_bn254_artifacts = if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::try_build_groth16_bn254_artifacts_dev( - &outer_proof.vk, - &outer_proof.proof, - ) - } else { - try_install_circuit_artifacts("groth16") - }; - - let proof = self.prover.wrap_groth16_bn254(outer_proof, &groth16_bn254_artifacts); - return Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Groth16(proof), - stdin, - public_values, - sp1_version: self.version().to_string(), - }); - } - - unreachable!() - } -} - -impl Default for CudaProver { - fn default() -> Self { - Self::new(SP1Prover::new()) - } -} diff --git a/crates/sdk/src/provers/mock.rs b/crates/sdk/src/provers/mock.rs deleted file mode 100644 index ca317972ac..0000000000 --- a/crates/sdk/src/provers/mock.rs +++ /dev/null @@ -1,170 +0,0 @@ -#![allow(unused_variables)] -use hashbrown::HashMap; -use sp1_core_executor::{SP1Context, SP1ReduceProof}; -use sp1_core_machine::io::SP1Stdin; -use sp1_stark::{ShardCommitment, ShardOpenedValues, ShardProof, StarkVerifyingKey}; - -use crate::{ - Prover, SP1Proof, SP1ProofKind, SP1ProofWithPublicValues, SP1ProvingKey, SP1VerificationError, - SP1VerifyingKey, -}; -use anyhow::Result; -use p3_baby_bear::BabyBear; -use p3_field::{AbstractField, PrimeField}; -use p3_fri::{FriProof, TwoAdicFriPcsProof}; -use sp1_prover::{ - components::DefaultProverComponents, - verify::{verify_groth16_bn254_public_inputs, verify_plonk_bn254_public_inputs}, - Groth16Bn254Proof, HashableKey, PlonkBn254Proof, SP1Prover, -}; - -use super::{ProofOpts, ProverType}; - -/// An implementation of [crate::ProverClient] that can generate mock proofs. -pub struct MockProver { - pub(crate) prover: SP1Prover, -} - -impl MockProver { - /// Creates a new [MockProver]. - pub fn new() -> Self { - let prover = SP1Prover::new(); - Self { prover } - } -} - -impl Prover for MockProver { - fn id(&self) -> ProverType { - ProverType::Mock - } - - fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey) { - self.prover.setup(elf) - } - - fn sp1_prover(&self) -> &SP1Prover { - &self.prover - } - - fn prove<'a>( - &'a self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - opts: ProofOpts, - context: SP1Context<'a>, - kind: SP1ProofKind, - ) -> Result { - match kind { - SP1ProofKind::Core => { - let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; - Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Core(vec![]), - stdin, - public_values, - sp1_version: self.version().to_string(), - }) - } - SP1ProofKind::Compressed => { - let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; - - let shard_proof = ShardProof { - commitment: ShardCommitment { - global_main_commit: [BabyBear::zero(); 8].into(), - local_main_commit: [BabyBear::zero(); 8].into(), - permutation_commit: [BabyBear::zero(); 8].into(), - quotient_commit: [BabyBear::zero(); 8].into(), - }, - opened_values: ShardOpenedValues { chips: vec![] }, - opening_proof: TwoAdicFriPcsProof { - fri_proof: FriProof { - commit_phase_commits: vec![], - query_proofs: vec![], - final_poly: Default::default(), - pow_witness: BabyBear::zero(), - }, - query_openings: vec![], - }, - chip_ordering: HashMap::new(), - public_values: vec![], - }; - - let reduce_vk = StarkVerifyingKey { - commit: [BabyBear::zero(); 8].into(), - pc_start: BabyBear::zero(), - chip_information: vec![], - chip_ordering: HashMap::new(), - }; - - let proof = SP1Proof::Compressed(Box::new(SP1ReduceProof { - vk: reduce_vk, - proof: shard_proof, - })); - - Ok(SP1ProofWithPublicValues { - proof, - stdin, - public_values, - sp1_version: self.version().to_string(), - }) - } - SP1ProofKind::Plonk => { - let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; - Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Plonk(PlonkBn254Proof { - public_inputs: [ - pk.vk.hash_bn254().as_canonical_biguint().to_string(), - public_values.hash_bn254().to_string(), - ], - encoded_proof: "".to_string(), - raw_proof: "".to_string(), - plonk_vkey_hash: [0; 32], - }), - stdin, - public_values, - sp1_version: self.version().to_string(), - }) - } - SP1ProofKind::Groth16 => { - let (public_values, _) = self.prover.execute(&pk.elf, &stdin, context)?; - Ok(SP1ProofWithPublicValues { - proof: SP1Proof::Groth16(Groth16Bn254Proof { - public_inputs: [ - pk.vk.hash_bn254().as_canonical_biguint().to_string(), - public_values.hash_bn254().to_string(), - ], - encoded_proof: "".to_string(), - raw_proof: "".to_string(), - groth16_vkey_hash: [0; 32], - }), - stdin, - public_values, - sp1_version: self.version().to_string(), - }) - } - } - } - - fn verify( - &self, - bundle: &SP1ProofWithPublicValues, - vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - match &bundle.proof { - SP1Proof::Plonk(PlonkBn254Proof { public_inputs, .. }) => { - verify_plonk_bn254_public_inputs(vkey, &bundle.public_values, public_inputs) - .map_err(SP1VerificationError::Plonk) - } - SP1Proof::Groth16(Groth16Bn254Proof { public_inputs, .. }) => { - verify_groth16_bn254_public_inputs(vkey, &bundle.public_values, public_inputs) - .map_err(SP1VerificationError::Groth16) - } - _ => Ok(()), - } - } -} - -impl Default for MockProver { - fn default() -> Self { - Self::new() - } -} diff --git a/crates/sdk/src/provers/mod.rs b/crates/sdk/src/provers/mod.rs deleted file mode 100644 index 1db5309fac..0000000000 --- a/crates/sdk/src/provers/mod.rs +++ /dev/null @@ -1,175 +0,0 @@ -mod cpu; -#[cfg(feature = "cuda")] -mod cuda; -mod mock; - -pub use cpu::CpuProver; -#[cfg(feature = "cuda")] -pub use cuda::CudaProver; -pub use mock::MockProver; - -use itertools::Itertools; -use p3_field::PrimeField32; -use std::borrow::Borrow; -use std::time::Duration; - -use anyhow::Result; -use sp1_core_executor::SP1Context; -use sp1_core_machine::{io::SP1Stdin, SP1_CIRCUIT_VERSION}; -use sp1_prover::{ - components::SP1ProverComponents, CoreSC, InnerSC, SP1CoreProofData, SP1Prover, SP1ProvingKey, - SP1VerifyingKey, -}; -use sp1_stark::{air::PublicValues, MachineVerificationError, SP1ProverOpts, Word}; -use strum_macros::EnumString; -use thiserror::Error; - -use crate::install::try_install_circuit_artifacts; -use crate::{SP1Proof, SP1ProofKind, SP1ProofWithPublicValues}; - -/// The type of prover. -#[derive(Debug, PartialEq, EnumString)] -pub enum ProverType { - Cpu, - Cuda, - Mock, - Network, -} - -/// Options to configure proof generation. -#[derive(Clone, Default)] -pub struct ProofOpts { - /// Options to configure the SP1 prover. - pub sp1_prover_opts: SP1ProverOpts, - /// Optional timeout duration for proof generation. - pub timeout: Option, -} - -#[derive(Error, Debug)] -pub enum SP1VerificationError { - #[error("Invalid public values")] - InvalidPublicValues, - #[error("Version mismatch")] - VersionMismatch(String), - #[error("Core machine verification error: {0}")] - Core(MachineVerificationError), - #[error("Recursion verification error: {0}")] - Recursion(MachineVerificationError), - #[error("Plonk verification error: {0}")] - Plonk(anyhow::Error), - #[error("Groth16 verification error: {0}")] - Groth16(anyhow::Error), -} - -/// An implementation of [crate::ProverClient]. -pub trait Prover: Send + Sync { - fn id(&self) -> ProverType; - - fn sp1_prover(&self) -> &SP1Prover; - - fn version(&self) -> &str { - SP1_CIRCUIT_VERSION - } - - fn setup(&self, elf: &[u8]) -> (SP1ProvingKey, SP1VerifyingKey); - - /// Prove the execution of a RISCV ELF with the given inputs, according to the given proof mode. - fn prove<'a>( - &'a self, - pk: &SP1ProvingKey, - stdin: SP1Stdin, - opts: ProofOpts, - context: SP1Context<'a>, - kind: SP1ProofKind, - ) -> Result; - - /// Verify that an SP1 proof is valid given its vkey and metadata. - /// For Plonk proofs, verifies that the public inputs of the PlonkBn254 proof match - /// the hash of the VK and the committed public values of the SP1ProofWithPublicValues. - fn verify( - &self, - bundle: &SP1ProofWithPublicValues, - vkey: &SP1VerifyingKey, - ) -> Result<(), SP1VerificationError> { - if bundle.sp1_version != self.version() { - return Err(SP1VerificationError::VersionMismatch(bundle.sp1_version.clone())); - } - match &bundle.proof { - SP1Proof::Core(proof) => { - let public_values: &PublicValues, _> = - proof.last().unwrap().public_values.as_slice().borrow(); - - // Get the committed value digest bytes. - let committed_value_digest_bytes = public_values - .committed_value_digest - .iter() - .flat_map(|w| w.0.iter().map(|x| x.as_canonical_u32() as u8)) - .collect_vec(); - - // Make sure the committed value digest matches the public values hash. - for (a, b) in - committed_value_digest_bytes.iter().zip_eq(bundle.public_values.hash()) - { - if *a != b { - return Err(SP1VerificationError::InvalidPublicValues); - } - } - - // Verify the core proof. - self.sp1_prover() - .verify(&SP1CoreProofData(proof.clone()), vkey) - .map_err(SP1VerificationError::Core) - } - SP1Proof::Compressed(proof) => { - let public_values: &PublicValues, _> = - proof.proof.public_values.as_slice().borrow(); - - // Get the committed value digest bytes. - let committed_value_digest_bytes = public_values - .committed_value_digest - .iter() - .flat_map(|w| w.0.iter().map(|x| x.as_canonical_u32() as u8)) - .collect_vec(); - - // Make sure the committed value digest matches the public values hash. - for (a, b) in - committed_value_digest_bytes.iter().zip_eq(bundle.public_values.hash()) - { - if *a != b { - return Err(SP1VerificationError::InvalidPublicValues); - } - } - - self.sp1_prover() - .verify_compressed(proof, vkey) - .map_err(SP1VerificationError::Recursion) - } - SP1Proof::Plonk(proof) => self - .sp1_prover() - .verify_plonk_bn254( - proof, - vkey, - &bundle.public_values, - &if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::plonk_bn254_artifacts_dev_dir() - } else { - try_install_circuit_artifacts("plonk") - }, - ) - .map_err(SP1VerificationError::Plonk), - SP1Proof::Groth16(proof) => self - .sp1_prover() - .verify_groth16_bn254( - proof, - vkey, - &bundle.public_values, - &if sp1_prover::build::sp1_dev_mode() { - sp1_prover::build::groth16_bn254_artifacts_dev_dir() - } else { - try_install_circuit_artifacts("groth16") - }, - ) - .map_err(SP1VerificationError::Groth16), - } - } -} diff --git a/crates/sdk/src/utils.rs b/crates/sdk/src/utils.rs new file mode 100644 index 0000000000..347c3bb02f --- /dev/null +++ b/crates/sdk/src/utils.rs @@ -0,0 +1,33 @@ +//! # SP1 SDK Utilities +//! +//! A collection of utilities for the SP1 SDK. + +use sp1_core_machine::io::SP1Stdin; +pub use sp1_core_machine::utils::setup_logger; + +/// Dump the program and stdin to files for debugging if `SP1_DUMP` is set. +pub(crate) fn sp1_dump(elf: &[u8], stdin: &SP1Stdin) { + if std::env::var("SP1_DUMP").map(|v| v == "1" || v.to_lowercase() == "true").unwrap_or(false) { + std::fs::write("program.bin", elf).unwrap(); + let stdin = bincode::serialize(&stdin).unwrap(); + std::fs::write("stdin.bin", stdin.clone()).unwrap(); + } +} + +/// Utility method for blocking on an async function. +/// +/// If we're already in a tokio runtime, we'll block in place. Otherwise, we'll create a new +/// runtime. +#[cfg(feature = "network")] +pub(crate) fn block_on(fut: impl std::future::Future) -> T { + use tokio::task::block_in_place; + + // Handle case if we're already in an tokio runtime. + if let Ok(handle) = tokio::runtime::Handle::try_current() { + block_in_place(|| handle.block_on(fut)) + } else { + // Otherwise create a new runtime. + let rt = tokio::runtime::Runtime::new().expect("Failed to create a new runtime"); + rt.block_on(fut) + } +} diff --git a/crates/test-artifacts/programs/Cargo.lock b/crates/test-artifacts/programs/Cargo.lock index b404318c5a..94423f6aef 100644 --- a/crates/test-artifacts/programs/Cargo.lock +++ b/crates/test-artifacts/programs/Cargo.lock @@ -107,7 +107,7 @@ version = "1.1.0" dependencies = [ "common-test-utils", "sp1-curves", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -150,7 +150,7 @@ name = "bls12381-mul-test" version = "1.1.0" dependencies = [ "sp1-derive", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -160,7 +160,7 @@ version = "1.1.0" dependencies = [ "common-test-utils", "sp1-curves", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -203,7 +203,7 @@ name = "bn254-mul-test" version = "1.1.0" dependencies = [ "sp1-derive", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -245,7 +245,7 @@ name = "common-test-utils" version = "1.1.0" dependencies = [ "num-bigint", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", ] [[package]] @@ -341,21 +341,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "curve25519-dalek" -version = "4.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fiat-crypto", - "rustc_version", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" version = "4.1.3" @@ -364,7 +349,7 @@ dependencies = [ "anyhow", "cfg-if", "cpufeatures", - "curve25519-dalek-derive 0.1.1 (git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-curve25519-v4.1.3)", + "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", "rustc_version", @@ -373,17 +358,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "curve25519-dalek-derive" version = "0.1.1" @@ -613,7 +587,7 @@ name = "ed25519-dalek" version = "2.1.1" source = "git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-curve25519-v4.1.3#1d73fd95f1a76bee8f46643cf78bbccc1fb06ede" dependencies = [ - "curve25519-dalek 4.1.3 (git+https://github.com/sp1-patches/curve25519-dalek?branch=patch-curve25519-v4.1.3)", + "curve25519-dalek", "ed25519", "serde", "sha2 0.10.8", @@ -1634,7 +1608,7 @@ version = "1.1.0" dependencies = [ "common-test-utils", "sp1-curves", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -1670,7 +1644,7 @@ dependencies = [ "num", "p256", "sp1-curves", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -1691,7 +1665,7 @@ dependencies = [ "num", "p256", "sp1-curves", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-zkvm", ] @@ -1832,10 +1806,9 @@ dependencies = [ [[package]] name = "sp1-curves" -version = "3.0.0" +version = "3.4.0" dependencies = [ "cfg-if", - "curve25519-dalek 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "dashu", "elliptic-curve 0.13.8", "generic-array 1.1.0", @@ -1853,7 +1826,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "3.0.0" +version = "3.4.0" dependencies = [ "quote", "syn 1.0.109", @@ -1875,7 +1848,9 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "3.0.0" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1aa18834c58df127706eb2fb2ea6e2892dbf0361d6b2485bf7b3fbd5f8b8c3c" dependencies = [ "bincode", "serde", @@ -1883,9 +1858,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1aa18834c58df127706eb2fb2ea6e2892dbf0361d6b2485bf7b3fbd5f8b8c3c" +version = "3.4.0" dependencies = [ "bincode", "serde", @@ -1893,7 +1866,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "hex", @@ -1909,7 +1882,7 @@ dependencies = [ [[package]] name = "sp1-stark" -version = "3.0.0" +version = "3.4.0" dependencies = [ "arrayref", "hashbrown 0.14.5", @@ -1941,7 +1914,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "3.0.1" +version = "3.4.0" dependencies = [ "cfg-if", "getrandom", @@ -1951,7 +1924,7 @@ dependencies = [ "p3-field", "rand", "sha2 0.10.8", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-primitives", ] diff --git a/crates/verifier/Cargo.toml b/crates/verifier/Cargo.toml index c2b861b16d..d3f76c92b3 100644 --- a/crates/verifier/Cargo.toml +++ b/crates/verifier/Cargo.toml @@ -12,17 +12,10 @@ categories = { workspace = true } [dependencies] bn = { version = "0.6.0", package = "substrate-bn-succinct" } sha2 = { version = "0.10.8", default-features = false } -thiserror = { version = "2", default-features = false } +thiserror-no-std = "2.0.2" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } lazy_static = { version = "1.5.0", default-features = false } -# arkworks -ark-bn254 = { version = "0.4.0", optional = true } -ark-serialize = { version = "0.4.2", optional = true } -ark-ff = { version = "0.4.2", optional = true } -ark-groth16 = { version = "0.4.0", optional = true } -ark-ec = { version = "0.4.0", optional = true } - [dev-dependencies] sp1-sdk = { workspace = true } num-bigint = "0.4.6" @@ -30,5 +23,4 @@ num-traits = "0.2.19" [features] default = ["std"] -std = ["thiserror/std"] -ark = ["ark-bn254", "ark-serialize", "ark-ff", "ark-groth16", "ark-ec"] +std = ["thiserror-no-std/std"] \ No newline at end of file diff --git a/crates/verifier/src/error.rs b/crates/verifier/src/error.rs index 1f30633fde..2d37bceac9 100644 --- a/crates/verifier/src/error.rs +++ b/crates/verifier/src/error.rs @@ -1,5 +1,5 @@ use bn::{CurveError, FieldError, GroupError}; -use thiserror::Error; +use thiserror_no_std::Error; #[derive(Error, Debug)] pub enum Error { diff --git a/crates/verifier/src/groth16/converter.rs b/crates/verifier/src/groth16/converter.rs index 6648eb95c9..6c7a5e3b97 100644 --- a/crates/verifier/src/groth16/converter.rs +++ b/crates/verifier/src/groth16/converter.rs @@ -13,7 +13,7 @@ use super::error::Groth16Error; /// Load the Groth16 proof from the given byte slice. /// /// The byte slice is represented as 2 uncompressed g1 points, and one uncompressed g2 point, -/// as outputted from Gnark. +/// as outputted from gnark. pub(crate) fn load_groth16_proof_from_bytes(buffer: &[u8]) -> Result { let ar = uncompressed_bytes_to_g1_point(&buffer[..64])?; let bs = uncompressed_bytes_to_g2_point(&buffer[64..192])?; diff --git a/crates/verifier/src/groth16/error.rs b/crates/verifier/src/groth16/error.rs index 18d8e2dcbe..36952cb749 100644 --- a/crates/verifier/src/groth16/error.rs +++ b/crates/verifier/src/groth16/error.rs @@ -1,4 +1,4 @@ -use thiserror::Error; +use thiserror_no_std::Error; #[derive(Debug, Error)] pub enum Groth16Error { diff --git a/crates/verifier/src/groth16/mod.rs b/crates/verifier/src/groth16/mod.rs index 9075d6491b..c6cf98a23a 100644 --- a/crates/verifier/src/groth16/mod.rs +++ b/crates/verifier/src/groth16/mod.rs @@ -2,25 +2,19 @@ mod converter; pub mod error; mod verify; -use bn::Fr; pub(crate) use converter::{load_groth16_proof_from_bytes, load_groth16_verifying_key_from_bytes}; +use sha2::{Digest, Sha256}; pub(crate) use verify::*; use error::Groth16Error; -use crate::{decode_sp1_vkey_hash, error::Error, hash_public_inputs}; - -use alloc::vec::Vec; -use sha2::{Digest, Sha256}; - -#[cfg(feature = "ark")] -pub mod ark_converter; +use crate::{bn254_public_values, decode_sp1_vkey_hash, error::Error}; /// A verifier for Groth16 zero-knowledge proofs. #[derive(Debug)] pub struct Groth16Verifier; impl Groth16Verifier { - /// Verifies an SP1 Groth16 proof, as generated by the SP1 SDK. + /// Verifies a Groth16 proof. /// /// # Arguments /// @@ -63,48 +57,11 @@ impl Groth16Verifier { } let sp1_vkey_hash = decode_sp1_vkey_hash(sp1_vkey_hash)?; + let public_inputs = bn254_public_values(&sp1_vkey_hash, sp1_public_inputs); - Self::verify_gnark_proof( - &proof[4..], - &[sp1_vkey_hash, hash_public_inputs(sp1_public_inputs)], - groth16_vk, - ) - } - - /// Verifies a Gnark Groth16 proof using raw byte inputs. - /// - /// WARNING: if you're verifying an SP1 proof, you should use [`verify`] instead. - /// This is a lower-level verification method that works directly with raw bytes rather than - /// the SP1 SDK's data structures. - /// - /// # Arguments - /// - /// * `proof` - The raw Groth16 proof bytes (without the 4-byte vkey hash prefix) - /// * `public_inputs` - The public inputs to the circuit - /// * `groth16_vk` - The Groth16 verifying key bytes - /// - /// # Returns - /// - /// A [`Result`] containing unit `()` if the proof is valid, - /// or a [`Groth16Error`] if verification fails. - /// - /// # Note - /// - /// This method expects the raw proof bytes without the 4-byte vkey hash prefix that - /// [`verify`] checks. If you have a complete proof with the prefix, use [`verify`] instead. - pub fn verify_gnark_proof( - proof: &[u8], - public_inputs: &[[u8; 32]], - groth16_vk: &[u8], - ) -> Result<(), Groth16Error> { - let proof = load_groth16_proof_from_bytes(proof)?; + let proof = load_groth16_proof_from_bytes(&proof[4..])?; let groth16_vk = load_groth16_verifying_key_from_bytes(groth16_vk)?; - let public_inputs = public_inputs - .iter() - .map(|input| Fr::from_slice(input)) - .collect::, bn::FieldError>>() - .map_err(|_| Groth16Error::GeneralError(Error::InvalidData))?; - verify_groth16_algebraic(&groth16_vk, &proof, &public_inputs) + verify_groth16_raw(&groth16_vk, &proof, &public_inputs) } } diff --git a/crates/verifier/src/groth16/verify.rs b/crates/verifier/src/groth16/verify.rs index 636a7f66d6..686e62ff61 100644 --- a/crates/verifier/src/groth16/verify.rs +++ b/crates/verifier/src/groth16/verify.rs @@ -46,11 +46,11 @@ fn prepare_inputs(vk: Groth16VerifyingKey, public_inputs: &[Fr]) -> Result Result<(), PlonkError> { let plonk_vk = load_plonk_verifying_key_from_bytes(plonk_vk)?; - let proof = load_plonk_proof_from_bytes(proof, plonk_vk.qcp.len())?; + let proof = load_plonk_proof_from_bytes(&proof[4..], plonk_vk.qcp.len())?; - let public_inputs = public_inputs - .iter() - .map(|input| Fr::from_slice(input)) - .collect::, bn::FieldError>>() - .map_err(|_| PlonkError::GeneralError(Error::InvalidData))?; - verify_plonk_algebraic(&plonk_vk, &proof, &public_inputs) + verify_plonk_raw(&plonk_vk, &proof, &public_inputs) } } diff --git a/crates/verifier/src/plonk/verify.rs b/crates/verifier/src/plonk/verify.rs index 6da0872d6e..4cfbcc884f 100644 --- a/crates/verifier/src/plonk/verify.rs +++ b/crates/verifier/src/plonk/verify.rs @@ -33,7 +33,7 @@ pub(crate) struct PlonkVerifyingKey { pub(crate) commitment_constraint_indexes: Vec, } -/// Verifies a PLONK proof using algebraic inputs. +/// Verifies a PLONK proof /// /// # Arguments /// @@ -44,7 +44,7 @@ pub(crate) struct PlonkVerifyingKey { /// # Returns /// /// * `Result` - Returns true if the proof is valid, or an error if verification fails -pub(crate) fn verify_plonk_algebraic( +pub(crate) fn verify_plonk_raw( vk: &PlonkVerifyingKey, proof: &PlonkProof, public_inputs: &[Fr], diff --git a/crates/verifier/src/tests.rs b/crates/verifier/src/tests.rs index c6d9a853c6..3cda26694a 100644 --- a/crates/verifier/src/tests.rs +++ b/crates/verifier/src/tests.rs @@ -1,6 +1,9 @@ use sp1_sdk::{install::try_install_circuit_artifacts, SP1ProofWithPublicValues}; +extern crate std; + #[test] +#[ignore] fn test_verify_groth16() { // Location of the serialized SP1ProofWithPublicValues. See README.md for more information. let proof_file = "test_binaries/fibonacci-groth16.bin"; @@ -19,6 +22,7 @@ fn test_verify_groth16() { } #[test] +#[ignore] fn test_verify_plonk() { // Location of the serialized SP1ProofWithPublicValues. See README.md for more information. let proof_file = "test_binaries/fibonacci-plonk.bin"; @@ -37,6 +41,7 @@ fn test_verify_plonk() { } #[test] +#[ignore] fn test_vkeys() { let groth16_path = try_install_circuit_artifacts("groth16"); let s3_vkey_path = groth16_path.join("groth16_vk.bin"); @@ -48,35 +53,3 @@ fn test_vkeys() { let s3_vkey_bytes = std::fs::read(s3_vkey_path).unwrap(); assert_eq!(s3_vkey_bytes, *crate::PLONK_VK_BYTES); } - -#[test] -#[cfg(feature = "ark")] -fn test_ark_groth16() { - use ark_bn254::Bn254; - use ark_groth16::{r1cs_to_qap::LibsnarkReduction, Groth16}; - - use crate::{decode_sp1_vkey_hash, groth16::ark_converter::*, hash_public_inputs}; - - // Location of the serialized SP1ProofWithPublicValues. See README.md for more information. - let proof_file = "test_binaries/fibonacci-groth16.bin"; - - // Load the saved proof and extract the proof and public inputs. - let sp1_proof_with_public_values = SP1ProofWithPublicValues::load(proof_file).unwrap(); - - let proof = sp1_proof_with_public_values.bytes(); - let public_inputs = sp1_proof_with_public_values.public_values.to_vec(); - - // This vkey hash was derived by calling `vk.bytes32()` on the verifying key. - let vkey_hash = "0x00e60860c07bfc6e4c480286c0ddbb879674eb47f84b4ef041cf858b17aa0ed1"; - - let proof = load_ark_proof_from_bytes(&proof[4..]).unwrap(); - let vkey = load_ark_groth16_verifying_key_from_bytes(&crate::GROTH16_VK_BYTES).unwrap(); - - let public_inputs = load_ark_public_inputs_from_bytes( - &decode_sp1_vkey_hash(vkey_hash).unwrap(), - &hash_public_inputs(&public_inputs), - ); - - Groth16::::verify_proof(&vkey.into(), &proof, &public_inputs) - .unwrap(); -} diff --git a/crates/zkvm/entrypoint/Cargo.toml b/crates/zkvm/entrypoint/Cargo.toml index e38600efd9..180f657881 100644 --- a/crates/zkvm/entrypoint/Cargo.toml +++ b/crates/zkvm/entrypoint/Cargo.toml @@ -2,7 +2,7 @@ name = "sp1-zkvm" description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM." readme = "../../../README.md" -version = "3.0.1" +version = "3.4.0" edition = { workspace = true } license = { workspace = true } repository = { workspace = true } diff --git a/crates/zkvm/lib/src/io.rs b/crates/zkvm/lib/src/io.rs index 94a92a602c..cc59cee8e3 100644 --- a/crates/zkvm/lib/src/io.rs +++ b/crates/zkvm/lib/src/io.rs @@ -16,6 +16,12 @@ pub const FD_HINT: u32 = 4; pub const K1_ECRECOVER_HOOK: u32 = 5; pub const R1_ECRECOVER_HOOK: u32 = 6; +/// The file descriptor through which to access `hook_ecrecover_2`. +pub const FD_ECRECOVER_HOOK_2: u32 = 7; + +/// The file descriptor through which to access `hook_ed_decompress`. +pub const FD_EDDECOMPRESS: u32 = 8; + /// A writer that writes to a file descriptor inside the zkVM. struct SyscallWriter { fd: u32, diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 05d23d23a0..7e8cbf164b 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "alloy-chains" @@ -78,7 +78,7 @@ version = "0.1.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18c5c520273946ecf715c0010b4e3503d7eba9893cd9ce6b7fff5654c4a3c470" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "num_enum 0.7.3", "serde", @@ -92,7 +92,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "629b62e38d471cc15fea534eb7283d2f8a4e8bdb1811bcc5d66dda6cfce6fae1" dependencies = [ "alloy-eips 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.3.6", "c-kzg", @@ -106,7 +106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed961a48297c732a5d97ee321aa8bb5009ecadbcb077d8bec90cb54e651629" dependencies = [ "alloy-eips 0.5.4", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.5.4", "auto_impl", @@ -121,7 +121,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "serde", ] @@ -132,7 +132,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea59dc42102bc9a1905dc57901edc6dd48b9f38115df86c7d252acba70d71d04" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "k256", "serde", @@ -144,7 +144,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64ffc577390ce50234e02d841214b3dc0bea6aaaae8e04bbf3cb82e9a45da9eb" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "derive_more 1.0.0", "serde", @@ -158,7 +158,7 @@ checksum = "f923dd5fca5f67a43d81ed3ebad0880bd41f6dd0ada930030353ac356c54cd0f" dependencies = [ "alloy-eip2930", "alloy-eip7702 0.1.1", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.3.6", "c-kzg", @@ -176,7 +176,7 @@ checksum = "b69e06cf9c37be824b9d26d6d101114fdde6af0c87de2828b414c05c4b3daa71" dependencies = [ "alloy-eip2930", "alloy-eip7702 0.3.2", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.5.4", "c-kzg", @@ -192,18 +192,18 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a7a18afb0b318616b6b2b0e2e7ac5529d32a966c673b48091c9919e284e6aca" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-serde 0.3.6", "serde", ] [[package]] name = "alloy-json-abi" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded610181f3dad5810f6ff12d1a99994cf9b42d2fcb7709029352398a5da5ae6" +checksum = "ac4b22b3e51cac09fd2adfcc73b55f447b4df669f983c13f7894ec82b607c63f" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-sol-type-parser", "serde", "serde_json", @@ -215,11 +215,11 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af5979e0d5a7bf9c7eb79749121e8256e59021af611322aee56e77e20776b4b3" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-sol-types", "serde", "serde_json", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", ] @@ -233,7 +233,7 @@ dependencies = [ "alloy-eips 0.5.4", "alloy-json-rpc", "alloy-network-primitives 0.5.4", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rpc-types-eth 0.5.4", "alloy-serde 0.5.4", "alloy-signer", @@ -241,7 +241,7 @@ dependencies = [ "async-trait", "auto_impl", "futures-utils-wasm", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -251,7 +251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94ad40869867ed2d9cd3842b1e800889e5b49e6b92da346e93862b4a741bedf3" dependencies = [ "alloy-eips 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-serde 0.3.6", "serde", ] @@ -264,7 +264,7 @@ checksum = "514f70ee2a953db21631cd817b13a1571474ec77ddc03d47616d5e8203489fde" dependencies = [ "alloy-consensus 0.5.4", "alloy-eips 0.5.4", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-serde 0.5.4", "serde", ] @@ -293,9 +293,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd58d377699e6cfeab52c4a9d28bdc4ef37e2bd235ff2db525071fe37a2e9af5" +checksum = "9db948902dfbae96a73c2fbf1f7abec62af034ab883e4c777c3fd29702bd6e2c" dependencies = [ "alloy-rlp", "bytes", @@ -304,7 +304,7 @@ dependencies = [ "derive_more 1.0.0", "foldhash", "getrandom", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "hex-literal", "indexmap 2.6.0", "itoa", @@ -339,7 +339,7 @@ checksum = "2b09cae092c27b6f1bde952653a22708691802e57bfef4a2973b80bea21efd3f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -362,7 +362,7 @@ dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-network-primitives 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.3.6", "alloy-sol-types", @@ -383,7 +383,7 @@ dependencies = [ "alloy-consensus 0.5.4", "alloy-eips 0.5.4", "alloy-network-primitives 0.5.4", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.5.4", "alloy-sol-types", @@ -399,7 +399,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731f75ec5d383107fd745d781619bd9cedf145836c51ecb991623d41278e71fa" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "serde", "serde_json", ] @@ -410,7 +410,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "028e72eaa9703e4882344983cfe7636ce06d8cce104a78ea62fd19b46659efc4" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "serde", "serde_json", ] @@ -421,12 +421,12 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "592c185d7100258c041afac51877660c7bf6213447999787197db4842f0e938e" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "async-trait", "auto_impl", "elliptic-curve", "k256", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -437,33 +437,33 @@ checksum = "6614f02fc1d5b079b2a4a5320018317b506fd0a6d67c1fd5542a71201724986c" dependencies = [ "alloy-consensus 0.5.4", "alloy-network", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-signer", "async-trait", "k256", "rand 0.8.5", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] name = "alloy-sol-macro" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1b42ac8f45e2f49f4bcdd72cbfde0bb148f5481d403774ffa546e48b83efc1" +checksum = "3bfd7853b65a2b4f49629ec975fee274faf6dff15ab8894c620943398ef283c0" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "alloy-sol-macro-expander" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06318f1778e57f36333e850aa71bd1bb5e560c10279e236622faae0470c50412" +checksum = "82ec42f342d9a9261699f8078e57a7a4fda8aaa73c1a212ed3987080e6a9cd13" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -472,31 +472,31 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "syn-solidity", "tiny-keccak", ] [[package]] name = "alloy-sol-macro-input" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaebb9b0ad61a41345a22c9279975c0cdd231b97947b10d7aad1cf0a7181e4a5" +checksum = "ed2c50e6a62ee2b4f7ab3c6d0366e5770a21cad426e109c2f40335a1b3aff3df" dependencies = [ "const-hex", "dunce", "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "syn-solidity", ] [[package]] name = "alloy-sol-type-parser" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c71028bfbfec210e24106a542aad3def7caf1a70e2c05710e92a98481980d3" +checksum = "ac17c6e89a50fb4a758012e4b409d9a0ba575228e69b539fe37d7a1bd507ca4a" dependencies = [ "serde", "winnow 0.6.20", @@ -504,12 +504,12 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d7fb042d68ddfe79ccb23359de3007f6d4d53c13f703b64fb0db422132111" +checksum = "c9dc0fffe397aa17628160e16b89f704098bf3c9d74d5d369ebc239575936de5" dependencies = [ "alloy-json-abi", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-sol-macro", "const-hex", "serde", @@ -521,7 +521,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a46c9c4fdccda7982e7928904bd85fe235a0404ee3d7e197fff13d61eac8b4f" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "derive_more 1.0.0", "hashbrown 0.14.5", @@ -752,6 +752,28 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "async-trait" version = "0.1.83" @@ -760,9 +782,15 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -781,7 +809,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -792,9 +820,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -816,9 +844,9 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -839,12 +867,26 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "backoff" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +dependencies = [ + "futures-core", + "getrandom", + "instant", + "pin-project-lite", + "rand 0.8.5", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -911,7 +953,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1031,7 +1073,7 @@ dependencies = [ "group 0.13.0", "pairing 0.23.0", "rand_core 0.6.4", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle", ] @@ -1078,9 +1120,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" dependencies = [ "bytemuck_derive", ] @@ -1093,7 +1135,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1104,9 +1146,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" dependencies = [ "serde", ] @@ -1137,9 +1179,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24b1f0365a6c6bb4020cd05806fd0d33c44d38046b8bd7f0e40814b9763cabfc" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" dependencies = [ "serde", ] @@ -1155,14 +1197,14 @@ dependencies = [ "semver 1.0.23", "serde", "serde_json", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] name = "cc" -version = "1.1.36" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "jobserver", "libc", @@ -1244,9 +1286,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -1254,9 +1296,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -1273,14 +1315,14 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "colorchoice" @@ -1297,15 +1339,15 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] [[package]] name = "const-hex" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586" +checksum = "4b0485bab839b018a8f1723fc5391819fea5f8f0f32288ef8a735fd096b6160c" dependencies = [ "cfg-if", "cpufeatures", @@ -1347,6 +1389,16 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1355,9 +1407,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -1377,6 +1429,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crossbeam-channel" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -1453,7 +1514,7 @@ dependencies = [ [[package]] name = "curve25519-dalek" version = "4.1.3" -source = "git+https://github.com/sp1-patches/curve25519-dalek?tag=curve25519_dalek-v4.1.3-patch-v1#dbdd0ffeea0ff767affc3f6765d1edbdaa9e2cb9" +source = "git+https://github.com/sp1-patches/curve25519-dalek?tag=patch-v4.1.3-v3.4.0#bfe63b8205f0b6baa0c1f4c71da33209f766e3e4" dependencies = [ "anyhow", "cfg-if", @@ -1462,7 +1523,7 @@ dependencies = [ "digest 0.10.7", "fiat-crypto", "rustc_version 0.4.1", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle", "zeroize", ] @@ -1470,11 +1531,11 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" version = "0.1.1" -source = "git+https://github.com/sp1-patches/curve25519-dalek?tag=curve25519_dalek-v4.1.3-patch-v1#dbdd0ffeea0ff767affc3f6765d1edbdaa9e2cb9" +source = "git+https://github.com/sp1-patches/curve25519-dalek?tag=patch-v4.1.3-v3.4.0#bfe63b8205f0b6baa0c1f4c71da33209f766e3e4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1487,7 +1548,7 @@ dependencies = [ "cfg-if", "digest 0.9.0", "rand_core 0.6.4", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle-ng", "zeroize", ] @@ -1502,7 +1563,7 @@ dependencies = [ "cfg-if", "digest 0.9.0", "rand_core 0.6.4", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "subtle-ng", "zeroize", ] @@ -1544,7 +1605,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1555,7 +1616,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1636,15 +1697,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "debugid" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" -dependencies = [ - "uuid", -] - [[package]] name = "der" version = "0.5.1" @@ -1698,7 +1750,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1719,7 +1771,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "unicode-xid", ] @@ -1773,7 +1825,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1819,7 +1871,7 @@ dependencies = [ "elliptic-curve", "hex-literal", "signature", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "spki 0.7.3", ] @@ -1843,7 +1895,7 @@ dependencies = [ "rand_core 0.6.4", "serde", "sha2 0.9.9", - "thiserror 1.0.68", + "thiserror 1.0.69", "zeroize", ] @@ -1933,7 +1985,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1944,7 +1996,7 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -1955,12 +2007,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1997,9 +2049,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fastrlp" @@ -2178,7 +2230,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2223,17 +2275,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" -[[package]] -name = "gecko_profile" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "890852c7e1e02bc6758e325d6b1e0236e4fbf21b492f585ce4d4715be54b4c6a" -dependencies = [ - "debugid", - "serde", - "serde_json", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2247,9 +2288,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" +checksum = "2cb8bc4c28d15ade99c7e90b219f30da4be5c88e586277e8cbe886beeb868ab2" dependencies = [ "serde", "typenum", @@ -2262,8 +2303,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -2291,17 +2334,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "goblin" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" -dependencies = [ - "log", - "plain", - "scroll", -] - [[package]] name = "groth16-verifier-program" version = "1.1.0" @@ -2341,6 +2373,25 @@ dependencies = [ "subtle", ] +[[package]] +name = "h2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.6.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "half" version = "1.8.3" @@ -2389,9 +2440,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", @@ -2483,13 +2534,14 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", + "h2", "http", "http-body", "httparse", @@ -2519,6 +2571,19 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.10" @@ -2676,7 +2741,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -2717,13 +2782,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] @@ -2750,21 +2815,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "serde", ] [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -2849,9 +2914,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -2864,9 +2929,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "fb15147158e79fd8b8afd0252522769c4f48725460b37338544d8379d94fc8f9" dependencies = [ "wasm-bindgen", ] @@ -2968,9 +3033,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libgit2-sys" @@ -2986,9 +3051,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets 0.52.6", @@ -3030,9 +3095,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -3056,7 +3121,7 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown 0.15.1", + "hashbrown 0.15.2", ] [[package]] @@ -3109,11 +3174,10 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ - "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -3268,7 +3332,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -3375,7 +3439,7 @@ checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -3429,7 +3493,7 @@ checksum = "21aad1fbf80d2bcd7406880efc7ba109365f44bbb72896758ddcbfa46bf1592c" dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-serde 0.3.6", "derive_more 1.0.0", @@ -3445,7 +3509,7 @@ checksum = "e281fbfc2198b7c0c16457d6524f83d192662bc9f3df70f24c3038d4521616df" dependencies = [ "alloy-eips 0.3.6", "alloy-network-primitives 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rpc-types-eth 0.3.6", "alloy-serde 0.3.6", "cfg-if", @@ -3461,6 +3525,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "option-ext" version = "0.2.0" @@ -3488,7 +3558,7 @@ dependencies = [ [[package]] name = "p3-air" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "p3-field", "p3-matrix", @@ -3497,7 +3567,7 @@ dependencies = [ [[package]] name = "p3-baby-bear" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "num-bigint 0.4.6", "p3-field", @@ -3511,7 +3581,7 @@ dependencies = [ [[package]] name = "p3-bn254-fr" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "ff 0.13.0", "num-bigint 0.4.6", @@ -3525,7 +3595,7 @@ dependencies = [ [[package]] name = "p3-challenger" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "p3-field", "p3-maybe-rayon", @@ -3538,7 +3608,7 @@ dependencies = [ [[package]] name = "p3-commit" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3551,7 +3621,7 @@ dependencies = [ [[package]] name = "p3-dft" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "p3-field", "p3-matrix", @@ -3563,7 +3633,7 @@ dependencies = [ [[package]] name = "p3-field" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "num-bigint 0.4.6", @@ -3576,7 +3646,7 @@ dependencies = [ [[package]] name = "p3-fri" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-challenger", @@ -3594,7 +3664,7 @@ dependencies = [ [[package]] name = "p3-interpolation" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "p3-field", "p3-matrix", @@ -3604,7 +3674,7 @@ dependencies = [ [[package]] name = "p3-keccak-air" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "p3-air", "p3-field", @@ -3617,7 +3687,7 @@ dependencies = [ [[package]] name = "p3-matrix" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3631,7 +3701,7 @@ dependencies = [ [[package]] name = "p3-maybe-rayon" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "rayon", ] @@ -3639,7 +3709,7 @@ dependencies = [ [[package]] name = "p3-mds" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-dft", @@ -3653,7 +3723,7 @@ dependencies = [ [[package]] name = "p3-merkle-tree" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-commit", @@ -3669,7 +3739,7 @@ dependencies = [ [[package]] name = "p3-poseidon2" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "gcd", "p3-field", @@ -3682,7 +3752,7 @@ dependencies = [ [[package]] name = "p3-symmetric" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-field", @@ -3692,7 +3762,7 @@ dependencies = [ [[package]] name = "p3-uni-stark" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "itertools 0.12.1", "p3-air", @@ -3710,7 +3780,7 @@ dependencies = [ [[package]] name = "p3-util" version = "0.1.0" -source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#db3d45d4ec899efaf8f7234a8573f285fbdda5db" +source = "git+https://github.com/Plonky3/Plonky3?branch=sp1-v4#bba88386261c3eaceb7f922b99bea56c1d6c6c58" dependencies = [ "serde", ] @@ -3735,28 +3805,29 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "8be4817d39f3272f69c59fe05d0535ae6456c2dc2fa1ba02910296c7e0a5c590" dependencies = [ "arrayvec 0.7.6", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.12" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "8781a75c6205af67215f382092b6e0a4ff3734798523e69073d4bcd294ec767b" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] @@ -3822,7 +3893,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" name = "patch-testing-program" version = "1.1.0" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "curve25519-dalek", "curve25519-dalek-ng 4.1.1 (git+https://github.com/sp1-patches/curve25519-dalek-ng?tag=curve25519_dalek_ng-v4.1.1-patch-v1)", "ed25519-consensus", @@ -3877,10 +3948,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" dependencies = [ "memchr", - "thiserror 1.0.68", + "thiserror 1.0.69", "ucd-trie", ] +[[package]] +name = "pin-project" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "pin-project-lite" version = "0.2.15" @@ -3942,17 +4033,11 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -3976,7 +4061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4037,14 +4122,14 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -4099,7 +4184,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4112,7 +4197,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4132,9 +4217,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", @@ -4143,26 +4228,29 @@ dependencies = [ "rustc-hash 2.0.0", "rustls", "socket2", - "thiserror 1.0.68", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand 0.8.5", "ring", "rustc-hash 2.0.0", "rustls", + "rustls-pki-types", "slab", - "thiserror 1.0.68", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] @@ -4326,7 +4414,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4337,7 +4425,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -4352,9 +4440,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -4419,7 +4507,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tokio-rustls", "tokio-util", @@ -4444,7 +4532,7 @@ dependencies = [ "http", "reqwest", "serde", - "thiserror 1.0.68", + "thiserror 1.0.69", "tower-service", ] @@ -4457,7 +4545,7 @@ dependencies = [ "reth-execution-errors", "reth-primitives", "reth-storage-errors", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4468,7 +4556,7 @@ dependencies = [ "alloy-chains", "alloy-eips 0.3.6", "alloy-genesis", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-trie", "auto_impl", "derive_more 1.0.0", @@ -4490,7 +4578,7 @@ dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-genesis", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-trie", "bytes", "modular-bitfield", @@ -4506,7 +4594,7 @@ dependencies = [ "convert_case 0.6.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -4551,7 +4639,7 @@ dependencies = [ "reth-execution-errors", "reth-fs-util", "reth-storage-errors", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4572,7 +4660,7 @@ version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ "alloy-chains", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "auto_impl", "crc", @@ -4635,7 +4723,7 @@ dependencies = [ "reth-revm", "revm", "revm-primitives", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", ] @@ -4645,7 +4733,7 @@ version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ "alloy-eips 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "derive_more 1.0.0", "nybbles", @@ -4674,7 +4762,7 @@ source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374 dependencies = [ "serde", "serde_json", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4682,11 +4770,11 @@ name = "reth-network-peers" version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "enr", "serde_with", - "thiserror 1.0.68", + "thiserror 1.0.69", "url", ] @@ -4696,7 +4784,7 @@ version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ "alloy-chains", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "derive_more 1.0.0", "once_cell", "reth-chainspec", @@ -4725,7 +4813,7 @@ dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-genesis", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-rpc-types", "alloy-serde 0.3.6", @@ -4743,7 +4831,7 @@ dependencies = [ "reth-trie-common", "revm-primitives", "serde", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4754,7 +4842,7 @@ dependencies = [ "alloy-consensus 0.3.6", "alloy-eips 0.3.6", "alloy-genesis", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-rpc-types-eth 0.3.6", "byteorder", @@ -4772,13 +4860,13 @@ name = "reth-prune-types" version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "bytes", "derive_more 1.0.0", "modular-bitfield", "reth-codecs", "serde", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -4801,7 +4889,7 @@ name = "reth-stages-types" version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "bytes", "modular-bitfield", "reth-codecs", @@ -4814,7 +4902,7 @@ name = "reth-static-file-types" version = "1.0.6" source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374182a43a3602aaa953d37aa9217b" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "derive_more 1.0.0", "serde", "strum", @@ -4873,7 +4961,7 @@ source = "git+https://github.com/sp1-patches/reth?tag=rsp-20240830#260c7ed2c9374 dependencies = [ "alloy-consensus 0.3.6", "alloy-genesis", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-trie", "bytes", @@ -4938,7 +5026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7a6bff9dbde3370a5ac9555104117f7e6039b3cc76e8d5d9d01899088beca2a" dependencies = [ "alloy-eips 0.3.6", - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "auto_impl", "bitflags", "bitvec", @@ -4998,9 +5086,9 @@ dependencies = [ [[package]] name = "roaring" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4b84ba6e838ceb47b41de5194a60244fac43d9fe03b71dbe8c5a201081d6d1" +checksum = "f81dc953b2244ddd5e7860cb0bb2a790494b898ef321d4aff8e260efab60cc88" dependencies = [ "bytemuck", "byteorder", @@ -5039,9 +5127,9 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" dependencies = [ "const-oid 0.9.6", "digest 0.10.7", @@ -5061,7 +5149,7 @@ dependencies = [ name = "rsa-program" version = "1.1.0" dependencies = [ - "rsa 0.9.6", + "rsa 0.9.7", "sha2 0.10.8", "sp1-zkvm", ] @@ -5080,7 +5168,7 @@ name = "rsp-client-executor" version = "0.1.0" source = "git+https://github.com/succinctlabs/rsp/?rev=3647076#3647076da6580e30384dd911a3fc50d4bcdb5bc1" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "eyre", "futures", @@ -5113,7 +5201,7 @@ name = "rsp-mpt" version = "0.1.0" source = "git+https://github.com/succinctlabs/rsp/?rev=3647076#3647076da6580e30384dd911a3fc50d4bcdb5bc1" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "alloy-rlp", "alloy-rpc-types", "anyhow", @@ -5127,7 +5215,7 @@ dependencies = [ "rlp", "rsp-primitives", "serde", - "thiserror 1.0.68", + "thiserror 1.0.69", ] [[package]] @@ -5163,7 +5251,7 @@ dependencies = [ name = "rsp-script" version = "0.1.0" dependencies = [ - "alloy-primitives 0.8.11", + "alloy-primitives 0.8.14", "bincode", "clap", "rsp-client-executor", @@ -5260,9 +5348,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags", "errno", @@ -5273,10 +5361,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ + "log", "once_cell", "ring", "rustls-pki-types", @@ -5285,6 +5374,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -5299,6 +5400,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -5337,9 +5441,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scale-info" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa7ffc1c0ef49b0452c6e2986abf2b07743320641ffd5fc63d552458e3b779b" +checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" dependencies = [ "cfg-if", "derive_more 1.0.0", @@ -5349,50 +5453,39 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.5" +version = "2.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46385cc24172cf615450267463f937c10072516359b3ff1cb24228a4a08bf951" +checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "scc" -version = "2.2.4" +version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "66b202022bb57c049555430e11fc22fea12909276a80a4c3d368da36ac1d88ed" dependencies = [ "sdd", ] [[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "scroll" -version = "0.12.0" +name = "schannel" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ - "scroll_derive", + "windows-sys 0.59.0", ] [[package]] -name = "scroll_derive" -version = "0.12.0" +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sdd" @@ -5435,6 +5528,29 @@ dependencies = [ "cc", ] +[[package]] +name = "security-framework" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.11.0" @@ -5455,18 +5571,18 @@ dependencies = [ [[package]] name = "semver-parser" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +checksum = "9900206b54a3527fdc7b8a938bffd94a568bac4f4aa8113b209df75a09c0dec2" dependencies = [ "pest", ] [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -5492,20 +5608,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap 2.6.0", "itoa", @@ -5532,7 +5648,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -5574,14 +5690,14 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "serial_test" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" dependencies = [ "futures", "log", @@ -5593,13 +5709,13 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -5726,9 +5842,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -5736,7 +5852,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "cargo_metadata", @@ -5747,18 +5863,15 @@ dependencies = [ [[package]] name = "sp1-core-executor" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "bytemuck", "elf", "enum-map", "eyre", - "gecko_profile", - "goblin", "hashbrown 0.14.5", "hex", - "indicatif", "itertools 0.13.0", "log", "nohash-hasher", @@ -5767,15 +5880,13 @@ dependencies = [ "p3-maybe-rayon", "rand 0.8.5", "rrs-succinct", - "rustc-demangle", "serde", - "serde_json", "sp1-curves", "sp1-primitives", "sp1-stark", "strum", "strum_macros", - "thiserror 1.0.68", + "thiserror 1.0.69", "tiny-keccak", "tracing", "typenum", @@ -5784,12 +5895,12 @@ dependencies = [ [[package]] name = "sp1-core-machine" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "cfg-if", "elliptic-curve", - "generic-array 1.1.0", + "generic-array 1.1.1", "hashbrown 0.14.5", "hex", "itertools 0.13.0", @@ -5820,7 +5931,7 @@ dependencies = [ "strum", "strum_macros", "tempfile", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", "tracing-forest", "tracing-subscriber", @@ -5830,7 +5941,7 @@ dependencies = [ [[package]] name = "sp1-cuda" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "ctrlc", @@ -5845,13 +5956,12 @@ dependencies = [ [[package]] name = "sp1-curves" -version = "3.0.0" +version = "3.4.0" dependencies = [ "cfg-if", - "curve25519-dalek", "dashu", "elliptic-curve", - "generic-array 1.1.0", + "generic-array 1.1.1", "itertools 0.13.0", "k256", "num", @@ -5866,7 +5976,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "3.0.0" +version = "3.4.0" dependencies = [ "quote", "syn 1.0.109", @@ -5888,7 +5998,7 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "serde", @@ -5896,9 +6006,9 @@ dependencies = [ [[package]] name = "sp1-lib" -version = "3.1.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14deb700469a37ec075bcf88dac3815b026dd9c4b9cb175980826f1fbb2e4e80" +checksum = "7a5729da1b05d56c01457e5ecabdc77f1cc941df23f2921163a2f325aec22428" dependencies = [ "bincode", "serde", @@ -5906,7 +6016,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "3.0.0" +version = "3.4.0" dependencies = [ "bincode", "hex", @@ -5922,7 +6032,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "bincode", @@ -5950,14 +6060,15 @@ dependencies = [ "sp1-recursion-core", "sp1-recursion-gnark-ffi", "sp1-stark", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", + "tracing-appender", "tracing-subscriber", ] [[package]] name = "sp1-recursion-circuit" -version = "3.0.0" +version = "3.4.0" dependencies = [ "hashbrown 0.14.5", "itertools 0.13.0", @@ -5989,7 +6100,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "3.0.0" +version = "3.4.0" dependencies = [ "backtrace", "itertools 0.13.0", @@ -6009,7 +6120,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "3.0.0" +version = "3.4.0" dependencies = [ "backtrace", "ff 0.13.0", @@ -6035,7 +6146,7 @@ dependencies = [ "sp1-primitives", "sp1-stark", "static_assertions", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", "vec_map", "zkhash", @@ -6043,7 +6154,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "3.0.0" +version = "3.4.0" dependencies = [ "quote", "syn 1.0.109", @@ -6051,7 +6162,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "3.0.0" +version = "3.4.0" dependencies = [ "anyhow", "bincode", @@ -6075,13 +6186,15 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "3.0.0" +version = "3.4.0" dependencies = [ + "alloy-primitives 0.8.14", "alloy-signer", "alloy-signer-local", "alloy-sol-types", "anyhow", "async-trait", + "backoff", "bincode", "cfg-if", "dirs", @@ -6098,6 +6211,7 @@ dependencies = [ "reqwest", "reqwest-middleware", "serde", + "serde_json", "sp1-build", "sp1-core-executor", "sp1-core-machine", @@ -6108,8 +6222,9 @@ dependencies = [ "strum", "strum_macros", "tempfile", - "thiserror 1.0.68", + "thiserror 1.0.69", "tokio", + "tonic", "tracing", "twirp-rs", "vergen", @@ -6117,7 +6232,7 @@ dependencies = [ [[package]] name = "sp1-stark" -version = "3.0.0" +version = "3.4.0" dependencies = [ "arrayref", "hashbrown 0.14.5", @@ -6149,7 +6264,7 @@ dependencies = [ [[package]] name = "sp1-verifier" -version = "3.0.0" +version = "3.4.0" dependencies = [ "hex", "lazy_static", @@ -6160,7 +6275,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "3.0.1" +version = "3.4.0" dependencies = [ "cfg-if", "getrandom", @@ -6170,7 +6285,7 @@ dependencies = [ "p3-field", "rand 0.8.5", "sha2 0.10.8", - "sp1-lib 3.0.0", + "sp1-lib 3.4.0", "sp1-primitives", ] @@ -6302,7 +6417,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6317,7 +6432,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "rustc-hex", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6334,7 +6449,7 @@ dependencies = [ "num-bigint 0.4.6", "rand 0.8.5", "rustc-hex", - "sp1-lib 3.1.0", + "sp1-lib 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6371,9 +6486,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -6382,14 +6497,14 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edf42e81491fb8871b74df3d222c64ae8cbc1269ea509fa768a3ed3e1b0ac8cb" +checksum = "da0523f59468a2696391f2a772edc089342aacd53c3caa2ac3264e598edf119b" dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6400,9 +6515,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -6427,7 +6542,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6453,9 +6568,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -6546,11 +6661,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.68", + "thiserror-impl 1.0.69", ] [[package]] @@ -6564,13 +6679,13 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6581,7 +6696,7 @@ checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6692,9 +6807,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -6716,7 +6831,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -6730,6 +6845,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -6771,6 +6897,59 @@ dependencies = [ "winnow 0.6.20", ] +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost 0.13.3", + "rustls-native-certs", + "rustls-pemfile", + "socket2", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower" version = "0.5.1" @@ -6801,9 +6980,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -6811,22 +6990,34 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror 1.0.69", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -6840,7 +7031,7 @@ checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f" dependencies = [ "ansi_term", "smallvec", - "thiserror 1.0.68", + "thiserror 1.0.69", "tracing", "tracing-subscriber", ] @@ -6858,9 +7049,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -6896,9 +7087,9 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 1.0.68", + "thiserror 1.0.69", "tokio", - "tower", + "tower 0.5.1", "url", ] @@ -6934,9 +7125,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-segmentation" @@ -6950,6 +7141,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -6964,9 +7161,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -6991,12 +7188,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" - [[package]] name = "valuable" version = "0.1.0" @@ -7063,9 +7254,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "21d3b25c3ea1126a2ad5f4f9068483c2af1e64168f847abe863a526b8dbfe00b" dependencies = [ "cfg-if", "once_cell", @@ -7074,36 +7265,37 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "52857d4c32e496dc6537646b5b117081e71fd2ff06de792e3577a150627db283" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.45" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" +checksum = "951fe82312ed48443ac78b66fa43eded9999f738f6022e67aead7b708659e49a" dependencies = [ "cfg-if", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "920b0ffe069571ebbfc9ddc0b36ba305ef65577c94b06262ed793716a1afd981" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7111,22 +7303,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "bf59002391099644be3524e23b781fa43d2be0c5aa0719a18c0731b9d195cab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "e5047c5392700766601942795a436d7d2599af60dcc3cc1248c9120bfb0827b0" [[package]] name = "wasm-streams" @@ -7143,9 +7335,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "476364ff87d0ae6bfb661053a9104ab312542658c3d8f963b7ace80b6f9b26b9" dependencies = [ "js-sys", "wasm-bindgen", @@ -7163,9 +7355,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -7430,9 +7622,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -7442,13 +7634,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -7470,27 +7662,27 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "synstructure 0.13.1", ] @@ -7511,7 +7703,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -7533,7 +7725,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] diff --git a/examples/Cargo.toml b/examples/Cargo.toml index d10ee9741e..73bcf63be5 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -66,7 +66,7 @@ serde_json = "1.0.132" tracing = "0.1.40" [patch.crates-io] -curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", tag = "curve25519_dalek-v4.1.3-patch-v1" } +curve25519-dalek = { git = "https://github.com/sp1-patches/curve25519-dalek", tag = "patch-v4.1.3-v3.4.0" } curve25519-dalek-ng = { git = "https://github.com/sp1-patches/curve25519-dalek-ng", tag = "curve25519_dalek_ng-v4.1.1-patch-v1" } ecdsa-core = { git = "https://github.com/sp1-patches/signatures", package = "ecdsa", branch = "umadayal/secp256r1" } ed25519-consensus = { git = "https://github.com/sp1-patches/ed25519-consensus", tag = "ed25519_consensus-v2.1.0-patch-v1" } diff --git a/examples/aggregation/script/src/main.rs b/examples/aggregation/script/src/main.rs index 9015cafcc2..2b1227d6c4 100644 --- a/examples/aggregation/script/src/main.rs +++ b/examples/aggregation/script/src/main.rs @@ -24,7 +24,7 @@ fn main() { sp1_sdk::utils::setup_logger(); // Initialize the proving client. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Setup the proving and verifying keys. let (aggregation_pk, _) = client.setup(AGGREGATION_ELF); diff --git a/examples/bls12381/script/src/main.rs b/examples/bls12381/script/src/main.rs index 385b04124a..7e6c02fd40 100644 --- a/examples/bls12381/script/src/main.rs +++ b/examples/bls12381/script/src/main.rs @@ -6,7 +6,7 @@ fn main() { let stdin = SP1Stdin::new(); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (_public_values, report) = client.execute(ELF, stdin).run().expect("failed to prove"); println!("executed: {}", report); diff --git a/examples/bn254/script/src/main.rs b/examples/bn254/script/src/main.rs index 4decb3a3f7..cd9c6e5057 100644 --- a/examples/bn254/script/src/main.rs +++ b/examples/bn254/script/src/main.rs @@ -6,7 +6,7 @@ fn main() { let stdin = SP1Stdin::new(); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (_public_values, report) = client.execute(ELF, stdin).run().expect("failed to prove"); println!("executed: {}", report); diff --git a/examples/chess/script/src/main.rs b/examples/chess/script/src/main.rs index 8026ddf454..3a1df33e50 100644 --- a/examples/chess/script/src/main.rs +++ b/examples/chess/script/src/main.rs @@ -13,7 +13,7 @@ fn main() { let san = "d4".to_string(); stdin.write(&san); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let mut proof = client.prove(&pk, stdin).run().unwrap(); diff --git a/examples/cycle-tracking/script/src/main.rs b/examples/cycle-tracking/script/src/main.rs index 58da7f4e8f..03a76a80f2 100644 --- a/examples/cycle-tracking/script/src/main.rs +++ b/examples/cycle-tracking/script/src/main.rs @@ -9,7 +9,7 @@ fn main() { utils::setup_logger(); // Execute the normal program. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (_, _) = client.execute(NORMAL_ELF, SP1Stdin::new()).run().expect("proving failed"); // Execute the report program. @@ -17,5 +17,8 @@ fn main() { // Get the "setup" cycle count from the report program. let setup_cycles = report.cycle_tracker.get("setup").unwrap(); - println!("Using cycle-tracker-report saves the number of cycles to the cycle-tracker mapping in the report.\nHere's the number of cycles used by the setup: {}", setup_cycles); + println!( + "Using cycle-tracker-report saves the number of cycles to the cycle-tracker mapping in the report.\nHere's the number of cycles used by the setup: {}", + setup_cycles + ); } diff --git a/examples/elf/riscv32im-succinct-zkvm-elf b/examples/elf/riscv32im-succinct-zkvm-elf new file mode 100755 index 0000000000..dbd4cfab99 Binary files /dev/null and b/examples/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf new file mode 100755 index 0000000000..c82f73b866 Binary files /dev/null and b/examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/fibonacci/script/bin/compressed.rs b/examples/fibonacci/script/bin/compressed.rs index 9261d092f8..632f9cd15f 100644 --- a/examples/fibonacci/script/bin/compressed.rs +++ b/examples/fibonacci/script/bin/compressed.rs @@ -13,7 +13,7 @@ fn main() { stdin.write(&n); // Generate the constant-sized proof for the given program and input. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let mut proof = client.prove(&pk, stdin).compressed().run().unwrap(); diff --git a/examples/fibonacci/script/bin/execute.rs b/examples/fibonacci/script/bin/execute.rs index 5cf1efe1b2..7b92525a71 100644 --- a/examples/fibonacci/script/bin/execute.rs +++ b/examples/fibonacci/script/bin/execute.rs @@ -14,7 +14,7 @@ fn main() { stdin.write(&n); // Only execute the program and get a `SP1PublicValues` object. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (mut public_values, execution_report) = client.execute(ELF, stdin).run().unwrap(); // Print the total number of cycles executed and the full execution report with a breakdown of diff --git a/examples/fibonacci/script/bin/groth16_bn254.rs b/examples/fibonacci/script/bin/groth16_bn254.rs index 06d5b0b95f..98e9fa96af 100644 --- a/examples/fibonacci/script/bin/groth16_bn254.rs +++ b/examples/fibonacci/script/bin/groth16_bn254.rs @@ -14,7 +14,7 @@ fn main() { stdin.write(&n); // Set up the pk and vk. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); println!("vk: {:?}", vk.bytes32()); diff --git a/examples/fibonacci/script/bin/plonk_bn254.rs b/examples/fibonacci/script/bin/plonk_bn254.rs index 8759293316..48f9c51a37 100644 --- a/examples/fibonacci/script/bin/plonk_bn254.rs +++ b/examples/fibonacci/script/bin/plonk_bn254.rs @@ -14,7 +14,7 @@ fn main() { stdin.write(&n); // Set up the pk and vk. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); println!("vk: {:?}", vk.bytes32()); diff --git a/examples/fibonacci/script/src/main.rs b/examples/fibonacci/script/src/main.rs index 4cfb02879c..442fce04c5 100644 --- a/examples/fibonacci/script/src/main.rs +++ b/examples/fibonacci/script/src/main.rs @@ -16,7 +16,7 @@ fn main() { stdin.write(&n); // Create a `ProverClient` method. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Execute the program using the `ProverClient.execute` method, without generating a proof. let (_, report) = client.execute(ELF, stdin.clone()).run().unwrap(); diff --git a/examples/groth16/script/src/main.rs b/examples/groth16/script/src/main.rs index b35a15f58c..2fecb5493a 100644 --- a/examples/groth16/script/src/main.rs +++ b/examples/groth16/script/src/main.rs @@ -23,7 +23,7 @@ fn generate_fibonacci_proof() -> (Vec, Vec, String) { stdin.write(&n); // Create a `ProverClient`. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Generate the groth16 proof for the Fibonacci program. let (pk, vk) = client.setup(FIBONACCI_ELF); @@ -46,7 +46,7 @@ fn main() { stdin.write(&vk); // Create a `ProverClient`. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Execute the program using the `ProverClient.execute` method, without generating a proof. let (_, report) = client.execute(GROTH16_ELF, stdin.clone()).run().unwrap(); diff --git a/examples/io/script/src/main.rs b/examples/io/script/src/main.rs index 21ad14d0fa..008c69e09d 100644 --- a/examples/io/script/src/main.rs +++ b/examples/io/script/src/main.rs @@ -23,7 +23,7 @@ fn main() { stdin.write(&q); // Generate the proof for the given program. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let mut proof = client.prove(&pk, stdin).run().unwrap(); diff --git a/examples/is-prime/script/src/main.rs b/examples/is-prime/script/src/main.rs index 628d1c605b..c965775743 100644 --- a/examples/is-prime/script/src/main.rs +++ b/examples/is-prime/script/src/main.rs @@ -14,7 +14,7 @@ fn main() { stdin.write(&n); // Generate and verify the proof - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let mut proof = client.prove(&pk, stdin).run().unwrap(); diff --git a/examples/json/script/src/main.rs b/examples/json/script/src/main.rs index ee093c1629..4c3eaa03a4 100644 --- a/examples/json/script/src/main.rs +++ b/examples/json/script/src/main.rs @@ -34,7 +34,7 @@ fn main() { stdin.write(&initial_account_state); stdin.write(&transactions); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(JSON_ELF); let mut proof = client.prove(&pk, stdin).run().expect("proving failed"); diff --git a/examples/patch-testing/program/src/main.rs b/examples/patch-testing/program/src/main.rs index fe6e0d36a0..d5c98607c0 100644 --- a/examples/patch-testing/program/src/main.rs +++ b/examples/patch-testing/program/src/main.rs @@ -81,15 +81,31 @@ fn test_curve25519_dalek_ng() { /// Emits ED_DECOMPRESS syscall. fn test_curve25519_dalek() { - let input = [1u8; 32]; - let y = CompressedEdwardsY_dalek(input); + let input_passing = [1u8; 32]; + + // This y-coordinate is not square, and therefore not on the curve + let limbs: [u64; 4] = + [8083970408152925034, 11907700107021980321, 16259949789167878387, 5645861033211660086]; + + // convert to bytes + let input_failing: [u8; 32] = + limbs.iter().flat_map(|l| l.to_be_bytes()).collect::>().try_into().unwrap(); + + let y_passing = CompressedEdwardsY_dalek(input_passing); println!("cycle-tracker-start: curve25519-dalek decompress"); - let decompressed_key = y.decompress().unwrap(); + let decompressed_key = y_passing.decompress().unwrap(); println!("cycle-tracker-end: curve25519-dalek decompress"); let compressed_key = decompressed_key.compress(); - assert_eq!(compressed_key, y); + assert_eq!(compressed_key, y_passing); + + let y_failing = CompressedEdwardsY_dalek(input_failing); + println!("cycle-tracker-start: curve25519-dalek decompress"); + let decompressed_key = y_failing.decompress(); + println!("cycle-tracker-end: curve25519-dalek decompress"); + + assert!(decompressed_key.is_none()); } /// Emits KECCAK_PERMUTE syscalls. diff --git a/examples/patch-testing/script/src/main.rs b/examples/patch-testing/script/src/main.rs index c80446a5b3..5e85f2b825 100644 --- a/examples/patch-testing/script/src/main.rs +++ b/examples/patch-testing/script/src/main.rs @@ -8,7 +8,7 @@ pub fn main() { let stdin = SP1Stdin::new(); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (_, report) = client.execute(PATCH_TEST_ELF, stdin).run().expect("executing failed"); // Confirm there was at least 1 SHA_COMPUTE syscall. diff --git a/examples/regex/script/src/main.rs b/examples/regex/script/src/main.rs index b198ab43c2..63c8c6fe66 100644 --- a/examples/regex/script/src/main.rs +++ b/examples/regex/script/src/main.rs @@ -18,7 +18,7 @@ fn main() { stdin.write(&target_string); // Generate the proof for the given program and input. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(REGEX_IO_ELF); let mut proof = client.prove(&pk, stdin).run().expect("proving failed"); diff --git a/examples/rsa/script/src/main.rs b/examples/rsa/script/src/main.rs index 4a6b50d640..991a458d7d 100644 --- a/examples/rsa/script/src/main.rs +++ b/examples/rsa/script/src/main.rs @@ -52,7 +52,7 @@ fn main() { // let verified = stdout.read::(); // Generate the proof for the given program and input. - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(RSA_ELF); let proof = client.prove(&pk, stdin).run().expect("proving failed"); diff --git a/examples/rsp/script/src/main.rs b/examples/rsp/script/src/main.rs index f67325ccc4..08ded491e0 100644 --- a/examples/rsp/script/src/main.rs +++ b/examples/rsp/script/src/main.rs @@ -31,7 +31,7 @@ fn main() { let client_input = load_input_from_cache(CHAIN_ID_ETH_MAINNET, 20526624); // Generate the proof. - let client = ProverClient::new(); + let client = ProverClient::from_env(); // Setup the proving key and verification key. let (pk, vk) = client.setup(include_elf!("rsp-program")); diff --git a/examples/ssz-withdrawals/script/src/main.rs b/examples/ssz-withdrawals/script/src/main.rs index f410d10815..9a6450bc7d 100644 --- a/examples/ssz-withdrawals/script/src/main.rs +++ b/examples/ssz-withdrawals/script/src/main.rs @@ -8,7 +8,7 @@ fn main() { utils::setup_logger(); let stdin = SP1Stdin::new(); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(ELF); let proof = client.prove(&pk, stdin).run().expect("proving failed"); diff --git a/examples/tendermint/script/src/main.rs b/examples/tendermint/script/src/main.rs index 258aea371d..298b8ee75f 100644 --- a/examples/tendermint/script/src/main.rs +++ b/examples/tendermint/script/src/main.rs @@ -41,7 +41,7 @@ pub fn main() { // let encoded: Vec = bincode::serialize(&light_block_1).unwrap(); // let decoded: LightBlock = bincode::deserialize(&encoded[..]).unwrap(); - let client = ProverClient::new(); + let client = ProverClient::from_env(); let (pk, vk) = client.setup(TENDERMINT_ELF); client.execute(TENDERMINT_ELF, stdin.clone()).run().expect("proving failed");