From 5c65a156e00378a2ea5a35c05ce1a5e09f9e9b37 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 19 Jul 2024 11:26:56 +0200 Subject: [PATCH] fix!: address minor bugs during main upgrade to SDK v50 (#2067) * fix consumer misb e2e test and mistakenly removed line during main upgrade to v50 * update UT * godoc --- tests/e2e/config.go | 1 + tests/e2e/state.go | 2 +- testutil/keeper/unit_test_helpers.go | 1 + x/ccv/provider/keeper/proposal.go | 1 + x/ccv/provider/keeper/proposal_test.go | 9 +++++++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 1c3c997aaf..40a1cfc4c5 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -761,6 +761,7 @@ func ConsumerMisbehaviourTestConfig() TestConfig { IpPrefix: "7.7.7", VotingWaitTime: 20, GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ".app_state.gov.params.expedited_voting_period = \"10s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + diff --git a/tests/e2e/state.go b/tests/e2e/state.go index c7d5baf99f..b9618a3964 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -837,7 +837,7 @@ func (tr Commands) GetClientFrozenHeight(chain ChainID, clientID string) (uint64 log.Fatal(err, "\n", string(bz)) } - return uint64(revHeight), uint64(revNumber) + return uint64(revNumber), uint64(revHeight) } func (tr Commands) GetHasToValidate( diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index a80138551a..0fd86f3c1c 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -273,6 +273,7 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) require.Empty(t, providerKeeper.GetAllCommissionRateValidators(ctx, expectedChainID)) + require.Zero(t, providerKeeper.GetEquivocationEvidenceMinHeight(ctx, expectedChainID)) } func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 3cc8d0b9a8..52007a38e8 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -186,6 +186,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo // Note: this call panics if the key assignment state is invalid k.DeleteKeyAssignments(ctx, chainID) k.DeleteMinimumPowerInTopN(ctx, chainID) + k.DeleteEquivocationEvidenceMinHeight(ctx, chainID) // close channel and delete the mappings between chain ID and channel ID if channelID, found := k.GetChainToChannel(ctx, chainID); found { diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 4b6cf9bad3..8cb9f3a00d 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -394,6 +394,8 @@ func TestStopConsumerChain(t *testing.T) { expErr bool } + consumerCID := "chainID" + tests := []testCase{ { description: "proposal dropped, client doesn't exist", @@ -407,6 +409,9 @@ func TestStopConsumerChain(t *testing.T) { setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks) + // set consumer minimum equivocation height + providerKeeper.SetEquivocationEvidenceMinHeight(ctx, consumerCID, 1) + // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) }, @@ -424,7 +429,7 @@ func TestStopConsumerChain(t *testing.T) { // Setup specific to test case tc.setup(ctx, &providerKeeper, mocks) - err := providerKeeper.StopConsumerChain(ctx, "chainID", true) + err := providerKeeper.StopConsumerChain(ctx, consumerCID, true) if tc.expErr { require.Error(t, err) @@ -432,7 +437,7 @@ func TestStopConsumerChain(t *testing.T) { require.NoError(t, err) } - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerCID, "channelID") ctrl.Finish() }