diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 4c1b1eca41..dce5ca5909 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -257,6 +257,8 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac case ccv.SlashPacketBouncedResult[0]: k.UpdateSlashRecordOnBounce(ctx) // Note slash is still at head of queue and will now be retried after appropriate delay period. + case ccv.VSCMaturedPacketHandledResult[0]: + // VSC matured are deleted upon sending, nothing to do here. default: k.Logger(ctx).Error("recv invalid result ack; expected 1, 2, or 3", "channel", packet.SourceChannel, "ack", res) } diff --git a/x/ccv/consumer/keeper/relay_test.go b/x/ccv/consumer/keeper/relay_test.go index 853a5c5e60..1a3305f559 100644 --- a/x/ccv/consumer/keeper/relay_test.go +++ b/x/ccv/consumer/keeper/relay_test.go @@ -391,14 +391,17 @@ func TestOnAcknowledgementPacketResult(t *testing.T) { require.Len(t, consumerKeeper.GetPendingPackets(ctx), 2) require.Equal(t, types.SlashPacket, consumerKeeper.GetPendingPackets(ctx)[0].Type) - // No-op result shouldn't do anything + // v1 result should delete slash record and head of pending packets. Vsc matured remains ack := channeltypes.NewResultAcknowledgement(types.V1Result) err := consumerKeeper.OnAcknowledgementPacket(ctx, packet, ack) require.Nil(t, err) _, found = consumerKeeper.GetSlashRecord(ctx) - require.True(t, found) - require.Len(t, consumerKeeper.GetPendingPackets(ctx), 2) - require.Equal(t, types.SlashPacket, consumerKeeper.GetPendingPackets(ctx)[0].Type) + require.False(t, found) + require.Len(t, consumerKeeper.GetPendingPackets(ctx), 1) + require.Equal(t, types.VscMaturedPacket, consumerKeeper.GetPendingPackets(ctx)[0].Type) + + // refresh state + setupSlashBeforeVscMatured(ctx, &consumerKeeper) // Slash packet handled result should delete slash record and head of pending packets ack = channeltypes.NewResultAcknowledgement(types.SlashPacketHandledResult) diff --git a/x/ccv/types/ccv.go b/x/ccv/types/ccv.go index 345096c163..93820b9d6d 100644 --- a/x/ccv/types/ccv.go +++ b/x/ccv/types/ccv.go @@ -171,13 +171,15 @@ var ( // slice types can't be const // The result ack that has historically been sent from the provider. // A provider with v1 throttling sends these acks for both slash and vsc matured packets. - // A provider with v2 throttling sends this ack for vsc matured packets only. V1Result = PacketAckResult([]byte{byte(1)}) // Slash packet handled result ack, sent by a throttling v2 provider to indicate that a slash packet was handled. SlashPacketHandledResult = PacketAckResult([]byte{byte(2)}) // Slash packet bounced result ack, sent by a throttling v2 provider to indicate that a slash packet was NOT handled // and should eventually be retried. SlashPacketBouncedResult = PacketAckResult([]byte{byte(3)}) + // VSC matured packet handled result ack, sent by a throttling v2 provider + // to indicate that a vsc matured packet was handled. + VSCMaturedPacketHandledResult = PacketAckResult([]byte{byte(4)}) ) // An exported wrapper around the auto generated isConsumerPacketData_Data interface, only for