Skip to content

Conversation

@starius
Copy link
Collaborator

@starius starius commented Jun 17, 2025

If a reorg happens, the saved txid prevents loop-out from discoveing new txid. So do not use this data after restart.

Added option WithSkippedTxns, which has one historical problematic tx by default. Sweeps originating from these transactions are omitted when reading from DB.

loopdb: add column sweep_batches.cancelled and replaced DropBatch with CancelBatch. It is needed, because sweep.batch_id is a foreign key to batch.

Changed StoreMock.InsertSweepBatch not to reuse batch_id. This is needed by the test, which checks that new batch has fresh ID.

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

Copy link
Collaborator

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

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

Thank you for the quick fix @starius. Iiuc this provids a fix for the current set of clients that have the precondition where different versions of batches were reorg'd, but not for future occurrences of this scenario, correct?
Just in case future clients might have to use SkippedTxs maybe it would be easier to persist the affected txns to the db and load it on restart rather than having it as a command flag to loopd or in a section of the config file.

LoopOutMaxParts uint32

// SkippedTxs is the list of existing HTLC txids to skip when starting
// Loop. This should only be used if affected by the historical bug.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe mention reorg here, so the historical reorg bug. Should we also include reorg here to make it easier to understand, like SkippedReorgdTxns?

client.go Outdated
}

if len(cfg.SkippedTxs) != 0 {
skippedTxs := make(map[chainhash.Hash]struct{})
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think usually we name it txns instead of txs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

loopd/config.go Outdated

LoopOutMaxParts uint32 `long:"loopoutmaxparts" description:"The maximum number of payment parts that may be used for a loop out swap."`

SkippedTxs []string `long:"skippedtxs" description:"The list of existing HTLC txids to skip when starting Loop. This should only be used if affected by the historical bug."`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this only need to be provided once on a restart and can then be skipped for future runs of loopd. Maybe we document the requirement here.

Could we also add a section for this new value in the sample-loopd.conf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This option is intended for testing mostly. It is not expected to be set in prod. I added hidden:"true" to it.

If a reorg happens, the saved txid prevents loop-out from discoveing new txid.
@starius starius requested a review from hieblmi June 17, 2025 16:13
@starius starius marked this pull request as ready for review June 17, 2025 16:34
Added option WithSkippedTxns, which has one historical problematic tx by default.
Sweeps originating from these transactions are omitted when reading from DB.

loopdb: add column sweep_batches.cancelled and replaced DropBatch with
CancelBatch. It is needed, because sweep.batch_id is a foreign key to batch.

Changed StoreMock.InsertSweepBatch not to reuse batch_id. This is needed by
the test, which checks that new batch has fresh ID.
Copy link
Member

@sputn1ck sputn1ck left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the fix

Copy link
Collaborator

@hieblmi hieblmi left a comment

Choose a reason for hiding this comment

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

LGTM!

@starius starius merged commit 0ca371e into lightninglabs:master Jun 17, 2025
4 checks passed
@starius starius deleted the skip-utxos branch June 17, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants