Skip to content

Conversation

@bhandras
Copy link
Member

@bhandras bhandras commented Dec 3, 2025

UpdateTxWitness mutates a pointer into a copied root asset when a split commitment is present, so the updated TxWitness never propagates back into SplitCommitment.RootAsset. That leaves the root witness empty and produces invalid split proofs/transactions.

To mitigate this issue we write the updated witness back into the stored root asset when handling split commitments, and add a regression test that demonstrates the previous failure and now passes.

@gemini-code-assist
Copy link

Summary of Changes

Hello @bhandras, 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 resolves a critical bug in the asset management system where transaction witness updates for assets involved in split commitments were not correctly persisted. The previous implementation mutated a copy of the root asset, causing the updated witness to be lost. The fix ensures proper propagation of witness changes back to the root asset, thereby preventing the generation of invalid split proofs and transactions. A new regression test has been added to confirm the correct behavior.

Highlights

  • Witness Propagation Fix: Corrected an issue where UpdateTxWitness failed to propagate updated transaction witnesses back to the SplitCommitment.RootAsset when a split commitment was present, leading to invalid proofs.
  • Explicit Witness Writeback: Implemented an explicit writeback mechanism within UpdateTxWitness to ensure that the modified TxWitness is correctly stored in the SplitCommitment.RootAsset.
  • Regression Test Added: Introduced TestUpdateTxWitnessSplitCommitment to validate the fix and prevent future regressions, demonstrating that witnesses are now properly updated in split commitment root assets.
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.

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 correctly fixes a bug where witness updates were not being propagated to the root asset in a split commitment. The fix ensures the updated witness is written back correctly. The addition of a regression test is a great way to prevent this issue from recurring. I've added one suggestion to simplify the implementation of the fix, making it more direct and efficient.

@bhandras bhandras force-pushed the updatetxwitness-splitcommitment-copy-bug branch from 136e8d1 to 54c8ec2 Compare December 3, 2025 18:06
@bhandras
Copy link
Member Author

bhandras commented Dec 3, 2025

@gemini-code-assist pls re-review

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 effectively addresses a critical bug where witness updates were not being correctly propagated for assets with split commitments. The fix in asset.go is direct and correct, preventing the mutation of a copied struct. The addition of a regression test in asset_test.go is excellent, as it clearly demonstrates the previous failure and ensures this issue won't reappear. I've left a couple of minor suggestions: one to improve test readability by adding comments as per the style guide, and another to fix a typo in the release notes.

@bhandras bhandras force-pushed the updatetxwitness-splitcommitment-copy-bug branch from 54c8ec2 to 342b3a1 Compare December 3, 2025 18:13
@bhandras
Copy link
Member Author

bhandras commented Dec 3, 2025

@gemini-code-assist pls re-review

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 correctly addresses a bug where witness updates for assets with split commitments were not being persisted due to modifications being made on a copy of the root asset. The fix involves directly updating the witness on the nested RootAsset within the SplitCommitment. A regression test has been added, which effectively validates the fix.

My review includes a suggestion to add a comment for clarity in asset/asset.go and points out a minor typo in the release notes. Overall, the changes are solid and well-tested.

@bhandras bhandras force-pushed the updatetxwitness-splitcommitment-copy-bug branch 2 times, most recently from 829268f to a64b3e7 Compare December 3, 2025 18:17
@bhandras
Copy link
Member Author

bhandras commented Dec 3, 2025

@gemini-code-assist pls re-review

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 provides a solid fix for a critical bug where witness updates for split commitments were not being persisted correctly. The logic now correctly writes the witness back to the root asset. The addition of a targeted regression test is excellent, ensuring this issue does not reappear. The release notes have also been updated to reflect the change. I have one minor suggestion regarding formatting in the release notes for consistency.

@bhandras bhandras force-pushed the updatetxwitness-splitcommitment-copy-bug branch from a64b3e7 to 901b7e5 Compare December 3, 2025 18:21
@bhandras
Copy link
Member Author

bhandras commented Dec 3, 2025

@gemini-code-assist pls re-review

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 correctly fixes a bug where witness updates were not being persisted for assets with a split commitment. The issue was due to modifying a copy of the root asset instead of the original. The fix directly updates the witness on the original root asset, and the logic is sound. A comprehensive regression test has been added to prevent this issue from recurring. I have one minor suggestion to improve readability.

@coveralls
Copy link

coveralls commented Dec 3, 2025

Pull Request Test Coverage Report for Build 19904484275

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 57 unchanged lines in 14 files lost coverage.
  • Overall coverage increased (+0.009%) to 56.617%

Files with Coverage Reduction New Missed Lines %
fn/context_guard.go 1 91.94%
asset/group_key.go 2 72.15%
mssmt/compacted_tree.go 2 77.65%
tapdb/mssmt.go 2 90.45%
itest/assertions.go 3 87.42%
itest/multisig.go 3 97.94%
tapchannel/aux_leaf_signer.go 3 43.53%
rpcserver.go 4 61.49%
tapdb/multiverse.go 4 80.16%
tapdb/universe.go 4 80.81%
Totals Coverage Status
Change from base Build 19823124678: 0.009%
Covered Lines: 64841
Relevant Lines: 114525

💛 - Coveralls

UpdateTxWitness mutates a pointer into a copied root asset when a split
commitment is present, so the updated TxWitness never propagates back
into SplitCommitment.RootAsset. That leaves the root witness empty and
produces invalid split proofs/transactions.

To mitigate this issue we write the updated witness back into the stored
root asset when handling split commitments, and add a regression test
that demonstrates the previous failure and now passes.
@bhandras bhandras force-pushed the updatetxwitness-splitcommitment-copy-bug branch from 901b7e5 to e53c30d Compare December 3, 2025 18:25
@bhandras
Copy link
Member Author

bhandras commented Dec 3, 2025

@gemini-code-assist pls re-review

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 effectively resolves a critical bug where witness updates for split commitments were not persisted. The issue stemmed from updating a copy of the root asset instead of the original. The fix correctly modifies the witness by operating on a pointer to the root asset within the split commitment. A comprehensive regression test is included, which validates the fix by ensuring the witness is written back to the correct location. The release notes have also been updated accordingly. The changes are well-implemented and adhere to the project's coding standards.

@bhandras bhandras requested review from ffranr and jtobin December 3, 2025 18:28
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.

LGTM, nice catch. 👍 👍

@jtobin jtobin added the bug Something isn't working label Dec 4, 2025
Copy link
Contributor

@ffranr ffranr left a comment

Choose a reason for hiding this comment

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

Great find, thanks. I’m going to add verification logic to ChainPorter to harden it against this bug. We will also add better lit custom channels itest coverage.

@github-project-automation github-project-automation bot moved this from 🆕 New to 👀 In review in Taproot-Assets Project Board Dec 4, 2025
@ffranr ffranr added this pull request to the merge queue Dec 4, 2025
Merged via the queue into lightninglabs:main with commit f9731ef Dec 4, 2025
27 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Dec 4, 2025
@bhandras bhandras deleted the updatetxwitness-splitcommitment-copy-bug branch December 4, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants