Skip to content

feat(l2): merge ZK-DEX e2e and CI fixes into app-customized-framework#12

Merged
Zena-park merged 107 commits intofeat/app-customized-frameworkfrom
pr/zk/02-circuit-framework
Mar 4, 2026
Merged

feat(l2): merge ZK-DEX e2e and CI fixes into app-customized-framework#12
Zena-park merged 107 commits intofeat/app-customized-frameworkfrom
pr/zk/02-circuit-framework

Conversation

@Zena-park
Copy link
Copy Markdown
Member

Summary

Context

Stacked PR chain (030201feat/app-customized-framework) had merge order issues.
PR #6 (01→target) and PR #7 (02→01) were merged on 3/2, but PR #11 (03→02) was merged later.
This PR brings the remaining 19 commits into feat/app-customized-framework.

Zena-park added 30 commits March 1, 2026 23:58
Add DexCircuit that processes ERC-20 style token transfers using
verified storage proofs instead of the previous keccak-chaining demo.
Includes Solidity-compatible storage layout, ABI parsing, and 15 tests.
…ncremental MPT)

Introduce the common infrastructure for app-specific guest programs:
- AppCircuit trait with classify_tx/execute_operation/gas_cost/generate_logs
- AppState for in-circuit state management via storage proofs
- AppProgramInput/StorageProof/AccountProof types
- Incremental MPT for state root recomputation from proof deltas
…ries

Add cycle-tracker-report start/end prints around read_input, execution,
and commit_public_inputs phases for performance profiling.
…arison

CLI binary that measures cycles and proving time for zk-dex, tokamon,
and evm-l2 using SP1 SDK. Supports --execute-only and --format groth16.
Add guest_program_id config field to ProofCoordinatorConfig and replace
hardcoded "evm-l2" string. Expose --proof-coordinator.guest-program-id
CLI arg and ETHREX_GUEST_PROGRAM_ID env var.
…verride

Add runtime configuration for selecting guest programs: programs.toml
with enabled_programs list, docker-compose override for injecting
ETHREX_GUEST_PROGRAM_ID, and Makefile targets for guest program mode.
Add dedicated Launch L2 flow page and setup guide. Rename "Deployments"
to "My L2s" across navigation, dashboard, and detail views. Replace
inline modals with /launch?program= links.
Add seedOfficialPrograms() at DB init to insert evm-l2, zk-dex, and
tokamon entries. JOIN programs table in getDeploymentById for metadata.
Accept config field in POST /api/deployments.
…circuit design

Add end-user GP Store deployment guide and developer notes covering
L2 launch platform design, SP1 performance comparison, and app-specific
circuit architecture and development plan.
Ignore Next.js build output, SP1 guest ELF/VK binaries, SP1 guest
Cargo.lock files, SQLite WAL/SHM files, and generated L2 config.
Migrate the zk-dex guest program from the old keccak-chaining demo
(DexProgramInput/execution_program) to the new AppCircuit-based
architecture (AppProgramInput/execute_app_circuit with DexCircuit).

- Rewrite bin/sp1-zk-dex to use execute_app_circuit(DexCircuit, input)
- Add rkyv derives to AppProgramInput, StorageProof, AccountProof
- Add ethrex-common dep and secp256k1 SP1 patch to sp1-zk-dex
- Delete old execution.rs and types.rs from zk_dex module
- Update sp1_benchmark.rs zk-dex input gen to TODO stub (Phase 3)
- Replace registry test with DexCircuit-based unit test
Implement prover-side input conversion so the zk-dex guest program
receives AppProgramInput (Merkle proofs) from the standard ProgramInput
(full ExecutionWitness trie), eliminating the need for coordinator or
protocol changes.

- Add input_converter module with convert_to_app_input() that rebuilds
  state/storage tries from ExecutionWitness and extracts Merkle proofs
- Replace ZkDexGuestProgram::serialize_input() pass-through with
  ProgramInput deserialization, transaction analysis, and conversion
- Add analyze_zk_dex_transactions() to extract needed accounts and
  storage slots from batch transactions
- Implement generate_zk_dex_input() in sp1_benchmark exercising the
  full conversion pipeline with mock state tries and transfer txs
- Update tests in traits.rs and registry.rs for the new behavior
- Fix build_trie_from_proofs storing intermediate nodes at hash-based
  paths instead of nibble paths, breaking multi-account trie lookups
- Add multi-account test coverage for incremental MPT operations
- Implement EIP-1559 transaction signing in SP1 benchmark using
  deterministic secp256k1 keys
- Generate AppProgramInput directly with Merkle proofs from trie
- Feature-gate serialize_input for zkVM guest (no l2 feature)
- Fix Address type alias usage in SP1 zk-dex guest binary
Add missing SP1 patched crates (k256, ecdsa, crypto-bigint, sha2, sha3,
p256) to the zk-dex guest binary. This enables SP1 precompiles for
ECDSA signature recovery and hashing, reducing execution cycles from
11.4M to 357K (182x vs EVM L2 baseline) and proving time from 5m05s
to 3m26s. Update benchmark comparison document with 3-way results.
Migrate the zk-dex guest program from the old keccak-chaining demo
(DexProgramInput/execution_program) to the new AppCircuit-based
architecture (AppProgramInput/execute_app_circuit with DexCircuit).

- Rewrite bin/sp1-zk-dex to use execute_app_circuit(DexCircuit, input)
- Add rkyv derives to AppProgramInput, StorageProof, AccountProof
- Add ethrex-common dep and secp256k1 SP1 patch to sp1-zk-dex
- Delete old execution.rs and types.rs from zk_dex module
- Update sp1_benchmark.rs zk-dex input gen to TODO stub (Phase 3)
- Replace registry test with DexCircuit-based unit test
Implement prover-side input conversion so the zk-dex guest program
receives AppProgramInput (Merkle proofs) from the standard ProgramInput
(full ExecutionWitness trie), eliminating the need for coordinator or
protocol changes.

- Add input_converter module with convert_to_app_input() that rebuilds
  state/storage tries from ExecutionWitness and extracts Merkle proofs
- Replace ZkDexGuestProgram::serialize_input() pass-through with
  ProgramInput deserialization, transaction analysis, and conversion
- Add analyze_zk_dex_transactions() to extract needed accounts and
  storage slots from batch transactions
- Implement generate_zk_dex_input() in sp1_benchmark exercising the
  full conversion pipeline with mock state tries and transfer txs
- Update tests in traits.rs and registry.rs for the new behavior
Timeline, SP1 profiling results (182x cycle reduction),
Halo2 vs SP1 decision, L1/L2 infra status, and next steps.
…tration

Add deployer support for registering custom guest programs (e.g., zk-dex)
on L1 during contract initialization, including GuestProgramRegistry
registration and SP1 verification key setup via upgradeVerificationKey().

- Add --register-guest-programs and --zk-dex-sp1-vk CLI options
- Add guest program registration loop in initialize_contracts()
- Add resolve_deployer_program_type_id() and get_vk_for_program() helpers
- Add ZK-DEX E2E Makefile targets (deploy, l2, prover)
- Add programs-zk-dex.toml prover config
- Add E2E design document
Three issues fixed:

1. Timelock ownership: VK registration called OnChainProposer directly
   but owner is Timelock. Added Timelock.upgradeVerificationKey() with
   SECURITY_COUNCIL role and updated deployer to use it.

2. KZG blob verification crash: kzg-rs BLS12-381 operations crash in
   SP1 VM despite sp1_bls12_381 dependency. App circuits now skip KZG
   verification (L1 already verifies) and compute versioned hash directly.

3. Empty batch safety: Added early returns in verify_state_proofs() and
   compute_new_state_root() when account proofs are empty.

SP1 guest execution verified: 414K cycles (42K read + 370K exec + 2K commit).
Automates the 4-step ZK-DEX E2E environment setup (L1 start, contract
deploy, L2 start, prover start) into a single script with start/stop/
status/logs commands and --no-prover option for app testing.
Increase health check timeouts to account for compilation time
(L1: 30s -> 300s, L2: 60s -> 600s) and switch summary output
from echo to printf to prevent garbled terminal formatting.
Add complete Docker infrastructure for running the ZK-DEX E2E pipeline
with real SP1 ZK proofs and optional GPU acceleration.

- Dockerfile.sp1: Multi-stage build with SP1 succinct toolchain, Docker
  CLI for Groth16 gnark wrapper, and ZK-DEX guest program compilation
- docker-compose-zk-dex.overrides.yaml: SP1 prover with Docker-in-Docker
  volume path alignment for Groth16 proving step
- docker-compose-zk-dex-gpu.overrides.yaml: NVIDIA GPU opt-in override
- scripts/zk-dex-docker.sh: One-command Docker localnet management
  (start/stop/status/logs/clean with --no-gpu/--no-prover flags)
- Makefile: 7 new Docker ZK-DEX targets
- Verified: 203s proving time (3m 23s) on Apple M4 Max CPU-only Docker
…rification

- Add withdraw-status.html: L2 withdrawal tracking page with 4-stage
  status view (TX confirmed → batch committed → batch verified → claimable),
  pagination (10/page), wallet-based filtering, auto-refresh, and
  block timestamp display
- Add navigation links from dashboard and bridge UI to withdrawal tracker
- Remove onlyOwner from verifyBatch() in OnChainProposer — ZK proof
  verification is cryptographically secured, making caller restriction
  unnecessary and enabling permissionless proving
- Fix Dockerfile.sp1: copy SP1 guest program VK files to final image
  so the deployer can register them on L1 during contract initialization
- Update bridge Dockerfile to include withdraw-status.html
- Add 3D styling and color accents to dashboard quick link tiles
…ker tools

Three root causes of the 00e (Invalid SP1 proof) error:

1. Race condition: program_id was only stored on proof submission, but
   the L1 committer needed it earlier to set the correct programTypeId.
   Batches were committed as evm-l2 (type=1) while proofs were generated
   for zk-dex (type=2), causing a VK mismatch.

   Fix: Store program_id in proof_coordinator when batch is assigned to
   prover, and fall back to ETHREX_GUEST_PROGRAM_ID env var in committer.

2. Custom program public values not implemented: The contract required
   customPublicValues for programTypeId > 1, but the proof sender always
   sent empty bytes. Since zk-dex uses the same ProgramOutput format as
   evm-l2, we use _getPublicInputsFromCommitment() for all program types.

3. Dockerfile.sp1 missing mkdir for canonicalize() path resolution:
   The deployer resolves VK paths via env!("CARGO_MANIFEST_DIR")/../../
   which needs /ethrex/cmd/ethrex/ to exist in the final Docker image.

Also adds Docker tools infrastructure (Blockscout, Bridge UI, Dashboard)
with make targets and script commands for managing them.
Extract inline transaction handlers from app_execution.rs into
dedicated modules under common/handlers/ to fix five root causes
of SP1 proof verification failure:

1. Withdrawal now credits BURN_ADDRESS with withdrawn value
2. L1Messenger.lastMessageId storage slot incremented on withdrawal
3. Withdrawal logs (WithdrawalInitiated + L1Message) properly generated
   instead of empty vec, fixing l1_out_messages_merkle_root mismatch
4. Gas fee distribution now debits effective_gas_price (not just
   base_fee) and credits coinbase/base_fee_vault/operator_fee_vault
5. Witness analyzer includes BURN_ADDRESS, messenger storage,
   coinbase, and fee vault accounts for proof generation
…ee handlers

Verify handlers produce EVM-identical state transitions and logs:
- Withdrawal: sender debit, BURN_ADDRESS credit, messenger lastMessageId
- Withdrawal logs: WithdrawalInitiated + L1Message with exact topic bytes
- Integration: generated logs parseable by get_block_l1_messages()
- Deposit: mintETH(0xb0f4d395) calldata parses real recipient correctly
- Gas fees: effective_gas_price distribution to coinbase/vaults with
  conservation law (sender debit == sum of all credits)
…l witness inclusion

- Use block.header.gas_used for per-tx gas computation instead of fixed
  constants (WITHDRAWAL_GAS=100k vs actual EVM gas=95,002), fixing the
  00e SP1 proof verification failure on withdrawal/transfer batches
- Only include withdrawal accounts (BURN_ADDRESS, L2_TO_L1_MESSENGER)
  and gas fee accounts (coinbase, fee vaults) in witness analysis when
  the batch actually contains those transaction types, preventing trie
  traversal errors on empty batches
- Skip L1 commits for empty batches (no txs, no messages) after batch 1

E2E validated: all 3 batch types (empty, deposit, withdrawal+transfer)
proved and verified on L1 without 00e errors.
Empty batches (only empty blocks, no transactions or messages) can now
be verified on L1 without generating a ZK proof, saving ~3 minutes of
proving time per empty batch.

Changes:
- OnChainProposer.sol: add _isEmptyBatch() check in verifyBatch() to
  skip SP1/RISC0/TDX proof verification for empty batches; exempt empty
  commits from blob requirement in commitBatch()
- l1_committer.rs: fast-forward empty blocks in batch assembly without
  consuming blob space; send EIP-1559 (no blob) tx for empty batches
- l1_proof_sender.rs: detect empty batches and send proof-free
  verifyBatch instead of waiting for prover
- batch.rs: add Batch::is_empty_batch() helper with 7 unit tests
- store.rs: expose get_non_privileged_transactions_by_batch()
- docs/design/empty-batch-optimization.md: design document
- Use block header state_root directly for empty blocks instead of
  checkpoint store lookup (which didn't have empty blocks registered)
- Register empty blocks in checkpoint store with empty account updates
  so forkchoice_update can find them
- Skip witness generation for empty batches (seal_batch instead of
  seal_batch_with_prover_input)
- Skip blob_gas_used metrics check for empty batch EIP-1559 commits
- Fix false-positive empty batch detection in proof sender: check all
  5 conditions (non_priv_tx, l1_in_hash, l1_out_msgs, balance_diffs,
  l2_in_msgs) instead of only non_privileged_transactions == 0
Add mint, spend, liquidate, convertNote, makeOrder, takeOrder, and
settleOrder operations to the DexCircuit, matching the ZkDex Solidity
contract's state transitions exactly.

New files:
- storage.rs: slot computation for notes, orders, encryptedNotes
- events.rs: NoteStateChange, OrderTaken, OrderSettled log generation
- notes.rs: mint/spend/liquidate/convertNote execution
- orders.rs: makeOrder/takeOrder/settleOrder execution + RLP decoder

Modified:
- circuit.rs: ABI selectors, calldata parsing, routing for 8 ops
- mod.rs: witness analyzer for all operation storage slots
Zena-park and others added 19 commits March 4, 2026 08:31
Single app chain only needs Vanilla integration test.
Re-enable TDX via vars.ENABLE_TDX_TEST = 'true'.
Enable via GitHub Settings > Variables:
- ENABLE_VALIDIUM_TEST=true
- ENABLE_WEB3SIGNER_TEST=true
- ENABLE_BASED_TEST=true
- ENABLE_TDX_TEST=true
- ENABLE_SHARED_BRIDGE_TEST=true
Disabled on pull_request (kept workflow_dispatch for manual runs):
- PR Status (lambdaclass project tracking)
- PR Lines of Code Analysis
- Benchmark Block execution
- Benchmark LEVM vs REVM
- Perf Changelog
- L2 TDX build
When all matrix items are excluded (enabled: false), the job is not created.
Changed gate job to only fail if job ran and failed, not when skipped.
GitHub Actions does not support `exclude` with `include`-only matrices.
The exclude pattern caused the matrix job to fail silently, breaking
the Integration Test L2 gate job. Comment out disabled variants instead.
…rehensive caching

- Remove all --test-threads=1 flags (enable parallel test execution)
- Add Rust build cache to integration-test-tdx and state-diff-test jobs
- Remove duplicate cache entry in state-diff-test
- Enable parallel tests in shared-bridge job (for future use)

Expected speedup:
- First run: 1h50m → ~50-60min (70% reduction via caching + parallelization)
- Cached runs: ~20-30min (full cache hits)

Context:
- Vanilla-only matrix already active (75% fewer variants)
- fail-fast: true already enabled in relevant jobs
- Combined with previous caching optimizations
Docker Compose uses tokamak-app-* container names:
- ethrex_l2 → tokamak-app-l2
- ethrex_l1 → tokamak-app-l1

Fixed in:
- integration-test (Vanilla)
- integration-test-tdx

Existing optimizations:
- Rust cache added (70% faster builds)
- fail-fast enabled
- --test-threads removed (parallel execution)
- Vanilla only (other variants disabled)
Removed stray ]; then...fi block after commented shared-bridge check.
This was causing: 'did not find expected key' YAML parse error at line 999.

Fixes job 65691595733
Add "Invalid Missing Ancestor Syncing ReOrg, Transaction Value,
EmptyTxs=False, CanonicalReOrg=True, Invalid P9" to the known-flaky
tests list. This is the same test family already allowlisted but with
the CanonicalReOrg=True variant, which causes intermittent CI failures
due to hive framework timing issues.
feat(l2): add ZK-DEX circuit, E2E infrastructure, and Docker polish
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly advances the modularity and efficiency of L2 operations by introducing a new app-specific circuit execution framework. This framework allows specialized guest programs to perform state transitions in native Rust, bypassing the overhead of a full EVM interpreter. The ZK-DEX guest program has been refactored to utilize this new architecture, promising substantial performance gains in proving times. Additionally, optimizations for empty batches have been implemented to reduce unnecessary ZK proof generation and L1 gas costs, alongside various Docker and CI improvements to streamline development and testing workflows.

Highlights

  • App-Specific Circuit Execution Framework: Introduced a new modular framework for app-specific circuits, allowing guest programs like ZK-DEX to execute native Rust logic instead of a full EVM, significantly reducing proving time and resource usage.
  • ZK-DEX Guest Program Refactoring: Rewrote the ZK-DEX guest program to leverage the new app-specific circuit execution, optimizing its performance by focusing only on the necessary DEX operations and state transitions.
  • Empty Batch Optimization: Implemented an optimization for empty batches (those with no state-changing transactions or messages) on the L1 OnChainProposer contract and L2 committer/proof sender, allowing them to be verified without a ZK proof and exempting them from blob data requirements.
  • Docker and CI Enhancements: Improved Docker infrastructure for ZK-DEX E2E testing, including a dedicated SP1 prover image with GPU support, and fixed CI issues such as flaky Hive tests and container naming.
  • Guest Program Registry and Deployment: Added functionality to register guest programs and their verification keys on L1 during deployment, and introduced configuration options for specifying guest programs in the sequencer and prover.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .dockerignore
    • Added .git/ to the ignore list for Docker builds.
  • .github/scripts/check-hive-results.sh
    • Expanded the list of known flaky Hive tests to be ignored.
  • .gitignore
    • Added new entries for ZK-DEX localnet runtime, Next.js build output, SP1 guest program build artifacts, SQLite WAL/SHM files, and generated L2 config files.
  • Cargo.lock
    • Updated dependencies to include ethrex-trie and secp256k1.
    • Updated bls12_381 source and removed an unused patch.
  • Dockerfile
    • Removed direct copying of the .git directory and introduced VERGEN_GIT_SHA and VERGEN_GIT_BRANCH environment variable fallbacks for Git information.
  • Dockerfile.sp1
    • Added a new Dockerfile for building an SP1 ZK-DEX prover image with GPU support, including SP1 toolchain installation and guest program build steps.
  • cmd/ethrex/build.rs
    • Modified the build script to use environment variables as a fallback for Git branch and SHA in Docker builds, preventing build failures when the .git directory is absent.
  • cmd/ethrex/initializers.rs
    • Refactored database initialization logic to improve error handling when RocksDB feature is not enabled.
  • cmd/ethrex/l2/deployer.rs
    • Introduced new command-line options for registering guest programs and specifying SP1 verification key paths.
    • Implemented logic to register guest programs in the GuestProgramRegistry and set up their SP1 verification keys on L1.
  • cmd/ethrex/l2/options.rs
    • Added a guest_program_id option to ProofCoordinatorOptions to specify which guest program to assign to batches.
    • Added a programs_config option to ProverClientOptions for configuring guest programs via a TOML file.
  • crates/common/types/l2/batch.rs
    • Added an is_empty_batch method to determine if a batch contains no state-changing transactions or messages.
  • crates/guest-program/Cargo.toml
    • Added ethrex-trie as a dependency.
  • crates/guest-program/bin/openvm/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/guest-program/bin/risc0/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/guest-program/bin/sp1-tokamon/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/guest-program/bin/sp1-tokamon/src/main.rs
    • Added cycle-tracker-report print statements to measure execution phases.
  • crates/guest-program/bin/sp1-zk-dex/Cargo.lock
    • Updated bls12_381 source and removed an unused patch.
  • crates/guest-program/bin/sp1-zk-dex/Cargo.toml
    • Added ethrex-common and various sp1-patches dependencies for cryptographic primitives.
  • crates/guest-program/bin/sp1-zk-dex/src/main.rs
    • Rewrote the ZK-DEX guest program to use the new app-specific circuit execution framework, replacing the previous keccak-based execution.
  • crates/guest-program/bin/sp1/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/guest-program/bin/zisk/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/guest-program/build.rs
    • Refactored SP1 guest program build logic into a generic build_sp1_guest_program function.
  • crates/guest-program/src/common/app_execution.rs
    • Added a new module defining the AppCircuit trait and the execute_app_circuit function for app-specific circuit execution.
  • crates/guest-program/src/common/app_state.rs
    • Added a new module for in-circuit state management, tracking accounts and storage slots based on Merkle proofs.
  • crates/guest-program/src/common/app_types.rs
    • Added a new module defining AppProgramInput, AccountProof, and StorageProof structures for app-specific circuits.
  • crates/guest-program/src/common/handlers/constants.rs
    • Added a new module defining constants for system contract addresses, event topics, and gas costs.
  • crates/guest-program/src/common/handlers/deposit.rs
    • Added a new module for handling privileged (deposit) transactions.
  • crates/guest-program/src/common/handlers/eth_transfer.rs
    • Added a new module for handling simple ETH transfers.
  • crates/guest-program/src/common/handlers/gas_fee.rs
    • Added a new module for applying gas fee distribution, replicating L2 hook logic.
  • crates/guest-program/src/common/handlers/mod.rs
    • Added a new module to export common transaction handlers.
  • crates/guest-program/src/common/handlers/system_call.rs
    • Added a new module for handling system contract calls.
  • crates/guest-program/src/common/handlers/withdrawal.rs
    • Added a new module for handling L2 to L1 withdrawal transactions.
  • crates/guest-program/src/common/incremental_mpt.rs
    • Added a new module for incremental Merkle Patricia Trie operations, including proof verification and state root computation.
  • crates/guest-program/src/common/input_converter.rs
    • Added a new module for converting a full ProgramInput into an AppProgramInput by extracting relevant Merkle proofs.
  • crates/guest-program/src/common/mod.rs
    • Updated to include new common modules for app-specific circuit execution.
  • crates/guest-program/src/l2/mod.rs
    • Changed visibility of blobs, messages, and output modules to pub(crate).
  • crates/guest-program/src/programs/zk_dex/DEV.md
    • Added new development documentation for the ZK-DEX full circuit.
  • crates/guest-program/src/programs/zk_dex/circuit.rs
    • Added a new module defining the DexCircuit, implementing the AppCircuit trait for ZK-DEX operations.
  • crates/guest-program/src/programs/zk_dex/events.rs
    • Added a new module for generating EVM-compatible event logs for ZK-DEX operations.
  • crates/guest-program/src/programs/zk_dex/execution.rs
    • Removed the previous keccak-based execution logic.
  • crates/guest-program/src/programs/zk_dex/mod.rs
    • Updated module declarations to reflect the new app-specific circuit structure and added a witness analyzer function.
  • crates/guest-program/src/programs/zk_dex/notes.rs
    • Added a new module for note-related operations (mint, spend, liquidate, convertNote) in the ZK-DEX circuit.
  • crates/guest-program/src/programs/zk_dex/orders.rs
    • Added a new module for order-related operations (makeOrder, takeOrder, settleOrder) in the ZK-DEX circuit.
  • crates/guest-program/src/programs/zk_dex/storage.rs
    • Added a new module for computing storage slots for ZkDex contract mappings and dynamic arrays.
  • crates/guest-program/src/programs/zk_dex/types.rs
    • Removed the previous DexProgramInput and DexProgramOutput types.
  • crates/guest-program/src/traits.rs
    • Modified the serialize_input_never_panics_on_arbitrary_bytes test to correctly reflect the new input serialization behavior of ZkDexGuestProgram.
  • crates/l2/.zk-dex-deployed.env
    • Added a new file to store ZK-DEX deployed environment variables.
  • crates/l2/Makefile
    • Added new Makefile targets for ZK-DEX localnet, Docker E2E, Docker Tools, and generic guest program initialization.
  • crates/l2/contracts/src/l1/OnChainProposer.sol
    • Modified commitBatch to exempt empty batches from blob data requirements.
    • Removed the publicValuesHash check for custom programs in verifyBatch.
    • Made verifyBatch external without onlyOwner restriction.
    • Added internal functions _isEmptyBatch and _hasNoStateChangingTransactions for empty batch auto-verification.
  • crates/l2/contracts/src/l1/Timelock.sol
    • Added a new upgradeVerificationKey function to register verification keys for guest programs.
  • crates/l2/contracts/src/l1/based/OnChainProposer.sol
    • Updated error messages for program not active and custom program publicValuesHash mismatch.
  • crates/l2/contracts/src/l1/interfaces/ITimelock.sol
    • Added upgradeVerificationKey to the ITimelock interface.
  • crates/l2/docker-compose-guest-program.overrides.yaml
    • Added a new Docker Compose override file for initializing guest programs.
  • crates/l2/docker-compose-l2-shared-bridge.overrides.yaml
    • Renamed container names from ethrex_l1 and contract_deployer to tokamak-app-l1 and tokamak-app-deployer respectively.
    • Updated ETHREX_ETH_RPC_URL to point to tokamak-app-l1.
  • crates/l2/docker-compose-l2-store.overrides.yaml
    • Renamed ethrex_l2 service to tokamak-app-l2.
  • crates/l2/docker-compose-l2-tdx.yaml
    • Renamed ethrex_l2 service to tokamak-app-l2.
  • crates/l2/docker-compose-l2-web3signer.yaml
    • Renamed ethrex_l2 service to tokamak-app-l2.
  • crates/l2/docker-compose-zk-dex-gpu.overrides.yaml
    • Added a new Docker Compose override file for NVIDIA GPU acceleration for SP1 prover in ZK-DEX E2E.
  • crates/l2/docker-compose-zk-dex-tools.yaml
    • Added a new Docker Compose file for ZK-DEX support tools including Blockscout, Bridge UI, and Dashboard.
  • crates/l2/docker-compose-zk-dex.overrides.yaml
    • Added a new Docker Compose override file for ZK-DEX E2E with SP1 real ZK proofs.
  • crates/l2/docker-compose.yaml
    • Renamed all ethrex_* services to tokamak-app_* for consistency.
    • Updated RPC URLs to reflect new service names.
    • Added ETHREX_GUEST_PROGRAM_ID environment variable to tokamak-app-l2.
  • crates/l2/programs-zk-dex.toml
    • Added a new program configuration file specifically for ZK-DEX, setting it as the default and only enabled program.
  • crates/l2/programs.toml
    • Added a new general program configuration file, enabling evm-l2, zk-dex, and tokamon programs.
  • crates/l2/prover/Cargo.toml
    • Added ethrex-trie, ethrex-crypto, and secp256k1 as dependencies.
    • Added sp1_benchmark binary.
  • crates/l2/prover/src/bin/sp1_benchmark.rs
    • Added a new binary for benchmarking SP1 guest program performance, including input generation for zk-dex and tokamon.
  • crates/l2/prover/src/registry.rs
    • Updated zk_dex_circuit_through_registry test to reflect the new AppCircuit implementation and program_type_id.
    • Modified serialize_input test to expect an error for invalid rkyv bytes due to new input conversion logic.
  • crates/l2/scripts/ZK-DEX-LOCALNET.md
    • Added new documentation for ZK-DEX localnet setup.
  • crates/l2/scripts/zk-dex-docker.sh
    • Added a new script for setting up and managing the ZK-DEX Docker localnet environment.
  • crates/l2/scripts/zk-dex-localnet.sh
    • Added a new script for setting up and managing the ZK-DEX localnet environment.
  • crates/l2/sequencer/configs.rs
    • Added guest_program_id field to ProofCoordinatorConfig.
  • crates/l2/sequencer/l1_committer.rs
    • Added has_pending_withdrawals function to trigger early batch commits.
    • Implemented empty block fast-forward logic to skip heavy processing for empty blocks.
    • Modified send_commitment to handle empty batches without requiring blob data.
  • crates/l2/sequencer/l1_proof_sender.rs
    • Implemented empty batch auto-verification, allowing proof-free verification for truly empty batches.
  • crates/l2/sequencer/proof_coordinator.rs
    • Modified to store program_id early for L1 committer lookup.
    • Updated logic to handle empty/genesis batches by sending an empty_batch_response.
  • crates/l2/storage/src/store.rs
    • Added get_non_privileged_transactions_by_batch method.
  • crates/l2/tee/quote-gen/Cargo.lock
    • Updated ethrex-trie dependency.
  • crates/l2/tooling/bridge/Dockerfile
    • Added a new Dockerfile for the ZK-DEX bridge UI.
  • crates/l2/tooling/bridge/dashboard.html
    • Added a new HTML file for the ZK-DEX localnet dashboard.
  • crates/l2/tooling/bridge/entrypoint.sh
    • Added a new entrypoint script for the ZK-DEX bridge UI, generating config.json from environment variables.
  • crates/l2/tooling/bridge/index.html
    • Added a new HTML file for the ZK-DEX bridge UI.
  • crates/l2/tooling/bridge/withdraw-status.html
    • Added a new HTML file for the ZK-DEX withdrawal status tracker.
  • docs/design/empty-batch-optimization.md
    • Added a new design document detailing the empty batch optimization for ZK proof-free verification.
  • docs/developers/l2/prover.md
    • Updated documentation to refer to data_dir instead of datadir.
  • docs/l2/deployment/gp-store-guide.md
    • Added a new guide for launching L2s using the Guest Program Store.
  • docs/l2/fundamentals/based.md
    • Updated the GitHub link for ethrex.
  • platform/client/app/admin/page.tsx
    • Updated 'Deployments' to 'L2s' in the admin page.
  • platform/client/app/deployments/[id]/page.tsx
    • Updated terminology from 'Deployment' to 'L2'.
    • Added functionality to download programs.toml and a quick start README.
    • Updated the quick start guide to reflect new Docker commands.
  • platform/client/app/deployments/page.tsx
    • Updated terminology from 'Deployments' to 'L2s' and 'Browse Programs' to 'Launch New L2'.
  • platform/client/app/guide/page.tsx
    • Added a new guide page for L2 setup instructions.
  • platform/client/app/launch/page.tsx
    • Added a new page for launching L2s, including program selection and configuration steps.
  • platform/client/app/page.tsx
    • Updated homepage text and links to reflect 'Launch L2' and 'Browse Store' actions.
    • Revised 'How it works' section to align with the new L2 launch platform flow.
  • platform/client/app/profile/page.tsx
    • Updated terminology from 'Deployments' to 'L2s' and 'Create New Program' to 'Launch L2' in the profile page.
  • platform/client/app/store/[id]/page.tsx
    • Modified the 'Use This Program' button to link to the new /launch page instead of showing a modal.
  • platform/client/components/nav.tsx
    • Added a 'Launch L2' link to the navigation bar and updated 'Deployments' to 'My L2s'.
  • platform/client/lib/api.ts
    • Added a 'config' field to the deployment creation API for custom deployment configurations.
  • platform/server/db/db.js
    • Added uuid import and seedOfficialPrograms call to initialize official guest programs in the database.
  • platform/server/db/deployments.js
    • Modified getDeploymentById to join with the programs table, retrieving program_name, program_slug, and category.
  • platform/server/routes/deployments.js
    • Added 'config' field to deployment creation route.
  • scripts/generate-zk-dex-genesis.sh
    • Added a new script to generate L2 genesis JSON with ZkDex contracts pre-deployed.
  • scripts/new-guest-program.sh
    • Added sed_inplace helper for cross-platform sed compatibility.
  • tokamak-notes/ethrex-l1-devnet-limitations.md
    • Added a new document analyzing JSON-RPC limitations and workarounds for ethrex L1 Devnet.
  • tokamak-notes/guest-program-modularization/09-l2-launch-platform.md
    • Added a new document outlining the GP Store L2 launch platform and its architecture.
  • tokamak-notes/guest-program-modularization/10-sp1-performance-comparison.md
    • Added a new document comparing SP1 proving performance between evm-l2 and zk-dex guest programs.
  • tokamak-notes/guest-program-modularization/11-app-specific-circuit-design.md
    • Added a new design document for app-specific circuits, focusing on lightweight proving without a full EVM.
  • tokamak-notes/guest-program-modularization/12-app-specific-circuit-dev-plan.md
    • Added a new development plan document for app-specific circuits.
  • tokamak-notes/guest-program-modularization/13-zkdex-genesis-deployment.md
    • Added a new document detailing the ZK-DEX L2 genesis deployment process and rationale.
  • tokamak-notes/sp1-zk-dex-infra-cost-analysis.md
    • Added a new document analyzing the infrastructure cost for SP1 ZK-DEX, focusing on L2 sequencer hosting strategies.
Ignored Files
  • Ignored by pattern: .github/workflows/** (8)
    • .github/workflows/pr-main_l2.yaml
    • .github/workflows/pr-main_l2_tdx_build.yaml
    • .github/workflows/pr-main_mdbook.yml
    • .github/workflows/pr_github_status_l1.yaml
    • .github/workflows/pr_loc.yaml
    • .github/workflows/pr_perf_blocks_exec.yaml
    • .github/workflows/pr_perf_changelog.yml
    • .github/workflows/pr_perf_levm.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-designed architectural change to support modular guest programs, moving away from a monolithic EVM execution model for specialized L2s. The implementation of the AppCircuit framework is clean and provides a solid foundation for future app-specific chains. The refactoring of the ZK-DEX program to use this new framework is a great showcase of its capabilities.

I've also noted several key optimizations, including the proof-free verification of empty batches and the early commitment of batches containing withdrawals, which will significantly improve the efficiency and user experience of the L2. The extensive additions to Docker and local testing infrastructure are also valuable contributions.

My review includes a few suggestions for improvement, mainly around code duplication and potential performance optimizations for future consideration. Overall, this is an excellent set of changes that greatly enhances the project's flexibility and performance.

Note: Security Review did not run due to the size of the PR.

…_balance_diffs

get_balance_diffs() was updated to require a second parameter
(native_token_scale_factor: Option<U256>) but this call site in
app_execution.rs was not updated, causing compilation failure in all
lint CI jobs.
…type_id

- RLP decoder errors now include specific failure reasons (e.g.,
  "insufficient data for length prefix", "length exceeds data bounds")
  instead of generic "invalid RLP encoding" messages.

- Consolidate duplicated resolve_program_type_id() from deployer.rs
  and l1_committer.rs into ethrex_l2_common as the single source of
  truth for program type ID mapping.
@Zena-park Zena-park merged commit d99df3e into feat/app-customized-framework Mar 4, 2026
43 of 44 checks passed
@Zena-park Zena-park deleted the pr/zk/02-circuit-framework branch March 7, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant