Skip to content

Commit

Permalink
Add number of commitments counting on commitment params (#488)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
jelysn and cosmic-vagabond authored May 16, 2024
1 parent 5b3baee commit 3035098
Show file tree
Hide file tree
Showing 35 changed files with 1,133 additions and 389 deletions.
69 changes: 36 additions & 33 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions proto/elys/commitment/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions proto/elys/estaking/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
Expand All @@ -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"
];
}
16 changes: 8 additions & 8 deletions proto/elys/incentive/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
}

Expand Down
18 changes: 18 additions & 0 deletions proto/elys/parameter/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions scripts/examples/commitment/commitment.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions scripts/examples/estaking/snapshot_test.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion scripts/examples/incentive/incentive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ pools:
reward_coins:
- amount: "78653292"
denom: ueden
rewardsUsd: "901.930122946153613244"
rewardsUsd: "901.930122946153613244"

elysd query incentive all-program-rewards elys1htv5hgrdjytzp2rd9j08e36974e6x5azzge80l
eden_staking_rewards: []
edenb_staking_rewards: []
elys_staking_rewards: []
usdc_staking_rewards: []
1 change: 1 addition & 0 deletions x/commitment/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions x/commitment/client/cli/query_show_commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading

0 comments on commit 3035098

Please sign in to comment.