From 01312dfd5d45d75c49d76d711292383e1ed6a78b Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:50:15 +0200 Subject: [PATCH] refactor(x/distribution)!: remove PreviousProposer and return early if there are no fees to distribute (#20735) --- .../distribution/v1beta1/genesis.pulsar.go | 209 ++++++------------ .../distribution/keeper/msg_server_test.go | 8 - x/distribution/CHANGELOG.md | 1 + x/distribution/keeper/abci.go | 5 +- x/distribution/keeper/allocation.go | 4 + x/distribution/keeper/genesis.go | 24 +- x/distribution/keeper/keeper.go | 2 - x/distribution/migrations/v4/migrate.go | 33 +-- x/distribution/migrations/v4/migrate_test.go | 15 +- .../cosmos/distribution/v1beta1/genesis.proto | 5 +- x/distribution/simulation/decoder.go | 3 - x/distribution/simulation/decoder_test.go | 7 +- x/distribution/types/genesis.go | 4 +- x/distribution/types/genesis.pb.go | 164 +++++--------- x/distribution/types/keys.go | 8 +- 15 files changed, 149 insertions(+), 343 deletions(-) diff --git a/api/cosmos/distribution/v1beta1/genesis.pulsar.go b/api/cosmos/distribution/v1beta1/genesis.pulsar.go index 39c24aa18ce8..caf16b6a68d6 100644 --- a/api/cosmos/distribution/v1beta1/genesis.pulsar.go +++ b/api/cosmos/distribution/v1beta1/genesis.pulsar.go @@ -4123,7 +4123,6 @@ var ( fd_GenesisState_params protoreflect.FieldDescriptor fd_GenesisState_fee_pool protoreflect.FieldDescriptor fd_GenesisState_delegator_withdraw_infos protoreflect.FieldDescriptor - fd_GenesisState_previous_proposer protoreflect.FieldDescriptor fd_GenesisState_outstanding_rewards protoreflect.FieldDescriptor fd_GenesisState_validator_accumulated_commissions protoreflect.FieldDescriptor fd_GenesisState_validator_historical_rewards protoreflect.FieldDescriptor @@ -4138,7 +4137,6 @@ func init() { fd_GenesisState_params = md_GenesisState.Fields().ByName("params") fd_GenesisState_fee_pool = md_GenesisState.Fields().ByName("fee_pool") fd_GenesisState_delegator_withdraw_infos = md_GenesisState.Fields().ByName("delegator_withdraw_infos") - fd_GenesisState_previous_proposer = md_GenesisState.Fields().ByName("previous_proposer") fd_GenesisState_outstanding_rewards = md_GenesisState.Fields().ByName("outstanding_rewards") fd_GenesisState_validator_accumulated_commissions = md_GenesisState.Fields().ByName("validator_accumulated_commissions") fd_GenesisState_validator_historical_rewards = md_GenesisState.Fields().ByName("validator_historical_rewards") @@ -4230,12 +4228,6 @@ func (x *fastReflection_GenesisState) Range(f func(protoreflect.FieldDescriptor, return } } - if x.PreviousProposer != "" { - value := protoreflect.ValueOfString(x.PreviousProposer) - if !f(fd_GenesisState_previous_proposer, value) { - return - } - } if len(x.OutstandingRewards) != 0 { value := protoreflect.ValueOfList(&_GenesisState_5_list{list: &x.OutstandingRewards}) if !f(fd_GenesisState_outstanding_rewards, value) { @@ -4293,8 +4285,6 @@ func (x *fastReflection_GenesisState) Has(fd protoreflect.FieldDescriptor) bool return x.FeePool != nil case "cosmos.distribution.v1beta1.GenesisState.delegator_withdraw_infos": return len(x.DelegatorWithdrawInfos) != 0 - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - return x.PreviousProposer != "" case "cosmos.distribution.v1beta1.GenesisState.outstanding_rewards": return len(x.OutstandingRewards) != 0 case "cosmos.distribution.v1beta1.GenesisState.validator_accumulated_commissions": @@ -4329,8 +4319,6 @@ func (x *fastReflection_GenesisState) Clear(fd protoreflect.FieldDescriptor) { x.FeePool = nil case "cosmos.distribution.v1beta1.GenesisState.delegator_withdraw_infos": x.DelegatorWithdrawInfos = nil - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - x.PreviousProposer = "" case "cosmos.distribution.v1beta1.GenesisState.outstanding_rewards": x.OutstandingRewards = nil case "cosmos.distribution.v1beta1.GenesisState.validator_accumulated_commissions": @@ -4371,9 +4359,6 @@ func (x *fastReflection_GenesisState) Get(descriptor protoreflect.FieldDescripto } listValue := &_GenesisState_3_list{list: &x.DelegatorWithdrawInfos} return protoreflect.ValueOfList(listValue) - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - value := x.PreviousProposer - return protoreflect.ValueOfString(value) case "cosmos.distribution.v1beta1.GenesisState.outstanding_rewards": if len(x.OutstandingRewards) == 0 { return protoreflect.ValueOfList(&_GenesisState_5_list{}) @@ -4438,8 +4423,6 @@ func (x *fastReflection_GenesisState) Set(fd protoreflect.FieldDescriptor, value lv := value.List() clv := lv.(*_GenesisState_3_list) x.DelegatorWithdrawInfos = *clv.list - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - x.PreviousProposer = value.Interface().(string) case "cosmos.distribution.v1beta1.GenesisState.outstanding_rewards": lv := value.List() clv := lv.(*_GenesisState_5_list) @@ -4536,8 +4519,6 @@ func (x *fastReflection_GenesisState) Mutable(fd protoreflect.FieldDescriptor) p } value := &_GenesisState_10_list{list: &x.ValidatorSlashEvents} return protoreflect.ValueOfList(value) - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - panic(fmt.Errorf("field previous_proposer of message cosmos.distribution.v1beta1.GenesisState is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.GenesisState")) @@ -4560,8 +4541,6 @@ func (x *fastReflection_GenesisState) NewField(fd protoreflect.FieldDescriptor) case "cosmos.distribution.v1beta1.GenesisState.delegator_withdraw_infos": list := []*DelegatorWithdrawInfo{} return protoreflect.ValueOfList(&_GenesisState_3_list{list: &list}) - case "cosmos.distribution.v1beta1.GenesisState.previous_proposer": - return protoreflect.ValueOfString("") case "cosmos.distribution.v1beta1.GenesisState.outstanding_rewards": list := []*ValidatorOutstandingRewardsRecord{} return protoreflect.ValueOfList(&_GenesisState_5_list{list: &list}) @@ -4663,10 +4642,6 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } - l = len(x.PreviousProposer) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } if len(x.OutstandingRewards) > 0 { for _, e := range x.OutstandingRewards { l = options.Size(e) @@ -4828,13 +4803,6 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { dAtA[i] = 0x2a } } - if len(x.PreviousProposer) > 0 { - i -= len(x.PreviousProposer) - copy(dAtA[i:], x.PreviousProposer) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PreviousProposer))) - i-- - dAtA[i] = 0x22 - } if len(x.DelegatorWithdrawInfos) > 0 { for iNdEx := len(x.DelegatorWithdrawInfos) - 1; iNdEx >= 0; iNdEx-- { encoded, err := options.Marshal(x.DelegatorWithdrawInfos[iNdEx]) @@ -5034,38 +5002,6 @@ func (x *fastReflection_GenesisState) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 4: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PreviousProposer", wireType) - } - var stringLen uint64 - 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++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - 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.PreviousProposer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 5: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field OutstandingRewards", wireType) @@ -5692,8 +5628,6 @@ type GenesisState struct { FeePool *FeePool `protobuf:"bytes,2,opt,name=fee_pool,json=feePool,proto3" json:"fee_pool,omitempty"` // fee_pool defines the delegator withdraw infos at genesis. DelegatorWithdrawInfos []*DelegatorWithdrawInfo `protobuf:"bytes,3,rep,name=delegator_withdraw_infos,json=delegatorWithdrawInfos,proto3" json:"delegator_withdraw_infos,omitempty"` - // fee_pool defines the previous proposer at genesis. - PreviousProposer string `protobuf:"bytes,4,opt,name=previous_proposer,json=previousProposer,proto3" json:"previous_proposer,omitempty"` // fee_pool defines the outstanding rewards of all validators at genesis. OutstandingRewards []*ValidatorOutstandingRewardsRecord `protobuf:"bytes,5,rep,name=outstanding_rewards,json=outstandingRewards,proto3" json:"outstanding_rewards,omitempty"` // fee_pool defines the accumulated commissions of all validators at genesis. @@ -5749,13 +5683,6 @@ func (x *GenesisState) GetDelegatorWithdrawInfos() []*DelegatorWithdrawInfo { return nil } -func (x *GenesisState) GetPreviousProposer() string { - if x != nil { - return x.PreviousProposer - } - return "" -} - func (x *GenesisState) GetOutstandingRewards() []*ValidatorOutstandingRewardsRecord { if x != nil { return x.OutstandingRewards @@ -5921,7 +5848,7 @@ var file_cosmos_distribution_v1beta1_genesis_proto_rawDesc = []byte{ 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, 0x13, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x22, 0x8c, 0x09, + 0x65, 0x6e, 0x74, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x22, 0xcb, 0x08, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, @@ -5939,79 +5866,75 @@ var file_cosmos_distribution_v1beta1_genesis_proto_rawDesc = []byte{ 0x61, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x16, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x57, 0x69, - 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x45, 0x0a, 0x11, 0x70, - 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x52, 0x10, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, - 0x65, 0x72, 0x12, 0x7a, 0x0a, 0x13, 0x6f, 0x75, 0x74, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, - 0x67, 0x5f, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x3e, 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, 0x2e, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x4f, 0x75, 0x74, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, - 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x12, 0x6f, 0x75, 0x74, 0x73, - 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x98, - 0x01, 0x0a, 0x21, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x63, 0x63, - 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x09, 0xc8, - 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x1f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x8a, 0x01, 0x0a, 0x1c, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, - 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x3d, 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, 0x2e, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, - 0x61, 0x6c, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, - 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x1a, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, - 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x81, 0x01, 0x0a, 0x19, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x77, - 0x61, 0x72, 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, - 0x01, 0x52, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x7d, 0x0a, 0x18, 0x64, 0x65, - 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, - 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, 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, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x67, - 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, + 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x7a, 0x0a, 0x13, 0x6f, + 0x75, 0x74, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x4f, 0x75, 0x74, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, + 0xb0, 0x2a, 0x01, 0x52, 0x12, 0x6f, 0x75, 0x74, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, 0x98, 0x01, 0x0a, 0x21, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, + 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x41, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x63, 0x63, 0x75, 0x6d, + 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, - 0x01, 0x52, 0x16, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x72, - 0x74, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x12, 0x77, 0x0a, 0x16, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x5f, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x01, 0x52, 0x1f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x63, 0x63, 0x75, + 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x8a, 0x01, 0x0a, 0x1c, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x77, 0x61, + 0x72, 0x64, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 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, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0x83, 0x02, 0x0a, - 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, + 0x72, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x77, 0x61, 0x72, + 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, + 0xb0, 0x2a, 0x01, 0x52, 0x1a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x48, 0x69, + 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x12, + 0x81, 0x01, 0x0a, 0x19, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x08, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x3a, 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, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, + 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x17, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x77, 0x61, + 0x72, 0x64, 0x73, 0x12, 0x7d, 0x0a, 0x18, 0x64, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, + 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, 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, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, + 0x72, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, + 0x09, 0xc8, 0xde, 0x1f, 0x00, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x16, 0x64, 0x65, 0x6c, 0x65, + 0x67, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x73, 0x12, 0x77, 0x0a, 0x16, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x5f, + 0x73, 0x6c, 0x61, 0x73, 0x68, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x36, 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, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 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, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 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, 0x3a, 0x08, 0x88, 0xa0, 0x1f, + 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x42, 0x83, 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, + 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 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 ( diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 89d31409ac11..f8dc17862403 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -216,7 +216,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { require.NoError(t, f.distrKeeper.Params.Set(f.sdkCtx, distrtypes.DefaultParams())) delAddr := sdk.AccAddress(PKS[1].Address()) - valConsAddr := sdk.ConsAddress(valConsPk0.Address()) valCommission := sdk.DecCoins{ sdk.NewDecCoinFromDec("mytoken", math.LegacyNewDec(5).Quo(math.LegacyNewDec(4))), @@ -325,9 +324,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { } height := f.app.LastBlockHeight() - _, err = f.distrKeeper.PreviousProposer.Get(f.sdkCtx) - assert.ErrorIs(t, err, collections.ErrNotFound) - for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { @@ -358,10 +354,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { assert.Assert(t, initBalance.IsAllLTE(curBalance)) } - prevProposerConsAddr, err := f.distrKeeper.PreviousProposer.Get(f.sdkCtx) - assert.NilError(t, err) - assert.Assert(t, prevProposerConsAddr.Empty() == false) - assert.DeepEqual(t, prevProposerConsAddr, valConsAddr) var previousTotalPower int64 for _, vote := range f.sdkCtx.CometInfo().LastCommit.Votes { previousTotalPower += vote.Validator.Power diff --git a/x/distribution/CHANGELOG.md b/x/distribution/CHANGELOG.md index ad37c21997b0..86940a5e2d81 100644 --- a/x/distribution/CHANGELOG.md +++ b/x/distribution/CHANGELOG.md @@ -66,6 +66,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking +* [#20735](https://github.com/cosmos/cosmos-sdk/pull/20735) Remove PreviousProposer from the state machine. * [#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. diff --git a/x/distribution/keeper/abci.go b/x/distribution/keeper/abci.go index 46ee8561a6a9..64cb205f5c11 100644 --- a/x/distribution/keeper/abci.go +++ b/x/distribution/keeper/abci.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/x/distribution/types" "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" ) // BeginBlocker sets the proposer for determining distribution during endblock @@ -38,7 +37,5 @@ func (k Keeper) BeginBlocker(ctx context.Context) error { } } - // record the proposer for when we payout on the next block - consAddr := sdk.ConsAddress(ci.ProposerAddress) - return k.PreviousProposer.Set(ctx, consAddr) + return nil } diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 67008af6f6ee..992c487ddb46 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -21,6 +21,10 @@ func (k Keeper) AllocateTokens(ctx context.Context, totalPreviousPower int64, bo // (and distributed to the previous proposer) feeCollector := k.authKeeper.GetModuleAccount(ctx, k.feeCollectorName) feesCollectedInt := k.bankKeeper.GetAllBalances(ctx, feeCollector.GetAddress()) + // return early if no fees to distribute + if feesCollectedInt.Empty() { + return nil + } feesCollected := sdk.NewDecCoinsFromCoins(feesCollectedInt...) // transfer collected fees to the distribution module account diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go index b6c0d0fb5c33..b6fa562268e4 100644 --- a/x/distribution/keeper/genesis.go +++ b/x/distribution/keeper/genesis.go @@ -37,19 +37,6 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) error } } - var previousProposer sdk.ConsAddress - if data.PreviousProposer != "" { - var err error - previousProposer, err = k.stakingKeeper.ConsensusAddressCodec().StringToBytes(data.PreviousProposer) - if err != nil { - return err - } - } - - if err := k.PreviousProposer.Set(ctx, previousProposer); err != nil { - return err - } - for _, rew := range data.OutstandingRewards { valAddr, err := k.stakingKeeper.ValidatorAddressCodec().StringToBytes(rew.ValidatorAddress) if err != nil { @@ -177,11 +164,6 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - pp, err := k.PreviousProposer.Get(ctx) - if err != nil { - return nil, err - } - outstanding := make([]types.ValidatorOutstandingRewardsRecord, 0) err = k.ValidatorOutstandingRewards.Walk(ctx, nil, func(addr sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool, err error) { @@ -303,9 +285,5 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) return nil, err } - ppAddr, err := k.stakingKeeper.ConsensusAddressCodec().BytesToString(pp) - if err != nil { - return nil, err - } - return types.NewGenesisState(params, feePool, dwi, ppAddr, outstanding, acc, his, cur, dels, slashes), nil + return types.NewGenesisState(params, feePool, dwi, outstanding, acc, his, cur, dels, slashes), nil } diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index e2bada2b9d8e..bc5096c4c506 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -51,7 +51,6 @@ type Keeper struct { ValidatorOutstandingRewards collections.Map[sdk.ValAddress, types.ValidatorOutstandingRewards] // ValidatorHistoricalRewards key: valAddr+period | value: ValidatorHistoricalRewards ValidatorHistoricalRewards collections.Map[collections.Pair[sdk.ValAddress, uint64], types.ValidatorHistoricalRewards] - PreviousProposer collections.Item[sdk.ConsAddress] // ValidatorSlashEvents key: valAddr+height+period | value: ValidatorSlashEvent ValidatorSlashEvents collections.Map[collections.Triple[sdk.ValAddress, uint64, uint64], types.ValidatorSlashEvent] @@ -130,7 +129,6 @@ func NewKeeper( collections.PairKeyCodec(sdk.LengthPrefixedAddressKey(sdk.ValAddressKey), sdk.LEUint64Key), //nolint: staticcheck // sdk.LengthPrefixedAddressKey is needed to retain state compatibility codec.CollValue[types.ValidatorHistoricalRewards](cdc), ), - PreviousProposer: collections.NewItem(sb, types.ProposerKey, "previous_proposer", collcodec.KeyToValueCodec(sdk.ConsAddressKey)), ValidatorSlashEvents: collections.NewMap( sb, types.ValidatorSlashEventPrefix, diff --git a/x/distribution/migrations/v4/migrate.go b/x/distribution/migrations/v4/migrate.go index 355bd854a65a..783dc91218c7 100644 --- a/x/distribution/migrations/v4/migrate.go +++ b/x/distribution/migrations/v4/migrate.go @@ -6,8 +6,6 @@ import ( gogotypes "github.com/cosmos/gogoproto/types" - "cosmossdk.io/collections" - collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" @@ -15,37 +13,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - OldProposerKey = []byte{0x01} - NewProposerKey = collections.NewPrefix(1) -) +var OldProposerKey = []byte{0x01} +// MigrateStore removes the last proposer from store. func MigrateStore(ctx context.Context, env appmodule.Environment, cdc codec.BinaryCodec) error { store := env.KVStoreService.OpenKVStore(ctx) - bz, err := store.Get(OldProposerKey) - if err != nil { - return err - } - - if bz == nil { - // previous proposer not set, nothing to do - return nil - } - - addrValue := gogotypes.BytesValue{} - err = cdc.Unmarshal(bz, &addrValue) - if err != nil { - return err - } - - sb := collections.NewSchemaBuilder(env.KVStoreService) - prevProposer := collections.NewItem(sb, NewProposerKey, "previous_proposer", collcodec.KeyToValueCodec(sdk.ConsAddressKey)) - _, err = sb.Build() - if err != nil { - return err - } - - return prevProposer.Set(ctx, addrValue.GetValue()) + return store.Delete(OldProposerKey) } // GetPreviousProposerConsAddr returns the proposer consensus address for the diff --git a/x/distribution/migrations/v4/migrate_test.go b/x/distribution/migrations/v4/migrate_test.go index 32fcebeaeced..a19ad2147187 100644 --- a/x/distribution/migrations/v4/migrate_test.go +++ b/x/distribution/migrations/v4/migrate_test.go @@ -5,8 +5,6 @@ import ( "github.com/stretchr/testify/require" - "cosmossdk.io/collections" - collcodec "cosmossdk.io/collections/codec" "cosmossdk.io/core/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/distribution" @@ -32,6 +30,7 @@ func TestMigration(t *testing.T) { addr1 := secp256k1.GenPrivKey().PubKey().Address() consAddr1 := sdk.ConsAddress(addr1) + // Set and check the previous proposer err := v4.SetPreviousProposerConsAddr(ctx, storeService, cdc, consAddr1) require.NoError(t, err) @@ -42,13 +41,7 @@ func TestMigration(t *testing.T) { err = v4.MigrateStore(ctx, env, cdc) require.NoError(t, err) - sb := collections.NewSchemaBuilder(storeService) - prevProposer := collections.NewItem(sb, v4.NewProposerKey, "previous_proposer", collcodec.KeyToValueCodec(sdk.ConsAddressKey)) - _, err = sb.Build() - require.NoError(t, err) - - newAddr, err := prevProposer.Get(ctx) - require.NoError(t, err) - - require.Equal(t, consAddr1, newAddr) + // Check that the previous proposer has been removed + _, err = v4.GetPreviousProposerConsAddr(ctx, storeService, cdc) + require.ErrorContains(t, err, "previous proposer not set") } diff --git a/x/distribution/proto/cosmos/distribution/v1beta1/genesis.proto b/x/distribution/proto/cosmos/distribution/v1beta1/genesis.proto index 70d4919f0696..024b263a0a8b 100644 --- a/x/distribution/proto/cosmos/distribution/v1beta1/genesis.proto +++ b/x/distribution/proto/cosmos/distribution/v1beta1/genesis.proto @@ -126,9 +126,6 @@ message GenesisState { repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - // fee_pool defines the previous proposer at genesis. - string previous_proposer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // fee_pool defines the outstanding rewards of all validators at genesis. repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; @@ -152,4 +149,6 @@ message GenesisState { // fee_pool defines the validator slash events at genesis. repeated ValidatorSlashEventRecord validator_slash_events = 10 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + + reserved 4; // previous_proposer } diff --git a/x/distribution/simulation/decoder.go b/x/distribution/simulation/decoder.go index 59f445349afd..0373ce40d87f 100644 --- a/x/distribution/simulation/decoder.go +++ b/x/distribution/simulation/decoder.go @@ -22,9 +22,6 @@ func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { cdc.MustUnmarshal(kvB.Value, &feePoolB) return fmt.Sprintf("%v\n%v", feePoolA, feePoolB) - case bytes.Equal(kvA.Key[:1], types.ProposerKey): - return fmt.Sprintf("%v\n%v", sdk.ConsAddress(kvA.Value), sdk.ConsAddress(kvB.Value)) - case bytes.Equal(kvA.Key[:1], types.ValidatorOutstandingRewardsPrefix): var rewardsA, rewardsB types.ValidatorOutstandingRewards cdc.MustUnmarshal(kvA.Value, &rewardsA) diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 98a5c91fe317..c96f8444840f 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -19,9 +19,8 @@ import ( ) var ( - delPk1 = ed25519.GenPrivKey().PubKey() - valAddr1 = sdk.ValAddress(delPk1.Address()) - consAddr1 = sdk.ConsAddress(delPk1.Address().Bytes()) + delPk1 = ed25519.GenPrivKey().PubKey() + valAddr1 = sdk.ValAddress(delPk1.Address()) ) func TestDecodeDistributionStore(t *testing.T) { @@ -38,7 +37,6 @@ func TestDecodeDistributionStore(t *testing.T) { kvPairs := kv.Pairs{ Pairs: []kv.Pair{ {Key: types.FeePoolKey, Value: cdc.MustMarshal(&feePool)}, - {Key: types.ProposerKey, Value: consAddr1.Bytes()}, {Key: types.GetValidatorSlashEventKeyPrefix(valAddr1, 13), Value: cdc.MustMarshal(&slashEvent)}, {Key: []byte{0x99}, Value: []byte{0x99}}, }, @@ -49,7 +47,6 @@ func TestDecodeDistributionStore(t *testing.T) { expectedLog string }{ {"FeePool", fmt.Sprintf("%v\n%v", feePool, feePool)}, - {"Proposer", fmt.Sprintf("%v\n%v", consAddr1, consAddr1)}, {"ValidatorSlashEvent", fmt.Sprintf("%v\n%v", slashEvent, slashEvent)}, {"other", ""}, } diff --git a/x/distribution/types/genesis.go b/x/distribution/types/genesis.go index d973fb94f473..b9228479be98 100644 --- a/x/distribution/types/genesis.go +++ b/x/distribution/types/genesis.go @@ -1,7 +1,7 @@ package types func NewGenesisState( - params Params, fp FeePool, dwis []DelegatorWithdrawInfo, pp string, r []ValidatorOutstandingRewardsRecord, + params Params, fp FeePool, dwis []DelegatorWithdrawInfo, r []ValidatorOutstandingRewardsRecord, acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord, cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord, ) *GenesisState { @@ -9,7 +9,6 @@ func NewGenesisState( Params: params, FeePool: fp, DelegatorWithdrawInfos: dwis, - PreviousProposer: pp, OutstandingRewards: r, ValidatorAccumulatedCommissions: acc, ValidatorHistoricalRewards: historical, @@ -25,7 +24,6 @@ func DefaultGenesisState() *GenesisState { FeePool: InitialFeePool(), Params: DefaultParams(), DelegatorWithdrawInfos: []DelegatorWithdrawInfo{}, - PreviousProposer: "", OutstandingRewards: []ValidatorOutstandingRewardsRecord{}, ValidatorAccumulatedCommissions: []ValidatorAccumulatedCommissionRecord{}, ValidatorHistoricalRewards: []ValidatorHistoricalRewardsRecord{}, diff --git a/x/distribution/types/genesis.pb.go b/x/distribution/types/genesis.pb.go index 4ca54fe3682b..65ea85286c83 100644 --- a/x/distribution/types/genesis.pb.go +++ b/x/distribution/types/genesis.pb.go @@ -334,8 +334,6 @@ type GenesisState struct { FeePool FeePool `protobuf:"bytes,2,opt,name=fee_pool,json=feePool,proto3" json:"fee_pool"` // fee_pool defines the delegator withdraw infos at genesis. DelegatorWithdrawInfos []DelegatorWithdrawInfo `protobuf:"bytes,3,rep,name=delegator_withdraw_infos,json=delegatorWithdrawInfos,proto3" json:"delegator_withdraw_infos"` - // fee_pool defines the previous proposer at genesis. - PreviousProposer string `protobuf:"bytes,4,opt,name=previous_proposer,json=previousProposer,proto3" json:"previous_proposer,omitempty"` // fee_pool defines the outstanding rewards of all validators at genesis. OutstandingRewards []ValidatorOutstandingRewardsRecord `protobuf:"bytes,5,rep,name=outstanding_rewards,json=outstandingRewards,proto3" json:"outstanding_rewards"` // fee_pool defines the accumulated commissions of all validators at genesis. @@ -399,66 +397,65 @@ func init() { } var fileDescriptor_76eed0f9489db580 = []byte{ - // 943 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xf6, 0x3a, 0x25, 0x4d, 0x26, 0x45, 0x34, 0xd3, 0x34, 0x6c, 0xd2, 0x76, 0x9d, 0x94, 0x1e, - 0x0a, 0x28, 0x6b, 0x1a, 0x10, 0x54, 0x45, 0x80, 0x1a, 0xb7, 0xe5, 0xc7, 0x01, 0x22, 0x5b, 0x02, - 0x81, 0x90, 0xac, 0xf1, 0xee, 0x78, 0x3d, 0xaa, 0xbd, 0x63, 0xcd, 0x8c, 0xd7, 0x80, 0xc4, 0x81, - 0x53, 0x11, 0xe2, 0xc0, 0x09, 0x71, 0xac, 0x38, 0x55, 0x48, 0x48, 0x1c, 0xfa, 0x47, 0xf4, 0x58, - 0x55, 0x1c, 0x38, 0x01, 0x72, 0x0e, 0x20, 0x8e, 0xfc, 0x05, 0x68, 0x67, 0x66, 0x77, 0xc7, 0xd9, - 0xed, 0xd6, 0x0d, 0xf5, 0x25, 0xf1, 0xce, 0xbc, 0xf7,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ed, 0x0f, - 0x51, 0x9f, 0xf8, 0x31, 0xc6, 0x07, 0x23, 0xc1, 0x05, 0x0a, 0xfd, 0xd8, 0x07, 0x8f, 0x11, 0xf3, - 0x79, 0x13, 0x7b, 0x94, 0xf9, 0xf0, 0x7d, 0xb0, 0x1a, 0x25, 0x46, 0x87, 0xb8, 0x6f, 0x3f, 0xb8, - 0xbb, 0x73, 0x4e, 0xa3, 0xa6, 0x81, 0x0e, 0x89, 0x88, 0x0e, 0x9d, 0xc3, 0x5b, 0x16, 0x38, 0x45, - 0x33, 0xb0, 0x36, 0x53, 0x68, 0x76, 0x75, 0x6b, 0xe1, 0xe2, 0xca, 0xee, 0x59, 0x5d, 0x22, 0x37, - 0x2e, 0x61, 0x52, 0x6d, 0xf7, 0x1a, 0xf6, 0x1a, 0x94, 0x84, 0x7b, 0x97, 0xef, 0xfd, 0x5e, 0xab, - 0xfc, 0xf4, 0x47, 0xed, 0xc5, 0x80, 0x88, 0xde, 0xa8, 0xe3, 0x7a, 0x74, 0xa0, 0xab, 0xa2, 0xff, - 0xed, 0x70, 0xff, 0x66, 0x5d, 0x7c, 0x3e, 0xc4, 0x3c, 0xf1, 0xe1, 0x77, 0xfe, 0xfa, 0xe5, 0x05, - 0xab, 0x09, 0x69, 0x4e, 0x9f, 0x91, 0x89, 0x7f, 0x2c, 0x70, 0x21, 0x13, 0xe0, 0x79, 0xa3, 0xc1, - 0xa8, 0x8f, 0x04, 0xf6, 0x1b, 0x74, 0x30, 0x20, 0x9c, 0x13, 0x1a, 0xce, 0x29, 0x19, 0x3d, 0xb0, - 0x82, 0x32, 0x38, 0x59, 0xcc, 0x95, 0xdd, 0xd7, 0xdd, 0x92, 0xce, 0x77, 0xcb, 0x79, 0xee, 0x2d, - 0xc7, 0x29, 0x52, 0x9a, 0xcd, 0xd0, 0x86, 0xd8, 0x7f, 0x2d, 0xb0, 0x95, 0x06, 0x79, 0x87, 0x70, - 0x41, 0x19, 0xf1, 0x50, 0x7f, 0xbe, 0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c, 0x09, 0xbf, 0x34, 0xfb, 0x7c, 0x6a, 0x3a, 0x72, 0x7b, 0x59, 0x32, 0xb8, 0xfc, - 0xf8, 0xe3, 0x31, 0x8f, 0x9f, 0x75, 0xbb, 0x69, 0xc7, 0xe1, 0x18, 0xac, 0x17, 0x8e, 0x21, 0x6e, - 0x03, 0x09, 0xfe, 0xea, 0xe3, 0xce, 0xa1, 0x3c, 0xf4, 0x5a, 0xc1, 0x34, 0x32, 0x96, 0xd9, 0xde, - 0x5b, 0x77, 0x26, 0x8e, 0x75, 0x6f, 0xe2, 0x58, 0xf7, 0x27, 0x8e, 0xf5, 0xe7, 0xc4, 0xb1, 0xbe, - 0x3b, 0x70, 0x2a, 0xf7, 0x0f, 0x9c, 0xca, 0x6f, 0x07, 0x4e, 0xe5, 0x93, 0x6d, 0x85, 0xcf, 0xfd, - 0x9b, 0x2e, 0xa1, 0xf5, 0xcf, 0xa6, 0xbf, 0xe1, 0xe5, 0x27, 0x5f, 0x67, 0x51, 0x7e, 0x87, 0xbf, - 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x95, 0x53, 0xd9, 0xb1, 0x65, 0x0c, 0x00, 0x00, + // 925 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x8f, 0xdb, 0x44, + 0x14, 0x8e, 0x93, 0x34, 0xcd, 0x4e, 0x8a, 0xd8, 0x9d, 0x6e, 0x17, 0xef, 0xb6, 0x75, 0x36, 0xa5, + 0x87, 0x02, 0x5a, 0x87, 0x06, 0x04, 0x55, 0x11, 0xa0, 0x26, 0x6d, 0x81, 0x1e, 0xa0, 0x4a, 0x24, + 0x10, 0x08, 0x29, 0x9a, 0xd8, 0x13, 0x67, 0xd4, 0xc4, 0x13, 0x79, 0x26, 0x0e, 0x20, 0x71, 0xe0, + 0x54, 0xc4, 0x89, 0x13, 0xe2, 0x58, 0x71, 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0x21, 0x93, 0xab, 0xc7, 0x99, 0xbb, 0x69, 0x1a, 0xcf, 0xf9, 0xd9, 0x96, 0xf0, 0x4b, 0xb5, 0x41, + 0xe7, 0xc6, 0x1a, 0xd3, 0xd7, 0x42, 0x06, 0x57, 0x8e, 0x3e, 0xd7, 0xd2, 0xf8, 0x49, 0x9b, 0xaa, + 0x76, 0x0c, 0x4e, 0xc1, 0x56, 0xe6, 0xfc, 0x60, 0x3a, 0x08, 0xc1, 0x5f, 0x3b, 0xea, 0x00, 0x49, + 0x43, 0x6f, 0x66, 0x8c, 0x11, 0x65, 0x0b, 0xdd, 0x2a, 0x96, 0x8b, 0xeb, 0x27, 0x9a, 0x6f, 0xdf, + 0x9f, 0x19, 0xda, 0xc3, 0x99, 0xa1, 0x3d, 0x9a, 0x19, 0xda, 0x9f, 0x33, 0x43, 0xfb, 0x76, 0xdf, + 0xc8, 0x3d, 0xda, 0x37, 0x72, 0xbf, 0xed, 0x1b, 0xb9, 0x4f, 0x6a, 0x82, 0x05, 0xb3, 0xef, 0x98, + 0x84, 0xd6, 0x3f, 0x9b, 0xff, 0x04, 0x0f, 0xbf, 0xd8, 0x7a, 0xa5, 0xf0, 0x33, 0xfa, 0x95, 0xff, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x9c, 0xf4, 0xd9, 0x24, 0x0c, 0x00, 0x00, } func (m *DelegatorWithdrawInfo) Marshal() (dAtA []byte, err error) { @@ -868,13 +865,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if len(m.PreviousProposer) > 0 { - i -= len(m.PreviousProposer) - copy(dAtA[i:], m.PreviousProposer) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.PreviousProposer))) - i-- - dAtA[i] = 0x22 - } if len(m.DelegatorWithdrawInfos) > 0 { for iNdEx := len(m.DelegatorWithdrawInfos) - 1; iNdEx >= 0; iNdEx-- { { @@ -1063,10 +1053,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = len(m.PreviousProposer) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } if len(m.OutstandingRewards) > 0 { for _, e := range m.OutstandingRewards { l = e.Size() @@ -2135,38 +2121,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PreviousProposer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PreviousProposer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OutstandingRewards", wireType) diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index f79281dcd88e..e4409d9d5959 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -33,8 +33,6 @@ const ( // // - 0x00: FeePol // -// - 0x01: sdk.ConsAddress -// // - 0x02: ValidatorOutstandingRewards // // - 0x03: sdk.AccAddress @@ -52,7 +50,6 @@ const ( // - 0x09: Params var ( FeePoolKey = collections.NewPrefix(0) // key for global distribution state - ProposerKey = collections.NewPrefix(1) // key for the proposer operator address ValidatorOutstandingRewardsPrefix = collections.NewPrefix(2) // key for outstanding rewards DelegatorWithdrawAddrPrefix = collections.NewPrefix(3) // key for delegator withdraw address DelegatorStartingInfoPrefix = collections.NewPrefix(4) // key for delegator starting info @@ -63,6 +60,11 @@ var ( ParamsKey = collections.NewPrefix(9) // key for distribution module params ) +// Reserved prefixes +var ( + DeprecatedProposerKey = collections.NewPrefix(1) // key for the proposer operator address +) + // GetValidatorSlashEventAddressHeight creates the height from a validator's slash event key. func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) { // key is in the format: