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

mint: Babylon inflation module #211

Merged
merged 16 commits into from
Oct 30, 2024
Merged

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Oct 18, 2024

Resolves https://github.com/babylonlabs-io/pm/issues/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 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 and Cosmos SDK.

Steps for implementation:

@SebastianElvis SebastianElvis changed the title mint: Babylon mint module (DNM) mint: Babylon mint module Oct 18, 2024
@SebastianElvis SebastianElvis changed the title (DNM) mint: Babylon mint module (DNM) mint: Babylon inflation module Oct 18, 2024
@SebastianElvis SebastianElvis added the consensus breaking change modifies `appHash` of the application label Oct 24, 2024
app/upgrades/v1/upgrades.go Outdated Show resolved Hide resolved
x/mint/README.md Outdated Show resolved Hide resolved
x/mint/abci.go Show resolved Hide resolved
@SebastianElvis SebastianElvis marked this pull request as ready for review October 29, 2024 11:19
@SebastianElvis SebastianElvis requested a review from a team as a code owner October 29, 2024 11:19
@SebastianElvis SebastianElvis changed the title (DNM) mint: Babylon inflation module mint: Babylon inflation module Oct 29, 2024

// GenesisState defines the mint module's genesis state.
message GenesisState {
reserved 1; // 1 was previously used for the `Minter` field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not keep the minter? https://github.com/cosmos/cosmos-sdk/blob/b49f948b36bc991db5be431607b475633aed697e/proto/cosmos/mint/v1beta1/genesis.proto#L11

I think this is good information

  // minter is a space for holding current inflation information.
  Minter minter = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];

and we could migrate the info during the upgrade

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is because in this inflation protocol, the minter object does not depend on the minter object in the previous block, so the protocol does not need to remember the minter in genesis at all. This is different from Cosmos SDK's design where the new inflation depends on the inflation at the previous block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what about the minted values during the previous version?

x/mint/README.md Outdated Show resolved Hide resolved
// Although ak.GetModuleAccount appears to be a no-op, it actually creates a
// new module account in the x/auth account store if it doesn't exist. See
// the x/auth keeper for more details.
ak.GetModuleAccount(ctx, types.ModuleName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ak.GetModuleAccount(ctx, types.ModuleName)

We should not do this during initGenesis, if there is a need to create a new module account should be done in app.go or during upgrade

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm checking the code of other modules and Cosmos SDK, and it seems that this line is not necessary. Removing it then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried, and found that we cannot remove it, otherwise will fail.

Checked Cosmos SDK code base and auth module is doing same https://github.com/cosmos/cosmos-sdk/blob/b49f948b36bc991db5be431607b475633aed697e/x/auth/keeper/genesis.go#L28-L29. Probably this is a bug of Cosmos SDK and Celestia people learned it in a hard way?

Wdyt about keeping it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

x/mint/types/keys.go Outdated Show resolved Hide resolved
Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SebastianElvis SebastianElvis merged commit a98cfd9 into main Oct 30, 2024
20 checks passed
@SebastianElvis SebastianElvis deleted the babylon-inflation-module branch October 30, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus breaking change modifies `appHash` of the application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants