Skip to content

Conversation

@darioAnongba
Copy link
Contributor

@darioAnongba darioAnongba commented Nov 3, 2025

RFQ buy/sell accepts are now written to the database (rfq_policies table) whenever a policy is agreed, giving us an audit trail and keeping quotes across restarts.

The OrderHandler reloads these rows at startup to rebuild policies and the manager repopulates its in-memory caches from the same data.

Added a check in itest that restarts Bob’s tapd mid RFQ flow and verifies the quote remains available to Carol.

Fixes #855

@darioAnongba darioAnongba self-assigned this Nov 3, 2025
@darioAnongba darioAnongba changed the base branch from main to 0-8-0-staging November 3, 2025 14:45
@coveralls
Copy link

coveralls commented Nov 3, 2025

Pull Request Test Coverage Report for Build 19360530476

Details

  • 433 of 576 (75.17%) changed or added relevant lines in 5 files are covered.
  • 59 unchanged lines in 13 files lost coverage.
  • Overall coverage increased (+7.1%) to 56.608%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tapdb/sqlc/rfq.sql.go 53 61 86.89%
rfq/manager.go 11 27 40.74%
rfq/order.go 61 98 62.24%
tapdb/rfq_policies.go 301 383 78.59%
Files with Coverage Reduction New Missed Lines %
fn/context_guard.go 1 91.94%
tapdb/sqlc/mssmt.sql.go 2 48.34%
tapdb/sqlc/transfers.sql.go 2 83.33%
itest/assertions.go 3 87.42%
itest/multisig.go 3 97.94%
tapdb/mssmt.go 4 90.45%
tapgarden/re-org_watcher.go 4 73.49%
mssmt/compacted_tree.go 6 78.11%
tapdb/multiverse.go 6 80.59%
tapfreighter/chain_porter.go 6 83.05%
Totals Coverage Status
Change from base Build 19360481010: 7.1%
Covered Lines: 64757
Relevant Lines: 114395

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 19038516198

Details

  • 425 of 603 (70.48%) changed or added relevant lines in 5 files are covered.
  • 507 unchanged lines in 39 files lost coverage.
  • Overall coverage decreased (-0.3%) to 56.265%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rfq/manager.go 14 21 66.67%
tapdb/sqlc/rfq.sql.go 58 74 78.38%
rfq/order.go 28 72 38.89%
tapdb/rfq_policies.go 318 429 74.13%
Files with Coverage Reduction New Missed Lines %
proof/courier.go 1 78.88%
asset/asset.go 2 79.97%
asset/group_key.go 2 72.15%
fn/func.go 2 58.82%
tapdb/assets_common.go 2 77.97%
tapdb/migrations.go 2 76.19%
tapdb/sqlc/mssmt.sql.go 2 47.02%
tapdb/sqlc/transfers.sql.go 2 82.65%
tapdb/universe_federation.go 2 88.55%
tapdb/universe.go 2 80.35%
Totals Coverage Status
Change from base Build 18942913401: -0.3%
Covered Lines: 64373
Relevant Lines: 114410

💛 - Coveralls

@darioAnongba darioAnongba force-pushed the feat/persist-rfq branch 2 times, most recently from 98bcb62 to 5a2bd52 Compare November 3, 2025 15:17
@darioAnongba darioAnongba marked this pull request as ready for review November 3, 2025 15:17
@levmi levmi moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Nov 3, 2025
@levmi levmi added this to the v0.8 milestone Nov 3, 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.

Just a few nits, will do a final pass soon

@@ -0,0 +1,20 @@
package rfq
Copy link
Member

Choose a reason for hiding this comment

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

nit: file should be named policy_store.go


// cleanupStalePolicies removes expired policies from the local cache.
func (h *OrderHandler) cleanupStalePolicies() {
func (h *OrderHandler) cleanupStalePolicies() error {
Copy link
Member

Choose a reason for hiding this comment

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

you only seem to return nil here, why not remove error?

@darioAnongba darioAnongba moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Nov 17, 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.

Looking good, dropped a few more comments

// lightning node.
scid := msg.ShortChannelId()
m.peerAcceptedBuyQuotes.Store(scid, msg)
m.orderHandler.peerAcceptedBuyQuotes.Store(scid, msg)
Copy link
Member

Choose a reason for hiding this comment

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

why are we moving the maps to orderHandler if we end up calling them again from rfq.Manager?

peerAcceptedBuyQuotes: lnutils.SyncMap[
SerialisedScid, rfqmsg.BuyAccept]{},
peerAcceptedSellQuotes: lnutils.SyncMap[
SerialisedScid, rfqmsg.SellAccept]{},
Copy link
Member

Choose a reason for hiding this comment

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

why are we not initializing localAcceptedBuyQuotes / localAcceptedSellQuotes ?

Copy link
Member

Choose a reason for hiding this comment

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

actually I think the lnutils.SyncMap type doesn't need to be initialized, in that case should remove above lines


err := h.cleanupStalePolicies()
if err != nil {
log.Errorf("error in main event loop: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

nit: line break after log

sqlc.InsertRfqPolicyParams) (int64, error)

FetchActiveRfqPolicies(context.Context) (
[]sqlc.RfqPolicy, error)
Copy link
Member

Choose a reason for hiding this comment

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

fits in one line

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

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

[feature]: Persist agreed quotes in RFQ service

6 participants