This repository was archived by the owner on Nov 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 160
refactor: Split config package so it doesn't import core, core/vm #734
Merged
+118
−18
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8f1ed91
refactor: Split config package so it doesn't end up importing core, c…
baffddb
Merge branch 'master' into split-config-type
7bc9381
adding UT to forbid certain imports
5efb9ff
Merge branch 'split-config-type' of github.com:ava-labs/coreth into s…
9654dac
add comment
25646ee
Revert "refactor: Split config package so it doesn't end up importing…
a33db3b
apply review suggestions
f156efa
Merge branch 'master' of github.com:ava-labs/coreth into split-config…
2d100c5
Merge branch 'master' into split-config-type
b9b887f
Update plugin/evm/imports_test.go
be34fc4
Update plugin/evm/imports_test.go
bf08ba4
add comment
afb9538
Update plugin/evm/config.go
304e096
Update plugin/evm/config/config.go
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| // (c) 2025, Ava Labs, Inc. All rights reserved. | ||
| // See the file LICENSE for licensing terms. | ||
|
|
||
| package evm | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "github.com/ava-labs/avalanchego/utils/constants" | ||
| "github.com/ava-labs/coreth/core/txpool/legacypool" | ||
| "github.com/ava-labs/coreth/eth" | ||
| "github.com/ava-labs/coreth/plugin/evm/config" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| ) | ||
|
|
||
| type Config config.Config | ||
|
|
||
| const ( | ||
| defaultAcceptorQueueLimit = 64 // Provides 2 minutes of buffer (2s block target) for a commit delay | ||
| defaultPruningEnabled = true | ||
| defaultCommitInterval = 4096 | ||
| defaultTrieCleanCache = 512 | ||
| defaultTrieDirtyCache = 512 | ||
| defaultTrieDirtyCommitTarget = 20 | ||
| defaultTriePrefetcherParallelism = 16 | ||
| defaultSnapshotCache = 256 | ||
| defaultSyncableCommitInterval = defaultCommitInterval * 4 | ||
| defaultSnapshotWait = false | ||
| defaultRpcGasCap = 50_000_000 // Default to 50M Gas Limit | ||
| defaultRpcTxFeeCap = 100 // 100 AVAX | ||
| defaultMetricsExpensiveEnabled = true | ||
| defaultApiMaxDuration = 0 // Default to no maximum API call duration | ||
| defaultWsCpuRefillRate = 0 // Default to no maximum WS CPU usage | ||
| defaultWsCpuMaxStored = 0 // Default to no maximum WS CPU usage | ||
| defaultMaxBlocksPerRequest = 0 // Default to no maximum on the number of blocks per getLogs request | ||
| defaultContinuousProfilerFrequency = 15 * time.Minute | ||
| defaultContinuousProfilerMaxFiles = 5 | ||
| defaultPushGossipPercentStake = .9 | ||
| defaultPushGossipNumValidators = 100 | ||
| defaultPushGossipNumPeers = 0 | ||
| defaultPushRegossipNumValidators = 10 | ||
| defaultPushRegossipNumPeers = 0 | ||
| defaultPushGossipFrequency = 100 * time.Millisecond | ||
| defaultPullGossipFrequency = 1 * time.Second | ||
| defaultTxRegossipFrequency = 30 * time.Second | ||
| defaultOfflinePruningBloomFilterSize uint64 = 512 // Default size (MB) for the offline pruner to use | ||
| defaultLogLevel = "info" | ||
| defaultLogJSONFormat = false | ||
| defaultMaxOutboundActiveRequests = 16 | ||
| defaultPopulateMissingTriesParallelism = 1024 | ||
| defaultStateSyncServerTrieCache = 64 // MB | ||
| defaultAcceptedCacheSize = 32 // blocks | ||
|
|
||
| // defaultStateSyncMinBlocks is the minimum number of blocks the blockchain | ||
| // should be ahead of local last accepted to perform state sync. | ||
| // This constant is chosen so normal bootstrapping is preferred when it would | ||
| // be faster than state sync. | ||
| // time assumptions: | ||
| // - normal bootstrap processing time: ~14 blocks / second | ||
| // - state sync time: ~6 hrs. | ||
| defaultStateSyncMinBlocks = 300_000 | ||
| DefaultStateSyncRequestSize = 1024 // the number of key/values to ask peers for per request | ||
| ) | ||
|
|
||
| var ( | ||
| defaultEnabledAPIs = []string{ | ||
| "eth", | ||
| "eth-filter", | ||
| "net", | ||
| "web3", | ||
| "internal-eth", | ||
| "internal-blockchain", | ||
| "internal-transaction", | ||
| } | ||
| defaultAllowUnprotectedTxHashes = []common.Hash{ | ||
| common.HexToHash("0xfefb2da535e927b85fe68eb81cb2e4a5827c905f78381a01ef2322aa9b0aee8e"), // EIP-1820: https://eips.ethereum.org/EIPS/eip-1820 | ||
| } | ||
| ) | ||
|
|
||
| // EthAPIs returns an array of strings representing the Eth APIs that should be enabled | ||
| func (c Config) EthAPIs() []string { | ||
| return c.EnabledEthAPIs | ||
| } | ||
|
|
||
| func (c Config) EthBackendSettings() eth.Settings { | ||
| return eth.Settings{MaxBlocksPerRequest: c.MaxBlocksPerRequest} | ||
| } | ||
|
|
||
| func (c *Config) SetDefaults() { | ||
| c.EnabledEthAPIs = defaultEnabledAPIs | ||
| c.RPCGasCap = defaultRpcGasCap | ||
| c.RPCTxFeeCap = defaultRpcTxFeeCap | ||
| c.MetricsExpensiveEnabled = defaultMetricsExpensiveEnabled | ||
|
|
||
| c.TxPoolPriceLimit = legacypool.DefaultConfig.PriceLimit | ||
| c.TxPoolPriceBump = legacypool.DefaultConfig.PriceBump | ||
| c.TxPoolAccountSlots = legacypool.DefaultConfig.AccountSlots | ||
| c.TxPoolGlobalSlots = legacypool.DefaultConfig.GlobalSlots | ||
| c.TxPoolAccountQueue = legacypool.DefaultConfig.AccountQueue | ||
| c.TxPoolGlobalQueue = legacypool.DefaultConfig.GlobalQueue | ||
| c.TxPoolLifetime.Duration = legacypool.DefaultConfig.Lifetime | ||
|
|
||
| c.APIMaxDuration.Duration = defaultApiMaxDuration | ||
| c.WSCPURefillRate.Duration = defaultWsCpuRefillRate | ||
| c.WSCPUMaxStored.Duration = defaultWsCpuMaxStored | ||
| c.MaxBlocksPerRequest = defaultMaxBlocksPerRequest | ||
| c.ContinuousProfilerFrequency.Duration = defaultContinuousProfilerFrequency | ||
| c.ContinuousProfilerMaxFiles = defaultContinuousProfilerMaxFiles | ||
| c.Pruning = defaultPruningEnabled | ||
| c.TrieCleanCache = defaultTrieCleanCache | ||
| c.TrieDirtyCache = defaultTrieDirtyCache | ||
| c.TrieDirtyCommitTarget = defaultTrieDirtyCommitTarget | ||
| c.TriePrefetcherParallelism = defaultTriePrefetcherParallelism | ||
| c.SnapshotCache = defaultSnapshotCache | ||
| c.AcceptorQueueLimit = defaultAcceptorQueueLimit | ||
| c.CommitInterval = defaultCommitInterval | ||
| c.SnapshotWait = defaultSnapshotWait | ||
| c.PushGossipPercentStake = defaultPushGossipPercentStake | ||
| c.PushGossipNumValidators = defaultPushGossipNumValidators | ||
| c.PushGossipNumPeers = defaultPushGossipNumPeers | ||
| c.PushRegossipNumValidators = defaultPushRegossipNumValidators | ||
| c.PushRegossipNumPeers = defaultPushRegossipNumPeers | ||
| c.PushGossipFrequency.Duration = defaultPushGossipFrequency | ||
| c.PullGossipFrequency.Duration = defaultPullGossipFrequency | ||
| c.RegossipFrequency.Duration = defaultTxRegossipFrequency | ||
| c.OfflinePruningBloomFilterSize = defaultOfflinePruningBloomFilterSize | ||
| c.LogLevel = defaultLogLevel | ||
| c.LogJSONFormat = defaultLogJSONFormat | ||
| c.MaxOutboundActiveRequests = defaultMaxOutboundActiveRequests | ||
| c.PopulateMissingTriesParallelism = defaultPopulateMissingTriesParallelism | ||
| c.StateSyncServerTrieCache = defaultStateSyncServerTrieCache | ||
| c.StateSyncCommitInterval = defaultSyncableCommitInterval | ||
| c.StateSyncMinBlocks = defaultStateSyncMinBlocks | ||
| c.StateSyncRequestSize = DefaultStateSyncRequestSize | ||
| c.AllowUnprotectedTxHashes = defaultAllowUnprotectedTxHashes | ||
| c.AcceptedCacheSize = defaultAcceptedCacheSize | ||
| } | ||
|
|
||
| // Validate returns an error if this is an invalid config. | ||
| func (c *Config) Validate(networkID uint32) error { | ||
| // Ensure that non-standard commit interval is not allowed for production networks | ||
| if constants.ProductionNetworkIDs.Contains(networkID) { | ||
| if c.CommitInterval != defaultCommitInterval { | ||
| return fmt.Errorf("cannot start non-local network with commit interval %d different than %d", c.CommitInterval, defaultCommitInterval) | ||
| } | ||
| if c.StateSyncCommitInterval != defaultSyncableCommitInterval { | ||
| return fmt.Errorf("cannot start non-local network with syncable interval %d different than %d", c.StateSyncCommitInterval, defaultSyncableCommitInterval) | ||
| } | ||
| } | ||
|
|
||
| if c.PopulateMissingTries != nil && (c.OfflinePruning || c.Pruning) { | ||
| return fmt.Errorf("cannot enable populate missing tries while offline pruning (enabled: %t)/pruning (enabled: %t) are enabled", c.OfflinePruning, c.Pruning) | ||
| } | ||
| if c.PopulateMissingTries != nil && c.PopulateMissingTriesParallelism < 1 { | ||
| return fmt.Errorf("cannot enable populate missing tries without at least one reader (parallelism: %d)", c.PopulateMissingTriesParallelism) | ||
| } | ||
|
|
||
| if !c.Pruning && c.OfflinePruning { | ||
| return fmt.Errorf("cannot run offline pruning while pruning is disabled") | ||
| } | ||
| // If pruning is enabled, the commit interval must be non-zero so the node commits state tries every CommitInterval blocks. | ||
| if c.Pruning && c.CommitInterval == 0 { | ||
| return fmt.Errorf("cannot use commit interval of 0 with pruning enabled") | ||
| } | ||
|
|
||
| if c.PushGossipPercentStake < 0 || c.PushGossipPercentStake > 1 { | ||
| return fmt.Errorf("push-gossip-percent-stake is %f but must be in the range [0, 1]", c.PushGossipPercentStake) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (c *Config) Deprecate() string { | ||
| return (*config.Config)(c).Deprecate() | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.