-
Notifications
You must be signed in to change notification settings - Fork 195
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
test(sim): add sim genesis state for custom modules #1759
Conversation
WalkthroughThe recent updates involve refining the Cosmos SDK modules by enhancing exported entities, reorganizing imports, and implementing the Changes
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? TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (11)
- x/devgas/v1/module.go (7 hunks)
- x/devgas/v1/simulation/genesis.go (1 hunks)
- x/inflation/module.go (2 hunks)
- x/inflation/simulation/genesis.go (1 hunks)
- x/perp/v2/module/module.go (2 hunks)
- x/perp/v2/simulation/genesis.go (1 hunks)
- x/spot/module.go (2 hunks)
- x/spot/simulation/genesis.go (1 hunks)
- x/sudo/simulation/genesis.go (1 hunks)
- x/tokenfactory/module.go (7 hunks)
- x/tokenfactory/simulation/genesis.go (1 hunks)
Additional comments: 23
x/perp/v2/simulation/genesis.go (1)
- 14-24: The
RandomizedGenState
function correctly initializes a default genesis state, marshals it into JSON, and assigns it to the simulation state. The use ofpanic
andMustMarshalJSON
is appropriate here as this code is for simulation setup where failures are critical and should stop execution.x/sudo/simulation/genesis.go (1)
- 14-22: The
RandomizedGenState
function in thesudo
module correctly introduces arootAddress
to randomize the genesis state. The use ofpanic
andMustMarshalJSON
is appropriate for simulation setup code.x/spot/simulation/genesis.go (1)
- 23-34: The
RandomizedGenState
function correctly initializes a default genesis state for thespot
module, marshals it into JSON, and assigns it to the simulation state. The use ofMustMarshalJSON
ensures proper error handling for simulation setup.x/devgas/v1/simulation/genesis.go (1)
- 24-46: The
RandomizedGenState
function for thedevgas
module correctly generates a randomdeveloperFeeShare
and uses it to initialize the genesis state. The use ofGetOrGenerate
for parameter generation andMustMarshalJSON
for marshaling is appropriate for simulation setup.x/tokenfactory/simulation/genesis.go (1)
- 23-44: The
RandomizedGenState
function for thetokenfactory
module correctly generates a randomdenomCreationGasConsume
and uses it to initialize the genesis state. The use ofGetOrGenerate
for parameter generation andMustMarshalJSON
for marshaling is appropriate for simulation setup.x/inflation/simulation/genesis.go (1)
- 15-47: The
RandomizedGenState
function for theinflation
module initializes the genesis state with hardcoded values for simulation purposes. The use ofpanic
andMustMarshalJSON
for error handling is appropriate for simulation setup.x/inflation/module.go (1)
- 157-158: The
GenerateGenesisState
function in theinflation
module has been correctly updated to accept asimState
parameter and call theRandomizedGenState
function from thesimulation
package, aligning with the PR objectives to set up simulation genesis states.x/spot/module.go (1)
- 161-162: The
GenerateGenesisState
function has been correctly added to thespot
module'sAppModule
, and the module now implements theAppModuleSimulation
interface, which is in line with the PR objectives for simulation enhancements.x/perp/v2/module/module.go (1)
- 175-176: The
GenerateGenesisState
function has been correctly added to theperp
module'sAppModule
, and the module now implements theAppModuleSimulation
interface, which aligns with the PR objectives for simulation enhancements.x/tokenfactory/module.go (7)
23-31: The import of
simtypes
and renaming of module references totypes
are consistent with the PR objectives to set up simulation genesis state for modules.51-51: The reference to
ModuleName
has been correctly updated to use thetypes
package.70-85: The
RegisterInterfaces
andDefaultGenesis
functions have been updated to use thetypes
package. Ensure that thetypes
package contains the correct implementations for these functions.Verification successful
The shell script output confirms that the
types
package in thex/tokenfactory
directory contains theRegisterInterfaces
andDefaultGenesis
functions. TheRegisterInterfaces
function is located incodec.go
, and theDefaultGenesis
function is ingenesis.go
.
- The
RegisterInterfaces
function is correctly implemented in thetypes
package.- The
DefaultGenesis
function is also present and correctly implemented in thetypes
package.Based on the provided output, the changes to the
RegisterInterfaces
andDefaultGenesis
functions to use thetypes
package are verified to be correct.* 96-108: The `RegisterGRPCGatewayRoutes`, `GetTxCmd`, and `GetQueryCmd` functions have been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for these functions.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterInterfaces' 'x/tokenfactory/types' rg --type go 'func DefaultGenesis' 'x/tokenfactory/types'Length of output: 284
Verification successful
The review comment is concerned with the updates to the
RegisterGRPCGatewayRoutes
,GetTxCmd
, andGetQueryCmd
functions to use thetypes
package. The shell script output confirms the presence of the necessary functions in the respective packages:
RegisterQueryHandlerClient
is found inx/tokenfactory/types/query.pb.gw.go
.NewTxCmd
is found inx/tokenfactory/cli/tx.go
.NewQueryCmd
is found inx/tokenfactory/cli/query.go
.Based on the script output, the functions are correctly located in their respective packages, which aligns with the changes mentioned in the review comment.
* 148-151: The `RegisterServices` function has been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for these functions.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterQueryHandlerClient' 'x/tokenfactory/types' rg --type go 'func NewTxCmd' 'x/tokenfactory/cli' rg --type go 'func NewQueryCmd' 'x/tokenfactory/cli'Length of output: 434
Verification successful
The shell script output confirms that the
types
package contains the necessary functionsRegisterMsgServer
andRegisterQueryServer
. These functions are defined intx.pb.go
andquery.pb.go
respectively within thex/tokenfactory/types
directory.
RegisterMsgServer
is present inx/tokenfactory/types/tx.pb.go
.RegisterQueryServer
is present inx/tokenfactory/types/query.pb.go
.Based on this information, the review comment has been addressed correctly.
* 167-167: The `InitGenesis` function has been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for this function.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterMsgServer' 'x/tokenfactory/types' rg --type go 'func RegisterQueryServer' 'x/tokenfactory/types'Length of output: 302
Verification successful
The
InitGenesis
function is indeed present within thekeeper
package of thetokenfactory
module, as indicated by the output of the script. This confirms that thetypes
package is being used correctly in the context of theInitGenesis
function within thetokenfactory
module.* 180-192: New simulation-related functions `GenerateGenesisState`, `RegisterStoreDecoder`, and `WeightedOperations` have been added. Ensure that these functions are correctly implemented and align with the simulation setup objectives.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func InitGenesis' 'x/tokenfactory/keeper'Length of output: 55
Script:
#!/bin/bash # Search for the InitGenesis function within the types package of the tokenfactory module. rg --type go 'func InitGenesis' 'x/tokenfactory/types'Length of output: 54
Script:
#!/bin/bash # Search for the InitGenesis function definition in the keeper package of the tokenfactory module. rg --type go 'func \(.*Keeper\) InitGenesis'Length of output: 155
Verification successful
The
RandomizedGenState
function exists in thex/tokenfactory/simulation
package, confirming that theGenerateGenesisState
method inAppModule
is correctly implemented by calling this function.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the simulation package. rg --type go 'func RandomizedGenState' 'x/tokenfactory/simulation'Length of output: 163
x/devgas/v1/module.go (7)
14-23: The import of
simtypes
and renaming of module references totypes
are consistent with the PR objectives to set up simulation genesis state for modules.41-41: The reference to
ModuleName
has been correctly updated to use thetypes
package.60-78: The
RegisterInterfaces
andDefaultGenesis
functions have been updated to use thetypes
package. Ensure that thetypes
package contains the correct implementations for these functions.Verification successful
The shell script output confirms that the
types
package contains theRegisterInterfaces
function inx/devgas/v1/types/codec.go
and theDefaultGenesisState
function inx/devgas/v1/types/genesis.go
. These functions are correctly implemented and available for use in themodule.go
file as indicated by the changes.
* 86-98: The `RegisterGRPCGatewayRoutes`, `GetTxCmd`, and `GetQueryCmd` functions have been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for these functions.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterInterfaces' 'x/devgas/v1/types' rg --type go 'func DefaultGenesisState' 'x/devgas/v1/types'Length of output: 282
Verification successful
The shell script output confirms the presence of the functions
RegisterQueryHandlerClient
,NewTxCmd
, andGetQueryCmd
in the respective packages as referenced in the code snippet fromx/devgas/v1/module.go
. Thetypes
package contains theRegisterQueryHandlerClient
function, and thecli
package contains bothNewTxCmd
andGetQueryCmd
functions.
RegisterQueryHandlerClient
is found inx/devgas/v1/types/query.pb.gw.go
.NewTxCmd
is found inx/devgas/v1/client/cli/tx.go
.GetQueryCmd
is found inx/devgas/v1/client/cli/query.go
.Based on this information, the review comment is verified as the functions are correctly implemented in their respective packages.
* 143-147: The `RegisterServices` function has been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for these functions.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterQueryHandlerClient' 'x/devgas/v1/types' rg --type go 'func NewTxCmd' 'x/devgas/v1/client/cli' rg --type go 'func GetQueryCmd' 'x/devgas/v1/client/cli'Length of output: 444
Verification successful
The shell script output confirms that the
types
package contains theRegisterMsgServer
function and thekeeper
package contains theNewQuerier
function. These functions are correctly implemented in their respective packages as indicated by the presence of their definitions in thetx.pb.go
andgrpc_query.go
files.
RegisterMsgServer
is found inx/devgas/v1/types/tx.pb.go
.NewQuerier
is found inx/devgas/v1/keeper/grpc_query.go
.Based on this information, the review comment has been addressed correctly.
* 162-162: The `InitGenesis` function has been updated to use the `types` package. Ensure that the `types` package contains the correct implementations for this function.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the types package. rg --type go 'func RegisterMsgServer' 'x/devgas/v1/types' rg --type go 'func NewQuerier' 'x/devgas/v1/keeper'Length of output: 261
- 180-191: New simulation-related functions
GenerateGenesisState
,RegisterStoreDecoder
, andWeightedOperations
have been added. Ensure that these functions are correctly implemented and align with the simulation setup objectives.Verification successful
The
RandomizedGenState
function is present in thex/devgas/v1/simulation
package, which confirms that theGenerateGenesisState
method in theAppModule
is correctly implemented by calling this function.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that the necessary functions are present in the simulation package. rg --type go 'func RandomizedGenState' 'x/devgas/v1/simulation'Length of output: 157
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Additional comments: 2
CHANGELOG.md (2)
89-89: The version bump for
google.golang.org/protobuf
is correctly documented. This is a routine update likely for improvements or security patches.81-92: The rest of the changelog entries within the hunk are consistent and provide the necessary information about the changes and dependency updates.
@@ -81,10 +81,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
* [#1728](https://github.com/NibiruChain/nibiru/pull/1728) - test(devgas-cli): CLI tests for devgas txs | |||
* [#1735](https://github.com/NibiruChain/nibiru/pull/1735) - test(sim): fix simulation tests | |||
* [#1754](https://github.com/NibiruChain/nibiru/pull/1754) - refactor(decode-base64): clean code improvements and fn docs | |||
* [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all cusom modules |
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 entry for PR #1736 is missing a description of the changes made. It's important for the changelog to include a brief summary of each change for clarity.
* [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all cusom modules
+ * [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all custom modules. This change sets up the simulation genesis state for various custom modules within the Nibiru blockchain framework, enhancing the simulation capabilities for testing.
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.
* [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all cusom modules | |
* [#1736](https://github.com/NibiruChain/nibiru/pull/1736) - test(sim): add sim genesis state for all custom modules. This change sets up the simulation genesis state for various custom modules within the Nibiru blockchain framework, enhancing the simulation capabilities for testing. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1759 +/- ##
==========================================
- Coverage 73.46% 73.43% -0.03%
==========================================
Files 195 194 -1
Lines 15449 15459 +10
==========================================
+ Hits 11350 11353 +3
- Misses 3437 3444 +7
Partials 662 662
|
Purpose / Abstract
Scaffolds the simulation genesis state for Nibiru's custom modules. I decided to go with a breadth approach (multiple modules) instead of a depth approach (a single module) for the sim genesis state because the code was repetitive so it would be easier to review.
Helps towards closing #1736.
Summary by CodeRabbit
New Features
Improvements
Documentation
Dependency Updates
google.golang.org/protobuf
from version 1.31.0 to 1.32.0.