Skip to content

Conversation

@noel2004
Copy link
Member

@noel2004 noel2004 commented Jun 25, 2025

The last refactoring phase before Feynman

Some breaking changes on deployment has been induced:

  • For the config of prover, there can be multiple forks (after euclidV2) being specified under circuits, with separated workspace path for each. (There is no change for the layout inside workspace), for example:
{
  "circuits": {
    "euclidV2": {
      "hard_fork_name": "euclidV2",
      "workspace_path": "/workspace/euclid"
    },
    "feynmanV1": {
      "hard_fork_name": "feynmanV1",
      "workspace_path": "/workspace/feynman1"
    },
    "feynmanV2": {
      "hard_fork_name": "feynmanV2",
      "workspace_path": "/workspace/feynman2"
    }
  }
}
  • Currently only one set of stuffs for verifier would be loaded by coordinator, and it is expected to be compatible with all proofs generated from different circuits loaded by prover. The vk is no longer read from verifier stuff directly. Instead, we have to specify them under the asset path

  • The format of dumped vk file is used for vk specify, there can be multiple of them with names being specified under verifier field in the config file. Currently there can be only one vk set (for chunk/batch/bundle) for each hardfork phase

  • A utility has been added to prover to generate the corresponding vk file, for example, we can generate the vk file for euclidv2 phase being set by the config file above by following command:

prover --config config.json --forkname euclidv2 dump euclid.json

The generated euclid.json file would be like:

{
    "chunk_vk": "bq14DegWJXatu142361dX/qzxwZxk9lEMXh8AceWwDhmGOolp5kYRbvF/VcWcO5HN5ujGs6S00W8pZcCoNQRLQ==",
    "batch_vk": "ShuQOk3N3x84Qe1iiN/vAgnBegBM/ys6Ib5yWXRgLUTyvi9EaNGsSnDnaCurscYEF+IcdjPUtVtY9EcD7IKwWg==",
    "bundle_vk": "AhYAAAAABAAAAD2PumVP6pqldS0PKWW8Q4IvnE/rvtm5/2fXvG196sYhwoWi5H4McKnjcoiwkxtSOLUNBvs1q0ogwWe4x+9lUyENu8s47Xabxy0EViND1dzsu5HicdAWl0xG5C+VpO2faJdK4nGwtD4WHtbdqWY72nSY5aKSDxAYO85vLy+9cJZlCigGKHeuwjPQrj3o8XjzGDHYqCyOjMJggo2ZN+X7nh5uSWyZPNuozaLpcGG7WwjLVKxXlfrRFeKO86ZJ3m61Lcw8T9j5UXpHz3K/2yuVSXK6OvMG4/058TXG09qKgXYP"
}
  • There can be also multiple verifiers being loaded into coordinator, each with specified asset path respectively. Like following
{
"prover_manager":{
    "verifier": {
      "min_prover_version": "v4.5.25",
      "verifiers": [{
        "assets_path": "assets",
        "fork_name": "euclidV2"
      }]
    }
}}

The vk file (with default name as openVmVk.json) is put under assets_path, in additional with other stuffs being needed by a verifier

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a CLI subcommand to verify cryptographic proofs for different types and forks.
    • Introduced health listener address configuration for monitoring.
    • Provided new configuration files for circuit and VM parameters.
    • Added scripts and Makefile targets to automate downloading and building circuit executables.
  • Enhancements

    • Improved proof assignment logic to handle already assigned tasks more robustly.
    • Enhanced L2 block height synchronization, including a mockable syncer for testing.
    • Standardized verification key management, including caching and validation.
    • Refactored proof verification to use a universal verifier and improved concurrency safety.
    • Added lazy initialization and caching of verification keys in prover handlers.
    • Improved prover CLI with a new dump verification key command.
    • Introduced more robust metadata validation and error handling in proof tasks.
    • Enhanced prover task preparation with iterative error recovery for missing data.
    • Updated prover configuration to support multiple verifiers and asset configs.
    • Improved internal configuration and controller initialization for L2geth endpoint.
  • Bug Fixes

    • Fixed logic for proof re-wrapping to use the correct verification key.
  • Chores

    • Updated .gitignore files and removed obsolete configuration files.
    • Updated dependency versions and simplified ignore patterns.
    • Migrated to safer concurrency primitives and removed unsafe code in verifier initialization.
    • Updated GitHub Actions workflows to use newer Rust nightly versions.
    • Refined Makefile and build scripts for circuit executables.
    • Cleaned up prover package manifest to inherit workspace versions.
  • Documentation

    • Added and clarified documentation comments for public functions.

@coderabbitai
Copy link

coderabbitai bot commented Jun 25, 2025

"""

Walkthrough

This update introduces significant refactoring and feature additions across the prover, verifier, and coordinator components. Key changes include enhanced verification key (VK) management with per-proof-type and per-fork caching, new CLI commands for proof verification and VK dumping, revised prover task assignment logic to handle already-assigned tasks, and improved configuration and build processes. Rust and Go interfaces are aligned for universal task handling, and new configuration files, scripts, and ignore patterns are added.

Changes

Files / Groups Change Summary
.gitignore, common/.gitignore, database/.gitignore, zkvm-prover/.work/.gitignore Updated ignore patterns for config, build, and debug files/directories.
zkvm-prover/.work/chunk/openvm.toml, zkvm-prover/.work/batch/openvm.toml, zkvm-prover/.work/bundle/openvm.toml Added new TOML configuration files specifying FRI and VM cryptographic parameters.
zkvm-prover/Makefile, zkvm-prover/download-release.sh Enhanced Makefile with stack size, circuit file rules, and a new download script for executables.
zkvm-prover/config.json Deleted the main configuration file.
zkvm-prover/config.json.template Added health listener address to the config template and extended circuits section.
Cargo.toml, crates/prover-bin/Cargo.toml Updated workspace dependency revisions and switched to workspace inheritance for version/edition.
common/Makefile, coordinator/Makefile Modified linting targets to add or remove Rust and Go linting steps.
coordinator/conf/config.json, coordinator/test/api_test.go Updated and tested configuration for L2geth endpoint.
coordinator/cmd/tool/tool.go, coordinator/cmd/tool/verify.go Refactored CLI: config loading in Before hook, global config var, and added a new "verify" command.
coordinator/internal/controller/api/controller.go Activated and refactored L2geth endpoint initialization.
coordinator/internal/controller/api/get_task.go, coordinator/internal/controller/api/l2_syncer.go, coordinator/internal/controller/api/mock_syncer.go Added L2 syncer for block height retrieval, with real and mock implementations.
coordinator/internal/logic/libzkp/lib.go, coordinator/internal/logic/libzkp/universal_task.go, coordinator/internal/logic/libzkp/mock_universal_task.go Standardized forkName to lowercase, refactored L2geth initialization, and updated universal task FFI.
coordinator/internal/logic/provertask/prover_task.go, coordinator/internal/logic/provertask/chunk_prover_task.go, coordinator/internal/logic/provertask/batch_prover_task.go, coordinator/internal/logic/provertask/bundle_prover_task.go Enhanced prover task assignment logic to handle already-assigned tasks and avoid redundant assignments.
coordinator/internal/logic/submitproof/proof_receiver.go Improved VK selection logic for proof wrapping.
coordinator/internal/logic/verifier/types.go, coordinator/internal/logic/verifier/mock.go, coordinator/internal/logic/verifier/verifier.go Added per-proof-type VK maps, refactored VK loading from JSON, and updated verifier initialization.
coordinator/internal/orm/prover_task.go Refactored assigned task check to return task pointer and added method to update assignment time.
crates/libzkp/src/lib.rs, crates/libzkp/src/verifier.rs, crates/libzkp/src/verifier/euclidv2.rs Switched to thread-safe verifier access, unified universal verifier, and deprecated VK dumping.
crates/libzkp/src/tasks.rs, crates/libzkp/src/tasks/batch.rs, crates/libzkp/src/tasks/bundle.rs, crates/libzkp/src/tasks/chunk.rs Refactored universal task metadata building and validation, added explicit chunk task preparation and metadata methods.
crates/libzkp_c/src/lib.rs Fixed tuple unpacking order for universal task FFI results.
crates/prover-bin/src/main.rs Added VK dump subcommand, optional fork name, and related logic.
crates/prover-bin/src/prover.rs, crates/prover-bin/src/zk_circuits_handler.rs, crates/prover-bin/src/zk_circuits_handler/euclidV2.rs Refactored prover to use per-fork handler map, VK caching, and synchronous VK retrieval.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI Tool
    participant Config as Config Loader
    participant Verifier as Verifier
    participant ProofFile as Proof File
    participant VKStore as VK Store

    CLI->>Config: Load config (Before hook)
    CLI->>ProofFile: Read proof file
    CLI->>Verifier: Initialize with config
    Verifier->>VKStore: Retrieve VK for fork/type
    CLI->>Verifier: Verify proof with VK
    Verifier-->>CLI: Verification result
    CLI->>CLI: Print result
Loading
sequenceDiagram
    participant Prover as Prover
    participant HandlerMap as Handler Map
    participant VKCache as VK Cache
    participant ProofReq as Proof Request

    Prover->>HandlerMap: Get or init handler for fork
    HandlerMap->>VKCache: Get VK for proof type
    ProofReq->>HandlerMap: Request proof generation
    HandlerMap->>VKCache: Compare VK in request vs expected
    VKCache-->>HandlerMap: OK/Error
    HandlerMap-->>ProofReq: Proof result or error
Loading

Possibly related PRs

  • scroll-tech/scroll#1682: Refactors and extends coordinator's universal prover task handling, introduces Go libzkp module, and updates proof/task logic—directly related to universal task and verifier changes.
  • scroll-tech/scroll#1652: Removes legacy halo2 prover logic, retains openvm prover logic—strongly related to the main PR's refactoring of prover/verifier logic.
  • scroll-tech/scroll#1613: Adds and respects euclidv2 support in prover/verifier, updates dependencies, and enhances logging—directly related to multi-fork and multi-proof-type refactoring.

Suggested reviewers

  • lispc
  • colinlyguo

Poem

Hopping through code with a whisk and a key,
VKs in my basket, as neat as can be.
Tasks now assigned with a clever new plan,
Proofs verified swiftly—oh, yes, I can!
With configs and scripts, and TOMLs in tow,
This bunny brings order wherever I go!
🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Base automatically changed from refactor/zkvm_2 to develop June 25, 2025 06:42
@lispc
Copy link
Contributor

lispc commented Jun 27, 2025

reviewed till 6c76a9b .

don't force push later.

@noel2004 noel2004 marked this pull request as ready for review June 27, 2025 06:10
@noel2004 noel2004 requested review from colinlyguo and georgehao June 27, 2025 06:10
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2025

Codecov Report

Attention: Patch coverage is 25.45455% with 287 lines in your changes missing coverage. Please review.

Project coverage is 39.88%. Comparing base (9dc57c6) to head (7748995).

Files with missing lines Patch % Lines
coordinator/cmd/tool/verify.go 0.00% 91 Missing ⚠️
...or/internal/logic/provertask/bundle_prover_task.go 8.06% 55 Missing and 2 partials ⚠️
...tor/internal/logic/provertask/chunk_prover_task.go 40.32% 29 Missing and 8 partials ⚠️
...tor/internal/logic/provertask/batch_prover_task.go 42.85% 28 Missing and 8 partials ⚠️
coordinator/internal/orm/prover_task.go 0.00% 19 Missing ⚠️
coordinator/cmd/tool/tool.go 0.00% 16 Missing ⚠️
coordinator/internal/controller/api/get_task.go 36.84% 9 Missing and 3 partials ⚠️
coordinator/cmd/api/app/mock_app.go 0.00% 5 Missing ⚠️
...nator/internal/logic/submitproof/proof_receiver.go 58.33% 4 Missing and 1 partial ⚠️
coordinator/internal/logic/libzkp/lib.go 33.33% 4 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1684      +/-   ##
===========================================
- Coverage    40.09%   39.88%   -0.22%     
===========================================
  Files          234      236       +2     
  Lines        18618    18829     +211     
===========================================
+ Hits          7465     7510      +45     
- Misses       10425    10577     +152     
- Partials       728      742      +14     
Flag Coverage Δ
common 29.75% <ø> (ø)
coordinator 33.64% <25.45%> (-0.75%) ⬇️
database 42.05% <ø> (ø)
rollup 46.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
coordinator/internal/config/config.go (1)

58-58: Fix typo in comment.

The comment contains a typo that should be corrected for clarity.

-// AssetConfig contain assets configurated for each fork, the defaul vkfile name is "OpenVmVk.json".
+// AssetConfig contains assets configured for each fork, the default vkfile name is "OpenVmVk.json".
coordinator/internal/logic/verifier/verifier.go (2)

120-131: Remove commented code or document retention reason.

The commented-out ReadVK method should either be removed if no longer needed or documented if kept for future reference.

-// func (v *Verifier) ReadVK(filePat string) (string, error) {
-
-// 	f, err := os.Open(filepath.Clean(filePat))
-// 	if err != nil {
-// 		return "", err
-// 	}
-// 	byt, err := io.ReadAll(f)
-// 	if err != nil {
-// 		return "", err
-// 	}
-// 	return base64.StdEncoding.EncodeToString(byt), nil
-// }

159-174: Consider refactoring repetitive base64 decoding logic.

The base64 decoding and caching logic is repeated three times. Consider extracting it into a helper function for better maintainability.

+func (v *Verifier) cacheVk(encoded string, forkName string, vkMap map[string][]byte) error {
+	decodedBytes, err := base64.StdEncoding.DecodeString(encoded)
+	if err != nil {
+		return err
+	}
+	vkMap[forkName] = decodedBytes
+	return nil
+}

 func (v *Verifier) loadOpenVMVks(cfg config.AssetConfig) error {
 	// ... existing code ...
 	
-	decodedBytes, err := base64.StdEncoding.DecodeString(dump.Chunk)
-	if err != nil {
-		return err
-	}
-	v.ChunkVk[cfg.ForkName] = decodedBytes
-	decodedBytes, err = base64.StdEncoding.DecodeString(dump.Batch)
-	if err != nil {
-		return err
-	}
-	v.BatchVk[cfg.ForkName] = decodedBytes
-	decodedBytes, err = base64.StdEncoding.DecodeString(dump.Bundle)
-	if err != nil {
-		return err
-	}
-	v.BundleVk[cfg.ForkName] = decodedBytes
+	if err := v.cacheVk(dump.Chunk, cfg.ForkName, v.ChunkVk); err != nil {
+		return err
+	}
+	if err := v.cacheVk(dump.Batch, cfg.ForkName, v.BatchVk); err != nil {
+		return err
+	}
+	if err := v.cacheVk(dump.Bundle, cfg.ForkName, v.BundleVk); err != nil {
+		return err
+	}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 991c60d and f19e3b1.

📒 Files selected for processing (12)
  • coordinator/cmd/api/app/mock_app.go (1 hunks)
  • coordinator/cmd/tool/verify.go (1 hunks)
  • coordinator/conf/config.json (2 hunks)
  • coordinator/internal/config/config.go (1 hunks)
  • coordinator/internal/logic/auth/login.go (2 hunks)
  • coordinator/internal/logic/provertask/batch_prover_task.go (4 hunks)
  • coordinator/internal/logic/provertask/bundle_prover_task.go (4 hunks)
  • coordinator/internal/logic/provertask/chunk_prover_task.go (4 hunks)
  • coordinator/internal/logic/verifier/verifier.go (4 hunks)
  • coordinator/test/api_test.go (1 hunks)
  • crates/libzkp/src/verifier.rs (2 hunks)
  • zkvm-prover/config.json.template (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • zkvm-prover/config.json.template
  • coordinator/test/api_test.go
  • coordinator/conf/config.json
  • coordinator/cmd/tool/verify.go
  • coordinator/internal/logic/provertask/chunk_prover_task.go
  • coordinator/internal/logic/provertask/batch_prover_task.go
  • coordinator/internal/logic/provertask/bundle_prover_task.go
🧰 Additional context used
🧬 Code Graph Analysis (2)
coordinator/internal/logic/auth/login.go (3)
coordinator/internal/config/config.go (1)
  • ProverManager (13-29)
common/version/prover_version.go (1)
  • CheckScrollRepoVersion (37-55)
coordinator/internal/types/auth.go (2)
  • Message (42-49)
  • ProverVersion (20-20)
coordinator/cmd/api/app/mock_app.go (1)
coordinator/internal/config/config.go (1)
  • AssetConfig (59-63)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
🔇 Additional comments (10)
coordinator/internal/logic/auth/login.go (2)

34-38: LGTM! Correctly implements multi-verifier fork aggregation.

The changes properly collect fork names from all configured verifiers instead of relying on a single high version circuit, which aligns with the new multi-verifier architecture.


61-62: LGTM! Updated to use new configuration structure.

The version check correctly uses the new MinProverVersion field from the verifier configuration, maintaining backward compatibility while supporting the new multi-verifier setup.

coordinator/cmd/api/app/mock_app.go (1)

93-98: LGTM! Mock configuration correctly updated for new structure.

The mock configuration properly reflects the new verifier config schema with MinProverVersion as a top-level field and Verifiers as a slice of AssetConfig structs, maintaining the same test values in the new format.

coordinator/internal/config/config.go (2)

58-63: LGTM! Well-designed configuration structure for multi-verifier support.

The AssetConfig struct properly supports per-fork asset configuration with an optional verification key file, enabling flexible verifier setups.


67-68: LGTM! Correctly restructured for multi-verifier architecture.

The new VerifierConfig structure with explicit MinProverVersion and a slice of Verifiers properly supports multiple verifier configurations while maintaining clear version requirements.

crates/libzkp/src/verifier.rs (3)

55-56: LGTM! Excellent thread-safe multi-verifier implementation.

The use of OnceLock<HashMap<>> with Arc<Mutex<>> provides proper thread safety for concurrent verifier access. The initialization logic correctly handles multiple circuits with good error handling and prevents duplicate fork names.

Also applies to: 58-74


76-93: LGTM! Well-structured verifier retrieval with comprehensive error handling.

The get_verifier function properly handles both uninitialized state and missing fork names, providing clear error messages for debugging.


63-63: Verify case sensitivity requirements for fork names.

The code converts fork names to lowercase when storing in the HashMap. Ensure this doesn't cause issues if other parts of the system expect case-sensitive fork name matching.

#!/bin/bash
# Description: Check if fork names are used case-sensitively elsewhere in the codebase
# Expected: Find usages of fork names to verify case sensitivity requirements

echo "Searching for fork name usage patterns..."
rg -A 2 -B 2 "fork_name|ForkName" --type go
echo -e "\n--- Rust fork name usage ---"
rg -A 2 -B 2 "fork_name" --type rust
coordinator/internal/logic/verifier/verifier.go (2)

40-51: LGTM! Correctly implements multi-circuit configuration mapping.

The rustVerifierConfig properly maps the new configuration structure with multiple circuits, maintaining clean separation between Go config and Rust FFI types.


72-75: LGTM! Excellent addition of VK caching for performance.

The new per-fork verification key maps (ChunkVk, BatchVk, BundleVk) provide efficient in-memory caching, and the initialization loop correctly processes all configured verifiers.

Also applies to: 77-81

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d402dd and d310d3a.

📒 Files selected for processing (19)
  • coordinator/internal/controller/api/controller.go (2 hunks)
  • coordinator/internal/controller/api/get_task.go (4 hunks)
  • coordinator/internal/logic/libzkp/lib.go (6 hunks)
  • coordinator/internal/logic/libzkp/libzkp.h (1 hunks)
  • coordinator/internal/logic/libzkp/mock_universal_task.go (1 hunks)
  • coordinator/internal/logic/libzkp/universal_task.go (1 hunks)
  • coordinator/internal/logic/provertask/batch_prover_task.go (5 hunks)
  • coordinator/internal/logic/provertask/bundle_prover_task.go (5 hunks)
  • coordinator/internal/logic/provertask/chunk_prover_task.go (5 hunks)
  • coordinator/internal/logic/provertask/prover_task.go (3 hunks)
  • crates/libzkp/src/lib.rs (5 hunks)
  • crates/libzkp/src/proofs.rs (2 hunks)
  • crates/libzkp/src/tasks.rs (1 hunks)
  • crates/libzkp/src/tasks/batch.rs (4 hunks)
  • crates/libzkp/src/tasks/bundle.rs (2 hunks)
  • crates/libzkp/src/verifier.rs (3 hunks)
  • crates/libzkp/src/verifier/euclidv2.rs (1 hunks)
  • crates/libzkp_c/src/lib.rs (2 hunks)
  • crates/prover-bin/src/zk_circuits_handler.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (16)
  • coordinator/internal/controller/api/controller.go
  • coordinator/internal/logic/libzkp/mock_universal_task.go
  • crates/prover-bin/src/zk_circuits_handler.rs
  • crates/libzkp/src/tasks/batch.rs
  • crates/libzkp/src/tasks/bundle.rs
  • coordinator/internal/logic/libzkp/universal_task.go
  • coordinator/internal/logic/provertask/prover_task.go
  • crates/libzkp_c/src/lib.rs
  • crates/libzkp/src/tasks.rs
  • coordinator/internal/logic/libzkp/lib.go
  • crates/libzkp/src/lib.rs
  • coordinator/internal/logic/provertask/batch_prover_task.go
  • coordinator/internal/logic/provertask/chunk_prover_task.go
  • coordinator/internal/controller/api/get_task.go
  • coordinator/internal/logic/provertask/bundle_prover_task.go
  • crates/libzkp/src/verifier/euclidv2.rs
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
🔇 Additional comments (7)
crates/libzkp/src/verifier.rs (5)

7-11: LGTM: Thread-safe concurrency primitives properly imported.

The imports correctly include OnceLock, Arc, Mutex, and HashMap for implementing thread-safe multi-verifier management. The choice of OnceLock for one-time initialization and Arc<Mutex<>> for shared mutable access is appropriate for this use case.


38-38: Good optimization: Changed from owned Vec<u8> to borrowed &[u8].

This change improves memory efficiency by avoiding unnecessary allocations and copies when verifying proofs. The verifier doesn't need to own the proof data, just read it.


55-56: LGTM: Appropriate global state management for multi-verifier system.

Using OnceLock<HashMap<...>> is the correct pattern for thread-safe, one-time initialization of global state. The type alias VerifierType improves readability.


58-76: Good implementation with proper validation.

The initialization logic correctly:

  • Iterates through all circuit configurations
  • Canonicalizes fork names to lowercase for consistent lookup
  • Validates against duplicate fork registrations
  • Provides clear error messages and logging

The assertion for duplicate prevention is appropriate since this represents a configuration error that should fail fast.


78-95: Excellent error handling and helpful debugging information.

The get_verifier function provides comprehensive error handling with informative messages:

  • Lists available keys when a fork is not found
  • Distinguishes between uninitialized state and missing keys
  • Returns proper Result types for error propagation
coordinator/internal/logic/libzkp/libzkp.h (1)

35-41: All callers updated with new parameters

Verified that every invocation of gen_universal_task—in the Rust crate (crates/libzkp/src/lib.rs), the C-ABI wrapper (crates/libzkp_c/src/lib.rs), and the Go binding (coordinator/internal/logic/libzkp/universal_task.go)—now includes both expected_vk and expected_vk_len. No outdated 3-argument calls remain.

crates/libzkp/src/proofs.rs (1)

182-182: Function renamed with improved error handling approach.

Good refactoring! Changing from sanity_check to pi_hash_check with a boolean return type allows callers to handle mismatches gracefully instead of panicking. This aligns well with the broader verification workflow improvements.

@noel2004
Copy link
Member Author

test passed with chunk from sepolia testnet

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
crates/prover-bin/src/zk_circuits_handler/euclidV2.rs (2)

60-71: Address the unreachable! macro usage.

The get_vk_and_cache method implements proper lazy VK initialization, but still uses unreachable! for unsupported proof types.

Replace unreachable! with proper error handling:

-            _ => unreachable!("Unsupported proof type {:?}", task_type),
+            _ => return String::new(), // Or handle this case appropriately in the caller

76-80: Avoid using try_lock().expect() to prevent potential panics.

The try_lock().expect() pattern could still panic if the lock is already held, similar to the previous try_lock().unwrap() issue.

Consider using proper error handling:

-    fn get_vk(&self, task_type: ProofType) -> String {
-        self.try_lock()
-            .expect("get vk is on called before other entry is used")
-            .get_vk_and_cache(task_type)
+    fn get_vk(&self, task_type: ProofType) -> String {
+        match self.try_lock() {
+            Ok(handler) => handler.get_vk_and_cache(task_type),
+            Err(_) => {
+                tracing::error!("Failed to acquire lock for get_vk");
+                String::new()
+            }
+        }
🧹 Nitpick comments (1)
coordinator/internal/logic/verifier/verifier_test.go (1)

32-36: Consider setting a valid MinProverVersion and testing multi-verifier scenarios.

The configuration structure correctly reflects the new multi-verifier design. However, consider:

  1. The empty MinProverVersion might not adequately test version validation logic
  2. Using only one verifier in the slice doesn't fully exercise the new multi-verifier capability

Consider this enhancement to better test the new functionality:

 cfg := &config.VerifierConfig{
-	MinProverVersion: "",
+	MinProverVersion: "v4.4.45",
 	Verifiers: []config.AssetConfig{{
 		AssetsPath: *assetsPathHi,
 		ForkName:   "euclidV2",
 	}},
 }

Additionally, consider adding a test case that exercises multiple verifiers to ensure the new architecture works as expected.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d310d3a and 7748995.

📒 Files selected for processing (6)
  • coordinator/cmd/tool/verify.go (1 hunks)
  • coordinator/conf/config.json (2 hunks)
  • coordinator/internal/config/config_test.go (1 hunks)
  • coordinator/internal/logic/verifier/verifier_test.go (1 hunks)
  • crates/libzkp/src/proofs.rs (2 hunks)
  • crates/prover-bin/src/zk_circuits_handler/euclidV2.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • coordinator/conf/config.json
  • crates/libzkp/src/proofs.rs
  • coordinator/cmd/tool/verify.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
coordinator/internal/logic/verifier/verifier_test.go (1)
coordinator/internal/config/config.go (1)
  • AssetConfig (59-63)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
🔇 Additional comments (6)
coordinator/internal/config/config_test.go (1)

23-27: Configuration structure correctly reflects the new multi-verifier architecture.

The JSON configuration properly demonstrates the structural changes:

  • min_prover_version moved to top level ✓
  • verifiers array replaces single circuit config ✓
  • Asset configuration format matches AssetConfig struct ✓

Consider adding a test case with multiple verifiers in the array to fully validate the new multi-verifier functionality:

 "verifiers": [{
 	"assets_path": "assets",
 	"fork_name": "euclidV2"
-}]
+}, {
+	"assets_path": "assets_v2",
+	"fork_name": "feynmanV1"
+}]
crates/prover-bin/src/zk_circuits_handler/euclidV2.rs (5)

1-5: LGTM: Appropriate imports for VK caching functionality.

The new imports support the VK caching mechanism with HashMap for storage and OnceLock for thread-safe lazy initialization.


20-20: LGTM: Well-designed VK caching field.

The cached_vks field uses OnceLock<String> for thread-safe lazy initialization of base64-encoded verification keys, which is appropriate for this caching pattern.


26-58: LGTM: Constructor properly initializes VK cache.

The constructor correctly:

  • Accepts a CircuitConfig reference for better configuration access
  • Initializes the VK cache using either pre-existing config values or empty OnceLock instances
  • Uses a clean closure pattern for cache initialization

The approach allows for flexible VK initialization while maintaining thread safety.


82-94: LGTM: Improved VK validation with proper async locking.

The VK validation logic is well-implemented:

  • Uses proper async locking with self.lock().await
  • Compares base64-encoded VKs for consistency
  • Provides clear error messages with context
  • Prevents proof generation with mismatched VKs

This significantly improves security by ensuring proof consistency.


95-115: LGTM: Improved error handling for unsupported proof types.

The proof generation logic correctly:

  • Uses the locked handler instance consistently
  • Replaces panics with proper Result error returns for unsupported proof types
  • Maintains the same proof generation flow

The TODO comment for checking expected public inputs is noted and appropriate for future enhancement.

@noel2004 noel2004 requested review from georgehao and lispc June 30, 2025 08:27
@lispc lispc merged commit ea38ae7 into develop Jun 30, 2025
15 checks passed
@lispc lispc deleted the refactor/zkvm_3 branch June 30, 2025 22:39
@scroll-tech scroll-tech deleted a comment from Pray4Lovee Jul 15, 2025
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.

5 participants