From c6891116d7f79d8f32a55394f15a34ecb6f0fbcd Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Fri, 8 Mar 2024 09:24:32 +0100 Subject: [PATCH] feat!: PSS enable per-consumer chain commission (#1657) * add draft commission * implement consumer commission draft * formatting * add msg handling * improve UT * nits * Update x/ccv/provider/keeper/keeper.go Co-authored-by: insumity * Update proto/interchain_security/ccv/provider/v1/tx.proto Co-authored-by: Marius Poke * optimize keys * Update x/ccv/provider/keeper/keeper.go Co-authored-by: insumity * address comments * address comments * remove unnecessary check * Revert "remove unnecessary check" This reverts commit 2951e9bace04f6436d6ad1e4a11efcedd0be8cb1. * fix minor bug in StopConsumerChain --------- Co-authored-by: insumity Co-authored-by: Marius Poke --- .../features}/1516-introduce-epochs.md | 0 .../provider/1516-introduce-epochs.md | 0 ...ble-opt-in-chains-through-gov-proposals.md | 0 .../ccv/provider/v1/provider.proto | 2 +- tests/e2e/actions.go | 2 - tests/mbt/model/README.md | 4 - tests/mbt/model/ccv_boundeddrift.qnt | 5 + tests/mbt/model/run_invariants.sh | 42 ------ testutil/keeper/mocks.go | 128 ------------------ x/ccv/provider/keeper/proposal_test.go | 4 - 10 files changed, 6 insertions(+), 181 deletions(-) rename .changelog/{v4.0.0/features/provider => unreleased/features}/1516-introduce-epochs.md (100%) rename .changelog/{v4.0.0 => unreleased}/state-breaking/provider/1516-introduce-epochs.md (100%) rename .changelog/{v4.0.0/features => unreleased/state-breaking/provider}/1587-enable-opt-in-chains-through-gov-proposals.md (100%) diff --git a/.changelog/v4.0.0/features/provider/1516-introduce-epochs.md b/.changelog/unreleased/features/1516-introduce-epochs.md similarity index 100% rename from .changelog/v4.0.0/features/provider/1516-introduce-epochs.md rename to .changelog/unreleased/features/1516-introduce-epochs.md diff --git a/.changelog/v4.0.0/state-breaking/provider/1516-introduce-epochs.md b/.changelog/unreleased/state-breaking/provider/1516-introduce-epochs.md similarity index 100% rename from .changelog/v4.0.0/state-breaking/provider/1516-introduce-epochs.md rename to .changelog/unreleased/state-breaking/provider/1516-introduce-epochs.md diff --git a/.changelog/v4.0.0/features/1587-enable-opt-in-chains-through-gov-proposals.md b/.changelog/unreleased/state-breaking/provider/1587-enable-opt-in-chains-through-gov-proposals.md similarity index 100% rename from .changelog/v4.0.0/features/1587-enable-opt-in-chains-through-gov-proposals.md rename to .changelog/unreleased/state-breaking/provider/1587-enable-opt-in-chains-through-gov-proposals.md diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 3576b03f55..8c70c9e428 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -338,4 +338,4 @@ message OptedInValidator { int64 power = 3; // public key used by the validator on the consumer bytes public_key = 4; -} +} \ No newline at end of file diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 600464af8b..676c0566d7 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1533,11 +1533,9 @@ func (tr TestConfig) delegateTokens( } cmd := target.ExecCommand(tr.chainConfigs[action.Chain].BinaryName, - "tx", "staking", "delegate", validatorAddress, fmt.Sprint(action.Amount)+`stake`, - `--from`, `validator`+fmt.Sprint(action.From), `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), `--home`, tr.getValidatorHome(action.Chain, action.From), diff --git a/tests/mbt/model/README.md b/tests/mbt/model/README.md index dac613337e..df994b7f84 100644 --- a/tests/mbt/model/README.md +++ b/tests/mbt/model/README.md @@ -138,8 +138,4 @@ The available sanity checks are: - CanOptIn (only with `--step stepBoundedDriftKeyAndPSS` on `ccv_boundeddrift.qnt`) - CanOptOut (only with `--step stepBoundedDriftKeyAndPSS` on `ccv_boundeddrift.qnt`) - CanFailOptOut (only with `--step stepBoundedDriftKeyAndPSS` on `ccv_boundeddrift.qnt`) -<<<<<<< HEAD - CanHaveOptIn (only with `--step stepBoundedDriftKeyAndPSS` on `ccv_boundeddrift.qnt`) -======= -- CanHaveOptIn (only with `--step stepBoundedDriftKeyAndPSS` on `ccv_boundeddrift.qnt`) ->>>>>>> 6e075652 (test: MBT: Add partial set security to model (feature branch version) (#1627)) diff --git a/tests/mbt/model/ccv_boundeddrift.qnt b/tests/mbt/model/ccv_boundeddrift.qnt index 37fcd5a15b..b067ca79b2 100644 --- a/tests/mbt/model/ccv_boundeddrift.qnt +++ b/tests/mbt/model/ccv_boundeddrift.qnt @@ -115,6 +115,11 @@ module ccv_boundeddrift { StepOptOut, } + action stepBoundedDriftKeyAssignment = any { + stepBoundedDrift, + nondetKeyAssignment, + } + // INVARIANT // The maxDrift between chains is never exceeded. // This *should* be ensured by the step function. diff --git a/tests/mbt/model/run_invariants.sh b/tests/mbt/model/run_invariants.sh index e232bcce8b..bda58d80f6 100755 --- a/tests/mbt/model/run_invariants.sh +++ b/tests/mbt/model/run_invariants.sh @@ -1,48 +1,6 @@ #!/bin/bash -<<<<<<< HEAD -# to stop on any errors -set -e - -quint test ccv_model.qnt -quint test ccv_test.qnt -quint run --invariant "all{ValidatorUpdatesArePropagatedInv,ValidatorSetHasExistedInv,SameVscPacketsInv,MatureOnTimeInv,EventuallyMatureOnProviderInv}" ccv_model.qnt --max-steps 200 --max-samples 200 -quint run --invariant "all{ValidatorUpdatesArePropagatedKeyAssignmentInv,ValidatorSetHasExistedKeyAssignmentInv,SameVscPacketsKeyAssignmentInv,MatureOnTimeInv,EventuallyMatureOnProviderInv,KeyAssignmentRulesInv}" ccv_model.qnt --step stepKeyAssignment --max-steps 200 --max-samples 200 - - -# do not stop on errors anymore, so we can give better output if we error -set +e - -run_invariant() { - local invariant=$1 - local step=$2 - local match=$3 - - if [[ -z "$step" ]]; then - quint run --invariant $invariant ccv_model.qnt | grep -q $match - else - quint run --invariant $invariant --step $step ccv_model.qnt | grep -q $match - fi - - if [[ $? -eq 0 ]]; then - echo "sanity check $invariant ok" - else - echo "sanity check $invariant not ok" - exit 1 - fi -} - -run_invariant "CanRunConsumer" "" '[violation]' -run_invariant "CanStopConsumer" "" '[violation]' -run_invariant "CanTimeoutConsumer" "" '[violation]' -run_invariant "CanSendVscPackets" "" '[violation]' -run_invariant "CanSendVscMaturedPackets" "" '[violation]' -run_invariant "CanAssignConsumerKey" "stepKeyAssignment" '[violation]' -run_invariant "CanHaveConsumerAddresses" "stepKeyAssignment" '[violation]' -run_invariant "CanReceiveMaturations" "stepKeyAssignment" '[violation]' -======= quint test ccv_model.qnt quint test ccv_test.qnt quint run --invariant "all{ValidatorUpdatesArePropagatedInv,ValidatorSetHasExistedInv,SameVscPacketsInv,MatureOnTimeInv,EventuallyMatureOnProviderInv}" ccv_model.qnt --max-steps 200 --max-samples 200 quint run --invariant "all{ValidatorUpdatesArePropagatedKeyAssignmentInv,ValidatorSetHasExistedKeyAssignmentInv,SameVscPacketsKeyAssignmentInv,MatureOnTimeInv,EventuallyMatureOnProviderInv,KeyAssignmentRulesInv}" ccv_model.qnt --step stepKeyAssignment --max-steps 200 --max-samples 200 ->>>>>>> 6e075652 (test: MBT: Add partial set security to model (feature branch version) (#1627)) diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index a192765ec9..78c0fbedc9 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -1114,134 +1114,6 @@ func (m *MockIBCTransferKeeper) EXPECT() *MockIBCTransferKeeperMockRecorder { return m.recorder } -// OnAcknowledgementPacket mocks base method. -func (m *MockIBCTransferKeeper) OnAcknowledgementPacket(ctx types0.Context, packet types9.Packet, acknowledgement []byte, relayer types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnAcknowledgementPacket", ctx, packet, acknowledgement, relayer) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnAcknowledgementPacket indicates an expected call of OnAcknowledgementPacket. -func (mr *MockIBCTransferKeeperMockRecorder) OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnAcknowledgementPacket", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnAcknowledgementPacket), ctx, packet, acknowledgement, relayer) -} - -// OnChanCloseConfirm mocks base method. -func (m *MockIBCTransferKeeper) OnChanCloseConfirm(ctx types0.Context, portID, channelID string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanCloseConfirm", ctx, portID, channelID) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnChanCloseConfirm indicates an expected call of OnChanCloseConfirm. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanCloseConfirm(ctx, portID, channelID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanCloseConfirm", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanCloseConfirm), ctx, portID, channelID) -} - -// OnChanCloseInit mocks base method. -func (m *MockIBCTransferKeeper) OnChanCloseInit(ctx types0.Context, portID, channelID string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanCloseInit", ctx, portID, channelID) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnChanCloseInit indicates an expected call of OnChanCloseInit. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanCloseInit(ctx, portID, channelID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanCloseInit", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanCloseInit), ctx, portID, channelID) -} - -// OnChanOpenAck mocks base method. -func (m *MockIBCTransferKeeper) OnChanOpenAck(ctx types0.Context, portID, channelID, counterpartyChannelID, counterpartyVersion string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanOpenAck", ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnChanOpenAck indicates an expected call of OnChanOpenAck. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanOpenAck", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanOpenAck), ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) -} - -// OnChanOpenConfirm mocks base method. -func (m *MockIBCTransferKeeper) OnChanOpenConfirm(ctx types0.Context, portID, channelID string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanOpenConfirm", ctx, portID, channelID) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnChanOpenConfirm indicates an expected call of OnChanOpenConfirm. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanOpenConfirm(ctx, portID, channelID interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanOpenConfirm", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanOpenConfirm), ctx, portID, channelID) -} - -// OnChanOpenInit mocks base method. -func (m *MockIBCTransferKeeper) OnChanOpenInit(ctx types0.Context, order types9.Order, connectionHops []string, portID, channelID string, channelCap *types2.Capability, counterparty types9.Counterparty, version string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanOpenInit", ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OnChanOpenInit indicates an expected call of OnChanOpenInit. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanOpenInit(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanOpenInit", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanOpenInit), ctx, order, connectionHops, portID, channelID, channelCap, counterparty, version) -} - -// OnChanOpenTry mocks base method. -func (m *MockIBCTransferKeeper) OnChanOpenTry(ctx types0.Context, order types9.Order, connectionHops []string, portID, channelID string, channelCap *types2.Capability, counterparty types9.Counterparty, counterpartyVersion string) (string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnChanOpenTry", ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// OnChanOpenTry indicates an expected call of OnChanOpenTry. -func (mr *MockIBCTransferKeeperMockRecorder) OnChanOpenTry(ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnChanOpenTry", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnChanOpenTry), ctx, order, connectionHops, portID, channelID, channelCap, counterparty, counterpartyVersion) -} - -// OnRecvPacket mocks base method. -func (m *MockIBCTransferKeeper) OnRecvPacket(ctx types0.Context, packet types9.Packet, relayer types0.AccAddress) exported.Acknowledgement { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnRecvPacket", ctx, packet, relayer) - ret0, _ := ret[0].(exported.Acknowledgement) - return ret0 -} - -// OnRecvPacket indicates an expected call of OnRecvPacket. -func (mr *MockIBCTransferKeeperMockRecorder) OnRecvPacket(ctx, packet, relayer interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnRecvPacket", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnRecvPacket), ctx, packet, relayer) -} - -// OnTimeoutPacket mocks base method. -func (m *MockIBCTransferKeeper) OnTimeoutPacket(ctx types0.Context, packet types9.Packet, relayer types0.AccAddress) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "OnTimeoutPacket", ctx, packet, relayer) - ret0, _ := ret[0].(error) - return ret0 -} - -// OnTimeoutPacket indicates an expected call of OnTimeoutPacket. -func (mr *MockIBCTransferKeeperMockRecorder) OnTimeoutPacket(ctx, packet, relayer interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnTimeoutPacket", reflect.TypeOf((*MockIBCTransferKeeper)(nil).OnTimeoutPacket), ctx, packet, relayer) -} - // Transfer mocks base method. func (m *MockIBCTransferKeeper) Transfer(arg0 context.Context, arg1 *types6.MsgTransfer) (*types6.MsgTransferResponse, error) { m.ctrl.T.Helper() diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 8de4282474..99e8c74e49 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -554,10 +554,6 @@ func TestStopConsumerChain(t *testing.T) { require.Error(t, err) } else { require.NoError(t, err) - - // in case the chain was successfully stopped, it should not contain a Top N associated to it - _, found := providerKeeper.GetTopN(ctx, "chainID") - require.False(t, found) } testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID")