Skip to content

Commit

Permalink
feat: dockerize evm prover (#146)
Browse files Browse the repository at this point in the history
## Overview

Fixes #142

---------

Co-authored-by: Javed Khan <[email protected]>
Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
3 people authored Feb 24, 2025
1 parent ebd51cc commit 231c10c
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ CONTRACT_ADDRESS="0x2854CFaC53FCaB6C95E28de8C91B96a31f0af8DD"
# Address of the E2E test faucet
E2E_FAUCET_ADDRESS="0xaF9053bB6c4346381C77C2FeD279B17ABAfCDf4d"
# Path to proto descriptor for celestia-prover
PROTO_DESCRIPTOR_PATH="./provers/celestia-prover/proto_descriptor.bin"
CELESTIA_PROTO_DESCRIPTOR_PATH="./provers/celestia-prover/proto_descriptor.bin"
# Path to proto descriptor for evm-prover
EVM_PROTO_DESCRIPTOR_PATH="./provers/evm-prover/proto_descriptor.bin"
# RPC of a celestia-node (light, bridge, or full)
export CELESTIA_NODE_URL="http://localhost:52351"
# Auth token for the celestia-node
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tonic = { version = "0.12", features = ["transport", "codegen", "prost"] }
tonic-build = "0.12"
tonic-reflection = "0.12"
tracing = { version = "0.1", default-features = false }
sp1-helper = "4.0.1"

# The rev in the following dependencies should match the commit used by the
# solidity-ibc-eureka submodule in this repo.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ For more information refer to the [architecture document](./ARCHITECTURE.md). No
# for Celestia (with IBC Eurekea enabled).
- TENDERMINT_RPC_URL=http://simapp-validator:26657
- RPC_URL=http://reth:8545
- PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
- CELESTIA_PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
+ - SP1_PROVER=network
+ - NETWORK_PRIVATE_KEY=PRIVATE_KEY
```
Expand Down
19 changes: 18 additions & 1 deletion docker-compose.rollkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ services:
# for Celestia (with IBC Eurekea enabled).
- TENDERMINT_RPC_URL=http://simapp-validator:26657
- RPC_URL=http://reth:8545
- PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
- CELESTIA_PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
ports:
- "50051:50051"
depends_on:
Expand All @@ -124,6 +124,23 @@ services:
networks:
- rollkit-network

evm-prover:
image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/evm-prover:latest
container_name: evm-prover
environment:
# TENDERMINT_RPC_URL should be the SimApp which is acting as a substitute
# for Celestia (with IBC Eurekea enabled).
- TENDERMINT_RPC_URL=http://simapp-validator:26657
- RPC_URL=http://reth:8545
- EVM_PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
ports:
- "50052:50052"
depends_on:
beacond:
condition: service_started
networks:
- rollkit-network

networks:
rollkit-network:
driver: bridge
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.sov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ services:
networks:
- sov-network

evm-prover:
image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/evm-prover:latest
container_name: evm-prover
environment:
# TENDERMINT_RPC_URL should be the SimApp which is acting as a substitute
# for Celestia (with IBC Eurekea enabled).
- TENDERMINT_RPC_URL=http://simapp-validator:26657
- RPC_URL=http://reth:8545
- EVM_PROTO_DESCRIPTOR_PATH=proto_descriptor.bin
ports:
- "50052:50052"
depends_on:
beacond:
condition: service_started
networks:
- rollkit-network

networks:
sov-network:
driver: bridge
Expand Down
60 changes: 60 additions & 0 deletions docker/evm_prover.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Use official Rust image as base
FROM rust:1.83-slim-bookworm AS builder

# Install dependencies
RUN apt-get update && apt-get install -y \
git \
pkg-config \
libssl-dev \
build-essential \
curl \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*

# Clone SP1 repo and install succinct toolchain
RUN mkdir -p /sp1
ENV SP1_DIR=/sp1
WORKDIR $SP1_DIR

RUN curl -Lv https://sp1.succinct.xyz | bash -x
RUN $SP1_DIR/bin/sp1up

# Clone the repo and build
WORKDIR /celestia_zkevm_ibc_demo/
COPY . .

# Build evm-prover release binary
RUN cargo build --release --bin evm-prover

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*

# Copy binary from builder
COPY --from=builder /celestia_zkevm_ibc_demo/target/release/evm-prover /usr/local/bin/

# Create non-root user
RUN useradd -m -u 10001 -s /bin/bash prover

USER prover
WORKDIR /home/prover

COPY --from=builder /celestia_zkevm_ibc_demo/provers/evm-prover/proto_descriptor.bin .

# Default environment variables that can be overridden
ENV TENDERMINT_RPC_URL=http://localhost:5123
ENV RPC_URL=http://localhost:8545
ENV CONTRACT_ADDRESS=0x2854CFaC53FCaB6C95E28de8C91B96a31f0af8DD
ENV PROVER_PORT=50052

# Expose port
EXPOSE ${PROVER_PORT}

# Run the prover
CMD ["evm-prover"]
4 changes: 2 additions & 2 deletions provers/celestia-prover/prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Prover Server listening on {}", addr);

// Get the path to the proto descriptor file from the environment variable
let proto_descriptor_path = env::var("PROTO_DESCRIPTOR_PATH")
.expect("PROTO_DESCRIPTOR_PATH environment variable not set");
let proto_descriptor_path = env::var("CELESTIA_PROTO_DESCRIPTOR_PATH")
.expect("CELESTIA_PROTO_DESCRIPTOR_PATH environment variable not set");

println!(
"Loading proto descriptor set from {}",
Expand Down
18 changes: 15 additions & 3 deletions provers/evm-prover/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use sp1_sdk::HashableKey;
use std::env;
use std::fs;
use std::path::PathBuf;
use tonic::{transport::Server, Request, Response, Status};

// Import the generated proto rust code
Expand Down Expand Up @@ -70,13 +71,24 @@ impl Prover for ProverService {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
dotenv::dotenv().ok();

let addr = "[::1]:50052".parse()?;
let addr = "[::]:50052".parse()?;
let prover = ProverService::new().await?;

println!("BLEVM Prover Server listening on {}", addr);

// Load the file descriptor set
let file_descriptor_set = fs::read("proto_descriptor.bin")?;
// Get the path to the proto descriptor file from the environment variable
let proto_descriptor_path: String = env::var("EVM_PROTO_DESCRIPTOR_PATH")
.expect("EVM_PROTO_DESCRIPTOR_PATH environment variable not set");

println!(
"Loading proto descriptor set from {}",
proto_descriptor_path
);
let file_path = PathBuf::from(proto_descriptor_path);

// Read the file
let file_descriptor_set = fs::read(&file_path)?;
println!("Loaded proto descriptor set");

Server::builder()
.add_service(ProverServer::new(prover))
Expand Down

0 comments on commit 231c10c

Please sign in to comment.