Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/mint): remove inflation_rewards_ratio param #305

Merged
merged 7 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import (
"github.com/archway-network/archway/wasmbinding"
"github.com/archway-network/archway/x/rewards"
rewardsKeeper "github.com/archway-network/archway/x/rewards/keeper"
"github.com/archway-network/archway/x/rewards/mintbankkeeper"
rewardsTypes "github.com/archway-network/archway/x/rewards/types"
"github.com/archway-network/archway/x/tracking"
trackingKeeper "github.com/archway-network/archway/x/tracking/keeper"
Expand Down Expand Up @@ -525,7 +524,7 @@ func NewArchwayApp(
app.getSubspace(minttypes.ModuleName),
&stakingKeeper,
app.AccountKeeper,
mintbankkeeper.NewKeeper(app.BankKeeper, app.RewardsKeeper),
app.BankKeeper,
authtypes.FeeCollectorName,
)

Expand Down
44 changes: 43 additions & 1 deletion docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Table of Contents

- [archway/mint/v1/mint.proto](#archway/mint/v1/mint.proto)
- [InflationRecipient](#archway.mint.v1.InflationRecipient)
- [LastBlockInfo](#archway.mint.v1.LastBlockInfo)
- [Params](#archway.mint.v1.Params)

Expand Down Expand Up @@ -96,6 +97,24 @@



<a name="archway.mint.v1.InflationRecipient"></a>

### InflationRecipient
InflationRecipient defines the inflation recipients.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `recipient` | [string](#string) | | recipient is the module receiving inflation, eg: x/staking, x/rewards. |
| `ratio` | [string](#string) | | ratio is the % of inflation being received.

percentage: 0 <= x <= 1. |






<a name="archway.mint.v1.LastBlockInfo"></a>

### LastBlockInfo
Expand All @@ -118,6 +137,29 @@ BlockInfo keeps track of the last block
Params defines the module parameters.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `min_inflation` | [string](#string) | | min_inflation defines the network's minimum inflation.

percentage: 0 <= x <= 1 |
| `max_inflation` | [string](#string) | | max_inflation defines the network's maximum inflation.

percentage: 0 <= x <= 1 |
| `min_bonded` | [string](#string) | | min_bonded defines the minimum wanted bond ratio (staked supply/total supply)

percentage: 0 <= x <= 1 |
| `max_bonded` | [string](#string) | | max_bonded defines the maximum wanted bond ratio (staked supply/total supply)

percentage: 0 <= x <= 1 |
| `inflation_change` | [string](#string) | | inflation_change defines how much the inflation should change if the bond ratio is not between the defined bands of min/max_bonded. This inflation change is applied to each second for which the bond ratio was not between min_bonded and max_bonded.

percentage: 0 <= x <= 1. |
| `max_block_duration` | [google.protobuf.Duration](#google.protobuf.Duration) | | max_block_duration defines the maximum duration of a block. this is important to have because there can be cases for which a block takes a lot longer than others, for example during upgrades. In these specific cases we don't want to have bursts of inflation in a single block.

0 <= x <= max duration. |
| `inflation_recipients` | [InflationRecipient](#archway.mint.v1.InflationRecipient) | repeated | inflation_recipients defines the list of inflation recipients. CONTRACT: the sum of the ratio of each inflation recipient must be 1. |





Expand Down Expand Up @@ -147,6 +189,7 @@ GenesisState defines the initial state of the mint module.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#archway.mint.v1.Params) | | params defines all the module parameters. |
| `last_block_info` | [LastBlockInfo](#archway.mint.v1.LastBlockInfo) | | last_block_info defines the previous block inflation and time |



Expand Down Expand Up @@ -278,7 +321,6 @@ Params defines the module parameters.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `inflation_rewards_ratio` | [string](#string) | | inflation_rewards_ratio defines the percentage of minted inflation tokens that are used for dApp rewards [0.0, 1.0]. If set to 0.0, no inflation rewards are distributed. |
| `tx_fee_rebate_ratio` | [string](#string) | | tx_fee_rebate_ratio defines the percentage of tx fees that are used for dApp rewards [0.0, 1.0]. If set to 0.0, no fee rewards are distributed. |
| `max_withdraw_records` | [uint64](#uint64) | | max_withdraw_records defines the maximum number of RewardsRecord objects used for the withdrawal operation. |

Expand Down
2 changes: 1 addition & 1 deletion e2e/gastracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func (s *E2ETestSuite) TestGasTrackingAndRewardsDistribution() {
// Setup (create new chain here with custom params)
chain := e2eTesting.NewTestChain(s.T(), 1,
e2eTesting.WithTxFeeRebatesRewardsRatio(txFeeRebateRewardsRatio),
e2eTesting.WithInflationRewardsRatio(inflationRewardsRatio),
e2eTesting.WithBlockGasLimit(blockGasLimit),
// Artificially increase the minted inflation coin to get some rewards for the contract (otherwise contractOp gas / blockGasLimit ratio will be 0)
e2eTesting.WithMintParams(
sdk.NewDecWithPrec(8, 1),
sdk.NewDecWithPrec(8, 1),
1000000,
),
e2eTesting.WithInflationDistributionRecipient(rewardsTypes.ModuleName, inflationRewardsRatio),
// Set default Tx fee for non-manual transaction like Upload / Instantiate
e2eTesting.WithDefaultFeeAmount("10000"),
)
Expand Down
2 changes: 1 addition & 1 deletion e2e/rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *E2ETestSuite) TestRewardsWithdrawProfitAndFees() {
e2eTesting.WithBlockGasLimit(100_000_000),
// x/rewards distribution params
e2eTesting.WithTxFeeRebatesRewardsRatio(sdk.NewDecWithPrec(5, 1)),
e2eTesting.WithInflationRewardsRatio(sdk.NewDecWithPrec(2, 1)),
e2eTesting.WithInflationDistributionRecipient(rewardsTypes.ModuleName, sdk.NewDecWithPrec(2, 1)),
// Set constant inflation rate
e2eTesting.WithMintParams(
sdk.NewDecWithPrec(10, 2), // 10%
Expand Down
29 changes: 17 additions & 12 deletions e2e/testing/chain_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"

"github.com/archway-network/archway/app"
minttypes "github.com/archway-network/archway/x/mint/types"
rewardsTypes "github.com/archway-network/archway/x/rewards/types"
)

Expand Down Expand Up @@ -81,18 +82,6 @@ func WithBlockGasLimit(gasLimit int64) TestChainConsensusParamsOption {
}
}

// WithInflationRewardsRatio sets x/rewards inflation rewards ratio parameter.
func WithInflationRewardsRatio(ratio sdk.Dec) TestChainGenesisOption {
return func(cdc codec.Codec, genesis app.GenesisState) {
var rewardsGenesis rewardsTypes.GenesisState
cdc.MustUnmarshalJSON(genesis[rewardsTypes.ModuleName], &rewardsGenesis)

rewardsGenesis.Params.InflationRewardsRatio = ratio

genesis[rewardsTypes.ModuleName] = cdc.MustMarshalJSON(&rewardsGenesis)
}
}

// WithMaxWithdrawRecords sets x/rewards MaxWithdrawRecords param.
func WithMaxWithdrawRecords(num uint64) TestChainGenesisOption {
return func(cdc codec.Codec, genesis app.GenesisState) {
Expand Down Expand Up @@ -130,3 +119,19 @@ func WithMintParams(inflationMin, inflationMax sdk.Dec, blocksPerYear uint64) Te
genesis[mintTypes.ModuleName] = cdc.MustMarshalJSON(&mintGenesis)
}
}

// WithInflationRewardsRatio sets x/rewards inflation distribution recipients
func WithInflationDistributionRecipient(recipientName string, ratio sdk.Dec) TestChainGenesisOption {
return func(cdc codec.Codec, genesis app.GenesisState) {
var mintGenesis minttypes.GenesisState
cdc.MustUnmarshalJSON(genesis[minttypes.ModuleName], &mintGenesis)

for _, recipient := range mintGenesis.Params.GetInflationRecipients() {
if recipient.Recipient == recipientName {
spoo-bar marked this conversation as resolved.
Show resolved Hide resolved
recipient.Ratio = ratio
}
}

genesis[minttypes.ModuleName] = cdc.MustMarshalJSON(&mintGenesis)
}
}
4 changes: 2 additions & 2 deletions e2e/txfees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func (s *E2ETestSuite) TestTxFees() {
// Set block gas limit (Archway mainnet param)
e2eTesting.WithBlockGasLimit(100_000_000),
// x/rewards distribution params
e2eTesting.WithTxFeeRebatesRewardsRatio(sdk.NewDecWithPrec(5, 1)), // 50 % (Archway mainnet param)
e2eTesting.WithInflationRewardsRatio(sdk.NewDecWithPrec(2, 1)), // 20 % (Archway mainnet param)
e2eTesting.WithTxFeeRebatesRewardsRatio(sdk.NewDecWithPrec(5, 1)), // 50 % (Archway mainnet param)
e2eTesting.WithInflationDistributionRecipient(rewardsTypes.ModuleName, sdk.NewDecWithPrec(2, 1)), // 20 % (Archway mainnet param)
// Set constant inflation rate
e2eTesting.WithMintParams(
sdk.NewDecWithPrec(10, 2), // 10% (Archway mainnet param)
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.2.0
)

Expand Down Expand Up @@ -63,7 +64,6 @@ require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
Expand All @@ -77,7 +77,6 @@ require (
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
Expand Down Expand Up @@ -130,7 +129,6 @@ require (
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmV
github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM=
github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
Expand Down Expand Up @@ -562,10 +561,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqC
github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2yq6j8bu0wa+9w14EEthWU=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.1 h1:I6ITHEanAwjB0FvaxmGm8pKqmCLR7QIe05ZmO4QAXMw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.1/go.mod h1:gYC+WX4YJFarA2ie73G2epzt7TBWpo9pzcBnK1g0MSw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU=
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s=
Expand Down Expand Up @@ -1657,8 +1652,6 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20230221151758-ace64dc21148 h1:muK+gVBJBfFb4SejshDBlN2/UgxCCOKH9Y34ljqEGOc=
google.golang.org/genproto v0.0.0-20230221151758-ace64dc21148/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw=
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 h1:znp6mq/drrY+6khTAlJUDNFFcDGV2ENLYKpMq8SyCds=
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
Expand Down
6 changes: 0 additions & 6 deletions proto/archway/rewards/v1beta1/rewards.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import "cosmos/base/v1beta1/coin.proto";
message Params {
option (gogoproto.goproto_stringer) = false;

// inflation_rewards_ratio defines the percentage of minted inflation tokens that are used for dApp rewards [0.0, 1.0].
// If set to 0.0, no inflation rewards are distributed.
string inflation_rewards_ratio = 1 [
spoo-bar marked this conversation as resolved.
Show resolved Hide resolved
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// tx_fee_rebate_ratio defines the percentage of tx fees that are used for dApp rewards [0.0, 1.0].
// If set to 0.0, no fee rewards are distributed.
string tx_fee_rebate_ratio = 2 [
Expand Down
11 changes: 9 additions & 2 deletions x/mint/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ var (
DefaultMaxBlockDuration time.Duration = time.Minute
DefaultFeeCollectorRecipient InflationRecipient = InflationRecipient{
Recipient: authtypes.FeeCollectorName,
Ratio: sdk.OneDec(),
Ratio: sdk.MustNewDecFromStr("0.80"), // 80%
}
DefaultRewardsRecipient InflationRecipient = InflationRecipient{
Recipient: "rewards",
spoo-bar marked this conversation as resolved.
Show resolved Hide resolved
Ratio: sdk.MustNewDecFromStr("0.20"), // 20%
}
)

Expand Down Expand Up @@ -60,7 +64,10 @@ func DefaultParams() Params {
DefaultMaximumBonded,
DefaultInflationChange,
DefaultMaxBlockDuration,
[]*InflationRecipient{&DefaultFeeCollectorRecipient},
[]*InflationRecipient{
&DefaultFeeCollectorRecipient,
&DefaultRewardsRecipient,
},
)
}

Expand Down
7 changes: 1 addition & 6 deletions x/mint/types/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion x/rewards/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (s *KeeperTestSuite) TestGenesisImportExport() {
})

newParams := types.NewParams(
sdk.NewDecWithPrec(99, 2),
sdk.NewDecWithPrec(98, 2),
1001,
)
Expand Down
6 changes: 2 additions & 4 deletions x/rewards/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ func (s *KeeperTestSuite) TestGRPC_Params() {
ctx, k := s.chain.GetContext(), s.chain.GetApp().RewardsKeeper
querySrvr := keeper.NewQueryServer(k)
params := rewardsTypes.Params{
InflationRewardsRatio: sdk.MustNewDecFromStr("0.1"),
TxFeeRebateRatio: sdk.MustNewDecFromStr("0.1"),
MaxWithdrawRecords: uint64(2),
TxFeeRebateRatio: sdk.MustNewDecFromStr("0.1"),
MaxWithdrawRecords: uint64(2),
}
k.SetParams(ctx, params)

Expand All @@ -32,7 +31,6 @@ func (s *KeeperTestSuite) TestGRPC_Params() {
s.Run("ok: gets params", func() {
res, err := querySrvr.Params(sdk.WrapSDKContext(ctx), &rewardsTypes.QueryParamsRequest{})
s.Require().NoError(err)
s.Require().Equal(params.InflationRewardsRatio, res.Params.InflationRewardsRatio)
s.Require().Equal(params.TxFeeRebateRatio, res.Params.TxFeeRebateRatio)
s.Require().Equal(params.MaxWithdrawRecords, res.Params.MaxWithdrawRecords)
})
Expand Down
7 changes: 0 additions & 7 deletions x/rewards/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import (
"github.com/archway-network/archway/x/rewards/types"
)

// InflationRewardsRatio return inflation rewards params ratio.
func (k Keeper) InflationRewardsRatio(ctx sdk.Context) (res sdk.Dec) {
k.paramStore.Get(ctx, types.InflationRewardsRatioParamKey, &res)
return
}

// TxFeeRebateRatio return tx fee rebate rewards params ratio.
func (k Keeper) TxFeeRebateRatio(ctx sdk.Context) (res sdk.Dec) {
k.paramStore.Get(ctx, types.TxFeeRebateRatioParamKey, &res)
Expand All @@ -27,7 +21,6 @@ func (k Keeper) MaxWithdrawRecords(ctx sdk.Context) (res uint64) {
// GetParams return all module parameters.
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
return types.NewParams(
k.InflationRewardsRatio(ctx),
k.TxFeeRebateRatio(ctx),
k.MaxWithdrawRecords(ctx),
)
Expand Down
Loading