Skip to content

chore(l2): docker and production polish#9

Closed
Zena-park wants to merge 16 commits intopr/zk/03-zk-dex-e2efrom
pr/zk/04-docker-polish
Closed

chore(l2): docker and production polish#9
Zena-park wants to merge 16 commits intopr/zk/03-zk-dex-e2efrom
pr/zk/04-docker-polish

Conversation

@Zena-park
Copy link
Copy Markdown
Member

@Zena-park Zena-park commented Mar 1, 2026

Summary

Final polish for Docker infrastructure and production readiness:

  • Docker tools stability: Improved build caching and fixed compilation errors
  • Withdrawal claim UI: On-chain claim status check in the withdrawal tracker
  • Rebrand Docker services: Renamed from ethrex to tokamak-app (TokamakAppL2)
  • Early batch commit optimization: Made conditional on prover idle state to avoid unnecessary commits
  • Infrastructure cost analysis: SP1 ZK-DEX infrastructure cost analysis documentation
  • Phase 4 documentation: Updated progress and E2E design docs

Dependencies

Part 4/4 of stacked PR series. Depends on #8 (ZK-DEX E2E).
Merge order: #6#7#8#9

Test plan

  • Verify Docker build caching produces correct images
  • Verify withdrawal claim UI shows correct on-chain status
  • Verify early batch commit only triggers when prover is idle
  • Verify Docker service names are consistently tokamak-app

@Zena-park Zena-park requested a review from jason-h23 March 1, 2026 11:40
@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 delivers a final polish to the Docker infrastructure and production readiness aspects of the project. It streamlines Docker builds, standardizes branding across services and user interfaces, and significantly enhances the user experience for withdrawals by providing real-time on-chain status and an interactive claim process. Additionally, it optimizes batch commitment logic to be more responsive to user actions while maintaining system efficiency, and introduces critical documentation for infrastructure planning and development awareness.

Highlights

  • Docker Infrastructure Polish: Improved Docker build caching by ignoring the .git directory and implemented fallback environment variables for Git information in Docker builds, enhancing stability and reproducibility.
  • Service Rebranding: Renamed all Docker services and UI elements from 'ethrex' to 'TokamakAppL2 ZK-DEX' across various Docker Compose files, scripts, and web interfaces for consistent branding.
  • Withdrawal Claim UI Enhancement: Introduced a comprehensive withdrawal tracker UI that displays on-chain claim status, including commit/verify timestamps and transaction hashes, and provides a 'Claim Withdrawal' button with MetaMask integration.
  • Early Batch Commit Optimization: Implemented a conditional early batch commit mechanism that triggers immediate batch submission if pending withdrawals are detected and the prover is currently idle, reducing withdrawal latency without overloading the prover.
  • New Documentation: Added detailed documentation covering SP1 ZK-DEX infrastructure cost analysis and identified limitations of the ethrex L1 devnet, providing valuable insights for deployment and development.

🧠 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 to improve Docker build caching.
  • Dockerfile
    • Removed copying of the .git directory and introduced VERGEN_GIT_SHA and VERGEN_GIT_BRANCH environment variables as fallbacks for Git information.
  • Dockerfile.sp1
    • Removed copying of the .git directory and introduced VERGEN_GIT_SHA and VERGEN_GIT_BRANCH environment variables as fallbacks for Git information.
  • cmd/ethrex/build.rs
    • Modified the build script to conditionally use VERGEN_GIT_BRANCH and VERGEN_GIT_SHA environment variables for Git information when building in a Docker environment without a .git directory.
  • cmd/ethrex/initializers.rs
    • Updated the open_store function to explicitly require the 'rocksdb' feature if not using an in-memory store, adding a compile-time error for clarity.
  • crates/l2/.zk-dex-deployed.env
    • Added a new file to store deployed ZK-DEX contract addresses as environment variables.
  • crates/l2/docker-compose-guest-program.overrides.yaml
    • Renamed Docker service 'ethrex_l2' to 'tokamak-app-l2' and 'ethrex_prover' to 'tokamak-app-prover', updating internal references.
  • crates/l2/docker-compose-l2-shared-bridge.overrides.yaml
    • Renamed Docker services 'contract_deployer' to 'tokamak-app-deployer', 'ethrex_l2' to 'tokamak-app-l2', and 'ethrex_l2_b' to 'tokamak-app-l2-b', updating internal references.
  • crates/l2/docker-compose-l2-store.overrides.yaml
    • Renamed Docker service 'ethrex_l2' to 'tokamak-app-l2'.
  • crates/l2/docker-compose-l2-tdx.yaml
    • Renamed Docker service 'ethrex_l2' to 'tokamak-app-l2' and updated comments.
  • crates/l2/docker-compose-l2-web3signer.yaml
    • Renamed Docker service 'ethrex_l2' to 'tokamak-app-l2'.
  • crates/l2/docker-compose-zk-dex-gpu.overrides.yaml
    • Renamed Docker service 'ethrex_prover' to 'tokamak-app-prover'.
  • crates/l2/docker-compose-zk-dex-tools.yaml
    • Added 'restart: unless-stopped' policy to Blockscout backend services, disabled internal transactions and empty blocks sanitizer for indexers, and rebranded network names in UI environment variables to 'TokamakAppL2 ZK-DEX L1/L2'.
  • crates/l2/docker-compose-zk-dex.overrides.yaml
    • Renamed Docker services 'contract_deployer' to 'tokamak-app-deployer', 'ethrex_l2' to 'tokamak-app-l2', and 'ethrex_prover' to 'tokamak-app-prover', updating internal references.
  • crates/l2/docker-compose.yaml
    • Renamed Docker services 'ethrex_l1' to 'tokamak-app-l1', 'contract_deployer' to 'tokamak-app-deployer', 'ethrex_l2' to 'tokamak-app-l2', and 'ethrex_prover' to 'tokamak-app-prover', updating internal references.
  • crates/l2/scripts/zk-dex-docker.sh
    • Updated service names in start and log commands to reflect the rebranding and modified the logic for extracting deployed contract addresses.
  • crates/l2/sequencer/l1_committer.rs
    • Imported get_last_verified_batch and implemented conditional early batch commit logic to trigger immediate batch submission if withdrawals are pending and the prover is idle.
  • crates/l2/tooling/bridge/dashboard.html
    • Rebranded the dashboard title and logo from 'ethrex' to 'TokamakAppL2 ZK-DEX', updated network names, and added sections for L2 Genesis System and ZK-DEX contracts.
  • crates/l2/tooling/bridge/index.html
    • Rebranded the bridge UI title from 'ethrex' to 'TokamakAppL2 ZK-DEX'.
  • crates/l2/tooling/bridge/withdraw-status.html
    • Rebranded the withdrawal tracker title from 'ethrex' to 'TokamakAppL2 ZK-DEX', added new CSS for claim status, implemented a 'Claim Withdrawal' section with on-chain status checks, and enhanced withdrawal detail display with commit/verify timestamps and transaction links.
  • tokamak-notes/ethrex-l1-devnet-limitations.md
    • Added a new document detailing limitations of the ethrex L1 devnet, including issues with eth_getBalance, debug_traceTransaction, and eth_getLogs, and comparing it with Anvil and Geth.
  • tokamak-notes/local-setup-guide.md
    • Updated the local setup guide to include a --no-build option for Docker, clarified Docker build caching, added details on L1 verification gas costs and batch behavior, and included the new Withdrawal Tracker URL.
  • tokamak-notes/sp1-zk-dex-infra-cost-analysis.md
    • Added a new document analyzing the infrastructure costs for hosting the SP1 ZK-DEX L2 sequencer, comparing various cloud providers and recommending cost-effective setups.
  • tokamak-notes/zk-dex-e2e-design.md
    • Updated the E2E design document to reflect completion of Phase 3 and Phase 4, detailed the 'Early Batch Commit' feature's background, design, implementation, and verification, and updated the branch reference.
  • tokamak-notes/zk-dex-progress.md
    • Updated the ZK-DEX progress document, marking Phase 4 (Docker Infra + Withdrawal UX Optimization) as complete, listing specific tasks accomplished, and updating the 'Remaining Tasks' section and branch reference.
Activity
  • This pull request is the final part (Part 4/4) of a stacked PR series, building upon previous changes related to ZK-DEX E2E functionality.
  • The author has outlined a comprehensive test plan to verify Docker build caching, withdrawal claim UI accuracy, early batch commit behavior, and consistent Docker service naming.
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.

@Zena-park Zena-park changed the title chore(docker): Docker & Production Polish chore(l2): docker and production polish Mar 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026

🤖 Kimi Code Review

⚠️ Review failed: KIMI_API_KEY secret is not set


Automated review by Kimi (Moonshot AI)

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 significant rebranding from 'ethrex' to 'TokamakAppL2 ZK-DEX' across Docker Compose configurations, UI elements (dashboard, bridge, withdrawal tracker), and documentation. Key functional changes include optimizing Docker builds by ignoring the .git directory and providing fallback git information via environment variables for vergen. The L1 committer logic is enhanced to trigger early batch commits for withdrawals, but only if the prover is idle, preventing unnecessary load. The withdrawal tracker UI is substantially improved with a new claim section, detailed status tracking, and the ability to claim withdrawals directly. Additionally, Blockscout services are configured with restart policies and disabled heavy indexing for better dev environment performance. A new documentation file outlines limitations of the ethrex L1 devnet and suggests alternatives like Anvil. A review comment highlights a potential issue in l1_committer.rs where unwrap_or could mask errors in RPC calls, suggesting explicit error handling and logging. Another comment points out a Cross-Site Scripting (XSS) vulnerability in withdraw-status.html due to direct innerHTML usage with potentially untrusted data, recommending safer DOM manipulation methods.

@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 23759c9 to 2d33b67 Compare March 1, 2026 11:46
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 338d5b1 to 8a8b1be Compare March 1, 2026 11:46
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 2d33b67 to c0623ad Compare March 1, 2026 12:01
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 8a8b1be to 5ac4927 Compare March 1, 2026 12:01
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from c0623ad to 6e74d66 Compare March 1, 2026 12:04
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 5ac4927 to a40d336 Compare March 1, 2026 12:04
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 6e74d66 to 7ca60e6 Compare March 1, 2026 12:14
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from a40d336 to 680b4ed Compare March 1, 2026 12:14
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 7ca60e6 to c777815 Compare March 1, 2026 12:32
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 680b4ed to 6cce894 Compare March 1, 2026 12:32
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from c777815 to 56604ad Compare March 1, 2026 12:46
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 6cce894 to 7559477 Compare March 1, 2026 12:46
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 56604ad to ccf3106 Compare March 1, 2026 13:05
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 7559477 to 97dd77d Compare March 1, 2026 13:05
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from ccf3106 to 791d666 Compare March 1, 2026 13:19
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 97dd77d to 8eca51c Compare March 1, 2026 13:19
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 791d666 to 7611496 Compare March 1, 2026 13:57
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 8eca51c to 362182d Compare March 1, 2026 13:57
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
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).
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
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
…, and rebrand to TokamakAppL2

- Add restart policy and disable heavy Blockscout indexers for stability
- Rename network branding from ethrex to TokamakAppL2 ZK-DEX
- Add L2 genesis contract sections to dashboard
- Add claim withdrawal button and status tracking to withdraw-status page
- Include local deployed contract addresses (.zk-dex-deployed.env)
- Add Phase 4 timeline: early batch commit, Docker tools stability,
  withdrawal claim UI, TokamakAppL2 rebranding, infra cost analysis
- Update checklist with newly completed items
- Add withdrawal E2E test as next priority
- Update E2E design doc: Phase 3 completed, Phase 4 added
Only trigger early batch commit when a pending withdrawal is detected
AND no batch is waiting for proof verification (committed <= verified).
If the prover is busy, skip the early commit and fall back to the
normal timer-based commit cycle.

Also update progress and E2E design docs with detailed early batch
commit design (flow diagram, code, verification table).
- Check claimedWithdrawalIDs on L1 bridge to detect already-claimed
  withdrawals, even across browser sessions
- Query WithdrawalClaimed events for claim TX hash and timestamp
- Extract showClaimedState() helper to reduce duplication
- Add 'finalized' status badge style for claimed withdrawals
- Remove COPY .git from Dockerfile and Dockerfile.sp1 to prevent
  cache invalidation on every commit; add VERGEN_GIT_SHA/BRANCH
  env var fallbacks for Docker builds without .git directory
- Add .git/ to .dockerignore
- Update cmd/ethrex/build.rs to support env var fallback for vergen
  git info (branch + SHA) in Docker builds
- Fix engine_type scope error in cmd/ethrex/initializers.rs by
  wrapping in proper #[cfg(feature = "rocksdb")] blocks
- Enhance withdrawal tracker with batch commit/verify timestamps,
  L1/L2 tx links, and on-chain claim status display
- Add ethrex L1 devnet limitations analysis document
- Update local-setup-guide with gas costs, batch behavior, env vars,
  and Docker caching troubleshooting
Rename all Docker Compose service and container names:
- ethrex_l1 → tokamak-app-l1
- ethrex_l2 → tokamak-app-l2
- contract_deployer → tokamak-app-deployer
- ethrex_prover → tokamak-app-prover

Also updates internal Docker network hostnames and script references.
@Zena-park Zena-park force-pushed the pr/zk/03-zk-dex-e2e branch from 7611496 to 7f2c47a Compare March 1, 2026 15:00
@Zena-park Zena-park force-pushed the pr/zk/04-docker-polish branch from 362182d to db37d1d Compare March 1, 2026 15:00
# Conflicts:
#	crates/guest-program/src/common/app_execution.rs
#	crates/guest-program/src/programs/zk_dex/circuit.rs
#	crates/guest-program/src/programs/zk_dex/mod.rs
#	crates/l2/contracts/src/l1/OnChainProposer.sol
#	crates/l2/prover/src/bin/sp1_benchmark.rs
- Remove duplicate import of compute_message_digests, get_batch_messages
- Remove dead code outside #[cfg(feature = "l2")] block in serialize_input
- Fix missing `fc` variable: iterate fee_configs for operator_fee_vault
- Add missing has_withdrawal/has_non_privileged assignments in witness analyzer
…it logic

Address Gemini Code Assist review: RPC failures in has_pending_withdrawals()
and get_last_verified_batch() were silently masked by unwrap_or fallbacks.
Now uses match with warn! logging so failures are visible in logs while
still safely skipping the early commit check.
@Zena-park Zena-park removed the request for review from jason-h23 March 2, 2026 23:32
@Zena-park
Copy link
Copy Markdown
Member Author

Closing: merging PR #3 and #4 into a combined PR for unified submission.

@Zena-park Zena-park closed this Mar 3, 2026
@Zena-park Zena-park deleted the pr/zk/04-docker-polish branch March 7, 2026 11:06
Zena-park added a commit that referenced this pull request Mar 16, 2026
…ntainability

- CORS: restrict origin to Tauri dev/prod allowlist (Copilot #1)
- open-url: use execFile with arg arrays instead of shell exec (Copilot #2)
- fs browse: restrict path traversal to home directory (Copilot #3)
- test-e2e-fork: move RPC URL to SEPOLIA_RPC_URL env var (Copilot #4)
- docker-remote: clear timeout on stream close, close stream on timeout (Copilot #5)
- docker-remote: add shell quoting (q()) and assertSafeName for all
  interpolated shell args to prevent injection (Copilot #6-8)
- genesis.rs: add ChainConfig::validate() for pre-startup checks (Copilot #9)
- listings.js: use named params (@id, @name, ...) instead of 30
  positional ? args for upsertListing (Gemini #1)
Zena-park added a commit that referenced this pull request Mar 17, 2026
- Return 503 instead of {exists:false} on check endpoint errors (#1)
- Sanitize all error messages — log internally, return generic to client (#2,#3,#4,#5)
- Add serverless rate limit limitation comment (#6)
- Add console.warn to all empty catch blocks in github-pr.ts (#9,#10,#11)
- Note: params as Promise is correct for Next.js 15 (#7,#8)
Zena-park added a commit that referenced this pull request Mar 17, 2026
* feat(platform): add appchain registry API routes to Next.js client

Port Express server appchain-registry endpoints to Next.js API routes
for Vercel deployment:
- GET /api/appchain-registry/check/[l1ChainId]/[stackType]/[identityAddress]
- POST /api/appchain-registry/submit
- GET /api/appchain-registry/status/[prNumber]

Shared logic in lib/appchain-registry.ts and lib/github-pr.ts.

* fix: address PR #67 code review feedback

- Return 503 instead of {exists:false} on check endpoint errors (#1)
- Sanitize all error messages — log internally, return generic to client (#2,#3,#4,#5)
- Add serverless rate limit limitation comment (#6)
- Add console.warn to all empty catch blocks in github-pr.ts (#9,#10,#11)
- Note: params as Promise is correct for Next.js 15 (#7,#8)

* fix: address additional Copilot PR #67 review feedback

- Add AbortSignal.timeout(15s) to all GitHub API fetch calls
- Fix authHeaders error message to list both accepted env vars
- Distinguish RPC errors (502) from permission denied (403) in ownership check
- Add typeof validation for metadata.signedBy
- Add unit test suggestion acknowledged (future work)
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