Skip to content

[Refactor] For universal prover task (the update on coordinator) #1682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 19, 2025

Conversation

noel2004
Copy link
Member

@noel2004 noel2004 commented Jun 17, 2025

Background: this is one of several PRs to support "Universal Prover", which can help prove circuits(zk programs) of different hardforks in one single binary.

This PR is part of #1680 and include required updates for coordinator.

There are changes as follows:

  • The packing of libzkp is moved from coordinator and become a separated go module, with corresponding updates in Make routine

  • The arguments of get_task and submit_proof has been updated to support the "universal task" prover

  • To support universal prover, some translating work is moved into coordinator, they are generated on-the-fly with a get_task request from new prover. We use a simple cache for saving the new universal tasks, no updated is required to the data in db And the metadata data is now separated before task is sent to prover and persisted in coordinator side

Summary by CodeRabbit

  • New Features

    • Introduced Go and C interfaces for a universal zero-knowledge proof task lifecycle, including task generation, proof wrapping, and memory management.
    • Added Go bindings for zero-knowledge proof operations, enabling initialization, verification, universal task generation, and proof wrapping.
    • Expanded API and configuration to support universal proving tasks and metadata handling.
    • Added support for managing and storing metadata in prover tasks.
  • Improvements

    • Refactored build processes for better modularity and clearer dependencies.
    • Enhanced database schema with a new metadata column for prover tasks.
    • Improved error reporting for proof formatting and diagnostics.
    • Updated version to v4.5.24.
    • Replaced direct C bindings with safer Go library calls for proof verification.
    • Modularized prover task assignment logic to handle universal task transformations before database insertion.
  • Bug Fixes

    • Improved memory management and header safety in C interfaces.
    • Fixed minor import and type issues in tests and code.
  • Chores

    • Updated CI workflows to build new proof libraries and handle updated library paths.
    • Adjusted .gitignore to exclude new shared library artifacts.

Copy link

coderabbitai bot commented Jun 17, 2025

Walkthrough

This update introduces a new universal task lifecycle for zero-knowledge proofs (ZKP), expanding the FFI and Go interfaces to support universal task generation, metadata management, and proof wrapping. The coordinator's logic, types, and database schema are updated to handle universal tasks, metadata, and wrapped proofs. Build and workflow scripts are adjusted to accommodate the new library structure.

Changes

Files/Groups Change Summary
common/libzkp/lib.go, common/libzkp/go.mod, common/libzkp/interface/libzkp.h, common/libzkp/impl/src/lib.rs, common/libzkp/impl/src/utils.rs Introduced Go bindings and extended FFI for universal task handling, proof wrapping, and memory management.
common/libzkp/impl/Makefile, common/libzkp/impl/Cargo.toml Enhanced build process, updated dependencies, and improved shared library management.
coordinator/Makefile, .github/workflows/coordinator.yml, .github/workflows/integration.yml Refactored build and CI scripts to modularize and ensure proper building of the ZKP library.
coordinator/.gitignore Now ignores the built libzkp.so shared library.
coordinator/internal/config/config.go Refactored L2 endpoint configuration into a nested struct.
coordinator/internal/orm/prover_task.go, database/migrate/migrations/00028_add_metadata_to_prover_task.sql, database/migrate/migrate_test.go Added a metadata column to the prover_task table and updated migration tests accordingly.
coordinator/internal/types/get_task.go, coordinator/internal/types/submit_proof.go Added Universal and related fields to task and proof parameter structs.
coordinator/internal/logic/provertask/prover_task.go Added applyUniversal method for universal task transformation.
coordinator/internal/logic/provertask/batch_prover_task.go, coordinator/internal/logic/provertask/bundle_prover_task.go, coordinator/internal/logic/provertask/chunk_prover_task.go Refactored assignment logic to support universal tasks and metadata handling.
coordinator/internal/logic/submitproof/proof_receiver.go Added logic for handling universal proofs and wrapping them before verification.
coordinator/internal/logic/verifier/verifier.go, coordinator/internal/logic/verifier/verifier_test.go Switched proof verification to use the new Go wrapper library, removing direct cgo usage.
common/libzkp/impl/src/verifier/euclidv2.rs Updated EVM proof conversion logic for bundle proofs.
common/version/version.go Updated version to v4.5.24.

Sequence Diagram(s)

sequenceDiagram
    participant GoApp as Go Coordinator
    participant GoLib as libzkp Go Bindings
    participant CLib as C/Rust FFI (libzkp)
    participant DB as Database

    GoApp->>GoLib: GenerateUniversalTask(taskType, taskJSON, forkName)
    GoLib->>CLib: gen_universal_task(...)
    CLib-->>GoLib: HandlingResult {ok, universal_task, metadata, hash}
    GoLib-->>GoApp: (ok, universal_task, metadata, hash)
    GoApp->>DB: Store ProverTask (with metadata)
    Note right of GoApp: Later, when proof is submitted:
    GoApp->>GoLib: GenerateWrappedProof(proofJSON, metadata, vkData)
    GoLib->>CLib: gen_wrapped_proof(...)
    CLib-->>GoLib: wrapped_proof
    GoLib-->>GoApp: wrapped_proof
    GoApp->>GoLib: Verify*Proof(wrapped_proof, forkName)
    GoLib->>CLib: verify_*_proof(...)
    CLib-->>GoLib: verification result
    GoLib-->>GoApp: verification result
Loading

Possibly related PRs

  • scroll-tech/scroll#1597: Implements the Euclid prover and coordinator with major changes to proof types and verification logic, directly related to the universal task and proof handling introduced here.

Suggested reviewers

  • georgehao
  • colinlyguo

Poem

A rabbit hopped through fields of code,
With universal tasks in its load.
Proofs wrapped tight, metadata in tow,
New bindings and logic, ready to go!
The build is now smarter, the flows are all neat—
With every commit, progress hops on swift feet.
🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 745a7d3 and d844890.

📒 Files selected for processing (1)
  • coordinator/internal/logic/provertask/batch_prover_task.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/internal/logic/provertask/batch_prover_task.go
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
✨ 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.

@noel2004 noel2004 marked this pull request as ready for review June 17, 2025 08:03
@noel2004 noel2004 requested review from lispc and colinlyguo June 17, 2025 08:03
@codecov-commenter
Copy link

codecov-commenter commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 23.61111% with 55 lines in your changes missing coverage. Please review.

Project coverage is 40.09%. Comparing base (b0943b1) to head (d844890).

Files with missing lines Patch % Lines
...or/internal/logic/provertask/bundle_prover_task.go 0.00% 16 Missing ⚠️
...tor/internal/logic/provertask/chunk_prover_task.go 13.33% 10 Missing and 3 partials ⚠️
...tor/internal/logic/provertask/batch_prover_task.go 26.66% 9 Missing and 2 partials ⚠️
...nator/internal/logic/submitproof/proof_receiver.go 0.00% 7 Missing and 1 partial ⚠️
...ordinator/internal/logic/provertask/prover_task.go 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1682      +/-   ##
===========================================
- Coverage    40.16%   40.09%   -0.08%     
===========================================
  Files          232      232              
  Lines        18447    18502      +55     
===========================================
+ Hits          7409     7418       +9     
- Misses       10315    10357      +42     
- Partials       723      727       +4     
Flag Coverage Δ
common 29.75% <ø> (ø)
coordinator 34.25% <23.61%> (-0.30%) ⬇️
database 42.05% <ø> (ø)
rollup 46.29% <ø> (ø)

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: 16

🔭 Outside diff range comments (3)
coordinator/internal/logic/verifier/verifier.go (2)

111-122: File descriptor leak in ReadVK

os.Open is invoked but the returned file handle is never closed, leaking an FD every time the method is used.

 func (v *Verifier) ReadVK(filePat string) (string, error) {
-	f, err := os.Open(filepath.Clean(filePat))
+	f, err := os.Open(filepath.Clean(filePat))
 	if err != nil {
 		return "", err
 	}
+	defer f.Close()

124-147: loadOpenVMVks leaves temp files & leaks FDs

  1. os.Open result is not closed.
  2. The temporary file is never deleted, so every Coordinator start will litter $TMPDIR.
-	f, err := os.Open(filepath.Clean(tempFile))
+	f, err := os.Open(filepath.Clean(tempFile))
 	if err != nil {
 		return err
 	}
+	defer func() {
+		f.Close()
+		_ = os.Remove(tempFile) // ignore error – best-effort cleanup
+}()
common/libzkp/impl/src/lib.rs (1)

14-18: Add null-check & robust deserialisation

init_verifier dereferences config blindly and unwrap()s JSON parsing. Any null pointer or malformed JSON will cause UB or panic across the FFI boundary.

 pub unsafe extern "C" fn init_verifier(config: *const c_char) {
-    let config_str = c_char_to_str(config);
-    let verifier_config = serde_json::from_str::<VerifierConfig>(config_str).unwrap();
+    if config.is_null() {
+        log::error!("init_verifier called with NULL pointer");
+        return;
+    }
+    let config_str = match std::str::from_utf8(std::ffi::CStr::from_ptr(config).to_bytes()) {
+        Ok(s) => s,
+        Err(e) => {
+            log::error!("Invalid UTF-8 in config: {:#}", e);
+            return;
+        }
+    };
+    let verifier_config = match serde_json::from_str::<VerifierConfig>(config_str) {
+        Ok(cfg) => cfg,
+        Err(e) => {
+            log::error!("Failed to parse verifier config: {:#}", e);
+            return;
+        }
+    };
🧹 Nitpick comments (16)
common/libzkp/impl/src/utils.rs (1)

6-8: Add null-pointer guard to avoid UB in FFI helper

CStr::from_ptr triggers undefined behaviour when c is null. A minimal guard prevents crashes coming from buggy callers.

 pub(crate) fn c_char_to_str(c: *const c_char) -> &'static str {
-    let cstr = unsafe { CStr::from_ptr(c) };
-    cstr.to_str().unwrap()
+    if c.is_null() {
+        return "";
+    }
+    let cstr = unsafe { CStr::from_ptr(c) };
+    cstr.to_str().unwrap()
 }
common/libzkp/impl/Makefile (2)

5-6: Hard-coded path: make it a variable for portability

Baking ../lib into the recipe ties the Makefile to the current directory layout. Consider:

LIB_DIR ?= $(CURDIR)/../lib
...
	@mkdir -p $(LIB_DIR)
	@cp -f target/release/libzkp.so $(LIB_DIR)/

11-13: clean target leaves Cargo artefacts behind

Removing only the copied .so can still leave stale binaries in target/.
Add cargo clean or rm -rf target for a truly fresh build.

coordinator/internal/types/submit_proof.go (1)

10-10: Explicitly document & validate the “universal” flag

The new field is optional, but its semantics ( e.g. allowed only for certain TaskTypes ) are not enforced. Consider adding validation logic or at least a comment so downstream handlers don’t silently ignore malformed requests (for instance universal=true with a non-universal task).

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

31-35: Name exported field URL, not Url

Go uses initialisms in all-caps (URL) to follow the standard library’s style (url.URL, http.Handler, etc.). Renaming improves readability and tooling auto-completion.

-type L2Endpoint struct {
-    Url string `json:"endpoint"`
+type L2Endpoint struct {
+    URL string `json:"endpoint"`
 }

39-41: Pointer indirection may be unnecessary

Endpoint *L2Endpoint forces nil-checking everywhere (as seen in the controller). Unless hot-swapping endpoints is expected, embed the struct directly to simplify access.

coordinator/internal/controller/api/controller.go (1)

34-37: “l2geth is not specified” panic happens late

You dereference cfg.L2.Endpoint only during controller initialisation. Mis-configuration would be caught earlier and more cleanly if validated in config.NewConfig, preventing partial startup.

coordinator/internal/logic/provertask/batch_prover_task.go (1)

197-228: Heavy path in GetTaskMetaData & logging mismatches

Minor but noisy: log messages reference "chunk" while executing batch logic, which confuses ops.

-	log.Error("failed to get chunk by hash", "task_id", taskID, "err", err)
+	log.Error("failed to get batch by hash", "task_id", taskID, "err", err)
...
-	log.Error("Generate universal prover task failure", "task_id", taskID, "type", "chunk")
+	log.Error("Generate universal prover task failure", "task_id", taskID, "type", "batch")

Additionally, consider short-circuiting when cached == nil after applyUniversal instead of a second lookup.

coordinator/internal/logic/provertask/chunk_prover_task.go (1)

46-47: Use a named constant for cache size

newCache(1024) is a magic number. Define a const defaultChunkTaskCacheSize = 1024 near the top of the file (or in task_cache.go) for clarity and easier tuning.

coordinator/internal/logic/provertask/bundle_prover_task.go (1)

48-49: Introduce a named constant for cache size

Replace bare 128 with a descriptive constant (e.g. defaultBundleTaskCacheSize).

coordinator/Makefile (2)

19-26: Declare libzkp (and clean_libzkp) as .PHONY targets

GNU Make will incorrectly treat them as real files and may skip rebuilding.

-.PHONY: lint docker clean coordinator coordinator_skip_libzkp mock_coordinator
+.PHONY: lint docker clean coordinator coordinator_skip_libzkp mock_coordinator \
+        libzkp clean_libzkp

45-52: Consider making shared-library path a variable

../common/libzkp/lib/libzkp.so appears in three targets; pull it into a LIBZKP_SO variable for maintainability.

coordinator/internal/logic/provertask/task_cache.go (2)

14-18: Rename dropping_cache to droppingCache

Go style prefers mixed-caps identifiers; improves readability without changing behaviour.


34-38: Avoid discarding the entire active map on single overflow

Purging the whole cache when it hits limit causes a bursty eviction pattern and defeats LRU intent.
Consider incremental eviction or a real LRU (list or container/list) for smoother hit ratio.

common/libzkp/lib.go (1)

35-42: Docstring copy-paste – function isn’t a verifier

InitL2geth comment duplicates “Initialize the verifier”; update comment to reflect L2 geth init.

common/libzkp/impl/src/lib.rs (1)

125-129: Consider idempotent release_string

release_string currently UB-panics if passed twice. After freeing, set the pointer to null on the caller side or accept *mut *mut c_char to null-out internally to make accidental double frees harmless.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d6b5a8 and e1ce631.

⛔ Files ignored due to path filters (2)
  • common/libzkp/impl/Cargo.lock is excluded by !**/*.lock
  • go.work is excluded by !**/*.work
📒 Files selected for processing (23)
  • common/libzkp/go.mod (1 hunks)
  • common/libzkp/impl/Cargo.toml (0 hunks)
  • common/libzkp/impl/Makefile (1 hunks)
  • common/libzkp/impl/src/lib.rs (2 hunks)
  • common/libzkp/impl/src/utils.rs (1 hunks)
  • common/libzkp/interface/libzkp.h (1 hunks)
  • common/libzkp/lib.go (1 hunks)
  • coordinator/.gitignore (1 hunks)
  • coordinator/Makefile (2 hunks)
  • coordinator/internal/config/config.go (1 hunks)
  • coordinator/internal/controller/api/controller.go (2 hunks)
  • coordinator/internal/controller/api/get_task.go (1 hunks)
  • coordinator/internal/controller/api/submit_proof.go (2 hunks)
  • coordinator/internal/logic/provertask/batch_prover_task.go (3 hunks)
  • coordinator/internal/logic/provertask/bundle_prover_task.go (3 hunks)
  • coordinator/internal/logic/provertask/chunk_prover_task.go (3 hunks)
  • coordinator/internal/logic/provertask/prover_task.go (4 hunks)
  • coordinator/internal/logic/provertask/task_cache.go (1 hunks)
  • coordinator/internal/logic/submitproof/proof_receiver.go (3 hunks)
  • coordinator/internal/logic/verifier/verifier.go (6 hunks)
  • coordinator/internal/logic/verifier/verifier_test.go (2 hunks)
  • coordinator/internal/types/get_task.go (1 hunks)
  • coordinator/internal/types/submit_proof.go (1 hunks)
💤 Files with no reviewable changes (1)
  • common/libzkp/impl/Cargo.toml
🧰 Additional context used
🧬 Code Graph Analysis (8)
coordinator/internal/controller/api/get_task.go (3)
common/types/message/message.go (1)
  • ProofType (20-20)
coordinator/internal/logic/provertask/prover_task.go (1)
  • ProverTask (35-38)
coordinator/internal/orm/prover_task.go (2)
  • ProverTask (20-46)
  • ProverTask (54-56)
coordinator/internal/logic/verifier/verifier_test.go (1)
common/types/message/message.go (2)
  • OpenVMBatchProof (189-198)
  • OpenVMChunkProof (157-165)
coordinator/internal/controller/api/submit_proof.go (3)
coordinator/internal/controller/api/get_task.go (1)
  • GetTaskController (24-28)
coordinator/internal/logic/submitproof/proof_receiver.go (1)
  • NewSubmitProofReceiverLogic (81-137)
common/types/message/message.go (3)
  • ProofTypeChunk (39-39)
  • ProofTypeBatch (41-41)
  • ProofTypeBundle (43-43)
coordinator/internal/logic/provertask/prover_task.go (4)
coordinator/internal/types/auth.go (1)
  • HardForkName (24-24)
coordinator/internal/logic/provertask/task_cache.go (2)
  • TaskCache (13-18)
  • CachedTaskData (7-10)
coordinator/internal/types/get_task.go (1)
  • GetTaskSchema (12-18)
common/libzkp/lib.go (1)
  • GenerateUniversalTask (77-102)
coordinator/internal/controller/api/controller.go (4)
coordinator/internal/config/config.go (1)
  • L2 (37-41)
common/libzkp/lib.go (1)
  • InitL2geth (36-41)
coordinator/internal/controller/api/get_task.go (1)
  • NewGetTaskController (31-48)
coordinator/internal/controller/api/submit_proof.go (1)
  • NewSubmitProofController (26-35)
coordinator/internal/logic/provertask/chunk_prover_task.go (3)
coordinator/internal/logic/provertask/prover_task.go (2)
  • ErrCoordinatorInternalFailure (26-26)
  • ProverTask (35-38)
coordinator/internal/logic/submitproof/proof_receiver.go (1)
  • ErrCoordinatorInternalFailure (47-47)
coordinator/internal/orm/prover_task.go (2)
  • ProverTask (20-46)
  • ProverTask (54-56)
common/libzkp/impl/src/lib.rs (3)
common/libzkp/impl/src/utils.rs (2)
  • c_char_to_str (6-9)
  • c_char_to_vec (11-14)
coordinator/internal/config/config.go (1)
  • VerifierConfig (66-68)
common/libzkp/interface/libzkp.h (6)
  • init_verifier (12-12)
  • gen_universal_task (35-35)
  • release_task_result (38-38)
  • gen_wrapped_proof (43-43)
  • release_string (46-46)
  • init_l2geth (15-15)
coordinator/internal/logic/verifier/verifier.go (2)
common/libzkp/lib.go (5)
  • InitVerifier (28-33)
  • VerifyBatchProof (55-63)
  • VerifyChunkProof (44-52)
  • VerifyBundleProof (66-74)
  • DumpVk (127-143)
coordinator/internal/logic/verifier/types.go (1)
  • Verifier (11-14)
🪛 checkmake (0.2.2)
coordinator/Makefile

[warning] 25-25: Target "libzkp" should be declared PHONY.

(phonydeclared)

⏰ 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: check
  • GitHub Check: tests
  • GitHub Check: tests
🔇 Additional comments (8)
common/libzkp/go.mod (2)

1-3: Go 1.22 requirement: double-check CI & prod images

go 1.22 is still very new. Make sure all build environments (CI, docker images, release pipelines) have been upgraded, otherwise the build will fail silently.


1-3: Module declaration looks good
No other issues spotted.

coordinator/.gitignore (1)

4-4: Ignore pattern may point to an obsolete location

The library is now produced at common/libzkp/lib/libzkp.so, but the ignore entry is coordinator/internal/libzkp/lib/libzkp.so.
Verify the path and update if the artefact is no longer copied there, otherwise the new binary could be added to git accidentally.

coordinator/internal/types/get_task.go (1)

7-8: ```shell
#!/bin/bash
rg -n "TaskTypes" coordinator/internal/types/get_task.go || echo "No TaskTypes in get_task.go"
rg -n "task_types" coordinator/internal/types/get_task.go || echo "No task_types in get_task.go"


</details>
<details>
<summary>coordinator/internal/logic/verifier/verifier_test.go (2)</summary>

`14-14`: **Import path update looks correct**

Switching to `scroll-tech/common/types/message` aligns with the refactor; compilation should proceed without additional changes.

---

`61-83`: **Helper functions updated consistently**

Return types, unmarshalling and callers all reflect the new message package.  Tests should remain green.

</details>
<details>
<summary>coordinator/internal/controller/api/submit_proof.go (1)</summary>

`26-34`: **Nil-pointer danger when `ProverTasks()` is incomplete**

If `getTaskController` is `nil` or its map lacks one of the three proof-type keys, the assignments below will panic. Guard upfront and fail fast with a clear error.

```diff
-proverTaskIf := getTaskController.ProverTasks()
-ifc.submitProofReceiverLogic.ChunkTask = proverTaskIf[message.ProofTypeChunk]
+if getTaskController == nil {
+	log.Crit("GetTaskController is nil – cannot wire prover tasks")
+}
+proverTaskIf := getTaskController.ProverTasks()
+if proverTaskIf == nil {
+	log.Crit("GetTaskController returned nil task map")
+}
+if controller.submitProofReceiverLogic.ChunkTask = proverTaskIf[message.ProofTypeChunk]; controller.submitProofReceiverLogic.ChunkTask == nil {
+	log.Crit("ChunkTask not registered in GetTaskController")
+}
common/libzkp/lib.go (1)

76-103: Double-check lifetime of result strings after release_task_result

defer C.release_task_result(result) frees C-allocated strings at function exit – safe. Ensure the C side does not retain Go-allocated memory after the call. (Heads-up only.)

@lispc lispc requested a review from georgehao June 17, 2025 11:45
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: 1

♻️ Duplicate comments (1)
coordinator/internal/logic/submitproof/proof_receiver.go (1)

177-185: Still passing an empty piHash to GenerateWrappedProof

A previous review already pointed out that the third parameter must be the piHash obtained from GenerateUniversalTask.
The call is unchanged – []byte{} is supplied, making the wrapped proof invalid.

- proofParameter.Proof = libzkp.GenerateWrappedProof(proofParameter.Proof, string(proverTask.Metadata), []byte{})
+ piHash := proverTask.PiHash // retrieve the value stored at assignment time
+ proofParameter.Proof = libzkp.GenerateWrappedProof(proofParameter.Proof, string(proverTask.Metadata), piHash)

Please store piHash alongside metadata when assigning the task (see comment in applyUniversal) and propagate it here.

#!/bin/bash
# Show all GenerateWrappedProof calls and the argument used for piHash
rg --line-number 'GenerateWrappedProof\(' | grep -v '[]byte{}'
🧹 Nitpick comments (2)
.github/workflows/integration.yml (1)

41-41: Validate ordering and optimize the new libzkp build step
The added make -C common/libzkp/impl build is required for the refactored module, but please verify:

  1. That make dev_docker (line 38) does not depend on the .so produced here—if it does, consider moving this command up.
  2. The produced libzkp.so is correctly placed in common/libzkp/lib before running tests.
  3. Whether caching common/libzkp/impl/build via actions/cache@v3 could speed up CI on subsequent runs.

Optionally, split into a dedicated “Build libzkp” step for clearer logging and caching setup.

coordinator/internal/logic/submitproof/proof_receiver.go (1)

75-78: Struct now owns three task helpers that are never referenced

ChunkTask, BundleTask, and BatchTask were added but are not used anywhere in ProofReceiverLogic.
Dead fields complicate the struct, trigger linter warnings, and mislead future maintainers.

If they are meant for future work, add a TODO explaining their purpose; otherwise remove them.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc6d3af and e7db393.

📒 Files selected for processing (12)
  • .github/workflows/coordinator.yml (1 hunks)
  • .github/workflows/integration.yml (1 hunks)
  • common/libzkp/impl/src/lib.rs (2 hunks)
  • coordinator/internal/controller/api/controller.go (1 hunks)
  • coordinator/internal/logic/provertask/batch_prover_task.go (2 hunks)
  • coordinator/internal/logic/provertask/bundle_prover_task.go (1 hunks)
  • coordinator/internal/logic/provertask/chunk_prover_task.go (1 hunks)
  • coordinator/internal/logic/provertask/prover_task.go (2 hunks)
  • coordinator/internal/logic/submitproof/proof_receiver.go (3 hunks)
  • coordinator/internal/orm/prover_task.go (1 hunks)
  • coordinator/internal/types/get_task.go (1 hunks)
  • database/migrate/migrations/00028_add_metadata_to_prover_task.sql (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • coordinator/internal/orm/prover_task.go
  • database/migrate/migrations/00028_add_metadata_to_prover_task.sql
🚧 Files skipped from review as they are similar to previous changes (7)
  • .github/workflows/coordinator.yml
  • coordinator/internal/controller/api/controller.go
  • coordinator/internal/types/get_task.go
  • coordinator/internal/logic/provertask/batch_prover_task.go
  • coordinator/internal/logic/provertask/chunk_prover_task.go
  • coordinator/internal/logic/provertask/bundle_prover_task.go
  • common/libzkp/impl/src/lib.rs
🧰 Additional context used
🪛 golangci-lint (1.64.8)
coordinator/internal/logic/provertask/prover_task.go

16-16: could not import scroll-tech/common/libzkp (-: build constraints exclude all Go files in /home/jailuser/git/common/libzkp)

(typecheck)

coordinator/internal/logic/submitproof/proof_receiver.go

18-18: could not import scroll-tech/common/libzkp (-: build constraints exclude all Go files in /home/jailuser/git/common/libzkp)

(typecheck)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: check

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 (1)
common/libzkp/impl/src/verifier/euclidv2.rs (1)

48-50: Minor lifetime / allocation nit – extract the conversion into a local.

&proof.into_evm_proof() creates a temporary EvmProof that is immediately borrowed.
While legal, extracting it into a named variable avoids the temporary-lifetime dance, makes the code easier to step through in a debugger, and prevents an accidental double conversion in future edits.

-                self.bundle_verifier
-                    .verify_proof_evm(&proof.into_evm_proof())
+                let evm_proof = proof.into_evm_proof();
+                self.bundle_verifier.verify_proof_evm(&evm_proof)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e7db393 and b046f99.

⛔ Files ignored due to path filters (1)
  • common/libzkp/impl/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • common/libzkp/impl/Cargo.toml (2 hunks)
  • common/libzkp/impl/src/verifier/euclidv2.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • common/libzkp/impl/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: check
  • GitHub Check: check
🔇 Additional comments (1)
common/libzkp/impl/src/verifier/euclidv2.rs (1)

6-6: Import looks correct – no issues found.

IntoEvmProof is required for the new conversion call below; the added import is appropriate and keeps the dependency list explicit.

@georgehao
Copy link
Member

georgehao commented Jun 18, 2025

@georgehao georgehao added the bump-version Bump the version tag for deployment label Jun 18, 2025
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 (1)
coordinator/internal/logic/provertask/prover_task.go (1)

189-197: piHash is still dropped – universal proof wrapping will break
libzkp.GenerateUniversalTask returns four values, the fourth being piHash, which is required later when calling libzkp.GenerateWrappedProof.
The current implementation keeps ignoring it, so downstream code will continue to supply an empty hash and wrapped-proof verification will fail once the library enforces the check.

-func (b *BaseProverTask) applyUniversal(schema *coordinatorType.GetTaskSchema) (*coordinatorType.GetTaskSchema, []byte, error) {
-    ok, uTaskData, metadata, _ := libzkp.GenerateUniversalTask(schema.TaskType, schema.TaskData, schema.HardForkName)
+func (b *BaseProverTask) applyUniversal(schema *coordinatorType.GetTaskSchema) (*coordinatorType.GetTaskSchema, []byte, []byte, error) {
+    ok, uTaskData, metadata, piHash := libzkp.GenerateUniversalTask(schema.TaskType, schema.TaskData, schema.HardForkName)
     if !ok {
-        return nil, nil, fmt.Errorf("can not generate universal task, see coordinator log for the reason")
+        return nil, nil, nil, fmt.Errorf("can not generate universal task, see coordinator log for the reason")
     }
 
     schema.TaskData = uTaskData
-    return schema, []byte(metadata), nil
+    return schema, []byte(metadata), piHash, nil
 }

Make sure the extra piHash slice is persisted (e.g., in CachedTaskData) and later fed into GenerateWrappedProof.
This was raised in a previous review but has not been addressed yet.

🧹 Nitpick comments (1)
database/migrate/migrate_test.go (1)

57-76: Avoid repetition of the migration version magic-number
The literal 28 is now duplicated in three assertions. The next migration will force another mechanical update. Define a single constant to keep tests DRY and reduce maintenance friction.

-	// total number of tables.
-	assert.Equal(t, int64(28), cur)
+	const expectedVersion = int64(28) // update when a new migration is added
+	// total number of tables.
+	assert.Equal(t, expectedVersion, cur)
@@
-	assert.Equal(t, int64(28), cur)
+	assert.Equal(t, expectedVersion, cur)
@@
-	assert.Equal(t, int64(28), version)
+	assert.Equal(t, expectedVersion, version)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3bb4ccf and 745a7d3.

📒 Files selected for processing (3)
  • coordinator/internal/logic/provertask/bundle_prover_task.go (1 hunks)
  • coordinator/internal/logic/provertask/prover_task.go (2 hunks)
  • database/migrate/migrate_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/internal/logic/provertask/bundle_prover_task.go
🧰 Additional context used
🪛 golangci-lint (1.64.8)
coordinator/internal/logic/provertask/prover_task.go

16-16: could not import scroll-tech/common/libzkp (-: build constraints exclude all Go files in /home/jailuser/git/common/libzkp)

(typecheck)

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: check
  • GitHub Check: tests

lispc
lispc previously approved these changes Jun 18, 2025
Copy link
Contributor

@lispc lispc left a comment

Choose a reason for hiding this comment

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

let us get another approval

georgehao
georgehao previously approved these changes Jun 18, 2025
colinlyguo
colinlyguo previously approved these changes Jun 18, 2025
@noel2004 noel2004 dismissed stale reviews from lispc, georgehao, and colinlyguo via d844890 June 19, 2025 01:30
@noel2004 noel2004 merged commit d2f7663 into develop Jun 19, 2025
15 checks passed
@noel2004 noel2004 deleted the refactor/zkvm_2_coordinator branch June 19, 2025 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump-version Bump the version tag for deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants