-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mint: Babylon inflation module (#211)
Resolves babylonlabs-io/pm#92 This PR provides the implementation of the inflation module. - The module shares the same interfaces as `x/mint`, and serves as a drop-in replacement of Cosmos SDK's `x/mint`. - The module implements a different inflation function. Currently, it employs Celestia's [algorithm](https://docs.celestia.org/learn/staking-governance-supply) where the inflation rate decreases gradually w.r.t. the block timestamp. It contains all necessary dependencies for implementing any inflation function. - The implementation is adapted from [Celestia](https://github.com/celestiaorg/celestia-app/tree/main/x/mint) and [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/tree/main/x/mint). Steps for implementation: - [x] copy https://github.com/celestiaorg/celestia-app/tree/main/x/mint to `x/mint` - [x] fix all dependencies - [x] bump module to Cosmos SDK v0.50 - [x] replace Cosmos x/mint with the new x/mint - [x] fix unit tests - [x] fix e2e tests - [x] fix software upgrade e2e - [x] changelog - [x] write ADR - [x] implement the design - [x] properly initialise the new mint module in upgrade handler - [x] fix doc
- Loading branch information
1 parent
c9a55a5
commit a98cfd9
Showing
35 changed files
with
4,171 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
package babylon.mint.v1; | ||
|
||
option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; | ||
|
||
// GenesisState defines the mint module's genesis state. | ||
message GenesisState { | ||
reserved 1; // 1 was previously used for the `Minter` field. | ||
|
||
// BondDenom is the denomination of the token that should be minted. | ||
string bond_denom = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
syntax = "proto3"; | ||
package babylon.mint.v1; | ||
|
||
option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
// Minter represents the mint state. | ||
message Minter { | ||
// InflationRate is the rate at which new tokens should be minted for the | ||
// current year. For example if InflationRate=0.1, then 10% of the total | ||
// supply will be minted over the course of the year. | ||
string inflation_rate = 1 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
// AnnualProvisions is the total number of tokens to be minted in the current | ||
// year due to inflation. | ||
string annual_provisions = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
// PreviousBlockTime is the timestamp of the previous block. | ||
google.protobuf.Timestamp previous_block_time = 4 | ||
[ (gogoproto.stdtime) = true ]; | ||
|
||
// BondDenom is the denomination of the token that should be minted. | ||
string bond_denom = 5; | ||
} | ||
|
||
// GenesisTime contains the timestamp of the genesis block. | ||
message GenesisTime { | ||
// GenesisTime is the timestamp of the genesis block. | ||
google.protobuf.Timestamp genesis_time = 1 [ (gogoproto.stdtime) = true ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
syntax = "proto3"; | ||
package babylon.mint.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "babylon/mint/v1/mint.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/babylonlabs-io/babylon/x/mint/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// InflationRate returns the current inflation rate. | ||
rpc InflationRate(QueryInflationRateRequest) | ||
returns (QueryInflationRateResponse) { | ||
option (google.api.http).get = "/cosmos/mint/v1beta1/inflation_rate"; | ||
} | ||
|
||
// AnnualProvisions returns the current annual provisions. | ||
rpc AnnualProvisions(QueryAnnualProvisionsRequest) | ||
returns (QueryAnnualProvisionsResponse) { | ||
option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; | ||
} | ||
|
||
// GenesisTime returns the genesis time. | ||
rpc GenesisTime(QueryGenesisTimeRequest) returns (QueryGenesisTimeResponse) { | ||
option (google.api.http).get = "/cosmos/mint/v1beta1/genesis_time"; | ||
} | ||
} | ||
|
||
// QueryInflationRateRequest is the request type for the Query/InflationRate RPC | ||
// method. | ||
message QueryInflationRateRequest {} | ||
|
||
// QueryInflationRateResponse is the response type for the Query/InflationRate | ||
// RPC method. | ||
message QueryInflationRateResponse { | ||
// InflationRate is the current inflation rate. | ||
bytes inflation_rate = 1 [ | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// QueryAnnualProvisionsRequest is the request type for the | ||
// Query/AnnualProvisions RPC method. | ||
message QueryAnnualProvisionsRequest {} | ||
|
||
// QueryAnnualProvisionsResponse is the response type for the | ||
// Query/AnnualProvisions RPC method. | ||
message QueryAnnualProvisionsResponse { | ||
// AnnualProvisions is the current annual provisions. | ||
bytes annual_provisions = 1 [ | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// QueryGenesisTimeRequest is the request type for the Query/GenesisTime RPC | ||
// method. | ||
message QueryGenesisTimeRequest {} | ||
|
||
// QueryGenesisTimeResponse is the response type for the Query/GenesisTime RPC | ||
// method. | ||
message QueryGenesisTimeResponse { | ||
// GenesisTime is the timestamp associated with the first block. | ||
google.protobuf.Timestamp genesis_time = 1 [ (gogoproto.stdtime) = true ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.