Skip to content

Conversation

@ffranr
Copy link
Contributor

@ffranr ffranr commented Dec 5, 2025

This PR adds ChainPorter hardening following from this bug: #1897

Add a pre-broadcast verification step to ensure split leaf outputs embed a split root that carries a populated TxWitness, preventing invalid split commitments from being broadcast.

@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 introduces a critical hardening measure to the ChainPorter component by implementing a pre-broadcast verification for split root witnesses. This enhancement ensures that all virtual packets containing split leaf outputs have correctly embedded transaction witnesses within their split roots before being broadcast, thereby preventing the propagation of invalid split commitments and improving the overall integrity and robustness of the system.

Highlights

  • Pre-broadcast Verification: A new pre-broadcast verification step has been added to ensure that split leaf outputs embed a split root that carries a populated transaction witness, preventing invalid split commitments from being broadcast.
  • Code Refactoring: The existing verifyPacketInputProofs function was refactored to handle a single virtual packet, and a new verifyVPackets function was introduced to orchestrate the verification of multiple packets, including the new split commitment witness check.
  • New Verification Function: A new function, verifySplitCommitmentWitnesses, was added to specifically check the validity of witnesses within split commitments.
  • Unit Tests: A new unit test, TestVerifySplitCommitmentWitnesses, was added to thoroughly test the new split witness verification logic with various scenarios.
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 introduces a valuable pre-broadcast verification step to ensure that split leaf outputs in Taproot Asset transactions contain a valid witness. This is a solid hardening measure. The changes are well-implemented, including the refactoring of verifyPacketInputProofs for better separation of concerns and the addition of the new verifySplitCommitmentWitnesses function with corresponding tests. My review includes a couple of suggestions to improve code clarity and conciseness by removing a redundant check and using a functional helper for a loop.

@coveralls
Copy link

coveralls commented Dec 6, 2025

Pull Request Test Coverage Report for Build 20037532411

Details

  • 36 of 56 (64.29%) changed or added relevant lines in 1 file are covered.
  • 46 unchanged lines in 12 files lost coverage.
  • Overall coverage increased (+7.0%) to 56.652%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapfreighter/chain_porter.go 36 56 64.29%
Files with Coverage Reduction New Missed Lines %
tapdb/mssmt.go 2 91.36%
tapdb/sqlc/mssmt.sql.go 2 48.34%
tapdb/sqlc/transfers.sql.go 2 83.33%
tapdb/sqlc/universe.sql.go 2 73.71%
tapgarden/custodian.go 2 76.83%
tapdb/sqlerrors.go 3 70.71%
universe/archive.go 3 81.05%
mssmt/compacted_tree.go 4 79.03%
universe/syncer.go 4 85.93%
tapdb/multiverse.go 6 79.63%
Totals Coverage Status
Change from base Build 20037487343: 7.0%
Covered Lines: 64924
Relevant Lines: 114601

💛 - Coveralls

@ffranr ffranr force-pushed the feat/split-witness-prebroadcast-check branch from a370f4a to 00fcdb5 Compare December 6, 2025 00:09
@ffranr ffranr requested review from GeorgeTsagk and jtobin December 6, 2025 00:10
@ffranr ffranr moved this from 🆕 New to 👀 In review in Taproot-Assets Project Board Dec 6, 2025
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. 👍 👍

Copy link
Member

@GeorgeTsagk GeorgeTsagk left a comment

Choose a reason for hiding this comment

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

Looks good

@ffranr ffranr added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@ffranr ffranr added this pull request to the merge queue Dec 8, 2025
github-merge-queue bot pushed a commit that referenced this pull request Dec 8, 2025
…adcast-check

tapfreighter: pre-broadcast guard for split root witnesses
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
Add `ChainPorter.verifyVPackets` as the central method for VPacket
verification, providing a general entry point for related logic.
Refactor `verifyPacketInputProofs` to accept a single VPacket argument
for verification. This simplifies unit testing and aligns better with
planned future verification logic.
@ffranr ffranr force-pushed the feat/split-witness-prebroadcast-check branch from 00fcdb5 to 2bae94f Compare December 8, 2025 17:49
@ffranr ffranr enabled auto-merge December 8, 2025 17:50
@ffranr ffranr added this pull request to the merge queue Dec 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 8, 2025
@ffranr ffranr added this pull request to the merge queue Dec 8, 2025
Merged via the queue into main with commit dd7b7c2 Dec 8, 2025
27 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Dec 8, 2025
@ffranr ffranr deleted the feat/split-witness-prebroadcast-check branch December 8, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants