Merge pull request #7083 from hieblmi/fwdinghistory-alias-opt-in

rpcserver: opting-in to peer alias lookup in `ForwardingHistory`
This commit is contained in:
Oliver Gugger authored and GitHub committed 2022-10-27 14:04:52 +02:00
commit 281cdd4209
7 files changed
+802 -779

No files matched your search

+9 -5
View File
@@ -1371,12 +1371,16 @@ func forwardingHistory(ctx *cli.Context) error {
maxEvents = uint32(m) maxEvents = uint32(m)
} }
// By default we will look up the peers' alias information unless the
// skip_peer_alias_lookup flag is specified.
lookupPeerAlias := !ctx.Bool("skip_peer_alias_lookup")
req := &lnrpc.ForwardingHistoryRequest{ req := &lnrpc.ForwardingHistoryRequest{
StartTime: startTime, StartTime: startTime,
EndTime: endTime, EndTime: endTime,
IndexOffset: indexOffset, IndexOffset: indexOffset,
NumMaxEvents: maxEvents, NumMaxEvents: maxEvents,
SkipPeerAliasLookup: ctx.Bool("skip_peer_alias_lookup"), PeerAliasLookup: lookupPeerAlias,
} }
resp, err := client.ForwardingHistory(ctxc, req) resp, err := client.ForwardingHistory(ctxc, req)
if err != nil { if err != nil {
+5 -4
View File
@@ -41,10 +41,11 @@
`openchannel`](https://github.com/lightningnetwork/lnd/pull/6956) `openchannel`](https://github.com/lightningnetwork/lnd/pull/6956)
* [`ForwardingHistory` ](https://github.com/lightningnetwork/lnd/pull/7001) now * [`ForwardingHistory` ](https://github.com/lightningnetwork/lnd/pull/7001) now
enriches each forwarding event with inbound and outbound peer alias names. In enriches each forwarding event with inbound and outbound peer alias names if
order for UIs to preserve the performance of this RPC the alias lookup can be the new flag `PeerAliasLookup` in `ForwardingHistoryRequest` is set to true.
skipped by specifying `skip_peer_alias_lookup`. `lncli fwdinghistory` also [`lncli fwdinghistory` ](https://github.com/lightningnetwork/lnd/pull/7083)
adds a flag `skip_peer_alias_lookup` to skip the lookup. enables this feature by default but adds a new flag `skip_peer_alias_lookup`
to skip the lookup.
* The graph lookups method `DescribeGraph`, `GetNodeInfo` and `GetChanInfo` now * The graph lookups method `DescribeGraph`, `GetNodeInfo` and `GetChanInfo` now
[expose tlv data](https://github.com/lightningnetwork/lnd/pull/7085) that is [expose tlv data](https://github.com/lightningnetwork/lnd/pull/7085) that is
+761 -761
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -4059,9 +4059,9 @@ message ForwardingHistoryRequest {
// The max number of events to return in the response to this query. // The max number of events to return in the response to this query.
uint32 num_max_events = 4; uint32 num_max_events = 4;
// Informs the server if the peer alias lookup per forwarding event // Informs the server if the peer alias should be looked up for each
// should be skipped in order to improve performance. // forwarding event.
bool skip_peer_alias_lookup = 5; bool peer_alias_lookup = 5;
} }
message ForwardingEvent { message ForwardingEvent {
// Timestamp is the time (unix epoch offset) that this circuit was // Timestamp is the time (unix epoch offset) that this circuit was
+2 -2
View File
@@ -4496,9 +4496,9 @@
"format": "int64", "format": "int64",
"description": "The max number of events to return in the response to this query." "description": "The max number of events to return in the response to this query."
}, },
"skip_peer_alias_lookup": { "peer_alias_lookup": {
"type": "boolean", "type": "boolean",
"description": "Informs the server if the peer alias lookup per forwarding event\nshould be skipped in order to improve performance." "description": "Informs the server if the peer alias should be looked up for each\nforwarding event."
} }
} }
}, },
+21 -3
View File
@@ -277,14 +277,32 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) {
ctxt, &lnrpc.ForwardingHistoryRequest{}, ctxt, &lnrpc.ForwardingHistoryRequest{},
) )
require.NoError(t.t, err) require.NoError(t.t, err)
require.EqualValues( require.Len(t.t, fwdingHistory.ForwardingEvents, numPayments)
t.t, numPayments, len(fwdingHistory.ForwardingEvents),
)
expectedForwardingFee := uint64(expectedFeeDave / numPayments) expectedForwardingFee := uint64(expectedFeeDave / numPayments)
for _, event := range fwdingHistory.ForwardingEvents { for _, event := range fwdingHistory.ForwardingEvents {
// Each event should show a fee of 170 satoshi. // Each event should show a fee of 170 satoshi.
require.Equal(t.t, expectedForwardingFee, event.Fee) require.Equal(t.t, expectedForwardingFee, event.Fee)
// Check that peer aliases are empty since the
// ForwardingHistoryRequest did not specify the PeerAliasLookup
// flag.
require.Empty(t.t, event.PeerAliasIn)
require.Empty(t.t, event.PeerAliasOut)
}
// Lookup the forwarding history again but this time also lookup the
// peers' alias names.
fwdingHistory, err = dave.ForwardingHistory(
ctxt, &lnrpc.ForwardingHistoryRequest{
PeerAliasLookup: true,
},
)
require.NoError(t.t, err)
require.Len(t.t, fwdingHistory.ForwardingEvents, numPayments)
for _, event := range fwdingHistory.ForwardingEvents {
// Each event should show a fee of 170 satoshi.
require.Equal(t.t, expectedForwardingFee, event.Fee)
// Check that peer aliases adhere to payment flow, namely // Check that peer aliases adhere to payment flow, namely
// Carol->Dave->Alice. // Carol->Dave->Alice.
require.Equal(t.t, carolAlias, event.PeerAliasIn) require.Equal(t.t, carolAlias, event.PeerAliasIn)
+1 -1
View File
@@ -6892,7 +6892,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
AmtOutMsat: uint64(amtOutMsat), AmtOutMsat: uint64(amtOutMsat),
} }
if !req.SkipPeerAliasLookup { if req.PeerAliasLookup {
aliasIn, err := getRemoteAlias(event.IncomingChanID) aliasIn, err := getRemoteAlias(event.IncomingChanID)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to lookup peer "+ return nil, fmt.Errorf("unable to lookup peer "+