Skip to content

Conversation

@ffranr
Copy link
Contributor

@ffranr ffranr commented Nov 18, 2025

  • Introduce SendStateVerifyPreBroadcast so ChainPorter re-validates anchor inputs/outputs immediately before broadcast, covering the pre-anchored RPC path that previously skipped this check
  • Refactor validateInputAssets to expose the purged/tombstone assets it already collects, ensuring the RPC layer can pass the complete tap tree data into ChainPorter’s new validation state
  • Wire the pruned asset map through PublishAndLogTransfer → pre-anchored parcel → sendPackage, allowing the new pre-broadcast validation to succeed even when the original input commitments aren’t locally available

@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 resolves an issue where pre-anchored transaction sends could fail due to an "anchor input script mismatch" during the final pre-broadcast validation in ChainPorter. The core problem was that the full set of assets, including "purged assets" like tombstones or burns, was not consistently available throughout the transaction lifecycle for pre-anchored RPC flows. The changes introduce a dedicated pre-broadcast verification step, refactor asset validation to expose these purged assets, and ensure they are correctly propagated to ChainPorter's final validation stage, thereby guaranteeing that the reconstructed tap tree matches the on-chain script.

Highlights

  • Enhanced Pre-Broadcast Validation: Introduced a new SendStateVerifyPreBroadcast state within ChainPorter to ensure re-validation of anchor inputs/outputs immediately before transaction broadcast, specifically addressing pre-anchored RPC paths.
  • Refactored Asset Handling: Modified validateInputAssets to explicitly return "purged assets" (tombstones/burns) that are part of an input commitment but not re-created in outputs, making this crucial data available for later validation steps.
  • Improved Data Flow for Validation: Wired the collected purged assets through the PublishAndLogTransfer function into the PreAnchoredParcel and sendPackage, allowing the new pre-broadcast validation to succeed even when original input commitments are not locally available.
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 pre-broadcast validation step for pre-anchored sends in ChainPorter to fix a bug where validation would fail due to missing information about purged assets. The changes are well-structured, extracting the logic to collect purged assets into a new collectPurgedAssets function and correctly plumbing this information through the RPC layer down to the ChainPorter. The refactoring is clean and the fix appears correct and robust. I have one minor suggestion for improving code readability.

Comment on lines +2936 to +2940
for key := range assets {
purgedAssets[outpoint] = append(
purgedAssets[outpoint], assets[key],
)
}

Choose a reason for hiding this comment

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

medium

This inner loop can be simplified by iterating over the map's values directly, instead of its keys. This is more idiomatic and slightly more readable.

Suggested change
for key := range assets {
purgedAssets[outpoint] = append(
purgedAssets[outpoint], assets[key],
)
}
for _, asset := range assets {
purgedAssets[outpoint] = append(
purgedAssets[outpoint], asset,
)
}

@ffranr ffranr force-pushed the wip/add-chainporter-prebroadcast-validation-state branch 2 times, most recently from 9f385e4 to c1e9b99 Compare November 18, 2025 19:41
Introduce SendStateVerifyPreBroadcast to handle the final verification
step before broadcasting. This isolates the logic from earlier states
and improves clarity in the send flow. Subsequent commits will extend
this state with additional proof verification logic.
We will later make use of the purged asset set at validateInputAssets
callsites.
Return the pruned leaves discovered in rpcServer.validateInputAssets and
store them in the pre-anchored parcel so ChainPorter can include them
when re-running ValidateAnchorInputs. PublishAndLogTransfer now forwards
that map, sendPackage/ChainPorter merge it with any locally derived
commitments, and other callers keep passing nil when they still have the
full taproot input state.
@ffranr ffranr force-pushed the wip/add-chainporter-prebroadcast-validation-state branch from c1e9b99 to c715986 Compare November 19, 2025 12:57
@coveralls
Copy link

Pull Request Test Coverage Report for Build 19502103674

Details

  • 75 of 77 (97.4%) changed or added relevant lines in 5 files are covered.
  • 71 unchanged lines in 17 files lost coverage.
  • Overall coverage decreased (-0.008%) to 56.415%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapchannel/aux_closer.go 0 1 0.0%
tapchannel/aux_funding_controller.go 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
fn/context_guard.go 1 91.94%
asset/group_key.go 2 72.15%
commitment/tap.go 2 85.19%
tapdb/assets_common.go 2 78.34%
universe/supplyverifier/manager.go 2 64.53%
itest/multisig.go 3 97.94%
tapchannel/aux_leaf_signer.go 3 43.53%
tapdb/interfaces.go 3 80.0%
tapdb/sqlerrors.go 3 70.71%
asset/asset.go 4 80.13%
Totals Coverage Status
Change from base Build 19501755090: -0.008%
Covered Lines: 64001
Relevant Lines: 113447

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

3 participants