Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rfqmsg: detect asset related custom records correctly #1322

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

guggero
Copy link
Member

@guggero guggero commented Jan 24, 2025

Fixes #1321.

@coveralls
Copy link

coveralls commented Jan 24, 2025

Pull Request Test Coverage Report for Build 12988277780

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 2 files are covered.
  • 32 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.01%) to 40.733%

Files with Coverage Reduction New Missed Lines %
tappsbt/create.go 2 53.22%
rfqmsg/records.go 2 73.42%
universe/interface.go 4 51.95%
tapdb/universe.go 4 80.91%
asset/mock.go 5 92.42%
asset/asset.go 7 77.0%
tapgarden/caretaker.go 8 68.11%
Totals Coverage Status
Change from base Build 12988192613: 0.01%
Covered Lines: 26752
Relevant Lines: 65677

💛 - Coveralls

@GeorgeTsagk GeorgeTsagk self-requested a review January 24, 2025 10:47
Copy link
Contributor

@gijswijs gijswijs left a comment

Choose a reason for hiding this comment

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

LGTM 🎉 Made some comments, no blockers.

rfqIDType HtlcRfqIDType
)
for key := range records {
if key == uint64(amountType.TypeVal()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns true also if there's only one of the two custom records. Are there cases where we expect one but not the other?

Copy link
Member

Choose a reason for hiding this comment

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

That's the asset keysend case I believe, there's no RFQ involved in that flow

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. Technically an HTLC isn't valid if it has only the RFQ ID an no amount (but just amount and no RFQ ID is correct for the keysend case as George mentioned).
But that logic is out of scope for this function IMO, we just want to know if there are any asset related records present.

tapchannel/aux_invoice_manager.go Outdated Show resolved Hide resolved
tapchannel/aux_invoice_manager.go Show resolved Hide resolved
@levmi levmi added this to the v0.5.1 milestone Jan 24, 2025
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.

very nice addition 🥕
LGTM

rfqIDType HtlcRfqIDType
)
for key := range records {
if key == uint64(amountType.TypeVal()) {
Copy link
Member

Choose a reason for hiding this comment

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

That's the asset keysend case I believe, there's no RFQ involved in that flow

tapchannel/aux_invoice_manager.go Show resolved Hide resolved
@GeorgeTsagk
Copy link
Member

kicking the itests

To save some space and not have a false positive on custom record
detection, we only encode the HTLC asset amounts if the list is actually
non-empty.
This is mostly to get the unit test in the next commit to work and
shouldn't have any direct real-world impact (as we should never encode
the HTLC struct into an actual wire message if there aren't any values
set inside the struct).
To detect whether an HTLC's custom records fields are values as we'd
expect them to be set for an asset HTLC, we add a new helper function.
@guggero guggero force-pushed the conditional-records branch from 5317009 to c97b302 Compare January 27, 2025 11:41
To not interfere with other custom records, we only want to count an
HTLC as an asset HTLC if it actually contains asset related custom
records.
@guggero guggero force-pushed the conditional-records branch from c97b302 to d2271e0 Compare January 27, 2025 11:47
@guggero guggero merged commit 454ee91 into main Jan 27, 2025
18 checks passed
@guggero guggero deleted the conditional-records branch January 27, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[bug]: make custom record detection more specific
5 participants