Skip to content
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

fix!: revert recent consumer packet data changes #1150

Merged
merged 9 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release.

* (fix!) revert consumer packet data changes from #1037 [#1150](https://github.com/cosmos/interchain-security/pull/1150)
* (fix!) proper deletion of pending packets [#1146](https://github.com/cosmos/interchain-security/pull/1146)
* (feat!) optimize pending packets storage on consumer, with migration! [#1037](https://github.com/cosmos/interchain-security/pull/1037)

Expand Down
1 change: 0 additions & 1 deletion proto/interchain_security/ccv/v1/ccv.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ message ConsumerPacketData {
SlashPacketData slashPacketData = 2;
VSCMaturedPacketData vscMaturedPacketData = 3;
}
uint64 idx = 4;
}


Expand Down
4 changes: 0 additions & 4 deletions x/ccv/consumer/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,12 @@ func TestExportGenesis(t *testing.T) {
Data: &ccv.ConsumerPacketData_SlashPacketData{
SlashPacketData: ccv.NewSlashPacketData(abciValidator, vscID, stakingtypes.Infraction_INFRACTION_DOWNTIME),
},
Idx: 0,
},
{
Type: ccv.VscMaturedPacket,
Data: &ccv.ConsumerPacketData_VscMaturedPacketData{
VscMaturedPacketData: ccv.NewVSCMaturedPacketData(vscID),
},
// This idx is a part of the expected genesis state.
// If the keeper is correctly storing consumer packet data, indexes should be populated.
Idx: 1,
},
},
}
Expand Down
9 changes: 3 additions & 6 deletions x/ccv/consumer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,10 @@ func (k Keeper) DeleteAllPendingDataPackets(ctx sdk.Context) {

// AppendPendingPacket enqueues the given data packet to the end of the pending data packets queue
func (k Keeper) AppendPendingPacket(ctx sdk.Context, packetType ccv.ConsumerPacketDataType, data ccv.ExportedIsConsumerPacketData_Data) {
cpd := ccv.NewConsumerPacketData(
packetType,
data,
k.getAndIncrementPendingPacketsIdx(ctx),
)
key := types.PendingDataPacketsKey(cpd.Idx)
idx := k.getAndIncrementPendingPacketsIdx(ctx) // for FIFO queue
key := types.PendingDataPacketsKey(idx)
store := ctx.KVStore(k.storeKey)
cpd := ccv.NewConsumerPacketData(packetType, data)
bz, err := cpd.Marshal()
if err != nil {
// This should never happen
Expand Down
6 changes: 0 additions & 6 deletions x/ccv/consumer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,12 @@ func TestPendingPackets(t *testing.T) {
Data: &ccv.ConsumerPacketData_VscMaturedPacketData{
VscMaturedPacketData: ccv.NewVSCMaturedPacketData(1),
},
Idx: 0, // Note these are expected idxs, we don't pass this data to the keeper
},
{
Type: ccv.VscMaturedPacket,
Data: &ccv.ConsumerPacketData_VscMaturedPacketData{
VscMaturedPacketData: ccv.NewVSCMaturedPacketData(2),
},
Idx: 1,
},
{
Type: ccv.SlashPacket,
Expand All @@ -343,14 +341,12 @@ func TestPendingPackets(t *testing.T) {
stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN,
),
},
Idx: 2,
},
{
Type: ccv.VscMaturedPacket,
Data: &ccv.ConsumerPacketData_VscMaturedPacketData{
VscMaturedPacketData: ccv.NewVSCMaturedPacketData(3),
},
Idx: 3,
},
}

Expand All @@ -376,7 +372,6 @@ func TestPendingPackets(t *testing.T) {
Data: &ccv.ConsumerPacketData_SlashPacketData{
SlashPacketData: slashPacket,
},
Idx: 4,
})

toAppend := packetData[len(packetData)-1]
Expand All @@ -391,7 +386,6 @@ func TestPendingPackets(t *testing.T) {
Data: &ccv.ConsumerPacketData_VscMaturedPacketData{
VscMaturedPacketData: vscMaturedPacket,
},
Idx: 5,
})
toAppend = packetData[len(packetData)-1]
consumerKeeper.AppendPendingPacket(ctx, toAppend.Type, toAppend.Data)
Expand Down
5 changes: 0 additions & 5 deletions x/ccv/consumer/keeper/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ func TestMigrateConsumerPacketData(t *testing.T) {
require.Equal(t, uint64(77), obtainedPackets[0].GetSlashPacketData().ValsetUpdateId)
require.Equal(t, uint64(88), obtainedPackets[1].GetVscMaturedPacketData().ValsetUpdateId)
require.Equal(t, uint64(99), obtainedPackets[2].GetVscMaturedPacketData().ValsetUpdateId)

// Check that indexes are populated
require.Equal(t, uint64(0), obtainedPackets[0].Idx)
require.Equal(t, uint64(1), obtainedPackets[1].Idx)
require.Equal(t, uint64(2), obtainedPackets[2].Idx)
}
3 changes: 1 addition & 2 deletions x/ccv/types/ccv.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ type ExportedIsConsumerPacketData_Data interface {
isConsumerPacketData_Data
}

func NewConsumerPacketData(cpdType ConsumerPacketDataType, data isConsumerPacketData_Data, idx uint64) ConsumerPacketData {
func NewConsumerPacketData(cpdType ConsumerPacketDataType, data isConsumerPacketData_Data) ConsumerPacketData {
return ConsumerPacketData{
Type: cpdType,
Data: data,
Idx: idx,
}
}
142 changes: 53 additions & 89 deletions x/ccv/types/ccv.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.