-
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
feat(server/v2/cometbft): wire mempool config #21741
Conversation
@julienrbrt your pull request is missing a changelog! |
WalkthroughWalkthroughThe changes introduced in this pull request enhance the configuration options for the CometBFT server, particularly focusing on the mempool functionality. New configuration fields have been added, and server options have been refactored to support dynamic configuration management. Additionally, new functions for initializing server configurations have been implemented, allowing for specific adjustments to logging, timeout settings, and server options. Changes
Assessment against linked issues
Recent review detailsConfiguration used: .coderabbit.yml Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
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
Documentation and Community
|
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
Outside diff range and nitpick comments (1)
server/v2/cometbft/flags.go (1)
54-60
: LGTM! The new server flag enhances configurability.The addition of the
FlagMempoolMaxTxs
server flag is a good practice to allow configuring the maximum number of transactions in the mempool. The flag is properly prefixed with the server name using theprefix
function, which is consistent with the existing flags.Suggestions for further improvement:
- Consider adding a comment to describe the purpose of the flag, e.g.,
// FlagMempoolMaxTxs sets the maximum number of transactions in the mempool
.- Consider adding a default value for the flag to provide a sensible default configuration.
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (9)
- server/v2/cometbft/config.go (3 hunks)
- server/v2/cometbft/flags.go (1 hunks)
- server/v2/cometbft/mempool/config.go (1 hunks)
- server/v2/cometbft/mempool/doc.go (1 hunks)
- server/v2/cometbft/options.go (2 hunks)
- server/v2/cometbft/server.go (4 hunks)
- server/v2/commands.go (1 hunks)
- simapp/v2/simdv2/cmd/commands.go (1 hunks)
- simapp/v2/simdv2/cmd/config.go (2 hunks)
Files skipped from review due to trivial changes (1)
- server/v2/cometbft/mempool/doc.go
Additional context used
Path-based instructions (8)
server/v2/cometbft/mempool/config.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/cometbft/options.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/cometbft/flags.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/cometbft/config.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/v2/simdv2/cmd/config.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.simapp/v2/simdv2/cmd/commands.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/commands.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.server/v2/cometbft/server.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (20)
server/v2/cometbft/mempool/config.go (3)
3-3
: LGTM!The declaration of the
DefaultMaxTx
variable with a value of-1
is clear and appropriate. It serves as a well-defined default value for the maximum number of transactions in the mempool.
7-8
: Excellent documentation!The updated comment for the
MaxTxs
field provides clear and comprehensive information about its behavior. It covers all possible scenarios and helps users understand how to configure the mempool effectively.
11-15
: Great addition!The
DefaultConfig()
function is a valuable addition to the package. It provides a convenient way to obtain a default configuration for the mempool, enhancing usability and reducing the chances of misconfiguration.server/v2/cometbft/options.go (4)
12-12
: LGTM!The comment provides a clear and concise explanation of the purpose and functionality of the
ServerOptions
struct fields.
14-14
: Excellent change to improve configurability!The modification of the
Mempool
field to be a function that accepts a configuration map enhances the flexibility and adaptability of the server. By allowing dynamic configuration based on runtime settings, the server can cater to various use cases and requirements. The use of theany
type for the configuration values further increases the versatility of the configuration options.
20-20
: Great change to enhance snapshot configurability!The modification of the
SnapshotOptions
field to be a function that accepts a configuration map is a positive change that improves the flexibility and adaptability of the server's snapshot functionality. By allowing dynamic configuration based on runtime settings, the server can accommodate different snapshot requirements and scenarios. The use of theany
type for the configuration values further enhances the versatility of the configuration options.
30-35
: Updates toDefaultServerOptions
function are consistent and maintain defaults!The changes made to the
DefaultServerOptions
function accurately reflect the modifications made to theServerOptions
struct. By initializing theMempool
andSnapshotOptions
fields with anonymous functions that return the default implementations, the function maintains consistency with the new field types. This approach ensures that the server can operate with minimal configuration if needed, while still allowing for flexibility when custom configurations are provided.server/v2/cometbft/config.go (4)
4-5
: LGTM!The import statement for the
mempool
package is correct and necessary for utilizing the default mempool configurations.
25-25
: LGTM!The modification to the
DefaultAppTomlConfig
function, which initializes theMempool
field with the default mempool configuration, is correct and aligns with the objective of integrating mempool settings into the application's configuration structure.
38-40
: LGTM!The addition of the
Mempool
field to theAppTomlConfig
struct, along with the appropriate TOML configuration mapping annotation and comments, is correct and enhances the application's configurability by integrating mempool settings into its configuration structure.
Line range hint
1-60
: Code conforms to the Uber Golang style guide.The file adheres to the Uber Golang style guide, following the recommended naming conventions, formatting, and commenting practices. No deviations were found.
simapp/v2/simdv2/cmd/config.go (2)
78-89
: LGTM!The
initCometConfig
function correctly customizes the default CometBFT configuration by modifying the logging levels, block timeout, and pprof listener address. The changes are clear and do not introduce any apparent issues.
91-104
: Provide more details about the mempool interface mismatch and the plans for the maximum transactions option.The
initCometOptions
function currently does not make any modifications to the default server options. There is a TODO comment indicating a mismatch between the mempool interfaces, but no further details are provided.Additionally, there is a commented-out code block that suggests an intention to overwrite the application mempool using a maximum transactions option, but it is currently not implemented.
Could you please provide more information about the following:
- The specific nature of the mempool interface mismatch and how it affects the integration with the CometBFT server.
- The plans and timeline for implementing the maximum transactions option and any potential challenges or considerations.
This will help in understanding the current state of the code and the future direction of the mempool configuration.
simapp/v2/simdv2/cmd/commands.go (1)
77-81
: LGTM! The changes enhance the customizability of the CometBFT component.The modifications to the
cometbft.New
function call introduce new parametersinitCometOptions[T]()
andinitCometConfig()
, replacing the default server options. This change suggests a shift towards a more flexible and customizable configuration for the CometBFT component, allowing for tailored options and settings during initialization.The updated implementation aligns with the PR objectives of wiring the mempool configuration in the server component and potentially improves the overall functionality by providing more control over the CometBFT configuration.
The changes do not introduce any apparent correctness, performance, or security issues.
server/v2/commands.go (2)
48-48
: LGTM!The
NewServer
function is correctly using theglobalServerCfg
parameter, which aligns with the previous change.
41-41
: Verify the initialization and usage ofglobalServerCfg
across the codebase.The renaming of the parameter from
serverCfg
toglobalServerCfg
suggests a shift in the intended scope of the configuration. Ensure thatglobalServerCfg
is properly initialized and contains the necessary settings for the server to function correctly.Run the following script to verify the usage of
globalServerCfg
:Verification successful
Renaming to
globalServerCfg
is appropriate and consistent with codebase usageThe change from
serverCfg
toglobalServerCfg
accurately reflects its usage in the codebase. TheServerConfig
struct is defined inserver/v2/config.go
and contains settings for minimum gas prices. The parameter is correctly used in theAddCommands
function and passed toNewServer
.While the config is not initialized within the function, this is expected as it's likely passed in from a higher level, allowing for flexible configuration management.
- The usage is limited to
server/v2/commands.go
, which is appropriate for its purpose.- The "global" prefix clarifies its scope of use across different server components.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the initialization and usage of `globalServerCfg` across the codebase. # Test: Search for the initialization of `globalServerCfg`. Expect: At least one occurrence. rg --type go $'globalServerCfg\s*:?=\s*\S+' # Test: Search for the usage of `globalServerCfg`. Expect: Multiple occurrences. rg --type go -w globalServerCfgLength of output: 214
Script:
#!/bin/bash # Description: Further investigation of `globalServerCfg` initialization and usage # Test 1: Search for any assignments to globalServerCfg with a more flexible pattern echo "=== Searching for globalServerCfg assignments ===" rg --type go -i 'globalServerCfg.*=' # Test 2: Look for the definition of ServerConfig type echo "=== Searching for ServerConfig type definition ===" ast-grep --lang go --pattern 'type ServerConfig struct { $$$ }' # Test 3: Perform a case-insensitive search for globalServerCfg echo "=== Performing case-insensitive search for globalServerCfg ===" rg --type go -i globalservercfgLength of output: 1046
server/v2/cometbft/server.go (4)
27-27
: LGTM!The import statement for the
mempool
package is valid and relevant to the mempool functionality being implemented.
109-109
: Looks good!The modification to pass the
cfg
map tos.serverOptions.Mempool
enhances the configurability of the mempool, aligning with the PR objective. The change is clean and localized.
131-131
: Looks good!The modification to pass the
cfg
map tos.serverOptions.SnapshotOptions
enhances the configurability of the snapshot manager, following a pattern similar to the mempool configuration change. The change is clean and localized.
244-244
: Looks good!The addition of the
FlagMempoolMaxTxs
flag allows users to configure the maximum transaction count for the application-side mempool. The flag is added correctly to theStartCmdFlags
function, uses a sensible default value, and follows the existing flag declaration pattern.
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.
let recreate the same interface. Les breakage and some teams then don't need to rewrite the api
Doing this in a follow-up to keep this PR focused. |
(cherry picked from commit 52ba264) # Conflicts: # server/v2/commands.go
Description
Closes: #21733
Note, that the sdkmempool interface vs the cometbft server mempool interface differs.
Meaning, we cannot use directly the SDK mempool in the new cometbft server.
types/mempool
server/v2/cometbft/mempool
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Refactor
These changes improve the flexibility and configurability of the application, allowing users to tailor settings to their needs.