-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lnrpc: add incoming/outgoing channel ids filter to forwarding history request #9356
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
lnrpc: add incoming/outgoing channel ids filter to forwarding history request #9356
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 (
|
Some CI are failing and the logs have expired. Could you rebase and push? |
21b7c97
to
12f979a
Compare
Rebased and pushed |
Great. I will drop a review tomorrow. In the meantime I think the lint CI is failing; I think all you need to do is add an empty line after the statement here |
Fixed the linting issue |
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 looks very neat. I just left a few nits and suggestions. Also don't forget to add a release-note.
I also tested this with a cluster of 3 nodes alice
-> bob
-> hank
, made some transactions and the lncli fwdinghistory --incoming_chan_ids=<...> --outgoing_chan_ids=<...>
works as expected, works correctly with the other existing params --max_events, --index_offset, ...
Good job!
cmd/commands/cmd_payments.go
Outdated
@@ -1597,6 +1611,21 @@ func forwardingHistory(ctx *cli.Context) error { | |||
NumMaxEvents: maxEvents, | |||
PeerAliasLookup: lookupPeerAlias, | |||
} | |||
outChan := ctx.Int64Slice("outgoing_chan_ids") |
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.
nit: could use outgoingChanIDs
(and incomingChanIDs
down) makes it immediately clear that these variables hold channel identifiers
channeldb/forwarding_log_test.go
Outdated
|
||
require.Equal(t, expectedEvents, timeSlice.ForwardingEvents, | ||
"unexpected events returned") | ||
} |
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 think we should also test for when IncomingChanIDs
and OutgoingChanIDs
are specified simultaneously.
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.
agreed
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.
@funyug - i think instead of having 2 verbose tests, you can just have 1 table driven tests with the various scenarios and expected results.
1040e23
to
9ae99da
Compare
Thanks. Did the changes requested above, added the release note and rebased and squashed the commits. |
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 🚀
Left one more nit.
Also consider splitting your future PRs into structured commits to ease the review process.
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.
nit: maybe add your name under the contributors' section like it's done here
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.
added
9ae99da
to
ad4b755
Compare
Thanks. Will split the PR into multiple commits in future. |
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.
Thanks for the feature. Looks pretty good, have a few simplifications to suggest.
channeldb/forwarding_log.go
Outdated
|
||
// If both conditions are met, then we'll add | ||
// the event to our return payload. | ||
if incomingMatch && outgoingMatch { |
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.
Could invert this condition and do a continue
. Then the rest of the code could continue without an additional level of indentation.
channeldb/forwarding_log_test.go
Outdated
eventQuery := ForwardingEventQuery{ | ||
StartTime: initialTime, | ||
EndTime: endTime, | ||
IncomingChanIDs: fn.NewSet(incomingChanIDs[0].ToUint64(), |
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.
nit: format these fn.NewSet()
calls like other multi-line function calls.
Technically, the require.NoError()
calls also fall under that rule, since they don't use string formatting templates (e.g. the function name doesn't end in an f
to indicate formatting).
channeldb/forwarding_log_test.go
Outdated
} | ||
} | ||
|
||
require.Equal(t, expectedEvents, timeSlice.ForwardingEvents, |
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.
See my comment above. IMO those additional context strings can just be omitted to make things tidier. The generated error message if this fails is pretty clear where things fail and what expectation failed. So often no additional context is needed in the first place.
channeldb/forwarding_log_test.go
Outdated
|
||
// TestForwardingLogQueryOutgoingChanIDs tests that querying the forwarding log | ||
// using only outgoing channel IDs returns the correct subset of events. | ||
func TestForwardingLogQueryOutgoingChanIDs(t *testing.T) { |
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.
Could this test be combined with the above? Creating events with both incoming and outgoing IDs, then do two different queries and compare the results?
rpcserver.go
Outdated
incomingChanIDs = make(fn.Set[uint64], len(req.IncomingChanIds)) | ||
outgoingChanIDs = make(fn.Set[uint64], len(req.OutgoingChanIds)) | ||
for _, chanID := range req.IncomingChanIds { | ||
incomingChanIDs.Add(chanID) | ||
} | ||
|
||
for _, chanID := range req.OutgoingChanIds { | ||
outgoingChanIDs.Add(chanID) | ||
} | ||
|
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.
Can just be:
incomingChanIDs := fn.NewSet(req.IncomingChanIds...)
outgoingChanIDs := fn.NewSet(req.OutgoingChanIds...)
ad4b755
to
ab53876
Compare
Did the changes mentioned above. Created a fixup commit and rebased the branch. |
Will take a look once |
@guggero I see 0.19.0-beta is out. Should i rebase it for review now? |
Yes please. |
ab53876
to
0e70bf1
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.
There are some unresolved comments from my last review. Can you please address those? This is quite close otherwise.
Can you point me to the ones that are unresolved. I think I did fix them all in the last commit. |
@funyug, remember to re-request review from reviewers when ready |
@guggero waiting for further instructions |
Hmm, I must've looked at an old version by accident. Looks good now, thanks. |
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.
logic LGTM! I'll Approve it once the fixup commits have been squashed.
It's fine for this PR since it is relatively small, but I'd suggest that for future you try to structure your commits as follows:
- first make the internal server changes (ie all your changes to
channeldb
and the unit test there. Ie, at this step the server can do the new thing but hasnt exposed the functionality yet. - Add the new proto fields (ie, expose the new server functionality)
- Finally, update the client (lncli) to make use of the new server functionality.
This type of structure makes it way easier for a reviewer to "read" the PR
channeldb/forwarding_log_test.go
Outdated
|
||
require.Equal(t, expectedEvents, timeSlice.ForwardingEvents, | ||
"unexpected events returned") | ||
} |
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.
agreed
channeldb/forwarding_log_test.go
Outdated
|
||
require.Equal(t, expectedEvents, timeSlice.ForwardingEvents, | ||
"unexpected events returned") | ||
} |
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.
@funyug - i think instead of having 2 verbose tests, you can just have 1 table driven tests with the various scenarios and expected results.
@funyug - some changes were made to an area touched by this PR recently - so you'll need to please fix the merge conflicts 🙏 |
587e4ef
to
b1cb0bc
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.
thanks @funyug 🙏
Please re-request review from me once you have squashed the fixup commits and addressed the test related comment 🙏
74c846e
to
6440b25
Compare
@ellemouton updated the tests as requested. Also fixed the linting issue, conflicts and squashed. |
This commit adds incoming and outgoing channel ids filter to forwarding history request to filter events received/forwarded from/to a particular channel
6440b25
to
bfe1edf
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.
thanks! LGTM! 🚀
fixes #5932
Change Description
This PR adds incoming channel ids and outgoing channel ids filter to forwarding history rpc call by introducing incoming_channel_ids and outgoing_channel_ids parameters to filter the events.
Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.