Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
golang.org/x/sys v0.28.0
golang.org/x/text v0.21.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.22.0
google.golang.org/protobuf v1.34.2
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanchego v1.12.2-0.20241224161435-3998475d671d h1:QCtjS4ANcNfCdL6Z2sKpanDVJNt1MU0bUyVdW0g5zuU=
github.com/ava-labs/avalanchego v1.12.2-0.20241224161435-3998475d671d/go.mod h1:cDoT0Hq3P+/XfCyVvzrBj66yoid2I5LnMuj7LIkap+o=
github.com/ava-labs/avalanchego v1.12.2-0.20241224181600-fade5be3051d h1:iPlsqC9pIy4emCo8wyI/VmVmfljpzmw58ZqahVdcehI=
github.com/ava-labs/avalanchego v1.12.2-0.20241224181600-fade5be3051d/go.mod h1:dKawab3nXqwI7ZcOFatTOv//l1V0t8MRBnhXoOqbN4E=
github.com/ava-labs/avalanchego v1.12.2-0.20250106102004-902377d447ba h1:7t2ORGM53sqdsczNZGFQIK99of9yeetCld90keJ47Os=
github.com/ava-labs/avalanchego v1.12.2-0.20250106102004-902377d447ba/go.mod h1:oK/C7ZGo5cAEayBKBoawh2EpOo3E9gD1rpd9NAM0RkQ=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down Expand Up @@ -586,8 +582,6 @@ go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lI
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down Expand Up @@ -693,8 +687,6 @@ golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -865,6 +857,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
3 changes: 2 additions & 1 deletion plugin/evm/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ava-labs/avalanchego/api"
"github.com/ava-labs/avalanchego/utils/profiler"
"github.com/ava-labs/coreth/plugin/evm/client"
"github.com/ava-labs/coreth/plugin/evm/config"
"github.com/ethereum/go-ethereum/log"
)

Expand Down Expand Up @@ -79,6 +80,6 @@ func (p *Admin) SetLogLevel(_ *http.Request, args *client.SetLogLevelArgs, reply
}

func (p *Admin) GetVMConfig(_ *http.Request, _ *struct{}, reply *client.ConfigReply) error {
reply.Config = &p.vm.config
reply.Config = (*config.Config)(&p.vm.config)
return nil
}
5 changes: 2 additions & 3 deletions plugin/evm/atomic_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ava-labs/avalanchego/database/versiondb"

"github.com/ava-labs/coreth/core/rawdb"
"github.com/ava-labs/coreth/plugin/evm/config"
"github.com/ava-labs/coreth/plugin/evm/message"
syncclient "github.com/ava-labs/coreth/sync/client"
"github.com/ava-labs/coreth/sync/handlers"
Expand Down Expand Up @@ -65,7 +64,7 @@ func testAtomicSyncer(t *testing.T, serverTrieDB *triedb.Database, targetHeight
// next trie.
for i, checkpoint := range checkpoints {
// Create syncer targeting the current [syncTrie].
syncer, err := atomicBackend.Syncer(mockClient, targetRoot, targetHeight, config.DefaultStateSyncRequestSize)
syncer, err := atomicBackend.Syncer(mockClient, targetRoot, targetHeight, DefaultStateSyncRequestSize)
if err != nil {
t.Fatal(err)
}
Expand All @@ -92,7 +91,7 @@ func testAtomicSyncer(t *testing.T, serverTrieDB *triedb.Database, targetHeight
}

// Create syncer targeting the current [targetRoot].
syncer, err := atomicBackend.Syncer(mockClient, targetRoot, targetHeight, config.DefaultStateSyncRequestSize)
syncer, err := atomicBackend.Syncer(mockClient, targetRoot, targetHeight, DefaultStateSyncRequestSize)
if err != nil {
t.Fatal(err)
}
Expand Down
175 changes: 175 additions & 0 deletions plugin/evm/config.go
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()
}
Loading
Loading