Skip to content

Commit 3c499a2

Browse files
authored
Docker reproducible builds, more VE content (#34)
* fix #28 - add talk on VE * docker reproducible builds * shitty workaround for sp1 tooling :-(
1 parent e60b838 commit 3c499a2

14 files changed

Lines changed: 292 additions & 205 deletions

File tree

Cargo.lock

Lines changed: 180 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ sp1-zkvm = "5.0"
2222
sp1-sdk = "5.0"
2323
sp1-build = "5.0"
2424
chacha20 = "0.9"
25-
jsonrpsee = { version = "0.24", features = ["macros", "server", "http-client"] }
25+
jsonrpsee = { version = "0.25", features = ["macros", "server", "http-client"] }
2626
serde = { version = "1.0", default-features = false, features = ["derive"] }
2727
serde_json = "1.0"
2828
tokio = { version = "1", features = ["full"] }
29-
tonic = { version = "0.12", default-features = false }
3029
celestia-types = "0.11"
3130
dotenv = "0.15"
3231
hyper-rustls = "0.27.6"
@@ -48,3 +47,6 @@ rustls-pemfile = "2.2"
4847
[patch.crates-io]
4948
# TODO: update to 5.0?
5049
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", tag = "patch-sha2-0.10.8-sp1-4.0.0" }
50+
51+
[workspace.features]
52+
reproducible-elf = ["service/reproducible-elf"]

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Base with Rust, Go, CUDA, SP1, and cargo-chef
2-
FROM nvidia/cuda:12.8.1-devel-ubuntu24.04 AS base-dev
2+
FROM nvidia/cuda:12.9.1-devel-ubuntu24.04 AS base-dev
33

44
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
55
apt-get install --no-install-recommends -y \
66
clang libclang-dev docker.io curl tar build-essential pkg-config git ca-certificates gnupg2 \
77
&& rm -rf /var/lib/apt/lists/*
88

9-
ENV GO_VERSION=1.22.0
9+
ENV GO_VERSION=1.24.4
1010
ENV GO_URL="https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz"
1111
RUN curl -L --proto '=https' --tlsv1.2 -sSf ${GO_URL} -o go.tar.gz && \
1212
mkdir -p /opt/go && \
@@ -49,17 +49,18 @@ RUN --mount=type=cache,id=target_cache,target=/app/target \
4949
COPY . .
5050

5151
# Build SP1 ELF to be proven (with optimizations)
52+
# TODO: need to use `cargo prove --docker` for repoducible builds?
5253
RUN --mount=type=cache,id=target_cache,target=/app/target \
53-
/root/.sp1/bin/cargo-prove prove build -p chacha-program
54-
54+
RUSTFLAGS="-Copt-level=3 -Clto=fat -Ccodegen-units=1 -Cdebuginfo=1 -Cembed-bitcode=yes" /root/.sp1/bin/cargo-prove prove build -p chacha-program
5555
# Build the final binary
56+
# NOTE: default feature is to use --docker ELF
5657
RUN --mount=type=cache,id=target_cache,target=/app/target \
57-
cargo build --release && \
58+
cargo build --release --no-default-features && \
5859
strip /app/target/release/pda-proxy && \
5960
cp target/release/pda-proxy /app/pda-proxy # pop out of cache
6061

6162
####################################################################################################
62-
FROM nvidia/cuda:12.8.1-base-ubuntu24.04 AS runtime
63+
FROM nvidia/cuda:12.9.1-base-ubuntu24.04 AS runtime
6364

6465
# SP1 CUDA support needs Docker-in-Docker to run `moongate-server` prover service
6566
# Internally run on localhost:3000

doc/verifiable_encryption.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Verifiable Encryption
22

3+
<figure align="center">
4+
<iframe
5+
width="560"
6+
height="315"
7+
src="https://www.youtube.com/embed/6P7yWZ4Cshs?si=RzSswRKxYD-gFa7T"
8+
title="YouTube video player"
9+
frameborder="0"
10+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
11+
referrerpolicy="strict-origin-when-cross-origin"
12+
allowfullscreen>
13+
</iframe>
14+
<figcaption>
15+
May 2025 overview talk - <a href="https://hackmd.io/@Nuke/SyHBUsdWlg">Slides here</a>
16+
</figcaption>
17+
</figure>
18+
319
### _A New Primitive Empowering Private Data Availability_
420

521
> “Don’t trust. Verify.”
@@ -64,7 +80,7 @@ In a world where chain data is globally replicated and indexed, **encryption at
6480

6581
- **PDA as a database** for collaborative dApps with fine-grained access control.
6682
- **Private rollups** with programmable cryptography, enabling [obfuscated state](https://0xparc.org/blog/programmable-cryptography-1).
67-
- **Private bridging and escrow** sending verifibly correctm but private messages around web2 and/or web3 apps.
83+
- **Private bridging and escrow** sending verifiably correct but private messages around web2 and/or web3 apps.
6884
- **Drop-in support** for existing DA users via a [proxy service](../README.md), simplifying migration to PDA.
6985

7086
### _Trustless Data Markets_
@@ -76,7 +92,7 @@ Here is a [diagram inspired by them](https://docs.google.com/presentation/d/1qq1
7692

7793
```mermaid
7894
flowchart LR
79-
Data["Data to be Sold"] --> zkVM_Algo["zkVM(tranform media)"]
95+
Data["Data to be Sold"] --> zkVM_Algo["zkVM(transform media)"]
8096
zkVM_Algo -- "proven data transform w/ VE anchor" --> Contract["Marketplace on <dApp chain>"]
8197
Data -- "VE data" --> Celestia["Celestia"]
8298
Celestia -- "header" --> Blobstream["Blobstream on <dApp chain>"]
@@ -85,7 +101,7 @@ flowchart LR
85101

86102
### _Verifiable Private Backups_
87103

88-
> NOTE: Celestia does _not_ guarantee that data will be avalible forever!
104+
> NOTE: Celestia does _not_ guarantee that data will be available forever!
89105
> See [the docs on retrievability](https://docs.celestia.org/learn/retrievability#data-retrievability-and-pruning-in-celestia-node) for the latest safe assumptions to use.
90106
91107
With PDA, sensitive data can be publicly published in encrypted form, with **predefined methods for recovery** - without revealing its contents.

example.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ PDA_PORT=26657
6060
# IMPORTANT: the prover programs *embed the ELF* into their own bin,
6161
# so this vat is only for development & compilation
6262
# NOTE: MUST USE FULL PATH, used in scripts, so relative will fail.
63-
ZK_PROGRAM_ELF_PATH=
63+
ZK_PROGRAM_ELF_PATH=/full/path/to/target/elf-compilation/release/riscv32im-succinct-zkvm-elf/release/chacha-program
64+
# See https://docs.succinct.xyz/docs/sp1/writing-programs/compiling#production-builds
65+
ZK_PROGRAM_REPRODUCIBLE_ELF_PATH=/full/path/to/target/elf-compilation/docker/riscv32im-succinct-zkvm-elf/release/chacha-program
6466

6567
# 'mock' for generating mock proofs locally, 'cpu', 'cuda', or 'network'
6668
SP1_PROVER=cuda

justfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ initial-config-installs:
3030
@just sp1 initial-config-installs
3131

3232
_pre-build:
33-
@just sp1 build-elf
33+
# ALWAYS build with docker
34+
@just sp1 build-elf-reproducible
3435

3536
_pre-run:
3637
echo "just pre-run TODO"
@@ -50,7 +51,7 @@ run-debug *FLAGS: _pre-build _pre-run
5051

5152
# Build docker image & tag
5253
docker-build:
53-
docker build --build-arg BUILDKIT_INLINE_CACHE=1 --tag "$DOCKER_CONTAINER_NAME" --progress=plain .
54+
DOCKER_BUILDKIT=1 docker build --build-arg BUILDKIT_INLINE_CACHE=1 --tag "$DOCKER_CONTAINER_NAME" --progress=plain .
5455

5556
# Save docker image to a tar.gz
5657
docker-save:

service/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ serde_json.workspace = true
1010
celestia-types.workspace = true
1111
jsonrpsee.workspace = true
1212
tokio.workspace = true
13-
tonic.workspace = true
1413
hyper = { workspace = true, features = ["http1", "server"] }
1514
hyper-util = { workspace = true, features = ["tokio"] }
1615
http-body-util.workspace = true
@@ -27,3 +26,8 @@ rustls.workspace = true
2726
tokio-rustls.workspace = true
2827
rustls-pemfile.workspace = true
2928
hyper-rustls.workspace = true
29+
30+
[features]
31+
default = ["reproducible-elf"]
32+
33+
reproducible-elf = []

service/src/internal/runner.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@ use std::sync::Arc;
1212
use tokio::sync::{OnceCell, mpsc};
1313

1414
/// Hardcoded ELF binary for the crate `program-keccak-inclusion`
15-
static CHACHA_ELF: &[u8] = include_bytes!(
15+
/// For reproducible builds, you need `cargo prove --docker`
16+
#[cfg(feature = "reproducible-elf")]
17+
pub const CHACHA_ELF: &[u8] = include_bytes!(
18+
"../../../target/elf-compilation/docker/riscv32im-succinct-zkvm-elf/release/chacha-program"
19+
);
20+
21+
#[cfg(not(feature = "reproducible-elf"))]
22+
pub const CHACHA_ELF: &[u8] = include_bytes!(
1623
"../../../target/elf-compilation/riscv32im-succinct-zkvm-elf/release/chacha-program"
1724
);
25+
1826
/// Hardcoded ID for the crate `program-keccak-inclusion`
1927
static CHACHA_ID: OnceCell<SuccNetProgramId> = OnceCell::const_new();
2028

zkVM/common/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ rand = { workspace = true, default-features = false, optional = true, features =
1111
sha2 = { workspace = true, optional = true }
1212

1313
[features]
14-
default = ["std"]
14+
default = ["std", "reproducible-elf"]
1515
std = ["rand/os_rng", "sha2"]
16+
reproducible-elf = []

zkVM/common/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Include the binary input file
2-
pub const INPUT_BYTES: &[u8] = include_bytes!("../../static/proof_input_example.bin");
2+
/// For reproducible builds, you need `cargo prove --docker`
3+
#[cfg(feature = "reproducible-elf")]
4+
pub const CHACHA_ELF: &[u8] = include_bytes!(
5+
"../../../target/elf-compilation/docker/riscv32im-succinct-zkvm-elf/release/chacha-program"
6+
);
7+
8+
#[cfg(not(feature = "reproducible-elf"))]
9+
pub const CHACHA_ELF: &[u8] = include_bytes!(
10+
"../../../target/elf-compilation/riscv32im-succinct-zkvm-elf/release/chacha-program"
11+
);
312

413
use chacha20::ChaCha20;
514
use chacha20::cipher::{KeyIvInit, StreamCipher};

0 commit comments

Comments
 (0)