From 3035098798dcad2a995076c23e4a763610536d16 Mon Sep 17 00:00:00 2001 From: jelysn <129082781+jelysn@users.noreply.github.com> Date: Thu, 16 May 2024 18:49:11 +0800 Subject: [PATCH] Add number of commitments counting on commitment params (#488) * add number of commitments counting on commitment params * fix panic in all program rewards query * fix panic in estaking tests * add number of commitments cli command * add eden and edenB committed amount checker * update estaking.rewards query from DecCoins to Coins * update rewards query nil rewards case * fix test in estaking query * update parameter migration script to keep old brokerAddress * Fix event emitting order in BurnEdenBoost function * Update allProgramRewards query to return Coins instead of DecCoins --------- Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com> --- docs/static/openapi.yml | 69 ++-- proto/elys/commitment/params.proto | 10 + proto/elys/estaking/query.proto | 8 +- proto/elys/incentive/query.proto | 16 +- proto/elys/parameter/params.proto | 18 + scripts/examples/commitment/commitment.sh | 7 + scripts/examples/estaking/snapshot_test.sh | 28 ++ scripts/examples/incentive/incentive.sh | 8 +- x/commitment/client/cli/query.go | 1 + .../client/cli/query_show_commitments.go | 27 ++ x/commitment/keeper/commitments.go | 139 ++----- .../keeper/msg_server_uncommit_tokens.go | 33 +- x/commitment/keeper/params.go | 13 + x/commitment/types/params.go | 11 + x/commitment/types/params.pb.go | 352 +++++++++++++++-- x/estaking/keeper/hooks.go | 60 ++- x/estaking/keeper/hooks_staking.go | 8 - x/estaking/keeper/keeper.go | 6 + x/estaking/keeper/keeper_burn_edenB.go | 7 +- x/estaking/keeper/keeper_test.go | 2 +- x/estaking/keeper/query.go | 12 +- x/estaking/keeper/query_test.go | 2 +- x/estaking/types/expected_keepers.go | 3 +- x/estaking/types/query.pb.go | 80 ++-- x/incentive/client/cli/queries.go | 27 ++ x/incentive/client/cli/query.go | 1 + x/incentive/keeper/queries.go | 21 +- x/incentive/migrations/v11_migration.go | 13 +- x/incentive/types/expected_keepers.go | 4 +- x/incentive/types/query.pb.go | 145 ++++--- x/masterchef/types/expected_keepers.go | 3 +- x/parameter/keeper/params.go | 13 + x/parameter/migrations/v3_migration.go | 11 +- x/parameter/types/params.go | 6 + x/parameter/types/params.pb.go | 358 ++++++++++++++++-- 35 files changed, 1133 insertions(+), 389 deletions(-) create mode 100644 scripts/examples/commitment/commitment.sh create mode 100644 scripts/examples/estaking/snapshot_test.sh diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 7a5efed7a..098948200 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -40044,6 +40044,9 @@ paths: custom method signatures required by gogoproto. + number_of_commitments: + type: string + format: uint64 description: >- QueryParamsResponse is response type for the Query/Params RPC method. @@ -40465,11 +40468,11 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a - decimal amount. + Coin defines a token with a denomination and an + amount. - NOTE: The amount field is an Dec which implements the + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -40484,11 +40487,10 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -40538,11 +40540,10 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -40556,11 +40557,10 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -40574,11 +40574,10 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -40592,11 +40591,10 @@ paths: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -85754,6 +85752,9 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + number_of_commitments: + type: string + format: uint64 description: Params defines the parameters for the module. elys.commitment.QueryNumberOfCommitmentsResponse: type: object @@ -85802,6 +85803,9 @@ definitions: method signatures required by gogoproto. + number_of_commitments: + type: string + format: uint64 description: QueryParamsResponse is response type for the Query/Params RPC method. elys.commitment.QueryShowCommitmentsResponse: type: object @@ -86030,9 +86034,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. elys.estaking.DexRewardsTracker: type: object @@ -86237,11 +86241,10 @@ definitions: amount: type: string description: >- - DecCoin defines a token with a denomination and a decimal - amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. @@ -86256,9 +86259,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. description: total defines the sum of all the rewards. elys.commitment.EarnType: @@ -86306,9 +86309,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. elys_staking_rewards: type: array @@ -86320,9 +86323,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. eden_staking_rewards: type: array @@ -86334,9 +86337,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. edenb_staking_rewards: type: array @@ -86348,9 +86351,9 @@ definitions: amount: type: string description: |- - DecCoin defines a token with a denomination and a decimal amount. + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Dec which implements the custom method + NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. elys.incentive.QueryAprResponse: type: object diff --git a/proto/elys/commitment/params.proto b/proto/elys/commitment/params.proto index 5fc2acf63..c79ef98e1 100644 --- a/proto/elys/commitment/params.proto +++ b/proto/elys/commitment/params.proto @@ -15,6 +15,16 @@ message Params { (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; + uint64 number_of_commitments = 3; +} + +message LegacyParams { + option (gogoproto.goproto_stringer) = false; + repeated VestingInfo vesting_infos = 1; + repeated cosmos.base.v1beta1.Coin total_committed = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } message VestingInfo { diff --git a/proto/elys/estaking/query.proto b/proto/elys/estaking/query.proto index 0f6c394a4..6123e8699 100644 --- a/proto/elys/estaking/query.proto +++ b/proto/elys/estaking/query.proto @@ -36,8 +36,8 @@ message QueryRewardsRequest { message DelegationDelegatorReward { string validator_address = 1; - repeated cosmos.base.v1beta1.DecCoin reward = 2 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + repeated cosmos.base.v1beta1.Coin reward = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false ]; } @@ -46,8 +46,8 @@ message QueryRewardsResponse { // rewards defines all the rewards accrued by a delegator. repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; // total defines the sum of all the rewards. - repeated cosmos.base.v1beta1.DecCoin total = 2 [ + repeated cosmos.base.v1beta1.Coin total = 2 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } \ No newline at end of file diff --git a/proto/elys/incentive/query.proto b/proto/elys/incentive/query.proto index 30154228d..011062df3 100644 --- a/proto/elys/incentive/query.proto +++ b/proto/elys/incentive/query.proto @@ -97,21 +97,21 @@ message QueryAllProgramRewardsRequest { } message QueryAllProgramRewardsResponse { - repeated cosmos.base.v1beta1.DecCoin usdc_staking_rewards = 1 [ + repeated cosmos.base.v1beta1.Coin usdc_staking_rewards = 1 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - repeated cosmos.base.v1beta1.DecCoin elys_staking_rewards = 2 [ + repeated cosmos.base.v1beta1.Coin elys_staking_rewards = 2 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - repeated cosmos.base.v1beta1.DecCoin eden_staking_rewards = 3 [ + repeated cosmos.base.v1beta1.Coin eden_staking_rewards = 3 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - repeated cosmos.base.v1beta1.DecCoin edenb_staking_rewards = 4 [ + repeated cosmos.base.v1beta1.Coin edenb_staking_rewards = 4 [ (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } diff --git a/proto/elys/parameter/params.proto b/proto/elys/parameter/params.proto index ad4717ceb..5c277db1e 100644 --- a/proto/elys/parameter/params.proto +++ b/proto/elys/parameter/params.proto @@ -24,3 +24,21 @@ message Params { string broker_address = 4; int64 total_blocks_per_year = 5; } + +message LegacyParams { + option (gogoproto.goproto_stringer) = false; + + string min_commission_rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string max_voting_power = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string min_self_delegation = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string broker_address = 4; +} \ No newline at end of file diff --git a/scripts/examples/commitment/commitment.sh b/scripts/examples/commitment/commitment.sh new file mode 100644 index 000000000..80538db0d --- /dev/null +++ b/scripts/examples/commitment/commitment.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +elysd query commitment number-of-commitments +# number: "395166" + +elysd tx commitment commit-claimed-rewards 503544 ueden --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment commit-claimed-rewards 1678547 uedenb --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 diff --git a/scripts/examples/estaking/snapshot_test.sh b/scripts/examples/estaking/snapshot_test.sh new file mode 100644 index 000000000..b37670052 --- /dev/null +++ b/scripts/examples/estaking/snapshot_test.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +elysd query estaking params + +elysd query staking validators +VALIDATOR=elysvaloper1dd34v384hdfqgajkg0jzp0y5k6qlvhltr73as2 +EDEN_VAL=elysvaloper1gnmpr8vvslp3shcq6e922xr0uq4aa2w5gdzht0 +EDENB_VAL=elysvaloper1wajd6ekh9u37hyghyw4mme59qmjllzuyaceanm + +elysd tx staking delegate $VALIDATOR 10000000000000uelys --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query distribution rewards elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg $VALIDATOR +elysd query distribution rewards elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg $EDEN_VAL +elysd query distribution rewards elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg $EDENB_VAL + +elysd tx estaking withdraw-all-rewards --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd tx commitment commit-claimed-rewards 158762097 ueden --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment commit-claimed-rewards 1066283235 uedenb --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment uncommit-tokens 35235693 ueden --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment commit-claimed-rewards 35235693 ueden --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment uncommit-tokens 304152385 uedenb --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd tx commitment uncommit-tokens 70471386 ueden --from=validator --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd query commitment show-commitments elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg +elysd query estaking rewards elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg +elysd tx estaking withdraw-all-rewards --from=validator --chain-id=elystestnet-1 + +elysd query incentive all-program-rewards elys1g3qnq7apxv964cqj0hza0pnwsw3q920lcc5lyg diff --git a/scripts/examples/incentive/incentive.sh b/scripts/examples/incentive/incentive.sh index d591a9a4c..afc2536d6 100644 --- a/scripts/examples/incentive/incentive.sh +++ b/scripts/examples/incentive/incentive.sh @@ -19,4 +19,10 @@ pools: reward_coins: - amount: "78653292" denom: ueden - rewardsUsd: "901.930122946153613244" \ No newline at end of file + rewardsUsd: "901.930122946153613244" + +elysd query incentive all-program-rewards elys1htv5hgrdjytzp2rd9j08e36974e6x5azzge80l +eden_staking_rewards: [] +edenb_staking_rewards: [] +elys_staking_rewards: [] +usdc_staking_rewards: [] \ No newline at end of file diff --git a/x/commitment/client/cli/query.go b/x/commitment/client/cli/query.go index f03d44b79..6ff7baf4f 100644 --- a/x/commitment/client/cli/query.go +++ b/x/commitment/client/cli/query.go @@ -26,6 +26,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdShowCommitments()) + cmd.AddCommand(CmdNumberOfCommitments()) // this line is used by starport scaffolding # 1 diff --git a/x/commitment/client/cli/query_show_commitments.go b/x/commitment/client/cli/query_show_commitments.go index be2eda7bd..f278caae9 100644 --- a/x/commitment/client/cli/query_show_commitments.go +++ b/x/commitment/client/cli/query_show_commitments.go @@ -35,3 +35,30 @@ func CmdShowCommitments() *cobra.Command { return cmd } + +func CmdNumberOfCommitments() *cobra.Command { + cmd := &cobra.Command{ + Use: "number-of-commitments", + Short: "Query number-of-commitments", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + params := &types.QueryNumberOfCommitmentsRequest{} + res, err := queryClient.NumberOfCommitments(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/commitment/keeper/commitments.go b/x/commitment/keeper/commitments.go index ed65859a8..00ab2833f 100644 --- a/x/commitment/keeper/commitments.go +++ b/x/commitment/keeper/commitments.go @@ -1,17 +1,19 @@ package keeper import ( - errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/elys-network/elys/x/commitment/types" - ptypes "github.com/elys-network/elys/x/parameter/types" ) // SetCommitments set a specific commitments in the store from its index func (k Keeper) SetCommitments(ctx sdk.Context, commitments types.Commitments) { + if !k.HasCommitments(ctx, commitments.Creator) { + params := k.GetParams(ctx) + params.NumberOfCommitments++ + k.SetParams(ctx, params) + } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix)) b := k.cdc.MustMarshal(&commitments) store.Set(types.CommitmentsKey(commitments.Creator), b) @@ -68,8 +70,19 @@ func (k Keeper) GetCommitments(ctx sdk.Context, creator string) types.Commitment return val } +func (k Keeper) HasCommitments(ctx sdk.Context, creator string) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix)) + b := store.Get(types.CommitmentsKey(creator)) + return b != nil +} + // RemoveCommitments removes a commitments from the store func (k Keeper) RemoveCommitments(ctx sdk.Context, creator string) { + if k.HasCommitments(ctx, creator) { + params := k.GetParams(ctx) + params.NumberOfCommitments-- + k.SetParams(ctx, params) + } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix)) store.Delete(types.CommitmentsKey(creator)) } @@ -94,16 +107,8 @@ func (k Keeper) IterateCommitments(ctx sdk.Context, handlerFn func(commitments t // NumberOfCommitments returns total number of commitment items func (k Keeper) TotalNumberOfCommitments(ctx sdk.Context) int64 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CommitmentsKeyPrefix)) - - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - defer iterator.Close() - - numberOfCommitments := int64(0) - for ; iterator.Valid(); iterator.Next() { - numberOfCommitments++ - } - return numberOfCommitments + params := k.GetParams(ctx) + return int64(params.NumberOfCommitments) } func (k Keeper) DeductClaimed(ctx sdk.Context, creator string, denom string, amount math.Int) (types.Commitments, error) { @@ -118,19 +123,13 @@ func (k Keeper) DeductClaimed(ctx sdk.Context, creator string, denom string, amo return commitments, nil } -func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (types.Commitments, error) { +func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) error { // Get the Commitments for the creator commitments := k.GetCommitments(ctx, creator) - addr := sdk.MustAccAddressFromBech32(creator) - err := k.hooks.BeforeEdenBCommitChange(ctx, addr) - if err != nil { - return commitments, err - } - // if deduction amount is zero - if amount.Equal(sdk.ZeroInt()) { - return commitments, nil + if amount.IsZero() { + return nil } // Subtract the amount from the claimed balance @@ -139,109 +138,41 @@ func (k Keeper) BurnEdenBoost(ctx sdk.Context, creator string, denom string, amo if claimed.LT(claimedRemovalAmount) { claimedRemovalAmount = claimed } - err = commitments.SubClaimed(sdk.NewCoin(denom, claimedRemovalAmount)) + err := commitments.SubClaimed(sdk.NewCoin(denom, claimedRemovalAmount)) if err != nil { - return types.Commitments{}, err + return err } amount = amount.Sub(claimedRemovalAmount) - if amount.Equal(sdk.ZeroInt()) { - return commitments, nil + if amount.IsZero() { + return nil } committedAmount := commitments.GetCommittedAmountForDenom(denom) if committedAmount.LT(amount) { amount = committedAmount } - - // Subtract the amount from the committed balance - err = commitments.DeductFromCommitted(denom, amount, uint64(ctx.BlockTime().Unix())) - if err != nil { - return types.Commitments{}, err + if amount.IsZero() { + return nil } - err = k.hooks.CommitmentChanged(ctx, creator, sdk.Coins{sdk.NewCoin(denom, amount)}) + addr := sdk.MustAccAddressFromBech32(creator) + err = k.hooks.BeforeEdenBCommitChange(ctx, addr) if err != nil { - return types.Commitments{}, err + return err } - return commitments, nil -} -func (k Keeper) HandleWithdrawFromCommitment(ctx sdk.Context, commitments *types.Commitments, amount sdk.Coins, sendCoins bool, addr sdk.AccAddress) error { - edenAmount := amount.AmountOf(ptypes.Eden) - edenBAmount := amount.AmountOf(ptypes.EdenB) - commitments.AddClaimed(sdk.NewCoin(ptypes.Eden, edenAmount)) - commitments.AddClaimed(sdk.NewCoin(ptypes.EdenB, edenBAmount)) - k.SetCommitments(ctx, *commitments) - - // Emit Hook commitment changed - err := k.CommitmentChanged(ctx, commitments.Creator, amount) + // Subtract the amount from the committed balance + err = commitments.DeductFromCommitted(denom, amount, uint64(ctx.BlockTime().Unix())) if err != nil { return err } - withdrawCoins := amount. - Sub(sdk.NewCoin(ptypes.Eden, edenAmount)). - Sub(sdk.NewCoin(ptypes.EdenB, edenBAmount)) - - if sendCoins && !withdrawCoins.Empty() { - return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, withdrawCoins) - } - return nil -} - -// Process delegation hook - create commitment entities for delegator and validator -func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delegator string, validator string) error { - _, err := sdk.AccAddressFromBech32(delegator) - if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert address from bech32") - } + k.SetCommitments(ctx, commitments) - _, err = sdk.ValAddressFromBech32(validator) + err = k.hooks.CommitmentChanged(ctx, creator, sdk.Coins{sdk.NewCoin(denom, amount)}) if err != nil { - return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, "unable to convert validator address from bech32") - } - - /***********************************************************/ - ////////////////// Delegator entity ////////////////////////// - /***********************************************************/ - // Get the Commitments for the delegator - commitments := k.GetCommitments(ctx, delegator) - if commitments.IsEmpty() { - k.SetCommitments(ctx, commitments) - - // Emit Hook commitment changed - err := k.CommitmentChanged(ctx, delegator, sdk.Coins{}) - if err != nil { - return err - } - - // Emit blockchain event - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, delegator), - sdk.NewAttribute(types.AttributeAmount, sdk.ZeroInt().String()), - ), - ) - } - - /***************************************************************/ - ////////////////////// Validator entity ///////////////////////// - // Get the Commitments for the validator - commitments = k.GetCommitments(ctx, validator) - if commitments.IsEmpty() { - k.SetCommitments(ctx, commitments) - - // Emit blockchain event - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeCommitmentChanged, - sdk.NewAttribute(types.AttributeCreator, validator), - sdk.NewAttribute(types.AttributeAmount, sdk.ZeroInt().String()), - ), - ) + return err } - return nil } diff --git a/x/commitment/keeper/msg_server_uncommit_tokens.go b/x/commitment/keeper/msg_server_uncommit_tokens.go index 87c4c1d8f..7115e93e1 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens.go @@ -47,32 +47,43 @@ func (k Keeper) UncommitTokens(ctx sdk.Context, addr sdk.AccAddress, denom strin k.SetCommitments(ctx, commitments) liquidCoins := sdk.NewCoins(sdk.NewCoin(denom, amount)) + edenAmount := liquidCoins.AmountOf(ptypes.Eden) + edenBAmount := liquidCoins.AmountOf(ptypes.EdenB) + commitments.AddClaimed(sdk.NewCoin(ptypes.Eden, edenAmount)) + commitments.AddClaimed(sdk.NewCoin(ptypes.EdenB, edenBAmount)) + k.SetCommitments(ctx, commitments) - err = k.HandleWithdrawFromCommitment(ctx, &commitments, liquidCoins, true, addr) + // Emit Hook commitment changed + err = k.CommitmentChanged(ctx, addr.String(), sdk.Coins{sdk.NewCoin(denom, amount)}) if err != nil { return err } - // Emit Hook if Eden is uncommitted - if denom == ptypes.Eden { - err = k.EdenUncommitted(ctx, addr.String(), sdk.NewCoin(denom, amount)) + withdrawCoins := liquidCoins. + Sub(sdk.NewCoin(ptypes.Eden, edenAmount)). + Sub(sdk.NewCoin(ptypes.EdenB, edenBAmount)) + + if !withdrawCoins.Empty() { + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, withdrawCoins) if err != nil { return err } } - // Emit Hook commitment changed - err = k.CommitmentChanged(ctx, addr.String(), sdk.Coins{sdk.NewCoin(denom, amount)}) - if err != nil { - return err - } - // Update total commitment params := k.GetParams(ctx) params.TotalCommitted = params.TotalCommitted.Add(liquidCoins...) k.SetParams(ctx, params) - // Emit blockchain event + // Emit Hook if Eden is uncommitted + if denom == ptypes.Eden { + err = k.EdenUncommitted(ctx, addr.String(), sdk.NewCoin(denom, amount)) + if err != nil { + return err + } + } + + // Emit event ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeCommitmentChanged, diff --git a/x/commitment/keeper/params.go b/x/commitment/keeper/params.go index f91dca460..f31bea0f2 100644 --- a/x/commitment/keeper/params.go +++ b/x/commitment/keeper/params.go @@ -37,3 +37,16 @@ func (k Keeper) GetVestingInfo(ctx sdk.Context, baseDenom string) (*types.Vestin return nil, 0 } + +// GetLegacyParams get all legacy parameters as types.LegacyParams +func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} diff --git a/x/commitment/types/params.go b/x/commitment/types/params.go index e29a6c12b..40e59d420 100644 --- a/x/commitment/types/params.go +++ b/x/commitment/types/params.go @@ -23,3 +23,14 @@ func (p Params) String() string { out, _ := yaml.Marshal(p) return string(out) } + +// Validate validates the set of params +func (p LegacyParams) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p LegacyParams) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/commitment/types/params.pb.go b/x/commitment/types/params.pb.go index d41f17029..d80b7ff18 100644 --- a/x/commitment/types/params.pb.go +++ b/x/commitment/types/params.pb.go @@ -65,8 +65,9 @@ func (EarnType) EnumDescriptor() ([]byte, []int) { // Params defines the parameters for the module. type Params struct { - VestingInfos []*VestingInfo `protobuf:"bytes,1,rep,name=vesting_infos,json=vestingInfos,proto3" json:"vesting_infos,omitempty"` - TotalCommitted github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=total_committed,json=totalCommitted,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_committed"` + VestingInfos []*VestingInfo `protobuf:"bytes,1,rep,name=vesting_infos,json=vestingInfos,proto3" json:"vesting_infos,omitempty"` + TotalCommitted github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=total_committed,json=totalCommitted,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_committed"` + NumberOfCommitments uint64 `protobuf:"varint,3,opt,name=number_of_commitments,json=numberOfCommitments,proto3" json:"number_of_commitments,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -115,6 +116,64 @@ func (m *Params) GetTotalCommitted() github_com_cosmos_cosmos_sdk_types.Coins { return nil } +func (m *Params) GetNumberOfCommitments() uint64 { + if m != nil { + return m.NumberOfCommitments + } + return 0 +} + +type LegacyParams struct { + VestingInfos []*VestingInfo `protobuf:"bytes,1,rep,name=vesting_infos,json=vestingInfos,proto3" json:"vesting_infos,omitempty"` + TotalCommitted github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=total_committed,json=totalCommitted,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total_committed"` +} + +func (m *LegacyParams) Reset() { *m = LegacyParams{} } +func (*LegacyParams) ProtoMessage() {} +func (*LegacyParams) Descriptor() ([]byte, []int) { + return fileDescriptor_92e317feaf73ff7e, []int{1} +} +func (m *LegacyParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LegacyParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyParams.Merge(m, src) +} +func (m *LegacyParams) XXX_Size() int { + return m.Size() +} +func (m *LegacyParams) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyParams.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyParams proto.InternalMessageInfo + +func (m *LegacyParams) GetVestingInfos() []*VestingInfo { + if m != nil { + return m.VestingInfos + } + return nil +} + +func (m *LegacyParams) GetTotalCommitted() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TotalCommitted + } + return nil +} + type VestingInfo struct { BaseDenom string `protobuf:"bytes,1,opt,name=base_denom,json=baseDenom,proto3" json:"base_denom,omitempty"` VestingDenom string `protobuf:"bytes,2,opt,name=vesting_denom,json=vestingDenom,proto3" json:"vesting_denom,omitempty"` @@ -127,7 +186,7 @@ func (m *VestingInfo) Reset() { *m = VestingInfo{} } func (m *VestingInfo) String() string { return proto.CompactTextString(m) } func (*VestingInfo) ProtoMessage() {} func (*VestingInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_92e317feaf73ff7e, []int{1} + return fileDescriptor_92e317feaf73ff7e, []int{2} } func (m *VestingInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -187,45 +246,49 @@ func (m *VestingInfo) GetNumMaxVestings() int64 { func init() { proto.RegisterEnum("elys.commitment.EarnType", EarnType_name, EarnType_value) proto.RegisterType((*Params)(nil), "elys.commitment.Params") + proto.RegisterType((*LegacyParams)(nil), "elys.commitment.LegacyParams") proto.RegisterType((*VestingInfo)(nil), "elys.commitment.VestingInfo") } func init() { proto.RegisterFile("elys/commitment/params.proto", fileDescriptor_92e317feaf73ff7e) } var fileDescriptor_92e317feaf73ff7e = []byte{ - // 506 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x6e, 0xd3, 0x40, - 0x18, 0xf4, 0x26, 0x69, 0x45, 0x36, 0x6d, 0x93, 0xae, 0x40, 0x72, 0xab, 0xd6, 0x89, 0x8a, 0x84, - 0x22, 0xa4, 0xda, 0x14, 0x6e, 0xdc, 0xf2, 0x47, 0x15, 0x29, 0x09, 0x91, 0x0b, 0x95, 0xe0, 0xb2, - 0x72, 0x9c, 0x4d, 0xb0, 0x92, 0xdd, 0x8d, 0xbc, 0x9b, 0x3f, 0xf1, 0x12, 0x1c, 0x39, 0x72, 0xe6, - 0x45, 0xe8, 0xb1, 0x47, 0xc4, 0xa1, 0xa0, 0xe4, 0x0d, 0x78, 0x02, 0xb4, 0x6b, 0xd7, 0x89, 0x38, - 0xf5, 0x64, 0x7f, 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0xac, 0x2c, 0x70, 0xbb, 0xb2, 0xc0, 0x9f, 0x95, 0x05, 0xbe, 0xac, 0x2d, 0xe3, 0x76, 0x6d, 0x19, - 0x3f, 0xd7, 0x96, 0xf1, 0xd1, 0xd9, 0xea, 0xad, 0xae, 0xe7, 0x9c, 0x11, 0x39, 0xe7, 0xe1, 0x48, - 0x0f, 0xce, 0x62, 0xfb, 0xde, 0xf5, 0x4f, 0xe8, 0xed, 0xea, 0x6b, 0x7c, 0xf5, 0x2f, 0x00, 0x00, - 0xff, 0xff, 0x37, 0x4a, 0xd4, 0x4a, 0x0f, 0x03, 0x00, 0x00, + // 546 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x53, 0x3f, 0x6f, 0xd3, 0x40, + 0x1c, 0xb5, 0x93, 0xb4, 0x22, 0x97, 0xb4, 0x49, 0x0f, 0x2a, 0xb9, 0x55, 0xeb, 0x44, 0x45, 0x42, + 0x11, 0x52, 0x6d, 0x5a, 0x36, 0xb6, 0xfc, 0xa3, 0x8a, 0x94, 0xa4, 0x91, 0x0b, 0x95, 0x60, 0x39, + 0xd9, 0xce, 0x25, 0x58, 0x89, 0xef, 0x22, 0xdf, 0xe5, 0x9f, 0xf8, 0x12, 0x8c, 0x8c, 0xcc, 0x7c, + 0x92, 0x2e, 0x48, 0x1d, 0x11, 0x43, 0x41, 0xc9, 0x37, 0x60, 0x65, 0x41, 0x77, 0xe7, 0x26, 0x11, + 0x13, 0x6b, 0x27, 0xfb, 0xf7, 0xde, 0xf3, 0xbd, 0xf7, 0x7e, 0xf2, 0x81, 0x23, 0x3c, 0x9c, 0x33, + 0xdb, 0xa7, 0x61, 0x18, 0xf0, 0x10, 0x13, 0x6e, 0x8f, 0xdc, 0xc8, 0x0d, 0x99, 0x35, 0x8a, 0x28, + 0xa7, 0x30, 0x27, 0x58, 0x6b, 0xcd, 0x1e, 0x3e, 0xe9, 0xd3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+ 0x7e, 0xeb, 0x20, 0xb3, 0x91, 0x0c, 0x1e, 0x03, 0x20, 0xcc, 0x50, 0x17, 0x13, 0x1a, 0x1a, 0x7a, + 0x51, 0x2f, 0xa5, 0x9d, 0xb4, 0x40, 0x6a, 0x02, 0x80, 0x4f, 0xd7, 0x6d, 0x95, 0x22, 0x21, 0x15, + 0xf7, 0x7d, 0x94, 0xe8, 0x18, 0x00, 0x32, 0x0e, 0x91, 0x37, 0xa4, 0xfe, 0x40, 0xad, 0x34, 0xe9, + 0xa4, 0xc9, 0x38, 0xac, 0x48, 0x00, 0x5e, 0x83, 0x9c, 0x90, 0x23, 0x42, 0xa7, 0xa8, 0xe7, 0xfa, + 0x9c, 0x46, 0x46, 0x4a, 0x9c, 0x52, 0xb1, 0x44, 0xa7, 0x1f, 0x77, 0x85, 0x67, 0xff, 0xd1, 0xa9, + 0x41, 0xb8, 0x23, 0xa3, 0xb4, 0xe9, 0xf4, 0xb5, 0x3c, 0x04, 0x96, 0x40, 0x5e, 0xd8, 0x86, 0xee, + 0x0c, 0xc5, 0x71, 0x98, 0xb1, 0x25, 0xcd, 0x77, 0xc9, 0x38, 0x6c, 0xb9, 0xb3, 0xb8, 0x27, 0x7b, + 0xfe, 0x11, 0x3c, 0xaa, 0xbb, 0x11, 0x79, 0x33, 0x1f, 0x61, 0x98, 0x03, 0x99, 0x72, 0xb3, 0x89, + 0x3a, 0xce, 0xe5, 0x85, 0x53, 0x6e, 0xe5, 0x35, 0x98, 0x07, 0xd9, 0xb7, 0x57, 0xb5, 0xea, 0x0a, + 0xd1, 0x05, 0x52, 0x6f, 0xbe, 0xbb, 0x5a, 0x21, 0x09, 0x89, 0xd4, 0xea, 0xed, 0x15, 0x92, 0x84, + 0x7b, 0x60, 0x47, 0x20, 0x95, 0x15, 0x94, 0x82, 0xfb, 0x60, 0xaf, 0xd9, 0x41, 0xad, 0x46, 0xbb, + 0xd1, 0xbe, 0x58, 0xc1, 0x5b, 0x95, 0xc6, 0xcd, 0xc2, 0xd4, 0x6f, 0x17, 0xa6, 0xfe, 0x6b, 0x61, + 0xea, 0x9f, 0x96, 0xa6, 0x76, 0xbb, 0x34, 0xb5, 0xef, 0x4b, 0x53, 0x7b, 0x6f, 0x6f, 0xf4, 0x16, + 0x7f, 0xcf, 0x29, 0xc1, 0x7c, 0x4a, 0xa3, 0x81, 0x1c, 0xec, 0xd9, 0xe6, 0x9d, 0x97, 0x4b, 0xf0, + 0xb6, 0xe5, 0x8d, 0x7c, 0xf9, 0x37, 0x00, 0x00, 0xff, 0xff, 0x57, 0x98, 0x9f, 0x4b, 0x13, 0x04, + 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -244,6 +307,62 @@ func (m *Params) MarshalTo(dAtA []byte) (int, error) { } func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NumberOfCommitments != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NumberOfCommitments)) + i-- + dAtA[i] = 0x18 + } + if len(m.TotalCommitted) > 0 { + for iNdEx := len(m.TotalCommitted) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TotalCommitted[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.VestingInfos) > 0 { + for iNdEx := len(m.VestingInfos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VestingInfos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *LegacyParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LegacyParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -348,6 +467,30 @@ func encodeVarintParams(dAtA []byte, offset int, v uint64) int { return base } func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.VestingInfos) > 0 { + for _, e := range m.VestingInfos { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.TotalCommitted) > 0 { + for _, e := range m.TotalCommitted { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if m.NumberOfCommitments != 0 { + n += 1 + sovParams(uint64(m.NumberOfCommitments)) + } + return n +} + +func (m *LegacyParams) Size() (n int) { if m == nil { return 0 } @@ -428,6 +571,143 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VestingInfos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VestingInfos = append(m.VestingInfos, &VestingInfo{}) + if err := m.VestingInfos[len(m.VestingInfos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalCommitted", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TotalCommitted = append(m.TotalCommitted, types.Coin{}) + if err := m.TotalCommitted[len(m.TotalCommitted)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfCommitments", wireType) + } + m.NumberOfCommitments = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfCommitments |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LegacyParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VestingInfos", wireType) diff --git a/x/estaking/keeper/hooks.go b/x/estaking/keeper/hooks.go index ef061320f..29bc3d74c 100644 --- a/x/estaking/keeper/hooks.go +++ b/x/estaking/keeper/hooks.go @@ -16,9 +16,18 @@ func (k Keeper) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Co if err != nil { return err } - err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenValAddr) - if err != nil { - return err + + del := k.Delegation(ctx, addr, edenValAddr) + if del == nil { + err = k.Keeper.Hooks().BeforeDelegationRemoved(ctx, addr, edenValAddr) + if err != nil { + return err + } + } else { + err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenValAddr) + if err != nil { + return err + } } } @@ -27,9 +36,18 @@ func (k Keeper) CommitmentChanged(ctx sdk.Context, creator string, amount sdk.Co if err != nil { return err } - err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenBValAddr) - if err != nil { - return err + + del := k.Delegation(ctx, addr, edenBValAddr) + if del == nil { + err = k.Keeper.Hooks().BeforeDelegationRemoved(ctx, addr, edenBValAddr) + if err != nil { + return err + } + } else { + err = k.Keeper.Hooks().AfterDelegationModified(ctx, addr, edenBValAddr) + if err != nil { + return err + } } } return nil @@ -73,9 +91,18 @@ func (k Keeper) BeforeEdenCommitChange(ctx sdk.Context, addr sdk.AccAddress) err if err != nil { return err } - err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenValAddr) - if err != nil { - return err + + del := k.Delegation(ctx, addr, edenValAddr) + if del == nil { + err = k.Keeper.Hooks().BeforeDelegationCreated(ctx, addr, edenValAddr) + if err != nil { + return err + } + } else { + err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenValAddr) + if err != nil { + return err + } } return nil } @@ -86,9 +113,18 @@ func (k Keeper) BeforeEdenBCommitChange(ctx sdk.Context, addr sdk.AccAddress) er if err != nil { return err } - err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenBValAddr) - if err != nil { - return err + + del := k.Delegation(ctx, addr, edenBValAddr) + if del == nil { + err = k.Keeper.Hooks().BeforeDelegationCreated(ctx, addr, edenBValAddr) + if err != nil { + return err + } + } else { + err = k.Keeper.Hooks().BeforeDelegationSharesModified(ctx, addr, edenBValAddr) + if err != nil { + return err + } } return nil } diff --git a/x/estaking/keeper/hooks_staking.go b/x/estaking/keeper/hooks_staking.go index 7494e6ca2..258908cb6 100644 --- a/x/estaking/keeper/hooks_staking.go +++ b/x/estaking/keeper/hooks_staking.go @@ -7,14 +7,6 @@ import ( // Creating a commitment object for a delegator if one does not exist: func (k Keeper) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { - // must not run on genesis - if ctx.BlockHeight() <= 1 { - return nil - } - - // Create an entity in commitment module - k.commKeeper.BeforeDelegationCreated(ctx, delAddr.String(), valAddr.String()) - return nil } diff --git a/x/estaking/keeper/keeper.go b/x/estaking/keeper/keeper.go index faeb91a57..d69f1e49c 100644 --- a/x/estaking/keeper/keeper.go +++ b/x/estaking/keeper/keeper.go @@ -184,6 +184,9 @@ func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk. if addrVal.String() == params.EdenCommitVal { commitments := k.commKeeper.GetCommitments(ctx, addrDel.String()) edenCommit := commitments.GetCommittedAmountForDenom(ptypes.Eden) + if edenCommit.IsZero() { + return nil + } return stakingtypes.Delegation{ DelegatorAddress: addrDel.String(), ValidatorAddress: addrVal.String(), @@ -194,6 +197,9 @@ func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk. if addrVal.String() == params.EdenbCommitVal { commitments := k.commKeeper.GetCommitments(ctx, addrDel.String()) edenBCommit := commitments.GetCommittedAmountForDenom(ptypes.EdenB) + if edenBCommit.IsZero() { + return nil + } return stakingtypes.Delegation{ DelegatorAddress: addrDel.String(), ValidatorAddress: addrVal.String(), diff --git a/x/estaking/keeper/keeper_burn_edenB.go b/x/estaking/keeper/keeper_burn_edenB.go index 579433748..59b40bc17 100644 --- a/x/estaking/keeper/keeper_burn_edenB.go +++ b/x/estaking/keeper/keeper_burn_edenB.go @@ -50,11 +50,9 @@ func (k Keeper) BurnEdenBFromElysUnstaking(ctx sdk.Context, delegator sdk.AccAdd } // Burn EdenB in commitment module - commitment, err := k.commKeeper.BurnEdenBoost(ctx, delAddr, ptypes.EdenB, edenBToBurn.TruncateInt()) + err := k.commKeeper.BurnEdenBoost(ctx, delAddr, ptypes.EdenB, edenBToBurn.TruncateInt()) if err != nil { k.Logger(ctx).Error("EdenB burn failure", err) - } else { - k.commKeeper.SetCommitments(ctx, commitment) } } @@ -89,7 +87,6 @@ func (k Keeper) BurnEdenBFromEdenUncommitted(ctx sdk.Context, delegator string, } // Burn EdenB in commitment module - commitment, err := k.commKeeper.BurnEdenBoost(ctx, delegator, ptypes.EdenB, edenBToBurn.TruncateInt()) - k.commKeeper.SetCommitments(ctx, commitment) + err := k.commKeeper.BurnEdenBoost(ctx, delegator, ptypes.EdenB, edenBToBurn.TruncateInt()) return err } diff --git a/x/estaking/keeper/keeper_test.go b/x/estaking/keeper/keeper_test.go index ed6d341fd..52189981e 100644 --- a/x/estaking/keeper/keeper_test.go +++ b/x/estaking/keeper/keeper_test.go @@ -67,7 +67,7 @@ func TestEstakingExtendedFunctions(t *testing.T) { require.Equal(t, edenDel.GetShares(), sdk.NewDec(1000_000)) edenBDel := estakingKeeper.Delegation(ctx, addr, edenBVal.GetOperator()) - require.Equal(t, edenBDel.GetShares(), sdk.NewDec(0)) + require.Nil(t, edenBDel) numDelegations := int64(0) estakingKeeper.IterateDelegations(ctx, addr, func(index int64, delegation stakingtypes.DelegationI) (stop bool) { diff --git a/x/estaking/keeper/query.go b/x/estaking/keeper/query.go index 04f26e4a6..a67eae0d2 100644 --- a/x/estaking/keeper/query.go +++ b/x/estaking/keeper/query.go @@ -38,18 +38,20 @@ func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) ( val := k.Validator(ctx, valAddr) endingPeriod := k.distrKeeper.IncrementValidatorPeriod(ctx, val) delReward := k.distrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) - if delReward == nil { - delReward = []sdk.DecCoin{} - } + finalRewards, _ := delReward.TruncateDecimal() + if finalRewards == nil { + finalRewards = []sdk.Coin{} + } delRewards = append(delRewards, types.DelegationDelegatorReward{ ValidatorAddress: valAddr.String(), - Reward: delReward, + Reward: finalRewards, }) total = total.Add(delReward...) return false }, ) + finalTotalRewards, _ := total.TruncateDecimal() - return &types.QueryRewardsResponse{Rewards: delRewards, Total: total}, nil + return &types.QueryRewardsResponse{Rewards: delRewards, Total: finalTotalRewards}, nil } diff --git a/x/estaking/keeper/query_test.go b/x/estaking/keeper/query_test.go index 041a65d50..a8b7d17a7 100644 --- a/x/estaking/keeper/query_test.go +++ b/x/estaking/keeper/query_test.go @@ -74,5 +74,5 @@ func TestQueryRewards(t *testing.T) { Address: addr.String(), }) require.Nil(t, err) - require.Equal(t, res.Total.String(), "147608.188000000000000000ueden") + require.Equal(t, res.Total.String(), "147608ueden") } diff --git a/x/estaking/types/expected_keepers.go b/x/estaking/types/expected_keepers.go index 0e5b07708..22dd0c8ca 100644 --- a/x/estaking/types/expected_keepers.go +++ b/x/estaking/types/expected_keepers.go @@ -51,8 +51,7 @@ type CommitmentKeeper interface { MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error SetCommitments(sdk.Context, commitmenttypes.Commitments) - BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (commitmenttypes.Commitments, error) - BeforeDelegationCreated(sdk.Context, string, string) error + BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) error } type DistrKeeper interface { diff --git a/x/estaking/types/query.pb.go b/x/estaking/types/query.pb.go index a72e6a6a0..8fc380582 100644 --- a/x/estaking/types/query.pb.go +++ b/x/estaking/types/query.pb.go @@ -160,8 +160,8 @@ func (m *QueryRewardsRequest) GetAddress() string { } type DelegationDelegatorReward struct { - ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - Reward github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"reward"` + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Reward github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"reward"` } func (m *DelegationDelegatorReward) Reset() { *m = DelegationDelegatorReward{} } @@ -204,7 +204,7 @@ func (m *DelegationDelegatorReward) GetValidatorAddress() string { return "" } -func (m *DelegationDelegatorReward) GetReward() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *DelegationDelegatorReward) GetReward() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.Reward } @@ -215,7 +215,7 @@ type QueryRewardsResponse struct { // rewards defines all the rewards accrued by a delegator. Rewards []DelegationDelegatorReward `protobuf:"bytes,1,rep,name=rewards,proto3" json:"rewards"` // total defines the sum of all the rewards. - Total github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=total,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"total"` + Total github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=total,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"total"` } func (m *QueryRewardsResponse) Reset() { *m = QueryRewardsResponse{} } @@ -258,7 +258,7 @@ func (m *QueryRewardsResponse) GetRewards() []DelegationDelegatorReward { return nil } -func (m *QueryRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryRewardsResponse) GetTotal() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.Total } @@ -276,39 +276,39 @@ func init() { func init() { proto.RegisterFile("elys/estaking/query.proto", fileDescriptor_c2581e8c6e0092fb) } var fileDescriptor_c2581e8c6e0092fb = []byte{ - // 504 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x4d, 0x6f, 0x13, 0x31, - 0x10, 0xcd, 0x06, 0x9a, 0x08, 0x57, 0x48, 0x60, 0x82, 0x94, 0xae, 0xaa, 0x6d, 0x59, 0x38, 0x44, - 0xad, 0x62, 0xab, 0x89, 0xf8, 0x01, 0x84, 0x4a, 0x20, 0x4e, 0xb0, 0x47, 0x2e, 0xc8, 0xd9, 0xb5, - 0x8c, 0x95, 0x8d, 0xbd, 0x5d, 0x3b, 0x2d, 0x51, 0xc5, 0x85, 0x1b, 0xb7, 0x4a, 0xfc, 0x0b, 0xae, - 0xfc, 0x89, 0x72, 0xab, 0xc4, 0x85, 0x13, 0xa0, 0x84, 0x1f, 0x82, 0xfc, 0xb1, 0xa5, 0xdb, 0x96, - 0xdc, 0x38, 0xc5, 0x99, 0xf7, 0xe6, 0xcd, 0x9b, 0x97, 0x09, 0xd8, 0xa0, 0xf9, 0x5c, 0x61, 0xaa, - 0x34, 0x99, 0x70, 0xc1, 0xf0, 0xc1, 0x8c, 0x96, 0x73, 0x54, 0x94, 0x52, 0x4b, 0x78, 0xdb, 0x40, - 0xa8, 0x82, 0xc2, 0x0e, 0x93, 0x4c, 0x5a, 0x04, 0x9b, 0x97, 0x23, 0x85, 0x9b, 0x4c, 0x4a, 0x96, - 0x53, 0x4c, 0x0a, 0x8e, 0x89, 0x10, 0x52, 0x13, 0xcd, 0xa5, 0x50, 0x1e, 0x8d, 0x52, 0xa9, 0xa6, - 0x52, 0xe1, 0x31, 0x51, 0x14, 0x1f, 0xee, 0x8d, 0xa9, 0x26, 0x7b, 0x38, 0x95, 0x5c, 0x78, 0x7c, - 0xe7, 0x22,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x53, 0xdf, 0xd3, 0x87, 0xf6, 0x1c, 0xb4, 0x1d, 0xc5, - 0xd8, 0x34, 0x26, 0x7a, 0x97, 0x52, 0xfb, 0xe7, 0xae, 0x3e, 0xc8, 0xaa, 0x1d, 0x32, 0xb0, 0xa6, - 0xa5, 0x26, 0xf9, 0xff, 0x5b, 0xc6, 0xe9, 0x0f, 0x4e, 0x9a, 0x60, 0xcd, 0xee, 0x02, 0x8f, 0x41, - 0xcb, 0xfd, 0xa8, 0xf0, 0xc1, 0x25, 0xd7, 0x57, 0xaf, 0x26, 0x8c, 0x57, 0x51, 0x5c, 0x1a, 0xf1, - 0xce, 0x87, 0x6f, 0xbf, 0x3f, 0x35, 0x1f, 0xc1, 0x18, 0x1b, 0x6e, 0x5f, 0x50, 0x7d, 0x24, 0xcb, - 0x09, 0xbe, 0xee, 0x42, 0xe1, 0xc7, 0x00, 0xb4, 0x7d, 0x9a, 0xf0, 0x5a, 0xed, 0xfa, 0x49, 0x85, - 0x0f, 0x57, 0x72, 0xbc, 0x81, 0xc7, 0xd6, 0x00, 0x86, 0xfd, 0x55, 0x06, 0x7c, 0xe2, 0xf8, 0xd8, - 0x1f, 0xd8, 0xfb, 0xd1, 0xb3, 0xd3, 0x45, 0x14, 0x9c, 0x2d, 0xa2, 0xe0, 0xd7, 0x22, 0x0a, 0x4e, - 0x96, 0x51, 0xe3, 0x6c, 0x19, 0x35, 0xbe, 0x2f, 0xa3, 0xc6, 0xeb, 0xfe, 0x85, 0x80, 0xaf, 0x4a, - 0xbe, 0xfb, 0x2b, 0x6a, 0xb3, 0x1e, 0xb7, 0xec, 0xff, 0x6e, 0xf8, 0x27, 0x00, 0x00, 0xff, 0xff, - 0x1f, 0x57, 0x10, 0xe9, 0x3f, 0x04, 0x00, 0x00, + // 502 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x53, 0x3d, 0x6f, 0x13, 0x41, + 0x10, 0xf5, 0x19, 0x62, 0x8b, 0x8d, 0x90, 0x60, 0x31, 0x92, 0x7d, 0x42, 0x97, 0x70, 0x50, 0x58, + 0x41, 0xde, 0x25, 0x8e, 0xf8, 0x01, 0x18, 0x24, 0x10, 0x15, 0x5c, 0x49, 0x83, 0xd6, 0xbe, 0xd5, + 0x71, 0xf2, 0x79, 0xe7, 0xb2, 0xbb, 0x4e, 0xb0, 0x22, 0x1a, 0x3a, 0xba, 0x48, 0xfc, 0x0b, 0x24, + 0x7e, 0x05, 0x4d, 0xca, 0x48, 0x34, 0x54, 0x80, 0x6c, 0x7e, 0x08, 0xda, 0x0f, 0x87, 0x5c, 0x62, + 0xdc, 0x51, 0x79, 0x3d, 0xef, 0xcd, 0x9b, 0x37, 0xcf, 0x63, 0xd4, 0xe1, 0xc5, 0x4c, 0x51, 0xae, + 0x34, 0x1b, 0xe7, 0x22, 0xa3, 0xfb, 0x53, 0x2e, 0x67, 0xa4, 0x94, 0xa0, 0x01, 0x5f, 0x37, 0x10, + 0x59, 0x42, 0x61, 0x2b, 0x83, 0x0c, 0x2c, 0x42, 0xcd, 0xcb, 0x91, 0xc2, 0x3b, 0x19, 0x40, 0x56, + 0x70, 0xca, 0xca, 0x9c, 0x32, 0x21, 0x40, 0x33, 0x9d, 0x83, 0x50, 0x1e, 0x8d, 0x46, 0xa0, 0x26, + 0xa0, 0xe8, 0x90, 0x29, 0x4e, 0x0f, 0x76, 0x87, 0x5c, 0xb3, 0x5d, 0x3a, 0x82, 0x5c, 0x78, 0x7c, + 0xe7, 0x3c, 0x6e, 0x67, 0x9f, 0xb1, 0x4a, 0x96, 0xe5, 0xc2, 0x8a, 0x79, 0x6e, 0x58, 0x75, 0x5a, + 0x32, 0xc9, 0x26, 0x7e, 0x4e, 0xdc, 0x42, 0xf8, 0x95, 0xe9, 0x7e, 0x69, 0x8b, 0x09, 0xdf, 0x9f, + 0x72, 0xa5, 0xe3, 0x17, 0xe8, 0x56, 0xa5, 0xaa, 0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 0x50, 0xc3, 0xfd, + 0x90, 0xf8, 0xee, 0x05, 0xbf, 0x97, 0x2f, 0x25, 0x8c, 0xd7, 0x51, 0x5c, 0x0e, 0xf1, 0xce, 0x87, + 0x6f, 0xbf, 0x3f, 0xd5, 0xef, 0xe3, 0x98, 0x1a, 0x6e, 0x4f, 0x70, 0x7d, 0x08, 0x72, 0x4c, 0x57, + 0x5d, 0x25, 0xfe, 0x18, 0xa0, 0xa6, 0xcf, 0x11, 0xaf, 0xd4, 0xae, 0x9e, 0x51, 0x78, 0x6f, 0x2d, + 0xc7, 0x1b, 0x78, 0x64, 0x0d, 0x50, 0xdc, 0x5b, 0x67, 0xc0, 0x67, 0x4d, 0x8f, 0xfc, 0x51, 0xbd, + 0x1f, 0x3c, 0x3b, 0x99, 0x47, 0xc1, 0xe9, 0x3c, 0x0a, 0x7e, 0xcd, 0xa3, 0xe0, 0x78, 0x11, 0xd5, + 0x4e, 0x17, 0x51, 0xed, 0xfb, 0x22, 0xaa, 0xbd, 0xee, 0x9d, 0x4b, 0xf7, 0xb2, 0xe4, 0xbb, 0xbf, + 0xa2, 0x36, 0xe8, 0x61, 0xc3, 0xfe, 0xd7, 0xf6, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x5b, + 0xd9, 0xff, 0x33, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1007,7 +1007,7 @@ func (m *DelegationDelegatorReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Reward = append(m.Reward, types.DecCoin{}) + m.Reward = append(m.Reward, types.Coin{}) if err := m.Reward[len(m.Reward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1125,7 +1125,7 @@ func (m *QueryRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Total = append(m.Total, types.DecCoin{}) + m.Total = append(m.Total, types.Coin{}) if err := m.Total[len(m.Total)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/incentive/client/cli/queries.go b/x/incentive/client/cli/queries.go index a4831876f..63a316c51 100644 --- a/x/incentive/client/cli/queries.go +++ b/x/incentive/client/cli/queries.go @@ -114,3 +114,30 @@ func CmdPoolRewards() *cobra.Command { return cmd } + +func CmdAllProgramRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "all-program-rewards [address]", + Short: "calculate all program rewards", + Example: "elysd q incentive all-program-rewards [address]", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllProgramRewardsRequest{ + Address: args[0], + } + res, err := queryClient.AllProgramRewards(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index 283af7025..3719415ce 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -22,6 +22,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdApr()) cmd.AddCommand(CmdAprs()) cmd.AddCommand(CmdPoolRewards()) + cmd.AddCommand(CmdAllProgramRewards()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/incentive/keeper/queries.go b/x/incentive/keeper/queries.go index 98aae43dc..3afe8c12f 100644 --- a/x/incentive/keeper/queries.go +++ b/x/incentive/keeper/queries.go @@ -167,14 +167,14 @@ func (k Keeper) AllProgramRewards(goCtx context.Context, req *types.QueryAllProg k.masterchef.AfterWithdraw(ctx, stablestaketypes.PoolId, req.Address, sdk.ZeroInt()) - stableStakeRewards := sdk.NewDecCoins() + stableStakeRewards := sdk.Coins{} for _, rewardDenom := range k.masterchef.GetRewardDenoms(ctx, stablestaketypes.PoolId) { userRewardInfo, found := k.masterchef.GetUserRewardInfo(ctx, req.Address, stablestaketypes.PoolId, rewardDenom) if found && userRewardInfo.RewardPending.IsPositive() { stableStakeRewards = stableStakeRewards.Add( - sdk.NewDecCoinFromDec( + sdk.NewCoin( rewardDenom, - userRewardInfo.RewardPending, + userRewardInfo.RewardPending.TruncateInt(), ), ) } @@ -182,34 +182,37 @@ func (k Keeper) AllProgramRewards(goCtx context.Context, req *types.QueryAllProg delAddr := sdk.MustAccAddressFromBech32(req.Address) delegations := k.estaking.Keeper.GetDelegatorDelegations(ctx, delAddr, 5000) - elysStakingRewards := sdk.DecCoins{} + elysStakingRewards := sdk.Coins{} for _, del := range delegations { rewards, err := k.estaking.DelegationRewards(ctx, req.Address, del.ValidatorAddress) if err != nil { return nil, err } - elysStakingRewards = elysStakingRewards.Add(rewards...) + finalRewards, _ := rewards.TruncateDecimal() + elysStakingRewards = elysStakingRewards.Add(finalRewards...) } // Eden commit rewards edenVal := k.estaking.GetParams(ctx).EdenCommitVal edenCommitRewards, err := k.estaking.DelegationRewards(ctx, req.Address, edenVal) if err != nil { - return nil, err + edenCommitRewards = []sdk.DecCoin{} } + finalEdenCommitRewards, _ := edenCommitRewards.TruncateDecimal() // EdenB commit rewards edenBVal := k.estaking.GetParams(ctx).EdenbCommitVal edenBCommitRewards, err := k.estaking.DelegationRewards(ctx, req.Address, edenBVal) if err != nil { - return nil, err + edenBCommitRewards = []sdk.DecCoin{} } + finalEdenBCommitRewards, _ := edenBCommitRewards.TruncateDecimal() return &types.QueryAllProgramRewardsResponse{ UsdcStakingRewards: stableStakeRewards, ElysStakingRewards: elysStakingRewards, - EdenStakingRewards: edenCommitRewards, - EdenbStakingRewards: edenBCommitRewards, + EdenStakingRewards: finalEdenCommitRewards, + EdenbStakingRewards: finalEdenBCommitRewards, }, nil } diff --git a/x/incentive/migrations/v11_migration.go b/x/incentive/migrations/v11_migration.go index 71c3d3514..3a82a561f 100644 --- a/x/incentive/migrations/v11_migration.go +++ b/x/incentive/migrations/v11_migration.go @@ -113,6 +113,8 @@ func (m Migrator) V11Migration(ctx sdk.Context) error { edenValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.Eden)) edenBValAddr := sdk.ValAddress(authtypes.NewModuleAddress(ptypes.EdenB)) legacyCommitments := m.commitmentKeeper.GetAllLegacyCommitments(ctx) + commParams := m.commitmentKeeper.GetLegacyParams(ctx) + numberOfCommitments := uint64(0) for _, legacy := range legacyCommitments { creator := legacy.Creator addr, err := sdk.AccAddressFromBech32(creator) @@ -129,9 +131,8 @@ func (m Migrator) V11Migration(ctx sdk.Context) error { VestingTokens: legacy.VestingTokens, } m.commitmentKeeper.SetCommitments(ctx, commitments) - commParams := m.commitmentKeeper.GetParams(ctx) for _, committed := range commitments.CommittedTokens { - if committed.Denom == ptypes.Eden && commParams.TotalCommitted.AmountOf(ptypes.Eden).IsPositive() { + if committed.Denom == ptypes.Eden && committed.Amount.IsPositive() && commParams.TotalCommitted.AmountOf(ptypes.Eden).IsPositive() { err = m.estakingKeeper.Hooks().BeforeDelegationCreated(ctx, addr, edenValAddr) if err != nil { return err @@ -141,7 +142,7 @@ func (m Migrator) V11Migration(ctx sdk.Context) error { return err } } - if committed.Denom == ptypes.EdenB && commParams.TotalCommitted.AmountOf(ptypes.EdenB).IsPositive() { + if committed.Denom == ptypes.EdenB && committed.Amount.IsPositive() && commParams.TotalCommitted.AmountOf(ptypes.EdenB).IsPositive() { err = m.estakingKeeper.Hooks().BeforeDelegationCreated(ctx, addr, edenBValAddr) if err != nil { return err @@ -163,7 +164,13 @@ func (m Migrator) V11Migration(ctx sdk.Context) error { m.masterchefKeeper.AfterDeposit(ctx, stablestaketypes.PoolId, addr.String(), committed.Amount) } } + numberOfCommitments++ } + m.commitmentKeeper.SetParams(ctx, commitmenttypes.Params{ + VestingInfos: commParams.VestingInfos, + TotalCommitted: commParams.TotalCommitted, + NumberOfCommitments: numberOfCommitments, + }) fmt.Println("Finished incentive v11 migration ...") return nil diff --git a/x/incentive/types/expected_keepers.go b/x/incentive/types/expected_keepers.go index 1a797a27a..5fe0905be 100644 --- a/x/incentive/types/expected_keepers.go +++ b/x/incentive/types/expected_keepers.go @@ -18,8 +18,6 @@ import ( // CommitmentKeeper type CommitmentKeeper interface { - // Initiate commitment according to standard staking - BeforeDelegationCreated(sdk.Context, string, string) error // Iterate all commitment IterateCommitments(sdk.Context, func(ctypes.Commitments) (stop bool)) // Update commitment @@ -27,7 +25,7 @@ type CommitmentKeeper interface { // Get commitment GetCommitments(sdk.Context, string) ctypes.Commitments // Burn eden boost - BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (ctypes.Commitments, error) + BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) error } // Staking keeper diff --git a/x/incentive/types/query.pb.go b/x/incentive/types/query.pb.go index bba038b83..6a9460891 100644 --- a/x/incentive/types/query.pb.go +++ b/x/incentive/types/query.pb.go @@ -250,10 +250,10 @@ func (m *QueryAllProgramRewardsRequest) GetAddress() string { } type QueryAllProgramRewardsResponse struct { - UsdcStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=usdc_staking_rewards,json=usdcStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"usdc_staking_rewards"` - ElysStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=elys_staking_rewards,json=elysStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"elys_staking_rewards"` - EdenStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,3,rep,name=eden_staking_rewards,json=edenStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"eden_staking_rewards"` - EdenbStakingRewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,4,rep,name=edenb_staking_rewards,json=edenbStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"edenb_staking_rewards"` + UsdcStakingRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=usdc_staking_rewards,json=usdcStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"usdc_staking_rewards"` + ElysStakingRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=elys_staking_rewards,json=elysStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"elys_staking_rewards"` + EdenStakingRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=eden_staking_rewards,json=edenStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"eden_staking_rewards"` + EdenbStakingRewards github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=edenb_staking_rewards,json=edenbStakingRewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"edenb_staking_rewards"` } func (m *QueryAllProgramRewardsResponse) Reset() { *m = QueryAllProgramRewardsResponse{} } @@ -289,28 +289,28 @@ func (m *QueryAllProgramRewardsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllProgramRewardsResponse proto.InternalMessageInfo -func (m *QueryAllProgramRewardsResponse) GetUsdcStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryAllProgramRewardsResponse) GetUsdcStakingRewards() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.UsdcStakingRewards } return nil } -func (m *QueryAllProgramRewardsResponse) GetElysStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryAllProgramRewardsResponse) GetElysStakingRewards() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.ElysStakingRewards } return nil } -func (m *QueryAllProgramRewardsResponse) GetEdenStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryAllProgramRewardsResponse) GetEdenStakingRewards() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.EdenStakingRewards } return nil } -func (m *QueryAllProgramRewardsResponse) GetEdenbStakingRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryAllProgramRewardsResponse) GetEdenbStakingRewards() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { return m.EdenbStakingRewards } @@ -481,67 +481,66 @@ func init() { func init() { proto.RegisterFile("elys/incentive/query.proto", fileDescriptor_29b04b3fcad26af2) } var fileDescriptor_29b04b3fcad26af2 = []byte{ - // 953 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0xc7, 0xe3, 0xec, 0x26, 0x69, 0x66, 0xd3, 0x40, 0x87, 0xa0, 0x3a, 0x4b, 0x71, 0x52, 0x23, - 0x95, 0x2d, 0x55, 0xec, 0x66, 0x7b, 0xa0, 0x70, 0x40, 0x4d, 0x68, 0x11, 0x3d, 0x11, 0xdc, 0xf4, - 0xc2, 0x65, 0x35, 0x6b, 0x8f, 0x5c, 0x2b, 0xde, 0x19, 0x77, 0xc6, 0x49, 0x58, 0x95, 0x5e, 0x40, - 0x5c, 0x38, 0x21, 0xf5, 0x5b, 0x20, 0x3e, 0x01, 0x9f, 0xa0, 0xc7, 0x22, 0x2e, 0x88, 0x43, 0x41, - 0x09, 0x12, 0x5f, 0x03, 0xbd, 0x99, 0x71, 0xd6, 0xeb, 0xcd, 0xa6, 0xd1, 0xae, 0x72, 0xca, 0x8e, - 0xe7, 0xbd, 0xff, 0xfb, 0xbd, 0x97, 0x37, 0x33, 0x0f, 0x35, 0x69, 0xda, 0x97, 0x7e, 0xc2, 0x42, - 0xca, 0xf2, 0xe4, 0x80, 0xfa, 0x4f, 0xf7, 0xa9, 0xe8, 0x7b, 0x99, 0xe0, 0x39, 0xc7, 0xcb, 0xb0, - 0xe7, 0x9d, 0xec, 0x35, 0x57, 0x43, 0x2e, 0x7b, 0x5c, 0x76, 0xd4, 0xae, 0xa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, 0x19, 0x6f, 0x9c, 0x9e, 0xf9, 0x98, 0xdb, 0xbf, 0xe9, 0x9d, 0xd7, 0xdc, - 0x70, 0xde, 0x55, 0x9c, 0x6d, 0x7c, 0xfb, 0xec, 0xaa, 0xa5, 0x29, 0x8c, 0xd8, 0x20, 0x50, 0xe0, - 0x6e, 0x7f, 0xf9, 0xf2, 0xc8, 0xb1, 0x5e, 0x1d, 0x39, 0xd6, 0x3f, 0x47, 0x8e, 0xf5, 0xf3, 0xb1, - 0x33, 0xf3, 0xea, 0xd8, 0x99, 0xf9, 0xf3, 0xd8, 0x99, 0xf9, 0xc6, 0x2b, 0x75, 0xfe, 0xa8, 0xea, - 0xb7, 0x25, 0x5d, 0x75, 0x0a, 0xba, 0xf3, 0x6a, 0x24, 0xbe, 0xf3, 0x7f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0xc2, 0x17, 0x24, 0xd5, 0xf9, 0x0b, 0x00, 0x00, + // 931 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0x1b, 0x45, + 0x14, 0xce, 0xc6, 0x9b, 0xa4, 0x19, 0xa7, 0x81, 0x0e, 0x41, 0xdd, 0x18, 0xd8, 0xa4, 0x8b, 0x54, + 0x5c, 0x50, 0x76, 0x1b, 0x73, 0xa0, 0x70, 0x40, 0x4d, 0xa0, 0x88, 0x9e, 0x08, 0xdb, 0xf4, 0xc2, + 0xc5, 0x1a, 0x7b, 0x47, 0xdb, 0x55, 0xd6, 0x33, 0xdb, 0x99, 0x4d, 0x82, 0x55, 0x22, 0x24, 0x8e, + 0x9c, 0x90, 0x7a, 0xe7, 0x07, 0x20, 0x7e, 0x48, 0x8f, 0x45, 0x5c, 0x10, 0x87, 0x82, 0x12, 0x24, + 0xfe, 0x06, 0x7a, 0x33, 0xb3, 0xf6, 0x7a, 0x1d, 0xa7, 0x95, 0x4d, 0x4e, 0x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, 0x37, 0xad, 0xe6, 0x72, 0xa8, 0x0f, 0xde, 0x3e, 0x7a, 0x7d, 0x48, 0x24, 0x33, + 0xce, 0x24, 0xc5, 0x77, 0x51, 0x8d, 0x64, 0x42, 0xe1, 0x2f, 0xef, 0xfa, 0xcf, 0x5e, 0x6c, 0xcc, + 0xfd, 0xf9, 0x62, 0xe3, 0x66, 0x9c, 0xe4, 0x8f, 0x0e, 0x3b, 0x40, 0x64, 0x12, 0x69, 0xfe, 0x6c, + 0xc9, 0xe8, 0x20, 0x00, 0x41, 0xd2, 0xbf, 0xcf, 0xf2, 0x10, 0x5c, 0x3d, 0x3c, 0x44, 0x95, 0x46, + 0xbf, 0x77, 0xb6, 0x88, 0xae, 0x95, 0x2e, 0x0d, 0x57, 0x88, 0xae, 0x1e, 0xca, 0xa8, 0xdb, 0x26, + 0x99, 0x68, 0xc3, 0x8f, 0x29, 0x59, 0xeb, 0xe0, 0xbb, 0x93, 0x89, 0x87, 0x32, 0xea, 0x02, 0x26, + 0x8d, 0x28, 0x1b, 0x62, 0xce, 0x4f, 0x87, 0x09, 0x20, 0x05, 0xe6, 0x3e, 0x5a, 0x1d, 0xe8, 0x84, + 0xfb, 0x8e, 0x53, 0x9b, 0x0a, 0x74, 0xc5, 0x08, 0xbd, 0x07, 0x18, 0x80, 0x3a, 0x50, 0xaa, 0x51, + 0xed, 0xe9, 0x50, 0x8d, 0x54, 0x8d, 0x5a, 0xce, 0x29, 0x3c, 0x38, 0x0b, 0x33, 0xe5, 0x14, 0x40, + 0x47, 0x72, 0xaa, 0x30, 0x17, 0x67, 0xca, 0xa9, 0xc2, 0x34, 0xd1, 0x77, 0x86, 0xa0, 0x4b, 0xd3, + 0x47, 0xdf, 0x29, 0x29, 0x1d, 0x46, 0x9f, 0xf6, 0xa5, 0x73, 0x65, 0xb6, 0xe8, 0xd3, 0xbe, 0x1c, + 0x8d, 0x1e, 0x30, 0x97, 0x67, 0x8b, 0x1e, 0x30, 0x47, 0xa3, 0x07, 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 0xf3, 0xe5, 0x86, 0x46, 0xcd, 0xb6, 0x52, 0xf3, 0x01, + 0xbe, 0x75, 0xa1, 0x1a, 0x55, 0xc3, 0xa6, 0xd8, 0xf0, 0xaf, 0x16, 0xba, 0x36, 0x36, 0x7d, 0xf1, + 0xd6, 0xf9, 0x91, 0x4f, 0x98, 0xf0, 0x0d, 0xff, 0x55, 0xcd, 0x8d, 0xce, 0x3b, 0x4a, 0x67, 0x0b, + 0xdf, 0xbe, 0x38, 0x6b, 0x69, 0x0a, 0x6b, 0x34, 0x00, 0x14, 0x72, 0x77, 0xbf, 0x7c, 0x76, 0xea, + 0x5a, 0xcf, 0x4f, 0x5d, 0xeb, 0xef, 0x53, 0xd7, 0xfa, 0xe9, 0xcc, 0x9d, 0x7b, 0x7e, 0xe6, 0xce, + 0xfd, 0x71, 0xe6, 0xce, 0x7d, 0xe3, 0x97, 0x2a, 0x7f, 0x1c, 0xf5, 0xdb, 0x12, 0xae, 0xea, 0x82, + 0xce, 0xa2, 0x5a, 0x7b, 0x3f, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x4f, 0x08, 0x2f, 0xdd, + 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2153,7 +2152,7 @@ func (m *QueryAllProgramRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UsdcStakingRewards = append(m.UsdcStakingRewards, types1.DecCoin{}) + m.UsdcStakingRewards = append(m.UsdcStakingRewards, types1.Coin{}) if err := m.UsdcStakingRewards[len(m.UsdcStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2187,7 +2186,7 @@ func (m *QueryAllProgramRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ElysStakingRewards = append(m.ElysStakingRewards, types1.DecCoin{}) + m.ElysStakingRewards = append(m.ElysStakingRewards, types1.Coin{}) if err := m.ElysStakingRewards[len(m.ElysStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2221,7 +2220,7 @@ func (m *QueryAllProgramRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.EdenStakingRewards = append(m.EdenStakingRewards, types1.DecCoin{}) + m.EdenStakingRewards = append(m.EdenStakingRewards, types1.Coin{}) if err := m.EdenStakingRewards[len(m.EdenStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2255,7 +2254,7 @@ func (m *QueryAllProgramRewardsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.EdenbStakingRewards = append(m.EdenbStakingRewards, types1.DecCoin{}) + m.EdenbStakingRewards = append(m.EdenbStakingRewards, types1.Coin{}) if err := m.EdenbStakingRewards[len(m.EdenbStakingRewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/masterchef/types/expected_keepers.go b/x/masterchef/types/expected_keepers.go index 144a237c8..132deb7be 100644 --- a/x/masterchef/types/expected_keepers.go +++ b/x/masterchef/types/expected_keepers.go @@ -18,12 +18,11 @@ import ( // CommitmentKeeper type CommitmentKeeper interface { - BeforeDelegationCreated(sdk.Context, string, string) error IterateCommitments(sdk.Context, func(ctypes.Commitments) (stop bool)) GetCommitments(sdk.Context, string) ctypes.Commitments SetCommitments(sdk.Context, ctypes.Commitments) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) (ctypes.Commitments, error) + BurnEdenBoost(ctx sdk.Context, creator string, denom string, amount math.Int) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error GetParams(sdk.Context) ctypes.Params } diff --git a/x/parameter/keeper/params.go b/x/parameter/keeper/params.go index 7c81ec2de..6c618ca77 100644 --- a/x/parameter/keeper/params.go +++ b/x/parameter/keeper/params.go @@ -24,3 +24,16 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { b := k.cdc.MustMarshal(¶ms) store.Set([]byte(types.ParamsKey), b) } + +// GetParams get all parameters as types.Params +func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) { + store := ctx.KVStore(k.storeKey) + + b := store.Get([]byte(types.ParamsKey)) + if b == nil { + return + } + + k.cdc.MustUnmarshal(b, ¶ms) + return +} diff --git a/x/parameter/migrations/v3_migration.go b/x/parameter/migrations/v3_migration.go index ddcfbc225..2f71ba68d 100644 --- a/x/parameter/migrations/v3_migration.go +++ b/x/parameter/migrations/v3_migration.go @@ -7,12 +7,13 @@ import ( func (m Migrator) V3Migration(ctx sdk.Context) error { // reset params + legacy := m.keeper.GetLegacyParams(ctx) params := types.NewParams( - sdk.NewDecWithPrec(5, 2), // min commission 0.05 - sdk.NewDecWithPrec(66, 2), // max voting power 0.66 - sdk.NewInt(1), // min self delegation - "elys1m3hduhk4uzxn8mxuvpz02ysndxfwgy5mq60h4c34qqn67xud584qeee3m4", // broker address - 6307200, // total blocks per year + legacy.MinCommissionRate, // min commission 0.05 + legacy.MaxVotingPower, // max voting power 0.66 + legacy.MinSelfDelegation, // min self delegation + legacy.BrokerAddress, // broker address + 6307200, // total blocks per year ) m.keeper.SetParams(ctx, params) diff --git a/x/parameter/types/params.go b/x/parameter/types/params.go index 88ea6fbf0..d5cb57b75 100644 --- a/x/parameter/types/params.go +++ b/x/parameter/types/params.go @@ -100,3 +100,9 @@ func validateBrokerAddress(i interface{}) error { } return nil } + +// String implements the Stringer interface. +func (p LegacyParams) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/parameter/types/params.pb.go b/x/parameter/types/params.pb.go index b8763e201..6d8e684a9 100644 --- a/x/parameter/types/params.pb.go +++ b/x/parameter/types/params.pb.go @@ -79,36 +79,85 @@ func (m *Params) GetTotalBlocksPerYear() int64 { return 0 } +type LegacyParams struct { + MinCommissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=min_commission_rate,json=minCommissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_commission_rate"` + MaxVotingPower github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_voting_power,json=maxVotingPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_voting_power"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` + BrokerAddress string `protobuf:"bytes,4,opt,name=broker_address,json=brokerAddress,proto3" json:"broker_address,omitempty"` +} + +func (m *LegacyParams) Reset() { *m = LegacyParams{} } +func (*LegacyParams) ProtoMessage() {} +func (*LegacyParams) Descriptor() ([]byte, []int) { + return fileDescriptor_b61780a5be327c2b, []int{1} +} +func (m *LegacyParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LegacyParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LegacyParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LegacyParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_LegacyParams.Merge(m, src) +} +func (m *LegacyParams) XXX_Size() int { + return m.Size() +} +func (m *LegacyParams) XXX_DiscardUnknown() { + xxx_messageInfo_LegacyParams.DiscardUnknown(m) +} + +var xxx_messageInfo_LegacyParams proto.InternalMessageInfo + +func (m *LegacyParams) GetBrokerAddress() string { + if m != nil { + return m.BrokerAddress + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "elys.parameter.Params") + proto.RegisterType((*LegacyParams)(nil), "elys.parameter.LegacyParams") } func init() { proto.RegisterFile("elys/parameter/params.proto", fileDescriptor_b61780a5be327c2b) } var fileDescriptor_b61780a5be327c2b = []byte{ - // 352 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xc1, 0x4a, 0xeb, 0x40, - 0x14, 0x86, 0x93, 0xdb, 0xde, 0xc2, 0x0d, 0xdc, 0xa2, 0x51, 0x21, 0x28, 0xa4, 0x45, 0x50, 0xba, - 0x69, 0x82, 0xb8, 0x73, 0x67, 0xed, 0x42, 0x77, 0x25, 0x82, 0xa8, 0x0b, 0x87, 0x49, 0x72, 0x1a, - 0x43, 0x32, 0x73, 0xc2, 0xcc, 0x68, 0xdb, 0xad, 0x4f, 0xe0, 0xd2, 0xa5, 0x8f, 0xd3, 0x65, 0x97, - 0xe2, 0xa2, 0x48, 0xfb, 0x22, 0x92, 0x89, 0x96, 0x6e, 0x75, 0x95, 0x93, 0xf3, 0xcd, 0x7c, 0xfc, - 0xc3, 0x6f, 0xed, 0x41, 0x3e, 0x91, 0x7e, 0x41, 0x05, 0x65, 0xa0, 0x40, 0x54, 0x93, 0xf4, 0x0a, - 0x81, 0x0a, 0xed, 0x66, 0x09, 0xbd, 0x15, 0xdc, 0xdd, 0x4e, 0x30, 0x41, 0x8d, 0xfc, 0x72, 0xaa, - 0x4e, 0xed, 0x3f, 0xd5, 0xac, 0xc6, 0x40, 0x5f, 0xb3, 0xef, 0xac, 0x2d, 0x96, 0x72, 0x12, 0x21, - 0x63, 0xa9, 0x94, 0x29, 0x72, 0x22, 0xa8, 0x02, 0xc7, 0x6c, 0x9b, 0x9d, 0x7f, 0x3d, 0x6f, 0x3a, - 0x6f, 0x19, 0xef, 0xf3, 0xd6, 0x61, 0x92, 0xaa, 0xfb, 0x87, 0xd0, 0x8b, 0x90, 0xf9, 0x11, 0x4a, - 0x86, 0xf2, 0xeb, 0xd3, 0x95, 0x71, 0xe6, 0xab, 0x49, 0x01, 0xd2, 0xeb, 0x43, 0x14, 0x6c, 0xb2, - 0x94, 0x9f, 0xad, 0x4c, 0x01, 0x55, 0x60, 0x5f, 0x5b, 0x1b, 0x8c, 0x8e, 0xc9, 0x23, 0xaa, 0x94, - 0x27, 0xa4, 0xc0, 0x11, 0x08, 0xe7, 0xcf, 0xaf, 0xe4, 0x4d, 0x46, 0xc7, 0x57, 0x5a, 0x33, 0x28, - 0x2d, 0xdf, 0xc9, 0x25, 0xe4, 0x43, 0x12, 0x43, 0x0e, 0x09, 0x55, 0x29, 0x72, 0xa7, 0xf6, 0x63, - 0xf9, 0x05, 0x57, 0x3a, 0xf9, 0x25, 0xe4, 0xc3, 0xfe, 0x4a, 0x64, 0x1f, 0x58, 0xcd, 0x50, 0x60, - 0x06, 0x82, 0xd0, 0x38, 0x16, 0x20, 0xa5, 0x53, 0x2f, 0xd5, 0xc1, 0xff, 0x6a, 0x7b, 0x5a, 0x2d, - 0xed, 0x23, 0x6b, 0x47, 0xa1, 0xa2, 0x39, 0x09, 0x73, 0x8c, 0x32, 0x49, 0x0a, 0x10, 0x64, 0x02, - 0x54, 0x38, 0x7f, 0xdb, 0x66, 0xa7, 0x16, 0xd8, 0x1a, 0xf6, 0x34, 0x1b, 0x80, 0xb8, 0x01, 0x2a, - 0x4e, 0xea, 0x2f, 0xaf, 0x2d, 0xa3, 0x77, 0x3e, 0x5d, 0xb8, 0xe6, 0x6c, 0xe1, 0x9a, 0x1f, 0x0b, - 0xd7, 0x7c, 0x5e, 0xba, 0xc6, 0x6c, 0xe9, 0x1a, 0x6f, 0x4b, 0xd7, 0xb8, 0xf5, 0xd6, 0x42, 0x97, - 0x7d, 0x76, 0x39, 0xa8, 0x11, 0x8a, 0x4c, 0xff, 0xf8, 0xe3, 0xb5, 0xee, 0xf5, 0x03, 0xc2, 0x86, - 0x6e, 0xf5, 0xf8, 0x33, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xe7, 0xd9, 0x9d, 0x1a, 0x02, 0x00, 0x00, + // 378 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0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x6c, 0x77, 0x4d, 0xf2, 0xa8, 0x04, 0xf3, + 0xd8, 0xf8, 0xc6, 0xe8, 0x94, 0x5c, 0xa2, 0x8c, 0xb3, 0x88, 0xe4, 0x38, 0x01, 0x6e, 0xd5, 0xde, + 0x04, 0x6f, 0x31, 0x3a, 0x3d, 0x52, 0x98, 0x51, 0x49, 0x79, 0x71, 0x2e, 0x20, 0x1d, 0x93, 0x10, + 0x52, 0x88, 0xa8, 0x8c, 0x31, 0xb3, 0xea, 0xaf, 0x86, 0xef, 0x67, 0x52, 0x39, 0x3f, 0x84, 0x74, + 0x3c, 0x5c, 0x83, 0xcc, 0xbf, 0x46, 0xcb, 0xe7, 0x98, 0x00, 0x27, 0x34, 0x0c, 0x39, 0x08, 0x61, + 0x35, 0x4a, 0xb4, 0xf7, 0xb5, 0xea, 0xee, 0x54, 0x4d, 0xf3, 0xbf, 0xf1, 0x4b, 0xa2, 0xa4, 0x29, + 0xf1, 0x53, 0x0c, 0x12, 0x41, 0x72, 0xe0, 0xa4, 0x00, 0xca, 0xad, 0x4f, 0x1d, 0xbd, 0x57, 0xf7, + 0x4c, 0x25, 0x0e, 0x94, 0x36, 0x02, 0x7e, 0x02, 0x94, 0x6f, 0x37, 0x6e, 0x6e, 0xdb, 0x5a, 0xf7, + 0xae, 0x66, 0x7c, 0x39, 0x80, 0x88, 0x06, 0xc5, 0xc7, 0x2a, 0xde, 0x65, 0x15, 0xd5, 0x5c, 0x07, + 0x7b, 0xb3, 0xa5, 0xad, 0xcf, 0x97, 0xb6, 0xfe, 0xb8, 0xb4, 0xf5, 0xeb, 0x95, 0xad, 0xcd, 0x57, + 0xb6, 0x76, 0xbf, 0xb2, 0xb5, 0x53, 0x67, 0xc3, 0x41, 0x99, 0x93, 0x7e, 0x06, 0x72, 0x82, 0x3c, + 0x51, 0x17, 0x77, 0xba, 0x91, 0x29, 0xe5, 0xc6, 0x6f, 0xaa, 0xb4, 0x6c, 0x3d, 0x05, 0x00, 0x00, + 0xff, 0xff, 0x48, 0x4f, 0x3f, 0x9c, 0x72, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -176,6 +225,66 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LegacyParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LegacyParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LegacyParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BrokerAddress) > 0 { + i -= len(m.BrokerAddress) + copy(dAtA[i:], m.BrokerAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.BrokerAddress))) + i-- + dAtA[i] = 0x22 + } + { + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MaxVotingPower.Size() + i -= size + if _, err := m.MaxVotingPower.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.MinCommissionRate.Size() + i -= size + if _, err := m.MinCommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -209,6 +318,25 @@ func (m *Params) Size() (n int) { return n } +func (m *LegacyParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MinCommissionRate.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxVotingPower.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinSelfDelegation.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.BrokerAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -418,6 +546,190 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *LegacyParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LegacyParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LegacyParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCommissionRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinCommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxVotingPower", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxVotingPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BrokerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BrokerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0