From 1e45c82da9b427ecacd9c8b1848b31aa01d2e19e Mon Sep 17 00:00:00 2001 From: Simon Noetzlin <simon.ntz@gmail.com> 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 <karolos@informal.systems> * Update proto/interchain_security/ccv/provider/v1/tx.proto Co-authored-by: Marius Poke <marius.poke@posteo.de> * optimize keys * Update x/ccv/provider/keeper/keeper.go Co-authored-by: insumity <karolos@informal.systems> * address comments * address comments * remove unnecessary check * Revert "remove unnecessary check" This reverts commit 2951e9bace04f6436d6ad1e4a11efcedd0be8cb1. * fix minor bug in StopConsumerChain --------- Co-authored-by: insumity <karolos@informal.systems> Co-authored-by: Marius Poke <marius.poke@posteo.de> --- .../ccv/provider/v1/provider.proto | 2 +- .../ccv/provider/v1/tx.proto | 23 +- tests/integration/distribution.go | 121 +++-- testutil/integration/interfaces.go | 1 + testutil/keeper/mocks.go | 128 ----- testutil/keeper/unit_test_helpers.go | 5 + x/ccv/provider/keeper/distribution.go | 53 +- x/ccv/provider/keeper/keeper.go | 69 +++ x/ccv/provider/keeper/keeper_test.go | 41 +- x/ccv/provider/keeper/msg_server.go | 41 +- .../keeper/partial_set_security_test.go | 25 + x/ccv/provider/keeper/proposal.go | 6 + x/ccv/provider/keeper/proposal_test.go | 4 - x/ccv/provider/types/errors.go | 1 + x/ccv/provider/types/events.go | 3 + x/ccv/provider/types/keys.go | 13 + x/ccv/provider/types/keys_test.go | 1 + x/ccv/provider/types/msg.go | 44 ++ x/ccv/provider/types/tx.pb.go | 510 ++++++++++++++++-- 19 files changed, 864 insertions(+), 227 deletions(-) diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 39e71df522..40c5258880 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -325,4 +325,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/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 51003bdf05..96844c2e72 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -17,6 +17,7 @@ service Msg { rpc SubmitConsumerDoubleVoting(MsgSubmitConsumerDoubleVoting) returns (MsgSubmitConsumerDoubleVotingResponse); rpc OptIn(MsgOptIn) returns (MsgOptInResponse); rpc OptOut(MsgOptOut) returns (MsgOptOutResponse); + rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); } message MsgAssignConsumerKey { @@ -88,4 +89,24 @@ message MsgOptOut { string provider_addr = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ]; } -message MsgOptOutResponse {} \ No newline at end of file +message MsgOptOutResponse {} + +// MsgSetConsumerCommissionRate allows validators to set +// a per-consumer chain commission rate +message MsgSetConsumerCommissionRate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + // The validator address on the provider + string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + // The chain id of the consumer chain to set a commission rate + string chain_id = 2; + // The rate to charge delegators on the consumer chain, as a fraction + string rate = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + + +message MsgSetConsumerCommissionRateResponse {} \ No newline at end of file diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go index f06c6f9482..65473d3bcf 100644 --- a/tests/integration/distribution.go +++ b/tests/integration/distribution.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/bytes" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" @@ -575,7 +575,7 @@ func (s *CCVTestSuite) TestIBCTransferMiddleware() { bankKeeper := s.providerApp.GetTestBankKeeper() amount := sdk.NewInt(100) - data = types.NewFungibleTokenPacketData( // can be explicitly changed in setup + data = transfertypes.NewFungibleTokenPacketData( // can be explicitly changed in setup sdk.DefaultBondDenom, amount.String(), authtypes.NewModuleAddress(consumertypes.ConsumerToSendToProviderName).String(), @@ -734,11 +734,11 @@ func (s *CCVTestSuite) TestAllocateTokens() { perValExpReward := validatorsExpRewards.QuoDec(sdk.NewDec(int64(valNum))) // verify the validator tokens allocation - // note all validators have the same voting power to keep things simple + // note that the validators have the same voting power to keep things simple for _, val := range s.providerChain.Vals.Validators { - valReward := distributionKeeper.GetValidatorOutstandingRewards(s.providerCtx(), sdk.ValAddress(val.Address)) + valRewards := distributionKeeper.GetValidatorOutstandingRewards(s.providerCtx(), sdk.ValAddress(val.Address)) s.Require().Equal( - valReward.Rewards, + valRewards.Rewards, lastValOutRewards[sdk.ValAddress(val.Address).String()].Add(perValExpReward...), ) } @@ -902,80 +902,133 @@ func (s *CCVTestSuite) prepareRewardDist() { } func (s *CCVTestSuite) TestAllocateTokensToValidator() { - - providerkeepr := s.providerApp.GetProviderKeeper() + providerKeeper := s.providerApp.GetProviderKeeper() + distributionKeeper := s.providerApp.GetTestDistributionKeeper() + bankKeeper := s.providerApp.GetTestBankKeeper() chainID := "consumer" - validators := []bytes.HexBytes{ s.providerChain.Vals.Validators[0].Address, s.providerChain.Vals.Validators[1].Address, } - votes := []abci.VoteInfo{ {Validator: abci.Validator{Address: validators[0], Power: 1}}, {Validator: abci.Validator{Address: validators[1], Power: 1}}, } testCases := []struct { - name string - votes []abci.VoteInfo - tokens sdk.DecCoins - expCoinTransferred sdk.DecCoins + name string + votes []abci.VoteInfo + tokens sdk.DecCoins + rate sdk.Dec + expAllocated sdk.DecCoins }{ { - name: "reward tokens are empty", + name: "tokens are empty", + tokens: sdk.DecCoins{}, + rate: sdk.ZeroDec(), + expAllocated: nil, }, { - name: "total voting power is zero", - tokens: sdk.DecCoins{sdk.NewDecCoin("uatom", math.NewInt(100_000))}, + name: "total voting power is zero", + tokens: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(100_000))}, + rate: sdk.ZeroDec(), + expAllocated: nil, }, { - name: "expect all tokens to be allocated to a single validator", - votes: []abci.VoteInfo{votes[0]}, - tokens: sdk.DecCoins{sdk.NewDecCoin("uatom", math.NewInt(100_000))}, - expCoinTransferred: sdk.DecCoins{sdk.NewDecCoin("uatom", math.NewInt(100_000))}, + name: "expect all tokens to be allocated to a single validator", + votes: []abci.VoteInfo{votes[0]}, + tokens: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(999))}, + rate: sdk.NewDecWithPrec(5, 1), + expAllocated: sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, math.NewInt(999))}, }, { - name: "expect tokens to be allocated evenly between validators", - votes: []abci.VoteInfo{votes[0], votes[1]}, - tokens: sdk.DecCoins{sdk.NewDecCoin("uatom", math.NewInt(555_555))}, - expCoinTransferred: sdk.DecCoins{sdk.NewDecCoin("uatom", math.NewInt(555_555))}, + name: "expect tokens to be allocated evenly between validators", + votes: []abci.VoteInfo{votes[0], votes[1]}, + tokens: sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))}, + rate: sdk.OneDec(), + expAllocated: sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecFromIntWithPrec(math.NewInt(999), 2))}, }, } for _, tc := range testCases { s.Run(tc.name, func() { - // TODO: opt validators in and verify - // that rewards are solely allocated to them + // set the same consumer commission rate for all validators + for _, v := range s.providerChain.Vals.Validators { + provAddr := providertypes.NewProviderConsAddress(sdk.ConsAddress(v.Address)) + + providerKeeper.SetConsumerCommissionRate( + s.providerCtx(), + chainID, + provAddr, + tc.rate, + ) + } + + // TODO: opt validators in and verify + // that rewards are only allocated to them ctx, _ := s.providerCtx().CacheContext() // allocate tokens - res := providerkeepr.AllocateTokensToConsumerValidators( + res := providerKeeper.AllocateTokensToConsumerValidators( ctx, chainID, tc.votes, tc.tokens, ) - // check that the expect result is returned - s.Require().Equal(tc.expCoinTransferred, res) + // check that the expected result is returned + s.Require().Equal(tc.expAllocated, res) - if !tc.expCoinTransferred.Empty() { + if !tc.expAllocated.Empty() { // rewards are expected to be allocated evenly between validators - rewardsPerVal := tc.expCoinTransferred.QuoDec(sdk.NewDec(int64(len(tc.votes)))) + rewardsPerVal := tc.expAllocated.QuoDec(sdk.NewDec(int64(len(tc.votes)))) - // check that the rewards are allocated to validators as expected + // check that the rewards are allocated to validators for _, v := range tc.votes { + valAddr := sdk.ValAddress(v.Validator.Address) rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( ctx, - sdk.ValAddress(v.Validator.Address), + valAddr, ) s.Require().Equal(rewardsPerVal, rewards.Rewards) + + // send rewards to the distribution module + valRewardsTrunc, _ := rewards.Rewards.TruncateDecimal() + err := bankKeeper.SendCoinsFromAccountToModule( + ctx, + s.providerChain.SenderAccount.GetAddress(), + distrtypes.ModuleName, + valRewardsTrunc) + s.Require().NoError(err) + + // check that validators can withdraw their rewards + withdrawnCoins, err := distributionKeeper.WithdrawValidatorCommission( + ctx, + valAddr, + ) + s.Require().NoError(err) + + // check that the withdrawn coins is equal to the entire reward amount + // times the set consumer commission rate + commission := rewards.Rewards.MulDec(tc.rate) + c, _ := commission.TruncateDecimal() + s.Require().Equal(withdrawnCoins, c) + + // check that validators get rewards in their balance + s.Require().Equal(withdrawnCoins, bankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddr))) + } + } else { + for _, v := range tc.votes { + valAddr := sdk.ValAddress(v.Validator.Address) + rewards := s.providerApp.GetTestDistributionKeeper().GetValidatorOutstandingRewards( + ctx, + valAddr, + ) + s.Require().Zero(rewards.Rewards) } } - }) } } diff --git a/testutil/integration/interfaces.go b/testutil/integration/interfaces.go index 89d59904df..fe3382b524 100644 --- a/testutil/integration/interfaces.go +++ b/testutil/integration/interfaces.go @@ -142,6 +142,7 @@ type TestDistributionKeeper interface { GetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) (rewards distributiontypes.ValidatorOutstandingRewards) GetCommunityTax(ctx sdk.Context) (percent sdk.Dec) + WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) (sdk.Coins, error) } type TestMintKeeper interface { 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/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 468b0cb5e9..d17433ca66 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -249,11 +249,16 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, providerKeeper.GetAllVscSendTimestamps(ctx, expectedChainID)) + // in case the chain was successfully stopped, it should not contain a Top N associated to it + _, found = providerKeeper.GetTopN(ctx, expectedChainID) + require.False(t, found) + // test key assignment state is cleaned require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &expectedChainID)) require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) require.Empty(t, providerKeeper.GetAllKeyAssignmentReplacements(ctx, expectedChainID)) require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) + require.Empty(t, providerKeeper.GetAllCommissionRateValidators(ctx, expectedChainID)) } func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index 45af3eb262..16511f8bde 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -5,9 +5,9 @@ import ( "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" ) @@ -138,16 +138,17 @@ func (k Keeper) AllocateTokensToConsumerValidators( chainID string, bondedVotes []abci.VoteInfo, tokens sdk.DecCoins, -) (totalReward sdk.DecCoins) { +) (allocated sdk.DecCoins) { + // return early if the tokens are empty if tokens.Empty() { - return totalReward + return allocated } // get the consumer total voting power from the votes totalPower := k.ComputeConsumerTotalVotingPower(ctx, chainID, bondedVotes) if totalPower == 0 { - return totalReward + return allocated } for _, vote := range bondedVotes { @@ -157,19 +158,31 @@ func (k Keeper) AllocateTokensToConsumerValidators( powerFraction := math.LegacyNewDec(vote.Validator.Power).QuoTruncate(math.LegacyNewDec(totalPower)) tokensFraction := tokens.MulDecTruncate(powerFraction) + // get the validator type struct for the consensus address + val := k.stakingKeeper.ValidatorByConsAddr(ctx, consAddr).(stakingtypes.Validator) + + // check if the validator set a custom commission rate for the consumer chain + if cr, found := k.GetConsumerCommissionRate(ctx, chainID, types.NewProviderConsAddress(consAddr)); found { + // set the validator commission rate + val.Commission.CommissionRates.Rate = cr + } + + // allocate the consumer reward tokens to the validator k.distributionKeeper.AllocateTokensToValidator( ctx, - k.stakingKeeper.ValidatorByConsAddr(ctx, consAddr), + val, tokensFraction, ) - totalReward = totalReward.Add(tokensFraction...) + + // sum the tokens allocated + allocated = allocated.Add(tokensFraction...) } - return totalReward + return allocated } -// TransferConsumerRewardsToDistributionModule transfers the collected rewards of the given consumer chain -// from the consumer rewards pool module account to a the distribution module +// TransferConsumerRewardsToDistributionModule transfers the rewards allocation of the given consumer chain +// from the consumer rewards pool to a the distribution module func (k Keeper) TransferConsumerRewardsToDistributionModule( ctx sdk.Context, chainID string, @@ -267,3 +280,23 @@ func (k Keeper) IdentifyConsumerChainIDFromIBCPacket(ctx sdk.Context, packet cha return chainID, nil } + +// HandleSetConsumerCommissionRate sets a per-consumer chain commission rate for the given provider address +// on the condition that the given consumer chain exists. +func (k Keeper) HandleSetConsumerCommissionRate(ctx sdk.Context, chainID string, providerAddr types.ProviderConsAddress, commissionRate sdk.Dec) error { + // check that the consumer chain exists + if !k.IsConsumerProposedOrRegistered(ctx, chainID) { + return errorsmod.Wrapf( + types.ErrUnknownConsumerChainId, + "unknown consumer chain, with id: %s", chainID) + } + // set per-consumer chain commission rate for the validator address + k.SetConsumerCommissionRate( + ctx, + chainID, + providerAddr, + commissionRate, + ) + + return nil +} diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index e6b1c589aa..ec73d85383 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -1248,6 +1248,75 @@ func (k Keeper) SetToBeOptedIn( store.Set(types.ToBeOptedInKey(chainID, providerAddr), []byte{}) } +// SetConsumerCommissionRate sets a per-consumer chain commission rate +// for the given validator address +func (k Keeper) SetConsumerCommissionRate( + ctx sdk.Context, + chainID string, + providerAddr types.ProviderConsAddress, + commissionRate sdk.Dec, +) { + store := ctx.KVStore(k.storeKey) + bz, err := commissionRate.Marshal() + if err != nil { + panic(fmt.Errorf("consumer commission rate marshalling failed: %s", err)) + } + + store.Set(types.ConsumerCommissionRateKey(chainID, providerAddr), bz) +} + +// GetConsumerCommissionRate returns the per-consumer commission rate set +// for the given validator address +func (k Keeper) GetConsumerCommissionRate( + ctx sdk.Context, + chainID string, + providerAddr types.ProviderConsAddress, +) (sdk.Dec, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ConsumerCommissionRateKey(chainID, providerAddr)) + if bz == nil { + return sdk.ZeroDec(), false + } + + cr := sdk.Dec{} + if err := cr.Unmarshal(bz); err != nil { + k.Logger(ctx).Error("consumer commission rate unmarshalling failed: %s", err) + return sdk.ZeroDec(), false + } + + return cr, true +} + +// GetAllCommissionRateValidators returns all the validator address +// that set a commission rate for the given chain ID +func (k Keeper) GetAllCommissionRateValidators( + ctx sdk.Context, + chainID string) (addresses []types.ProviderConsAddress) { + + store := ctx.KVStore(k.storeKey) + key := types.ChainIdWithLenKey(types.ConsumerCommissionRatePrefix, chainID) + iterator := sdk.KVStorePrefixIterator(store, key) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + providerAddr := types.NewProviderConsAddress(iterator.Key()[len(key):]) + addresses = append(addresses, providerAddr) + } + + return addresses +} + +// DeleteConsumerCommissionRate the per-consumer chain commission rate +// associated to the given validator address +func (k Keeper) DeleteConsumerCommissionRate( + ctx sdk.Context, + chainID string, + providerAddr types.ProviderConsAddress, +) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerCommissionRateKey(chainID, providerAddr)) +} + func (k Keeper) DeleteToBeOptedIn( ctx sdk.Context, chainID string, diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index a231eb4c0c..595e01100a 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -15,6 +15,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + sdk "github.com/cosmos/cosmos-sdk/types" cryptotestutil "github.com/cosmos/interchain-security/v4/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v4/testutil/keeper" "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" @@ -692,7 +693,8 @@ func TestGetAllOptedIn(t *testing.T) { ProviderAddr: expectedOptedInValidator.ProviderAddr, BlockHeight: expectedOptedInValidator.BlockHeight, Power: expectedOptedInValidator.Power, - PublicKey: expectedOptedInValidator.PublicKey}) + PublicKey: expectedOptedInValidator.PublicKey, + }) } actualOptedInValidators := providerKeeper.GetAllOptedIn(ctx, "chainID") @@ -858,3 +860,40 @@ func TestToBeOptedOut(t *testing.T) { providerKeeper.DeleteToBeOptedOut(ctx, "chainID", providerAddr) require.False(t, providerKeeper.IsToBeOptedOut(ctx, "chainID", providerAddr)) } + +// TestToBeOptedOut tests the `SetConsumerCommissionRate`, `GetConsumerCommissionRate`, and `DeleteConsumerCommissionRate` methods +func TestConsumerCommissionRate(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + providerAddr1 := types.NewProviderConsAddress([]byte("providerAddr1")) + providerAddr2 := types.NewProviderConsAddress([]byte("providerAddr2")) + + cr, found := providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + require.False(t, found) + require.Equal(t, sdk.ZeroDec(), cr) + + providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr1, sdk.OneDec()) + cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + require.True(t, found) + require.Equal(t, sdk.OneDec(), cr) + + providerKeeper.SetConsumerCommissionRate(ctx, "chainID", providerAddr2, sdk.ZeroDec()) + cr, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr2) + require.True(t, found) + require.Equal(t, sdk.ZeroDec(), cr) + + provAddrs := providerKeeper.GetAllCommissionRateValidators(ctx, "chainID") + require.Len(t, provAddrs, 2) + + for _, addr := range provAddrs { + providerKeeper.DeleteConsumerCommissionRate(ctx, "chainID", addr) + } + + _, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr1) + require.False(t, found) + + _, found = providerKeeper.GetConsumerCommissionRate(ctx, "chainID", providerAddr2) + require.False(t, found) + +} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 4863cd0d66..9e019bcb22 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -2,14 +2,12 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" + errorsmod "cosmossdk.io/errors" + tmtypes "github.com/cometbft/cometbft/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - tmtypes "github.com/cometbft/cometbft/types" - "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types" ) @@ -195,3 +193,38 @@ func (k msgServer) OptOut(goCtx context.Context, msg *types.MsgOptOut) (*types.M return &types.MsgOptOutResponse{}, nil } + +func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.MsgSetConsumerCommissionRate) (*types.MsgSetConsumerCommissionRateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + providerValidatorAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + if err != nil { + return nil, err + } + + // validator must already be registered + validator, found := k.stakingKeeper.GetValidator(ctx, providerValidatorAddr) + if !found { + return nil, stakingtypes.ErrNoValidatorFound + } + + consAddr, err := validator.GetConsAddr() + if err != nil { + return nil, err + } + + if err := k.HandleSetConsumerCommissionRate(ctx, msg.ChainId, types.NewProviderConsAddress(consAddr), msg.Rate); err != nil { + return nil, err + } + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSetConsumerCommissionRate, + sdk.NewAttribute(types.AttributeConsumerChainID, msg.ChainId), + sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), + sdk.NewAttribute(types.AttributeConsumerCommissionRate, msg.Rate.String()), + ), + }) + + return &types.MsgSetConsumerCommissionRateResponse{}, nil +} diff --git a/x/ccv/provider/keeper/partial_set_security_test.go b/x/ccv/provider/keeper/partial_set_security_test.go index 1af5f58c7c..a6b2ec45e7 100644 --- a/x/ccv/provider/keeper/partial_set_security_test.go +++ b/x/ccv/provider/keeper/partial_set_security_test.go @@ -112,3 +112,28 @@ func TestHandleOptOut(t *testing.T) { require.NoError(t, err) require.False(t, providerKeeper.IsToBeOptedOut(ctx, "chainID", providerAddr)) } + +func TestHandleSetConsumerCommissionRate(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + providerAddr := types.NewProviderConsAddress([]byte("providerAddr")) + + // trying to set a commission rate to a unknown consumer chain + require.Error(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, "unknownChainID", providerAddr, sdk.ZeroDec())) + + // setup a pending consumer chain + chainID := "pendingChainID" + providerKeeper.SetPendingConsumerAdditionProp(ctx, &types.ConsumerAdditionProposal{ChainId: chainID}) + + // check that there's no commission rate set for the validator yet + _, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) + require.False(t, found) + + require.NoError(t, providerKeeper.HandleSetConsumerCommissionRate(ctx, chainID, providerAddr, sdk.OneDec())) + + // check that the commission rate is now set + cr, found := providerKeeper.GetConsumerCommissionRate(ctx, chainID, providerAddr) + require.Equal(t, sdk.OneDec(), cr) + require.True(t, found) +} diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 50dc69d080..399989354c 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -190,6 +190,12 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo k.DeleteVscSendTimestampsForConsumer(ctx, chainID) } + // delete consumer commission rate + provAddrs := k.GetAllCommissionRateValidators(ctx, chainID) + for _, addr := range provAddrs { + k.DeleteConsumerCommissionRate(ctx, chainID, addr) + } + k.DeleteInitChainHeight(ctx, chainID) k.DeleteSlashAcks(ctx, chainID) k.DeletePendingVSCPackets(ctx, chainID) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index dacc456d2f..a979301521 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") diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 6c19a7b396..271ea90329 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -24,4 +24,5 @@ var ( ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists") ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") + ErrInvalidConsumerCommissionRate = errorsmod.Register(ModuleName, 19, "consumer commission rate is invalid") ) diff --git a/x/ccv/provider/types/events.go b/x/ccv/provider/types/events.go index 58d686020f..4838c1ba43 100644 --- a/x/ccv/provider/types/events.go +++ b/x/ccv/provider/types/events.go @@ -7,6 +7,7 @@ const ( EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom" EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" + EventTypeSetConsumerCommissionRate = "set_consumer_commission_rate" AttributeInfractionHeight = "infraction_height" AttributeInitialHeight = "initial_height" AttributeInitializationTimeout = "initialization_timeout" @@ -15,4 +16,6 @@ const ( AttributeProviderValidatorAddress = "provider_validator_address" AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" AttributeConsumerRewardDenom = "consumer_reward_denom" + AttributeConsumerCommissionRate = "consumer_commission_rate" + AttributeConsumerChainID = "consumer_chain_id" ) diff --git a/x/ccv/provider/types/keys.go b/x/ccv/provider/types/keys.go index 9fb9fc9caf..c7b4a01d14 100644 --- a/x/ccv/provider/types/keys.go +++ b/x/ccv/provider/types/keys.go @@ -164,6 +164,10 @@ const ( // it allocated to the consumer rewards pool ConsumerRewardsAllocationBytePrefix + // ConsumerCommissionRatePrefix is the byte prefix used when storing a validator a per-consumer chain commission rate + // for a validator address + ConsumerCommissionRatePrefix + // NOTE: DO NOT ADD NEW BYTE PREFIXES HERE WITHOUT ADDING THEM TO getAllKeyPrefixes() IN keys_test.go ) @@ -564,6 +568,15 @@ func ConsumerRewardsAllocationKey(chainID string) []byte { return append([]byte{ConsumerRewardsAllocationBytePrefix}, []byte(chainID)...) } +// ConsumerCommissionRateKey returns the key of consumer chain `chainID` and validator with `providerAddr` +func ConsumerCommissionRateKey(chainID string, providerAddr ProviderConsAddress) []byte { + return ChainIdAndConsAddrKey( + ConsumerCommissionRatePrefix, + chainID, + providerAddr.ToSdkConsAddr(), + ) +} + // // End of generic helpers section // diff --git a/x/ccv/provider/types/keys_test.go b/x/ccv/provider/types/keys_test.go index 9d797011b6..6bd05f2759 100644 --- a/x/ccv/provider/types/keys_test.go +++ b/x/ccv/provider/types/keys_test.go @@ -61,6 +61,7 @@ func getAllKeyPrefixes() []byte { providertypes.ToBeOptedInBytePrefix, providertypes.ToBeOptedOutBytePrefix, providertypes.ConsumerRewardsAllocationBytePrefix, + providertypes.ConsumerCommissionRatePrefix, } } diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 20aae43f6c..1a8d6fa145 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -24,6 +24,7 @@ const ( TypeMsgSubmitConsumerDoubleVoting = "submit_consumer_double_vote" TypeMsgOptIn = "opt_in" TypeMsgOptOut = "opt_out" + TypeMsgSetConsumerCommissionRate = "set_consumer_commission_rate" ) var ( @@ -32,6 +33,7 @@ var ( _ sdk.Msg = &MsgSubmitConsumerDoubleVoting{} _ sdk.Msg = &MsgOptIn{} _ sdk.Msg = &MsgOptOut{} + _ sdk.Msg = &MsgSetConsumerCommissionRate{} ) // NewMsgAssignConsumerKey creates a new MsgAssignConsumerKey instance. @@ -316,3 +318,45 @@ func (msg MsgOptOut) ValidateBasic() error { func (msg MsgOptOut) Type() string { return TypeMsgOptOut } + +func (msg MsgSetConsumerCommissionRate) Route() string { + return RouterKey +} + +func (msg MsgSetConsumerCommissionRate) Type() string { + return TypeMsgSetConsumerCommissionRate +} + +func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { + if strings.TrimSpace(msg.ChainId) == "" { + return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot be blank") + } + + if 128 < len(msg.ChainId) { + return errorsmod.Wrapf(ErrInvalidConsumerChainID, "chainId cannot exceed 128 length") + } + _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + if err != nil { + return ErrInvalidProviderAddress + } + + if msg.Rate.IsNegative() || msg.Rate.GT(sdk.OneDec()) { + return errorsmod.Wrapf(ErrInvalidConsumerCommissionRate, "consumer commission rate should be in the range [0, 1]") + } + + return nil +} + +func (msg MsgSetConsumerCommissionRate) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +func (msg MsgSetConsumerCommissionRate) GetSignBytes() []byte { + bz := ccvtypes.ModuleCdc.MustMarshalJSON(&msg) + return sdk.MustSortJSON(bz) +} diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 647f5f49dc..7330433f5b 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -9,6 +9,7 @@ import ( types "github.com/cometbft/cometbft/proto/tendermint/types" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -426,6 +427,86 @@ func (m *MsgOptOutResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgOptOutResponse proto.InternalMessageInfo +// MsgSetConsumerCommissionRate allows validators to set +// a per-consumer chain commission rate +type MsgSetConsumerCommissionRate struct { + // The validator address on the provider + ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + // The chain id of the consumer chain to set a commission rate + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // The rate to charge delegators on the consumer chain, as a fraction + Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` +} + +func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerCommissionRate{} } +func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRate) ProtoMessage() {} +func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{10} +} +func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetConsumerCommissionRate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRate.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRate) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetConsumerCommissionRate proto.InternalMessageInfo + +type MsgSetConsumerCommissionRateResponse struct { +} + +func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetConsumerCommissionRateResponse{} } +func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} +func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43221a4391e9fbf4, []int{11} +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgAssignConsumerKey)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKey") proto.RegisterType((*MsgAssignConsumerKeyResponse)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKeyResponse") @@ -437,6 +518,8 @@ func init() { proto.RegisterType((*MsgOptInResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptInResponse") proto.RegisterType((*MsgOptOut)(nil), "interchain_security.ccv.provider.v1.MsgOptOut") proto.RegisterType((*MsgOptOutResponse)(nil), "interchain_security.ccv.provider.v1.MsgOptOutResponse") + proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRate") + proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "interchain_security.ccv.provider.v1.MsgSetConsumerCommissionRateResponse") } func init() { @@ -444,50 +527,57 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 683 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0x4d, 0x4f, 0xd4, 0x40, - 0x18, 0xde, 0x42, 0x40, 0x18, 0xd0, 0x48, 0x85, 0x00, 0x1b, 0xec, 0xea, 0x1a, 0xc5, 0x03, 0xcc, - 0x04, 0xfc, 0x8a, 0x24, 0x1e, 0x58, 0x31, 0x11, 0xcd, 0x06, 0xb3, 0x26, 0x98, 0x78, 0xb0, 0x69, - 0xa7, 0x43, 0x77, 0x42, 0x3b, 0xd3, 0xcc, 0x4c, 0x1b, 0xf6, 0x1f, 0x90, 0x78, 0xd1, 0x93, 0xf1, - 0xc6, 0x0f, 0xf0, 0x87, 0x78, 0xe4, 0xc8, 0xc9, 0x18, 0xb8, 0x78, 0xf6, 0x17, 0x98, 0x9d, 0x7e, - 0x6c, 0x89, 0x2b, 0x5f, 0xc6, 0x78, 0xeb, 0xbc, 0xef, 0x33, 0xcf, 0xf3, 0xbc, 0x6f, 0xe7, 0x9d, - 0x01, 0x0b, 0x94, 0x29, 0x22, 0x70, 0xdb, 0xa1, 0xcc, 0x96, 0x04, 0xc7, 0x82, 0xaa, 0x0e, 0xc2, - 0x38, 0x41, 0x91, 0xe0, 0x09, 0xf5, 0x88, 0x40, 0xc9, 0x12, 0x52, 0x3b, 0x30, 0x12, 0x5c, 0x71, - 0xf3, 0x56, 0x1f, 0x34, 0xc4, 0x38, 0x81, 0x39, 0x1a, 0x26, 0x4b, 0xd5, 0x49, 0x9f, 0xfb, 0x5c, - 0xe3, 0x51, 0xf7, 0x2b, 0xdd, 0x5a, 0x9d, 0xc5, 0x5c, 0x86, 0x5c, 0xda, 0x69, 0x22, 0x5d, 0xe4, - 0x29, 0x9f, 0x73, 0x3f, 0x20, 0x48, 0xaf, 0xdc, 0x78, 0x0b, 0x39, 0xac, 0x93, 0xa5, 0x10, 0x75, - 0x31, 0x0a, 0xa8, 0xdf, 0x56, 0x38, 0xa0, 0x84, 0x29, 0x89, 0x14, 0x61, 0x1e, 0x11, 0x21, 0x65,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 0x33, 0xdb, 0x38, 0xab, 0xc2, - 0x9f, 0x39, 0xaa, 0x2f, 0xfe, 0x9e, 0xe3, 0x04, 0xbb, 0xc7, 0xa6, 0xf3, 0x82, 0x76, 0xcb, 0x1c, - 0x17, 0xb5, 0xdb, 0x6f, 0x36, 0xcc, 0x10, 0x0c, 0xa5, 0x73, 0xb1, 0x78, 0x56, 0x52, 0x0d, 0xaf, - 0x3e, 0x38, 0x17, 0xbc, 0x90, 0x8b, 0xc0, 0x70, 0x76, 0xca, 0xe1, 0x39, 0x08, 0x36, 0x62, 0x55, - 0x7d, 0x78, 0x3e, 0x7c, 0xae, 0xd8, 0x78, 0xf3, 0xf5, 0xd0, 0x32, 0xf6, 0x0f, 0x2d, 0xe3, 0xfb, - 0xa1, 0x65, 0x7c, 0x38, 0xb2, 0x2a, 0xfb, 0x47, 0x56, 0xe5, 0xe0, 0xc8, 0xaa, 0xbc, 0x7d, 0xe2, - 0x53, 0xd5, 0x8e, 0x5d, 0x88, 0x79, 0x98, 0xbd, 0xa7, 0xa8, 0x27, 0xb1, 0x58, 0x3c, 0xe6, 0xc9, - 0x7d, 0xb4, 0x73, 0xfc, 0x45, 0xd7, 0xb7, 0xa2, 0x3b, 0xac, 0xdf, 0xc3, 0x7b, 0xbf, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x3b, 0x47, 0x43, 0x85, 0x02, 0x08, 0x00, 0x00, + // 787 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x4f, 0xd4, 0x4e, + 0x18, 0xde, 0xc2, 0xef, 0xc7, 0xc7, 0x80, 0x46, 0x2a, 0x04, 0x68, 0x70, 0x57, 0x57, 0x05, 0x0f, + 0x6c, 0x1b, 0xf0, 0x2b, 0x12, 0x3d, 0xb0, 0x60, 0x22, 0x9a, 0x0d, 0xa4, 0x24, 0x98, 0x78, 0xb0, + 0x69, 0xa7, 0x43, 0x77, 0xc2, 0x76, 0xa6, 0xe9, 0x4c, 0x1b, 0xf6, 0xee, 0x81, 0xc4, 0x8b, 0x9e, + 0x8c, 0x37, 0xae, 0x26, 0x1e, 0xfd, 0x23, 0x38, 0x19, 0xe2, 0xc9, 0x78, 0x20, 0x06, 0x2e, 0x9e, + 0xfd, 0x0b, 0xcc, 0x4e, 0x3f, 0xb6, 0x1b, 0x96, 0x65, 0x81, 0x18, 0x4f, 0xbb, 0x33, 0xef, 0x33, + 0xcf, 0xfb, 0x3c, 0x6f, 0xa7, 0x4f, 0x0a, 0x66, 0x31, 0xe1, 0xc8, 0x87, 0x55, 0x13, 0x13, 0x83, + 0x21, 0x18, 0xf8, 0x98, 0xd7, 0x35, 0x08, 0x43, 0xcd, 0xf3, 0x69, 0x88, 0x6d, 0xe4, 0x6b, 0xe1, + 0x9c, 0xc6, 0xb7, 0x55, 0xcf, 0xa7, 0x9c, 0xca, 0x37, 0xdb, 0xa0, 0x55, 0x08, 0x43, 0x35, 0x41, + 0xab, 0xe1, 0x9c, 0x32, 0xea, 0x50, 0x87, 0x0a, 0xbc, 0xd6, 0xf8, 0x17, 0x1d, 0x55, 0x26, 0x21, + 0x65, 0x2e, 0x65, 0x46, 0x54, 0x88, 0x16, 0x49, 0xc9, 0xa1, 0xd4, 0xa9, 0x21, 0x4d, 0xac, 0xac, + 0x60, 0x53, 0x33, 0x49, 0x3d, 0x2e, 0x69, 0xd8, 0x82, 0x5a, 0x0d, 0x3b, 0x55, 0x0e, 0x6b, 0x18, + 0x11, 0xce, 0x34, 0x8e, 0x88, 0x8d, 0x7c, 0x17, 0x13, 0x2e, 0x94, 0xa5, 0xab, 0xf8, 0x40, 0x21, + 0x53, 0xe7, 0x75, 0x0f, 0x31, 0x0d, 0x35, 0x84, 0x11, 0x88, 0x22, 0x40, 0xf1, 0x83, 0x04, 0x46, + 0x2b, 0xcc, 0x59, 0x64, 0x0c, 0x3b, 0x64, 0x89, 0x12, 0x16, 0xb8, 0xc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0x16, 0xa7, + 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -507,6 +597,7 @@ type MsgClient interface { SubmitConsumerDoubleVoting(ctx context.Context, in *MsgSubmitConsumerDoubleVoting, opts ...grpc.CallOption) (*MsgSubmitConsumerDoubleVotingResponse, error) OptIn(ctx context.Context, in *MsgOptIn, opts ...grpc.CallOption) (*MsgOptInResponse, error) OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.CallOption) (*MsgOptOutResponse, error) + SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) } type msgClient struct { @@ -562,6 +653,15 @@ func (c *msgClient) OptOut(ctx context.Context, in *MsgOptOut, opts ...grpc.Call return out, nil } +func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { + out := new(MsgSetConsumerCommissionRateResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { AssignConsumerKey(context.Context, *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) @@ -569,6 +669,7 @@ type MsgServer interface { SubmitConsumerDoubleVoting(context.Context, *MsgSubmitConsumerDoubleVoting) (*MsgSubmitConsumerDoubleVotingResponse, error) OptIn(context.Context, *MsgOptIn) (*MsgOptInResponse, error) OptOut(context.Context, *MsgOptOut) (*MsgOptOutResponse, error) + SetConsumerCommissionRate(context.Context, *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -590,6 +691,9 @@ func (*UnimplementedMsgServer) OptIn(ctx context.Context, req *MsgOptIn) (*MsgOp func (*UnimplementedMsgServer) OptOut(ctx context.Context, req *MsgOptOut) (*MsgOptOutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OptOut not implemented") } +func (*UnimplementedMsgServer) SetConsumerCommissionRate(ctx context.Context, req *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetConsumerCommissionRate not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -685,6 +789,24 @@ func _Msg_OptOut_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetConsumerCommissionRate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.provider.v1.Msg/SetConsumerCommissionRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, req.(*MsgSetConsumerCommissionRate)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.provider.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -709,6 +831,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "OptOut", Handler: _Msg_OptOut_Handler, }, + { + MethodName: "SetConsumerCommissionRate", + Handler: _Msg_SetConsumerCommissionRate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/provider/v1/tx.proto", @@ -1050,6 +1176,76 @@ func (m *MsgOptOutResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgSetConsumerCommissionRate) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetConsumerCommissionRate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetConsumerCommissionRateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetConsumerCommissionRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1203,6 +1399,34 @@ func (m *MsgOptOutResponse) Size() (n int) { return n } +func (m *MsgSetConsumerCommissionRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2137,6 +2361,204 @@ func (m *MsgOptOutResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetConsumerCommissionRateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0