-
Notifications
You must be signed in to change notification settings - Fork 6
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: set precompiles after keeper creation #101
Conversation
WalkthroughWalkthroughThe recent changes introduce a new method to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Keeper
participant ContractManager
User->>Keeper: WithStatefulPrecompiledContracts(contracts)
Keeper->>ContractManager: Register custom contracts
ContractManager->>Keeper: Acknowledge registration
Keeper->>User: Confirmation of custom contracts setup
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #101 +/- ##
==========================================
- Coverage 67.73% 67.72% -0.02%
==========================================
Files 124 124
Lines 11452 11454 +2
==========================================
Hits 7757 7757
- Misses 3254 3256 +2
Partials 441 441
|
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 UI
Review profile: CHILL
Files selected for processing (1)
- x/evm/keeper/keeper.go (1 hunks)
Additional comments not posted (1)
x/evm/keeper/keeper.go (1)
418-420
: Approved: Addition ofWithStatefulPrecompiledContracts
.The method
WithStatefulPrecompiledContracts
correctly assigns the provided slice ofCustomContractFn
to thecustomContractFns
field of theKeeper
. This addition is clear and concise, enhancing the flexibility of theKeeper
.It is advisable to verify the usage of this method throughout the codebase to ensure it is integrated correctly and does not introduce circular dependencies or other issues.
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.
func (k *Keeper) WithStatefulPrecompiledContracts(contracts []CustomContractFn) { | ||
k.customContractFns = contracts | ||
} |
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.
Refactor the method for better readability and safety.
Consider applying the following refactors:
- Rename the method to
SetStatefulPrecompiledContracts
to clearly indicate that it's a setter method. - Return the
Keeper
instance to allow method chaining, which can lead to more concise and readable code. - Add a nil check for the
contracts
argument to prevent setting a nil slice and to improve the method's defensive programming.
Here's the updated method with the suggested changes:
func (k *Keeper) SetStatefulPrecompiledContracts(contracts []CustomContractFn) *Keeper {
if contracts == nil {
panic("contracts cannot be nil")
}
k.customContractFns = contracts
return k
}
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs. |
Description
When creating an EVM Keeper with precompiles from the core Zeta node, it can be the case there are circular dependencies, such as:
To solve this a function to set the precompiles is exposed:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation