Skip to content

Commit d8738fd

Browse files
committed
First working version of SP1 Distributed Prover
1 parent 36a5614 commit d8738fd

File tree

9 files changed

+149
-71
lines changed

9 files changed

+149
-71
lines changed

Cargo.lock

+97-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+16-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ risc0-build = { version = "1.0.1" }
5757
risc0-binfmt = { version = "1.0.1" }
5858

5959
# SP1
60-
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" }
61-
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" }
62-
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", branch = "main" }
60+
sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", rev = "14eb569d41d24721ffbd407d6060e202482d659c" }
61+
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", rev = "14eb569d41d24721ffbd407d6060e202482d659c" }
62+
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", rev = "14eb569d41d24721ffbd407d6060e202482d659c" }
63+
6364

6465
# alloy
6566
alloy-rlp = { version = "0.3.4", default-features = false }
@@ -189,3 +190,15 @@ revm-primitives = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-
189190
revm-precompile = { git = "https://github.com/taikoxyz/revm.git", branch = "v36-taiko" }
190191
secp256k1 = { git = "https://github.com/CeciliaZ030/rust-secp256k1", branch = "sp1-patch" }
191192
blst = { git = "https://github.com/CeciliaZ030/blst.git", branch = "v0.3.12-serialize" }
193+
194+
# Patch Plonky3 for Serialize and Deserialize of DuplexChallenger
195+
[patch."https://github.com/succinctlabs/sp1.git"]
196+
sp1-sdk = { path = "../sp1/sdk" }
197+
198+
# Patch Plonky3 for Serialize and Deserialize of DuplexChallenger
199+
[patch."https://github.com/Plonky3/Plonky3.git"]
200+
p3-field = { git = "https://github.com/Champii/Plonky3.git", branch = "serde_patch" }
201+
p3-challenger = { git = "https://github.com/Champii/Plonky3.git", branch = "serde_patch" }
202+
p3-poseidon2 = { git = "https://github.com/Champii/Plonky3.git", branch = "serde_patch" }
203+
p3-baby-bear = { git = "https://github.com/Champii/Plonky3.git", branch = "serde_patch" }
204+
p3-symmetric = { git = "https://github.com/Champii/Plonky3.git", branch = "serde_patch" }

host/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ ethers-core = { workspace = true }
8282

8383
[features]
8484
default = []
85-
sp1 = ["raiko-core/sp1"]
85+
sp1 = ["raiko-core/sp1", "sp1-driver"]
8686
risc0 = ["raiko-core/risc0"]
8787
sgx = ["raiko-core/sgx"]
8888

host/src/lib.rs

+19
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ pub struct Opts {
3535
/// [default: 0.0.0.0:8080]
3636
address: String,
3737

38+
#[arg(long, require_equals = true, default_value = "0.0.0.0:8081")]
39+
#[serde(default = "Opts::default_sp1_worker_address")]
40+
/// Distributed SP1 worker listening address
41+
/// [default: 0.0.0.0:8081]
42+
sp1_worker_address: String,
43+
44+
#[arg(long, default_value = None)]
45+
/// Distributed SP1 worker orchestrator address
46+
///
47+
/// Setting this will enable the worker and restrict it to only accept requests from
48+
/// this orchestrator
49+
///
50+
/// [default: None]
51+
sp1_orchestrator_address: Option<String>,
52+
3853
#[arg(long, require_equals = true, default_value = "16")]
3954
#[serde(default = "Opts::default_concurrency_limit")]
4055
/// Limit the max number of in-flight requests
@@ -88,6 +103,10 @@ impl Opts {
88103
"0.0.0.0:8080".to_string()
89104
}
90105

106+
fn default_sp1_worker_address() -> String {
107+
"0.0.0.0:8081".to_string()
108+
}
109+
91110
fn default_concurrency_limit() -> usize {
92111
16
93112
}

host/src/server/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ pub mod api;
88

99
/// Starts the proverd server.
1010
pub async fn serve(state: ProverState) -> anyhow::Result<()> {
11+
#[cfg(feature = "sp1")]
12+
if let Some(orchestrator_addr) = state.opts.sp1_orchestrator_address.as_ref() {
13+
sp1_driver::serve_worker(
14+
state.opts.sp1_worker_address.clone(),
15+
orchestrator_addr.clone(),
16+
)
17+
.await;
18+
}
19+
1120
let addr = SocketAddr::from_str(&state.opts.address)
1221
.map_err(|_| HostError::InvalidAddress(state.opts.address.clone()))?;
1322
let listener = TcpListener::bind(addr).await?;

provers/sp1/driver/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ once_cell = { workspace = true, optional = true }
2121
sha3 = { workspace = true, optional = true, default-features = false }
2222
tracing = { workspace = true, optional = true }
2323

24-
2524
[features]
2625
enable = [
2726
"serde",

provers/sp1/driver/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use raiko_lib::{
44
prover::{IdStore, IdWrite, Proof, ProofKey, Prover, ProverConfig, ProverError, ProverResult},
55
};
66
use serde::{Deserialize, Serialize};
7+
pub use sp1_sdk::serve_worker;
78
use sp1_sdk::{
89
network::client::NetworkClient,
910
proto::network::{ProofMode, ProofStatus, UnclaimReason},

provers/sp1/guest/elf/sp1-guest

100755100644
File mode changed.

script/build.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ if [ -z "$1" ] || [ "$1" == "sp1" ]; then
150150
cargo ${TOOLCHAIN_SP1} build ${FLAGS} --features sp1
151151
else
152152
if [ -z "${TEST}" ]; then
153+
if [ -n "$ORCHESTRATOR" ]; then
154+
export ARGS="--sp1-orchestrator-address $ORCHESTRATOR"
155+
echo "Running in worker mode with orchestrator address $ORCHESTRATOR"
156+
fi
157+
153158
echo "Running Sp1 prover"
154-
cargo ${TOOLCHAIN_SP1} run ${FLAGS} --features sp1
159+
cargo ${TOOLCHAIN_SP1} run ${FLAGS} --features sp1 -- ${ARGS}
155160
else
156161
echo "Running Sp1 tests"
157162
cargo ${TOOLCHAIN_SP1} test ${FLAGS} --lib sp1-driver --features sp1 -- run_unittest_elf

0 commit comments

Comments
 (0)