diff --git a/app/app.go b/app/app.go index 2315181..979043c 100644 --- a/app/app.go +++ b/app/app.go @@ -999,4 +999,7 @@ func (app *App) setupUpgradeHandlers() { app.UpgradeKeeper.SetUpgradeHandler("v0.10.0", func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return app.mm.RunMigrations(ctx, app.configurator, fromVM) }) + app.UpgradeKeeper.SetUpgradeHandler("v0.10.3", func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) } diff --git a/proto/planetmintgo/dao/params.proto b/proto/planetmintgo/dao/params.proto index 4aa40ed..b80f881 100644 --- a/proto/planetmintgo/dao/params.proto +++ b/proto/planetmintgo/dao/params.proto @@ -25,4 +25,5 @@ message Params { int64 mqtt_response_timeout = 14; string claim_address = 15; uint64 tx_gas_limit = 16; + uint64 validator_pop_reward = 17; } diff --git a/x/dao/keeper/migrations.go b/x/dao/keeper/migrations.go index bb4862e..73948b7 100644 --- a/x/dao/keeper/migrations.go +++ b/x/dao/keeper/migrations.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" v2 "github.com/planetmint/planetmint-go/x/dao/migrations/v2" + v3 "github.com/planetmint/planetmint-go/x/dao/migrations/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -19,3 +20,7 @@ func NewMigrator(keeper Keeper) Migrator { func (m Migrator) Migrate1to2(ctx sdk.Context) error { return v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) } + +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v3.MigrateParams(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/dao/keeper/params.go b/x/dao/keeper/params.go index 53d154f..7f8f418 100644 --- a/x/dao/keeper/params.go +++ b/x/dao/keeper/params.go @@ -42,3 +42,7 @@ func (k Keeper) GetTxGasLimit(ctx sdk.Context) (txGasLimit uint64) { func (k Keeper) GetClaimAddress(ctx sdk.Context) (claimAddress string) { return k.GetParams(ctx).ClaimAddress } + +func (k Keeper) GetValidatorPoPReward(ctx sdk.Context) (validatorPoPReward uint64) { + return k.GetParams(ctx).ValidatorPopReward +} diff --git a/x/dao/migrations/v3/params.go b/x/dao/migrations/v3/params.go new file mode 100644 index 0000000..8a2ece3 --- /dev/null +++ b/x/dao/migrations/v3/params.go @@ -0,0 +1,31 @@ +package v3 + +import ( + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/planetmint/planetmint-go/x/dao/types" +) + +func MigrateParams(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + paramBytes := store.Get(types.KeyPrefix(types.ParamsKey)) + + var params types.Params + err := cdc.Unmarshal(paramBytes, ¶ms) + if err != nil { + return err + } + + params.ValidatorPopReward = 1 + + // migratedParams := types.NewParams(params.MintAddress, params.TokenDenom, params.StagedDenom, params.ClaimDenom, params.ReissuanceAsset, params.ReissuanceEpochs, params.PopEpochs, params.DistributionOffset, params.DistributionAddressEarlyInv, params.DistributionAddressInvestor, params.DistributionAddressStrategic, params.DistributionAddressDao, params.DistributionAddressPop, params.MqttResponseTimeout, params.ClaimAddress, params.TxGasLimit, 1) + bz, err := cdc.Marshal(¶ms) + if err != nil { + return err + } + + store.Set(types.KeyPrefix(types.ParamsKey), bz) + + return nil +} diff --git a/x/dao/module.go b/x/dao/module.go index 842f58e..fb91048 100644 --- a/x/dao/module.go +++ b/x/dao/module.go @@ -122,6 +122,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate1to2); err != nil { panic(fmt.Errorf("failed to register migration of %s to v2: %w", types.ModuleName, err)) } + if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate2to3); err != nil { + panic(fmt.Errorf("failed to register migration of %s to v3: %w", types.ModuleName, err)) + } } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) diff --git a/x/dao/types/params.go b/x/dao/types/params.go index 398c72b..6df3ede 100644 --- a/x/dao/types/params.go +++ b/x/dao/types/params.go @@ -17,7 +17,7 @@ func NewParams(mintAddress string, tokenDenom string, stagedDenom string, claimDenom string, reissuanceAsset string, reissuanceEpochs int64, popEpochs int64, distributionOffset int64, distributionAddressEarlyInv string, distributionAddressInvestor string, distributionAddressStrategic string, distributionAddressDao string, distributionAddressPop string, - mqttResponseTimeout int64, claimAddress string, txGasLimit uint64) Params { + mqttResponseTimeout int64, claimAddress string, txGasLimit uint64, validatorPoPReward uint64) Params { return Params{ MintAddress: mintAddress, TokenDenom: tokenDenom, @@ -42,6 +42,7 @@ func NewParams(mintAddress string, tokenDenom string, stagedDenom string, MqttResponseTimeout: mqttResponseTimeout, ClaimAddress: claimAddress, TxGasLimit: txGasLimit, + ValidatorPopReward: validatorPoPReward, } } @@ -63,7 +64,9 @@ func DefaultParams() Params { "vjTvXCFSReRsZ7grdsAreRR12KuKpDw8idueQJK9Yh1BYS7ggAqgvCxCgwh13KGK6M52y37HUmvr4GdD", 2000, "plmnt1m5apfematgm7uueazhk482026ert95x2l2dx78", - 200000) + 200000, + 1, + ) } // ParamSetPairs get the params.ParamSet diff --git a/x/dao/types/params.pb.go b/x/dao/types/params.pb.go index 9667132..3a1238c 100644 --- a/x/dao/types/params.pb.go +++ b/x/dao/types/params.pb.go @@ -41,6 +41,7 @@ type Params struct { MqttResponseTimeout int64 `protobuf:"varint,14,opt,name=mqtt_response_timeout,json=mqttResponseTimeout,proto3" json:"mqtt_response_timeout,omitempty"` ClaimAddress string `protobuf:"bytes,15,opt,name=claim_address,json=claimAddress,proto3" json:"claim_address,omitempty"` TxGasLimit uint64 `protobuf:"varint,16,opt,name=tx_gas_limit,json=txGasLimit,proto3" json:"tx_gas_limit,omitempty"` + ValidatorPopReward uint64 `protobuf:"varint,17,opt,name=validator_pop_reward,json=validatorPopReward,proto3" json:"validator_pop_reward,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -187,6 +188,13 @@ func (m *Params) GetTxGasLimit() uint64 { return 0 } +func (m *Params) GetValidatorPopReward() uint64 { + if m != nil { + return m.ValidatorPopReward + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "planetmintgo.dao.Params") } @@ -194,38 +202,40 @@ func init() { func init() { proto.RegisterFile("planetmintgo/dao/params.proto", fileDescriptor_a58575036b3ad531) } var fileDescriptor_a58575036b3ad531 = []byte{ - // 493 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xb1, 0x6f, 0x13, 0x31, - 0x14, 0xc6, 0x73, 0x34, 0x0d, 0xc4, 0x49, 0x69, 0x70, 0x01, 0x59, 0x40, 0x2e, 0x01, 0x96, 0x20, - 0x44, 0x4e, 0x82, 0x05, 0xb1, 0xb5, 0xa4, 0x42, 0x91, 0x90, 0xa8, 0x02, 0x13, 0x8b, 0xe5, 0xdc, - 0xb9, 0x57, 0x8b, 0x9c, 0x9f, 0x39, 0xbf, 0x44, 0xe9, 0x7f, 0xc1, 0xc8, 0xc8, 0x9f, 0xc3, 0xd8, - 0x91, 0x11, 0x25, 0xff, 0x06, 0x03, 0xb2, 0xef, 0xa2, 0x5e, 0xa5, 0x64, 0xb3, 0xbe, 0xef, 0xf7, - 0x7d, 0xb6, 0xac, 0xf7, 0x48, 0xd7, 0xcc, 0x84, 0x96, 0x98, 0x29, 0x8d, 0x29, 0x44, 0x89, 0x80, - 0xc8, 0x88, 0x5c, 0x64, 0x76, 0x68, 0x72, 0x40, 0xa0, 0x9d, 0xaa, 0x3d, 0x4c, 0x04, 0x3c, 0xba, - 0x9f, 0x42, 0x0a, 0xde, 0x8c, 0xdc, 0xa9, 0xe0, 0x9e, 0xfd, 0xdb, 0x27, 0x8d, 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b9, 0x99, 0x03, 0x00, 0x00, + // 521 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xc1, 0x6e, 0x13, 0x3d, + 0x14, 0x85, 0x33, 0x7f, 0xf3, 0x07, 0xe2, 0xa4, 0x34, 0x75, 0x0b, 0xb2, 0x80, 0x4c, 0x02, 0x6c, + 0x82, 0x10, 0x19, 0x04, 0x1b, 0xc4, 0xae, 0x25, 0x15, 0x8a, 0x84, 0x44, 0x14, 0x58, 0xb1, 0xb1, + 0x9c, 0x8c, 0x3b, 0xb5, 0xc8, 0xcc, 0x35, 0xf6, 0x4d, 0x48, 0xdf, 0x82, 0x25, 0x4b, 0x9e, 0x80, + 0xe7, 0x60, 0xd9, 0x25, 0x4b, 0x94, 0xbc, 0x08, 0xb2, 0x67, 0x42, 0x07, 0x29, 0xd9, 0x59, 0xe7, + 0x7c, 0xe7, 0xd8, 0xb2, 0xee, 0x25, 0x6d, 0x3d, 0x13, 0x99, 0xc4, 0x54, 0x65, 0x98, 0x40, 0x14, + 0x0b, 0x88, 0xb4, 0x30, 0x22, 0xb5, 0x7d, 0x6d, 0x00, 0x81, 0xb6, 0xca, 0x76, 0x3f, 0x16, 0x70, + 0xf7, 0x38, 0x81, 0x04, 0xbc, 0x19, 0xb9, 0x53, 0xce, 0x3d, 0xfc, 0x51, 0x23, 0xb5, 0x91, 0x0f, + 0xd2, 0x07, 0xa4, 0xe9, 0x70, 0x2e, 0xe2, 0xd8, 0x48, 0x6b, 0x59, 0xd0, 0x0d, 0x7a, 0xf5, 0x71, + 0xc3, 0x69, 0x27, 0xb9, 0x44, 0x3b, 0xa4, 0x81, 0xf0, 0x49, 0x66, 0x3c, 0x96, 0x19, 0xa4, 0xec, + 0x3f, 0x4f, 0x10, 0x2f, 0x0d, 0x9c, 0xe2, 0x3a, 0x2c, 0x8a, 0x44, 0xc6, 0x05, 0xb1, 0x97, 0x77, +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, 0x3b, 0xfd, 0x8c, 0xc8, 0x8d, 0xb4, 0x1a, 0x32, 0x2b, + 0x39, 0xaa, 0x54, 0xc2, 0x1c, 0xd9, 0x2d, 0xff, 0xeb, 0x47, 0xce, 0x1c, 0x17, 0xde, 0x87, 0xdc, + 0xa2, 0x8f, 0xc8, 0x7e, 0x3e, 0x3f, 0x9b, 0x39, 0x3d, 0xf0, 0x57, 0x34, 0xbd, 0xb8, 0x19, 0xd4, + 0x2e, 0x69, 0xe2, 0x92, 0x27, 0xc2, 0xf2, 0x99, 0x4a, 0x15, 0xb2, 0x56, 0x37, 0xe8, 0x55, 0xc7, + 0x04, 0x97, 0x6f, 0x84, 0x7d, 0xeb, 0x14, 0xfa, 0x8c, 0x1c, 0x2f, 0xc4, 0x4c, 0xc5, 0x02, 0xc1, + 0xb8, 0x97, 0x72, 0x23, 0xbf, 0x08, 0x13, 0xb3, 0x43, 0x4f, 0xd2, 0xbf, 0xde, 0x08, 0xf4, 0xd8, + 0x3b, 0xaf, 0xaa, 0xdf, 0xbe, 0x77, 0x2a, 0xa7, 0xc3, 0x9f, 0xab, 0x30, 0xb8, 0x5a, 0x85, 0xc1, + 0xef, 0x55, 0x18, 0x7c, 0x5d, 0x87, 0x95, 0xab, 0x75, 0x58, 0xf9, 0xb5, 0x0e, 0x2b, 0x1f, 0xa3, + 0x44, 0xe1, 0xc5, 0x7c, 0xd2, 0x9f, 0x42, 0x1a, 0x5d, 0x6f, 0x5f, 0xe9, 0xf8, 0x34, 0x81, 0x68, + 0xe9, 0x57, 0x15, 0x2f, 0xb5, 0xb4, 0x93, 0x9a, 0x5f, 0xc1, 0x17, 0x7f, 0x02, 0x00, 0x00, 0xff, + 0xff, 0x67, 0x5d, 0xde, 0x8f, 0xcb, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -248,6 +258,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ValidatorPopReward != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.ValidatorPopReward)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } if m.TxGasLimit != 0 { i = encodeVarintParams(dAtA, i, uint64(m.TxGasLimit)) i-- @@ -431,6 +448,9 @@ func (m *Params) Size() (n int) { if m.TxGasLimit != 0 { n += 2 + sovParams(uint64(m.TxGasLimit)) } + if m.ValidatorPopReward != 0 { + n += 2 + sovParams(uint64(m.ValidatorPopReward)) + } return n } @@ -916,6 +936,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorPopReward", wireType) + } + m.ValidatorPopReward = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorPopReward |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])