Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Jul 14, 2023
1 parent 3f3ba9c commit 209d4df
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 112 deletions.
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
4 changes: 0 additions & 4 deletions x/ccv/consumer/keeper/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,4 @@ func TestMigrateConsumerPacketData(t *testing.T) {
require.Equal(t, uint64(88), obtainedPackets[1].GetVscMaturedPacketData().ValsetUpdateId)
require.Equal(t, uint64(99), obtainedPackets[2].GetVscMaturedPacketData().ValsetUpdateId)

Check failure on line 63 in x/ccv/consumer/keeper/migration_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
// 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.

0 comments on commit 209d4df

Please sign in to comment.