-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat!: optimize pending packets storage on consumer + migration #1037
Changes from all commits
5bb3e14
6b6eabe
84e0250
0eafb05
1af896f
cf2359d
1c7e7df
84d4a75
98dd226
35a464b
d4393e9
18f852a
0e1bd28
9737d0f
189c1da
1c33106
394f709
a42229a
05acaba
d918fb4
f517201
e3f2133
747e8aa
d84b29d
8084b49
ab23828
98c64d4
db04b8f
e6f696e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,9 +90,12 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) | |
k.SetLastTransmissionBlockHeight(ctx, state.LastTransmissionBlockHeight) | ||
} | ||
|
||
// set pending consumer pending packets | ||
// Set pending consumer packets, using the depreciated ConsumerPacketDataList type | ||
// that exists for genesis. | ||
// note that the list includes pending mature VSC packet only if the handshake is completed | ||
k.AppendPendingPacket(ctx, state.PendingConsumerPackets.List...) | ||
for _, packet := range state.PendingConsumerPackets.List { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Genesis methods still expect the depreciated type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment on ccv.proto |
||
k.AppendPendingPacket(ctx, packet.Type, packet.Data) | ||
} | ||
|
||
// set height to valset update id mapping | ||
for _, h2v := range state.HeightToValsetUpdateId { | ||
|
@@ -122,6 +125,11 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt | |
// export the current validator set | ||
valset := k.MustGetCurrentValidatorsAsABCIUpdates(ctx) | ||
|
||
// export pending packets using the depreciated ConsumerPacketDataList type | ||
pendingPackets := k.GetPendingPackets(ctx) | ||
pendingPacketsDepreciated := ccv.ConsumerPacketDataList{} | ||
pendingPacketsDepreciated.List = append(pendingPacketsDepreciated.List, pendingPackets...) | ||
|
||
// export all the states created after a provider channel got established | ||
if channelID, ok := k.GetProviderChannel(ctx); ok { | ||
clientID, found := k.GetProviderClientID(ctx) | ||
|
@@ -136,7 +144,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt | |
k.GetAllPacketMaturityTimes(ctx), | ||
valset, | ||
k.GetAllHeightToValsetUpdateIDs(ctx), | ||
k.GetPendingPackets(ctx), | ||
pendingPacketsDepreciated, | ||
k.GetAllOutstandingDowntimes(ctx), | ||
k.GetLastTransmissionBlockHeight(ctx), | ||
params, | ||
|
@@ -156,7 +164,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt | |
nil, | ||
valset, | ||
k.GetAllHeightToValsetUpdateIDs(ctx), | ||
k.GetPendingPackets(ctx), | ||
pendingPacketsDepreciated, | ||
nil, | ||
consumertypes.LastTransmissionBlockHeight{}, | ||
params, | ||
|
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.
Extra care should be taken in reviewing this PR, as it does mutate a proto file. Note this index field was added to the
ConsumerPacketData
type so that we can use that index inPendingDataPacketsKey
, to implement a queue with constant append time. SeeAppendPendingPacket