Skip to content

tapgarden: surface non-critical custodian errors to subscribers#2070

Merged
jtobin merged 1 commit intolightninglabs:mainfrom
kaldun-tech:wip/surface-noncrit-custodian-errors
Apr 25, 2026
Merged

tapgarden: surface non-critical custodian errors to subscribers#2070
jtobin merged 1 commit intolightninglabs:mainfrom
kaldun-tech:wip/surface-noncrit-custodian-errors

Conversation

@kaldun-tech
Copy link
Copy Markdown
Contributor

Fixes #1942.

Adds NewAssetReceiveErrorEvent to publish error events through the existing subscriber mechanism. Error paths in inspectWalletTx, handleMailboxMessages, and mapProofToEvent now notify subscribers before returning/continuing on errors.

This enables subscribers (e.g., RPC clients watching for receives) to be notified about errors during asset receive processing, rather than only learning about successful completions or silent failures logged to the daemon.

Unit tests added for both the subscriber event flow and error event structure.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 observability of the asset receive process within the tapgarden custodian. By surfacing non-critical errors to subscribers, it enables external systems to react to failures during transaction inspection, mailbox message handling, and proof mapping. This change ensures that subscribers receive timely feedback on the status of their asset receives, improving overall system transparency and debugging capabilities.

Highlights

  • Error Event Propagation: Introduced NewAssetReceiveErrorEvent to allow the custodian to publish error events to subscribers when non-critical failures occur during asset receive processing.
  • Improved Error Visibility: Updated multiple error paths in inspectWalletTx, handleMailboxMessages, and mapProofToEvent to notify subscribers of failures, ensuring RPC clients and other observers are aware of issues instead of silent failures.
  • Testing: Added comprehensive unit tests to verify the subscriber event flow and ensure that error events are correctly structured and distinguishable from success events.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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
Copy Markdown

@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 enhances the Custodian by publishing error events to subscribers during asset reception failures in wallet transaction inspection, mailbox message handling, and proof mapping. It also refines proof mapping to capture specific event context and adds unit tests for these mechanisms. A review comment suggests optimizing event lookups in mapProofToEvent by using direct map access instead of iteration.

Comment thread tapgarden/custodian.go Outdated
Comment thread tapgarden/custodian.go
Comment thread tapgarden/custodian_test.go
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24594654080

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.1%) to 34.385%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 89 uncovered changes across 1 file (0 of 89 lines covered, 0.0%).
  • 1456 coverage regressions across 22 files.

Uncovered Changes

File Changed Covered %
tapgarden/custodian.go 89 0 0.0%

Coverage Regressions

1456 previously-covered lines in 22 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
rpcserver/rpcserver.go 519 0.0%
rfq/order.go 300 0.0%
rfq/portfolio_pilot_rpc.go 101 18.35%
authmailbox/server.go 70 75.91%
rfqmsg/request.go 63 83.21%
rfqmsg/buy_request.go 61 62.79%
rfq/negotiator.go 59 25.93%
authmailbox/receive_subscription.go 58 74.28%
rfqmsg/sell_request.go 58 64.79%
tappsbt/create.go 32 22.71%

Coverage Stats

Coverage Status
Relevant Lines: 100210
Covered Lines: 34457
Line Coverage: 34.38%
Coverage Strength: 0.37 hits per line

💛 - Coveralls

@jtobin jtobin requested review from GeorgeTsagk and jtobin April 20, 2026 06:05
Copy link
Copy Markdown
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.

Just a few changes required IMO:

  • I wrote a couple of comments re: a nil pointer deref problem and not explicitly handling decryption errors in handleMailboxMessages, please check those out.
  • The fix-up commits should be squashed into the commits that introduce the changes, or just a single fix-up commit would also be fine IMO. Please make sure they obey the change target: change summary style of other commits, too.

Comment thread tapgarden/custodian.go Outdated
Comment thread tapgarden/custodian.go Outdated
@github-project-automation github-project-automation Bot moved this from 🆕 New to 👀 In review in Taproot-Assets Project Board Apr 20, 2026
@jtobin jtobin added the testing label Apr 20, 2026
@kaldun-tech kaldun-tech force-pushed the wip/surface-noncrit-custodian-errors branch from d857e4f to 7add191 Compare April 20, 2026 18:02
@kaldun-tech
Copy link
Copy Markdown
Contributor Author

Hey Jared, thanks for the review! Addressed both points:

  1. Nil pointer deref - Now saving tapAddr and prevStatus before GetOrCreateEvent and using those in error paths (lines 741-744...).
  2. Decryption errors - Restored the original behavior (log and continue). I agree that failed decryption from external parties isn't really an asset receive error.

Also squashed everything into a single commit.

Copy link
Copy Markdown
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.

One problem introduced in the last changeset, otherwise looks clean.

Comment thread tapgarden/custodian.go Outdated
Publish AssetReceiveErrorEvent in error paths that previously only
logged, so RPC clients subscribed via SubscribeReceiveEvents can be
notified of failures.

Changes:
- inspectWalletTx: publish error events when NewTransferFromWalletTx
  or GetOrCreateEvent fails
- mapProofToEvent: refactor to capture matching event, publish errors
  when FetchProof or assertProofInLocalArchive fails
- handleMailboxMessages: publish error events for script
  key, block fetch, and event creation failures

For errors occurring before full context is available, use defaults:
confHeight=0, status=StatusTransactionDetected.

Add TestCustodianEventSubscriber to verify subscriber mechanism and
TestAssetReceiveErrorEvent to verify error event structure.

Fixes lightninglabs#1942

Signed-off-by: kaldun-tech <tsmereka@protonmail.com>
@kaldun-tech kaldun-tech force-pushed the wip/surface-noncrit-custodian-errors branch from 7add191 to 3934ef5 Compare April 21, 2026 15:30
Comment thread tapgarden/custodian.go

// Save these before GetOrCreateEvent, which may
// return nil on error.
tapAddr := event.Addr.Tap
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pass the stored *tapAddr and op (Outpoint from line 717) into the ErrorEvents

Copy link
Copy Markdown
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. 👍 👍

@jtobin jtobin added this pull request to the merge queue Apr 25, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 25, 2026
@jtobin jtobin added this pull request to the merge queue Apr 25, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 25, 2026
@jtobin jtobin added this pull request to the merge queue Apr 25, 2026
Merged via the queue into lightninglabs:main with commit b3f94c4 Apr 25, 2026
80 of 81 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Apr 25, 2026
@kaldun-tech kaldun-tech deleted the wip/surface-noncrit-custodian-errors branch April 26, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[feature]: Surface non-critical Custodian errors to UI/API

3 participants