htlcswitch: exit early if no adds are in the fwd pkg#9911
htlcswitch: exit early if no adds are in the fwd pkg#9911Roasbeef merged 1 commit intolightningnetwork:masterfrom
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
yyforyongyu
left a comment
There was a problem hiding this comment.
would always record a HTLC two times in the decayed log (batch-replay bucket) protection
When there are no Adds it's a noop?
|
I actually verified on my local node and HTLC will be persisted 2 times in the batch-reply log, here is the flow: Line 3761 in 4a7cd00 We start the batch_replay tx here: lnd/htlcswitch/hop/iterator.go Line 756 in 4a7cd00 it persist the empty batch in the batch-reply here: lnd/htlcswitch/hop/iterator.go Line 831 in 4a7cd00 which happens here: and writes it eventually here: Line 407 in 4a7cd00 |
yyforyongyu
left a comment
There was a problem hiding this comment.
I actually verified on my local node and HTLC will be persisted 2 times in the batch-reply log, here is the flow:
Nice analysis! I'm wondering why would call processRemoteAdds with empty ADDs?
| func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { | ||
| // Exit early if there are no adds to process. | ||
| if len(fwdPkg.Adds) == 0 { | ||
| return |
There was a problem hiding this comment.
Let's add a log here since it's unexpected to have empty Adds here
There was a problem hiding this comment.
It is not unexpeted tho, every HTLC will eventually be resolved and then the fwd has only Fail/Settles no ADDs, I can add a trace if you want ? In case no other HTLC is added while the first one is Removed.
FWD PKG 1 => adds the invoming HTLC onto the Channel
FWD PKG 2 => resolves the HTLC via an FAIL/Settle and has 0 ADDs in the single HTLC flow.
There was a problem hiding this comment.
yeah right - we sort just move the empty check into the methods, so they are always called.
a7219c0 to
d82b1b8
Compare
This lead to the case that we would always record a HTLC two times in the decayed log protection which is not necessary in the first place.
d82b1b8 to
6feed32
Compare
| func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) { | ||
| // Exit early if there are no adds to process. | ||
| if len(fwdPkg.Adds) == 0 { | ||
| return |
There was a problem hiding this comment.
yeah right - we sort just move the empty check into the methods, so they are always called.
This lead to the case that we would always record a HTLC
two times in the decayed log (batch-replay bucket) protection which is not necessary
in the first place.
We already do it for the settle/fail package:
lnd/htlcswitch/link.go
Lines 3626 to 3628 in 4a7cd00