Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
005072e
feat(zk-dex): rewrite SP1 binary to use DexCircuit + AppProgramInput
Zena-park Feb 23, 2026
881c302
feat(zk-dex): convert ProgramInput to AppProgramInput in serialize_input
Zena-park Feb 23, 2026
8f74865
fix(zk-dex): resolve SP1 guest crash and add Timelock VK registration
Zena-park Feb 24, 2026
33e976c
fix(zk-dex): modularize handlers and fix SP1 proof verification (00e)
Zena-park Feb 24, 2026
7049b9d
feat(zk-dex): implement full circuit with 7 new operations
Zena-park Feb 24, 2026
4012cd5
feat(zk-dex): improve Docker tools stability, add withdrawal claim UI…
Zena-park Feb 26, 2026
dfabc7d
docs(zk-dex): add SP1 ZK-DEX infrastructure cost analysis
Zena-park Feb 26, 2026
82bb70d
docs(zk-dex): update progress and E2E design docs with Phase 4 work
Zena-park Feb 26, 2026
170cd9a
feat(l2): make early batch commit conditional on prover idle state
Zena-park Feb 26, 2026
6b604b2
feat(zk-dex): add on-chain claim status check to withdrawal tracker
Zena-park Feb 26, 2026
817f3b5
fix(docker): improve build caching and fix compilation errors
Zena-park Feb 26, 2026
a2b2c8d
refactor(docker): rename Docker services from ethrex to tokamak-app
Zena-park Feb 27, 2026
db37d1d
style(l2): run cargo fmt on docker polish code
Zena-park Mar 1, 2026
da10c80
Merge branch 'pr/zk/02-circuit-framework' into pr/zk/04-docker-polish
Zena-park Mar 2, 2026
7b68cdb
fix(ci): resolve compilation errors after merging CI fixes from PR #7
Zena-park Mar 2, 2026
e610a90
fix(l2): replace unwrap_or with explicit error handling in early comm…
Zena-park Mar 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# Documentation
docs/

# Git history (not needed in Docker builds, vergen uses env var fallback)
.git/

# Local development
hive/
ethereum-package/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-main_mdbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Check links
uses: lycheeverse/lychee-action@v2
with:
args: --no-progress --exclude 'localhost' docs/
args: --no-progress --timeout 30 --exclude 'localhost' --exclude 'medium\.com' --exclude 'github\.com/lambdaclass/ethrex' --exclude 'docs\.taiko\.xyz' --exclude 'ephema\.io' --exclude 'share\.firefox\.dev' docs/
fail: true

deploy:
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ COPY cmd ./cmd
COPY metrics ./metrics
COPY tooling ./tooling
COPY fixtures/genesis ./fixtures/genesis
COPY .git ./.git
COPY Cargo.* ./
COPY fixtures ./fixtures
COPY .cargo/ ./.cargo

ENV COMPILE_CONTRACTS=true

# Fallback git info for Docker builds without .git directory.
# vergen build scripts check these env vars before trying to open .git.
ENV VERGEN_GIT_SHA=docker-build
ENV VERGEN_GIT_BRANCH=docker-build

RUN cargo build --profile $PROFILE $BUILD_FLAGS

RUN mkdir -p /ethrex/bin && \
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile.sp1
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ COPY cmd ./cmd
COPY metrics ./metrics
COPY tooling ./tooling
COPY fixtures/genesis ./fixtures/genesis
COPY .git ./.git
COPY Cargo.* ./
COPY fixtures ./fixtures
COPY .cargo/ ./.cargo

ENV COMPILE_CONTRACTS=true
ENV GUEST_PROGRAMS=${GUEST_PROGRAMS}

# Fallback git info for Docker builds without .git directory.
# vergen build scripts check these env vars before trying to open .git.
ENV VERGEN_GIT_SHA=docker-build
ENV VERGEN_GIT_BRANCH=docker-build

# Build with SP1 features and guest programs
# RUSTUP_TOOLCHAIN=stable ensures the host build uses stable,
# while sp1_build internally uses the succinct toolchain for guest programs
Expand Down
23 changes: 16 additions & 7 deletions cmd/ethrex/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ fn main() -> Result<(), Box<dyn Error>> {
.host_triple(true)
.build()?;

// Export git commit hash and branch name as environment variables
let git2 = Git2Builder::default().branch(true).sha(false).build()?;

Emitter::default()
.add_instructions(&rustc)?
.add_instructions(&git2)?
.emit()?;
// Export git commit hash and branch name as environment variables.
// In Docker builds without .git, fall back to env vars (set in Dockerfile).
if let (Ok(branch), Ok(sha)) = (
std::env::var("VERGEN_GIT_BRANCH"),
std::env::var("VERGEN_GIT_SHA"),
) {
Emitter::default().add_instructions(&rustc)?.emit()?;
println!("cargo:rustc-env=VERGEN_GIT_BRANCH={}", branch.trim());
println!("cargo:rustc-env=VERGEN_GIT_SHA={}", sha.trim());
} else {
let git2 = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&rustc)?
.add_instructions(&git2)?
.emit()?;
}

#[cfg(feature = "l2")]
{
Expand Down
14 changes: 10 additions & 4 deletions cmd/ethrex/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,16 @@ pub fn open_store(datadir: &Path) -> Result<Store, StoreError> {
Store::new(datadir, EngineType::InMemory)
} else {
#[cfg(feature = "rocksdb")]
let engine_type = EngineType::RocksDB;
#[cfg(feature = "metrics")]
ethrex_metrics::process::set_datadir_path(datadir.to_path_buf());
Store::new(datadir, engine_type)
{
#[cfg(feature = "metrics")]
ethrex_metrics::process::set_datadir_path(datadir.to_path_buf());
Store::new(datadir, EngineType::RocksDB)
}
#[cfg(not(feature = "rocksdb"))]
{
let _ = datadir;
compile_error!("Database feature must be enabled (Available: `rocksdb`).");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/guest-program/bin/openvm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/guest-program/bin/risc0/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/guest-program/bin/sp1-tokamon/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions crates/guest-program/bin/sp1-zk-dex/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/guest-program/bin/zisk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 15 additions & 45 deletions crates/guest-program/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {

if programs.contains(&"zk-dex".to_string()) {
#[cfg(all(not(clippy), feature = "sp1"))]
build_sp1_zk_dex();
build_sp1_guest_program("sp1-zk-dex");
} else {
// Ensure placeholder ELF exists so `include_bytes!` doesn't fail
// when zk-dex isn't in the build list.
Expand All @@ -45,7 +45,7 @@ fn main() {

if programs.contains(&"tokamon".to_string()) {
#[cfg(all(not(clippy), feature = "sp1"))]
build_sp1_tokamon();
build_sp1_guest_program("sp1-tokamon");
} else {
// Ensure placeholder ELF exists so `include_bytes!` doesn't fail
// when tokamon isn't in the build list.
Expand Down Expand Up @@ -271,71 +271,41 @@ fn build_openvm_program() {
}

#[cfg(all(not(clippy), feature = "sp1"))]
fn build_sp1_zk_dex() {
fn build_sp1_guest_program(name: &str) {
use hex;
use sp1_sdk::{HashableKey, ProverClient};

sp1_build::build_program_with_args(
"./bin/sp1-zk-dex",
sp1_build::BuildArgs {
output_directory: Some("./bin/sp1-zk-dex/out".to_string()),
elf_name: Some("riscv32im-succinct-zkvm-elf".to_string()),
docker: option_env!("PROVER_REPRODUCIBLE_BUILD").is_some(),
tag: "v5.0.8".to_string(),
workspace_directory: Some(format!("{}/../../../", env!("CARGO_MANIFEST_DIR"))),
..Default::default()
},
);

let elf = std::fs::read("./bin/sp1-zk-dex/out/riscv32im-succinct-zkvm-elf")
.expect("could not read SP1 ZK-DEX elf file");
let prover = ProverClient::from_env();
let (_, vk) = prover.setup(&elf);

std::fs::write(
"./bin/sp1-zk-dex/out/riscv32im-succinct-zkvm-vk-bn254",
format!("{}\n", vk.vk.bytes32()),
)
.expect("could not write SP1 ZK-DEX vk-bn254 to file");
std::fs::write(
"./bin/sp1-zk-dex/out/riscv32im-succinct-zkvm-vk-u32",
format!("0x{}\n", hex::encode(vk.vk.hash_bytes())),
)
.expect("could not write SP1 ZK-DEX vk-u32 to file");
}

#[cfg(all(not(clippy), feature = "sp1"))]
fn build_sp1_tokamon() {
use hex;
use sp1_sdk::{HashableKey, ProverClient};
let bin_dir = format!("./bin/{name}");
let out_dir = format!("{bin_dir}/out");
let elf_name = "riscv32im-succinct-zkvm-elf";

sp1_build::build_program_with_args(
"./bin/sp1-tokamon",
&bin_dir,
sp1_build::BuildArgs {
output_directory: Some("./bin/sp1-tokamon/out".to_string()),
elf_name: Some("riscv32im-succinct-zkvm-elf".to_string()),
output_directory: Some(out_dir.clone()),
elf_name: Some(elf_name.to_string()),
docker: option_env!("PROVER_REPRODUCIBLE_BUILD").is_some(),
tag: "v5.0.8".to_string(),
workspace_directory: Some(format!("{}/../../../", env!("CARGO_MANIFEST_DIR"))),
..Default::default()
},
);

let elf = std::fs::read("./bin/sp1-tokamon/out/riscv32im-succinct-zkvm-elf")
.expect("could not read SP1 Tokamon elf file");
let elf_path = format!("{out_dir}/{elf_name}");
let elf = std::fs::read(&elf_path).unwrap_or_else(|_| panic!("could not read {name} elf file"));
let prover = ProverClient::from_env();
let (_, vk) = prover.setup(&elf);

std::fs::write(
"./bin/sp1-tokamon/out/riscv32im-succinct-zkvm-vk-bn254",
format!("{out_dir}/riscv32im-succinct-zkvm-vk-bn254"),
format!("{}\n", vk.vk.bytes32()),
)
.expect("could not write SP1 Tokamon vk-bn254 to file");
.unwrap_or_else(|_| panic!("could not write {name} vk-bn254 to file"));
std::fs::write(
"./bin/sp1-tokamon/out/riscv32im-succinct-zkvm-vk-u32",
format!("{out_dir}/riscv32im-succinct-zkvm-vk-u32"),
format!("0x{}\n", hex::encode(vk.vk.hash_bytes())),
)
.expect("could not write SP1 Tokamon vk-u32 to file");
.unwrap_or_else(|_| panic!("could not write {name} vk-u32 to file"));
}

#[cfg(all(not(clippy), feature = "zisk"))]
Expand Down
8 changes: 4 additions & 4 deletions crates/guest-program/src/common/app_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ pub fn execute_app_circuit<C: AppCircuit>(

// ── ETH transfer (no calldata) ── common
if tx.data().is_empty() {
eth_transfer::handle_eth_transfer(&mut state, sender, to_address, tx.value())?;
let gas =
eth_transfer::handle_eth_transfer(&mut state, sender, to_address, tx.value())?;
cumulative_gas += gas;
gas_fee::apply_gas_fee_distribution(
&mut state,
Expand All @@ -265,8 +266,7 @@ pub fn execute_app_circuit<C: AppCircuit>(

// ── Withdrawal (CommonBridgeL2) ── common
if to_address == COMMON_BRIDGE_L2_ADDRESS {
let (_handler_gas, message_id) =
withdrawal::handle_withdrawal(&mut state, tx, sender)?;
let (gas, message_id) = withdrawal::handle_withdrawal(&mut state, tx, sender)?;
cumulative_gas += gas;
gas_fee::apply_gas_fee_distribution(
&mut state,
Expand All @@ -288,7 +288,7 @@ pub fn execute_app_circuit<C: AppCircuit>(

// ── System contract calls ── common
if system_call::is_system_contract(to_address) {
system_call::handle_system_call(&mut state, tx, sender, to_address)?;
let gas = system_call::handle_system_call(&mut state, tx, sender, to_address)?;
cumulative_gas += gas;
gas_fee::apply_gas_fee_distribution(
&mut state,
Expand Down
Loading