-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: use prover client from env #232
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
WalkthroughThis pull request updates the instantiation and usage of the Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as Main Function
participant ENV as Environment
participant PC as ProverClient
CLI->>ENV: Read SP1_PROVER variable
CLI->>PC: Invoke from_env()
PC-->>CLI: Return configured client
CLI->>CLI: Log SP1_PROVER value and proceed
sequenceDiagram
participant Prover as Prover Module
participant ENV as Environment
participant PC as EnvProver
Prover->>ENV: Retrieve SP1_PROVER config
Prover->>PC: Initialize via from_env()
PC-->>Prover: Return EnvProver instance
Prover->>PC: Invoke groth16-based prove()
PC-->>Prover: Provide proof result
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
crates/tests/src/lib.rs
Outdated
@@ -40,7 +40,9 @@ async fn test_light_client_prover_talking() -> Result<()> { | |||
); | |||
pretty_env_logger::init(); | |||
|
|||
let prover_client = ProverClient::builder().mock().build(); | |||
std::env::set_var("SP1_PROVER", "mock"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't be using std::env::set_var
any more in the code. In Rust version 2024 it will be an "unsafe" operation.
Can we move this to the Justfile
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Smuu <[email protected]>
Signed-off-by: Smuu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this 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 (2)
crates/node_types/prover/src/prover/mod.rs (2)
140-140
: Simplified prover client initialization using environment variablesThe initialization has been simplified to use
ProverClient::from_env()
instead of conditional compilation blocks. This is a good improvement for configurability, but it lacks error handling or logging for cases where environment variables are missing or misconfigured.Consider adding error handling and logging for the environment variable configuration:
- let prover_client = ProverClient::from_env(); + info!("Initializing prover client from environment variables"); + let prover_client = match ProverClient::from_env() { + Ok(client) => { + info!("Using prover: {}", std::env::var("SP1_PROVER").unwrap_or_else(|_| "default".to_string())); + client + }, + Err(e) => { + error!("Failed to initialize prover client from environment: {}", e); + return Err(anyhow!("Failed to initialize prover client from environment: {}", e)); + } + };
1-562
: Document the environment variable requirementsThe transition to environment-based configuration is significant, yet there is no documentation in the code about what environment variables are required and what their valid values should be.
Add a documentation comment at the module level that explains the environment variables used by this module, particularly
SP1_PROVER
. This will help users understand the configuration options and troubleshoot issues.1 + // This module uses the following environment variables: + // - SP1_PROVER: Specifies the prover implementation to use. + // Possible values include: "cpu", "mock", etc. + // See sp1_sdk documentation for details. + // mod timer; 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/node_types/prover/src/prover/mod.rs
(3 hunks)crates/tests/src/lib.rs
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/tests/src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: unused dependencies
- GitHub Check: unit-test
- GitHub Check: integration-test
- GitHub Check: build-and-push-image
- GitHub Check: clippy
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
crates/node_types/prover/src/prover/mod.rs (4)
35-35
: Updated import statement to use EnvProver from sp1_sdkThe import statement has been updated to include EnvProver instead of CpuProver, which aligns with the transition to using environment-based configuration for the prover client.
117-117
: Field type updated to use EnvProver instead of CpuProverThe prover_client field type has been changed from
Arc<RwLock<CpuProver>>
toArc<RwLock<EnvProver>>
. This change correctly reflects the shift from a CPU-specific prover to an environment-determined prover.
1-562
:❓ Verification inconclusive
Verify integration with external systems
The change from a CPU-specific prover to an environment-determined prover could affect interactions with external systems or services. Ensure that all relevant components are updated to handle this change.
🏁 Script executed:
#!/bin/bash # Check if there are any other places in the codebase that might need updates # due to the change from CpuProver to EnvProver # Look for places that use CpuProver rg "CpuProver" --glob "**/*.rs" # Look for places that might be referencing prover types rg "Prover(Client|Type)" --glob "**/*.rs" # Check for environment variable usage in other files rg "SP1_PROVER" --glob "**/*.rs"Length of output: 1144
Integration with external systems verified – Review external dependencies and confirm environment-specific configurations
- Our codebase search did not reveal any lingering references to the old CPU-specific prover; all instantiations now correctly rely on
ProverClient::from_env()
, especially incrates/node_types/prover
.- References in other modules (such as in CLI and tests) also consistently use the environment-based prover.
- Note that
crates/zk/sp1-script
usesProverClient::builder().cuda().build()
, so please verify that this usage aligns with the intended environment-determined behavior.- Additionally, the logging of the
SP1_PROVER
environment variable incrates/cli/src/main.rs
indicates that environment-based configuration is in use.Please ensure through integration testing that all external services and clients (including those with CUDA-specific builds) correctly handle this change.
410-413
:❓ Verification inconclusive
Unified proof generation approach
The code now uses a consistent approach for proof generation with
.groth16().run()
, without conditional compilation for different proving methods. This simplifies the codebase and makes it more maintainable.However, ensure that your integration tests verify that this approach still covers all necessary proof generation scenarios.
🏁 Script executed:
#!/bin/bash # Check if there are any tests that might be affected by the proof generation change # Look for tests related to proof generation rg -A 2 -B 2 "test.*prove" --glob "**/*.rs" # Look for any code paths that might be affected by the removal of conditional compilation rg -A 2 -B 2 "cfg\(feature" --glob "**/prover/**.rs"Length of output: 2996
Unified proof generation approach verified – please double-check integration coverage
The code in
crates/node_types/prover/src/prover/mod.rs
now consistently uses.groth16().run()
, eliminating earlier conditional compilation paths. Our search showed that proof-related tests (e.g., incrates/node_types/prover/tests.rs
) are present, and no conditional compilation code is found in the prover module.Please ensure that your integration tests fully cover all proof generation scenarios, as even subtle edge cases might otherwise be missed.
Summary by CodeRabbit
New Features
Refactor
Tests
Chores