-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
chainntnfs: validate conf/spend ntfn registration parameters #3405
chainntnfs: validate conf/spend ntfn registration parameters #3405
Conversation
fb17176
to
89cd6a8
Compare
89cd6a8
to
10af31e
Compare
As a result of having the validation checks being done at the chain notifier level, a bug was discovered with the BumpFee RPC that would cause us to scan the chain from genesis due to a 0 height hint. See the relevant commit for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🥓
1556a7c
to
becd3d2
Compare
becd3d2
to
6244950
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pr did get quite out of hand. I didn't expect the move of subscription logic to txNotifier
to involve so many changed lines of code. To me the end result looks definitely like an improvement. I hope you found it worthwhile to do. I left some non-blocking comments.
@@ -690,9 +677,12 @@ func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, | |||
// | |||
// We'll update our filter first to ensure we can immediately detect the | |||
// spend at tip. | |||
if outpoint == nil { | |||
outpoint = &chainntnfs.ZeroOutPoint | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this as first thing in this function, so that txNotifier.RegisterSpend
can accept it as a value parameter?
err) | ||
} | ||
confs := int64(0) | ||
if txDetail.Block.Height != -1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
means unconfirmed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's what's returned by the underlying call for unconfirmed transactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const unconfirmed = -1
would be nice
A height hint not being set would cause lnd to scan for the confirmation/spend of a txid/outpoint/address from genesis. The number of confirmations not being set within a confirmation request would cause the internal TxNotifier to deadlock when dispatching updates.
This prevents a deadlock while tearing down the TxNotifier if it's currently blocked delivering a notification. By closing the quit chan first, we ensure blocked sends/reads can exit and allow the TxNotifier to proceed tearing down.
These fields are only relevant for spent transaction outputs.
The cache wasn't really serving a purpose as FetchInputInfo isn't known to be a hot path. Also, with a planned addition of returning the confirmation status of an output within FetchInputInfo in a later commit, caching won't be useful as we'll have to go to disk anyway to determine the confirmation status.
We already have all of the information required for the outputs from the ListUnspent method.
In this commit, we address an issue that would cause us to scan from the genesis block for the spend of an output that we wish to use to raise the fee of a transaction through CPFP. This was due to setting a 0 height hint when constructing the input required by the sweeper and was discovered due to the recently added validation checks at the chain notifier level. We'll now use the current height as the height hint instead as the sweeper will end up creating a new transaction that spends the input.
6244950
to
2cc5891
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌 nice to see chainntnfs getting some more love!
I see an issue here where I get this error when trying to restore an SCB
|
A height hint not being set would cause lnd to scan for the confirmation/spend of a txid/outpoint/address from genesis.
The number of confirmations not being set within a confirmation request would cause the internal TxNotifier to deadlock when dispatching updates. To prevent this, we default to dispatching a notification upon one confirmation.
Fixes #3398.