Skip to content

Commit d6fd5b6

Browse files
smtmfftjohntaiko
andauthored
feat(raiko): test 2 phases prove (#512)
* test 2 phases prove * fix typo * add batch 2 phase prover * connect batch input request and batch proof request, need test * fix batch input prove * update test script * feat: introduce gaiko (#514) * feat: introduce gaiko * refactor: update Dockerfile and entrypoint script for improved build process and remove obsolete install script * chore: update subproject commit for gaiko * feat: add PIVOT environment variable to Docker Compose services * fix: update command instantiation for consistency in SGX prover and setup bootstrap * chore: remove obsolete install script from .dockerignore * feat: add .env file support to Docker Compose services * chore: update subproject commit for gaiko * chore: update subproject commit for gaiko * chore: update subproject commit for gaiko * chore: update subproject commit for gaiko * chore: update subproject commit for gaiko * chore: optimize Dockerfile build process with cache mount * chore: update SGX configuration and add pivot support in prover logic * chore: improve error handling for input serialization in prover logic * chore: enhance prover logic to support Pivot proof type and refactor method signatures for consistency * chore: add support for Pivot proof type in SGX prover and refactor related methods * chore: add Pivot configuration support in devnet JSON files * chore: update subproject commit reference in gaiko * chore: update setup_bootstrap to use async/await for Sgx and Pivot proof types * chore: refactor SgxProver to accept ProofType and streamline proof handling for Sgx and Pivot * chore: enhance setup_bootstrap to pass ProofType to bootstrap function for improved handling * chore: update error messages in setup_bootstrap to include proof_type for better debugging * chore: add pivot prover specific options to ProverSpecificOpts struct and update related tests * chore: update subproject commit reference in gaiko * chore: update subproject commit reference in gaiko * chore: update subproject commit reference in gaiko * chore: simplify Dockerfile cache mounts for cargo * chore: simplify Dockerfile cache mounts for cargo * chore: improve error handling in output logging * chore: update subproject commit reference in gaiko * chore: update Dockerfile to use cargo-chef for improved build efficiency and update Rust toolchain to 1.85.0 * chore: update .dockerignore to include additional target directories and remove obsolete entries * chore: update Dockerfile and .dockerignore to include cargo-config.toml and improve build configuration * fix: correct typo in cargo-config.toml from 'buid' to 'build' * chore: update subproject commit reference in gaiko * fix: conditionally print SGX mode warning based on proof type * chore: update subproject commit reference in gaiko * lru mem db (#516) * use lru in in-mem db, to avoid memory exhaustion * fix CI * response earlier until task status successed, except for aggregation … (#518) * response earlier until task status successed, except for aggregation request * remove duplicate trace * fix CI and update configs * update docker build env for pivot instance id * fix CI * update config * fix CI * feat: add sample environment configuration for Docker (#523) * fix CI sgx build * fix CI * fix CI --------- Co-authored-by: johntaiko <[email protected]>
1 parent 024ba47 commit d6fd5b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1263
-320
lines changed

.dockerignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
!/config.json
88
!/docker/entrypoint.sh
99
!/docker/enclave-key.pem
10+
!/docker/cargo-config.toml
1011
!/lib
1112
!/primitives
1213
!/provers
@@ -16,7 +17,6 @@
1617
!/rust-toolchain
1718
!/taiko.toml
1819
!/tests
19-
!/provers/sgx/setup
2020
!/kzg_settings_raw.bin
2121
!/core
2222
!/taskdb
@@ -26,3 +26,7 @@
2626
!/reqactor
2727
!/ballot
2828
!/redis-derive
29+
!/gaiko
30+
31+
/provers/sp1/guest/target
32+
/provers/risc0/guest/target

.github/workflows/ci-sgx-docker.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v4
24+
with:
25+
submodules: true
2426
- name: Setup and build sgx docker
2527
run: |
2628
cd docker
29+
cp ./.env.sample ./.env
2730
docker compose build raiko --no-cache
2831
shell: bash

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "gaiko"]
22
path = gaiko
3-
url = git@github.com:taikoxyz/gaiko.git
3+
url = https://github.com/taikoxyz/gaiko
44
branch = main

Cargo.lock

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

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ hashbrown = { version = "0.14", features = ["inline-more"] }
180180
tempfile = "3.8"
181181
cargo_metadata = "0.18.1"
182182
clap = { version = "4.4.6", features = ["derive", "string", "env"] }
183-
lru_time_cache = "0.11.11"
183+
lru = "0.13.0"
184184
lazy_static = "1.4.0"
185185
once_cell = "1.8.0"
186186
proptest = "1.4.0"

Dockerfile

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
1-
FROM rust:1.81.0 AS builder
1+
FROM ghcr.io/edgelesssys/ego-dev:v1.7.0 AS build-gaiko
2+
WORKDIR /opt/gaiko
23

4+
# Install dependencies
5+
COPY gaiko/go.mod .
6+
COPY gaiko/go.sum .
7+
RUN go mod download
8+
9+
# Build
10+
COPY gaiko/ .
11+
RUN ego-go build -o gaiko-ego ./cmd/gaiko
12+
13+
# Sign with our enclave config and private key
14+
COPY gaiko/ego/enclave.json .
15+
COPY docker/enclave-key.pem private.pem
16+
RUN ego sign && ego bundle gaiko-ego gaiko && ego uniqueid gaiko-ego
17+
18+
FROM rust:1.85.0 AS chef
19+
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
20+
RUN cargo binstall -y cargo-chef wild-linker
21+
RUN apt-get update && apt-get install -y clang
22+
WORKDIR /opt/raiko
323
ENV DEBIAN_FRONTEND=noninteractive
424
ARG BUILD_FLAGS=""
525

26+
FROM chef AS planner
27+
COPY . .
28+
COPY docker/cargo-config.toml .cargo/config.toml
29+
RUN cargo chef prepare --recipe-path recipe.json
30+
631
# risc0 dependencies
732
# RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash && \
833
# cargo binstall -y --force cargo-risczero && \
934
# cargo risczero install
1035

11-
WORKDIR /opt/raiko
36+
FROM chef AS builder
37+
COPY --from=planner /opt/raiko/recipe.json recipe.json
38+
RUN cargo chef cook --release ${BUILD_FLAGS} --features "sgx" --features "docker_build" --recipe-path recipe.json
1239
COPY . .
40+
COPY docker/cargo-config.toml .cargo/config.toml
1341
RUN cargo build --release ${BUILD_FLAGS} --features "sgx" --features "docker_build"
1442

1543
FROM gramineproject/gramine:1.8-jammy AS runtime
@@ -23,9 +51,11 @@ RUN apt-get update && \
2351
libsgx-dcap-ql \
2452
libsgx-urts \
2553
sgx-pck-id-retrieval-tool \
54+
build-essential \
55+
libssl-dev \
2656
jq \
2757
sudo && \
28-
apt-get clean && \
58+
apt-get clean all && \
2959
rm -rf /var/lib/apt/lists/*
3060

3161
RUN sed -i 's/#default quoting type = ecdsa_256/default quoting type = ecdsa_256/' /etc/aesmd.conf && \
@@ -36,6 +66,7 @@ RUN mkdir -p \
3666
./provers/sgx \
3767
/var/log/raiko
3868

69+
COPY --from=build-gaiko /opt/gaiko/gaiko ./bin/
3970
COPY --from=builder /opt/raiko/docker/entrypoint.sh ./bin/
4071
COPY --from=builder /opt/raiko/provers/sgx/config/sgx-guest.docker.manifest.template ./provers/sgx/config/sgx-guest.local.manifest.template
4172
# copy to /etc/raiko, but if self register mode, the mounted one will overwrite it.

core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ clap = { workspace = true }
6262

6363
# db cache
6464
lazy_static = { workspace = true }
65-
lru_time_cache = { workspace = true }
65+
lru = { workspace = true }
6666

6767
[dev-dependencies]
6868
assert_cmd = { workspace = true }

core/src/interfaces.rs

+39-20
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,32 @@ pub async fn run_prover(
8989
store: Option<&mut dyn IdWrite>,
9090
) -> RaikoResult<Proof> {
9191
match proof_type {
92-
ProofType::Native => NativeProver::run(input.clone(), output, config, store)
92+
ProofType::Native => NativeProver
93+
.run(input.clone(), output, config, store)
9394
.await
9495
.map_err(<ProverError as Into<RaikoError>>::into),
9596
ProofType::Sp1 => {
9697
#[cfg(feature = "sp1")]
97-
return sp1_driver::Sp1Prover::run(input.clone(), output, config, store)
98+
return sp1_driver::Sp1Prover
99+
.run(input.clone(), output, config, store)
98100
.await
99101
.map_err(|e| e.into());
100102
#[cfg(not(feature = "sp1"))]
101103
Err(RaikoError::FeatureNotSupportedError(proof_type))
102104
}
103105
ProofType::Risc0 => {
104106
#[cfg(feature = "risc0")]
105-
return risc0_driver::Risc0Prover::run(input.clone(), output, config, store)
107+
return risc0_driver::Risc0Prover
108+
.run(input.clone(), output, config, store)
106109
.await
107110
.map_err(|e| e.into());
108111
#[cfg(not(feature = "risc0"))]
109112
Err(RaikoError::FeatureNotSupportedError(proof_type))
110113
}
111-
ProofType::Sgx => {
114+
ProofType::Sgx | ProofType::Pivot => {
112115
#[cfg(feature = "sgx")]
113-
return sgx_prover::SgxProver::run(input.clone(), output, config, store)
116+
return sgx_prover::SgxProver::new(proof_type)
117+
.run(input.clone(), output, config, store)
114118
.await
115119
.map_err(|e| e.into());
116120
#[cfg(not(feature = "sgx"))]
@@ -128,28 +132,32 @@ pub async fn run_batch_prover(
128132
store: Option<&mut dyn IdWrite>,
129133
) -> RaikoResult<Proof> {
130134
match proof_type {
131-
ProofType::Native => NativeProver::batch_run(input.clone(), output, config, store)
135+
ProofType::Native => NativeProver
136+
.batch_run(input.clone(), output, config, store)
132137
.await
133138
.map_err(<ProverError as Into<RaikoError>>::into),
134139
ProofType::Sp1 => {
135140
#[cfg(feature = "sp1")]
136-
return sp1_driver::Sp1Prover::batch_run(input.clone(), output, config, store)
141+
return sp1_driver::Sp1Prover
142+
.batch_run(input.clone(), output, config, store)
137143
.await
138144
.map_err(|e| e.into());
139145
#[cfg(not(feature = "sp1"))]
140146
Err(RaikoError::FeatureNotSupportedError(proof_type))
141147
}
142148
ProofType::Risc0 => {
143149
#[cfg(feature = "risc0")]
144-
return risc0_driver::Risc0Prover::batch_run(input.clone(), output, config, store)
150+
return risc0_driver::Risc0Prover
151+
.batch_run(input.clone(), output, config, store)
145152
.await
146153
.map_err(|e| e.into());
147154
#[cfg(not(feature = "risc0"))]
148155
Err(RaikoError::FeatureNotSupportedError(proof_type))
149156
}
150-
ProofType::Sgx => {
157+
ProofType::Sgx | ProofType::Pivot => {
151158
#[cfg(feature = "sgx")]
152-
return sgx_prover::SgxProver::batch_run(input.clone(), output, config, store)
159+
return sgx_prover::SgxProver::new(proof_type)
160+
.batch_run(input.clone(), output, config, store)
153161
.await
154162
.map_err(|e| e.into());
155163
#[cfg(not(feature = "sgx"))]
@@ -167,28 +175,32 @@ pub async fn aggregate_proofs(
167175
store: Option<&mut dyn IdWrite>,
168176
) -> RaikoResult<Proof> {
169177
let proof = match proof_type {
170-
ProofType::Native => NativeProver::aggregate(input.clone(), output, config, store)
178+
ProofType::Native => NativeProver
179+
.aggregate(input.clone(), output, config, store)
171180
.await
172181
.map_err(<ProverError as Into<RaikoError>>::into),
173182
ProofType::Sp1 => {
174183
#[cfg(feature = "sp1")]
175-
return sp1_driver::Sp1Prover::aggregate(input.clone(), output, config, store)
184+
return sp1_driver::Sp1Prover
185+
.aggregate(input.clone(), output, config, store)
176186
.await
177187
.map_err(|e| e.into());
178188
#[cfg(not(feature = "sp1"))]
179189
Err(RaikoError::FeatureNotSupportedError(proof_type))
180190
}
181191
ProofType::Risc0 => {
182192
#[cfg(feature = "risc0")]
183-
return risc0_driver::Risc0Prover::aggregate(input.clone(), output, config, store)
193+
return risc0_driver::Risc0Prover
194+
.aggregate(input.clone(), output, config, store)
184195
.await
185196
.map_err(|e| e.into());
186197
#[cfg(not(feature = "risc0"))]
187198
Err(RaikoError::FeatureNotSupportedError(proof_type))
188199
}
189-
ProofType::Sgx => {
200+
ProofType::Sgx | ProofType::Pivot => {
190201
#[cfg(feature = "sgx")]
191-
return sgx_prover::SgxProver::aggregate(input.clone(), output, config, store)
202+
return sgx_prover::SgxProver::new(proof_type)
203+
.aggregate(input.clone(), output, config, store)
192204
.await
193205
.map_err(|e| e.into());
194206
#[cfg(not(feature = "sgx"))]
@@ -205,28 +217,32 @@ pub async fn cancel_proof(
205217
read: Box<&mut dyn IdStore>,
206218
) -> RaikoResult<()> {
207219
match proof_type {
208-
ProofType::Native => NativeProver::cancel(proof_key, read)
220+
ProofType::Native => NativeProver
221+
.cancel(proof_key, read)
209222
.await
210223
.map_err(<ProverError as Into<RaikoError>>::into),
211224
ProofType::Sp1 => {
212225
#[cfg(feature = "sp1")]
213-
return sp1_driver::Sp1Prover::cancel(proof_key, read)
226+
return sp1_driver::Sp1Prover
227+
.cancel(proof_key, read)
214228
.await
215229
.map_err(|e| e.into());
216230
#[cfg(not(feature = "sp1"))]
217231
Err(RaikoError::FeatureNotSupportedError(proof_type))
218232
}
219233
ProofType::Risc0 => {
220234
#[cfg(feature = "risc0")]
221-
return risc0_driver::Risc0Prover::cancel(proof_key, read)
235+
return risc0_driver::Risc0Prover
236+
.cancel(proof_key, read)
222237
.await
223238
.map_err(|e| e.into());
224239
#[cfg(not(feature = "risc0"))]
225240
Err(RaikoError::FeatureNotSupportedError(proof_type))
226241
}
227-
ProofType::Sgx => {
242+
ProofType::Sgx | ProofType::Pivot => {
228243
#[cfg(feature = "sgx")]
229-
return sgx_prover::SgxProver::cancel(proof_key, read)
244+
return sgx_prover::SgxProver::new(proof_type)
245+
.cancel(proof_key, read)
230246
.await
231247
.map_err(|e| e.into());
232248
#[cfg(not(feature = "sgx"))]
@@ -394,6 +410,8 @@ pub struct ProverSpecificOpts {
394410
pub native: Option<Value>,
395411
/// SGX prover specific options.
396412
pub sgx: Option<Value>,
413+
/// Pivot prover specific options.
414+
pub pivot: Option<Value>,
397415
/// SP1 prover specific options.
398416
pub sp1: Option<Value>,
399417
/// RISC0 prover specific options.
@@ -407,6 +425,7 @@ impl<S: ::std::hash::BuildHasher + ::std::default::Default> From<ProverSpecificO
407425
[
408426
("native", value.native.clone()),
409427
("sgx", value.sgx.clone()),
428+
("pivot", value.pivot.clone()),
410429
("sp1", value.sp1.clone()),
411430
("risc0", value.risc0.clone()),
412431
]

core/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ pub mod provider;
2929
pub type MerkleProof = HashMap<Address, EIP1186AccountProofResponse>;
3030

3131
pub struct Raiko {
32-
l1_chain_spec: ChainSpec,
33-
taiko_chain_spec: ChainSpec,
34-
request: ProofRequest,
32+
pub l1_chain_spec: ChainSpec,
33+
pub taiko_chain_spec: ChainSpec,
34+
pub request: ProofRequest,
3535
}
3636

3737
impl Raiko {

0 commit comments

Comments
 (0)