diff --git a/CHANGELOG.md b/CHANGELOG.md index 87949647a7..efe850fa2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,8 +87,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/gov/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/18036) `MsgDeposit` has been removed because of AutoCLI migration. * (x/staking/testutil) [#17986](https://github.com/cosmos/cosmos-sdk/pull/17986) `MsgRedelegateExec`, `MsgUnbondExec` has been removed because of AutoCLI migration. * (x/bank/testutil) [#17868](https://github.com/cosmos/cosmos-sdk/pull/17868) `MsgSendExec` has been removed because of AutoCLI migration. -* (x/distribution) [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The `FundCommunityPool` and `DistributeFromFeePool` keeper methods are now removed from x/distribution. -* (x/distribution) [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The distribution module keeper now takes a new argument `PoolKeeper` in addition. * (app) [#17838](https://github.com/cosmos/cosmos-sdk/pull/17838) Params module was removed from simapp and all imports of the params module removed throughout the repo. * The Cosmos SDK has migrated away from using params, if your app still uses it, then you can leave it plugged into your app * (x/staking) [#17778](https://github.com/cosmos/cosmos-sdk/pull/17778) Use collections for `Params` @@ -136,8 +134,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/staking) [#17248](https://github.com/cosmos/cosmos-sdk/pull/17248) Use collections for `UnbondingType`. * remove from `types`: `GetUnbondingTypeKey`. * (client) [#17259](https://github.com/cosmos/cosmos-sdk/pull/17259) Remove deprecated `clientCtx.PrintObjectLegacy`. Use `clientCtx.PrintProto` or `clientCtx.PrintRaw` instead. -* (x/distribution) [#17115](https://github.com/cosmos/cosmos-sdk/pull/17115) Use collections for `PreviousProposer` and `ValidatorSlashEvents`: - * remove from `Keeper`: `GetPreviousProposerConsAddr`, `SetPreviousProposerConsAddr`, `GetValidatorHistoricalReferenceCount`, `GetValidatorSlashEvent`, `SetValidatorSlashEvent`. * (x/feegrant) [#16535](https://github.com/cosmos/cosmos-sdk/pull/16535) Use collections for `FeeAllowance`, `FeeAllowanceQueue`. * (x/staking) [#17063](https://github.com/cosmos/cosmos-sdk/pull/17063) Use collections for `HistoricalInfo`: * remove `Keeper`: `GetHistoricalInfo`, `SetHistoricalInfo` @@ -147,19 +143,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * remove `Keeper`: `SetValidatorSigningInfo`, `GetValidatorSigningInfo`, `IterateValidatorSigningInfos` * (x/staking) [#17026](https://github.com/cosmos/cosmos-sdk/pull/17026) Use collections for `LastTotalPower`: * remove `Keeper`: `SetLastTotalPower`, `GetLastTotalPower` -* (x/distribution) [#16440](https://github.com/cosmos/cosmos-sdk/pull/16440) use collections for `DelegatorWithdrawAddresState`: - * remove `Keeper`: `SetDelegatorWithdrawAddr`, `DeleteDelegatorWithdrawAddr`, `IterateDelegatorWithdrawAddrs`. -* (x/distribution) [#16459](https://github.com/cosmos/cosmos-sdk/pull/16459) use collections for `ValidatorCurrentRewards` state management: - * remove `Keeper`: `IterateValidatorCurrentRewards`, `GetValidatorCurrentRewards`, `SetValidatorCurrentRewards`, `DeleteValidatorCurrentRewards` * (x/authz) [#16509](https://github.com/cosmos/cosmos-sdk/pull/16509) `AcceptResponse` has been moved to sdk/types/authz and the `Updated` field is now of the type `sdk.Msg` instead of `authz.Authorization`. -* (x/distribution) [#16483](https://github.com/cosmos/cosmos-sdk/pull/16483) use collections for `DelegatorStartingInfo` state management: - * remove `Keeper`: `IterateDelegatorStartingInfo`, `GetDelegatorStartingInfo`, `SetDelegatorStartingInfo`, `DeleteDelegatorStartingInfo`, `HasDelegatorStartingInfo` -* (x/distribution) [#16571](https://github.com/cosmos/cosmos-sdk/pull/16571) use collections for `ValidatorAccumulatedCommission` state management: - * remove `Keeper`: `IterateValidatorAccumulatedCommission`, `GetValidatorAccumulatedCommission`, `SetValidatorAccumulatedCommission`, `DeleteValidatorAccumulatedCommission` -* (x/distribution) [#16590](https://github.com/cosmos/cosmos-sdk/pull/16590) use collections for `ValidatorOutstandingRewards` state management: - * remove `Keeper`: `IterateValidatorOutstandingRewards`, `GetValidatorOutstandingRewards`, `SetValidatorOutstandingRewards`, `DeleteValidatorOutstandingRewards` -* (x/distribution) [#16607](https://github.com/cosmos/cosmos-sdk/pull/16607) use collections for `ValidatorHistoricalRewards` state management: - * remove `Keeper`: `IterateValidatorHistoricalRewards`, `GetValidatorHistoricalRewards`, `SetValidatorHistoricalRewards`, `DeleteValidatorHistoricalRewards`, `DeleteValidatorHistoricalReward`, `DeleteAllValidatorHistoricalRewards` * (x/slashing) [#16441](https://github.com/cosmos/cosmos-sdk/pull/16441) Params state is migrated to collections. `GetParams` has been removed. * (types) [#16918](https://github.com/cosmos/cosmos-sdk/pull/16918) Remove `IntProto` and `DecProto`. Instead, `math.Int` and `math.LegacyDec` should be used respectively. Both types support `Marshal` and `Unmarshal` which should be used for binary marshaling. * (client) [#17215](https://github.com/cosmos/cosmos-sdk/pull/17215) `server.StartCmd`,`server.ExportCmd`,`server.NewRollbackCmd`,`pruning.Cmd`,`genutilcli.InitCmd`,`genutilcli.GenTxCmd`,`genutilcli.CollectGenTxsCmd`,`genutilcli.AddGenesisAccountCmd`, do not take a home directory anymore. It is inferred from the root command. @@ -171,7 +155,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [#17426](https://github.com/cosmos/cosmos-sdk/pull/17426) `NewContext` does not take a `cmtproto.Header{}` any longer. * `WithChainID` / `WithBlockHeight` / `WithBlockHeader` must be used to set values on the context * (x/bank) [#17569](https://github.com/cosmos/cosmos-sdk/pull/17569) `BurnCoins` takes an address instead of a module name -* (x/distribution) [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` * (types) [#17738](https://github.com/cosmos/cosmos-sdk/pull/17738) `WithBlockTime()` was removed & `BlockTime()` were deprecated in favor of `WithHeaderInfo()` & `HeaderInfo()`. `BlockTime` now gets data from `HeaderInfo()` instead of `BlockHeader()`. * (client) [#17746](https://github.com/cosmos/cosmos-sdk/pull/17746) `txEncodeAmino` & `txDecodeAmino` txs via grpc and rest were removed * `RegisterLegacyAmino` was removed from `AppModuleBasic` @@ -195,19 +178,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `appd export` has moved with other genesis commands, use `appd genesis export` instead. * (x/auth/vesting) [#18100](https://github.com/cosmos/cosmos-sdk/pull/18100) `appd tx vesting create-vesting-account` takes an amount of coin as last argument instead of second. Coins are space separated. -* (x/distribution) [#17963](https://github.com/cosmos/cosmos-sdk/pull/17963) `appd tx distribution withdraw-rewards` now only withdraws rewards for the delegator's own delegations. For withdrawing validators commission, use `appd tx distribution withdraw-validator-commission`. ### State Machine Breaking -* (x/distribution) [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) Migrate community pool funds from x/distribution to x/protocolpool. -* (x/distribution) [#17115](https://github.com/cosmos/cosmos-sdk/pull/17115) Migrate `PreviousProposer` to collections. * (x/upgrade) [#16244](https://github.com/cosmos/cosmos-sdk/pull/16244) Upgrade module no longer stores the app version but gets and sets the app version stored in the `ParamStore` of baseapp. * (x/staking) [#17655](https://github.com/cosmos/cosmos-sdk/pull/17655) `HistoricalInfo` was replaced with `HistoricalRecord`, it removes the validator set and comet header and only keep what is needed for IBC. -### Client Breaking Changes - -* (x/distribution) [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) Deprecate `CommunityPool` and `FundCommunityPool` rpc methods. Use x/protocolpool module's rpc methods instead. - ## [v0.50.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1) - 2023-11-07 > v0.50.0 has been retracted due to a mistake in tagging the release. Please use v0.50.1 instead. diff --git a/api/cosmos/distribution/v1beta1/distribution.pulsar.go b/api/cosmos/distribution/v1beta1/distribution.pulsar.go index 73f5ec2668..cdfdc65147 100644 --- a/api/cosmos/distribution/v1beta1/distribution.pulsar.go +++ b/api/cosmos/distribution/v1beta1/distribution.pulsar.go @@ -3703,15 +3703,68 @@ func (x *_FeePool_1_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_FeePool_2_list)(nil) + +type _FeePool_2_list struct { + list *[]*v1beta1.DecCoin +} + +func (x *_FeePool_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_FeePool_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_FeePool_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.DecCoin) + (*x.list)[i] = concreteValue +} + +func (x *_FeePool_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.DecCoin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_FeePool_2_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.DecCoin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_FeePool_2_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_FeePool_2_list) NewElement() protoreflect.Value { + v := new(v1beta1.DecCoin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_FeePool_2_list) IsValid() bool { + return x.list != nil +} + var ( md_FeePool protoreflect.MessageDescriptor fd_FeePool_community_pool protoreflect.FieldDescriptor + fd_FeePool_decimal_pool protoreflect.FieldDescriptor ) func init() { file_cosmos_distribution_v1beta1_distribution_proto_init() md_FeePool = File_cosmos_distribution_v1beta1_distribution_proto.Messages().ByName("FeePool") fd_FeePool_community_pool = md_FeePool.Fields().ByName("community_pool") + fd_FeePool_decimal_pool = md_FeePool.Fields().ByName("decimal_pool") } var _ protoreflect.Message = (*fastReflection_FeePool)(nil) @@ -3785,6 +3838,12 @@ func (x *fastReflection_FeePool) Range(f func(protoreflect.FieldDescriptor, prot return } } + if len(x.DecimalPool) != 0 { + value := protoreflect.ValueOfList(&_FeePool_2_list{list: &x.DecimalPool}) + if !f(fd_FeePool_decimal_pool, value) { + return + } + } } // Has reports whether a field is populated. @@ -3802,6 +3861,8 @@ func (x *fastReflection_FeePool) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { case "cosmos.distribution.v1beta1.FeePool.community_pool": return len(x.CommunityPool) != 0 + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + return len(x.DecimalPool) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3820,6 +3881,8 @@ func (x *fastReflection_FeePool) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "cosmos.distribution.v1beta1.FeePool.community_pool": x.CommunityPool = nil + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + x.DecimalPool = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3842,6 +3905,12 @@ func (x *fastReflection_FeePool) Get(descriptor protoreflect.FieldDescriptor) pr } listValue := &_FeePool_1_list{list: &x.CommunityPool} return protoreflect.ValueOfList(listValue) + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + if len(x.DecimalPool) == 0 { + return protoreflect.ValueOfList(&_FeePool_2_list{}) + } + listValue := &_FeePool_2_list{list: &x.DecimalPool} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3866,6 +3935,10 @@ func (x *fastReflection_FeePool) Set(fd protoreflect.FieldDescriptor, value prot lv := value.List() clv := lv.(*_FeePool_1_list) x.CommunityPool = *clv.list + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + lv := value.List() + clv := lv.(*_FeePool_2_list) + x.DecimalPool = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3892,6 +3965,12 @@ func (x *fastReflection_FeePool) Mutable(fd protoreflect.FieldDescriptor) protor } value := &_FeePool_1_list{list: &x.CommunityPool} return protoreflect.ValueOfList(value) + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + if x.DecimalPool == nil { + x.DecimalPool = []*v1beta1.DecCoin{} + } + value := &_FeePool_2_list{list: &x.DecimalPool} + return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3908,6 +3987,9 @@ func (x *fastReflection_FeePool) NewField(fd protoreflect.FieldDescriptor) proto case "cosmos.distribution.v1beta1.FeePool.community_pool": list := []*v1beta1.DecCoin{} return protoreflect.ValueOfList(&_FeePool_1_list{list: &list}) + case "cosmos.distribution.v1beta1.FeePool.decimal_pool": + list := []*v1beta1.DecCoin{} + return protoreflect.ValueOfList(&_FeePool_2_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.FeePool")) @@ -3983,6 +4065,12 @@ func (x *fastReflection_FeePool) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if len(x.DecimalPool) > 0 { + for _, e := range x.DecimalPool { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -4012,6 +4100,22 @@ func (x *fastReflection_FeePool) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.DecimalPool) > 0 { + for iNdEx := len(x.DecimalPool) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.DecimalPool[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + } + } if len(x.CommunityPool) > 0 { for iNdEx := len(x.CommunityPool) - 1; iNdEx >= 0; iNdEx-- { encoded, err := options.Marshal(x.CommunityPool[iNdEx]) @@ -4111,6 +4215,40 @@ func (x *fastReflection_FeePool) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DecimalPool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.DecimalPool = append(x.DecimalPool, &v1beta1.DecCoin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.DecimalPool[len(x.DecimalPool)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -6925,12 +7063,15 @@ func (x *ValidatorSlashEvents) GetValidatorSlashEvents() []*ValidatorSlashEvent } // FeePool is the global fee pool for distribution. +// It holds decimal coins. Once whole those coins can be burned or distributed to the community pool. type FeePool struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // Deprecated: Do not use. CommunityPool []*v1beta1.DecCoin `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3" json:"community_pool,omitempty"` + DecimalPool []*v1beta1.DecCoin `protobuf:"bytes,2,rep,name=decimal_pool,json=decimalPool,proto3" json:"decimal_pool,omitempty"` } func (x *FeePool) Reset() { @@ -6953,6 +7094,7 @@ func (*FeePool) Descriptor() ([]byte, []int) { return file_cosmos_distribution_v1beta1_distribution_proto_rawDescGZIP(), []int{7} } +// Deprecated: Do not use. func (x *FeePool) GetCommunityPool() []*v1beta1.DecCoin { if x != nil { return x.CommunityPool @@ -6960,6 +7102,13 @@ func (x *FeePool) GetCommunityPool() []*v1beta1.DecCoin { return nil } +func (x *FeePool) GetDecimalPool() []*v1beta1.DecCoin { + if x != nil { + return x.DecimalPool + } + return nil +} + // CommunityPoolSpendProposal details a proposal for use of community funds, // together with how many coins are proposed to be spent, and to which // recipient account. @@ -7304,92 +7453,99 @@ var file_cosmos_distribution_v1beta1_distribution_proto_rawDesc = []byte{ 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x6c, 0x61, - 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x88, 0x01, 0x0a, 0x07, 0x46, 0x65, 0x65, - 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x7d, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, + 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x80, 0x02, 0x0a, 0x07, 0x46, 0x65, 0x65, + 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x7f, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x38, 0xc8, 0xde, 0x1f, 0x00, - 0xaa, 0xdf, 0x1f, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, - 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0xa8, - 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x50, - 0x6f, 0x6f, 0x6c, 0x22, 0x97, 0x02, 0x0a, 0x1a, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, - 0x79, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, - 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, - 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, - 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, - 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, - 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x3a, 0x28, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0xca, - 0xb4, 0x2d, 0x1a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0xd4, 0x01, - 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x72, 0x74, - 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, - 0x6f, 0x75, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0e, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, - 0x12, 0x4c, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x36, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, - 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, - 0x65, 0x63, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, 0x44, - 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x2c, - 0xea, 0xde, 0x1f, 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0xa2, 0xe7, 0xb0, 0x2a, 0x0f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x68, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x22, 0xe1, 0x01, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x12, 0x4e, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, - 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x6e, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, - 0x42, 0x38, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, - 0x43, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0xd5, 0x01, 0x0a, 0x25, 0x43, 0x6f, 0x6d, - 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x50, - 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x57, 0x69, 0x74, 0x68, 0x44, 0x65, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, - 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, - 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x3a, 0x24, 0x18, 0x01, 0x88, 0xa0, - 0x1f, 0x00, 0xca, 0xb4, 0x2d, 0x1a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x42, 0x88, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x42, 0x11, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, - 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x44, - 0x58, 0xaa, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, - 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x27, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, - 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x3a, 0x3a, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x61, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x3a, 0x18, 0x01, 0xc8, 0xde, + 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, + 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, + 0x73, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, + 0x79, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x74, 0x0a, 0x0c, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, + 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x33, 0xc8, 0xde, 0x1f, 0x00, 0xaa, + 0xdf, 0x1f, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x0b, + 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x50, 0x6f, 0x6f, 0x6c, 0x22, 0x97, 0x02, 0x0a, 0x1a, + 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x50, 0x6f, 0x6f, 0x6c, 0x53, 0x70, 0x65, + 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, + 0x12, 0x79, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x46, 0xc8, 0xde, 0x1f, + 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, + 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x9a, 0xe7, 0xb0, + 0x2a, 0x0c, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, + 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x28, 0x18, 0x01, 0x88, + 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0xca, 0xb4, 0x2d, 0x1a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0xd4, 0x01, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, + 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x27, 0x0a, 0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x69, + 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0e, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, + 0x75, 0x73, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x4c, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x6b, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, + 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, + 0x74, 0x68, 0x2e, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, + 0x05, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x12, 0x44, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x2c, 0xea, 0xde, 0x1f, 0x0f, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0xa2, 0xe7, 0xb0, 0x2a, 0x0f, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0xa8, + 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0xe1, 0x01, 0x0a, + 0x19, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x6c, 0x65, 0x67, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x4e, 0x0a, 0x11, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x21, 0xd2, 0xb4, 0x2d, 0x1d, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x6e, 0x0a, 0x06, 0x72, 0x65, + 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x38, 0xc8, 0xde, 0x1f, 0x00, 0xaa, 0xdf, + 0x1f, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0xa8, 0xe7, 0xb0, + 0x2a, 0x01, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, + 0x22, 0xd5, 0x01, 0x0a, 0x25, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x50, 0x6f, + 0x6f, 0x6c, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x57, + 0x69, 0x74, 0x68, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, + 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x63, 0x69, 0x70, 0x69, 0x65, 0x6e, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x3a, 0x24, 0x18, 0x01, 0x88, 0xa0, 0x1f, 0x00, 0xca, 0xb4, 0x2d, 0x1a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x88, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x11, 0x44, 0x69, + 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x40, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, + 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x44, 0x58, 0xaa, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x5c, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x27, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x44, + 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x1d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa8, + 0xe2, 0x1e, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -7428,13 +7584,14 @@ var file_cosmos_distribution_v1beta1_distribution_proto_depIdxs = []int32{ 12, // 3: cosmos.distribution.v1beta1.ValidatorOutstandingRewards.rewards:type_name -> cosmos.base.v1beta1.DecCoin 5, // 4: cosmos.distribution.v1beta1.ValidatorSlashEvents.validator_slash_events:type_name -> cosmos.distribution.v1beta1.ValidatorSlashEvent 12, // 5: cosmos.distribution.v1beta1.FeePool.community_pool:type_name -> cosmos.base.v1beta1.DecCoin - 13, // 6: cosmos.distribution.v1beta1.CommunityPoolSpendProposal.amount:type_name -> cosmos.base.v1beta1.Coin - 12, // 7: cosmos.distribution.v1beta1.DelegationDelegatorReward.reward:type_name -> cosmos.base.v1beta1.DecCoin - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 12, // 6: cosmos.distribution.v1beta1.FeePool.decimal_pool:type_name -> cosmos.base.v1beta1.DecCoin + 13, // 7: cosmos.distribution.v1beta1.CommunityPoolSpendProposal.amount:type_name -> cosmos.base.v1beta1.Coin + 12, // 8: cosmos.distribution.v1beta1.DelegationDelegatorReward.reward:type_name -> cosmos.base.v1beta1.DecCoin + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_cosmos_distribution_v1beta1_distribution_proto_init() } diff --git a/proto/cosmos/distribution/v1beta1/distribution.proto b/proto/cosmos/distribution/v1beta1/distribution.proto index 120afb15fc..4be19167c2 100644 --- a/proto/cosmos/distribution/v1beta1/distribution.proto +++ b/proto/cosmos/distribution/v1beta1/distribution.proto @@ -115,12 +115,17 @@ message ValidatorSlashEvents { } // FeePool is the global fee pool for distribution. +// It holds decimal coins. Once whole those coins can be burned or distributed to the community pool. message FeePool { repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + deprecated = true ]; + + repeated cosmos.base.v1beta1.DecCoin decimal_pool = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; } // CommunityPoolSpendProposal details a proposal for use of community funds, diff --git a/simapp/export.go b/simapp/export.go index 81e78fd326..3d50129819 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -126,8 +126,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] if err != nil { panic(err) } - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) + // donate any unwithdrawn outstanding reward tokens to the community pool + rewards, err := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, valBz) if err != nil { panic(err) } @@ -135,7 +135,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] if err != nil { panic(err) } - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) + feePool.DecimalPool = feePool.DecimalPool.Add(rewards...) // distribution will allocate this to the protocolpool eventually if err := app.DistrKeeper.FeePool.Set(ctx, feePool); err != nil { panic(err) } diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 4afa781f6b..e03280f4bc 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -178,8 +178,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { }) require.NoError(t, err) require.NoError(t, f.distrKeeper.Params.Set(f.sdkCtx, distrtypes.DefaultParams())) - initFeePool, err := f.distrKeeper.FeePool.Get(f.sdkCtx) - assert.NilError(t, err) delAddr := sdk.AccAddress(PKS[1].Address()) valConsAddr := sdk.ConsAddress(valConsPk0.Address()) @@ -228,8 +226,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { require.NoError(t, err) err = f.distrKeeper.ValidatorOutstandingRewards.Set(f.sdkCtx, f.valAddr, distrtypes.ValidatorOutstandingRewards{Rewards: valCommission}) require.NoError(t, err) - initOutstandingRewards, err := f.distrKeeper.GetValidatorOutstandingRewardsCoins(f.sdkCtx, f.valAddr) - assert.NilError(t, err) testCases := []struct { name string @@ -324,13 +320,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { // check current balance is greater than initial balance curBalance := f.bankKeeper.GetAllBalances(f.sdkCtx, sdk.AccAddress(f.valAddr)) assert.Assert(t, initBalance.IsAllLTE(curBalance)) - - // check rewards - curFeePool, _ := f.distrKeeper.FeePool.Get(f.sdkCtx) - rewards := curFeePool.GetCommunityPool().Sub(initFeePool.CommunityPool) - curOutstandingRewards, err := f.distrKeeper.ValidatorOutstandingRewards.Get(f.sdkCtx, f.valAddr) - assert.NilError(t, err) - assert.DeepEqual(t, rewards, initOutstandingRewards.Sub(curOutstandingRewards.Rewards)) } prevProposerConsAddr, err := f.distrKeeper.PreviousProposer.Get(f.sdkCtx) diff --git a/x/distribution/CHANGELOG.md b/x/distribution/CHANGELOG.md new file mode 100644 index 0000000000..6eaa62a96b --- /dev/null +++ b/x/distribution/CHANGELOG.md @@ -0,0 +1,64 @@ + + +# Changelog + +## [Unreleased] + +### Features + +* + +### API Breaking Changes + +* [#17115](https://github.com/cosmos/cosmos-sdk/pull/17115) Use collections for `PreviousProposer` and `ValidatorSlashEvents`: + * remove from `Keeper`: `GetPreviousProposerConsAddr`, `SetPreviousProposerConsAddr`, `GetValidatorHistoricalReferenceCount`, `GetValidatorSlashEvent`, `SetValidatorSlashEvent`. +* [#16483](https://github.com/cosmos/cosmos-sdk/pull/16483) use collections for `DelegatorStartingInfo` state management: + * remove `Keeper`: `IterateDelegatorStartingInfo`, `GetDelegatorStartingInfo`, `SetDelegatorStartingInfo`, `DeleteDelegatorStartingInfo`, `HasDelegatorStartingInfo` +* [#16571](https://github.com/cosmos/cosmos-sdk/pull/16571) use collections for `ValidatorAccumulatedCommission` state management: + * remove `Keeper`: `IterateValidatorAccumulatedCommission`, `GetValidatorAccumulatedCommission`, `SetValidatorAccumulatedCommission`, `DeleteValidatorAccumulatedCommission` +* [#16590](https://github.com/cosmos/cosmos-sdk/pull/16590) use collections for `ValidatorOutstandingRewards` state management: + * remove `Keeper`: `IterateValidatorOutstandingRewards`, `GetValidatorOutstandingRewards`, `SetValidatorOutstandingRewards`, `DeleteValidatorOutstandingRewards` +* [#16607](https://github.com/cosmos/cosmos-sdk/pull/16607) use collections for `ValidatorHistoricalRewards` state management: + * remove `Keeper`: `IterateValidatorHistoricalRewards`, `GetValidatorHistoricalRewards`, `SetValidatorHistoricalRewards`, `DeleteValidatorHistoricalRewards`, `DeleteValidatorHistoricalReward`, `DeleteAllValidatorHistoricalRewards` +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The `FundCommunityPool` and `DistributeFromFeePool` keeper methods are now removed from x/distribution. +* [#16440](https://github.com/cosmos/cosmos-sdk/pull/16440) use collections for `DelegatorWithdrawAddresState`: + * remove `Keeper`: `SetDelegatorWithdrawAddr`, `DeleteDelegatorWithdrawAddr`, `IterateDelegatorWithdrawAddrs`. +* [#16459](https://github.com/cosmos/cosmos-sdk/pull/16459) use collections for `ValidatorCurrentRewards` state management: + * remove `Keeper`: `IterateValidatorCurrentRewards`, `GetValidatorCurrentRewards`, `SetValidatorCurrentRewards`, `DeleteValidatorCurrentRewards` +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) The distribution module keeper now takes a new argument `PoolKeeper` in addition. +* [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` + +### CLI Breaking Changes + +* [#17963](https://github.com/cosmos/cosmos-sdk/pull/17963) `appd tx distribution withdraw-rewards` now only withdraws rewards for the delegator's own delegations. For withdrawing validators commission, use `appd tx distribution withdraw-validator-commission`. + +### State Machine Breaking + +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) Migrate community pool funds from `x/distribution` to `x/protocolpool`. +* [#17115](https://github.com/cosmos/cosmos-sdk/pull/17115) Migrate `PreviousProposer` to collections. +* [#18539](https://github.com/cosmos/cosmos-sdk/pull/18539) Introduce `FeePool.DecimalPool` to replace `FeePool.CommunityPool`, which temporarily holds fractional rewards until they are distributed to the community pool every 1000 blocks. + +### Client Breaking Changes + +* [#17657](https://github.com/cosmos/cosmos-sdk/pull/17657) Deprecate `CommunityPool` and `FundCommunityPool` rpc methods. Use `x/protocolpool` module's rpc methods instead. diff --git a/x/distribution/README.md b/x/distribution/README.md index 32858fd696..03e1e5baff 100644 --- a/x/distribution/README.md +++ b/x/distribution/README.md @@ -43,7 +43,7 @@ and delegators to independently and lazily withdraw their rewards. As a part of the lazy computations, each delegator holds an accumulation term specific to each validator which is used to estimate what their approximate -fair portion of tokens held in the global fee pool is owed to them. +fair portion of tokens held in the fee pool is owed to them. ```text entitlement = delegator-accumulation / all-delegators-accumulation @@ -81,7 +81,6 @@ to set up a script to periodically withdraw and rebond rewards. * [Concepts](#concepts) * [State](#state) - * [FeePool](#feepool) * [Validator Distribution](#validator-distribution) * [Delegation Distribution](#delegation-distribution) * [Params](#params) @@ -129,14 +128,9 @@ count is decremented. If the reference count hits zero, the historical record is ### FeePool -All globally tracked parameters for distribution are stored within -`FeePool`. Rewards are collected and added to the reward pool and -distributed to validators/delegators from here. +The `FeePool` is used to store decimal rewards to allow for fractions of coins to be received from operations like inflation. -Note that the reward pool holds decimal coins (`DecCoins`) to allow -for fractions of coins to be received from operations like inflation. -When coins are distributed from the pool they are truncated back to -`sdk.Coins` which are non-decimal. +Once those rewards are big enough, they are sent as `sdk.Coins` to the community pool. * FeePool: `0x00 -> ProtocolBuffer(FeePool)` @@ -150,10 +144,6 @@ type DecCoin struct { } ``` -```protobuf reference -https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/distribution/v1beta1/distribution.proto#L116-L123 -``` - ### Validator Distribution Validator distribution information for the relevant validator is updated each time: @@ -218,12 +208,12 @@ inflationary rewards to the stake. All fees are collected in a specific module account during the block. During `BeginBlock`, they are sent to the `"distribution"` `ModuleAccount`. No other sending of tokens occurs. Instead, the rewards each account is entitled to are stored, and withdrawals can be triggered -through the messages `FundCommunityPool`, `WithdrawValidatorCommission` and +through the messages `WithdrawValidatorCommission` and `WithdrawDelegatorReward`. #### Reward to the Community Pool -The community pool gets `community_tax * fees`, plus any remaining dust after +The community pool (x/protocolpool) gets `community_tax * fees`, plus any remaining dust after validators get their rewards that are always rounded down to the nearest integer value. @@ -287,15 +277,15 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/distribution/ ```go func (k Keeper) SetWithdrawAddr(ctx context.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error - if k.blockedAddrs[withdrawAddr.String()] { - fail with "`{withdrawAddr}` is not allowed to receive external funds" - } + if k.blockedAddrs[withdrawAddr.String()] { + fail with "`{withdrawAddr}` is not allowed to receive external funds" + } - if !k.GetWithdrawAddrEnabled(ctx) { - fail with `ErrSetWithdrawAddrDisabled` - } + if !k.GetWithdrawAddrEnabled(ctx) { + fail with `ErrSetWithdrawAddrDisabled` + } - k.SetDelegatorWithdrawAddr(ctx, delegatorAddr, withdrawAddr) + k.SetDelegatorWithdrawAddr(ctx, delegatorAddr, withdrawAddr) ``` ### MsgWithdrawDelegatorReward @@ -344,33 +334,6 @@ The commission is calculated in every block during `BeginBlock`, so no iteration The amount withdrawn is deducted from the `ValidatorOutstandingRewards` variable for the validator. Only integer amounts can be sent. If the accumulated awards have decimals, the amount is truncated before the withdrawal is sent, and the remainder is left to be withdrawn later. -### FundCommunityPool - -This message sends coins directly from the sender to the community pool. - -The transaction fails if the amount cannot be transferred from the sender to the distribution module account. - -```go -func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error { - if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount); err != nil { - return err - } - - feePool, err := k.FeePool.Get(ctx) - if err != nil { - return err - } - - feePool.CommunityPool = feePool.CommunityPool.Add(sdk.NewDecCoinsFromCoins(amount...)...) - - if err := k.FeePool.Set(ctx, feePool); err != nil { - return err - } - - return nil -} -``` - ### Common distribution operations These operations take place during many different messages. @@ -386,17 +349,17 @@ func (k Keeper) initializeDelegation(ctx context.Context, val sdk.ValAddress, de // period has already been incremented - we want to store the period ended by this delegation action previousPeriod := k.GetValidatorCurrentRewards(ctx, val).Period - 1 - // increment reference count for the period we're going to track - k.incrementReferenceCount(ctx, val, previousPeriod) + // increment reference count for the period we're going to track + k.incrementReferenceCount(ctx, val, previousPeriod) - validator := k.stakingKeeper.Validator(ctx, val) - delegation := k.stakingKeeper.Delegation(ctx, del, val) + validator := k.stakingKeeper.Validator(ctx, val) + delegation := k.stakingKeeper.Delegation(ctx, del, val) - // calculate delegation stake in tokens - // we don't store directly, so multiply delegation shares * (tokens per share) - // note: necessary to truncate so we don't allow withdrawing more rewards than owed - stake := validator.TokensFromSharesTruncated(delegation.GetShares()) - k.SetDelegatorStartingInfo(ctx, val, del, types.NewDelegatorStartingInfo(previousPeriod, stake, uint64(ctx.BlockHeight()))) + // calculate delegation stake in tokens + // we don't store directly, so multiply delegation shares * (tokens per share) + // note: necessary to truncate so we don't allow withdrawing more rewards than owed + stake := validator.TokensFromSharesTruncated(delegation.GetShares()) + k.SetDelegatorStartingInfo(ctx, val, del, types.NewDelegatorStartingInfo(previousPeriod, stake, uint64(ctx.BlockHeight()))) } ``` @@ -452,7 +415,7 @@ By default, all values are set to a `0`, except period, which is set to `1`. * triggered-by: `staking.RemoveValidator` Outstanding commission is sent to the validator's self-delegation withdrawal address. -Remaining delegator rewards get sent to the community fee pool. +Remaining delegator rewards get sent to the community pool. Note: The validator gets removed only when it has no remaining delegations. At that time, all outstanding delegator rewards will have been withdrawn. @@ -525,13 +488,12 @@ The distribution module contains the following parameters: * `baseproposerreward` and `bonusproposerreward` were parameters that are deprecated in v0.47 and are not used. :::note -The reserve pool is the pool of collected funds for use by governance taken via the `CommunityTax`. -Currently with the Cosmos SDK, tokens collected by the CommunityTax are accounted for but unspendable. +The community tax is collected and sent to the community pool (x/protocolpool). ::: ## Client -## CLI +### CLI A user can query and interact with the `distribution` module using the CLI. @@ -565,28 +527,6 @@ commission: denom: stake ``` -##### community-pool - -The `community-pool` command allows users to query all coin balances within the community pool. - -```shell -simd query distribution community-pool [flags] -``` - -Example: - -```shell -simd query distribution community-pool -``` - -Example Output: - -```yml -pool: -- amount: "1000000.000000000000000000" - denom: stake -``` - ##### params The `params` command allows users to query the parameters of the `distribution` module. @@ -688,7 +628,7 @@ rewards: The `validator-distribution-info` command allows users to query validator commission and self-delegation rewards for validator. -````shell +```shell simd query distribution validator-distribution-info cosmosvaloper1... ``` @@ -712,20 +652,6 @@ The `tx` commands allow users to interact with the `distribution` module. simd tx distribution --help ``` -##### fund-community-pool - -The `fund-community-pool` command allows users to send funds to the community pool. - -```shell -simd tx distribution fund-community-pool [amount] [flags] -``` - -Example: - -```shell -simd tx distribution fund-community-pool 100stake --from cosmos1... -``` - ##### set-withdraw-addr The `set-withdraw-addr` command allows users to set the withdraw address for rewards associated with a delegator address. @@ -1022,28 +948,3 @@ Example Output: "withdrawAddress": "cosmos1..." } ``` - -#### CommunityPool - -The `CommunityPool` endpoint allows users to query the community pool coins. - -Example: - -```shell -grpcurl -plaintext \ - localhost:9090 \ - cosmos.distribution.v1beta1.Query/CommunityPool -``` - -Example Output: - -```json -{ - "pool": [ - { - "denom": "stake", - "amount": "1000000000000000000" - } - ] -} -``` diff --git a/x/distribution/go.mod b/x/distribution/go.mod index c945881ae6..70db48d98d 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -32,6 +32,8 @@ require ( gotest.tools/v3 v3.5.1 ) +require golang.org/x/sync v0.5.0 // indirect + require ( cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/tx v0.12.0 // indirect @@ -145,7 +147,6 @@ require ( golang.org/x/crypto v0.16.0 // indirect golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect golang.org/x/net v0.19.0 // indirect - golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/x/distribution/abci.go b/x/distribution/keeper/abci.go similarity index 78% rename from x/distribution/abci.go rename to x/distribution/keeper/abci.go index 85d6bf769d..d4db46c609 100644 --- a/x/distribution/abci.go +++ b/x/distribution/keeper/abci.go @@ -1,9 +1,8 @@ -package distribution +package keeper import ( "time" - "cosmossdk.io/x/distribution/keeper" "cosmossdk.io/x/distribution/types" "github.com/cosmos/cosmos-sdk/telemetry" @@ -12,7 +11,7 @@ import ( // BeginBlocker sets the proposer for determining distribution during endblock // and distribute rewards for the previous block. -func BeginBlocker(ctx sdk.Context, k keeper.Keeper) error { +func (k Keeper) BeginBlocker(ctx sdk.Context) error { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) // determine the total power signing the block @@ -27,6 +26,13 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) error { if err := k.AllocateTokens(ctx, previousTotalPower, ctx.CometInfo().LastCommit.Votes); err != nil { return err } + + // every 1000 blocks send whole coins from decimal pool to community pool + if ctx.BlockHeight()%1000 == 0 { + if err := k.sendDecimalPoolToCommunityPool(ctx); err != nil { + return err + } + } } // record the proposer for when we payout on the next block diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index a3eb1cdd3b..0d798b593b 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -24,21 +24,19 @@ func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bo feesCollected := sdk.NewDecCoinsFromCoins(feesCollectedInt...) // transfer collected fees to the distribution module account - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, types.ModuleName, feesCollectedInt) - if err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, k.feeCollectorName, types.ModuleName, feesCollectedInt); err != nil { return err } - // temporary workaround to keep CanWithdrawInvariant happy - // general discussions here: https://github.com/cosmos/cosmos-sdk/issues/2906#issuecomment-441867634 feePool, err := k.FeePool.Get(ctx) if err != nil { return err } if totalPreviousPower == 0 { - feePool.CommunityPool = feePool.CommunityPool.Add(feesCollected...) - return k.FeePool.Set(ctx, feePool) + if err := k.FeePool.Set(ctx, types.FeePool{DecimalPool: feePool.DecimalPool.Add(feesCollected...)}); err != nil { + return err + } } // calculate fraction allocated to validators @@ -69,17 +67,23 @@ func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bo powerFraction := math.LegacyNewDec(vote.Validator.Power).QuoTruncate(math.LegacyNewDec(totalPreviousPower)) reward := feeMultiplier.MulDecTruncate(powerFraction) - err = k.AllocateTokensToValidator(ctx, validator, reward) - if err != nil { + if err = k.AllocateTokensToValidator(ctx, validator, reward); err != nil { return err } remaining = remaining.Sub(reward) } + // send to community pool and set remainder in fee pool + amt, re := remaining.TruncateDecimal() + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { + return err + } - // allocate community funding - feePool.CommunityPool = feePool.CommunityPool.Add(remaining...) - return k.FeePool.Set(ctx, feePool) + if err := k.FeePool.Set(ctx, types.FeePool{DecimalPool: feePool.DecimalPool.Add(re...)}); err != nil { + return err + } + + return nil } // AllocateTokensToValidator allocate tokens to a particular validator, @@ -144,3 +148,23 @@ func (k Keeper) AllocateTokensToValidator(ctx context.Context, val stakingtypes. outstanding.Rewards = outstanding.Rewards.Add(tokens...) return k.ValidatorOutstandingRewards.Set(ctx, valBz, outstanding) } + +// sendDecimalPoolToCommunityPool sends the decimal pool to the community pool +// Any remainer stays in the decimal pool +func (k Keeper) sendDecimalPoolToCommunityPool(ctx context.Context) error { + feePool, err := k.FeePool.Get(ctx) + if err != nil { + return err + } + + if feePool.DecimalPool.IsZero() { + return nil + } + + amt, re := feePool.DecimalPool.TruncateDecimal() + if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ProtocolPoolModuleName, amt); err != nil { + return err + } + + return k.FeePool.Set(ctx, types.FeePool{DecimalPool: re}) +} diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 3b3a4dd9d1..e88f9df2ac 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -150,7 +150,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { feePool, err := distrKeeper.FeePool.Get(ctx) require.NoError(t, err) - require.True(t, feePool.CommunityPool.IsZero()) + require.True(t, feePool.DecimalPool.IsZero()) _, err = distrKeeper.ValidatorsAccumulatedCommission.Get(ctx, valAddr0) require.ErrorIs(t, err, collections.ErrNotFound) @@ -168,6 +168,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, sdk.Coins{{Denom: sdk.DefaultBondDenom, Amount: math.NewInt(2)}}) // 2 community pool coins votes := []comet.VoteInfo{ { @@ -189,10 +190,9 @@ func TestAllocateTokensToManyValidators(t *testing.T) { require.NoError(t, err) require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: math.LegacyNewDecWithPrec(490, 1)}}, val1OutstandingRewards.Rewards) - // 2 community pool coins feePool, err = distrKeeper.FeePool.Get(ctx) require.NoError(t, err) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: math.LegacyNewDec(2)}}, feePool.CommunityPool) + require.True(t, feePool.DecimalPool.IsZero()) // 50% commission for first proposer, (0.5 * 98%) * 100 / 2 = 23.25 val0Commission, err := distrKeeper.ValidatorsAccumulatedCommission.Get(ctx, valAddr0) @@ -291,7 +291,7 @@ func TestAllocateTokensTruncation(t *testing.T) { feePool, err := distrKeeper.FeePool.Get(ctx) require.NoError(t, err) - require.True(t, feePool.CommunityPool.IsZero()) + require.True(t, feePool.DecimalPool.IsZero()) _, err = distrKeeper.ValidatorsAccumulatedCommission.Get(ctx, valAddr0) require.ErrorIs(t, err, collections.ErrNotFound) @@ -309,6 +309,7 @@ func TestAllocateTokensTruncation(t *testing.T) { fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(634195840))) bankKeeper.EXPECT().GetAllBalances(gomock.Any(), feeCollectorAcc.GetAddress()).Return(fees) bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), "fee_collector", disttypes.ModuleName, fees) + bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), disttypes.ModuleName, disttypes.ProtocolPoolModuleName, gomock.Any()) // something is sent to community pool votes := []comet.VoteInfo{ { diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index a107f35d7c..ec40d025cc 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -248,7 +248,7 @@ func (k Keeper) withdrawDelegationRewards(ctx context.Context, val stakingtypes. ) } - // truncate reward dec coins, return remainder to community pool + // truncate reward dec coins, return remainder to decimal pool finalRewards, remainder := rewards.TruncateDecimal() // add coins to user account @@ -264,10 +264,8 @@ func (k Keeper) withdrawDelegationRewards(ctx context.Context, val stakingtypes. } } - // update the outstanding rewards and the community pool only if the - // transaction was successful - err = k.ValidatorOutstandingRewards.Set(ctx, sdk.ValAddress(valAddr), types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(rewards)}) - if err != nil { + // update the outstanding rewards and the decimal pool only if the transaction was successful + if err := k.ValidatorOutstandingRewards.Set(ctx, sdk.ValAddress(valAddr), types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(rewards)}); err != nil { return nil, err } @@ -276,7 +274,7 @@ func (k Keeper) withdrawDelegationRewards(ctx context.Context, val stakingtypes. return nil, err } - feePool.CommunityPool = feePool.CommunityPool.Add(remainder...) + feePool.DecimalPool = feePool.DecimalPool.Add(remainder...) err = k.FeePool.Set(ctx, feePool) if err != nil { return nil, err diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go index 10a733c51d..2abc164561 100644 --- a/x/distribution/keeper/genesis.go +++ b/x/distribution/keeper/genesis.go @@ -14,8 +14,7 @@ import ( func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) { var moduleHoldings sdk.DecCoins - err := k.FeePool.Set(ctx, data.FeePool) - if err != nil { + if err := k.FeePool.Set(ctx, data.FeePool); err != nil { panic(err) } @@ -47,7 +46,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) { } } - if err = k.PreviousProposer.Set(ctx, previousProposer); err != nil { + if err := k.PreviousProposer.Set(ctx, previousProposer); err != nil { panic(err) } @@ -128,7 +127,7 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) { } } - moduleHoldings = moduleHoldings.Add(data.FeePool.CommunityPool...) + moduleHoldings = moduleHoldings.Add(data.FeePool.DecimalPool...) moduleHoldingsInt, _ := moduleHoldings.TruncateDecimal() // check if the module account exists diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index 6a819fc885..924744f903 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -56,13 +56,13 @@ func (h Hooks) AfterValidatorRemoved(ctx context.Context, _ sdk.ConsAddress, val // split into integral & remainder coins, remainder := commission.TruncateDecimal() - // remainder to community pool + // remainder to decimal pool feePool, err := h.k.FeePool.Get(ctx) if err != nil { return err } - feePool.CommunityPool = feePool.CommunityPool.Add(remainder...) + feePool.DecimalPool = feePool.DecimalPool.Add(remainder...) err = h.k.FeePool.Set(ctx, feePool) if err != nil { return err @@ -82,15 +82,15 @@ func (h Hooks) AfterValidatorRemoved(ctx context.Context, _ sdk.ConsAddress, val } } - // Add outstanding to community pool + // Add outstanding to decimal pool // The validator is removed only after it has no more delegations. - // This operation sends only the remaining dust to the community pool. + // This operation sends only the remaining dust to the decimal pool. feePool, err := h.k.FeePool.Get(ctx) if err != nil { return err } - feePool.CommunityPool = feePool.CommunityPool.Add(outstanding...) + feePool.DecimalPool = feePool.DecimalPool.Add(outstanding...) err = h.k.FeePool.Set(ctx, feePool) if err != nil { return err diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go index fd11bc60a9..9384d48297 100644 --- a/x/distribution/keeper/invariants.go +++ b/x/distribution/keeper/invariants.go @@ -196,16 +196,9 @@ func ModuleAccountInvariant(k Keeper) sdk.Invariant { return sdk.FormatInvariant(types.ModuleName, "module account coins", err.Error()), true } - communityPool, err := k.FeePool.Get(ctx) - if err != nil { - panic(err) - } - - expectedInt, _ := expectedCoins.Add(communityPool.CommunityPool...).TruncateDecimal() - - macc := k.GetDistributionAccount(ctx) - balances := k.bankKeeper.GetAllBalances(ctx, macc.GetAddress()) + expectedInt, _ := expectedCoins.TruncateDecimal() + balances := k.bankKeeper.GetAllBalances(ctx, k.GetDistributionAccount(ctx).GetAddress()) broken := !balances.Equal(expectedInt) return sdk.FormatInvariant( types.ModuleName, "ModuleAccount coins", diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 7be7e2b4b9..1b018349b8 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -25,14 +25,16 @@ type Keeper struct { authKeeper types.AccountKeeper bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper - poolKeeper types.PoolKeeper // TODO: Needs to be removed in v0.53 + poolKeeper types.PoolKeeper // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. authority string - Schema collections.Schema - Params collections.Item[types.Params] + Schema collections.Schema + Params collections.Item[types.Params] + // FeePool stores decimal tokens that cannot be yet distributed. + // In the past it held the community pool, but it has been replaced by x/protocolpool. FeePool collections.Item[types.FeePool] // DelegatorsWithdrawAddress key: delAddr | value: withdrawAddr DelegatorsWithdrawAddress collections.Map[sdk.AccAddress, sdk.AccAddress] diff --git a/x/distribution/keeper/migrations.go b/x/distribution/keeper/migrations.go index 6c7719711b..4152a9a6fa 100644 --- a/x/distribution/keeper/migrations.go +++ b/x/distribution/keeper/migrations.go @@ -1,10 +1,8 @@ package keeper import ( - "cosmossdk.io/x/distribution/migrations/funds" v4 "cosmossdk.io/x/distribution/migrations/v4" "cosmossdk.io/x/distribution/types" - pooltypes "cosmossdk.io/x/protocolpool/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -32,22 +30,30 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { return nil } +// Migrate3to4 migrates the x/distribution module state to use collections +// Additionally it migrates distribution fee pool to use protocol pool module account func (m Migrator) Migrate3to4(ctx sdk.Context) error { - return v4.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc) + if err := v4.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc); err != nil { + return err + } + + return m.migrateFunds(ctx) } -func (m Migrator) MigrateFundsToPool(ctx sdk.Context) error { +func (m Migrator) migrateFunds(ctx sdk.Context) error { macc := m.keeper.GetDistributionAccount(ctx) - poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, pooltypes.ModuleName) + poolMacc := m.keeper.authKeeper.GetModuleAccount(ctx, types.ProtocolPoolModuleName) feePool, err := m.keeper.FeePool.Get(ctx) if err != nil { return err } - err = funds.MigrateFunds(ctx, m.keeper.bankKeeper, feePool, macc, poolMacc) + + feePool, err = v4.MigrateFunds(ctx, m.keeper.bankKeeper, feePool, macc, poolMacc) if err != nil { return err } - // return FeePool as empty (since FeePool funds are migrated to pool module account) - return m.keeper.FeePool.Set(ctx, types.FeePool{}) + + // the feePool has now an empty community pool and the remainder is stored in the DecimalPool + return m.keeper.FeePool.Set(ctx, feePool) } diff --git a/x/distribution/keeper/msg_server.go b/x/distribution/keeper/msg_server.go index d92b619a09..48282e0f9e 100644 --- a/x/distribution/keeper/msg_server.go +++ b/x/distribution/keeper/msg_server.go @@ -158,7 +158,7 @@ func (k msgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni return nil, fmt.Errorf("invalid recipient address: %w", err) } - if err := k.poolKeeper.DistributeFromFeePool(ctx, msg.Amount, recipient); err != nil { + if err := k.poolKeeper.DistributeFromCommunityPool(ctx, msg.Amount, recipient); err != nil { return nil, err } diff --git a/x/distribution/keeper/msg_server_test.go b/x/distribution/keeper/msg_server_test.go index 19441a97f0..a4aa0f97d0 100644 --- a/x/distribution/keeper/msg_server_test.go +++ b/x/distribution/keeper/msg_server_test.go @@ -259,7 +259,7 @@ func TestMsgUpdateParams(t *testing.T) { func TestMsgCommunityPoolSpend(t *testing.T) { ctx, addrs, distrKeeper, dep := initFixture(t) - dep.poolKeeper.EXPECT().DistributeFromFeePool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() + dep.poolKeeper.EXPECT().DistributeFromCommunityPool(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() msgServer := keeper.NewMsgServerImpl(distrKeeper) cases := []struct { diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index f07ff12705..995f3e6d69 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -61,7 +61,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx context.Context, val stakingtypes.V if val.GetTokens().IsZero() { // can't calculate ratio for zero-token validators - // ergo we instead add to the community pool + // ergo we instead add to the decimal pool feePool, err := k.FeePool.Get(ctx) if err != nil { return 0, err @@ -72,7 +72,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx context.Context, val stakingtypes.V return 0, err } - feePool.CommunityPool = feePool.CommunityPool.Add(rewards.Rewards...) + feePool.DecimalPool = feePool.DecimalPool.Add(rewards.Rewards...) outstanding.Rewards = outstanding.GetRewards().Sub(rewards.Rewards) err = k.FeePool.Set(ctx, feePool) if err != nil { diff --git a/x/distribution/migrations/funds/migrate.go b/x/distribution/migrations/v4/migrate_funds.go similarity index 52% rename from x/distribution/migrations/funds/migrate.go rename to x/distribution/migrations/v4/migrate_funds.go index 73688e6ffb..bf2df7c822 100644 --- a/x/distribution/migrations/funds/migrate.go +++ b/x/distribution/migrations/v4/migrate_funds.go @@ -1,4 +1,4 @@ -package funds +package v4 import ( "fmt" @@ -9,23 +9,24 @@ import ( ) // MigrateFunds migrates the distribution module funds to pool module -func MigrateFunds(ctx sdk.Context, bankKeeper types.BankKeeper, feePool types.FeePool, macc, poolMacc sdk.ModuleAccountI) error { - poolBal := sdk.NormalizeCoins(feePool.CommunityPool) +func MigrateFunds(ctx sdk.Context, bankKeeper types.BankKeeper, feePool types.FeePool, macc, poolMacc sdk.ModuleAccountI) (types.FeePool, error) { + poolBal, remainder := feePool.CommunityPool.TruncateDecimal() + distrbalances := bankKeeper.GetAllBalances(ctx, macc.GetAddress()) if distrbalances.IsZero() || distrbalances.IsAllLT(poolBal) { - return fmt.Errorf("%s module account balance is less than FeePool balance", macc.GetName()) + return types.FeePool{}, fmt.Errorf("%s module account balance is less than FeePool balance", macc.GetName()) } // transfer feepool funds from the distribution module account to pool module account - err := bankKeeper.SendCoinsFromModuleToModule(ctx, macc.GetName(), poolMacc.GetName(), poolBal) - if err != nil { - return err + if err := bankKeeper.SendCoinsFromModuleToModule(ctx, macc.GetName(), poolMacc.GetName(), poolBal); err != nil { + return types.FeePool{}, err } // check the migrated balance from pool module account is same as fee pool balance balances := bankKeeper.GetAllBalances(ctx, poolMacc.GetAddress()) if !balances.Equal(poolBal) { - return fmt.Errorf("pool module account balance is not same as FeePool balance after migration") + return types.FeePool{}, fmt.Errorf("pool module account balance is not same as FeePool balance after migration") } - return nil + + return types.FeePool{DecimalPool: remainder}, nil } diff --git a/x/distribution/migrations/funds/migrate_test.go b/x/distribution/migrations/v4/migrate_funds_test.go similarity index 96% rename from x/distribution/migrations/funds/migrate_test.go rename to x/distribution/migrations/v4/migrate_funds_test.go index 1ba5d0ea00..74e4647e76 100644 --- a/x/distribution/migrations/funds/migrate_test.go +++ b/x/distribution/migrations/v4/migrate_funds_test.go @@ -1,4 +1,4 @@ -package funds_test +package v4_test import ( "testing" @@ -16,7 +16,7 @@ import ( banktypes "cosmossdk.io/x/bank/types" "cosmossdk.io/x/distribution" "cosmossdk.io/x/distribution/keeper" - "cosmossdk.io/x/distribution/migrations/funds" + v4 "cosmossdk.io/x/distribution/migrations/v4" distrtestutil "cosmossdk.io/x/distribution/testutil" disttypes "cosmossdk.io/x/distribution/types" pooltypes "cosmossdk.io/x/protocolpool/types" @@ -100,8 +100,8 @@ func TestFundsMigration(t *testing.T) { // Set pool module account poolAcc := authtypes.NewEmptyModuleAccount(pooltypes.ModuleName) - // migrate feepool funds from distribution module account to pool module accout - err = funds.MigrateFunds(ctx, bankKeeper, feepool, distrAcc, poolAcc) + // migrate feepool funds from distribution module account to pool module account + _, err = v4.MigrateFunds(ctx, bankKeeper, feepool, distrAcc, poolAcc) require.NoError(t, err) // set distrbution feepool as empty (since migration) diff --git a/x/distribution/module.go b/x/distribution/module.go index 97a501b908..caa441ee2c 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -28,7 +28,7 @@ import ( ) // ConsensusVersion defines the current x/distribution module consensus version. -const ConsensusVersion = 5 +const ConsensusVersion = 4 var ( _ module.AppModuleBasic = AppModule{} @@ -143,10 +143,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err)) } - - if err := cfg.RegisterMigration(types.ModuleName, 4, m.MigrateFundsToPool); err != nil { - panic(fmt.Sprintf("failed to migrate funds from x/%s to x/protocolpool module", types.ModuleName)) - } } // InitGenesis performs genesis initialization for the distribution module. It returns @@ -170,7 +166,7 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // BeginBlock returns the begin blocker for the distribution module. func (am AppModule) BeginBlock(ctx context.Context) error { c := sdk.UnwrapSDKContext(ctx) - return BeginBlocker(c, am.keeper) + return am.keeper.BeginBlocker(c) } // AppModuleSimulation functions diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 10f97a8378..fdd35a28ef 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -31,7 +31,7 @@ func TestDecodeDistributionStore(t *testing.T) { decCoins := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyOneDec())} feePool := types.InitialFeePool() - feePool.CommunityPool = decCoins + feePool.DecimalPool = decCoins slashEvent := types.NewValidatorSlashEvent(10, math.LegacyOneDec()) kvPairs := kv.Pairs{ diff --git a/x/distribution/testutil/expected_keepers_mocks.go b/x/distribution/testutil/expected_keepers_mocks.go index f57b9aca57..8cc11554bb 100644 --- a/x/distribution/testutil/expected_keepers_mocks.go +++ b/x/distribution/testutil/expected_keepers_mocks.go @@ -249,18 +249,18 @@ func (m *MockPoolKeeper) EXPECT() *MockPoolKeeperMockRecorder { return m.recorder } -// DistributeFromFeePool mocks base method. -func (m *MockPoolKeeper) DistributeFromFeePool(ctx context.Context, amount types0.Coins, receiveAddr types0.AccAddress) error { +// DistributeFromCommunityPool mocks base method. +func (m *MockPoolKeeper) DistributeFromCommunityPool(ctx context.Context, amount types0.Coins, receiveAddr types0.AccAddress) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DistributeFromFeePool", ctx, amount, receiveAddr) + ret := m.ctrl.Call(m, "DistributeFromCommunityPool", ctx, amount, receiveAddr) ret0, _ := ret[0].(error) return ret0 } -// DistributeFromFeePool indicates an expected call of DistributeFromFeePool. -func (mr *MockPoolKeeperMockRecorder) DistributeFromFeePool(ctx, amount, receiveAddr interface{}) *gomock.Call { +// DistributeFromCommunityPool indicates an expected call of DistributeFromCommunityPool. +func (mr *MockPoolKeeperMockRecorder) DistributeFromCommunityPool(ctx, amount, receiveAddr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DistributeFromFeePool", reflect.TypeOf((*MockPoolKeeper)(nil).DistributeFromFeePool), ctx, amount, receiveAddr) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DistributeFromCommunityPool", reflect.TypeOf((*MockPoolKeeper)(nil).DistributeFromCommunityPool), ctx, amount, receiveAddr) } // FundCommunityPool mocks base method. diff --git a/x/distribution/types/distribution.pb.go b/x/distribution/types/distribution.pb.go index 8fcd62b9ba..5e072e0ed0 100644 --- a/x/distribution/types/distribution.pb.go +++ b/x/distribution/types/distribution.pb.go @@ -387,8 +387,10 @@ func (m *ValidatorSlashEvents) GetValidatorSlashEvents() []ValidatorSlashEvent { } // FeePool is the global fee pool for distribution. +// It holds decimal coins. Once whole those coins can be burned or distributed to the community pool. type FeePool struct { - CommunityPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"community_pool"` + CommunityPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"community_pool"` // Deprecated: Do not use. + DecimalPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=decimal_pool,json=decimalPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"decimal_pool"` } func (m *FeePool) Reset() { *m = FeePool{} } @@ -424,6 +426,7 @@ func (m *FeePool) XXX_DiscardUnknown() { var xxx_messageInfo_FeePool proto.InternalMessageInfo +// Deprecated: Do not use. func (m *FeePool) GetCommunityPool() github_com_cosmos_cosmos_sdk_types.DecCoins { if m != nil { return m.CommunityPool @@ -431,6 +434,13 @@ func (m *FeePool) GetCommunityPool() github_com_cosmos_cosmos_sdk_types.DecCoins return nil } +func (m *FeePool) GetDecimalPool() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.DecimalPool + } + return nil +} + // CommunityPoolSpendProposal details a proposal for use of community funds, // together with how many coins are proposed to be spent, and to which // recipient account. @@ -647,71 +657,73 @@ func init() { } var fileDescriptor_cd78a31ea281a992 = []byte{ - // 1015 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xc1, 0x6f, 0x1b, 0xc5, - 0x17, 0xf6, 0x34, 0x89, 0xd3, 0x4c, 0xdb, 0xe4, 0xd7, 0x89, 0x93, 0x3a, 0x6e, 0x7f, 0xb6, 0xbb, - 0xa2, 0xc2, 0x04, 0x62, 0x93, 0x22, 0x21, 0x94, 0x0b, 0x6a, 0xec, 0x56, 0x20, 0x15, 0x88, 0x36, - 0x08, 0x24, 0x38, 0xac, 0xc6, 0xbb, 0x13, 0x7b, 0xc8, 0xee, 0xcc, 0x32, 0x33, 0x76, 0x92, 0x03, - 0xf7, 0xc0, 0x01, 0xb8, 0x81, 0x7a, 0xaa, 0xe0, 0x52, 0x71, 0xca, 0x21, 0x7f, 0x44, 0xc5, 0xa9, - 0xaa, 0x00, 0x21, 0x0e, 0x01, 0x92, 0x43, 0x10, 0x7f, 0x05, 0x9a, 0x9d, 0xf1, 0xae, 0x13, 0x02, - 0x2a, 0x45, 0x16, 0x97, 0x28, 0xf3, 0xde, 0xec, 0xfb, 0xbe, 0xef, 0xcd, 0x37, 0x6f, 0x0c, 0xeb, - 0x3e, 0x97, 0x11, 0x97, 0x8d, 0x80, 0x4a, 0x25, 0x68, 0xbb, 0xa7, 0x28, 0x67, 0x8d, 0xfe, 0x72, - 0x9b, 0x28, 0xbc, 0x7c, 0x22, 0x58, 0x8f, 0x05, 0x57, 0x1c, 0x5d, 0x35, 0xfb, 0xeb, 0x27, 0x52, - 0x76, 0x7f, 0xa9, 0xd0, 0xe1, 0x1d, 0x9e, 0xec, 0x6b, 0xe8, 0xff, 0xcc, 0x27, 0xa5, 0xb2, 0x85, - 0x68, 0x63, 0x49, 0xd2, 0xd2, 0x3e, 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0x16, 0xab, 0x06, 0x60, - 0x49, 0x06, 0x9b, 0x8d, 0xed, 0x93, 0x8e, 0x31, 0x27, 0xe2, 0xfc, 0x00, 0x60, 0xe9, 0x1d, 0x1c, - 0xd2, 0x00, 0x2b, 0x2e, 0x5e, 0xa3, 0x52, 0x71, 0x41, 0x7d, 0x1c, 0x1a, 0x60, 0x89, 0x3e, 0x05, - 0xf0, 0x8a, 0xdf, 0x8b, 0x7a, 0x21, 0x56, 0xb4, 0x4f, 0xac, 0x48, 0x4f, 0x60, 0x45, 0x79, 0x11, - 0x54, 0xc7, 0x6a, 0x17, 0x6e, 0x5e, 0xb3, 0x7e, 0xac, 0xeb, 0x2e, 0x0d, 0x7c, 0xa5, 0x15, 0x35, - 0x39, 0x65, 0xa6, 0x11, 0xdf, 0xfc, 0x5c, 0x79, 0xbe, 0x43, 0x55, 0xb7, 0xd7, 0xae, 0xfb, 0x3c, - 0xb2, 0x7e, 0x69, 0x0c, 0x51, 0x53, 0x3b, 0x31, 0x91, 0x83, 0x6f, 0xa4, 0x39, 0xdb, 0xb9, 0x0c, - 0xd6, 0x90, 0x71, 0x35, 0x28, 0x7a, 0x16, 0xce, 0x08, 0xb2, 0x41, 0x04, 0x61, 0x3e, 0xf1, 0x7c, - 0xde, 0x63, 0x2a, 0x39, 0xdf, 0x4b, 0xee, 0x74, 0x1a, 0x6e, 0xea, 0xa8, 0xf3, 0x35, 0x80, 0x57, - 0x52, 0x61, 0xcd, 0x9e, 0x10, 0x84, 0xa9, 0x81, 0xaa, 0x18, 0x4e, 0x1a, 0x25, 0x72, 0xc4, 0x22, - 0x06, 0x30, 0x68, 0x1e, 0xe6, 0x63, 0x22, 0x28, 0x37, 0x6e, 0x1c, 0x77, 0xed, 0xca, 0xf9, 0x12, - 0xc0, 0x72, 0xca, 0xf2, 0x96, 0x6f, 0x35, 0x93, 0xa0, 0xc9, 0xa3, 0x88, 0x4a, 0x49, 0x39, 0x43, - 0x7d, 0x08, 0xfd, 0x74, 0x35,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xec, 0x6e, 0xdb, 0x38, 0x62, 0x30, 0x9f, 0x3e, 0xed, 0xa3, 0x74, 0xb5, 0x45, 0x59, 0x19, - 0xd7, 0xc7, 0xeb, 0x7c, 0x0f, 0xe0, 0x8d, 0xbf, 0x36, 0xf5, 0xbb, 0x54, 0x75, 0x5b, 0x24, 0xe6, - 0x92, 0xaa, 0x11, 0xf9, 0x7b, 0x7e, 0xc8, 0xdf, 0x3a, 0x65, 0x57, 0xa8, 0x08, 0x27, 0x03, 0x03, - 0x5c, 0x9c, 0x48, 0x12, 0x83, 0xe5, 0xca, 0x33, 0xbb, 0x4f, 0x60, 0xc9, 0xd5, 0x57, 0x1f, 0x1c, - 0x96, 0xc1, 0xc3, 0xc3, 0x32, 0x78, 0x74, 0x58, 0x06, 0xbf, 0x1c, 0x96, 0xc1, 0xe7, 0x47, 0xe5, - 0xdc, 0xa3, 0xa3, 0x72, 0xee, 0xc7, 0xa3, 0x72, 0xee, 0xbd, 0xeb, 0x27, 0x6c, 0x75, 0xea, 0x37, - 0x44, 0xd2, 0xb4, 0x76, 0x3e, 0xf9, 0x99, 0xf7, 0xd2, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x10, - 0x1e, 0x8d, 0x91, 0x99, 0x0a, 0x00, 0x00, + // 1044 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xe4, 0x87, 0xd3, 0x4c, 0xd2, 0x84, 0x4e, 0x7e, 0xd4, 0x71, 0x8b, 0x9d, 0xae, 0xa8, + 0x08, 0x81, 0xd8, 0xa4, 0x95, 0x10, 0xf2, 0x05, 0x35, 0x76, 0x2b, 0x90, 0x0a, 0x44, 0x1b, 0x04, + 0x12, 0x1c, 0x56, 0xe3, 0xdd, 0x89, 0x3d, 0x64, 0x77, 0x66, 0x99, 0x19, 0x3b, 0xc9, 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3, 0xac, 0xf8, 0x3c, + 0xb2, 0xf5, 0x52, 0xed, 0xa3, 0xa6, 0xb6, 0x63, 0x22, 0x7b, 0xdf, 0x48, 0x73, 0xb6, 0x33, 0x19, + 0xac, 0x21, 0xe3, 0x6a, 0x50, 0xf4, 0x3c, 0x9c, 0x14, 0x64, 0x9d, 0x08, 0xc2, 0x7c, 0xe2, 0xf9, + 0xbc, 0xc3, 0x54, 0x72, 0xbe, 0x17, 0xdd, 0x89, 0xd4, 0x5c, 0xd7, 0x56, 0xe7, 0x5b, 0x00, 0x2f, + 0xa7, 0xc2, 0xea, 0x1d, 0x21, 0x08, 0x53, 0x3d, 0x55, 0x31, 0x1c, 0x31, 0x4a, 0xe4, 0x39, 0x8b, + 0xe8, 0xc1, 0xa0, 0x59, 0x98, 0x8f, 0x89, 0xa0, 0xdc, 0x54, 0xe3, 0x90, 0x6b, 0x57, 0xce, 0xd7, + 0x00, 0x96, 0x52, 0x96, 0xb7, 0x7c, 0xab, 0x99, 0x04, 0x75, 0x1e, 0x45, 0x54, 0x4a, 0xca, 0x19, + 0xea, 0x42, 0xe8, 0xa7, 0xab, 0x73, 0xe6, 0xdb, 0x87, 0xe4, 0x7c, 0x01, 0xe0, 0x95, 0x94, 0xda, + 0xdb, 0x1d, 0x25, 0x15, 0x66, 0x01, 0x65, 0xad, 0xa7, 0x96, 0x44, 0xcd, 0x68, 0x2a, 0x65, 0xb4, + 0x16, 0x62, 0xd9, 0xbe, 0xdd, 0x25, 0x4c, 0xa1, 0x17, 0xe0, 0x33, 0xdd, 0x9e, 0xd9, 0xb3, 0x69, + 0x06, 0x49, 0x9a, 0x27, 0x53, 0xfb, 0x6a, 0x62, 0x46, 0x6f, 0xc2, 0x0b, 0xeb, 0x02, 0xfb, 0xba, + 0x03, 0xec, 0x5c, 0x58, 0xfe, 0xcf, 0xad, 0xea, 0xa6, 0x21, 0x9c, 0x4f, 0x01, 0x9c, 0x3e, 0x81, + 0x91, 0x44, 0x1f, 0xc1, 0x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89, 0xa3, 0xb7, 0xac, 0x3d, 0x77, 0xef, 0x14, 0x25, 0xb9, 0xf2, 0xda, 0xc3, 0xfd, 0x12, 0x78, + 0xb4, 0x5f, 0x02, 0x8f, 0xf7, 0x4b, 0xe0, 0xb7, 0xfd, 0x12, 0xf8, 0xf2, 0xa0, 0x94, 0x7b, 0x7c, + 0x50, 0xca, 0xfd, 0x7c, 0x50, 0xca, 0xbd, 0x7f, 0xed, 0x48, 0x59, 0x1d, 0x7b, 0xbb, 0x24, 0x49, + 0x6b, 0xe6, 0x93, 0xe7, 0xe5, 0xcd, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x08, 0x33, 0x8d, + 0x11, 0x0b, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -952,6 +964,14 @@ func (this *FeePool) Equal(that interface{}) bool { return false } } + if len(this.DecimalPool) != len(that1.DecimalPool) { + return false + } + for i := range this.DecimalPool { + if !this.DecimalPool[i].Equal(&that1.DecimalPool[i]) { + return false + } + } return true } func (this *DelegatorStartingInfo) Equal(that interface{}) bool { @@ -1368,6 +1388,20 @@ func (m *FeePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.DecimalPool) > 0 { + for iNdEx := len(m.DecimalPool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DecimalPool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDistribution(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } if len(m.CommunityPool) > 0 { for iNdEx := len(m.CommunityPool) - 1; iNdEx >= 0; iNdEx-- { { @@ -1724,6 +1758,12 @@ func (m *FeePool) Size() (n int) { n += 1 + l + sovDistribution(uint64(l)) } } + if len(m.DecimalPool) > 0 { + for _, e := range m.DecimalPool { + l = e.Size() + n += 1 + l + sovDistribution(uint64(l)) + } + } return n } @@ -2621,6 +2661,40 @@ func (m *FeePool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecimalPool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDistribution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDistribution + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDistribution + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DecimalPool = append(m.DecimalPool, types.DecCoin{}) + if err := m.DecimalPool[len(m.DecimalPool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDistribution(dAtA[iNdEx:]) diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 6b0c7ffc39..ce6968a5ec 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -36,7 +36,7 @@ type BankKeeper interface { // PoolKeeper defines the expected interface needed to fund & distribute pool balances. type PoolKeeper interface { FundCommunityPool(ctx context.Context, amount sdk.Coins, sender sdk.AccAddress) error - DistributeFromFeePool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error + DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error GetCommunityPool(ctx context.Context) (sdk.Coins, error) } diff --git a/x/distribution/types/fee_pool.go b/x/distribution/types/fee_pool.go index 645afd401a..894bff1919 100644 --- a/x/distribution/types/fee_pool.go +++ b/x/distribution/types/fee_pool.go @@ -6,18 +6,22 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// zero fee pool +// InitialFeePool initializes a zero fee pool func InitialFeePool() FeePool { return FeePool{ + DecimalPool: sdk.DecCoins{}, CommunityPool: sdk.DecCoins{}, } } // ValidateGenesis validates the fee pool for a genesis state func (f FeePool) ValidateGenesis() error { - if f.CommunityPool.IsAnyNegative() { - return fmt.Errorf("negative CommunityPool in distribution fee pool, is %v", - f.CommunityPool) + if f.DecimalPool.IsAnyNegative() { + return fmt.Errorf("negative DecimalPool in distribution fee pool, is %v", f.DecimalPool) + } + + if f.CommunityPool.IsAnyNegative() { // TODO(@julienrbrt) in v0.53, panic if the community pool is set + return fmt.Errorf("negative CommunityPool in distribution fee pool, is %v", f.CommunityPool) } return nil diff --git a/x/distribution/types/fee_pool_test.go b/x/distribution/types/fee_pool_test.go index 192e94f022..86d3c93f6e 100644 --- a/x/distribution/types/fee_pool_test.go +++ b/x/distribution/types/fee_pool_test.go @@ -17,4 +17,7 @@ func TestValidateGenesis(t *testing.T) { fp2 := types.FeePool{CommunityPool: sdk.DecCoins{{Denom: "stake", Amount: math.LegacyNewDec(-1)}}} require.NotNil(t, fp2.ValidateGenesis()) + + fp3 := types.FeePool{DecimalPool: sdk.DecCoins{{Denom: "stake", Amount: math.LegacyNewDec(-1)}}} + require.NotNil(t, fp3.ValidateGenesis()) } diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index 70260d5a75..f79281dcd8 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -24,6 +24,8 @@ const ( // It should be synced with the gov module's name if it is ever changed. // See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9 GovModuleName = "gov" + // ProtocolPoolModuleName duplicates the protocolpool module's name to avoid a cyclic dependency with x/protocolpool. + ProtocolPoolModuleName = "protocolpool" ) // Keys for distribution store diff --git a/x/protocolpool/keeper/keeper.go b/x/protocolpool/keeper/keeper.go index 5af89f45fb..1ef7be7d16 100644 --- a/x/protocolpool/keeper/keeper.go +++ b/x/protocolpool/keeper/keeper.go @@ -75,9 +75,9 @@ func (k Keeper) FundCommunityPool(ctx context.Context, amount sdk.Coins, sender return k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, amount) } -// DistributeFromFeePool distributes funds from the protocolpool module account to +// DistributeFromCommunityPool distributes funds from the protocolpool module account to // a receiver address. -func (k Keeper) DistributeFromFeePool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { +func (k Keeper) DistributeFromCommunityPool(ctx context.Context, amount sdk.Coins, receiveAddr sdk.AccAddress) error { return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receiveAddr, amount) } @@ -97,10 +97,10 @@ func (k Keeper) claimFunds(ctx context.Context, recipient sdk.AccAddress) (amoun return sdk.Coin{}, fmt.Errorf("error getting claimable funds: %w", err) } - // distribute amount from feepool - err = k.DistributeFromFeePool(ctx, sdk.NewCoins(amount), recipient) + // distribute amount from community pool + err = k.DistributeFromCommunityPool(ctx, sdk.NewCoins(amount), recipient) if err != nil { - return sdk.Coin{}, fmt.Errorf("error distributing from fee pool: %w", err) + return sdk.Coin{}, fmt.Errorf("error distributing from community pool: %w", err) } return amount, nil diff --git a/x/protocolpool/keeper/msg_server.go b/x/protocolpool/keeper/msg_server.go index ad1e4b61c5..5cc9137778 100644 --- a/x/protocolpool/keeper/msg_server.go +++ b/x/protocolpool/keeper/msg_server.go @@ -93,12 +93,11 @@ func (k MsgServer) CommunityPoolSpend(ctx context.Context, msg *types.MsgCommuni } // distribute funds from community pool module account - if err := k.Keeper.DistributeFromFeePool(ctx, msg.Amount, recipient); err != nil { + if err := k.Keeper.DistributeFromCommunityPool(ctx, msg.Amount, recipient); err != nil { return nil, err } - logger := k.Logger(ctx) - logger.Info("transferred from the community pool to recipient", "amount", msg.Amount.String(), "recipient", msg.Recipient) + k.Logger(ctx).Info("transferred from the community pool to recipient", "amount", msg.Amount.String(), "recipient", msg.Recipient) return &types.MsgCommunityPoolSpendResponse{}, nil }