From 66c7511ef809e259241769314433051afb886cc2 Mon Sep 17 00:00:00 2001 From: insumity Date: Fri, 5 Apr 2024 14:31:39 +0200 Subject: [PATCH 1/2] init commit --- x/ccv/provider/keeper/relay.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 1ef8547243..35c98aa088 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -405,7 +405,8 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas if !k.IsConsumerValidator(ctx, chainID, providerConsAddr) { k.Logger(ctx).Error("cannot jail validator %s that does not belong to consumer %s valset", providerConsAddr.String(), chainID) - // drop packet + // drop packet but return a slash ack so that the consumer can send another slash packet + k.AppendSlashAck(ctx, chainID, consumerConsAddr.String()) return } From c7c673442ff8fc9a404d8062591ba76965ce40ea Mon Sep 17 00:00:00 2001 From: insumity Date: Fri, 5 Apr 2024 14:44:18 +0200 Subject: [PATCH 2/2] fix test --- x/ccv/provider/keeper/relay_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index 594783a9a1..a0c0b20e48 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -303,8 +303,9 @@ func TestHandleSlashPacket(t *testing.T) { name string packetData ccv.SlashPacketData // The mocks that we expect to be called for the specified packet data. - expectedCalls func(sdk.Context, testkeeper.MockedKeepers, ccv.SlashPacketData) []*gomock.Call - expectedSlashAcksLen int + expectedCalls func(sdk.Context, testkeeper.MockedKeepers, ccv.SlashPacketData) []*gomock.Call + expectedSlashAcksLen int + expectedSlashAckConsumerConsAddress types.ConsumerConsAddress }{ { "validator isn't a consumer validator", @@ -318,7 +319,8 @@ func TestHandleSlashPacket(t *testing.T) { ) []*gomock.Call { return []*gomock.Call{} }, - 0, + 1, + dummyConsAddr, }, { "unfound validator", @@ -340,6 +342,7 @@ func TestHandleSlashPacket(t *testing.T) { } }, 0, + consumerConsAddr, }, { "found, but tombstoned validator", @@ -362,6 +365,7 @@ func TestHandleSlashPacket(t *testing.T) { } }, 0, + consumerConsAddr, }, { "drop packet when infraction height not found", @@ -385,6 +389,7 @@ func TestHandleSlashPacket(t *testing.T) { } }, 0, + consumerConsAddr, }, { "full downtime packet handling, uses init chain height and non-jailed validator", @@ -402,6 +407,7 @@ func TestHandleSlashPacket(t *testing.T) { true) // expectJailing = true }, 1, + consumerConsAddr, }, { "full downtime packet handling, uses valid vscID and jailed validator", @@ -419,6 +425,7 @@ func TestHandleSlashPacket(t *testing.T) { false) // expectJailing = false, validator is already jailed. }, 1, + consumerConsAddr, }, // Note: double-sign slash packet handling should not occur, see OnRecvSlashPacket. } @@ -447,7 +454,7 @@ func TestHandleSlashPacket(t *testing.T) { if tc.expectedSlashAcksLen == 1 { // must match the consumer address - require.Equal(t, consumerConsAddr.String(), providerKeeper.GetSlashAcks(ctx, chainId)[0]) + require.Equal(t, tc.expectedSlashAckConsumerConsAddress.String(), providerKeeper.GetSlashAcks(ctx, chainId)[0]) require.NotEqual(t, providerConsAddr.String(), providerKeeper.GetSlashAcks(ctx, chainId)[0]) require.NotEqual(t, providerConsAddr.String(), consumerConsAddr.String()) }