-
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: Isolate conf notifications during historical scans #1787
chainntnfs: Isolate conf notifications during historical scans #1787
Conversation
02f825f
to
63213cd
Compare
63213cd
to
b40ab48
Compare
b40ab48
to
925a658
Compare
Is this needed for initial height hint cache enabling? |
@halseth yes, and similar work needs to be done for spends |
925a658
to
0ddcce8
Compare
0ddcce8
to
08fbd20
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.
Did initial review pass.
chainntnfs/txconfnotifier.go
Outdated
confSet.ntfns[ntfn.ConfID] = ntfn | ||
|
||
switch { | ||
case ntfn.HeightHint > tcn.currentHeight: |
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.
Also comments on what is happening here.
e3b585b
to
141c5e2
Compare
chainntnfs/txconfnotifier_test.go
Outdated
@@ -139,6 +143,11 @@ func TestTxConfFutureDispatch(t *testing.T) { | |||
t.Fatalf("unable to register ntfn: %v", err) | |||
} | |||
|
|||
err = tcn.UpdateConfDetails(*ntfn2.TxID, 0, nil) |
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.
why is this added/not here from before?
chainntnfs/txconfnotifier.go
Outdated
@@ -124,35 +135,35 @@ func NewTxConfNotifier(startHeight uint32, reorgSafetyLimit uint32, | |||
// the confirmation details must be provided with the UpdateConfDetails method, | |||
// otherwise we will wait for the transaction to confirm even though it already | |||
// has. | |||
func (tcn *TxConfNotifier) Register(ntfn *ConfNtfn) error { | |||
func (tcn *TxConfNotifier) Register(ntfn *ConfNtfn) (bool, uint32, error) { |
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.
return values should be explained.
d2f2551
to
5d6d206
Compare
Needs a rebase! (I think?) |
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.
These changes are starting to look good IMO now :)
It will need a rebase, and some commits can be squashed together, as now it is a bit hard to review going in Github commit order (maybe an --ignore-date
is needed?).
chainntnfs/txconfnotifier.go
Outdated
} | ||
|
||
ntfn, ok := ntfns[clientID] | ||
ntfn, ok := confSet.ntfns[clientID] |
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.
I feel like this check could be removed in favor of the loop below now?
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.
I don't think so, otherwise we will dereference a nil confSet
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.
ahh nvm, misread. this is done in a later commit
5d6d206
to
75a7cd9
Compare
to UpdateConfDetails
This commit ensures that a confSet's details are assigned in the confNotifications index after discovering the transaction at tip. The recent changes allow a later notification to be dispatched on registration if an earlier one has already discovered the confirmation details. Before this change, it was observed that a later registration would attempt an immediate delivery, but fail to do so because the confset's details were nil. This commit remedies that dispatch path, allowing the integration tests to pass again.
…irmed at tip In this commit, we mark the rescan status for a transaction as complete if we happen to detect it has confirmed within a new block that extends the chain. We do this as otherwise, it's possible for us to not immediately dispatch the notification upon a subsequent registration due to the rescan state machine.
…n block inclusion In this commit, we'll attempt to consume a reorg notification for a transaction that was previously reorged out of the chain upon block inclusion to ensure that it is not lingering due to a client not handling it the first time.
In this commit, we address a small bug where it's possible to deliver a confirmation notification with stale confirmation details upon registration. This can happen if a transaction has confirmed but was reorged out of the chain later on, and a subsequent notification is registered.
Removes details field from conf notifications, in favor of using the details on the confSet. We also bound the requested conf depth to the reorg saftey limit, as the behavior of state tracking within the notifier is undefined otherwise.
ce395f4
to
ba28ec3
Compare
Rebased |
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 💡
In this PR, we modify the
TxConfNotifier
to isolate confirmation notifications while a historical dispatch is being processed. The purpose of this is to segment which notifications should have their height hints updated in the cache. During a historical rescan, we don't yet know if the txn is in the chain, so we shouldn't continue to update its height hint until after finishing the rescan. Once the rescan finishes, the notification is grouped along with all other notifications at tip so that their height hints can progress as blocks are added.This PR also introduces:
TxConfNotifier
In a follow PR, we will do the same for spend notifications.
This PR depends on #1951, which contains the first four commits