feat(x/mint)!: Replace InflationCalculationFn with MintFn + simple epoch minting#20363
Conversation
WalkthroughWalkthroughThe changes introduce a new flexible minting logic in the Cosmos SDK's Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AppModule
participant Keeper
participant MintFn
User->>AppModule: Define custom MintFn
AppModule->>Keeper: Initialize with MintFn
Keeper->>MintFn: Invoke MintFn at epoch start
MintFn->>Keeper: Mint tokens based on custom logic
Keeper->>AppModule: Update state with minted tokens
AppModule->>User: Minting process complete
sequenceDiagram
participant User
participant AppModule
participant Keeper
participant DefaultMintFn
User->>AppModule: Use default MintFn
AppModule->>Keeper: Initialize with DefaultMintFn
Keeper->>DefaultMintFn: Invoke DefaultMintFn at epoch start
DefaultMintFn->>Keeper: Mint tokens based on default logic
Keeper->>AppModule: Update state with minted tokens
AppModule->>User: Minting process complete
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
| event.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), | ||
| event.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), | ||
| ) | ||
| return k.Minter.Set(ctx, minter) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| // BeginBlock returns the begin blocker for the mint module. | ||
| func (am AppModule) BeginBlock(ctx context.Context) error { | ||
| return am.keeper.BeginBlocker(ctx, am.inflationCalculator) | ||
| return am.keeper.BeginBlocker(ctx, am.mintFn) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 7
Outside diff range and nitpick comments (1)
x/epochs/keeper/keeper_test.go (1)
Line range hint
52-70: Update toSetupfunction to return a pointer and initialize the genesis state is well-implemented. Consider adding a test to verify the correct initialization of the genesis state.Would you like me to help by adding a test case for genesis state initialization?
Review Details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (7)
simapp/go.modis excluded by!**/*.modtests/go.modis excluded by!**/*.modx/group/go.modis excluded by!**/*.modx/group/go.sumis excluded by!**/*.sumx/mint/go.modis excluded by!**/*.modx/mint/go.sumis excluded by!**/*.sumx/mint/types/mint.pb.gois excluded by!**/*.pb.go
Files selected for processing (22)
- api/cosmos/mint/v1beta1/mint.pulsar.go (17 hunks)
- simapp/app.go (1 hunks)
- simapp/app_di.go (3 hunks)
- simapp/mint_fn.go (1 hunks)
- tests/e2e/bank/grpc.go (4 hunks)
- tests/e2e/distribution/grpc_query_suite.go (3 hunks)
- x/epochs/depinject.go (2 hunks)
- x/epochs/keeper/epoch_test.go (1 hunks)
- x/epochs/keeper/genesis_test.go (1 hunks)
- x/epochs/keeper/grpc_query.go (1 hunks)
- x/epochs/keeper/grpc_query_test.go (1 hunks)
- x/epochs/keeper/keeper.go (2 hunks)
- x/epochs/keeper/keeper_test.go (3 hunks)
- x/epochs/module.go (1 hunks)
- x/epochs/types/genesis.go (1 hunks)
- x/mint/depinject.go (4 hunks)
- x/mint/epoch_hooks.go (1 hunks)
- x/mint/keeper/abci.go (2 hunks)
- x/mint/keeper/keeper.go (2 hunks)
- x/mint/module.go (2 hunks)
- x/mint/proto/cosmos/mint/v1beta1/mint.proto (1 hunks)
- x/mint/types/genesis.go (1 hunks)
Files not summarized due to errors (1)
- api/cosmos/mint/v1beta1/mint.pulsar.go: Error: Message exceeds token limit
Additional Context Used
GitHub Check Runs (1)
CodeQL success (7)
api/cosmos/mint/v1beta1/mint.pulsar.go: [warning] 36-42: Iteration over map
Iteration over map may be a possible source of non-determinism
api/cosmos/mint/v1beta1/mint.pulsar.go: [warning] 441-443: Iteration over map
Iteration over map may be a possible source of non-determinism
api/cosmos/mint/v1beta1/mint.pulsar.go: [warning] 509-515: Iteration over map
Iteration over map may be a possible source of non-determinism
x/mint/keeper/abci.go: [warning] 28-28: Panic in BeginBock or EndBlock consensus methods
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
x/mint/module.go: [warning] 161-161: Panic in BeginBock or EndBlock consensus methods
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
path flow from Begin/EndBlock to a panic call
Path-based Instructions (21)
x/epochs/keeper/grpc_query_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/mint/keeper/abci.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/mint/epoch_hooks.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/epochs/keeper/keeper.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/mint/types/genesis.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/epochs/keeper/grpc_query.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/epochs/depinject.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/epochs/types/genesis.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/mint/depinject.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/epochs/keeper/keeper_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/epochs/keeper/genesis_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/epochs/keeper/epoch_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/epochs/module.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/mint_fn.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/mint/keeper/keeper.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.x/mint/module.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.tests/e2e/bank/grpc.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"tests/e2e/distribution/grpc_query_suite.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"simapp/app_di.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/app.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.api/cosmos/mint/v1beta1/mint.pulsar.go (1)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Learnings (1)
x/epochs/keeper/genesis_test.go (1)
User: likhita-809 PR: cosmos/cosmos-sdk#18471 File: x/protocolpool/keeper/genesis.go:12-51 Timestamp: 2023-11-22T12:32:39.368Z Learning: - The user `likhita-809` has confirmed the changes suggested in the previous interaction. - The file in question is `x/protocolpool/keeper/genesis.go` from a Cosmos SDK module. - The changes involve optimizing the `InitGenesis` function by removing redundant code and ensuring proper handling of start times for budget proposals.
Additional comments not posted (24)
x/mint/keeper/abci.go (1)
28-28: Ensure that theSetmethod inMinterhandles all possible error scenarios to prevent panics.x/mint/epoch_hooks.go (1)
16-29: Ensure that themintFnused inBeforeEpochStartis robust against all potential errors, especially since it interacts with external state.x/epochs/keeper/keeper.go (1)
Line range hint
22-35: Ensure that thepanicinNewKeeperis handled or logged appropriately to aid in debugging.x/mint/types/genesis.go (1)
10-10: The newMintFntype provides the necessary flexibility for custom minting operations as described in the PR. Ensure it is well-documented.x/epochs/keeper/grpc_query.go (1)
18-18: The changes to theQuerierstruct and theNewQuerierfunction are correct and improve the handling of the keeper instance.Also applies to: 22-22
x/epochs/depinject.go (1)
42-42: Change from value to pointer type forEpochKeeperlooks good. Ensure all usages correctly handle the pointer semantics.Verification successful
The usages of
EpochKeepercorrectly handle pointer semantics.
ProvideModuleassignsEpochKeeperthe result ofkeeper.NewKeeper, which returns a pointer.InvokeSetHooksacceptsEpochKeeperas a pointer argument.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all usages of `EpochKeeper` handle pointer semantics. # Test: Search for usages of `EpochKeeper`. Expect: Proper handling of pointers. rg --type go 'EpochKeeper' --context 5Length of output: 851
x/epochs/types/genesis.go (1)
20-20: Addition of the "minute" epoch aligns with the PR's objectives. Ensure it is integrated correctly in the system.Verification successful
The "minute" epoch is correctly integrated into the system, as evidenced by its usage in multiple relevant files.
x/tx/signing/textual/duration.go: Formatting of durations includes "minute".x/epochs/types/genesis.go: Added to the genesis configuration.x/epochs/keeper/epoch_test.go: Included in the epoch tests.simapp/mint_fn.go: Used in the minting function.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of the "minute" epoch. # Test: Search for usages of the "minute" epoch. Expect: Correct integration. rg --type go '"minute"' --context 5Length of output: 3333
x/mint/depinject.go (2)
9-9: Addition ofepochstypesimport is necessary for the new integration with the epochs module.
46-46: Integration ofEpochHooksand handling ofMintFninProvideModuleare well-implemented. Verify the integration and fallback mechanisms.Also applies to: 76-76, 79-79
Verification successful
The integration of
EpochHooksandMintFnis well-implemented across the codebase. The fallback mechanism forMintFnis correctly handled.
MintFnis used inx/mint/module.go,x/mint/depinject.go,x/mint/keeper/keeper.go, andsimapp/mint_fn.go.EpochHooksis used inx/mint/epoch_hooks.go,x/mint/depinject.go,x/epochs/types/hooks.go, andx/epochs/keeper/keeper.go.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `EpochHooks` and `MintFn`. # Test: Search for usages of `EpochHooks` and `MintFn`. Expect: Correct integration and fallback. rg --type go 'EpochHooks|MintFn' --context 5Length of output: 16300
x/epochs/keeper/keeper_test.go (1)
30-30: Transition to pointer type forEpochsKeeperin tests is consistent with main code changes. Ensure all test cases correctly handle the pointer type.Verification successful
The previous script failed because the specified directory or file does not exist. Let's locate the correct directory or file containing the test cases for
EpochsKeeperand verify the handling ofEpochsKeeperpointers.
The script successfully located the test files and found occurrences of
EpochsKeeperin several test files, includingx/epochs/keeper/keeper_test.go. Let's review the context around these occurrences to ensure proper handling of the pointer type.
The script successfully located the test files and found occurrences of
EpochsKeeperin several test files, includingx/epochs/keeper/keeper_test.go. The context around these occurrences shows that theEpochsKeeperpointer type is being handled correctly in the test cases.Transition to pointer type for
EpochsKeeperin tests is consistent with main code changes. Ensure all test cases correctly handle the pointer type.
x/epochs/keeper/keeper_test.gox/epochs/keeper/epoch_test.gox/epochs/keeper/abci_test.goScripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all test cases handle the `EpochsKeeper` pointer type correctly. # Test: Search for test cases using `EpochsKeeper`. Expect: Correct handling of pointers. rg --type go 'EpochsKeeper' 'x/epochs/keeper/*_test.go' --context 5Length of output: 133
Script:
#!/bin/bash # Description: Locate the correct directory or file containing the test cases for `EpochsKeeper` and verify the handling of `EpochsKeeper` pointers. # Step 1: Find all Go test files in the repository. test_files=$(fd --type f --extension go --glob '*_test.go') # Step 2: Search for occurrences of `EpochsKeeper` in the test files. for file in $test_files; do echo "Checking file: $file" rg --type go 'EpochsKeeper' "$file" --context 5 doneLength of output: 178958
Script:
#!/bin/bash # Description: Review the context around the occurrences of `EpochsKeeper` in the test files to ensure proper handling of the pointer type. # Step 1: Find all Go test files in the repository. test_files=$(fd --type f --extension go --glob '*_test.go') # Step 2: Search for occurrences of `EpochsKeeper` in the test files and display the context. for file in $test_files; do echo "Checking file: $file" rg --type go 'EpochsKeeper' "$file" --context 10 doneLength of output: 180975
x/epochs/keeper/genesis_test.go (1)
21-21: Update to expect four epochs in the genesis test is correct. Verify that the genesis state is correctly initialized elsewhere in the system.x/epochs/keeper/epoch_test.go (1)
96-101: Updated assertions correctly reflect the addition of the "minute" epoch and its order among other epochs.x/epochs/module.go (1)
39-43: Transitioningkeeperfrom a value to a pointer in theAppModulestruct and its constructor enhances performance and maintainability.simapp/mint_fn.go (1)
19-123: TheProvideExampleMintFnfunction is well-implemented, with comprehensive error handling and condition checks for minting based on the epoch ID.x/mint/keeper/keeper.go (1)
107-180: TheDefaultMintFnfunction encapsulates the minting logic effectively, with appropriate checks for conditions like epoch ID and max supply, and includes comprehensive error handling.x/mint/module.go (1)
47-69: Adding amintFnfield to theAppModulestruct and handling it in theNewAppModuleconstructor enhances the flexibility of the mint module by allowing for custom minting logic.tests/e2e/bank/grpc.go (1)
Line range hint
38-75: Updated expected amounts in GRPC handler test cases correctly reflect the new staking tokens configuration.tests/e2e/distribution/grpc_query_suite.go (3)
286-286: Updated delegator rewards value to "60.27stake" appears correct given the PR context.
173-173: Updated commission value to "60.27stake" appears correct given the PR context.Verification successful
The search results show that the value "60.27stake" appears in two places within the same file: once for commission and once for rewards. To ensure the correctness of the updated commission value, we need to verify if this value is consistent with the actual commission calculation logic in the codebase.
To verify the correctness of the updated commission value, we need to inspect the implementation of the
SetInitialCommissionandbuildCommissionRatesfunctions, as they seem directly related to commission settings.
To fully understand the commission calculation, we need the complete implementation of both the
SetInitialCommissionandbuildCommissionRatesfunctions.
To fully verify the commission calculation, we still need the complete implementation of the
SetInitialCommissionfunction.
The command to extract the remaining part of the
SetInitialCommissionfunction did not produce any output. To ensure we capture the full implementation of this function, we need to use a broader search pattern.
The updated commission value in the test is consistent with the commission calculation logic in the codebase.
- The
SetInitialCommissionfunction validates and sets the commission for the validator.- The
buildCommissionRatesfunction converts string inputs to decimal values for commission rates.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the updated commission value in the distribution logic. # Test: Search for the commission calculation logic. Expect: Consistency with the new test value. rg --type go $'60.27stake'Length of output: 212
Script:
#!/bin/bash # Description: Search for the commission calculation logic in the codebase to verify consistency with the test value. # Search for functions or methods related to commission calculation. rg --type go 'commission' | grep -i 'func\|method'Length of output: 1247
Script:
#!/bin/bash # Description: Extract and review the implementation of the SetInitialCommission and buildCommissionRates functions to verify commission calculation logic. # Extract the implementation of the SetInitialCommission function. rg --type go --context 10 'func (v Validator) SetInitialCommission' x/staking/types/validator.go # Extract the implementation of the buildCommissionRates function. rg --type go --context 10 'func buildCommissionRates' x/staking/client/cli/utils.goLength of output: 857
Script:
#!/bin/bash # Description: Extract the full implementation of the SetInitialCommission and buildCommissionRates functions to verify commission calculation logic. # Extract the full implementation of the SetInitialCommission function. rg --type go --context 20 'func (v Validator) SetInitialCommission' x/staking/types/validator.go # Extract the remaining part of the buildCommissionRates function. rg --type go --context 20 'func buildCommissionRates' x/staking/client/cli/utils.goLength of output: 1436
Script:
#!/bin/bash # Description: Extract the remaining part of the SetInitialCommission function to verify commission calculation logic. # Extract the remaining part of the SetInitialCommission function. rg --type go --context 30 'func (v Validator) SetInitialCommission' x/staking/types/validator.goLength of output: 98
Script:
#!/bin/bash # Description: Use a broader search pattern to locate the full implementation of the SetInitialCommission function. # Search for the full implementation of the SetInitialCommission function. rg --type go --context 50 'SetInitialCommission' x/staking/types/validator.goLength of output: 3735
119-119: Updated reward value to "120.54stake" appears correct given the PR context.simapp/app_di.go (2)
96-96: Transition ofEpochsKeeperto pointer type aligns with the PR's objectives to enhance performance and manageability.
115-115: Addition ofProvideExampleMintFnto the dependency injection setup is consistent with the PR's objectives to introduce new minting logic.simapp/app.go (1)
174-174: Ensure thatEpochsKeeperis properly instantiated before use to avoid nil pointer dereferences.api/cosmos/mint/v1beta1/mint.pulsar.go (1)
441-443: Verify deterministic behavior in map iteration during size calculation.The iteration over
x.ArbitraryParamsin theSizemethod offastReflection_Mintermight lead to non-deterministic size calculations. If the order of map entries affects the size calculation, consider implementing a sorting mechanism before iteration.Verification successful
The
Sizefunction infastReflection_Minteralready includes a mechanism to ensure deterministic behavior when iterating overx.ArbitraryParams. Whenoptions.Deterministicis true, the keys are sorted before iteration, ensuring consistent size calculations.
- Lines 427-443 in
api/cosmos/mint/v1beta1/mint.pulsar.gohandle this correctly.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if the map order affects the size calculation logic. grep -rn 'Size' api/cosmos/mint/v1beta1/mint.pulsar.goLength of output: 944
Script:
#!/bin/bash # Extract the relevant portion of the Size function to analyze the iteration over x.ArbitraryParams sed -n '400,460p' api/cosmos/mint/v1beta1/mint.pulsar.goLength of output: 1835
| (gogoproto.nullable) = false | ||
| ]; | ||
|
|
||
| map<string, string> arbitrary_params = 3; |
There was a problem hiding this comment.
Addition of arbitrary_params to the Minter message enhances customization. Consider documenting its intended use cases.
+ // arbitrary_params can be used to pass custom parameters for minting operations.Committable suggestion was skipped due low confidence.
| Supply: sdk.NewCoins( | ||
| sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), s.cfg.AccountTokens), | ||
| sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(10))), | ||
| sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(123))), |
There was a problem hiding this comment.
Because now it mints the equivalent of a minute in the first block (the beginning of the epoch)
… into facu/exp-mintfn2
There was a problem hiding this comment.
Actionable comments posted: 3
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (1)
x/mint/go.modis excluded by!**/*.mod
Files selected for processing (3)
- x/mint/CHANGELOG.md (1 hunks)
- x/mint/README.md (3 hunks)
- x/mint/keeper/keeper.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/mint/keeper/keeper.go
Additional context used
Path-based instructions (2)
x/mint/CHANGELOG.md (1)
Pattern
**/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"x/mint/README.md (1)
Pattern
**/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
LanguageTool
x/mint/CHANGELOG.md
[style] ~37-~37: Consider a shorter alternative to avoid wordiness.
Context: ...per.DefaultMintFnwrapper must be used in order to continue using it inNewAppModule`. Th...x/mint/README.md
[uncategorized] ~10-~10: Possible missing preposition found.
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
[uncategorized] ~120-~120: Possible missing preposition found.
Context: ...e desired ratio (67%). The maximum rate change possible is defined to be 13% per year,...
[typographical] ~121-~121: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence.
Context: ...e possible is defined to be 13% per year, however, the annual inflation is capped as betwe...
Markdownlint
x/mint/CHANGELOG.md
30-30: Expected: 0 or 2; Actual: 1
Trailing spacesx/mint/README.md
10-10: Expected: 2; Actual: 4
Unordered list indentation
12-12: Expected: 2; Actual: 4
Unordered list indentation
13-13: Expected: 2; Actual: 4
Unordered list indentation
15-15: Expected: 2; Actual: 4
Unordered list indentation
17-17: Expected: 2; Actual: 4
Unordered list indentation
18-18: Expected: 2; Actual: 4
Unordered list indentation
19-19: Expected: 2; Actual: 4
Unordered list indentation
20-20: Expected: 2; Actual: 4
Unordered list indentation
23-23: Expected: 2; Actual: 4
Unordered list indentation
25-25: Expected: 2; Actual: 4
Unordered list indentation
26-26: Expected: 2; Actual: 4
Unordered list indentation
27-27: Expected: 2; Actual: 4
Unordered list indentation
72-72: Expected: 0 or 2; Actual: 1
Trailing spaces
102-102: Expected: 0 or 2; Actual: 1
Trailing spaces
126-126: Column: 1
Hard tabs
127-127: Column: 1
Hard tabs
129-129: Column: 1
Hard tabs
130-130: Column: 1
Hard tabs
131-131: Column: 1
Hard tabs
132-132: Column: 1
Hard tabs
133-133: Column: 1
Hard tabs
134-134: Column: 1
Hard tabs
135-135: Column: 1
Hard tabs
136-136: Column: 1
Hard tabs
138-138: Column: 1
Hard tabs
149-149: Column: 1
Hard tabs
158-158: Column: 1
Hard tabs
159-159: Column: 1
Hard tabs
54-54: Expected: 1; Actual: 2
Multiple consecutive blank lines
95-95: Expected: 1; Actual: 2
Multiple consecutive blank lines
162-162: Expected: 1; Actual: 2
Multiple consecutive blank lines
178-178: Expected: 1; Actual: 2
Multiple consecutive blank lines
192-192: Expected: 1; Actual: 2
Multiple consecutive blank lines
Additional comments not posted (5)
x/mint/CHANGELOG.md (1)
30-30: Correct the trailing space issue.Tools
Markdownlint
30-30: Expected: 0 or 2; Actual: 1
Trailing spacesx/mint/README.md (4)
59-60: Ensure the newdatafield in theMinterstruct is clearly explained.
83-83: Clarify the transition fromInflationCalculationFntoMintFn.
87-91: Ensure theMintFnfunction signature is correct and matches the implementation.
98-98: Clarify the conditions under which block-based minting occurs.
|
|
||
| ### API Breaking Changes | ||
|
|
||
| * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Deprecated InflationCalculationFn in favor of MintFn, `keeper.DefaultMintFn` wrapper must be used in order to continue using it in `NewAppModule`. This is not breaking for depinject users, as both `MintFn` and `InflationCalculationFn` are accepted. |
There was a problem hiding this comment.
Consider using a more concise expression.
- `keeper.DefaultMintFn` wrapper must be used in order to continue using it in `NewAppModule`.
+ `keeper.DefaultMintFn` wrapper is required in `NewAppModule`.Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Deprecated InflationCalculationFn in favor of MintFn, `keeper.DefaultMintFn` wrapper must be used in order to continue using it in `NewAppModule`. This is not breaking for depinject users, as both `MintFn` and `InflationCalculationFn` are accepted. | |
| * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Deprecated InflationCalculationFn in favor of MintFn, `keeper.DefaultMintFn` wrapper is required in `NewAppModule`. This is not breaking for depinject users, as both `MintFn` and `InflationCalculationFn` are accepted. |
Tools
LanguageTool
[style] ~37-~37: Consider a shorter alternative to avoid wordiness.
Context: ...per.DefaultMintFnwrapper must be used in order to continue using it inNewAppModule`. Th...
Co-authored-by: Marko <marko@baricevic.me>
| params, err := k.Params.Get(ctx) | ||
| // we pass -1 as epoch number to indicate that this is not an epoch minting, | ||
| // but a regular block minting. Same with epoch id "block". | ||
| err = mintFn(ctx, k.Environment, &minter, "block", -1) |
There was a problem hiding this comment.
how would you disable this?
There was a problem hiding this comment.
The mintFn always check for the epoch ID and returns early if it doesn't match. It's not the cleanest, but works :D
… into facu/exp-mintfn2
tac0turtle
left a comment
There was a problem hiding this comment.
how does inflation work on epochs, is it the user needs to estimate how many epochs in a year? also is it the same as the old way with 67% bond ratio?
For the default function in x/mint, it works exactly the same way as before, it mints on every block. For The other difference, which is a bit of a workaround to avoid breaking all the current code, we mint tokens for 60s prior to the chain genesis. It's just to get tokens on the very first block, as many tests depend on this. |
There was a problem hiding this comment.
Actionable comments posted: 5
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (6)
simapp/go.modis excluded by!**/*.modtests/go.modis excluded by!**/*.modx/group/go.modis excluded by!**/*.modx/group/go.sumis excluded by!**/*.sumx/mint/go.modis excluded by!**/*.modx/mint/go.sumis excluded by!**/*.sum
Files selected for processing (4)
- x/mint/README.md (3 hunks)
- x/mint/keeper/keeper_test.go (3 hunks)
- x/mint/keeper/msg_server_test.go (1 hunks)
- x/mint/module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/mint/module_test.go
Additional context used
Path-based instructions (3)
x/mint/keeper/msg_server_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/mint/keeper/keeper_test.go (2)
Pattern
**/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"x/mint/README.md (1)
Pattern
**/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
LanguageTool
x/mint/README.md
[uncategorized] ~10-~10: Possible missing preposition found. (AI_HYDRA_LEO_MISSING_OF)
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
[typographical] ~132-~132: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (HOWEVER_SENTENCE)
Context: ...e possible is defined to be 13% per year, however, the annual inflation is capped as betwe...
Markdownlint
x/mint/README.md
10-10: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
12-12: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
13-13: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
15-15: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
17-17: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
18-18: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
19-19: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
20-20: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
23-23: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
25-25: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
26-26: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
27-27: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
72-72: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
113-113: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
137-137: Column: 1 (MD010, no-hard-tabs)
Hard tabs
138-138: Column: 1 (MD010, no-hard-tabs)
Hard tabs
140-140: Column: 1 (MD010, no-hard-tabs)
Hard tabs
141-141: Column: 1 (MD010, no-hard-tabs)
Hard tabs
142-142: Column: 1 (MD010, no-hard-tabs)
Hard tabs
143-143: Column: 1 (MD010, no-hard-tabs)
Hard tabs
144-144: Column: 1 (MD010, no-hard-tabs)
Hard tabs
145-145: Column: 1 (MD010, no-hard-tabs)
Hard tabs
146-146: Column: 1 (MD010, no-hard-tabs)
Hard tabs
147-147: Column: 1 (MD010, no-hard-tabs)
Hard tabs
149-149: Column: 1 (MD010, no-hard-tabs)
Hard tabs
160-160: Column: 1 (MD010, no-hard-tabs)
Hard tabs
169-169: Column: 1 (MD010, no-hard-tabs)
Hard tabs
170-170: Column: 1 (MD010, no-hard-tabs)
Hard tabs
54-54: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
106-106: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
173-173: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
189-189: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
203-203: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
Additional comments not posted (1)
x/mint/README.md (1)
113-113: Remove trailing spaces.- If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`. + If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`.Likely invalid or redundant comment.
Tools
Markdownlint
113-113: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
| ) | ||
|
|
||
| func (s *IntegrationTestSuite) TestUpdateParams() { | ||
| func (s *KeeperTestSuite) TestUpdateParams() { |
There was a problem hiding this comment.
Ensure comprehensive test coverage for TestUpdateParams.
Would you like me to help expand the test cases to cover more scenarios or edge cases?
| s.Nil(s.mintKeeper.AddCollectedFees(s.ctx, fees)) | ||
| } | ||
|
|
||
| func (s *KeeperTestSuite) TestDefaultMintFn() { |
There was a problem hiding this comment.
Enhance test coverage for TestDefaultMintFn.
Would you like assistance in adding more test cases to cover scenarios where MintCoins and SendCoinsFromModuleToModule might fail?
| s.NotEqual(minter, newMinter) | ||
| } | ||
|
|
||
| func (s *KeeperTestSuite) TestMigrator() { |
There was a problem hiding this comment.
Improve clarity and coverage of migration tests.
Consider clarifying the intent behind setting the max supply to one and then zero in the migration tests. Additionally, testing other critical migration paths could ensure comprehensive coverage.
| const govModuleNameStr = "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" | ||
|
|
||
| type IntegrationTestSuite struct { | ||
| type KeeperTestSuite struct { |
There was a problem hiding this comment.
Refactor KeeperTestSuite to improve clarity and maintainability.
Consider breaking down the SetupTest method into smaller, more focused methods to improve readability and maintainability.
| ## Contents | ||
|
|
||
| * [Concepts](#concepts) | ||
| * [The Minting Mechanism](#the-minting-mechanism) |
There was a problem hiding this comment.
Correct the indentation for the unordered list.
- * [The Minting Mechanism](#the-minting-mechanism)
+ * [The Minting Mechanism](#the-minting-mechanism)Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
| * [The Minting Mechanism](#the-minting-mechanism) | |
| * [The Minting Mechanism](#the-minting-mechanism) |
Tools
LanguageTool
[uncategorized] ~10-~10: Possible missing preposition found. (AI_HYDRA_LEO_MISSING_OF)
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
Markdownlint
10-10: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
There was a problem hiding this comment.
@facundomedica, understood! I'll hold off on any further actions or comments until you indicate otherwise. If there's anything specific you need when you're ready to resume, just let me know!
There was a problem hiding this comment.
Actionable comments posted: 3
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (8)
- simapp/app.go (1 hunks)
- tests/e2e/bank/grpc.go (4 hunks)
- tests/e2e/distribution/grpc_query_suite.go (3 hunks)
- x/group/go.mod (1 hunks)
- x/mint/README.md (3 hunks)
- x/mint/keeper/keeper_test.go (3 hunks)
- x/mint/types/minter_test.go (2 hunks)
- x/mint/types/params.go (6 hunks)
Files skipped from review as they are similar to previous changes (6)
- simapp/app.go
- tests/e2e/bank/grpc.go
- tests/e2e/distribution/grpc_query_suite.go
- x/mint/keeper/keeper_test.go
- x/mint/types/minter_test.go
- x/mint/types/params.go
Additional context used
Path-based instructions (1)
x/mint/README.md (1)
Pattern
**/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
LanguageTool
x/mint/README.md
[uncategorized] ~10-~10: Possible missing preposition found. (AI_HYDRA_LEO_MISSING_OF)
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
[uncategorized] ~72-~72: This verb may not be in the correct form. Consider using a different form for this context. (AI_EN_LECTOR_REPLACEMENT_VERB_FORM)
Context: ...ion of theMaxSupplyparameter allows controlling the maximum supply of tokens minted by ...
[uncategorized] ~120-~120: A determiner appears to be missing. Consider inserting it. (AI_EN_LECTOR_MISSING_DETERMINER)
Context: ...Fn)`. ### Inflation rate calculation Inflation rate is calculated using an "inflation ...
[uncategorized] ~135-~135: Possible missing preposition found. (AI_HYDRA_LEO_MISSING_OF)
Context: ...e desired ratio (67%). The maximum rate change possible is defined to be 5% per year, ...
[typographical] ~136-~136: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (HOWEVER_SENTENCE)
Context: ...ge possible is defined to be 5% per year, however, the annual inflation is capped between ...
Markdownlint
x/mint/README.md
10-10: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
12-12: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
13-13: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
15-15: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
17-17: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
18-18: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
19-19: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
20-20: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
23-23: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
25-25: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
26-26: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
27-27: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
72-72: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
117-117: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
140-140: Column: 1 (MD010, no-hard-tabs)
Hard tabs
141-141: Column: 1 (MD010, no-hard-tabs)
Hard tabs
143-143: Column: 1 (MD010, no-hard-tabs)
Hard tabs
144-144: Column: 1 (MD010, no-hard-tabs)
Hard tabs
145-145: Column: 1 (MD010, no-hard-tabs)
Hard tabs
146-146: Column: 1 (MD010, no-hard-tabs)
Hard tabs
147-147: Column: 1 (MD010, no-hard-tabs)
Hard tabs
148-148: Column: 1 (MD010, no-hard-tabs)
Hard tabs
149-149: Column: 1 (MD010, no-hard-tabs)
Hard tabs
150-150: Column: 1 (MD010, no-hard-tabs)
Hard tabs
152-152: Column: 1 (MD010, no-hard-tabs)
Hard tabs
163-163: Column: 1 (MD010, no-hard-tabs)
Hard tabs
172-172: Column: 1 (MD010, no-hard-tabs)
Hard tabs
173-173: Column: 1 (MD010, no-hard-tabs)
Hard tabs
54-54: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
110-110: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
176-176: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
192-192: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
206-206: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines
Additional comments not posted (2)
x/group/go.mod (1)
47-47: The addition ofcosmossdk.io/x/epochsas an indirect dependency aligns with the changes in the minting logic. Ensure that this dependency is maintained up-to-date and review its impact periodically.x/mint/README.md (1)
59-60: The addition of thedatafield in theMinterstruct is correctly documented. Ensure that examples or guidelines on how to use this field are provided to avoid misuse.
| * [Concepts](#concepts) | ||
| * [The Minting Mechanism](#the-minting-mechanism) | ||
| * [State](#state) | ||
| * [Minter](#minter) | ||
| * [Params](#params) | ||
| * [Begin-Block](#begin-block) | ||
| * [Epoch minting](#epoch-minting) | ||
| * [MintFn](#mintfn) | ||
| * [Block based minting](#block-based-minting) | ||
| * [Default configuration](#default-configuration) |
There was a problem hiding this comment.
Ensure consistent indentation for list items to improve readability.
- * [The Minting Mechanism](#the-minting-mechanism)
+ * [The Minting Mechanism](#the-minting-mechanism)
- * [Default configuration](#default-configuration)
+ * [Default configuration](#default-configuration)
- * [NextInflationRate](#nextinflationrate)
+ * [NextInflationRate](#nextinflationrate)
- * [NextAnnualProvisions](#nextannualprovisions)
+ * [NextAnnualProvisions](#nextannualprovisions)
- * [BlockProvision](#blockprovision)
+ * [BlockProvision](#blockprovision)Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| * [Concepts](#concepts) | |
| * [The Minting Mechanism](#the-minting-mechanism) | |
| * [State](#state) | |
| * [Minter](#minter) | |
| * [Params](#params) | |
| * [Begin-Block](#begin-block) | |
| * [Epoch minting](#epoch-minting) | |
| * [MintFn](#mintfn) | |
| * [Block based minting](#block-based-minting) | |
| * [Default configuration](#default-configuration) | |
| * [Concepts](#concepts) | |
| * [The Minting Mechanism](#the-minting-mechanism) | |
| * [State](#state) | |
| * [Minter](#minter) | |
| * [Params](#params) | |
| * [Epoch minting](#epoch-minting) | |
| * [MintFn](#mintfn) | |
| * [Block based minting](#block-based-minting) | |
| * [Default configuration](#default-configuration) |
Tools
LanguageTool
[uncategorized] ~10-~10: Possible missing preposition found. (AI_HYDRA_LEO_MISSING_OF)
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
Markdownlint
10-10: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
12-12: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
13-13: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
15-15: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
17-17: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation
| In the latest release of x/mint, the minting logic has been refactored to allow for more flexibility in the minting process. The `InflationCalculationFn` has been deprecated in favor of `MintFn`. The `MintFn` function is passed to the `NewAppModule` function and is used to mint tokens on the configured epoch beginning. This change allows users to define their own minting logic and removes any assumptions on how tokens are minted. | ||
|
|
||
| The minting logic in the `BeginBlocker` function provides an optional feature for controlling token minting based on the maximum allowable supply (MaxSupply). This feature allows users to adjust the minting process according to their specific requirements and use cases. However, it's important to note that the MaxSupply parameter is independent of the minting process and assumes that any adjustments to the total supply, including burning tokens, are handled by external modules. | ||
| ```mermaid | ||
| flowchart LR | ||
| A[BeforeEpochStart] --> B[MintFn] | ||
|
|
||
| subgraph B["MintFn (user defined)"] | ||
| direction LR | ||
| C[Get x/staking info] --> D[Calculate Inflation] | ||
| D --> E[Mint Tokens] | ||
| end | ||
| ``` | ||
|
|
||
| ### MintFn | ||
|
|
||
| The `MintFn` function is called at the beginning of each epoch and is responsible for minting tokens. The function signature is as follows: | ||
|
|
||
| ```go | ||
| type MintFn func(ctx context.Context, env appmodule.Environment, minter *Minter, epochId string, epochNumber int64) error | ||
| ``` | ||
|
|
||
| How this function mints tokens is defined by the app developers, meaning they can query state and perform any calculations they deem necessary. [This implementation](https://github.com/cosmos/cosmos-sdk/blob/ace7bca105a8d5363782cfd19c6f169b286cd3b2/simapp/mint_fn.go#L25) in SimApp contains examples of how to use `QueryRouterService` and the Minter's `data`. |
There was a problem hiding this comment.
The documentation for the new MintFn is clear and informative. Consider adding a warning about ensuring the idempotency of MintFn to prevent unintended minting due to repeated calls or reverts.
Would you like me to draft a section on ensuring the idempotency of MintFn?
|
|
||
| ### Default configuration | ||
|
|
||
| If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`. |
There was a problem hiding this comment.
Remove trailing spaces to maintain clean and professional documentation.
- If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`.
+ If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`.Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`. | |
| If no `MintFn` is passed to the `NewAppModule` function, the minting logic defaults to block-based minting, corresponding to `mintKeeper.DefaultMintFn(types.DefaultInflationCalculationFn)`. |
Tools
Markdownlint
117-117: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- x/mint/module_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- x/mint/module_test.go
* main: refactor(x/auth): Fix system test (#20531) feat(crypto): add blst (#20296) docs: Update high level overview and introduction (#20535) refactor(x/core): remove test (#20624) feat(x/mint)!: Replace InflationCalculationFn with MintFn + simple epoch minting (#20363) docs: remove duplicate words (#20622) feat: prep for errors v2 (#20539) chore: reduce default inflation (#20606) refactor(store): add miss defer (#20602) chore: use comet api pkg instead of comet alias (#20614) chore: write gentx info to cmd.ErrOrStderr (#20616) docs: ADR 073: update to accepted and add to README.md (#20619) chore(proto): change future extracted modules version from v1.0.0 to v0.2.0 (#20600) fix: remove some duplicate words (#20605) feat(stf): port simappv2 changes (#20587) chore: bring patch changelogs to main (#20599)
Description
MintFn is a breaking replacement for InflationCalculationFn (only for non-depinject users, depinject will continue to work with no changes).
Until now, developers could only modify minting by passing an inflation calculation function that could take in some x/mint parameters and the bonded ratio from x/staking. The rest of the minting process was being handled by the module, so minting to custom accounts was not possible without having to create a separate module for this.
Now
MintFn...Minter now contains arbitrary data
Minter now has a
datafield which can contain[]byte. This can be used by developers to store data related to the minting process. For example, the last time tokens were minted, or any other information. The SDK does not make any assumptions on it and does not run any checks on it, so it's the developers' responsibility to ensure deterministic behavior when using this field.Changes in NewAppModule (breaking if passing in a custom InflationCalculationFn)
NewAppModulenow receives aMintFninstead of aInflationCalculationFn. If no custom function was being passed in, no breaks occur as it can continue to benil. If anInflationCalculationFnwas being passed, developers can usemintKeeper.DefaultMintFn(theCustomInflationFn)to keep the current minting behaviorFor depinject users this is abstracted away, but for legacy users they'll have to change this in their app.go.
Before & after
Before only the "Calculate Inflation" step was user/dev defined.
flowchart subgraph x/mint B[BeginBlock] --> C[Get data from x/staking] C --> D[Calculate Inflation<br/><i>user defined</i>] D --> E[Mint tokens] end style D fill:#9f6,stroke:#333,stroke-width:2pxNow the entire MintFn is user defined, so the user can make it work like it used to work:
flowchart LR A[BeforeEpochStart] --> B[MintFn] subgraph B["MintFn (user defined)"] direction LR C[Get x/staking info] --> D[Calculate Inflation] D --> E[Mint Tokens] endOr it can get creative and do other stuff:
flowchart LR A[BeforeEpochStart] --> B[MintFn] subgraph B["MintFn (user defined)"] direction LR C[Mint tokens to team] --> D[Mint tokens to Community Pool] D --> E[Mint Tokens to Distribute] endCloses: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
New Features
MintFn, allowing users to define custom minting functions.Bug Fixes
Tests
TestDefaultMintFn,TestBeginBlocker, andTestMigrator.Refactor
InflationCalculationFnin favor ofMintFnfor better flexibility.