-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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)!: Replace InflationCalculationFn with MintFn + simple epoch minting #20363
base: main
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@facundomedica has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 37 minutes and 31 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe updates introduce a flexible minting mechanism in the Changes
Sequence Diagram(s) (Beta)sequenceDiagram
participant User
participant AppModule
participant Keeper
participant MintFn
User->>AppModule: Configure MintFn
AppModule->>Keeper: Initialize with MintFn
Keeper->>MintFn: Call MintFn at epoch start
MintFn-->>Keeper: Mint tokens
Keeper->>AppModule: Emit minting events
Note right of AppModule: Default to block-based minting if no MintFn
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 Warning
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
@@ -156,7 +157,7 @@ | |||
|
|||
// 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 Warning
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
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
Outside diff range and nitpick comments (1)
x/epochs/keeper/keeper_test.go (1)
Line range hint
52-70
: Update toSetup
function 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.mod
is excluded by!**/*.mod
tests/go.mod
is excluded by!**/*.mod
x/group/go.mod
is excluded by!**/*.mod
x/group/go.sum
is excluded by!**/*.sum
x/mint/go.mod
is excluded by!**/*.mod
x/mint/go.sum
is excluded by!**/*.sum
x/mint/types/mint.pb.go
is 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 theSet
method inMinter
handles all possible error scenarios to prevent panics.x/mint/epoch_hooks.go (1)
16-29
: Ensure that themintFn
used inBeforeEpochStart
is 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 thepanic
inNewKeeper
is handled or logged appropriately to aid in debugging.x/mint/types/genesis.go (1)
10-10
: The newMintFn
type 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 theQuerier
struct and theNewQuerier
function 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 forEpochKeeper
looks good. Ensure all usages correctly handle the pointer semantics.Verification successful
The usages of
EpochKeeper
correctly handle pointer semantics.
ProvideModule
assignsEpochKeeper
the result ofkeeper.NewKeeper
, which returns a pointer.InvokeSetHooks
acceptsEpochKeeper
as 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 ofepochstypes
import is necessary for the new integration with the epochs module.
46-46
: Integration ofEpochHooks
and handling ofMintFn
inProvideModule
are well-implemented. Verify the integration and fallback mechanisms.Also applies to: 76-76, 79-79
Verification successful
The integration of
EpochHooks
andMintFn
is well-implemented across the codebase. The fallback mechanism forMintFn
is correctly handled.
MintFn
is used inx/mint/module.go
,x/mint/depinject.go
,x/mint/keeper/keeper.go
, andsimapp/mint_fn.go
.EpochHooks
is 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 forEpochsKeeper
in 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
EpochsKeeper
and verify the handling ofEpochsKeeper
pointers.
The script successfully located the test files and found occurrences of
EpochsKeeper
in 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
EpochsKeeper
in several test files, includingx/epochs/keeper/keeper_test.go
. The context around these occurrences shows that theEpochsKeeper
pointer type is being handled correctly in the test cases.Transition to pointer type for
EpochsKeeper
in tests is consistent with main code changes. Ensure all test cases correctly handle the pointer type.
x/epochs/keeper/keeper_test.go
x/epochs/keeper/epoch_test.go
x/epochs/keeper/abci_test.go
Scripts 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
: Transitioningkeeper
from a value to a pointer in theAppModule
struct and its constructor enhances performance and maintainability.simapp/mint_fn.go (1)
19-123
: TheProvideExampleMintFn
function 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
: TheDefaultMintFn
function 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 amintFn
field to theAppModule
struct and handling it in theNewAppModule
constructor 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
SetInitialCommission
andbuildCommissionRates
functions, as they seem directly related to commission settings.
To fully understand the commission calculation, we need the complete implementation of both the
SetInitialCommission
andbuildCommissionRates
functions.
To fully verify the commission calculation, we still need the complete implementation of the
SetInitialCommission
function.
The command to extract the remaining part of the
SetInitialCommission
function 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
SetInitialCommission
function validates and sets the commission for the validator.- The
buildCommissionRates
function 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 ofEpochsKeeper
to pointer type aligns with the PR's objectives to enhance performance and manageability.
115-115
: Addition ofProvideExampleMintFn
to the dependency injection setup is consistent with the PR's objectives to introduce new minting logic.simapp/app.go (1)
174-174
: Ensure thatEpochsKeeper
is 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.ArbitraryParams
in theSize
method offastReflection_Minter
might 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
Size
function infastReflection_Minter
already includes a mechanism to ensure deterministic behavior when iterating overx.ArbitraryParams
. Whenoptions.Deterministic
is true, the keys are sorted before iteration, ensuring consistent size calculations.
- Lines 427-443 in
api/cosmos/mint/v1beta1/mint.pulsar.go
handle 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
@@ -21,6 +21,8 @@ message Minter { | |||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | |||
(gogoproto.nullable) = false | |||
]; | |||
|
|||
map<string, string> arbitrary_params = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -35,7 +35,7 @@ func (s *E2ETestSuite) TestTotalSupplyGRPCHandler() { | |||
&types.QueryTotalSupplyResponse{ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the increase ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because now it mints the equivalent of a minute in the first block (the beginning of the epoch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (7)
simapp/go.mod
is excluded by!**/*.mod
tests/go.mod
is excluded by!**/*.mod
x/group/go.mod
is excluded by!**/*.mod
x/group/go.sum
is excluded by!**/*.sum
x/mint/go.mod
is excluded by!**/*.mod
x/mint/go.sum
is excluded by!**/*.sum
x/mint/types/mint.pb.go
is excluded by!**/*.pb.go
Files selected for processing (7)
- api/cosmos/mint/v1beta1/mint.pulsar.go (15 hunks)
- simapp/app.go (1 hunks)
- simapp/mint_fn.go (1 hunks)
- x/epochs/keeper/keeper_test.go (4 hunks)
- x/mint/proto/cosmos/mint/v1beta1/mint.proto (2 hunks)
- x/mint/types/genesis_test.go (1 hunks)
- x/mint/types/params_test.go (1 hunks)
Files not summarized due to errors (1)
- api/cosmos/mint/v1beta1/mint.pulsar.go: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (4)
- simapp/app.go
- simapp/mint_fn.go
- x/epochs/keeper/keeper_test.go
- x/mint/proto/cosmos/mint/v1beta1/mint.proto
Additional context used
Path-based instructions (3)
x/mint/types/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/mint/types/params_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"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.
golangci-lint
x/mint/types/genesis_test.go
10-10: undefined: DefaultInitialMinter
11-11: undefined: DefaultParams
13-13: undefined: NewGenesisState
14-14: undefined: ValidateGenesis
17-17: undefined: DefaultGenesisState
18-18: undefined: ValidateGenesis
x/mint/types/params_test.go
12-12: undefined: DefaultParams
16-16: undefined: NewParams
37-37: undefined: DefaultParams
42-42: undefined: DefaultParams
47-47: undefined: DefaultParams
52-52: undefined: DefaultParams
57-57: undefined: DefaultParams
62-62: undefined: DefaultParams
67-67: undefined: DefaultParams
72-72: undefined: DefaultParams
77-77: undefined: DefaultParams
82-82: undefined: DefaultParams
87-87: undefined: DefaultParams
92-92: undefined: DefaultParams
97-97: undefined: DefaultParams
102-102: undefined: DefaultParams
107-107: undefined: DefaultParams
Additional comments not posted (14)
api/cosmos/mint/v1beta1/mint.pulsar.go (14)
23-23
: Addition offd_Minter_data
field descriptor.This addition aligns with the protobuf changes to include a
data
field in theMinter
message, allowing for custom data in the minting process.
31-31
: Initialization offd_Minter_data
field descriptor.Proper initialization of the field descriptor for the new
data
field in theMinter
message.
111-116
: Handling of thedata
field in theRange
method.The method correctly handles the new
data
field, ensuring it is processed if populated. This is crucial for the correct functioning of protobuf reflection.
136-137
: Check for the presence of thedata
field.The
Has
method has been correctly updated to handle the newdata
field, allowing it to check if the field is populated.
158-159
: Clearing thedata
field.The
Clear
method now supports thedata
field, ensuring that it can be reset as needed.
182-184
: Retrieving thedata
field value.The
Get
method has been updated to retrieve the value of thedata
field correctly, which is essential for accessing this new field.
209-210
: Setting thedata
field value.The
Set
method now supports setting thedata
field, which is crucial for modifying this field through protobuf reflection.
235-236
: Immutable nature of thedata
field in theMutable
method.The
Mutable
method correctly identifies thedata
field as immutable, which is consistent with the handling of byte slices in protobufs.
254-255
: Creating a new field fordata
.The
NewField
method correctly handles the creation of a newdata
field, returning an appropriate default value.
333-336
: Size calculation includesdata
field.The
ProtoMethods
size calculation has been correctly updated to include thedata
field, ensuring accurate size reporting.
366-372
: Marshaling thedata
field.The
Marshal
method correctly handles thedata
field, ensuring it is included in the serialized output.
500-533
: Unmarshaling thedata
field.The
Unmarshal
method has been updated to correctly handle thedata
field, ensuring it can be properly read from the serialized input.
1380-1382
: Documentation for thedata
field.The comment describing the
data
field is clear and informative, providing context for its use in the minting process.
1419-1424
: Getter for thedata
field.The
GetData
method provides a safe way to access thedata
field, returning a copy of the data to prevent unintended modifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (3)
- simapp/app_di.go (3 hunks)
- simapp/mint_fn.go (1 hunks)
- x/mint/epoch_hooks.go (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- simapp/app_di.go
- simapp/mint_fn.go
Additional context used
Path-based instructions (1)
x/mint/epoch_hooks.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
golangci-lint
x/mint/epoch_hooks.go
9-9: undefined: AppModule
12-12: undefined: AppModule
17-17: undefined: AppModule
32-32: undefined: AppModule
Additional comments not posted (4)
x/mint/epoch_hooks.go (4)
3-7
: Import statements are correctly structured and relevant to the file's functionality.
31-34
:AfterEpochEnd
correctly implements a no-operation function as intended.Tools
golangci-lint
32-32: undefined: AppModule
11-14
: Verify implementation ofName()
method inAppModule
.Verification successful
The
Name()
method is correctly implemented in theAppModule
type, ensuring that theGetModuleName
function will work as intended.
Name()
method is defined inx/group/module/module.go
at line 70.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the `Name()` method in `AppModule`. # Test: Search for the `Name` method within `AppModule`. Expect: At least one definition. ast-grep --lang go --pattern $'type AppModule { $$$ } func (am AppModule) Name() string { $$$ }'Length of output: 584
Script:
#!/bin/bash # Description: Verify the implementation of the `Name()` method in `AppModule`. # Test: Search for the `Name` method within `AppModule`. Expect: At least one definition. ast-grep --lang go --pattern $'func (am AppModule) Name() string { $$$ }'Length of output: 227
Tools
golangci-lint
12-12: undefined: AppModule
16-29
: EnsureAppModule
is defined in the project as it's used here but flagged by static analysis.Verification successful
The
AppModule
type is defined in multiple locations within the codebase, includingx/mint/module.go
, which is relevant to the file under review (x/mint/epoch_hooks.go
). This confirms thatAppModule
is indeed defined and the static analysis tool's flagging was a false positive.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `AppModule`. # Test: Search for the definition of `AppModule`. Expect: At least one definition. ast-grep --lang go --pattern $'type AppModule { $$$ }'Length of output: 400
Script:
#!/bin/bash # Description: Verify the definition of `AppModule`. # Test: Search for the definition of `AppModule` using a more general pattern. rg 'type AppModule' --type goLength of output: 1583
Tools
golangci-lint
17-17: undefined: AppModule
x/mint/module_test.go
Outdated
|
||
const govModuleNameStr = "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" | ||
|
||
type IntegrationTestSuite struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integration tests should live with the other integration tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really an integration test, I'll rename it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, missing documentation on the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range and nitpick comments (3)
x/mint/module.go (3)
[!TIP]
Codebase VerificationThe
AppModule
inx/mint/module.go
does not implement the methods required by theappmodule.HasGenesis
interface. The following methods are missing:
DefaultGenesis() json.RawMessage
ValidateGenesis(data json.RawMessage) error
InitGenesis(ctx context.Context, data json.RawMessage) error
ExportGenesis(ctx context.Context) (json.RawMessage, error)
Please ensure these methods are implemented to correctly satisfy the
appmodule.HasGenesis
interface.
Analysis chain
Line range hint
38-38
: Ensure theAppModule
type correctly implements theappmodule.HasGenesis
interface.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `appmodule.HasGenesis` interface by `AppModule`. ast-grep --lang go --pattern $'type AppModule struct { $$$ } implements appmodule.HasGenesis { $$$ }'Length of output: 447
Script:
#!/bin/bash # Step 1: Identify the `appmodule.HasGenesis` interface definition. ast-grep --lang go --pattern $'type HasGenesis interface { $$$ }' # Step 2: Check if `AppModule` implements the methods required by `appmodule.HasGenesis`. ast-grep --lang go --pattern $'type AppModule struct { $$$ }'Length of output: 7980
Script:
#!/bin/bash # Check if the methods required by `appmodule.HasGenesis` are implemented in `x/mint/module.go`. ast-grep --lang go --pattern $'func (a AppModule) DefaultGenesis() json.RawMessage { $$$ }' x/mint/module.go ast-grep --lang go --pattern $'func (a AppModule) ValidateGenesis(data json.RawMessage) error { $$$ }' x/mint/module.go ast-grep --lang go --pattern $'func (a AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error { $$$ }' x/mint/module.go ast-grep --lang go --pattern $'func (a AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) { $$$ }' x/mint/module.goLength of output: 505
[!TIP]
Codebase VerificationThe
AppModule
struct inx/mint/module.go
does not implement theBeginBlocker
method required by theappmodule.HasBeginBlocker
interface.
appmodule.HasBeginBlocker
interface is defined incore/appmodule/v2/module.go
and includes theBeginBlock
method.- No
BeginBlocker
method is implemented inx/mint/module.go
.Please ensure that
AppModule
inx/mint/module.go
implements theBeginBlocker
method to comply with theappmodule.HasBeginBlocker
interface.Analysis chain
Line range hint
34-34
: Ensure theAppModule
type correctly implements theappmodule.HasBeginBlocker
interface.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `appmodule.HasBeginBlocker` interface by `AppModule`. ast-grep --lang go --pattern $'type AppModule struct { $$$ } implements appmodule.HasBeginBlocker { $$$ }'Length of output: 452
Script:
#!/bin/bash # Step 1: Locate the definition of the `AppModule` struct. ast-grep --lang go --pattern 'type AppModule struct { $$$ }' # Step 2: Check if `AppModule` implements the `appmodule.HasBeginBlocker` interface by searching for methods that match the interface. ast-grep --lang go --pattern 'func (a AppModule) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) { $$$ }'Length of output: 7550
Script:
#!/bin/bash # Step 1: Locate the definition of the `appmodule.HasBeginBlocker` interface. ast-grep --lang go --pattern 'type HasBeginBlocker interface { $$$ }' # Step 2: Verify if `AppModule` in `x/mint/module.go` implements the `BeginBlocker` method. ast-grep --lang go --pattern 'func (a AppModule) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) { $$$ }' x/mint/module.goLength of output: 613
[!TIP]
Codebase VerificationThe
HasMigrations
interface is defined incore/appmodule/v2/migrations.go
and includes theRegisterMigrations
method. However, there is no evidence that theAppModule
struct inx/mint/module.go
implements this interface, as there are no methods related to migrations found in the context.
core/appmodule/v2/migrations.go
defines theHasMigrations
interface with theRegisterMigrations
method.- No
Migrate
orRegisterMigrations
methods were found in theAppModule
struct inx/mint/module.go
.Please ensure that the
AppModule
struct inx/mint/module.go
implements theRegisterMigrations
method from theHasMigrations
interface.Analysis chain
Line range hint
36-36
: Ensure theAppModule
type correctly implements theappmodule.HasMigrations
interface.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `appmodule.HasMigrations` interface by `AppModule`. ast-grep --lang go --pattern $'type AppModule struct { $$$ } implements appmodule.HasMigrations { $$$ }'Length of output: 450
Script:
#!/bin/bash # Locate the definition of the `AppModule` struct. ast-grep --lang go --pattern 'type AppModule struct { $$$ }' # Check if `AppModule` implements the `appmodule.HasMigrations` interface. rg 'func (a AppModule) Migrate' --context 5Length of output: 7478
Script:
#!/bin/bash # Search for the definition of the `HasMigrations` interface. rg 'type HasMigrations interface' --context 5 # Search for methods of the `HasMigrations` interface. rg 'func (.*) Migrate' --context 5Length of output: 21747
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (9)
- simapp/app_di.go (3 hunks)
- simapp/mint_fn.go (1 hunks)
- x/mint/CHANGELOG.md (1 hunks)
- x/mint/depinject.go (4 hunks)
- x/mint/keeper/keeper.go (2 hunks)
- x/mint/keeper/keeper_test.go (1 hunks)
- x/mint/module.go (2 hunks)
- x/mint/module_test.go (1 hunks)
- x/mint/types/genesis.go (2 hunks)
Files skipped from review as they are similar to previous changes (4)
- simapp/mint_fn.go
- x/mint/keeper/keeper.go
- x/mint/keeper/keeper_test.go
- x/mint/module_test.go
Additional context used
Path-based instructions (5)
x/mint/CHANGELOG.md (1)
Pattern
**/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"x/mint/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/mint/module.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/app_di.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
LanguageTool
x/mint/CHANGELOG.md
[misspelling] ~37-~37: It seems that a plural noun fits better in this context, or did you forget an article?
Context: ....DefaultMintFnwrapper must be used in other to continue using it in
NewAppModule`....
Markdownlint
x/mint/CHANGELOG.md
30-30: Expected: 0 or 2; Actual: 1
Trailing spaces
golangci-lint
x/mint/types/genesis.go
16-16: undefined: Minter
19-19: undefined: Minter
23-23: undefined: Minter
28-28: undefined: Minter
36-36: undefined: GenesisState
45-45: undefined: GenesisState
29-29: undefined: GenesisState
37-37: undefined: GenesisState
38-38: undefined: DefaultInitialMinter
39-39: undefined: DefaultParams
50-50: undefined: ValidateMinter
x/mint/depinject.go
16-16: undefined: AppModule
19-19: undefined: AppModule
91-91: undefined: NewAppModule
x/mint/module.go
33-33: cannot use AppModule{} (value of type AppModule) as "cosmossdk.io/core/appmodule/v2".AppModule value in variable declaration: AppModule does not implement "cosmossdk.io/core/appmodule/v2".AppModule (missing method IsOnePerModuleType)
34-34: cannot use AppModule{} (value of type AppModule) as "cosmossdk.io/core/appmodule/v2".HasBeginBlocker value in variable declaration: AppModule does not implement "cosmossdk.io/core/appmodule/v2".HasBeginBlocker (missing method IsOnePerModuleType)
35-35: cannot use AppModule{} (value of type AppModule) as "cosmossdk.io/core/appmodule".HasServices value in variable declaration: AppModule does not implement "cosmossdk.io/core/appmodule".HasServices (missing method IsOnePerModuleType)
36-36: cannot use AppModule{} (value of type AppModule) as "cosmossdk.io/core/appmodule/v2".HasMigrations value in variable declaration: AppModule does not implement "cosmossdk.io/core/appmodule/v2".HasMigrations (missing method IsOnePerModuleType)
38-38: cannot use AppModule{} (value of type AppModule) as "cosmossdk.io/core/appmodule/v2".HasGenesis value in variable declaration: AppModule does not implement "cosmossdk.io/core/appmodule/v2".HasGenesis (missing method IsOnePerModuleType)
simapp/app_di.go
62-62: cannot use (*SimApp)(nil) (value of type *SimApp) as "github.com/cosmos/cosmos-sdk/runtime".AppI value in variable declaration: *SimApp does not implement "github.com/cosmos/cosmos-sdk/runtime".AppI (missing method ExportAppStateAndValidators)
114-114: undefined: appConfig
115-115: undefined: ProvideExampleMintFn
239-239: undefined: NewVoteExtensionHandler
254-254: app.RegisterUpgradeHandlers undefined (type *SimApp has no field or method RegisterUpgradeHandlers)
313-313: undefined: NewAnteHandler
314-314: undefined: HandlerOptions
415-415: undefined: moduleAccPerms
426-426: undefined: blockAccAddrs
427-427: undefined: blockAccAddrs
Additional comments not posted (25)
x/mint/types/genesis.go (11)
6-6
: Ensure theMinter
type is defined or imported correctly.Verification successful
The
Minter
type is defined in multiple locations within the codebase, specifically inx/mint/types/mint.pb.go
andapi/cosmos/mint/v1beta1/mint.pulsar.go
. The type is used extensively throughout the codebase, indicating that it is correctly defined and imported.
x/mint/types/mint.pb.go:31
:type Minter struct { ... }
api/cosmos/mint/v1beta1/mint.pulsar.go:1371
:type Minter struct { ... }
The
Minter
type is also referenced in various other files, confirming its presence and usage.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `Minter` type. ast-grep --lang go --pattern $'type Minter { $$$ }'Length of output: 397
Script:
#!/bin/bash # Search for the definition of the `Minter` type in Go files ast-grep --lang go --pattern 'type Minter struct { $$$ }' # Search for import statements that might import `Minter` rg --fixed-strings 'Minter' --glob '*.go'Length of output: 26863
Line range hint
36-36
: Ensure theGenesisState
type is defined or imported correctly.
22-22
: Ensure theMinter
type is defined or imported correctly.Verification successful
The
Minter
type is defined in the following files:
x/mint/types/mint.pb.go
api/cosmos/mint/v1beta1/mint.pulsar.go
This confirms that the
Minter
type is defined correctly within the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `Minter` type. ast-grep --lang go --pattern $'type Minter { $$$ }'Length of output: 397
Script:
#!/bin/bash # Description: Search for the definition of `Minter` type in Go files. rg 'type Minter' --type go # Description: Search for import statements that might include `Minter`. rg 'import' --type goLength of output: 159689
Line range hint
28-28
: Ensure theGenesisState
type is defined or imported correctly.
18-20
: Ensure theMinter
type is defined or imported correctly.Verification successful
The
Minter
type is defined in the codebase, specifically in the following files:
x/mint/types/mint.pb.go
api/cosmos/mint/v1beta1/mint.pulsar.go
The definition in
x/mint/types/mint.pb.go
is as follows:type Minter struct { Inflation cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"inflation"` AnnualProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"annual_provisions"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` }The definition in
api/cosmos/mint/v1beta1/mint.pulsar.go
is as follows:type Minter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Inflation string `protobuf:"bytes,1,opt,name=inflation,proto3" json:"inflation,omitempty"` AnnualProvisions string `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3" json:"annual_provisions,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` }These definitions confirm that the
Minter
type is correctly defined and imported in the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `Minter` type. ast-grep --lang go --pattern $'type Minter { $$$ }'Length of output: 397
Script:
#!/bin/bash # Description: Refine the search for the definition of `Minter` type in Go codebase. # Search for the `Minter` type definition using a more flexible pattern. ast-grep --lang go --pattern 'type Minter struct { $$$ }' # Additionally, search for any alias or import statements that might define `Minter`. rg 'Minter' --type goLength of output: 26843
Tools
golangci-lint
19-19: undefined: Minter
Line range hint
29-29
: Ensure theGenesisState
type is defined or imported correctly.
Line range hint
38-38
: Ensure theDefaultInitialMinter
function is defined or imported correctly.Verification successful
The
DefaultInitialMinter
function is defined in thex/mint/types/minter.go
file. Here is the relevant information:
- Definition: The function
DefaultInitialMinter
is defined inx/mint/types/minter.go
as follows:// DefaultInitialMinter returns a default initial Minter object for a new chain func DefaultInitialMinter() Minter {This confirms that the function is correctly defined and available for use.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `DefaultInitialMinter` function. ast-grep --lang go --pattern $'func DefaultInitialMinter() { $$$ }'Length of output: 68
Script:
#!/bin/bash # Search for the definition of `DefaultInitialMinter` in the entire codebase. ast-grep --lang go --pattern $'func DefaultInitialMinter() { $$$ }' # Search for any import statements that might include `DefaultInitialMinter`. rg 'DefaultInitialMinter' --type goLength of output: 1052
Line range hint
37-37
: Ensure theGenesisState
type is defined or imported correctly.
Line range hint
39-39
: Ensure theDefaultParams
function is defined or imported correctly.Verification successful
The
DefaultParams
function is defined in multiple locations within the codebase, including thex/mint/types/params.go
file, which is relevant to thex/mint/types/genesis.go
file under review.
x/mint/types/params.go: func DefaultParams() Params {
This confirms that the
DefaultParams
function is defined and should be correctly imported or used within thex/mint/types/genesis.go
file.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `DefaultParams` function. ast-grep --lang go --pattern $'func DefaultParams() { $$$ }'Length of output: 61
Script:
#!/bin/bash # Search for the definition of the `DefaultParams` function across the entire codebase. ast-grep --lang go --pattern $'func DefaultParams() { $$$ }' # Search for any import statements that might include `DefaultParams`. rg 'DefaultParams' --type goLength of output: 15479
Line range hint
50-50
: Ensure theValidateMinter
function is defined or imported correctly.Verification successful
The
ValidateMinter
function is defined in thex/mint/types/minter.go
file. Here are the relevant locations:
x/mint/types/minter.go: func ValidateMinter(minter Minter) error {
This confirms that the
ValidateMinter
function is correctly defined and should be accessible.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `ValidateMinter` function. ast-grep --lang go --pattern $'func ValidateMinter($_) { $$$ }'Length of output: 64
Script:
#!/bin/bash # Search for the definition of the `ValidateMinter` function in Go files. ast-grep --lang go --pattern $'func ValidateMinter($_) { $$$ }' # Search for any imports that might include `ValidateMinter`. rg 'ValidateMinter' --type goLength of output: 427
Line range hint
45-45
: Ensure theGenesisState
type is defined or imported correctly.x/mint/depinject.go (3)
Line range hint
19-19
: Ensure theAppModule
type is defined or imported correctly.Verification successful
The
AppModule
type is defined in multiple locations within the codebase, includingx/mint/module.go
. This confirms that theAppModule
type is indeed defined and imported correctly.
x/mint/module.go:42
:type AppModule struct { ... }
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `AppModule` type. ast-grep --lang go --pattern $'type AppModule { $$$ }'Length of output: 400
Script:
#!/bin/bash # Description: Verify the definition of `AppModule` type using a more flexible pattern. ast-grep --lang go --pattern $'type AppModule $$$'Length of output: 8077
91-91
: Ensure theNewAppModule
function is defined or imported correctly.Verification successful
Ensure the
NewAppModule
function is defined or imported correctly.
- The
NewAppModule
function is defined in multiple files, includingx/mint/module.go
, which matches the context ofx/mint/depinject.go
.Locations:
x/mint/module.go: func NewAppModule(
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `NewAppModule` function. ast-grep --lang go --pattern $'func NewAppModule($_, $_, $_, $_) { $$$ }'Length of output: 74
Script:
#!/bin/bash # Description: Verify the definition of `NewAppModule` function with different parameter counts and check for imports. # Search for `NewAppModule` function with different parameter counts ast-grep --lang go --pattern $'func NewAppModule($$$) { $$$ }' # Check for imports of `NewAppModule` rg --fixed-strings 'NewAppModule' --glob '!**/vendor/**'Length of output: 15775
Tools
golangci-lint
91-91: undefined: NewAppModule
Line range hint
16-16
: Ensure theAppModule
type is defined or imported correctly.Verification successful
The
AppModule
type is defined in multiple locations within the codebase, includingx/mint/module.go
. This confirms that theAppModule
type is indeed defined and should be correctly imported or referenced in the filex/mint/depinject.go
.
x/mint/module.go:42:type AppModule struct {
Given this information, the review comment's concern about ensuring the
AppModule
type is defined or imported correctly is addressed.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `AppModule` type. ast-grep --lang go --pattern $'type AppModule { $$$ }'Length of output: 400
Script:
#!/bin/bash # Description: Verify the definition of `AppModule` type with a refined pattern. ast-grep --lang go --pattern 'type AppModule struct { $$$ }' # Description: Check for import statements that might include `AppModule`. rg 'AppModule' --type goLength of output: 147929
x/mint/module.go (2)
Line range hint
35-35
: Ensure theAppModule
type correctly implements theappmodule.HasServices
interface.Verification successful
The results from the shell scripts provide a comprehensive overview of the
AppModule
struct and its methods across various modules. Specifically, for thex/mint/module.go
file, theAppModule
struct and its methods are as follows:
Struct Definition:
type AppModule struct { cdc codec.Codec keeper keeper.Keeper authKeeper types.AccountKeeper mintFn types.MintFn }Methods:
func (am AppModule) RegisterServices(registrar grpc.ServiceRegistrar) error { types.RegisterMsgServer(registrar, keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(registrar, keeper.NewQueryServerImpl(am.keeper)) return nil } func (am AppModule) RegisterMigrations(mr appmodule.MigrationRegistrar) error { m := keeper.NewMigrator(am.keeper) if err := mr.Register(types.ModuleName, 1, m.Migrate1to2); err != nil { return fmt.Errorf("failed to migrate x/%s from version 1 to 2: %w", types.ModuleName, err) } if err := mr.Register(types.ModuleName, 2, m.Migrate2to3); err != nil { return fmt.Errorf("failed to migrate x/%s from version 2 to 3: %w", types.ModuleName, err) } return nil } func (am AppModule) ValidateGenesis(bz json.RawMessage) error { var data types.GenesisState if err := am.cdc.UnmarshalJSON(bz, &data); err != nil { return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return types.ValidateGenesis(data) } func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) { gs, err := am.keeper.ExportGenesis(ctx) if err != nil { return nil, err } return am.cdc.MarshalJSON(gs) } func (am AppModule) BeginBlock(ctx context.Context) error { return am.keeper.BeginBlocker(ctx, am.mintFn) }The
appmodule.HasServices
interface, as defined incore/appmodule/module.go
, requires the following method:type HasServices interface { RegisterServices(grpc.ServiceRegistrar) error }Given the above information, the
AppModule
struct inx/mint/module.go
correctly implements theRegisterServices
method required by theappmodule.HasServices
interface.
- : The
AppModule
type inx/mint/module.go
correctly implements theappmodule.HasServices
interface.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `appmodule.HasServices` interface by `AppModule`. ast-grep --lang go --pattern $'type AppModule struct { $$$ } implements appmodule.HasServices { $$$ }'Length of output: 448
Script:
#!/bin/bash # Step 1: Find the definition of the `appmodule.HasServices` interface. ast-grep --lang go --pattern $'type HasServices interface { $$$ }' # Step 2: Find the definition of the `AppModule` struct. ast-grep --lang go --pattern $'type AppModule struct { $$$ }' # Step 3: List all methods of `AppModule` to verify if it implements the `HasServices` interface. ast-grep --lang go --pattern $'func ($_ AppModule) $_($_) $_ { $$$ }'Length of output: 52206
Line range hint
33-33
: Ensure theAppModule
type correctly implements theappmodule.AppModule
interface.Verification successful
The results show that the
AppModule
struct is defined in multiple files, includingx/mint/module.go
. Additionally, there are several methods implemented forAppModule
across different modules, which suggests thatAppModule
is likely implementing various interfaces, includingappmodule.AppModule
.To ensure that the
AppModule
inx/mint/module.go
correctly implements theappmodule.AppModule
interface, we need to verify the specific methods required by this interface.Let's proceed by checking the methods defined in
x/mint/module.go
to confirm if they align with theappmodule.AppModule
interface.
The methods implemented by
AppModule
inx/mint/module.go
include:
RegisterServices
RegisterMigrations
ValidateGenesis
ExportGenesis
BeginBlock
These methods are consistent with the typical methods required by a module to implement the
appmodule.AppModule
interface. Therefore, it appears thatAppModule
inx/mint/module.go
correctly implements theappmodule.AppModule
interface.
RegisterServices
andRegisterMigrations
are common methods for registering services and migrations.ValidateGenesis
andExportGenesis
handle genesis state validation and export.BeginBlock
is used for block-related operations.Given this information, the
AppModule
type inx/mint/module.go
does indeed implement theappmodule.AppModule
interface.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `appmodule.AppModule` interface by `AppModule`. ast-grep --lang go --pattern $'type AppModule struct { $$$ } implements appmodule.AppModule { $$$ }'Length of output: 446
Script:
#!/bin/bash # Locate the definition of the `AppModule` struct. ast-grep --lang go --pattern 'type AppModule struct { $$$ }' # Check for methods that indicate `AppModule` implements the `appmodule.AppModule` interface. ast-grep --lang go --pattern 'func ($_ AppModule) $_($_) $_ { $$$ }'Length of output: 50721
Script:
#!/bin/bash # Check for methods implemented by `AppModule` in `x/mint/module.go`. ast-grep --lang go --pattern 'func ($_ AppModule) $_($_) $_ { $$$ }' ./x/mint/module.goLength of output: 2234
simapp/app_di.go (9)
115-115
: Ensure theProvideExampleMintFn
function is defined or imported correctly.Verification successful
The
ProvideExampleMintFn
function is defined insimapp/mint_fn.go
with the following signature:func ProvideExampleMintFn(bankKeeper MintBankKeeper) minttypes.MintFn {This confirms that the function is correctly defined and available for use.
simapp/mint_fn.go: func ProvideExampleMintFn(bankKeeper MintBankKeeper) minttypes.MintFn
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `ProvideExampleMintFn` function. ast-grep --lang go --pattern $'func ProvideExampleMintFn() { $$$ }'Length of output: 68
Script:
#!/bin/bash # Description: Verify if `ProvideExampleMintFn` is imported from another package. rg 'ProvideExampleMintFn' --type go # Description: Verify if `ProvideExampleMintFn` is defined with a different signature or in a different way. ast-grep --lang go --pattern $'func ProvideExampleMintFn($_) { $$$ }'Length of output: 442
Tools
golangci-lint
115-115: undefined: ProvideExampleMintFn
Line range hint
313-313
: Ensure theNewAnteHandler
function is defined or imported correctly.Verification successful
The
NewAnteHandler
function is defined in multiple locations within the codebase, specifically inx/auth/ante/ante.go
andsimapp/ante.go
. This confirms that the function is indeed defined and should be correctly imported or referenced.
x/auth/ante/ante.go: func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error)
simapp/ante.go: func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error)
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `NewAnteHandler` function. ast-grep --lang go --pattern $'func NewAnteHandler($_) { $$$ }'Length of output: 64
Script:
#!/bin/bash # Description: Search for the import statements that might include `NewAnteHandler`. rg 'NewAnteHandler' --type go # Re-verify the definition of `NewAnteHandler` function with a broader pattern. ast-grep --lang go --pattern $'func NewAnteHandler$$$'Length of output: 1114
Line range hint
427-427
: Ensure theblockAccAddrs
variable is defined or imported correctly.Verification successful
The
blockAccAddrs
variable is defined insimapp/app_config.go
as follows:
simapp/app_config.go: blockAccAddrs = []string{
This confirms that
blockAccAddrs
is correctly defined and used within the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `blockAccAddrs` variable. ast-grep --lang go --pattern $'var blockAccAddrs $_'Length of output: 53
Script:
#!/bin/bash # Description: Verify the definition or import of `blockAccAddrs` variable in different contexts. # Search for `blockAccAddrs` as a constant ast-grep --lang go --pattern $'const blockAccAddrs $_' # Search for `blockAccAddrs` as a function ast-grep --lang go --pattern $'func blockAccAddrs($_) $_' # Search for `blockAccAddrs` as an imported entity rg 'blockAccAddrs' --type goLength of output: 710
Line range hint
426-426
: Ensure theblockAccAddrs
variable is defined or imported correctly.Verification successful
The
blockAccAddrs
variable is defined and used within thesimapp/app_config.go
file. Here are the relevant lines:
simapp/app_config.go: blockAccAddrs = []string{
simapp/app_config.go: BlockedModuleAccountsOverride: blockAccAddrs,
This confirms that
blockAccAddrs
is defined and used correctly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `blockAccAddrs` variable. ast-grep --lang go --pattern $'var blockAccAddrs $_'Length of output: 53
Script:
#!/bin/bash # Description: Verify the definition or usage of `blockAccAddrs` in different contexts. # Search for `blockAccAddrs` as a function parameter ast-grep --lang go --pattern $'func $_($_ blockAccAddrs $_) $_' # Search for `blockAccAddrs` as a struct field ast-grep --lang go --pattern $'type $_ struct { blockAccAddrs $_ }' # Search for `blockAccAddrs` as a constant ast-grep --lang go --pattern $'const blockAccAddrs $_ = $_'Length of output: 196
Script:
#!/bin/bash # Description: Verify the definition or usage of `blockAccAddrs` in different contexts. # Search for `blockAccAddrs` as a global variable ast-grep --lang go --pattern $'var blockAccAddrs $_' # Search for `blockAccAddrs` as a local variable rg 'blockAccAddrs' # Search for `blockAccAddrs` in import statements rg 'blockAccAddrs' --glob '*.go'Length of output: 549
Line range hint
254-254
: Ensure theRegisterUpgradeHandlers
method is defined or imported correctly.Verification successful
The
RegisterUpgradeHandlers
method is defined insimapp/upgrades.go
as follows:func (app SimApp) RegisterUpgradeHandlers() {This confirms that the method is correctly defined and should be accessible within the
SimApp
struct.
simapp/upgrades.go: func (app SimApp) RegisterUpgradeHandlers() {
The method is also referenced in
simapp/app_di.go
andsimapp/app.go
, indicating that it is being used appropriately.
simapp/app_di.go: app.RegisterUpgradeHandlers()
simapp/app.go: app.RegisterUpgradeHandlers()
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `RegisterUpgradeHandlers` method. ast-grep --lang go --pattern $'func ($_ *SimApp) RegisterUpgradeHandlers($_, $_) { $$$ }'Length of output: 90
Script:
#!/bin/bash # Description: Search for the `RegisterUpgradeHandlers` method with different patterns. ast-grep --lang go --pattern $'func ($_ *SimApp) RegisterUpgradeHandlers($$$) { $$$ }' # Check for any imports that might include `RegisterUpgradeHandlers`. rg 'RegisterUpgradeHandlers' --type goLength of output: 465
Line range hint
314-314
: Ensure theHandlerOptions
type is defined or imported correctly.Verification successful
The
HandlerOptions
type is defined in multiple locations:
./simapp/ante.go
./x/auth/posthandler/post.go
./x/auth/ante/ante.go
Given that
simapp/app_di.go
is part of thesimapp
package, the most relevant definition is likely the one in./simapp/ante.go
.Relevant Definitions:
./simapp/ante.go:14
:type HandlerOptions struct {
./x/auth/posthandler/post.go:8
:type HandlerOptions struct{}
./x/auth/ante/ante.go:16
:type HandlerOptions struct {
The definition in
./simapp/ante.go
appears to be the most relevant forsimapp/app_di.go
.Conclusion:
The
HandlerOptions
type is defined correctly in thesimapp
package.
- : The
HandlerOptions
type is defined correctly in thesimapp
package.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `HandlerOptions` type. ast-grep --lang go --pattern $'type HandlerOptions struct { $$$ }'Length of output: 1132
Line range hint
239-239
: Ensure theNewVoteExtensionHandler
function is defined or imported correctly.Verification successful
The
NewVoteExtensionHandler
function is defined insimapp/abci.go
at line 30. The function returns a pointer to aVoteExtensionHandler
struct.
simapp/abci.go:30
:func NewVoteExtensionHandler() *VoteExtensionHandler {
This confirms that the function is correctly defined and available for use.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `NewVoteExtensionHandler` function. ast-grep --lang go --pattern $'func NewVoteExtensionHandler() { $$$ }'Length of output: 71
Script:
#!/bin/bash # Description: Verify if `NewVoteExtensionHandler` is imported from another package. rg --fixed-strings 'NewVoteExtensionHandler' --glob '*.go' # Description: Check for alternative definitions of `NewVoteExtensionHandler` that might include parameters or return types. ast-grep --lang go --pattern $'func NewVoteExtensionHandler($$$) $$$'Length of output: 471
Line range hint
415-415
: Ensure themoduleAccPerms
variable is defined or imported correctly.Verification successful
The
moduleAccPerms
variable is defined insimapp/app_config.go
as a slice of*authmodulev1.ModuleAccountPermission
. This confirms that the variable is correctly defined and should be accessible within the same package.
simapp/app_config.go
:moduleAccPerms = []*authmodulev1.ModuleAccountPermission{...}
Since
moduleAccPerms
is defined within the same package (simapp
), it should be accessible insimapp/app_di.go
without any import issues.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the definition of `moduleAccPerms` variable. ast-grep --lang go --pattern $'var moduleAccPerms $_'Length of output: 54
Script:
#!/bin/bash # Description: Search for all occurrences of `moduleAccPerms` in the codebase to gather more context. rg 'moduleAccPerms'Length of output: 224
Script:
#!/bin/bash # Description: Extract the relevant lines from `simapp/app_config.go` to verify the definition of `moduleAccPerms`. sed -n '1,20p' simapp/app_config.goLength of output: 993
Script:
#!/bin/bash # Description: Search for the definition of `moduleAccPerms` within `simapp/app_config.go`. rg 'moduleAccPerms' simapp/app_config.goLength of output: 146
Script:
#!/bin/bash # Description: Extract the relevant lines around the definition of `moduleAccPerms` in `simapp/app_config.go`. sed -n '/moduleAccPerms =/,/}/p' simapp/app_config.goLength of output: 155
Line range hint
62-62
: Ensure theSimApp
type correctly implements theruntime.AppI
interface.
@@ -27,12 +27,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
|
|||
### Features | |||
|
|||
* [19896](https://github.com/cosmos/cosmos-sdk/pull/19896) Added a new max supply genesis param to existing params. | |||
* [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Implemented epoched minting, configurable through `MintFn`. Now `MintFn` doesn't do any assumptions on how tokens are minted, users can define their own minting logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the trailing space issue.
- * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Implemented epoched minting, configurable through `MintFn`. Now `MintFn` doesn't do any assumptions on how tokens are minted, users can define their own minting logic.
+ * [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Implemented epoched minting, configurable through `MintFn`. Now `MintFn` doesn't do any assumptions on how tokens are minted, users can define their own minting logic.
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) Implemented epoched minting, configurable through `MintFn`. Now `MintFn` doesn't do any assumptions on how tokens are minted, users can define their own minting logic. | |
* [#20363](https://github.com/cosmos/cosmos-sdk/pull/20363) Implemented epoched minting, configurable through `MintFn`. Now `MintFn` doesn't do any assumptions on how tokens are minted, users can define their own minting logic. |
Tools
Markdownlint
30-30: Expected: 0 or 2; Actual: 1
Trailing spaces
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. This looks very good now.
@@ -111,7 +111,8 @@ func init() { | |||
// AppConfig returns the default app config. | |||
func AppConfig() depinject.Config { | |||
return depinject.Configs( | |||
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML) | |||
appConfig, // Alternatively use appconfig.LoadYAML(AppConfigYAML) | |||
depinject.Provide(ProvideExampleMintFn), // optional: override the mint module's mint function with epoched minting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal opinion: I have seen people just copying the app.go without thinking too much about the configuration. With this change, you make the new mint function default. This may cause some unexpected behaviour and risks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine if this becomes the new default for new apps, we'll get some good side effects from this. For example, we can stop producing empty blocks
@@ -0,0 +1,123 @@ | |||
package simapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! Personally, I would prefer something like x/mint/example
. I do understand your point of keeping it decoupled but it still relates more the mint package than to simapp for me. This is personal preference of course.
func (k Keeper) DefaultMintFn(types.InflationCalculationFn) types.MintFn { | ||
return func(ctx context.Context, env appmodule.Environment, minter *types.Minter, epochId string, epochNumber int64) error { | ||
// the default mint function is called every block, so we only check if epochId is "block" which is | ||
// a special value to indicate that this is not an epoch minting, but a regular block minting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 helpful code doc
} | ||
} | ||
|
||
if mintedCoin.Amount.IsZero() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The checks look good now
x/mint/keeper/keeper.go
Outdated
// calculate the difference between maxSupply and totalSupply | ||
diff := maxSupply.Sub(totalSupply) | ||
if diff.LTE(math.ZeroInt()) { | ||
k.logger.Warn("max supply reached, no new tokens will be minted") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal preference: info level would be fine, too. There are no actionable steps for an operator. The warning level can be annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll apply this suggestion, thank you
… into facu/exp-mintfn2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files ignored due to path filters (1)
x/mint/go.mod
is 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 in
NewAppModule`. 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 newdata
field in theMinter
struct is clearly explained.
83-83
: Clarify the transition fromInflationCalculationFn
toMintFn
.
87-91
: Ensure theMintFn
function signature is correct and matches the implementation.
98-98
: Clarify the conditions under which block-based minting occurs.
|
||
### Improvements | ||
|
||
### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 in
NewAppModule`. Th...
@@ -6,10 +6,15 @@ sidebar_position: 1 | |||
|
|||
## Contents | |||
|
|||
* [Concepts](#concepts) | |||
* [The Minting Mechanism](#the-minting-mechanism) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Context: ...ontents * Concepts * [The Minting Mechanism](#the-minting-mechani...
Markdownlint
10-10: Expected: 2; Actual: 4
Unordered list indentation
|
||
### 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)`.
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.
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
102-102: Expected: 0 or 2; Actual: 1
Trailing spaces
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would you disable this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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
data
field 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)
NewAppModule
now receives aMintFn
instead of aInflationCalculationFn
. If no custom function was being passed in, no breaks occur as it can continue to benil
. If anInflationCalculationFn
was 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.
Now the entire MintFn is user defined, so the user can make it work like it used to work:
Or it can get creative and do other stuff:
Closes: #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.md
Reviewers 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 their own minting logic.Deprecations
InflationCalculationFn
in favor ofMintFn
.Enhancements
Minter
to include data related to minting.telemetry
package for enhanced monitoring and event emission.