Skip to content

feat: Bridge guest program with AppCircuit-based lightweight ZK proof#71

Merged
Zena-park merged 5 commits intofeat/app-customized-frameworkfrom
feat/launch-multi-program
Mar 23, 2026
Merged

feat: Bridge guest program with AppCircuit-based lightweight ZK proof#71
Zena-park merged 5 commits intofeat/app-customized-frameworkfrom
feat/launch-multi-program

Conversation

@Zena-park
Copy link
Copy Markdown
Member

Summary

  • Add bridge-dedicated guest program using execute_app_circuit instead of full EVM execution_program
  • Bridge handles only deposits, withdrawals, and ETH transfers via common handlers — no app-specific operations
  • ARM64 (Apple Silicon) Docker image support for local development

Performance (benchmarked)

evm-l2 bridge Improvement
ELF size 4.1 MB 863 KB 4.7x smaller
Execution cycles 22,000,000+ 983,945 22x fewer
Proof time ~20 min 238s (4 min) 5x faster

Full flow verified

  1. L1→L2 deposit 1 ETH ✅
  2. L2→L1 withdraw 0.1 ETH ✅
  3. SP1 proof generation (983K cycles) ✅
  4. L1 batch verification ✅
  5. L1 claim withdrawal (+0.1 ETH) ✅

Files changed

  • crates/guest-program/src/programs/bridge/ — BridgeCircuit, analyze, GuestProgram impl
  • crates/guest-program/bin/sp1-bridge/ — SP1 zkVM entry point
  • crates/guest-program/build.rs — bridge ELF build support
  • crates/l2/prover/ — bridge program registry
  • crates/l2/common/ — bridge typeId mapping (4)
  • crates/desktop-app/local-server/lib/compose-generator.js — auto-register from programs.toml
  • GUEST_PROGRAM_GUIDE.md — full guide for adding new guest programs

Test plan

  • cargo build --release --features l2,sp1 with GUEST_PROGRAMS=bridge
  • Docker compose deploy (L1 + deployer + L2 + prover)
  • Deposit + withdraw + SP1 proof + L1 verify + L1 claim
  • Unit tests for analyze_bridge_transactions

🤖 Generated with Claude Code

Zena-park and others added 4 commits March 22, 2026 14:11
Add linux/arm64 platform to multi-arch build so pre-built images
work natively on Apple Silicon Macs without amd64 emulation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…roof

Bridge guest program uses execute_app_circuit instead of full EVM execution,
reducing proof cycles from 22M+ to ~1M (22x faster). Only handles deposits,
withdrawals, and ETH transfers via common handlers.

Key changes:
- bridge/circuit.rs: BridgeCircuit (no app-specific operations)
- bridge/analyze.rs: Transaction analysis for needed accounts/storage
- bridge/mod.rs: serialize_input converting ProgramInput → AppProgramInput
- sp1-bridge/main.rs: Uses execute_app_circuit instead of execution_program
- build.rs: Bridge ELF build support via sp1_build
- compose-generator: Auto-register bridge programs from programs.toml
- prover: Bridge program in registry with typeId=4

Tested: deposit 1 ETH, withdraw 0.1 ETH, SP1 proof in 238s (4 min),
L1 batch verification successful.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…benchmarks

Add AppCircuit pattern documentation, Cargo.lock sync requirement,
analyze pattern rules (witness-safe account collection), and real
performance comparison (evm-l2 vs zk-dex vs bridge).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove unused ethrex-vm dependency from sp1-bridge Cargo.toml
- Add error propagation for tx.sender() failure in analyze (was silent skip)
- Add version() override returning "0.1.0"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tokamak-appchain Ready Ready Preview, Comment Mar 23, 2026 6:58am

@Zena-park Zena-park added the skip-ci Skip CI checks on this PR label Mar 23, 2026
@Zena-park Zena-park requested a review from Copilot March 23, 2026 06:23
@Zena-park Zena-park changed the base branch from main to feat/app-customized-framework March 23, 2026 06:24
@Zena-park
Copy link
Copy Markdown
Member Author

/gemini review

@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 introduces a new bridge guest program leveraging AppCircuit-based lightweight ZK proofs, significantly improving performance compared to the existing evm-l2 program. It also enhances the deployment process with new features and options, including ARM64 Docker image support and L1 contract deployment for guest program registration. Several files were modified across different crates to implement these changes, and a comprehensive test plan was executed to verify the functionality.

Highlights

  • Bridge Guest Program: Introduces a bridge-dedicated guest program using execute_app_circuit, offering a more lightweight ZK proof mechanism compared to full EVM execution.
  • Performance Improvements: Achieves significant performance gains, including a 4.7x smaller ELF size, 22x fewer execution cycles, and 5x faster proof time compared to the evm-l2 program.
  • Docker Image Support: Adds ARM64 (Apple Silicon) Docker image support for local development, enhancing accessibility for developers using Apple Silicon Macs.
  • L1 Contract Deployment: Adds GuestProgramRegistry contract deployment and initialization to L1, including support for registering guest programs and setting up verification keys.
  • Deployer Enhancements: Improves the deployer with options to override the L2 chain ID, register guest programs, and specify the ZK-DEX SP1 verification key path.
Ignored Files
  • Ignored by pattern: .github/workflows/** (23)
    • .github/workflows/build-desktop.yml
    • .github/workflows/build-docker-images.yml
    • .github/workflows/main_prover.yaml
    • .github/workflows/pr-main_l1.yaml
    • .github/workflows/pr-main_l1_l2_dev.yaml
    • .github/workflows/pr-main_l2.yaml
    • .github/workflows/pr-main_l2_prover.yaml
    • .github/workflows/pr-main_l2_tdx_build.yaml
    • .github/workflows/pr-main_levm.yaml
    • .github/workflows/pr-main_mdbook.yml
    • .github/workflows/pr_check_l2_genesis.yml
    • .github/workflows/pr_fixture_tests.yml
    • .github/workflows/pr_github_metadata.yaml
    • .github/workflows/pr_github_status_l1.yaml
    • .github/workflows/pr_lint_gha.yaml
    • .github/workflows/pr_lint_license.yaml
    • .github/workflows/pr_lint_readme.yaml
    • .github/workflows/pr_loc.yaml
    • .github/workflows/pr_perf_blocks_exec.yaml
    • .github/workflows/pr_perf_build_block_bench.yml
    • .github/workflows/pr_perf_changelog.yml
    • .github/workflows/pr_perf_levm.yaml
    • .github/workflows/pr_upgradeability.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.

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 new lightweight ZK guest program for the bridge, which significantly improves performance by using a specialized AppCircuit instead of the full EVM execution. The benchmarks show impressive gains in proof generation time, execution cycles, and ELF size. The changes also include support for ARM64 Docker images for local development and a new dynamic loading mechanism for guest programs from the filesystem, which is a great enhancement for extensibility.

My review focuses on a few areas for improvement in the Docker Compose generator script and a minor documentation update. Specifically, I've suggested making the TOML parsing more robust, improving path handling for cross-platform compatibility, and updating a design document to reflect the final benchmarked performance improvements.

Overall, this is a solid pull request with significant performance benefits and valuable new features.

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 new lightweight ZK guest program for the bridge, which significantly improves performance. It also adds support for dynamically loading guest programs from the filesystem and improves Docker support for ARM64. The changes are well-structured and the new functionality is a great addition. My review focuses on improving the robustness and maintainability of the Docker Compose generation script, specifically around configuration parsing and error handling, and addressing code duplication.

- Log TOML parse errors instead of silently swallowing them
- Add source-of-truth comment for TYPE_IDS referencing crates/l2/common/src/lib.rs
- Use path.join() for cross-platform path construction
- Update design doc with actual benchmark results (863KB ELF, 983K cycles)
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Zena-park Zena-park merged commit 2d0def3 into feat/app-customized-framework Mar 23, 2026
32 of 33 checks passed
@Zena-park Zena-park deleted the feat/launch-multi-program branch March 23, 2026 07:26
@Zena-park Zena-park restored the feat/launch-multi-program branch March 23, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-ci Skip CI checks on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants