Skip to content

refactor config pkg #958

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

refactor config pkg #958

wants to merge 5 commits into from

Conversation

ceyonur
Copy link
Collaborator

@ceyonur ceyonur commented May 13, 2025

Why this should be merged

It was a bit weird to get txpool defaults from VM. This PR removes that in favor of retrieving defaults from libevm along with other refactors.

How this works

This pull request introduces several changes to the transaction pool configuration and the EVM plugin's configuration handling. Key updates include simplifying configuration management by removing deprecated fields and methods, updating default values, and enhancing test coverage. The changes aim to streamline the codebase and ensure consistency in configuration handling.

Transaction Pool Configuration Updates:

  • Updated the default transaction pool journal file to "transactions.rlp" and increased the default transaction lifetime from 10 minutes to 3 hours in DefaultConfig. (core/txpool/legacypool/legacypool.go, [1] [2]

EVM Plugin Configuration Simplification:

  • Removed deprecated fields such as CorethAdminAPIEnabled, TxRegossipFrequency, and TxLookupLimit from the Config struct. (plugin/evm/config/config.go, [1] [2] [3]
  • Removed the TxPoolConfig struct and the SetDefaults method, consolidating default configuration management into the GetDefaultConfig and GetConfig functions. (plugin/evm/config/config.go, plugin/evm/config/config.goL247-L320)

Testing Enhancements:

Code Cleanup:

  • Removed unused imports and constants, such as those in plugin/evm/config/config.go and plugin/evm/atomic_syncer_test.go. (plugin/evm/config/config.go, [1]; plugin/evm/atomic_syncer_test.go, [2]
  • Consolidated constants like commitInterval and introduced syncInterval for better readability and maintainability in tests. (plugin/evm/atomic_syncer_test.go, plugin/evm/atomic_syncer_test.goL31-R33)

These changes collectively improve the maintainability and clarity of the transaction pool and EVM plugin configurations, while also ensuring robust testing for future modifications.

How this was tested

UT

Need to be documented?

No

Need to update RELEASES.md?

Yes

@ceyonur ceyonur requested a review from Copilot May 15, 2025 15:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors configuration handling for the transaction pool and EVM plugin by replacing legacy methods with a new default retrieval mechanism from libevm and removing deprecated configuration fields. Key changes include updating default values (e.g. txpool journal and lifetime), simplifying configuration management by removing legacy structs and methods, and enhancing test coverage for the new configuration functions.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plugin/evm/vm_test.go Removed outdated tests for VM configuration settings
plugin/evm/vm.go Replaced legacy config initialization with GetConfig function
plugin/evm/config/default_config.go Updated default configuration values
plugin/evm/config/config_test.go Added tests for GetConfig and updated deprecation handling
plugin/evm/config/config.go Removed deprecated fields and SetDefaults method; added deprecate()
plugin/evm/atomic_syncer_test.go Updated syncer initialization to use new syncInterval constant
core/txpool/legacypool/legacypool.go Updated default journal file and extended lifetime for transactions
RELEASES.md Updated release notes to reflect removal of deprecated config flags


if err := vm.config.Validate(vm.ctx.NetworkID); err != nil {
return err
cfg, deprecateMsg, err := config.GetConfig(configBytes, vm.ctx.NetworkID)
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider logging or otherwise handling the deprecation message returned by GetConfig (deprecateMsg) so that users are informed when deprecated configuration flags are provided.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably copilot is right, something like, but unless you're trying to maintain some interface, I think it would make sense to change this to
cfg, err := config.GetConfig(configBytes, vm.ctx.NetworkID)
And just log in deprecate call. We can log with varying levels: e.g. we force switch to Firewood we can have log.Crit, but some other minor issues can just have a warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate() does change the config itself (moves from flag to another). I really would like to keep a single call to config to get the config. If this is really weird looking I can move the deprecate call to where we log it

@ceyonur ceyonur marked this pull request as ready for review May 15, 2025 15:01
@ceyonur ceyonur requested a review from a team as a code owner May 15, 2025 15:01
Copy link
Contributor

@alarso16 alarso16 left a 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 reasonable, just don't love the deprecate message style, but that might just be me


if err := vm.config.Validate(vm.ctx.NetworkID); err != nil {
return err
cfg, deprecateMsg, err := config.GetConfig(configBytes, vm.ctx.NetworkID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably copilot is right, something like, but unless you're trying to maintain some interface, I think it would make sense to change this to
cfg, err := config.GetConfig(configBytes, vm.ctx.NetworkID)
And just log in deprecate call. We can log with varying levels: e.g. we force switch to Firewood we can have log.Crit, but some other minor issues can just have a warning.

)

const (
defaultCommitInterval = 4096
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't like how there's just the one constant up here, feels unnecessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it bc we use it for both commit interval + sync interval

@@ -177,7 +175,7 @@ var DefaultConfig = Config{
AccountQueue: 64,
GlobalQueue: 1024,

Lifetime: 10 * time.Minute,
Lifetime: 3 * time.Hour,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the diff between upstream.

// If we re-enable txpool journaling, we should also add the saved local
// transactions to the p2p gossip on startup.
Journal: "",
Journal: "transactions.rlp",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be overriden in VM

@@ -177,7 +175,7 @@ var DefaultConfig = Config{
AccountQueue: 64,
GlobalQueue: 1024,

Lifetime: 10 * time.Minute,
Lifetime: 3 * time.Hour,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be overriden in config defaults

@@ -177,7 +175,7 @@ var DefaultConfig = Config{
AccountQueue: 64,
GlobalQueue: 1024,

Lifetime: 10 * time.Minute,
Lifetime: 3 * time.Hour,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To reduce the diff between upstream.


if err := vm.config.Validate(vm.ctx.NetworkID); err != nil {
return err
cfg, deprecateMsg, err := config.GetConfig(configBytes, vm.ctx.NetworkID)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecate() does change the config itself (moves from flag to another). I really would like to keep a single call to config to get the config. If this is really weird looking I can move the deprecate call to where we log it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants