From 8f93a9a3d2aaf8c5472ed41054677b7b34edc4ad Mon Sep 17 00:00:00 2001 From: Solovyov1796 Date: Thu, 1 Aug 2024 23:46:49 +0800 Subject: [PATCH] migrate from 0glabs-v0.46.11-release-x --- Makefile | 2 +- api/cosmos/mint/v1beta1/mint.pulsar.go | 443 +++++++++++++++++- client/flags/flags.go | 6 + client/v2/autocli/flag/register.go | 1 - client/v2/autocli/query_test.go | 4 +- go.mod | 2 + go.sum | 4 + proto/cosmos/auth/v1beta1/auth.proto | 4 +- .../cosmos/base/store/v1beta1/listening.proto | 22 +- proto/cosmos/distribution/v1beta1/tx.proto | 4 +- proto/cosmos/evidence/v1beta1/evidence.proto | 6 +- proto/cosmos/evidence/v1beta1/tx.proto | 2 +- proto/cosmos/gov/v1/gov.proto | 30 +- proto/cosmos/gov/v1/tx.proto | 24 +- proto/cosmos/gov/v1beta1/gov.proto | 18 +- proto/cosmos/gov/v1beta1/tx.proto | 16 +- proto/cosmos/mint/v1beta1/mint.proto | 27 +- proto/cosmos/upgrade/v1beta1/upgrade.proto | 6 +- proto/cosmos/vesting/v1beta1/tx.proto | 4 +- proto/cosmos/vesting/v1beta1/vesting.proto | 2 +- proto/tendermint/abci/types.proto | 68 +-- proto/tendermint/types/evidence.proto | 2 +- proto/tendermint/types/params.proto | 2 +- proto/tendermint/types/types.proto | 28 +- server/cmd/execute.go | 8 +- server/util.go | 41 +- simapp/app.go | 12 +- simapp/go.mod | 2 + simapp/go.sum | 4 + x/auth/vesting/keeper/genesis.go | 17 + x/auth/vesting/keeper/keeper.go | 55 +++ x/auth/vesting/keeper/msg_server.go | 219 +++++++++ x/auth/vesting/module.go | 14 +- x/auth/vesting/types/constants.go | 3 + x/auth/vesting/types/expected_keepers.go | 8 + x/auth/vesting/types/keys.go | 24 + x/mint/abci.go | 42 +- x/mint/keeper/genesis_test.go | 15 +- x/mint/keeper/keeper.go | 9 + x/mint/simulation/genesis.go | 8 +- x/mint/simulation/genesis_test.go | 2 +- x/mint/testutil/expected_keepers_mocks.go | 16 +- x/mint/types/expected_keepers.go | 7 +- x/mint/types/genesis.go | 6 +- x/mint/types/mint.pb.go | 298 ++++++++++-- x/mint/types/minter.go | 2 +- x/mint/types/minter_test.go | 4 +- x/mint/types/params.go | 17 +- x/mint/types/params_legacy.go | 16 + x/staking/keeper/keeper.go | 3 + x/staking/keeper/keeper_test.go | 2 + x/staking/keeper/pool.go | 35 ++ x/staking/module.go | 2 + x/staking/testutil/expected_keepers_mocks.go | 38 +- x/staking/types/expected_keepers.go | 5 + 55 files changed, 1439 insertions(+), 222 deletions(-) create mode 100644 x/auth/vesting/keeper/genesis.go create mode 100644 x/auth/vesting/keeper/keeper.go create mode 100644 x/auth/vesting/keeper/msg_server.go create mode 100644 x/auth/vesting/types/keys.go diff --git a/Makefile b/Makefile index d931324677..aa189b52fc 100644 --- a/Makefile +++ b/Makefile @@ -119,7 +119,7 @@ build-linux-arm64: GOOS=linux GOARCH=arm64 LEDGER_ENABLED=false $(MAKE) build $(BUILD_TARGETS): go.sum $(BUILDDIR)/ - cd ${CURRENT_DIR}/simapp && go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... + cd ${CURRENT_DIR}/simapp && go $@ $(BUILD_FLAGS) $(BUILD_ARGS) ./... $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ diff --git a/api/cosmos/mint/v1beta1/mint.pulsar.go b/api/cosmos/mint/v1beta1/mint.pulsar.go index ee021a461c..df8896b0f4 100644 --- a/api/cosmos/mint/v1beta1/mint.pulsar.go +++ b/api/cosmos/mint/v1beta1/mint.pulsar.go @@ -500,13 +500,18 @@ func (x *fastReflection_Minter) ProtoMethods() *protoiface.Methods { } var ( - md_Params protoreflect.MessageDescriptor - fd_Params_mint_denom protoreflect.FieldDescriptor - fd_Params_inflation_rate_change protoreflect.FieldDescriptor - fd_Params_inflation_max protoreflect.FieldDescriptor - fd_Params_inflation_min protoreflect.FieldDescriptor - fd_Params_goal_bonded protoreflect.FieldDescriptor - fd_Params_blocks_per_year protoreflect.FieldDescriptor + md_Params protoreflect.MessageDescriptor + fd_Params_mint_denom protoreflect.FieldDescriptor + fd_Params_inflation_rate_change protoreflect.FieldDescriptor + fd_Params_inflation_max protoreflect.FieldDescriptor + fd_Params_inflation_min protoreflect.FieldDescriptor + fd_Params_goal_bonded protoreflect.FieldDescriptor + fd_Params_blocks_per_year protoreflect.FieldDescriptor + fd_Params_max_staked_ratio protoreflect.FieldDescriptor + fd_Params_apy_at_max_staked_ratio protoreflect.FieldDescriptor + fd_Params_min_staked_ratio protoreflect.FieldDescriptor + fd_Params_apy_at_min_staked_ratio protoreflect.FieldDescriptor + fd_Params_decay_rate protoreflect.FieldDescriptor ) func init() { @@ -518,6 +523,11 @@ func init() { fd_Params_inflation_min = md_Params.Fields().ByName("inflation_min") fd_Params_goal_bonded = md_Params.Fields().ByName("goal_bonded") fd_Params_blocks_per_year = md_Params.Fields().ByName("blocks_per_year") + fd_Params_max_staked_ratio = md_Params.Fields().ByName("max_staked_ratio") + fd_Params_apy_at_max_staked_ratio = md_Params.Fields().ByName("apy_at_max_staked_ratio") + fd_Params_min_staked_ratio = md_Params.Fields().ByName("min_staked_ratio") + fd_Params_apy_at_min_staked_ratio = md_Params.Fields().ByName("apy_at_min_staked_ratio") + fd_Params_decay_rate = md_Params.Fields().ByName("decay_rate") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -621,6 +631,36 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.MaxStakedRatio != "" { + value := protoreflect.ValueOfString(x.MaxStakedRatio) + if !f(fd_Params_max_staked_ratio, value) { + return + } + } + if x.ApyAtMaxStakedRatio != "" { + value := protoreflect.ValueOfString(x.ApyAtMaxStakedRatio) + if !f(fd_Params_apy_at_max_staked_ratio, value) { + return + } + } + if x.MinStakedRatio != "" { + value := protoreflect.ValueOfString(x.MinStakedRatio) + if !f(fd_Params_min_staked_ratio, value) { + return + } + } + if x.ApyAtMinStakedRatio != "" { + value := protoreflect.ValueOfString(x.ApyAtMinStakedRatio) + if !f(fd_Params_apy_at_min_staked_ratio, value) { + return + } + } + if x.DecayRate != "" { + value := protoreflect.ValueOfString(x.DecayRate) + if !f(fd_Params_decay_rate, value) { + return + } + } } // Has reports whether a field is populated. @@ -648,6 +688,16 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return x.GoalBonded != "" case "cosmos.mint.v1beta1.Params.blocks_per_year": return x.BlocksPerYear != uint64(0) + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + return x.MaxStakedRatio != "" + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + return x.ApyAtMaxStakedRatio != "" + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + return x.MinStakedRatio != "" + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + return x.ApyAtMinStakedRatio != "" + case "cosmos.mint.v1beta1.Params.decay_rate": + return x.DecayRate != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -676,6 +726,16 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.GoalBonded = "" case "cosmos.mint.v1beta1.Params.blocks_per_year": x.BlocksPerYear = uint64(0) + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + x.MaxStakedRatio = "" + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + x.ApyAtMaxStakedRatio = "" + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + x.MinStakedRatio = "" + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + x.ApyAtMinStakedRatio = "" + case "cosmos.mint.v1beta1.Params.decay_rate": + x.DecayRate = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -710,6 +770,21 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "cosmos.mint.v1beta1.Params.blocks_per_year": value := x.BlocksPerYear return protoreflect.ValueOfUint64(value) + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + value := x.MaxStakedRatio + return protoreflect.ValueOfString(value) + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + value := x.ApyAtMaxStakedRatio + return protoreflect.ValueOfString(value) + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + value := x.MinStakedRatio + return protoreflect.ValueOfString(value) + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + value := x.ApyAtMinStakedRatio + return protoreflect.ValueOfString(value) + case "cosmos.mint.v1beta1.Params.decay_rate": + value := x.DecayRate + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -742,6 +817,16 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.GoalBonded = value.Interface().(string) case "cosmos.mint.v1beta1.Params.blocks_per_year": x.BlocksPerYear = value.Uint() + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + x.MaxStakedRatio = value.Interface().(string) + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + x.ApyAtMaxStakedRatio = value.Interface().(string) + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + x.MinStakedRatio = value.Interface().(string) + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + x.ApyAtMinStakedRatio = value.Interface().(string) + case "cosmos.mint.v1beta1.Params.decay_rate": + x.DecayRate = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -774,6 +859,16 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field goal_bonded of message cosmos.mint.v1beta1.Params is not mutable")) case "cosmos.mint.v1beta1.Params.blocks_per_year": panic(fmt.Errorf("field blocks_per_year of message cosmos.mint.v1beta1.Params is not mutable")) + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + panic(fmt.Errorf("field max_staked_ratio of message cosmos.mint.v1beta1.Params is not mutable")) + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + panic(fmt.Errorf("field apy_at_max_staked_ratio of message cosmos.mint.v1beta1.Params is not mutable")) + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + panic(fmt.Errorf("field min_staked_ratio of message cosmos.mint.v1beta1.Params is not mutable")) + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + panic(fmt.Errorf("field apy_at_min_staked_ratio of message cosmos.mint.v1beta1.Params is not mutable")) + case "cosmos.mint.v1beta1.Params.decay_rate": + panic(fmt.Errorf("field decay_rate of message cosmos.mint.v1beta1.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -799,6 +894,16 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor return protoreflect.ValueOfString("") case "cosmos.mint.v1beta1.Params.blocks_per_year": return protoreflect.ValueOfUint64(uint64(0)) + case "cosmos.mint.v1beta1.Params.max_staked_ratio": + return protoreflect.ValueOfString("") + case "cosmos.mint.v1beta1.Params.apy_at_max_staked_ratio": + return protoreflect.ValueOfString("") + case "cosmos.mint.v1beta1.Params.min_staked_ratio": + return protoreflect.ValueOfString("") + case "cosmos.mint.v1beta1.Params.apy_at_min_staked_ratio": + return protoreflect.ValueOfString("") + case "cosmos.mint.v1beta1.Params.decay_rate": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.mint.v1beta1.Params")) @@ -891,6 +996,26 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if x.BlocksPerYear != 0 { n += 1 + runtime.Sov(uint64(x.BlocksPerYear)) } + l = len(x.MaxStakedRatio) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ApyAtMaxStakedRatio) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.MinStakedRatio) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ApyAtMinStakedRatio) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.DecayRate) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -920,6 +1045,41 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.DecayRate) > 0 { + i -= len(x.DecayRate) + copy(dAtA[i:], x.DecayRate) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.DecayRate))) + i-- + dAtA[i] = 0x5a + } + if len(x.ApyAtMinStakedRatio) > 0 { + i -= len(x.ApyAtMinStakedRatio) + copy(dAtA[i:], x.ApyAtMinStakedRatio) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ApyAtMinStakedRatio))) + i-- + dAtA[i] = 0x52 + } + if len(x.MinStakedRatio) > 0 { + i -= len(x.MinStakedRatio) + copy(dAtA[i:], x.MinStakedRatio) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MinStakedRatio))) + i-- + dAtA[i] = 0x4a + } + if len(x.ApyAtMaxStakedRatio) > 0 { + i -= len(x.ApyAtMaxStakedRatio) + copy(dAtA[i:], x.ApyAtMaxStakedRatio) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ApyAtMaxStakedRatio))) + i-- + dAtA[i] = 0x42 + } + if len(x.MaxStakedRatio) > 0 { + i -= len(x.MaxStakedRatio) + copy(dAtA[i:], x.MaxStakedRatio) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.MaxStakedRatio))) + i-- + dAtA[i] = 0x3a + } if x.BlocksPerYear != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.BlocksPerYear)) i-- @@ -1188,6 +1348,166 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { break } } + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MaxStakedRatio", 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.MaxStakedRatio = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ApyAtMaxStakedRatio", 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.ApyAtMaxStakedRatio = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinStakedRatio", 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.MinStakedRatio = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ApyAtMinStakedRatio", 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.ApyAtMinStakedRatio = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DecayRate", 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.DecayRate = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -1299,7 +1619,12 @@ type Params struct { // goal of percent bonded atoms GoalBonded string `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3" json:"goal_bonded,omitempty"` // expected blocks per year - BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + MaxStakedRatio string `protobuf:"bytes,7,opt,name=max_staked_ratio,json=maxStakedRatio,proto3" json:"max_staked_ratio,omitempty"` + ApyAtMaxStakedRatio string `protobuf:"bytes,8,opt,name=apy_at_max_staked_ratio,json=apyAtMaxStakedRatio,proto3" json:"apy_at_max_staked_ratio,omitempty"` + MinStakedRatio string `protobuf:"bytes,9,opt,name=min_staked_ratio,json=minStakedRatio,proto3" json:"min_staked_ratio,omitempty"` + ApyAtMinStakedRatio string `protobuf:"bytes,10,opt,name=apy_at_min_staked_ratio,json=apyAtMinStakedRatio,proto3" json:"apy_at_min_staked_ratio,omitempty"` + DecayRate string `protobuf:"bytes,11,opt,name=decay_rate,json=decayRate,proto3" json:"decay_rate,omitempty"` } func (x *Params) Reset() { @@ -1364,6 +1689,41 @@ func (x *Params) GetBlocksPerYear() uint64 { return 0 } +func (x *Params) GetMaxStakedRatio() string { + if x != nil { + return x.MaxStakedRatio + } + return "" +} + +func (x *Params) GetApyAtMaxStakedRatio() string { + if x != nil { + return x.ApyAtMaxStakedRatio + } + return "" +} + +func (x *Params) GetMinStakedRatio() string { + if x != nil { + return x.MinStakedRatio + } + return "" +} + +func (x *Params) GetApyAtMinStakedRatio() string { + if x != nil { + return x.ApyAtMinStakedRatio + } + return "" +} + +func (x *Params) GetDecayRate() string { + if x != nil { + return x.DecayRate + } + return "" +} + var File_cosmos_mint_v1beta1_mint_proto protoreflect.FileDescriptor var file_cosmos_mint_v1beta1_mint_proto_rawDesc = []byte{ @@ -1387,7 +1747,7 @@ var file_cosmos_mint_v1beta1_mint_proto_rawDesc = []byte{ 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, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x10, 0x61, 0x6e, 0x6e, 0x75, 0x61, - 0x6c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x89, 0x04, 0x0a, 0x06, + 0x6c, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x9e, 0x08, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x69, 0x6e, 0x74, 0x5f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x74, 0x44, 0x65, 0x6e, 0x6f, 0x6d, 0x12, 0x70, 0x0a, 0x15, 0x69, 0x6e, 0x66, 0x6c, 0x61, 0x74, 0x69, @@ -1418,22 +1778,55 @@ var file_cosmos_mint_v1beta1_mint_proto_rawDesc = []byte{ 0x52, 0x0a, 0x67, 0x6f, 0x61, 0x6c, 0x42, 0x6f, 0x6e, 0x64, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x79, 0x65, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, - 0x59, 0x65, 0x61, 0x72, 0x3a, 0x21, 0x98, 0xa0, 0x1f, 0x00, 0x8a, 0xe7, 0xb0, 0x2a, 0x18, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78, 0x2f, 0x6d, 0x69, 0x6e, 0x74, - 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x42, 0x09, 0x4d, 0x69, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, - 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x4d, 0x69, - 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, - 0x3a, 0x4d, 0x69, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x59, 0x65, 0x61, 0x72, 0x12, 0x66, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x74, 0x61, 0x6b, + 0x65, 0x64, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, + 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x26, 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, 0xd2, 0xb4, + 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x0e, 0x6d, 0x61, + 0x78, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x12, 0x72, 0x0a, 0x17, + 0x61, 0x70, 0x79, 0x5f, 0x61, 0x74, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x74, 0x61, 0x6b, 0x65, + 0x64, 0x5f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xc8, + 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x26, 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, 0xd2, 0xb4, 0x2d, + 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x13, 0x61, 0x70, 0x79, + 0x41, 0x74, 0x4d, 0x61, 0x78, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x52, 0x61, 0x74, 0x69, 0x6f, + 0x12, 0x66, 0x0a, 0x10, 0x6d, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x5f, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xc8, 0xde, 0x1f, 0x00, + 0xda, 0xde, 0x1f, 0x26, 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, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x0e, 0x6d, 0x69, 0x6e, 0x53, 0x74, 0x61, + 0x6b, 0x65, 0x64, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x12, 0x72, 0x0a, 0x17, 0x61, 0x70, 0x79, 0x5f, + 0x61, 0x74, 0x5f, 0x6d, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x5f, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3c, 0xc8, 0xde, 0x1f, 0x00, 0xda, + 0xde, 0x1f, 0x26, 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, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x13, 0x61, 0x70, 0x79, 0x41, 0x74, 0x4d, 0x69, + 0x6e, 0x53, 0x74, 0x61, 0x6b, 0x65, 0x64, 0x52, 0x61, 0x74, 0x69, 0x6f, 0x12, 0x5b, 0x0a, 0x0a, + 0x64, 0x65, 0x63, 0x61, 0x79, 0x5f, 0x72, 0x61, 0x74, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x3c, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x26, 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, + 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x09, + 0x64, 0x65, 0x63, 0x61, 0x79, 0x52, 0x61, 0x74, 0x65, 0x3a, 0x21, 0x98, 0xa0, 0x1f, 0x00, 0x8a, + 0xe7, 0xb0, 0x2a, 0x18, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x78, + 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xc4, 0x01, 0x0a, + 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x4d, 0x69, 0x6e, 0x74, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, + 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x69, 0x6e, 0x74, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x13, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x4d, 0x69, 0x6e, + 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x5c, 0x4d, 0x69, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x4d, 0x69, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/client/flags/flags.go b/client/flags/flags.go index b7cf758237..2a66377d15 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -88,6 +88,12 @@ const ( FlagLogLevel = "log_level" FlagLogFormat = "log_format" FlagLogNoColor = "log_no_color" + FlagLogMaxSize = "log_max_size" + FlagLogMaxAge = "log_max_age" + FlagLogMaxBackups = "log_max_backups" + FlagLogOutputConsole = "log_output_console" + FlagLogRotateInterval = "log_rotate_interval" + FlagLogCompress = "log_compress" ) // LineBreak can be included in a command list to provide a blank line diff --git a/client/v2/autocli/flag/register.go b/client/v2/autocli/flag/register.go index cc18df69b6..a3a525b343 100644 --- a/client/v2/autocli/flag/register.go +++ b/client/v2/autocli/flag/register.go @@ -104,7 +104,6 @@ func (b *Builder) addMessageFlags(ctx context.Context, flagSet *pflag.FlagSet, m flag.Deprecated = opts.Deprecated flag.ShorthandDeprecated = opts.ShorthandDeprecated flag.Hidden = opts.Hidden - flag.NoOptDefVal = opts.NoOptDefaultValue } }) diff --git a/client/v2/autocli/query_test.go b/client/v2/autocli/query_test.go index 6eec93707b..a3b0ba5f18 100644 --- a/client/v2/autocli/query_test.go +++ b/client/v2/autocli/query_test.go @@ -53,8 +53,8 @@ var testCmdDesc = &autocliv1.ServiceCommandDescriptor{ DefaultValue: "3", }, "u64": { - Usage: "some random uint64", - NoOptDefaultValue: "5", + Usage: "some random uint64", + DefaultValue: "5", }, "deprecated_field": { Deprecated: "don't use this", diff --git a/go.mod b/go.mod index 22eb8500ee..d56ff86416 100644 --- a/go.mod +++ b/go.mod @@ -53,6 +53,7 @@ require ( github.com/prometheus/common v0.42.0 github.com/rakyll/statik v0.1.7 github.com/rs/zerolog v1.32.0 + github.com/shopspring/decimal v1.4.0 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 @@ -66,6 +67,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 + gopkg.in/natefinch/lumberjack.v2 v2.2.1 gotest.tools/v3 v3.5.1 pgregory.net/rapid v1.1.0 sigs.k8s.io/yaml v1.4.0 diff --git a/go.sum b/go.sum index 94be73b897..377514aeed 100644 --- a/go.sum +++ b/go.sum @@ -925,6 +925,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1639,6 +1641,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/proto/cosmos/auth/v1beta1/auth.proto b/proto/cosmos/auth/v1beta1/auth.proto index 0578453ccf..f09df38283 100644 --- a/proto/cosmos/auth/v1beta1/auth.proto +++ b/proto/cosmos/auth/v1beta1/auth.proto @@ -17,8 +17,8 @@ message BaseAccount { option (gogoproto.equal) = false; option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; uint64 account_number = 3; uint64 sequence = 4; } diff --git a/proto/cosmos/base/store/v1beta1/listening.proto b/proto/cosmos/base/store/v1beta1/listening.proto index 753f7c1655..d6f7128931 100644 --- a/proto/cosmos/base/store/v1beta1/listening.proto +++ b/proto/cosmos/base/store/v1beta1/listening.proto @@ -20,15 +20,15 @@ message StoreKVPair { // BlockMetadata contains all the abci event data of a block // the file streamer dump them into files together with the state changes. message BlockMetadata { - // DeliverTx encapulate deliver tx request and response. - message DeliverTx { - tendermint.abci.RequestDeliverTx request = 1; - tendermint.abci.ResponseDeliverTx response = 2; - } - tendermint.abci.RequestBeginBlock request_begin_block = 1; - tendermint.abci.ResponseBeginBlock response_begin_block = 2; - repeated DeliverTx deliver_txs = 3; - tendermint.abci.RequestEndBlock request_end_block = 4; - tendermint.abci.ResponseEndBlock response_end_block = 5; - tendermint.abci.ResponseCommit response_commit = 6; + // DeliverTx encapulate deliver tx request and response. + message DeliverTx { + tendermint.abci.RequestDeliverTx request = 1; + tendermint.abci.ResponseDeliverTx response = 2; + } + tendermint.abci.RequestBeginBlock request_begin_block = 1; + tendermint.abci.ResponseBeginBlock response_begin_block = 2; + repeated DeliverTx deliver_txs = 3; + tendermint.abci.RequestEndBlock request_end_block = 4; + tendermint.abci.ResponseEndBlock response_end_block = 5; + tendermint.abci.ResponseCommit response_commit = 6; } diff --git a/proto/cosmos/distribution/v1beta1/tx.proto b/proto/cosmos/distribution/v1beta1/tx.proto index 957747cf43..b921879a16 100644 --- a/proto/cosmos/distribution/v1beta1/tx.proto +++ b/proto/cosmos/distribution/v1beta1/tx.proto @@ -162,8 +162,8 @@ message MsgCommunityPoolSpend { option (amino.name) = "cosmos-sdk/distr/MsgCommunityPoolSpend"; // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string recipient = 2; + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 2; repeated cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true, diff --git a/proto/cosmos/evidence/v1beta1/evidence.proto b/proto/cosmos/evidence/v1beta1/evidence.proto index 8dca3201d0..195be98b19 100644 --- a/proto/cosmos/evidence/v1beta1/evidence.proto +++ b/proto/cosmos/evidence/v1beta1/evidence.proto @@ -18,14 +18,14 @@ message Equivocation { option (gogoproto.equal) = false; // height is the equivocation height. - int64 height = 1; + int64 height = 1; // time is the equivocation time. - google.protobuf.Timestamp time = 2 + google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdtime) = true]; // power is the equivocation validator power. - int64 power = 3; + int64 power = 3; // consensus_address is the equivocation validator consensus address. string consensus_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; diff --git a/proto/cosmos/evidence/v1beta1/tx.proto b/proto/cosmos/evidence/v1beta1/tx.proto index f5646e2dec..e6fe5c4514 100644 --- a/proto/cosmos/evidence/v1beta1/tx.proto +++ b/proto/cosmos/evidence/v1beta1/tx.proto @@ -29,7 +29,7 @@ message MsgSubmitEvidence { option (gogoproto.goproto_getters) = false; // submitter is the signer account address of evidence. - string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // evidence defines the evidence of misbehavior. google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "cosmos.evidence.v1beta1.Evidence"]; diff --git a/proto/cosmos/gov/v1/gov.proto b/proto/cosmos/gov/v1/gov.proto index 49bfcc264b..491b0d29f2 100644 --- a/proto/cosmos/gov/v1/gov.proto +++ b/proto/cosmos/gov/v1/gov.proto @@ -32,17 +32,17 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; + string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; } // Deposit defines an amount deposited by an account address to an active // proposal. message Deposit { // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; @@ -51,33 +51,33 @@ message Deposit { // Proposal defines the core field members of a governance proposal. message Proposal { // id defines the unique id of the proposal. - uint64 id = 1; + uint64 id = 1; // messages are the arbitrary messages to be executed if the proposal passes. repeated google.protobuf.Any messages = 2; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4; + TallyResult final_tally_result = 4; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; // deposit_end_time is the end time for deposition. - google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; // total_deposit is the total deposit on the proposal. - repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // voting_start_time is the starting time to vote on a proposal. - google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; // voting_end_time is the end time of voting on a proposal. - google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 10; @@ -122,11 +122,11 @@ enum ProposalStatus { // TallyResult defines a standard tally for a governance proposal. message TallyResult { // yes_count is the number of yes votes on a proposal. - string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; + string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; // abstain_count is the number of abstain votes on a proposal. - string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; + string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_count is the number of no votes on a proposal. - string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; + string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_with_veto_count is the number of no with veto votes on a proposal. string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"]; } @@ -138,7 +138,7 @@ message Vote { uint64 proposal_id = 1; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; reserved 3; diff --git a/proto/cosmos/gov/v1/tx.proto b/proto/cosmos/gov/v1/tx.proto index 1708066c65..0cac6558c4 100644 --- a/proto/cosmos/gov/v1/tx.proto +++ b/proto/cosmos/gov/v1/tx.proto @@ -46,13 +46,13 @@ message MsgSubmitProposal { option (amino.name) = "cosmos-sdk/v1/MsgSubmitProposal"; // messages are the arbitrary messages to be executed if proposal passes. - repeated google.protobuf.Any messages = 1; + repeated google.protobuf.Any messages = 1; // initial_deposit is the deposit value that must be paid at proposal submission. repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // proposer is the account address of the proposer. - string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 4; @@ -95,16 +95,16 @@ message MsgVote { option (amino.name) = "cosmos-sdk/v1/MsgVote"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; // metadata is any arbitrary metadata attached to the Vote. - string metadata = 4; + string metadata = 4; } // MsgVoteResponse defines the Msg/Vote response type. @@ -116,16 +116,16 @@ message MsgVoteWeighted { option (amino.name) = "cosmos-sdk/v1/MsgVoteWeighted"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3; + repeated WeightedVoteOption options = 3; // metadata is any arbitrary metadata attached to the VoteWeighted. - string metadata = 4; + string metadata = 4; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -137,10 +137,10 @@ message MsgDeposit { option (amino.name) = "cosmos-sdk/v1/MsgDeposit"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/proto/cosmos/gov/v1beta1/gov.proto b/proto/cosmos/gov/v1beta1/gov.proto index dc8fcfd33f..b8996a4abc 100644 --- a/proto/cosmos/gov/v1beta1/gov.proto +++ b/proto/cosmos/gov/v1beta1/gov.proto @@ -39,7 +39,7 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [ + string weight = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false @@ -55,7 +55,7 @@ message TextProposal { option (gogoproto.equal) = true; // title of the proposal. - string title = 1; + string title = 1; // description associated with the proposal. string description = 2; @@ -68,10 +68,10 @@ message Deposit { option (gogoproto.equal) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ @@ -86,20 +86,20 @@ message Proposal { option (gogoproto.equal) = true; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // content is the proposal's content. google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"]; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // deposit_end_time is the end time for deposition. @@ -188,7 +188,7 @@ message Vote { uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true]; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Deprecated: Prefer to use `options` instead. This field is set in queries // if and only if `len(options) == 1` and that option has weight 1. In all // other cases, this field will default to VOTE_OPTION_UNSPECIFIED. diff --git a/proto/cosmos/gov/v1beta1/tx.proto b/proto/cosmos/gov/v1beta1/tx.proto index 0afa1d5670..a976137de6 100644 --- a/proto/cosmos/gov/v1beta1/tx.proto +++ b/proto/cosmos/gov/v1beta1/tx.proto @@ -71,13 +71,13 @@ message MsgVote { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; } // MsgVoteResponse defines the Msg/Vote response type. @@ -96,13 +96,13 @@ message MsgVoteWeighted { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -121,10 +121,10 @@ message MsgDeposit { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ diff --git a/proto/cosmos/mint/v1beta1/mint.proto b/proto/cosmos/mint/v1beta1/mint.proto index 49b00a5d47..c9ea8f84b1 100644 --- a/proto/cosmos/mint/v1beta1/mint.proto +++ b/proto/cosmos/mint/v1beta1/mint.proto @@ -55,5 +55,30 @@ message Params { (gogoproto.nullable) = false ]; // expected blocks per year - uint64 blocks_per_year = 6; + uint64 blocks_per_year = 6; + string max_staked_ratio = 7 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string apy_at_max_staked_ratio = 8 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string min_staked_ratio = 9 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string apy_at_min_staked_ratio = 10 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string decay_rate = 11 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } diff --git a/proto/cosmos/upgrade/v1beta1/upgrade.proto b/proto/cosmos/upgrade/v1beta1/upgrade.proto index 0a96716856..327ef5af8c 100644 --- a/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -56,13 +56,13 @@ message SoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; // plan of the proposal - Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software @@ -77,7 +77,7 @@ message CancelSoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index 42d3213f7b..30b726a659 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -86,8 +86,8 @@ message MsgCreatePeriodicVestingAccount { option (gogoproto.equal) = false; - string from_address = 1; - string to_address = 2; + string from_address = 1; + string to_address = 2; // start of vesting as unix time (in seconds). int64 start_time = 3; repeated Period vesting_periods = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/proto/cosmos/vesting/v1beta1/vesting.proto b/proto/cosmos/vesting/v1beta1/vesting.proto index 7ab1fb797b..e772b18620 100644 --- a/proto/cosmos/vesting/v1beta1/vesting.proto +++ b/proto/cosmos/vesting/v1beta1/vesting.proto @@ -44,7 +44,7 @@ message ContinuousVestingAccount { BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; // Vesting start time, as unix timestamp (in seconds). - int64 start_time = 2; + int64 start_time = 2; } // DelayedVestingAccount implements the VestingAccount interface. It vests all diff --git a/proto/tendermint/abci/types.proto b/proto/tendermint/abci/types.proto index cf9927d796..0c57bf0c6e 100644 --- a/proto/tendermint/abci/types.proto +++ b/proto/tendermint/abci/types.proto @@ -103,8 +103,8 @@ message RequestListSnapshots {} // offers a snapshot to the application message RequestOfferSnapshot { - Snapshot snapshot = 1; // snapshot offered by peers - bytes app_hash = 2; // light client-verified app hash for snapshot height + Snapshot snapshot = 1; // snapshot offered by peers + bytes app_hash = 2; // light client-verified app hash for snapshot height } // loads a snapshot chunk @@ -205,8 +205,8 @@ message ResponseInitChain { message ResponseQuery { uint32 code = 1; // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 index = 5; bytes key = 6; bytes value = 7; @@ -223,15 +223,15 @@ message ResponseBeginBlock { message ResponseCheckTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; - string sender = 9; - int64 priority = 10; + string codespace = 8; + string sender = 9; + int64 priority = 10; // mempool_error is set by CometBFT. // ABCI applictions creating a ResponseCheckTX should not set mempool_error. @@ -241,8 +241,8 @@ message ResponseCheckTx { message ResponseDeliverTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [ @@ -273,12 +273,12 @@ message ResponseOfferSnapshot { Result result = 1; enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Snapshot accepted, apply chunks - ABORT = 2; // Abort all snapshot restoration - REJECT = 3; // Reject this specific snapshot, try others - REJECT_FORMAT = 4; // Reject all snapshots of this format, try others - REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Snapshot accepted, apply chunks + ABORT = 2; // Abort all snapshot restoration + REJECT = 3; // Reject this specific snapshot, try others + REJECT_FORMAT = 4; // Reject all snapshots of this format, try others + REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others } } @@ -288,16 +288,16 @@ message ResponseLoadSnapshotChunk { message ResponseApplySnapshotChunk { Result result = 1; - repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply - repeated string reject_senders = 3; // Chunk senders to reject and ban + repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply + repeated string reject_senders = 3; // Chunk senders to reject and ban enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Chunk successfully accepted - ABORT = 2; // Abort all snapshot restoration - RETRY = 3; // Retry chunk (combine with refetch and reject) - RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) - REJECT_SNAPSHOT = 5; // Reject this snapshot, try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Chunk successfully accepted + ABORT = 2; // Abort all snapshot restoration + RETRY = 3; // Retry chunk (combine with refetch and reject) + RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) + REJECT_SNAPSHOT = 5; // Reject this snapshot, try others } } @@ -346,7 +346,7 @@ message Event { message EventAttribute { string key = 1; string value = 2; - bool index = 3; // nondeterministic + bool index = 3; // nondeterministic } // TxResult contains results of executing the transaction. @@ -364,9 +364,9 @@ message TxResult { // Validator message Validator { - bytes address = 1; // The first 20 bytes of SHA256(public key) + bytes address = 1; // The first 20 bytes of SHA256(public key) // PubKey pub_key = 2 [(gogoproto.nullable)=false]; - int64 power = 3; // The voting power + int64 power = 3; // The voting power } // ValidatorUpdate @@ -384,7 +384,7 @@ message VoteInfo { message ExtendedVoteInfo { Validator validator = 1 [(gogoproto.nullable) = false]; bool signed_last_block = 2; - bytes vote_extension = 3; // Reserved for future use + bytes vote_extension = 3; // Reserved for future use } enum MisbehaviorType { @@ -412,11 +412,11 @@ message Misbehavior { // State Sync Types message Snapshot { - uint64 height = 1; // The height at which the snapshot was taken - uint32 format = 2; // The application-specific snapshot format - uint32 chunks = 3; // Number of chunks in the snapshot - bytes hash = 4; // Arbitrary snapshot hash, equal only if identical - bytes metadata = 5; // Arbitrary application metadata + uint64 height = 1; // The height at which the snapshot was taken + uint32 format = 2; // The application-specific snapshot format + uint32 chunks = 3; // Number of chunks in the snapshot + bytes hash = 4; // Arbitrary snapshot hash, equal only if identical + bytes metadata = 5; // Arbitrary application metadata } //---------------------------------------- diff --git a/proto/tendermint/types/evidence.proto b/proto/tendermint/types/evidence.proto index 1f35049bdc..06f30ec2f5 100644 --- a/proto/tendermint/types/evidence.proto +++ b/proto/tendermint/types/evidence.proto @@ -30,7 +30,7 @@ message LightClientAttackEvidence { int64 common_height = 2; repeated tendermint.types.Validator byzantine_validators = 3; int64 total_voting_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } message EvidenceList { diff --git a/proto/tendermint/types/params.proto b/proto/tendermint/types/params.proto index 66963eec4e..e8f56c2e8d 100644 --- a/proto/tendermint/types/params.proto +++ b/proto/tendermint/types/params.proto @@ -26,7 +26,7 @@ message BlockParams { // Note: must be greater or equal to -1 int64 max_gas = 2; - reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 + reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 } // EvidenceParams determine how we handle evidence of malfeasance. diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index 425f041dab..b4c31671e3 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -66,19 +66,19 @@ message Header { BlockID last_block_id = 5 [(gogoproto.nullable) = false]; // hashes of block data - bytes last_commit_hash = 6; // commit from validators from the last block - bytes data_hash = 7; // transactions + bytes last_commit_hash = 6; // commit from validators from the last block + bytes data_hash = 7; // transactions // hashes from the app output from the prev block - bytes validators_hash = 8; // validators for the current block - bytes next_validators_hash = 9; // validators for the next block - bytes consensus_hash = 10; // consensus params for current block - bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block + bytes validators_hash = 8; // validators for the current block + bytes next_validators_hash = 9; // validators for the next block + bytes consensus_hash = 10; // consensus params for current block + bytes app_hash = 11; // state after txs from the previous block + bytes last_results_hash = 12; // root hash of all results from the txs from the previous block // consensus info - bytes evidence_hash = 13; // evidence included in the block - bytes proposer_address = 14; // original proposer of the block + bytes evidence_hash = 13; // evidence included in the block + bytes proposer_address = 14; // original proposer of the block } // Data contains the set of transactions included in the block @@ -99,9 +99,9 @@ message Vote { [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes validator_address = 6; - int32 validator_index = 7; - bytes signature = 8; + bytes validator_address = 6; + int32 validator_index = 7; + bytes signature = 8; } // Commit contains the evidence that a block was committed by a set of validators. @@ -118,7 +118,7 @@ message CommitSig { bytes validator_address = 2; google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 4; + bytes signature = 4; } message Proposal { @@ -129,7 +129,7 @@ message Proposal { BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 7; + bytes signature = 7; } message SignedHeader { diff --git a/server/cmd/execute.go b/server/cmd/execute.go index 1f869b1b31..a42826ccee 100644 --- a/server/cmd/execute.go +++ b/server/cmd/execute.go @@ -27,7 +27,13 @@ func Execute(rootCmd *cobra.Command, envPrefix string, defaultHome string) error rootCmd.PersistentFlags().String(flags.FlagLogLevel, tmcfg.DefaultLogLevel, "The logging level (trace|debug|info|warn|error|fatal|panic)") rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmcfg.LogFormatPlain, "The logging format (json|plain)") - rootCmd.PersistentFlags().Bool(flags.FlagLogNoColor, false, "Disable colored logs") + rootCmd.PersistentFlags().Bool(flags.FlagLogNoColor, true, "Disable colored logs") + rootCmd.PersistentFlags().Int(flags.FlagLogMaxSize, 2048, "Maximum space occupied by a single log file") + rootCmd.PersistentFlags().Int(flags.FlagLogMaxBackups, 1024, "The maximum number of log files to be retained for split storage") + rootCmd.PersistentFlags().Int(flags.FlagLogMaxAge, 365, "The maximum retention time of the split and stored log files, in days") + rootCmd.PersistentFlags().Bool(flags.FlagLogOutputConsole, false, "Log output to console") + rootCmd.PersistentFlags().Int(flags.FlagLogRotateInterval, 24, "Log rotation interval in hours") + rootCmd.PersistentFlags().Bool(flags.FlagLogCompress, true, "Compress log files using gzip") executor := tmcli.PrepareBaseCmd(rootCmd, envPrefix, defaultHome) return executor.ExecuteContext(ctx) diff --git a/server/util.go b/server/util.go index e22137aad0..063917545b 100644 --- a/server/util.go +++ b/server/util.go @@ -40,6 +40,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/version" + "gopkg.in/natefinch/lumberjack.v2" ) // DONTCOVER @@ -185,12 +186,50 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s } } - logger := log.NewLogger(tmlog.NewSyncWriter(os.Stdout), opts...).With(log.ModuleKey, "server") + logMaxSize := serverCtx.Viper.GetInt(flags.FlagLogMaxSize) + logMaxAge := serverCtx.Viper.GetInt(flags.FlagLogMaxAge) + logMaxBackups := serverCtx.Viper.GetInt(flags.FlagLogMaxBackups) + logRotateInterval := serverCtx.Viper.GetInt(flags.FlagLogRotateInterval) + + rootDir := serverCtx.Viper.GetString(flags.FlagHome) + logPath := filepath.Join(rootDir, "log") + logFile := filepath.Join(logPath, "chain.log") + + loggerWrite := &lumberjack.Logger{ + Filename: logFile, + MaxSize: logMaxSize, + MaxAge: logMaxAge, + MaxBackups: logMaxBackups, + Compress: serverCtx.Viper.GetBool(flags.FlagLogCompress), + } + + go logRotate(loggerWrite, logRotateInterval) + + var writer io.Writer + if serverCtx.Viper.GetBool(flags.FlagLogOutputConsole) { + writer = tmlog.NewSyncWriter(io.MultiWriter(loggerWrite, os.Stdout)) + } else { + writer = tmlog.NewSyncWriter(loggerWrite) + } + + logger := log.NewLogger(writer, opts...).With(log.ModuleKey, "server") serverCtx.Logger = serverlog.CometLoggerWrapper{Logger: logger} return SetCmdServerContext(cmd, serverCtx) } +func logRotate(loggerWrite *lumberjack.Logger, intervalByHour int) { + interval := time.Duration(intervalByHour) * time.Hour + for { + nowTime := time.Now().UTC().Truncate(interval) + next := nowTime.Add(interval) + after := next.Unix() - time.Now().Unix() - 1 + <-time.After(time.Duration(after) * time.Second) + loggerWrite.Rotate() + time.Sleep(time.Second) + } +} + // GetServerContextFromCmd returns a Context from a command or an empty Context // if it has not been set. func GetServerContextFromCmd(cmd *cobra.Command) *Context { diff --git a/simapp/app.go b/simapp/app.go index 078bda0193..31e5cd7f7f 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -45,6 +45,7 @@ import ( authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" + vestingkeeper "github.com/cosmos/cosmos-sdk/x/auth/vesting/keeper" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" @@ -190,6 +191,7 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper NFTKeeper nftkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper + VestingKeeper vestingkeeper.VestingKeeper // the module manager ModuleManager *module.Manager @@ -263,7 +265,7 @@ func NewSimApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, - authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, + authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, vestingtypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -309,8 +311,12 @@ func NewSimApp( BlockedAddresses(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) + + app.VestingKeeper = vestingkeeper.NewVestingKeeper(app.AccountKeeper, app.BankKeeper, + keys[vestingtypes.StoreKey]) + app.StakingKeeper = stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.VestingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) app.MintKeeper = mintkeeper.NewKeeper(appCodec, keys[minttypes.StoreKey], app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) @@ -400,7 +406,7 @@ func NewSimApp( encodingConfig.TxConfig, ), auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), + vesting.NewAppModule(app.AccountKeeper, app.BankKeeper, app.VestingKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), diff --git a/simapp/go.mod b/simapp/go.mod index cd749cbf99..ace4bec9bc 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -148,6 +148,7 @@ require ( github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.32.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect + github.com/shopspring/decimal v1.4.0 // indirect github.com/spf13/afero v1.9.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect @@ -177,6 +178,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect google.golang.org/grpc v1.60.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 00ce70f4a2..cccc66de19 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -923,6 +923,8 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1637,6 +1639,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/x/auth/vesting/keeper/genesis.go b/x/auth/vesting/keeper/genesis.go new file mode 100644 index 0000000000..425f999e9a --- /dev/null +++ b/x/auth/vesting/keeper/genesis.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" +) + +// InitGenesis initializes the vesting module state based on genesis state. +func (vk VestingKeeper) InitGenesis(ctx sdk.Context) { + vk.accountKeeper.IterateAccounts(ctx, func(account authtypes.AccountI) bool { + if va, ok := account.(exported.VestingAccount); ok { + vk.AddVestingAccount(ctx, va.GetAddress()) + } + return false + }) +} diff --git a/x/auth/vesting/keeper/keeper.go b/x/auth/vesting/keeper/keeper.go new file mode 100644 index 0000000000..ce0dc9a7d6 --- /dev/null +++ b/x/auth/vesting/keeper/keeper.go @@ -0,0 +1,55 @@ +package keeper + +import ( + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" +) + +type VestingKeeper struct { + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper + key storetypes.StoreKey +} + +func NewVestingKeeper( + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + key storetypes.StoreKey, +) VestingKeeper { + return VestingKeeper{ + accountKeeper, + bankKeeper, + key, + } +} + +// AddVestingAccount adds the address of vesting account to store. +// The caller should check the account type to make sure it's a vesting account type. +func (vk VestingKeeper) AddVestingAccount(ctx sdk.Context, addr sdk.AccAddress) { + store := ctx.KVStore(vk.key) + store.Set(types.VestingAccountStoreKey(addr), []byte{}) +} + +// IterateVestingAccounts iterates over all the stored accounts and performs a callback function. +// Stops iteration when callback returns true. +func (vk VestingKeeper) IterateVestingAccounts(ctx sdk.Context, cb func(account exported.VestingAccount) (stop bool)) { + store := ctx.KVStore(vk.key) + iterator := sdk.KVStorePrefixIterator(store, types.VestingAccountStoreKeyPrefix) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + addr := types.AddressFromVestingAccountKey(iterator.Key()) + + acct := vk.accountKeeper.GetAccount(ctx, addr) + vestingAcct, ok := acct.(exported.VestingAccount) + if !ok { + // not vesting account + continue + } + if cb(vestingAcct) { + break + } + } +} diff --git a/x/auth/vesting/keeper/msg_server.go b/x/auth/vesting/keeper/msg_server.go new file mode 100644 index 0000000000..4a044bfdee --- /dev/null +++ b/x/auth/vesting/keeper/msg_server.go @@ -0,0 +1,219 @@ +package keeper + +import ( + "context" + + "github.com/armon/go-metrics" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" +) + +type msgServer struct { + *VestingKeeper +} + +// NewMsgServerImpl returns an implementation of the vesting MsgServer interface, +// wrapping the corresponding AccountKeeper and BankKeeper. +func NewMsgServerImpl(vk *VestingKeeper) types.MsgServer { + return &msgServer{VestingKeeper: vk} +} + +var _ types.MsgServer = msgServer{} + +func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCreateVestingAccount) (*types.MsgCreateVestingAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + ak := s.accountKeeper + bk := s.bankKeeper + vk := s.VestingKeeper + + if err := bk.IsSendEnabledCoins(ctx, msg.Amount...); err != nil { + return nil, err + } + + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return nil, err + } + + if bk.BlockedAddr(to) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress) + } + + if acc := ak.GetAccount(ctx, to); acc != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) + } + + baseAccount := authtypes.NewBaseAccountWithAddress(to) + baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) + baseVestingAccount := types.NewBaseVestingAccount(baseAccount, msg.Amount.Sort(), msg.EndTime) + + var vestingAccount authtypes.AccountI + if msg.Delayed { + vestingAccount = types.NewDelayedVestingAccountRaw(baseVestingAccount) + } else { + vestingAccount = types.NewContinuousVestingAccountRaw(baseVestingAccount, ctx.BlockTime().Unix()) + } + + ak.SetAccount(ctx, vestingAccount) + vk.AddVestingAccount(ctx, to) + + defer func() { + telemetry.IncrCounter(1, "new", "account") + + for _, a := range msg.Amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "create_vesting_account"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + err = bk.SendCoins(ctx, from, to, msg.Amount) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + return &types.MsgCreateVestingAccountResponse{}, nil +} + +func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *types.MsgCreatePermanentLockedAccount) (*types.MsgCreatePermanentLockedAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + ak := s.accountKeeper + bk := s.bankKeeper + vk := s.VestingKeeper + + if err := bk.IsSendEnabledCoins(ctx, msg.Amount...); err != nil { + return nil, err + } + + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return nil, err + } + + if bk.BlockedAddr(to) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", msg.ToAddress) + } + + if acc := ak.GetAccount(ctx, to); acc != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) + } + + baseAccount := authtypes.NewBaseAccountWithAddress(to) + baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) + vestingAccount := types.NewPermanentLockedAccount(baseAccount, msg.Amount) + + ak.SetAccount(ctx, vestingAccount) + vk.AddVestingAccount(ctx, to) + + defer func() { + telemetry.IncrCounter(1, "new", "account") + + for _, a := range msg.Amount { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "create_permanent_locked_account"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + err = bk.SendCoins(ctx, from, to, msg.Amount) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + + return &types.MsgCreatePermanentLockedAccountResponse{}, nil +} + +func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *types.MsgCreatePeriodicVestingAccount) (*types.MsgCreatePeriodicVestingAccountResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + ak := s.accountKeeper + bk := s.bankKeeper + vk := s.VestingKeeper + + from, err := sdk.AccAddressFromBech32(msg.FromAddress) + if err != nil { + return nil, err + } + to, err := sdk.AccAddressFromBech32(msg.ToAddress) + if err != nil { + return nil, err + } + + if acc := ak.GetAccount(ctx, to); acc != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "account %s already exists", msg.ToAddress) + } + + var totalCoins sdk.Coins + + for _, period := range msg.VestingPeriods { + totalCoins = totalCoins.Add(period.Amount...) + } + + baseAccount := authtypes.NewBaseAccountWithAddress(to) + baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount) + vestingAccount := types.NewPeriodicVestingAccount(baseAccount, totalCoins.Sort(), msg.StartTime, msg.VestingPeriods) + + ak.SetAccount(ctx, vestingAccount) + vk.AddVestingAccount(ctx, to) + + defer func() { + telemetry.IncrCounter(1, "new", "account") + + for _, a := range totalCoins { + if a.Amount.IsInt64() { + telemetry.SetGaugeWithLabels( + []string{"tx", "msg", "create_periodic_vesting_account"}, + float32(a.Amount.Int64()), + []metrics.Label{telemetry.NewLabel("denom", a.Denom)}, + ) + } + } + }() + + err = bk.SendCoins(ctx, from, to, totalCoins) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + ), + ) + return &types.MsgCreatePeriodicVestingAccountResponse{}, nil +} diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 985b51bb62..dce3eeb20e 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -18,8 +18,9 @@ import ( modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" "cosmossdk.io/core/appmodule" - "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/keeper" "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" ) @@ -78,15 +79,17 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - accountKeeper keeper.AccountKeeper + accountKeeper authkeeper.AccountKeeper bankKeeper types.BankKeeper + keeper keeper.VestingKeeper } -func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { +func NewAppModule(ak authkeeper.AccountKeeper, bk types.BankKeeper, vk keeper.VestingKeeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, accountKeeper: ak, bankKeeper: bk, + keeper: vk, } } @@ -132,8 +135,9 @@ func init() { type VestingInputs struct { depinject.In - AccountKeeper keeper.AccountKeeper + AccountKeeper authkeeper.AccountKeeper BankKeeper types.BankKeeper + VestingKeeper keeper.VestingKeeper } type VestingOutputs struct { @@ -143,7 +147,7 @@ type VestingOutputs struct { } func ProvideModule(in VestingInputs) VestingOutputs { - m := NewAppModule(in.AccountKeeper, in.BankKeeper) + m := NewAppModule(in.AccountKeeper, in.BankKeeper, in.VestingKeeper) return VestingOutputs{Module: m} } diff --git a/x/auth/vesting/types/constants.go b/x/auth/vesting/types/constants.go index b385598d6a..1d0b0ebbb3 100644 --- a/x/auth/vesting/types/constants.go +++ b/x/auth/vesting/types/constants.go @@ -4,6 +4,9 @@ const ( // ModuleName defines the module's name. ModuleName = "vesting" + // AttributeValueCategory is an alias for the message event value. + AttributeValueCategory = ModuleName + // RouterKey defines the module's message routing key RouterKey = ModuleName ) diff --git a/x/auth/vesting/types/expected_keepers.go b/x/auth/vesting/types/expected_keepers.go index 5705eea30b..c6883f5455 100644 --- a/x/auth/vesting/types/expected_keepers.go +++ b/x/auth/vesting/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // BankKeeper defines the expected interface contract the vesting module requires @@ -11,3 +12,10 @@ type BankKeeper interface { SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error BlockedAddr(addr sdk.AccAddress) bool } + +type AccountKeeper interface { + NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI + SetAccount(sdk.Context, authtypes.AccountI) + GetAccount(sdk.Context, sdk.AccAddress) authtypes.AccountI + IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) bool) +} diff --git a/x/auth/vesting/types/keys.go b/x/auth/vesting/types/keys.go new file mode 100644 index 0000000000..a803a3fe2c --- /dev/null +++ b/x/auth/vesting/types/keys.go @@ -0,0 +1,24 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" +) + +const ( + // StoreKey is string representation of the store key for vesting + StoreKey = ModuleName +) + +var VestingAccountStoreKeyPrefix = []byte{0x01} + +// VestingAccountStoreKey turn an address to key used to record it in the vesting store +func VestingAccountStoreKey(addr sdk.AccAddress) []byte { + return append(VestingAccountStoreKeyPrefix, addr.Bytes()...) +} + +// AddressFromVestingAccountKey creates the address from VestingAccountKey +func AddressFromVestingAccountKey(key []byte) sdk.AccAddress { + kv.AssertKeyAtLeastLength(key, 1) + return key[1:] // remove prefix byte +} diff --git a/x/mint/abci.go b/x/mint/abci.go index f8f0c8ce41..a0b2ee51ed 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -7,8 +7,47 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/mint/keeper" "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/shopspring/decimal" ) +func decExp(x sdk.Dec) sdk.Dec { + xDec := decimal.NewFromBigInt(x.BigInt(), -18) + expDec, _ := xDec.ExpTaylor(18) + expInt := expDec.Shift(18).BigInt() + return sdk.NewDecFromBigIntWithPrec(expInt, 18) +} + +func NextInflationRate(ctx sdk.Context, params types.Params, bondedRatio sdk.Dec, circulatingRatio sdk.Dec) sdk.Dec { + X := bondedRatio.Quo(circulatingRatio) + ctx.Logger().Info("NextInflationRate", "params", params) + var apy sdk.Dec + if X.LT(params.MinStakedRatio) { + apy = params.ApyAtMinStakedRatio + } else if X.GT(params.MaxStakedRatio) { + apy = params.ApyAtMaxStakedRatio + } else { + exp := params.DecayRate.Neg().Mul(params.MaxStakedRatio.Sub(params.MinStakedRatio)) + c := decExp(exp) + d := params.ApyAtMaxStakedRatio.Sub(params.ApyAtMinStakedRatio.Mul(c)).Quo(sdk.OneDec().Sub(c)) + expBonded := params.DecayRate.Neg().Mul(X.Sub(params.MinStakedRatio)) + cBonded := decExp(expBonded) + e := params.ApyAtMinStakedRatio.Sub(d).Mul(cBonded) + apy = d.Add(e) + } + + inflation := apy.Mul(bondedRatio) + + ctx.Logger().Info( + "nextInflationRate", + "bondedRatio", bondedRatio, + "circulatingRatio", circulatingRatio, + "apy", apy, + "inflation", inflation, + "params", params, + ) + return inflation +} + // BeginBlocker mints new tokens for the previous block. func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculationFn) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) @@ -20,7 +59,8 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper, ic types.InflationCalculatio // recalculate inflation rate totalStakingSupply := k.StakingTokenSupply(ctx) bondedRatio := k.BondedRatio(ctx) - minter.Inflation = ic(ctx, minter, params, bondedRatio) + circulatingRaio := k.CirculatingRatio(ctx) + minter.Inflation = NextInflationRate(ctx, params, bondedRatio, circulatingRaio) minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply) k.SetMinter(ctx, minter) diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index 5a88558613..5905fc779b 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -59,14 +59,13 @@ func (s *GenesisTestSuite) SetupTest() { func (s *GenesisTestSuite) TestImportExportGenesis() { genesisState := types.DefaultGenesisState() genesisState.Minter = types.NewMinter(sdk.NewDecWithPrec(20, 2), math.LegacyNewDec(1)) - genesisState.Params = types.NewParams( - "testDenom", - sdk.NewDecWithPrec(15, 2), - sdk.NewDecWithPrec(22, 2), - sdk.NewDecWithPrec(9, 2), - sdk.NewDecWithPrec(69, 2), - uint64(60*60*8766/5), - ) + genesisState.Params = types.DefaultParams() + genesisState.Params.MintDenom = "testDenom" + genesisState.Params.InflationRateChange = sdk.NewDecWithPrec(15, 2) + genesisState.Params.InflationMax = sdk.NewDecWithPrec(22, 2) + genesisState.Params.InflationMin = sdk.NewDecWithPrec(9, 2) + genesisState.Params.GoalBonded = sdk.NewDecWithPrec(69, 2) + genesisState.Params.BlocksPerYear = uint64(60 * 60 * 8766 / 5) s.keeper.InitGenesis(s.sdkCtx, s.accountKeeper, genesisState) diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 693dbd1da4..c7d9fa8c63 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -110,6 +110,15 @@ func (k Keeper) StakingTokenSupply(ctx sdk.Context) math.Int { return k.stakingKeeper.StakingTokenSupply(ctx) } +func (k Keeper) CirculatingRatio(ctx sdk.Context) sdk.Dec { + circulatingSupply := k.stakingKeeper.StakingTokenCirculatingSupply(ctx) + totalSupply := k.stakingKeeper.StakingTokenSupply(ctx) + if circulatingSupply.IsPositive() { + return sdk.NewDecFromInt(circulatingSupply).QuoInt(totalSupply) + } + return sdk.ZeroDec() +} + // BondedRatio implements an alias call to the underlying staking keeper's // BondedRatio to be used in BeginBlocker. func (k Keeper) BondedRatio(ctx sdk.Context) math.LegacyDec { diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index be363a4298..c408df40e9 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -83,7 +83,13 @@ func RandomizedGenState(simState *module.SimulationState) { mintDenom := sdk.DefaultBondDenom blocksPerYear := uint64(60 * 60 * 8766 / 5) - params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear) + params := types.DefaultParams() + params.MintDenom = mintDenom + params.InflationRateChange = inflationRateChange + params.InflationMax = inflationMax + params.InflationMin = inflationMin + params.GoalBonded = goalBonded + params.BlocksPerYear = blocksPerYear mintGenesis := types.NewGenesisState(types.InitialMinter(inflation), params) diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index 6c590d6c8e..f762fdacf8 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -52,7 +52,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, "stake", mintGenesis.Params.MintDenom) require.Equal(t, "0stake", mintGenesis.Minter.BlockProvision(mintGenesis.Params).String()) require.Equal(t, "0.170000000000000000", mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, math.OneInt()).String()) - require.Equal(t, "0.169999926644441493", mintGenesis.Minter.NextInflationRate(mintGenesis.Params, math.LegacyOneDec()).String()) + require.Equal(t, "0.169999926644441493", mintGenesis.Minter.NextInflationRate(mintGenesis.Params, math.LegacyOneDec(), sdk.ZeroDec()).String()) require.Equal(t, "0.170000000000000000", mintGenesis.Minter.Inflation.String()) require.Equal(t, "0.000000000000000000", mintGenesis.Minter.AnnualProvisions.String()) } diff --git a/x/mint/testutil/expected_keepers_mocks.go b/x/mint/testutil/expected_keepers_mocks.go index c174f75d97..279e3b437e 100644 --- a/x/mint/testutil/expected_keepers_mocks.go +++ b/x/mint/testutil/expected_keepers_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/mint/types/expected_keepers.go +// Source: ./x/mint/types/expected_keepers.go // Package testutil is a generated GoMock package. package testutil @@ -50,6 +50,20 @@ func (mr *MockStakingKeeperMockRecorder) BondedRatio(ctx interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BondedRatio", reflect.TypeOf((*MockStakingKeeper)(nil).BondedRatio), ctx) } +// StakingTokenCirculatingSupply mocks base method. +func (m *MockStakingKeeper) StakingTokenCirculatingSupply(ctx types.Context) math.Int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "StakingTokenCirculatingSupply", ctx) + ret0, _ := ret[0].(math.Int) + return ret0 +} + +// StakingTokenCirculatingSupply indicates an expected call of StakingTokenCirculatingSupply. +func (mr *MockStakingKeeperMockRecorder) StakingTokenCirculatingSupply(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StakingTokenCirculatingSupply", reflect.TypeOf((*MockStakingKeeper)(nil).StakingTokenCirculatingSupply), ctx) +} + // StakingTokenSupply mocks base method. func (m *MockStakingKeeper) StakingTokenSupply(ctx types.Context) math.Int { m.ctrl.T.Helper() diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index 68fb5765bf..d72d67b39b 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -3,12 +3,13 @@ package types // noalias import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // StakingKeeper defines the expected staking keeper type StakingKeeper interface { StakingTokenSupply(ctx sdk.Context) math.Int + StakingTokenCirculatingSupply(ctx sdk.Context) math.Int BondedRatio(ctx sdk.Context) sdk.Dec } @@ -17,8 +18,8 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - SetModuleAccount(sdk.Context, types.ModuleAccountI) - GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI + SetModuleAccount(sdk.Context, authtypes.ModuleAccountI) + GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI } // BankKeeper defines the contract needed to be fulfilled for banking and supply diff --git a/x/mint/types/genesis.go b/x/mint/types/genesis.go index d32c573484..28d6e1ef0e 100644 --- a/x/mint/types/genesis.go +++ b/x/mint/types/genesis.go @@ -10,11 +10,11 @@ import ( // bondedRatio and returns the newly calculated inflation rate. // It can be used to specify a custom inflation calculation logic, instead of relying on the // default logic provided by the sdk. -type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec) sdk.Dec +type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, circulatingRatio sdk.Dec) sdk.Dec // DefaultInflationCalculationFn is the default function used to calculate inflation. -func DefaultInflationCalculationFn(_ sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec) math.LegacyDec { - return minter.NextInflationRate(params, bondedRatio) +func DefaultInflationCalculationFn(_ sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec, circulatingRatio sdk.Dec) math.LegacyDec { + return minter.NextInflationRate(params, bondedRatio, circulatingRatio) } // NewGenesisState creates a new GenesisState object diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 2663329608..1d35438d38 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -80,7 +80,12 @@ type Params struct { // goal of percent bonded atoms GoalBonded github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"goal_bonded"` // expected blocks per year - BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty"` + MaxStakedRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=max_staked_ratio,json=maxStakedRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_staked_ratio"` + ApyAtMaxStakedRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=apy_at_max_staked_ratio,json=apyAtMaxStakedRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"apy_at_max_staked_ratio"` + MinStakedRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=min_staked_ratio,json=minStakedRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_staked_ratio"` + ApyAtMinStakedRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=apy_at_min_staked_ratio,json=apyAtMinStakedRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"apy_at_min_staked_ratio"` + DecayRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=decay_rate,json=decayRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"decay_rate"` } func (m *Params) Reset() { *m = Params{} } @@ -137,34 +142,39 @@ func init() { func init() { proto.RegisterFile("cosmos/mint/v1beta1/mint.proto", fileDescriptor_2df116d183c1e223) } var fileDescriptor_2df116d183c1e223 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4f, 0x8b, 0xd3, 0x40, - 0x18, 0xc6, 0x13, 0xad, 0x81, 0x8e, 0x2e, 0xba, 0xb3, 0x0a, 0x71, 0xc1, 0x74, 0xdd, 0xc3, 0xb2, - 0x0a, 0x9b, 0x50, 0xbc, 0x89, 0xa7, 0xb6, 0xd7, 0x42, 0xc9, 0xcd, 0x82, 0x84, 0x37, 0xc9, 0x98, - 0x0e, 0x4d, 0x66, 0xc2, 0xcc, 0xb4, 0xb4, 0x1f, 0x41, 0x4f, 0x1e, 0x3d, 0xfa, 0x11, 0x3c, 0xf8, - 0x21, 0x7a, 0xb3, 0x78, 0x12, 0x0f, 0x45, 0xda, 0x83, 0x5f, 0x43, 0x32, 0x13, 0x52, 0xf1, 0xb0, - 0xa7, 0x5c, 0xf2, 0xe7, 0x79, 0xde, 0xfc, 0x9e, 0x27, 0x21, 0x2f, 0xf2, 0x12, 0x2e, 0x0b, 0x2e, - 0x83, 0x82, 0x32, 0x15, 0x2c, 0xfb, 0x31, 0x51, 0xd0, 0xd7, 0x37, 0x7e, 0x29, 0xb8, 0xe2, 0xf8, - 0xcc, 0xf8, 0xbe, 0x96, 0x6a, 0xff, 0xfc, 0x71, 0xc6, 0x33, 0xae, 0xfd, 0xa0, 0xba, 0x32, 0xa3, - 0xe7, 0x4f, 0xcd, 0x68, 0x64, 0x8c, 0xfa, 0x39, 0x63, 0x9d, 0x42, 0x41, 0x19, 0x0f, 0xf4, 0xd1, - 0x48, 0x97, 0xdf, 0x6d, 0xe4, 0x8c, 0x29, 0x53, 0x44, 0xe0, 0x29, 0xea, 0x52, 0xf6, 0x3e, 0x07, - 0x45, 0x39, 0x73, 0xed, 0x0b, 0xfb, 0xba, 0x3b, 0x78, 0xb3, 0xd9, 0xf5, 0xac, 0x5f, 0xbb, 0xde, - 0x55, 0x46, 0xd5, 0x6c, 0x11, 0xfb, 0x09, 0x2f, 0x6a, 0x62, 0x7d, 0xba, 0x91, 0xe9, 0x3c, 0x50, - 0xeb, 0x92, 0x48, 0x7f, 0x44, 0x92, 0x1f, 0xdf, 0x6e, 0x50, 0x1d, 0x38, 0x22, 0x49, 0x78, 0xc4, - 0x61, 0x8a, 0x4e, 0x81, 0xb1, 0x05, 0xe4, 0x55, 0xad, 0x25, 0x95, 0x94, 0x33, 0xe9, 0xde, 0x69, - 0x21, 0xe3, 0x91, 0xc1, 0x4e, 0x1a, 0xea, 0xe5, 0x87, 0x0e, 0x72, 0x26, 0x20, 0xa0, 0x90, 0xf8, - 0x19, 0x42, 0xd5, 0x07, 0x8b, 0x52, 0xc2, 0x78, 0x61, 0x5e, 0x29, 0xec, 0x56, 0xca, 0xa8, 0x12, - 0x70, 0x89, 0x9e, 0x34, 0x0d, 0x23, 0x01, 0x8a, 0x44, 0xc9, 0x0c, 0x58, 0x46, 0x5a, 0x29, 0x76, - 0xd6, 0xa0, 0x43, 0x50, 0x64, 0xa8, 0xc1, 0x18, 0xd0, 0xc9, 0x31, 0xb1, 0x80, 0x95, 0x7b, 0xb7, - 0x85, 0xa4, 0x07, 0x0d, 0x72, 0x0c, 0xab, 0xff, 0x22, 0x28, 0x73, 0x3b, 0xed, 0x46, 0x50, 0x86, - 0xdf, 0xa1, 0xfb, 0x19, 0x87, 0x3c, 0x8a, 0x39, 0x4b, 0x49, 0xea, 0xde, 0x6b, 0x21, 0x00, 0x55, - 0xc0, 0x81, 0xe6, 0xe1, 0x2b, 0xf4, 0x30, 0xce, 0x79, 0x32, 0x97, 0x51, 0x49, 0x44, 0xb4, 0x26, - 0x20, 0x5c, 0xe7, 0xc2, 0xbe, 0xee, 0x84, 0x27, 0x46, 0x9e, 0x10, 0xf1, 0x96, 0x80, 0x78, 0xfd, - 0xfc, 0xf3, 0x97, 0x9e, 0xf5, 0xf1, 0xcf, 0xd7, 0x97, 0xee, 0x3f, 0x01, 0x2b, 0xb3, 0x42, 0xe6, - 0x07, 0x18, 0x0c, 0x37, 0x7b, 0xcf, 0xde, 0xee, 0x3d, 0xfb, 0xf7, 0xde, 0xb3, 0x3f, 0x1d, 0x3c, - 0x6b, 0x7b, 0xf0, 0xac, 0x9f, 0x07, 0xcf, 0x9a, 0xbe, 0xb8, 0xb5, 0x66, 0x4d, 0xd1, 0x6d, 0x63, - 0x47, 0x6f, 0xca, 0xab, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x18, 0xb9, 0xae, 0xa4, 0x03, - 0x00, 0x00, + // 504 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x80, 0x1b, 0x18, 0x65, 0xf5, 0x18, 0x6c, 0x1e, 0x88, 0x30, 0x89, 0x74, 0xec, 0x30, 0x0d, + 0xa4, 0x35, 0x9a, 0xb8, 0x21, 0x2e, 0x74, 0xbd, 0x56, 0xaa, 0xc2, 0x89, 0x21, 0x64, 0xbd, 0x24, + 0x5e, 0x66, 0xb5, 0xb1, 0xa3, 0xd8, 0x9b, 0x92, 0xbf, 0xc0, 0x89, 0x23, 0x27, 0xc4, 0x4f, 0xe0, + 0xc0, 0x8f, 0xd8, 0x8d, 0x89, 0x13, 0xe2, 0x30, 0xa1, 0xf6, 0xc0, 0xdf, 0x40, 0xb6, 0xa3, 0x8e, + 0x0e, 0xb1, 0x93, 0x2f, 0x6d, 0xf2, 0x9e, 0xfd, 0x7d, 0xef, 0x25, 0xf1, 0x43, 0x41, 0x22, 0x64, + 0x2e, 0x64, 0x98, 0x33, 0xae, 0xc2, 0xd3, 0xfd, 0x98, 0x2a, 0xd8, 0x37, 0x37, 0xbd, 0xa2, 0x14, + 0x4a, 0xe0, 0x0d, 0x9b, 0xef, 0x99, 0x50, 0x93, 0xdf, 0xbc, 0x9f, 0x89, 0x4c, 0x98, 0x7c, 0xa8, + 0xaf, 0xec, 0xd2, 0xcd, 0x47, 0x76, 0x29, 0xb1, 0x89, 0x66, 0x9f, 0x4d, 0xad, 0x43, 0xce, 0xb8, + 0x08, 0xcd, 0xaf, 0x0d, 0x6d, 0x7f, 0xf3, 0x50, 0x7b, 0xc8, 0xb8, 0xa2, 0x25, 0x3e, 0x44, 0x1d, + 0xc6, 0x8f, 0x26, 0xa0, 0x98, 0xe0, 0xbe, 0xb7, 0xe5, 0xed, 0x76, 0xfa, 0x2f, 0xcf, 0x2e, 0xba, + 0xad, 0x9f, 0x17, 0xdd, 0x9d, 0x8c, 0xa9, 0xe3, 0x93, 0xb8, 0x97, 0x88, 0xbc, 0x21, 0x36, 0x7f, + 0x7b, 0x32, 0x1d, 0x87, 0xaa, 0x2e, 0xa8, 0xec, 0x0d, 0x68, 0xf2, 0xfd, 0xeb, 0x1e, 0x6a, 0x84, + 0x03, 0x9a, 0x44, 0x97, 0x38, 0xcc, 0xd0, 0x3a, 0x70, 0x7e, 0x02, 0x13, 0x5d, 0xd6, 0x29, 0x93, + 0x4c, 0x70, 0xe9, 0xdf, 0x70, 0xe0, 0x58, 0xb3, 0xd8, 0xd1, 0x9c, 0xba, 0xfd, 0x69, 0x19, 0xb5, + 0x47, 0x50, 0x42, 0x2e, 0xf1, 0x63, 0x84, 0xf4, 0x03, 0x23, 0x29, 0xe5, 0x22, 0xb7, 0x2d, 0x45, + 0x1d, 0x1d, 0x19, 0xe8, 0x00, 0x2e, 0xd0, 0x83, 0x79, 0x85, 0xa4, 0x04, 0x45, 0x49, 0x72, 0x0c, + 0x3c, 0xa3, 0x4e, 0x0a, 0xdb, 0x98, 0xa3, 0x23, 0x50, 0xf4, 0xc0, 0x80, 0x31, 0xa0, 0xd5, 0x4b, + 0x63, 0x0e, 0x95, 0x7f, 0xd3, 0x81, 0xe9, 0xce, 0x1c, 0x39, 0x84, 0xea, 0x8a, 0x82, 0x71, 0x7f, + 0xc9, 0xad, 0x82, 0x71, 0xfc, 0x0e, 0xad, 0x64, 0x02, 0x26, 0x24, 0x16, 0x3c, 0xa5, 0xa9, 0x7f, + 0xcb, 0x81, 0x00, 0x69, 0x60, 0xdf, 0xf0, 0xf0, 0x0e, 0xba, 0x17, 0x4f, 0x44, 0x32, 0x96, 0xa4, + 0xa0, 0x25, 0xa9, 0x29, 0x94, 0x7e, 0x7b, 0xcb, 0xdb, 0x5d, 0x8a, 0x56, 0x6d, 0x78, 0x44, 0xcb, + 0x37, 0x14, 0x4a, 0x7c, 0x84, 0xd6, 0x72, 0xa8, 0x88, 0x54, 0x30, 0xa6, 0xa9, 0x7e, 0x7f, 0x4c, + 0xf8, 0xb7, 0x1d, 0xd4, 0x72, 0x37, 0x87, 0xea, 0xb5, 0x81, 0x46, 0x9a, 0x89, 0x4b, 0xf4, 0x10, + 0x8a, 0x9a, 0x80, 0x22, 0xff, 0xe8, 0x96, 0x5d, 0x7c, 0x28, 0x50, 0xd4, 0xaf, 0xd4, 0x70, 0xd1, + 0xa9, 0x7b, 0x63, 0x7c, 0x51, 0xd6, 0x71, 0xd2, 0x1b, 0xe3, 0xff, 0xe9, 0xed, 0xaa, 0x0e, 0xb9, + 0xeb, 0x6d, 0xd1, 0xf9, 0x16, 0xa1, 0x94, 0x26, 0x50, 0x9b, 0x23, 0xe7, 0xaf, 0xb8, 0x18, 0x34, + 0x86, 0xa7, 0xcf, 0xd9, 0x8b, 0x27, 0x1f, 0x3f, 0x77, 0x5b, 0xef, 0x7f, 0x7f, 0x79, 0xe6, 0xff, + 0xb5, 0xaf, 0xb2, 0x73, 0xd5, 0x4e, 0x85, 0xfe, 0xc1, 0xd9, 0x34, 0xf0, 0xce, 0xa7, 0x81, 0xf7, + 0x6b, 0x1a, 0x78, 0x1f, 0x66, 0x41, 0xeb, 0x7c, 0x16, 0xb4, 0x7e, 0xcc, 0x82, 0xd6, 0xe1, 0xd3, + 0x6b, 0xed, 0x0d, 0xc5, 0x14, 0x11, 0xb7, 0xcd, 0xf8, 0x7c, 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff, + 0x2d, 0x8c, 0x47, 0x0e, 0xb9, 0x05, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { @@ -230,6 +240,56 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.DecayRate.Size() + i -= size + if _, err := m.DecayRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size := m.ApyAtMinStakedRatio.Size() + i -= size + if _, err := m.ApyAtMinStakedRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + { + size := m.MinStakedRatio.Size() + i -= size + if _, err := m.MinStakedRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + { + size := m.ApyAtMaxStakedRatio.Size() + i -= size + if _, err := m.ApyAtMaxStakedRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.MaxStakedRatio.Size() + i -= size + if _, err := m.MaxStakedRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a if m.BlocksPerYear != 0 { i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) i-- @@ -330,6 +390,16 @@ func (m *Params) Size() (n int) { if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) } + l = m.MaxStakedRatio.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.ApyAtMaxStakedRatio.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.MinStakedRatio.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.ApyAtMinStakedRatio.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.DecayRate.Size() + n += 1 + l + sovMint(uint64(l)) return n } @@ -673,6 +743,176 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxStakedRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxStakedRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApyAtMaxStakedRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ApyAtMaxStakedRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStakedRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinStakedRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ApyAtMinStakedRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ApyAtMinStakedRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DecayRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + 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 ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DecayRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMint(dAtA[iNdEx:]) diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go index 9605d04705..f28d75e7c9 100644 --- a/x/mint/types/minter.go +++ b/x/mint/types/minter.go @@ -43,7 +43,7 @@ func ValidateMinter(minter Minter) error { } // NextInflationRate returns the new inflation rate for the next hour. -func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec) math.LegacyDec { +func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec, _ sdk.Dec) math.LegacyDec { // The target annual inflation rate is recalculated for each previsions cycle. The // inflation is also subject to a rate change (positive or negative) depending on // the distance from the desired ratio (67%). The maximum rate change possible is diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index cd0c9f6da0..8495eaf670 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -51,7 +51,7 @@ func TestNextInflation(t *testing.T) { for i, tc := range tests { minter.Inflation = tc.setInflation - inflation := minter.NextInflationRate(params, tc.bondedRatio) + inflation := minter.NextInflationRate(params, tc.bondedRatio, sdk.ZeroDec()) diffInflation := inflation.Sub(tc.setInflation) require.True(t, diffInflation.Equal(tc.expChange), @@ -118,7 +118,7 @@ func BenchmarkNextInflation(b *testing.B) { // run the NextInflationRate function b.N times for n := 0; n < b.N; n++ { - minter.NextInflationRate(params, bondedRatio) + minter.NextInflationRate(params, bondedRatio, sdk.ZeroDec()) } } diff --git a/x/mint/types/params.go b/x/mint/types/params.go index d0fb5ae955..a891cea177 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -11,18 +11,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// NewParams returns Params instance with the given values. -func NewParams(mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64) Params { - return Params{ - MintDenom: mintDenom, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, - } -} - // DefaultParams returns default x/mint module parameters. func DefaultParams() Params { return Params{ @@ -32,6 +20,11 @@ func DefaultParams() Params { InflationMin: sdk.NewDecWithPrec(7, 2), GoalBonded: sdk.NewDecWithPrec(67, 2), BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times + MaxStakedRatio: sdk.NewDecWithPrec(80, 2), // 80% + ApyAtMaxStakedRatio: sdk.NewDecWithPrec(5, 2), // 5% + MinStakedRatio: sdk.NewDecWithPrec(25, 2), // 25% + ApyAtMinStakedRatio: sdk.NewDecWithPrec(30, 2), // 30% + DecayRate: sdk.NewDecWithPrec(15, 1), // 1.5 } } diff --git a/x/mint/types/params_legacy.go b/x/mint/types/params_legacy.go index 23354e2f89..c57b795478 100644 --- a/x/mint/types/params_legacy.go +++ b/x/mint/types/params_legacy.go @@ -17,6 +17,11 @@ var ( KeyInflationMin = []byte("InflationMin") KeyGoalBonded = []byte("GoalBonded") KeyBlocksPerYear = []byte("BlocksPerYear") + KeyMaxStakedRatio = []byte("MaxStakedRatio") + KeyApyAtMaxStakedRatio = []byte("ApyAtMaxStakedRatio") + KeyMinStakedRatio = []byte("MinStakedRatio") + KeyApyAtMinStakedRatio = []byte("ApyAtMinStakedRatio") + KeyDecayRate = []byte("DecayRate") ) // Deprecated: ParamTable for minting module. @@ -27,6 +32,7 @@ func ParamKeyTable() paramtypes.KeyTable { // Implements params.ParamSet // // Deprecated. +// Implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), @@ -35,5 +41,15 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin), paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded), paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear), + paramtypes.NewParamSetPair(KeyMaxStakedRatio, &p.MaxStakedRatio, dummyValidate), + paramtypes.NewParamSetPair(KeyApyAtMaxStakedRatio, &p.ApyAtMaxStakedRatio, dummyValidate), + paramtypes.NewParamSetPair(KeyMinStakedRatio, &p.MinStakedRatio, dummyValidate), + paramtypes.NewParamSetPair(KeyApyAtMinStakedRatio, &p.ApyAtMinStakedRatio, dummyValidate), + paramtypes.NewParamSetPair(KeyDecayRate, &p.DecayRate, dummyValidate), } } + +func dummyValidate(i interface{}) error { + // TODO: implement + return nil +} diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index d261ce3fc8..1440ed915b 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -26,6 +26,7 @@ type Keeper struct { cdc codec.BinaryCodec authKeeper types.AccountKeeper bankKeeper types.BankKeeper + vestingKeeper types.VestingKeeper hooks types.StakingHooks authority string } @@ -36,6 +37,7 @@ func NewKeeper( key storetypes.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, + vk types.VestingKeeper, authority string, ) *Keeper { // ensure bonded and not bonded module accounts are set @@ -57,6 +59,7 @@ func NewKeeper( cdc: cdc, authKeeper: ak, bankKeeper: bk, + vestingKeeper: vk, hooks: nil, authority: authority, } diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index 3cf81a06cc..d1fcf8b4be 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -50,12 +50,14 @@ func (s *KeeperTestSuite) SetupTest() { accountKeeper.EXPECT().GetModuleAddress(stakingtypes.BondedPoolName).Return(bondedAcc.GetAddress()) accountKeeper.EXPECT().GetModuleAddress(stakingtypes.NotBondedPoolName).Return(notBondedAcc.GetAddress()) bankKeeper := stakingtestutil.NewMockBankKeeper(ctrl) + vestingKeeper := stakingtestutil.NewMockVestingKeeper(ctrl) keeper := stakingkeeper.NewKeeper( encCfg.Codec, key, accountKeeper, bankKeeper, + vestingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) keeper.SetParams(ctx, stakingtypes.DefaultParams()) diff --git a/x/staking/keeper/pool.go b/x/staking/keeper/pool.go index ae2b089c2e..8aba52723a 100644 --- a/x/staking/keeper/pool.go +++ b/x/staking/keeper/pool.go @@ -4,6 +4,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -68,6 +69,40 @@ func (k Keeper) StakingTokenSupply(ctx sdk.Context) math.Int { return k.bankKeeper.GetSupply(ctx, k.BondDenom(ctx)).Amount } +func (k Keeper) StakingTokenCirculatingSupply(ctx sdk.Context) math.Int { + totalSupply := k.StakingTokenSupply(ctx) + + totalLocked := math.ZeroInt() + k.vestingKeeper.IterateVestingAccounts(ctx, func(vestingAcc vestexported.VestingAccount) bool { + vestingCoins := vestingAcc.GetVestingCoins(ctx.BlockTime()) + for _, coin := range vestingCoins { + if coin.Denom == k.BondDenom(ctx) { + totalLocked = totalLocked.Add(coin.Amount) + break + } else { + ctx.Logger().With("module", "x/staking").Info("non-staking token", + "acc", vestingAcc, + "coin", coin) + } + } + return false + }) + + // k.authKeeper.IterateAccounts(ctx, func(acc authtypes.AccountI) bool { + // if vestingAcc, ok := acc.(vestexported.VestingAccount); ok { + // vestingCoins := vestingAcc.GetVestingCoins(ctx.BlockTime()) + // for _, coin := range vestingCoins { + // if coin.Denom == k.BondDenom(ctx) { + // totalLocked = totalLocked.Add(coin.Amount) + // } + // } + // } + // return false + // }) + + return totalSupply.Sub(totalLocked) +} + // BondedRatio the fraction of the staking tokens which are currently bonded func (k Keeper) BondedRatio(ctx sdk.Context) math.LegacyDec { stakeSupply := k.StakingTokenSupply(ctx) diff --git a/x/staking/module.go b/x/staking/module.go index 4f8294aa4f..9ddaaeab18 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -206,6 +206,7 @@ type StakingInputs struct { Config *modulev1.Module AccountKeeper types.AccountKeeper BankKeeper types.BankKeeper + VestingKeeper types.VestingKeeper Cdc codec.Codec Key *store.KVStoreKey @@ -233,6 +234,7 @@ func ProvideModule(in StakingInputs) StakingOutputs { in.Key, in.AccountKeeper, in.BankKeeper, + in.VestingKeeper, authority.String(), ) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) diff --git a/x/staking/testutil/expected_keepers_mocks.go b/x/staking/testutil/expected_keepers_mocks.go index 375c6ff3c7..9a5e9cb774 100644 --- a/x/staking/testutil/expected_keepers_mocks.go +++ b/x/staking/testutil/expected_keepers_mocks.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/staking/types/expected_keepers.go +// Source: ./x/staking/types/expected_keepers.go // Package testutil is a generated GoMock package. package testutil @@ -10,6 +10,7 @@ import ( math "cosmossdk.io/math" types "github.com/cosmos/cosmos-sdk/types" types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + exported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" types1 "github.com/cosmos/cosmos-sdk/x/staking/types" gomock "github.com/golang/mock/gomock" ) @@ -303,6 +304,41 @@ func (mr *MockBankKeeperMockRecorder) UndelegateCoinsFromModuleToAccount(ctx, se return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UndelegateCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).UndelegateCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) } +// MockVestingKeeper is a mock of VestingKeeper interface. +type MockVestingKeeper struct { + ctrl *gomock.Controller + recorder *MockVestingKeeperMockRecorder +} + +// MockVestingKeeperMockRecorder is the mock recorder for MockVestingKeeper. +type MockVestingKeeperMockRecorder struct { + mock *MockVestingKeeper +} + +// NewMockVestingKeeper creates a new mock instance. +func NewMockVestingKeeper(ctrl *gomock.Controller) *MockVestingKeeper { + mock := &MockVestingKeeper{ctrl: ctrl} + mock.recorder = &MockVestingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockVestingKeeper) EXPECT() *MockVestingKeeperMockRecorder { + return m.recorder +} + +// IterateVestingAccounts mocks base method. +func (m *MockVestingKeeper) IterateVestingAccounts(ctx types.Context, process func(exported.VestingAccount) bool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IterateVestingAccounts", ctx, process) +} + +// IterateVestingAccounts indicates an expected call of IterateVestingAccounts. +func (mr *MockVestingKeeperMockRecorder) IterateVestingAccounts(ctx, process interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateVestingAccounts", reflect.TypeOf((*MockVestingKeeper)(nil).IterateVestingAccounts), ctx, process) +} + // MockValidatorSet is a mock of ValidatorSet interface. type MockValidatorSet struct { ctrl *gomock.Controller diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 05672ee256..c0e4f6a7dc 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" ) // DistributionKeeper expected distribution keeper (noalias) @@ -41,6 +42,10 @@ type BankKeeper interface { BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error } +type VestingKeeper interface { + IterateVestingAccounts(ctx sdk.Context, process func(vestexported.VestingAccount) (stop bool)) +} + // ValidatorSet expected properties for the set of all validators (noalias) type ValidatorSet interface { // iterate through validators by operator address, execute func for each validator