-
Notifications
You must be signed in to change notification settings - Fork 157
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
base: master
Are you sure you want to change the base?
refactor config pkg #958
Conversation
Signed-off-by: Ceyhun Onur <[email protected]>
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.
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) |
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.
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.
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.
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.
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.
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
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.
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) |
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.
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 |
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.
nit: I don't like how there's just the one constant up here, feels unnecessary.
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.
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, |
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.
What's this change for?
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.
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", |
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.
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, |
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.
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, |
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.
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) |
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.
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
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:
"transactions.rlp"
and increased the default transaction lifetime from 10 minutes to 3 hours inDefaultConfig
. (core/txpool/legacypool/legacypool.go
, [1] [2]EVM Plugin Configuration Simplification:
CorethAdminAPIEnabled
,TxRegossipFrequency
, andTxLookupLimit
from theConfig
struct. (plugin/evm/config/config.go
, [1] [2] [3]TxPoolConfig
struct and theSetDefaults
method, consolidating default configuration management into theGetDefaultConfig
andGetConfig
functions. (plugin/evm/config/config.go
, plugin/evm/config/config.goL247-L320)Testing Enhancements:
GetConfig
to validate proper default value assignment and configuration unmarshalling. (plugin/evm/config/config_test.go
, plugin/evm/config/config_test.goL130-R162)tx-lookup-limit
. (plugin/evm/config/config_test.go
, plugin/evm/config/config_test.goL108-L113)Code Cleanup:
plugin/evm/config/config.go
andplugin/evm/atomic_syncer_test.go
. (plugin/evm/config/config.go
, [1];plugin/evm/atomic_syncer_test.go
, [2]commitInterval
and introducedsyncInterval
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