routing+migration32: update migration 32 to use pure TLV encoding for mission control results#9167
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 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
9057d4e to
b666a60
Compare
guggero
left a comment
There was a problem hiding this comment.
tACK, LGTM 🎉
Just a couple of nits and suggestions.
bitromortac
left a comment
There was a problem hiding this comment.
Looks great ⚡, will do some more tests.
| } | ||
|
|
||
| // Record returns a TLV record that can be used to encode/decode a list of | ||
| // mcRoute to/from a TLV stream. |
There was a problem hiding this comment.
s/list of mcRoute/failureMessage/
There was a problem hiding this comment.
nit: a list of is still present, same for Record of mcRoute (in the migration as well)
9154415 to
4d8aa29
Compare
ellemouton
left a comment
There was a problem hiding this comment.
Thanks yall, updated
| } | ||
|
|
||
| // Record returns a TLV record that can be used to encode/decode a list of | ||
| // mcRoute to/from a TLV stream. |
4d8aa29 to
bc491a6
Compare
bc491a6 to
1ecd942
Compare
bitromortac
left a comment
There was a problem hiding this comment.
Very close 🚀, just a question if we want to also remove the success bool, which may be worth it because we do a migration.
I tested the migration as well and tested what happens if one runs with the old migration in master and then updates to the new migration, which will probably lead to an error like:
[ERR] LTND lnd.go:159: Shutting down because error in main method: unable to create server: can't create mission control manager: tlv stream is not canonical. This would require a manual deletion of the results bucket or the insertion of a temporary purge call at in initMissionControl.
| sourcePubKey: route.SourcePubKey, | ||
| totalAmount: route.TotalAmount, | ||
| hops: extractMCHops(route.Hops), | ||
| sourcePubKey: tlv.NewRecordT[tlv.TlvType0, route.Vertex](r.SourcePubKey), |
There was a problem hiding this comment.
nit: there are still a few places left in this commit where some parameters can be removed, here and extractMCHop as well as in migration32/mission_control_store.go, migration_test.go
There was a problem hiding this comment.
thanks - struggling to get my editor to do the thing....
| // contains information required to update mission control. | ||
| func interpretResult(rt *mcRoute, success bool, failureSrcIdx *int, | ||
| failure lnwire.FailureMessage) *interpretedResult { | ||
| func interpretResult(rt *mcRoute, success bool, |
There was a problem hiding this comment.
do you think it makes sense to get rid of the success bool as well? We could interpret the non-existence of a failure (index) as a success. Since we can remove unknownFailureSourceIdx it seems like that one was never used as well
There was a problem hiding this comment.
hmmm I dont think they are duplicates/redundancies. There are times when we want to report a failure but we don't know the index of the failure. See this call where we are reporting a failure but we set the source index and failure messages to nil
There was a problem hiding this comment.
right, but in the end we only have successes or failures, so we could combine the failure index and failure message into an optional TLV sub-struct whose presence encodes if it was a failure? but non-blocking, as it's not a huge gain in savings, but it would enforce that we can't have a success and failures set in the same result
There was a problem hiding this comment.
ah! good point - cool will update 👍
| } | ||
|
|
||
| // Record returns a TLV record that can be used to encode/decode a list of | ||
| // mcRoute to/from a TLV stream. |
There was a problem hiding this comment.
nit: a list of is still present, same for Record of mcRoute (in the migration as well)
|
|
||
| func encodeMCRoute(w io.Writer, val interface{}, _ *[8]byte) error { | ||
| if v, ok := val.(*mcRoute); ok { | ||
| return serializeRoute(w, v) |
There was a problem hiding this comment.
nit: serializeRoute and deserializeRoute could be inlined, as those are not reused and small, to be in a single place (please ignore if too nitty)
There was a problem hiding this comment.
cool yeah think im gonna leave this one just cause of the mismatch in signatures. So would need to put the full serialisation and deserialisation code here which makes it harder to read given the TLV specific wrapping that happens here
|
Thanks @bitromortac
Yes we dont support things if they were running on latest master. If they were, they can do a clear-mc call manually before starting again with this version. If we were supporting on latest master, then we would have added this as a new migration instead. |
ca16b85 to
44950d0
Compare
ellemouton
left a comment
There was a problem hiding this comment.
thanks @bitromortac - updated!
| sourcePubKey: route.SourcePubKey, | ||
| totalAmount: route.TotalAmount, | ||
| hops: extractMCHops(route.Hops), | ||
| sourcePubKey: tlv.NewRecordT[tlv.TlvType0, route.Vertex](r.SourcePubKey), |
There was a problem hiding this comment.
thanks - struggling to get my editor to do the thing....
|
|
||
| func encodeMCRoute(w io.Writer, val interface{}, _ *[8]byte) error { | ||
| if v, ok := val.(*mcRoute); ok { | ||
| return serializeRoute(w, v) |
There was a problem hiding this comment.
cool yeah think im gonna leave this one just cause of the mismatch in signatures. So would need to put the full serialisation and deserialisation code here which makes it harder to read given the TLV specific wrapping that happens here
| // contains information required to update mission control. | ||
| func interpretResult(rt *mcRoute, success bool, failureSrcIdx *int, | ||
| failure lnwire.FailureMessage) *interpretedResult { | ||
| func interpretResult(rt *mcRoute, success bool, |
There was a problem hiding this comment.
hmmm I dont think they are duplicates/redundancies. There are times when we want to report a failure but we don't know the index of the failure. See this call where we are reporting a failure but we set the source index and failure messages to nil
bitromortac
left a comment
There was a problem hiding this comment.
Yes we dont support things if they were running on latest master. If they were, they can do a clear-mc call manually before starting again with this version. If we were supporting on latest master, then we would have added this as a new migration instead.
Right, just in case anybody updates without knowing about the migrations beforehand, it's possible to get stuck, because one can't resetmc then due to the rpc server not being available, just wanted to have an answer for that case.
LGTM ⚡ (pending some clarification on a suggestion)
| // contains information required to update mission control. | ||
| func interpretResult(rt *mcRoute, success bool, failureSrcIdx *int, | ||
| failure lnwire.FailureMessage) *interpretedResult { | ||
| func interpretResult(rt *mcRoute, success bool, |
There was a problem hiding this comment.
right, but in the end we only have successes or failures, so we could combine the failure index and failure message into an optional TLV sub-struct whose presence encodes if it was a failure? but non-blocking, as it's not a huge gain in savings, but it would enforce that we can't have a success and failures set in the same result
d9ebbd5 to
01d8285
Compare
Yeah, I think in that case they need to manually drop the bucket (kvdb) or write a cascading delete (sql). Let's defs confirm with @Roasbeef though. I just think that if we do want to support users in this state, then we should have gone with adding a separate migration all together. If we made the decision about editing an existing migration, then to me that means not supporting this state. |
|
@bitromortac - in the mean time, I've updated the PR to use the implicit success/fail struct you suggested - mind having a look at the new structure? Once I get the ACK from you, then I'll ask Oli to also take another look given the structure is quite different now |
01d8285 to
68de584
Compare
bitromortac
left a comment
There was a problem hiding this comment.
The latest changes look good 🙏, leaving some comments, but will also do another round of testing.
Add the TrueBoolean type along with its Record method. Also update the Millisatoshi type with a Record method. Both of these will be used in an upcoming commit which adjusts a mission control migration to use pure TLV types.
So that we can use it in TLV encoding. Also add this to the codec for channeldb migration 32 since we will be using it there in an upcoming adjustment commit.
68de584 to
11fc268
Compare
| result2.timeReply = result1.timeReply.Add(time.Hour) | ||
| result2.timeFwd = result1.timeReply.Add(time.Hour) | ||
| result2.id = 2 | ||
| result2 := newPaymentResult( |
There was a problem hiding this comment.
Can we also add a test with a failure that has no details? Just to show that works too (didn't see one, but perhaps I didn't look hard enough).
There was a problem hiding this comment.
indeed - good idea! added
In this commit, we update an existing migration which at the time of writing has not been included in a release. We update it so that it converts the format used for MissionControl result encoding to use pure TLV instead. The 3 structs that have been updated are: `mcHop`, `mcRoute` and `paymentResult`.
11fc268 to
30e0d6c
Compare
In this commit, we update an existing migration which at the time of
writing has not been included in a release. We update it so that it
converts the format used for MissionControl result encoding to use pure
TLV instead. The 3 structs that have been updated are:
mcHop,mcRouteandpaymentResult.