-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor(evidence): migrate to env var #19482
Conversation
WalkthroughWalkthroughThe recent updates focus on enhancing the evidence keeper in the blockchain application by integrating a new 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? 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 (
|
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.
infraction test is failing in integration tests. Can you please check that ?
Otherwise lgtm
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.yml
Files selected for processing (8)
- simapp/app.go (1 hunks)
- tests/integration/evidence/keeper/infraction_test.go (3 hunks)
- x/evidence/CHANGELOG.md (1 hunks)
- x/evidence/depinject.go (3 hunks)
- x/evidence/keeper/abci.go (2 hunks)
- x/evidence/keeper/infraction.go (2 hunks)
- x/evidence/keeper/keeper.go (4 hunks)
- x/evidence/keeper/keeper_test.go (4 hunks)
Additional comments: 16
x/evidence/depinject.go (2)
- 29-30: The replacement of
StoreService
withEnvironment
in theModuleInputs
struct is a significant architectural change that aligns with modern development practices for better configuration management. Ensure that theEnvironment
provides all necessary functionalities previously offered byStoreService
.- 45-45: The update in the
ProvideModule
function to utilize the newEnvironment
parameter is consistent with the changes made in theModuleInputs
struct. This modification enhances the modularity of the evidence module by decoupling it from direct service dependencies.x/evidence/keeper/abci.go (1)
- 34-34: Removing the
sdkCtx
variable and directly accessing the logger in theBeginBlocker
function simplifies the code. Ensure that the logger is correctly initialized and accessible in this context.x/evidence/CHANGELOG.md (2)
- 30-31: The changelog entry documenting the migration to
appmodule.Environment
is clear and accurately reflects the significant architectural change. Ensure all significant changes are documented and review the changelog for completeness and accuracy.- 36-36: The documentation of the
x/evidence
module extraction to a separatego.mod
file and modifications toBeginBlocker
andHandleEquivocation
are well-documented in the changelog. This provides clear information on the module's evolution and improvements in modularity.x/evidence/keeper/keeper.go (2)
- 26-26: Replacing the
storeService
field withenvironment
in theKeeper
struct is a significant architectural change that enhances modularity. Ensure thorough testing to verify thatenvironment
provides all necessary functionalities and that there are no regressions in event management.- 109-114: The update in the
SubmitEvidence
function to useenvironment
for event management aligns with the architectural changes made in theKeeper
struct. Ensure that the event management functionality is thoroughly tested to confirm its correctness and efficiency.x/evidence/keeper/infraction.go (2)
- 28-28: Adjusting how the logger is obtained in the
handleEquivocationEvidence
function enhances modularity. Ensure that the logger is correctly initialized and accessible in this context.- 66-71: Using the header service for header information instead of direct context access is a significant improvement that aligns with the PR's objectives. Verify the header service's accuracy and ensure that it provides timely and accurate header information.
x/evidence/keeper/keeper_test.go (2)
- 14-14: The addition of the
"cosmossdk.io/log"
import aligns with the architectural changes made in the keeper and is necessary for the updated logging functionality.- 86-92: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [89-103]
Replacing
storeService
withenv
in theSetupTest()
function and adjusting theLogger()
function call are consistent with the changes made in the keeper. Ensure the test suite is reviewed for completeness and adequately covers the new changes.tests/integration/evidence/keeper/infraction_test.go (3)
- 134-134: The addition of a new parameter for the environment in the
NewKeeper
function call aligns with the PR's objective to migrate the evidence module to use environment variables. However, it's crucial to ensure that this new environment parameter is correctly initialized and passed throughout the test setup to maintain consistency and avoid potential null pointer exceptions.- 274-274: The modification in the
TestHandleDoubleSign_TooOld
function to set the block height and header information differently is a critical change. It's essential to verify that this new context setup accurately reflects the intended test conditions, especially considering the test's focus on handling double sign infractions that are too old. This change should be carefully reviewed to ensure it does not inadvertently affect the test's validity or the accuracy of its assertions.- 309-309: The adjustment in the
TestHandleDoubleSign_TooOld
function to increment the block height and adjust the time based on the consensus parameters is a significant change. This modification is crucial for testing the evidence handling logic for outdated infractions. It's important to ensure that the new block height and time are set correctly to test the intended edge cases without introducing inconsistencies in the test logic.simapp/app.go (2)
- 407-407: The change to the
evidenceKeeper
initialization in theNewSimApp
function to include a new environment parameter with a logger is aligned with the PR's objective of migrating the evidence module to use environment variables for better configuration management and security. This approach enhances modularity and maintainability by decoupling the evidence keeper's dependencies from direct service access, instead relying on an environment abstraction. It's crucial to ensure that all references and usages of the evidence keeper throughout the application are updated to accommodate this change.- 404-410: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-407]
Overall, the modifications in
simapp/app.go
appear to be well-integrated and consistent with the stated objectives of the PR. The introduction of an environment parameter for the evidence keeper aligns with modern development practices and enhances the application's configuration management and security posture. It's recommended to thoroughly test these changes, especially in integration tests, to ensure that the new environment-based configuration does not introduce any regressions or unexpected behavior in the evidence module's functionality.
Description
ref #19290
closes: #19487
migrate evidence module to use env, this leave consensus related things to context for now. This will be removed before the next pr
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
Refactor
BeginBlocker
logic and madeHandleEquivocation
function private for better encapsulation.Tests
Documentation