Skip to content

refactor: use configurable prover url for batch operations#1831

Merged
sergeytimoshin merged 2 commits intomainfrom
sergey/forester-configurable-prover
Jun 20, 2025
Merged

refactor: use configurable prover url for batch operations#1831
sergeytimoshin merged 2 commits intomainfrom
sergey/forester-configurable-prover

Conversation

@sergeytimoshin
Copy link
Contributor

@sergeytimoshin sergeytimoshin commented Jun 20, 2025

Summary by CodeRabbit

  • New Features

    • Added configuration options for proof generation services, including customizable prover URL, polling interval, and maximum wait time.
    • Enhanced batch processing to support external prover service configuration for address updates, state appends, and state nullifications.
  • Refactor

    • Centralized and streamlined proof client usage by sharing configuration across batch operations.
    • Simplified proof generation logic and improved error handling during batch processing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

Walkthrough

This update introduces configurable prover client parameters throughout the proof generation workflow. Functions responsible for batch proof generation now accept and propagate prover_url, polling_interval, and max_wait_time parameters. The BatchContext struct is extended with these fields, and the control flow is updated to utilize a shared, configurable ProofClient instance for all proof-related operations.

Changes

File(s) Change Summary
forester-utils/src/instructions/address_batch_update.rs Updated function to accept prover configuration parameters and use them to instantiate a ProofClient.
forester-utils/src/instructions/state_batch_append.rs,
forester-utils/src/instructions/state_batch_nullify.rs
Updated batch proof generation functions and helpers to accept prover configuration parameters and use a shared ProofClient via Arc.
forester/src/epoch_manager.rs Added prover configuration fields to BatchContext initialization in process_v2.
forester/src/processor/v2/common.rs Added prover_url, prover_polling_interval, and prover_max_wait_time as public fields to BatchContext.
forester/src/processor/v2/address.rs,
forester/src/processor/v2/state.rs
Updated function calls to pass prover configuration from BatchContext to proof generation functions.

Sequence Diagram(s)

sequenceDiagram
    participant Config
    participant EpochManager
    participant BatchContext
    participant Processor
    participant ProofClient

    Config->>EpochManager: Provide prover_url, polling_interval, max_wait_time
    EpochManager->>BatchContext: Initialize with prover config fields
    Processor->>BatchContext: Access prover config
    Processor->>ProofClient: Instantiate with config (prover_url, etc.)
    Processor->>ProofClient: Generate ZKP proofs (shared client)
    ProofClient-->>Processor: Return proofs
Loading

Poem

In the warren where proofs are spun,
Now a single client serves everyone.
With URLs and timers, the rabbits agree,
To share their secrets efficiently.
No more local clients, no more delay—
Just swift, smart proofing, the rabbit way!
🐇✨


📜 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 28efeb6 and df3e56a.

📒 Files selected for processing (1)
  • forester/src/epoch_manager.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • forester/src/epoch_manager.rs
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Test sdk-libs
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test concurrent-merkle-tree
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: test-double-registration
  • GitHub Check: stateless-js-v2
  • GitHub Check: test-2-foresters
  • GitHub Check: test-state-batched
  • GitHub Check: test-state-photon-batched
  • GitHub Check: test-e2e
  • GitHub Check: test-address-batched
  • GitHub Check: lint
  • GitHub Check: cli-v1
  • GitHub Check: stateless-js-v1
  • GitHub Check: cli-v2
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
forester-utils/src/instructions/state_batch_append.rs (1)

92-96: Remove unnecessary clone of prover_url

Since prover_url is already owned by this function (passed by value), the .clone() on line 93 is unnecessary.

-    let proof_client = Arc::new(ProofClient::with_config(
-        prover_url.clone(),
-        polling_interval,
-        max_wait_time,
-    ));
+    let proof_client = Arc::new(ProofClient::with_config(
+        prover_url,
+        polling_interval,
+        max_wait_time,
+    ));
forester-utils/src/instructions/state_batch_nullify.rs (1)

132-136: Remove unnecessary clone of prover_url

Same as in the previous file, since prover_url is already owned by this function, the .clone() is unnecessary.

-    let proof_client = Arc::new(ProofClient::with_config(
-        prover_url.clone(),
-        polling_interval,
-        max_wait_time,
-    ));
+    let proof_client = Arc::new(ProofClient::with_config(
+        prover_url,
+        polling_interval,
+        max_wait_time,
+    ));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b95653c and 28efeb6.

📒 Files selected for processing (7)
  • forester-utils/src/instructions/address_batch_update.rs (3 hunks)
  • forester-utils/src/instructions/state_batch_append.rs (5 hunks)
  • forester-utils/src/instructions/state_batch_nullify.rs (4 hunks)
  • forester/src/epoch_manager.rs (1 hunks)
  • forester/src/processor/v2/address.rs (1 hunks)
  • forester/src/processor/v2/common.rs (2 hunks)
  • forester/src/processor/v2/state.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: Test batched-merkle-tree-simulate
  • GitHub Check: Test sdk-libs
  • GitHub Check: Test program-libs-slow
  • GitHub Check: Test program-libs-fast
  • GitHub Check: Test concurrent-merkle-tree
  • GitHub Check: lint
  • GitHub Check: stateless-js-v1
  • GitHub Check: test-2-foresters
  • GitHub Check: test-double-registration
  • GitHub Check: test-e2e
  • GitHub Check: test-state-batched
  • GitHub Check: test-state-photon-batched
  • GitHub Check: test-address-batched
  • GitHub Check: cli-v1
  • GitHub Check: stateless-js-v2
  • GitHub Check: cli-v2
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
forester/src/processor/v2/common.rs (2)

1-1: LGTM - Duration import added for new fields.

The Duration import is correctly added to support the new prover timing configuration fields.


29-31: LGTM - BatchContext properly extended with prover configuration.

The three new fields are well-named and appropriately typed. The public visibility is correct for a context struct that needs to propagate configuration through the processing pipeline.

forester/src/processor/v2/address.rs (1)

26-28: LGTM - Prover configuration properly propagated.

The function call correctly passes the new prover configuration parameters from the BatchContext. The .clone() on prover_url is appropriate for the String type.

forester/src/processor/v2/state.rs (2)

39-41: LGTM - Append operation updated with prover configuration.

The function call correctly passes the prover configuration parameters from the BatchContext for the append batch operation.


147-159: LGTM - Nullify operation updated with prover configuration.

The function call correctly passes the prover configuration parameters from the BatchContext for the nullify batch operation. The parameter propagation is consistent with the append operation.

forester-utils/src/instructions/address_batch_update.rs (3)

1-1: LGTM - Duration import added for new parameters.

The Duration import is correctly added to support the new prover timing configuration parameters.


32-34: LGTM - Function signature properly extended.

The three new parameters are well-named and appropriately typed. The parameter order is logical and consistent with other similar functions in the codebase.


261-261: LGTM - ProofClient properly configured with custom parameters.

The change from ProofClient::local() to ProofClient::with_config() correctly utilizes the configurable prover parameters, enabling external prover service configuration.

forester-utils/src/instructions/state_batch_append.rs (1)

147-148: Good refactoring to share ProofClient across concurrent operations

The change to pass a shared ProofClient instance instead of creating one per proof generation is a solid performance improvement. Using Arc for thread-safe sharing is the correct approach.

Also applies to: 174-177

forester-utils/src/instructions/state_batch_nullify.rs (1)

223-242: Good simplification of concurrent proof generation

The removal of tokio::spawn wrappers is a good simplification. futures::future::join_all already executes the futures concurrently, so the extra task spawning was unnecessary overhead. The error handling is also cleaner and more direct.

Co-authored-by: Swen Schäferjohann <42959314+SwenSchaeferjohann@users.noreply.github.com>
@sergeytimoshin sergeytimoshin merged commit 05bcb00 into main Jun 20, 2025
25 of 26 checks passed
@sergeytimoshin sergeytimoshin deleted the sergey/forester-configurable-prover branch June 20, 2025 09:03
@coderabbitai coderabbitai bot mentioned this pull request Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants