Skip to content

Conversation

@ffranr
Copy link
Contributor

@ffranr ffranr commented Dec 3, 2025

This PR tightens the proof replacement path used during block re-org handling. It explicitly ensures that we no longer ignore errors that should be surfaced, giving more reliable behaviour during re-org updates.

Key changes

  • Refactor replacement to a pure ReplaceProofInFiles function that updates supplied proof files and validates asset IDs.
  • Remove implicit side effects. Callers now fetch candidate proofs and import updates explicitly during re-org handling.
  • Strengthen error handling across proof encoding, decoding, lookup, and file validation. All errors are now surfaced instead of being ignored.
  • Add unit tests covering multiple proof-replacement scenarios triggered by re-org events.

- Replace ReplaceProofInBlob with pure ReplaceProofInFiles that updates
  provided proof blobs and validates asset IDs.
- Update re-org watcher and planter to fetch candidate proofs and
  explicitly import updates using their verifier context.

Why this helps:

- The replacement logic is now side-effect free and focused on
  transformation, making it easier to unit test.
- Fetching and importing responsibilities are explicit at call sites,
  improving clarity and making state changes easier to reason about.
@gemini-code-assist
Copy link

Summary of Changes

Hello @ffranr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness and clarity of proof replacement mechanisms, particularly during blockchain re-organizations. By introducing a pure function for proof replacement and enforcing explicit error handling, it ensures that the system behaves more reliably and predictably when updating proofs, preventing critical errors from being overlooked.

Highlights

  • Refactored Proof Replacement: The core logic for replacing proofs during re-organizations has been refactored into a new, pure function ReplaceProofInFiles, improving modularity and testability.
  • Explicit Side Effects: Implicit side effects have been removed from the proof replacement process. Callers are now responsible for explicitly fetching candidate proofs and importing updates, leading to clearer control flow.
  • Strengthened Error Handling: Error handling has been significantly improved across proof encoding, decoding, lookup, and file validation. All errors are now properly surfaced and wrapped, preventing silent failures.
  • Expanded Test Coverage: New unit tests have been added to cover various proof-replacement scenarios, including successful updates, skipping non-matching proofs, and handling mismatched asset IDs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ffranr ffranr moved this from 🆕 New to 👀 In review in Taproot-Assets Project Board Dec 3, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great improvement. It refactors the proof replacement logic into a pure function, which improves testability and separation of concerns. The error handling has been significantly strengthened by adding more context to error messages, which will make debugging much easier. The new unit tests are also a welcome addition, ensuring the new functionality is well-covered.

I've found one minor style issue that I've commented on. Otherwise, the changes look solid.

@coveralls
Copy link

coveralls commented Dec 3, 2025

Pull Request Test Coverage Report for Build 19935475562

Details

  • 89 of 136 (65.44%) changed or added relevant lines in 4 files are covered.
  • 82 unchanged lines in 20 files lost coverage.
  • Overall coverage remained the same at 56.62%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapgarden/planter.go 22 27 81.48%
tapgarden/re-org_watcher.go 25 32 78.13%
proof/archive.go 32 42 76.19%
proof/file.go 10 35 28.57%
Files with Coverage Reduction New Missed Lines %
commitment/tap.go 1 85.65%
asset/group_key.go 2 72.15%
mssmt/compacted_tree.go 2 77.19%
rfqmsg/records.go 2 70.8%
tapchannel/aux_leaf_signer.go 2 43.18%
tapdb/mssmt.go 2 89.55%
tapdb/sqlc/mssmt.sql.go 2 48.34%
tapdb/sqlc/transfers.sql.go 2 83.33%
tapdb/sqlc/universe.sql.go 2 73.71%
tapdb/universe.go 2 81.04%
Totals Coverage Status
Change from base Build 19933051412: 0.0%
Covered Lines: 64877
Relevant Lines: 114584

💛 - Coveralls

Copy link
Member

@jtobin jtobin left a comment

Choose a reason for hiding this comment

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

- The replacement logic is now side-effect free and focused on
  transformation, making it easier to unit test.
- Fetching and importing responsibilities are explicit at call sites,
  improving clarity and making state changes easier to reason about.

😍

Ensure that proof decode errors and other issues are no longer ignored.
Adds proper error propagation to make failures visible and easier to
debug.
Add unit test coverage for `ReplaceProofInFiles`.
@ffranr ffranr force-pushed the wip/re-org/ReplaceProofInFiles-refactor-test-coverage branch from 487aa3f to c7eb0cc Compare December 4, 2025 16:05
@ffranr ffranr requested a review from GeorgeTsagk December 4, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

4 participants