Skip to content

Conversation

Zombeescott
Copy link
Contributor

@Zombeescott Zombeescott commented Jun 17, 2025

Summary by CodeRabbit

  • New Features

    • Introduced detailed error messages for proof verification, providing clearer feedback when verification fails.
  • Refactor

    • Improved error handling in proof verification by switching to structured, domain-specific error types instead of generic errors.
  • Chores

    • Updated dependencies to include new workspace libraries for enhanced error handling and encoding.
    • Removed unused import statements for cleaner code.

Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
prism ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 23, 2025 6:52am

Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce structured error handling in the proof verification logic by replacing generic anyhow errors with a custom ProofError enum. The dependency management is updated to include bincode and thiserror as workspace dependencies. An unused import is removed from a common transaction module.

Changes

File(s) Change Summary
crates/tree/src/proofs.rs Refactored error handling in proof verification to use a new ProofError enum instead of anyhow; updated method signatures and error propagation accordingly.
crates/tree/Cargo.toml Added bincode and thiserror as workspace dependencies.
crates/common/src/transaction.rs Removed unused import of anyhow::Result.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Batch
    participant InsertProof
    participant UpdateProof
    participant ProofError

    Caller->>Batch: verify()
    Batch->>Batch: internal verification logic
    alt InsertProof needed
        Batch->>InsertProof: verify(service_challenge)
        InsertProof-->>Batch: Result<(), ProofError>
    end
    alt UpdateProof needed
        Batch->>UpdateProof: verify()
        UpdateProof-->>Batch: Result<(), ProofError>
    end
    Batch-->>Caller: Result<(), ProofError>
    Note right of ProofError: Structured error variants returned on failure
Loading

Suggested reviewers

  • distractedm1nd

Poem

In the warren of code, where errors once hid,
Now ProofError hops, with messages amid.
No more generic bails, just structure and grace,
With bincode and thiserror joining the race.
The garden grows tidy, dependencies in line—
This rabbit approves, and all will be fine! 🐇✨

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment

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 auto-generate unit tests to generate unit tests for 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

@distractedm1nd distractedm1nd left a comment

Choose a reason for hiding this comment

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

get it together boy

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

🧹 Nitpick comments (1)
crates/tree/Cargo.toml (1)

28-31: Consider dropping anyhow from this crate

With ProofError + thiserror in place, prism-tree no longer needs the full anyhow dependency (only the Context extension trait is used).
Replacing those few .context() calls with explicit mapping removes a heavy crate:

-anyhow.workspace = true

and adjust code accordingly.
Reduces build time & binary size.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0f750ef and e12d26b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • crates/common/src/operation.rs (1 hunks)
  • crates/common/src/transaction.rs (0 hunks)
  • crates/tree/Cargo.toml (1 hunks)
  • crates/tree/src/proofs.rs (9 hunks)
💤 Files with no reviewable changes (1)
  • crates/common/src/transaction.rs
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: unused dependencies
  • GitHub Check: clippy
  • GitHub Check: coverage
  • GitHub Check: unit-test
  • GitHub Check: integration-test
🔇 Additional comments (1)
crates/tree/src/proofs.rs (1)

128-137: Leaking anyhow back into the new API

verify() now returns Result<_, ProofError> yet still calls .context() which converts the inner error to anyhow::Error, immediately string-ifying it. This re-introduces an anyhow dependency just for message decoration.

Replace with custom context or direct mapping to keep the crate anyhow-free:

-        self.non_membership_proof
-            .verify_nonexistence()
-            .context("Invalid NonMembershipProof")
-            .map_err(|e| ProofError::NonexistenceError(e.to_string()))?;
+        self.non_membership_proof
+            .verify_nonexistence()
+            .map_err(|e| ProofError::NonexistenceError(format!("Invalid NonMembershipProof: {e}")))?;

[ suggest_optional_refactor ]

Copy link

codecov bot commented Jun 17, 2025

Codecov Report

Attention: Patch coverage is 67.92453% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/tree/src/proofs.rs 67.92% 7 Missing and 10 partials ⚠️

📢 Thoughts on this report? Let us know!

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

🔭 Outside diff range comments (1)
crates/tree/src/proofs.rs (1)

74-82: assert_eq! causes panics – return a typed error instead

Using assert_eq! here aborts execution on mismatch instead of returning a recoverable ProofError.

-assert_eq!(root, self.new_root);
+if root != self.new_root {
+    return Err(ProofError::VerificationError(
+        "root mismatch after processing batch".to_string(),
+    ));
+}
♻️ Duplicate comments (2)
crates/tree/src/proofs.rs (2)

42-44: Signature still relies on the shadowed alias

Because of the import above, this line currently refers to the wrong Result:

pub fn verify(&self) -> Result<(), ProofError>

After dropping the alias, update the signature:

-pub fn verify(&self) -> Result<(), ProofError> {
+pub fn verify(&self) -> std::result::Result<(), ProofError> {

Without the change, the file will not compile.
(The same fix is required for InsertProof::verify and UpdateProof::verify.)


262-279: MissingServiceProof enum variant is dead code

MissingServiceProof is defined but never used (all call-sites raise MissingServiceChallenge).
Keeping unused variants bloats the API surface and invites confusion.

-    #[error("service proof is missing from batch for create account verification: {0}")]
-    MissingServiceProof(String),

Remove the variant (or wire it into Batch::verify) and run cargo clippy -- -D dead_code to prevent regressions.

🧹 Nitpick comments (1)
crates/tree/src/proofs.rs (1)

128-133: Still coupling to anyhow::Context; consider removing the dependency entirely

The new error model no longer needs anyhow, yet .context() keeps the dependency alive.
If you want to keep the rich-context behaviour, re-implement it via a helper, otherwise simplify:

-self.non_membership_proof
-    .verify_nonexistence()
-    .context("Invalid NonMembershipProof")
-    .map_err(|e| ProofError::NonexistenceError(e.to_string()))?;
+self.non_membership_proof
+    .verify_nonexistence()
+    .map_err(|e| ProofError::NonexistenceError(format!("Invalid NonMembershipProof: {e}")))?;

This lets you drop the anyhow crate completely.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e12d26b and 9ba6266.

📒 Files selected for processing (2)
  • crates/tree/Cargo.toml (1 hunks)
  • crates/tree/src/proofs.rs (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/tree/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: clippy
  • GitHub Check: unused dependencies
  • GitHub Check: coverage
  • GitHub Check: unit-test
  • GitHub Check: integration-test

@distractedm1nd distractedm1nd enabled auto-merge (squash) June 23, 2025 06:52
@distractedm1nd distractedm1nd merged commit a9846df into deltadevsde:main Jun 23, 2025
8 of 9 checks passed
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.

2 participants