-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lnrpc: add HtlcIndex to ForwardingEvents #9813
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
base: master
Are you sure you want to change the base?
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 (
|
f4c5fd9
to
009584f
Compare
Thanks for the PR. |
Thanks for the heads up. I will check how this was handled before in previous PRs. For now, I will change this to a draft. |
009584f
to
cb09e8c
Compare
cb09e8c
to
a775db2
Compare
Thanks again for the early feedback, @guggero. I thought about writing a migration script or handling the EOF error, but I decided to handle the EOF error when decoding the events (Let me know if a migration is preferred instead). Also, does it make sense to set a default value of "0" when returning older event logs?. This means if you execute |
Definitely looks better now, thanks for the update. I think because |
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 PR!
For forwarding events we need to have both incoming and outgoing htlc index.
A migration would be nice, tho I don't think it's possible since we cannot get the htlc index info. Alternative to fn.Option
, we can use a tlv record instead, sth like tlv.BigSizeT
to save the space since for a busy node the logs can be huge.
We should also update the RPC docs, and release docs to mention this behavior.
lnrpc/lightning.proto
Outdated
@@ -4710,6 +4710,10 @@ message ForwardingEvent { | |||
// The peer alias of the outgoing channel. | |||
string peer_alias_out = 13; | |||
|
|||
// The index of the HTLC in the channel. This allows for better tracking |
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: typo in the commit fwdinghiatory -> fwdinghistory
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.
Addressed
htlcswitch/switch.go
Outdated
@@ -3074,6 +3074,7 @@ func (s *Switch) handlePacketSettle(packet *htlcPacket) error { | |||
OutgoingChanID: circuit.Outgoing.ChanID, | |||
AmtIn: circuit.IncomingAmount, | |||
AmtOut: circuit.OutgoingAmount, | |||
HtlcIndex: circuit.Incoming.HtlcID, |
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.
For forwarding events I think we need to have both indices? like what we have in the htlcPacket
, which has both incomingHTLCID
and outgoingHTLCID
. Or like the RPC routerrpc.HtlcEvent
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
rpcserver.go
Outdated
@@ -8060,6 +8060,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context, | |||
FeeMsat: uint64(feeMsat), | |||
AmtInMsat: uint64(amtInMsat), | |||
AmtOutMsat: uint64(amtOutMsat), | |||
HtlcIndex: event.HtlcIndex, |
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.
let's also update the test here to check the change,
lnd/itest/lnd_multi-hop-payments_test.go
Lines 183 to 184 in 3707b1f
fwdingHistory := dave.RPC.ForwardingHistory(nil) | |
require.Len(ht, fwdingHistory.ForwardingEvents, numPayments) |
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.
Updated to check for the change 👍
|
||
// TestForwardingLogDecodeForwardingEvent tests that we're able to decode | ||
// forwarding events that don't have the new HtlcIndex field. | ||
func TestForwardingLogDecodeForwardingEvent(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.
👍
In this commit we add htlcindex field to the forwardingevent struct, which is persisted alongside the other event fields.
a775db2
to
a6343fe
Compare
In this commit we update the returned message for fwdinghistory to include the htlcindex for all forwarded htlcs.
a6343fe
to
5b070cb
Compare
Now using |
Thanks for the review @yyforyongyu. The ....
// IncomingHtlcID is the ID of the incoming HTLC in the payment circuit.
// If the HTLC ID is not set, the value will be nil.
IncomingHtlcID tlv.OptionalRecordT[tlv.TlvType0, tlv.BigSizeT[uint64]]
// OutgoingHtlcID is the ID of the outgoing HTLC in the payment circuit.
// If the HTLC ID is not set, the value will be nil.
OutgoingHtlcID tlv.OptionalRecordT[tlv.TlvType0, tlv.BigSizeT[uint64]]
... and then checking if the indices are set in the encode and decode functions? |
Change Description
Fixes #9656
This PR adds a new
HtlcIndex
field to theForwardingEvent
to improve HTLC tracking and reconciliation.The
HtlcIndex
field is populated using the incoming HtlcId from the circuit when creating forwarding events. This allows for matching HTLCs between channel state and forwarding log.To ensure everything works well together, we handle
EOF
errors by setting theHtlcIndex
field to a default value of "0" for olderForwardingEvents
that do not have this field.Steps to Test
HtlcIndex
of the payments' htlc are present in the response fromlncli fwdinghistory
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.