Skip to content
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

move config type to client #701

Draft
wants to merge 1 commit into
base: move-atomic-txs
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions plugin/evm/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func (p *Admin) SetLogLevel(_ *http.Request, args *client.SetLogLevelArgs, reply
return nil
}

type ConfigReply struct {
Config *Config `json:"config"`
}

func (p *Admin) GetVMConfig(_ *http.Request, _ *struct{}, reply *ConfigReply) error {
reply.Config = &p.vm.config
func (p *Admin) GetVMConfig(_ *http.Request, _ *struct{}, reply *client.ConfigReply) error {
reply.Config = (*client.Config)(&p.vm.config)
return nil
}
16 changes: 10 additions & 6 deletions plugin/evm/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Client interface {
MemoryProfile(ctx context.Context, options ...rpc.Option) error
LockProfile(ctx context.Context, options ...rpc.Option) error
SetLogLevel(ctx context.Context, level slog.Level, options ...rpc.Option) error
// GetVMConfig(ctx context.Context, options ...rpc.Option) (*Config, error)
GetVMConfig(ctx context.Context, options ...rpc.Option) (*Config, error)
}

// Client implementation for interacting with EVM [chain]
Expand Down Expand Up @@ -299,9 +299,13 @@ func (c *client) SetLogLevel(ctx context.Context, level slog.Level, options ...r
}, &api.EmptyReply{}, options...)
}

type ConfigReply struct {
Config *Config `json:"config"`
}

// GetVMConfig returns the current config of the VM
// func (c *client) GetVMConfig(ctx context.Context, options ...rpc.Option) (*Config, error) {
// res := &ConfigReply{}
// err := c.adminRequester.SendRequest(ctx, "admin.getVMConfig", struct{}{}, res, options...)
// return res.Config, err
// }
func (c *client) GetVMConfig(ctx context.Context, options ...rpc.Option) (*Config, error) {
res := &ConfigReply{}
err := c.adminRequester.SendRequest(ctx, "admin.getVMConfig", struct{}{}, res, options...)
return res.Config, err
}
175 changes: 175 additions & 0 deletions plugin/evm/client/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
package client

import (
"encoding/json"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/spf13/cast"
)

type Duration struct {
time.Duration
}

func (d *Duration) UnmarshalJSON(data []byte) (err error) {
var v interface{}
if err := json.Unmarshal(data, &v); err != nil {
return err
}
d.Duration, err = cast.ToDurationE(v)
return err
}

// String implements the stringer interface.
func (d Duration) String() string {
return d.Duration.String()
}

// String implements the stringer interface.
func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Duration.String())
}

// Config ...
type Config struct {
// Coreth APIs
SnowmanAPIEnabled bool `json:"snowman-api-enabled"`
AdminAPIEnabled bool `json:"admin-api-enabled"`
AdminAPIDir string `json:"admin-api-dir"`
CorethAdminAPIEnabled bool `json:"coreth-admin-api-enabled"` // Deprecated: use AdminAPIEnabled instead
CorethAdminAPIDir string `json:"coreth-admin-api-dir"` // Deprecated: use AdminAPIDir instead
WarpAPIEnabled bool `json:"warp-api-enabled"`

// EnabledEthAPIs is a list of Ethereum services that should be enabled
// If none is specified, then we use the default list [defaultEnabledAPIs]
EnabledEthAPIs []string `json:"eth-apis"`

// Continuous Profiler
ContinuousProfilerDir string `json:"continuous-profiler-dir"` // If set to non-empty string creates a continuous profiler
ContinuousProfilerFrequency Duration `json:"continuous-profiler-frequency"` // Frequency to run continuous profiler if enabled
ContinuousProfilerMaxFiles int `json:"continuous-profiler-max-files"` // Maximum number of files to maintain

// API Gas/Price Caps
RPCGasCap uint64 `json:"rpc-gas-cap"`
RPCTxFeeCap float64 `json:"rpc-tx-fee-cap"`

// Cache settings
TrieCleanCache int `json:"trie-clean-cache"` // Size of the trie clean cache (MB)
TrieDirtyCache int `json:"trie-dirty-cache"` // Size of the trie dirty cache (MB)
TrieDirtyCommitTarget int `json:"trie-dirty-commit-target"` // Memory limit to target in the dirty cache before performing a commit (MB)
TriePrefetcherParallelism int `json:"trie-prefetcher-parallelism"` // Max concurrent disk reads trie prefetcher should perform at once
SnapshotCache int `json:"snapshot-cache"` // Size of the snapshot disk layer clean cache (MB)

// Eth Settings
Preimages bool `json:"preimages-enabled"`
SnapshotWait bool `json:"snapshot-wait"`
SnapshotVerify bool `json:"snapshot-verification-enabled"`

// Pruning Settings
Pruning bool `json:"pruning-enabled"` // If enabled, trie roots are only persisted every 4096 blocks
AcceptorQueueLimit int `json:"accepted-queue-limit"` // Maximum blocks to queue before blocking during acceptance
CommitInterval uint64 `json:"commit-interval"` // Specifies the commit interval at which to persist EVM and atomic tries.
AllowMissingTries bool `json:"allow-missing-tries"` // If enabled, warnings preventing an incomplete trie index are suppressed
PopulateMissingTries *uint64 `json:"populate-missing-tries,omitempty"` // Sets the starting point for re-populating missing tries. Disables re-generation if nil.
PopulateMissingTriesParallelism int `json:"populate-missing-tries-parallelism"` // Number of concurrent readers to use when re-populating missing tries on startup.
PruneWarpDB bool `json:"prune-warp-db-enabled"` // Determines if the warpDB should be cleared on startup

// Metric Settings
MetricsExpensiveEnabled bool `json:"metrics-expensive-enabled"` // Debug-level metrics that might impact runtime performance

// API Settings
LocalTxsEnabled bool `json:"local-txs-enabled"`

TxPoolPriceLimit uint64 `json:"tx-pool-price-limit"`
TxPoolPriceBump uint64 `json:"tx-pool-price-bump"`
TxPoolAccountSlots uint64 `json:"tx-pool-account-slots"`
TxPoolGlobalSlots uint64 `json:"tx-pool-global-slots"`
TxPoolAccountQueue uint64 `json:"tx-pool-account-queue"`
TxPoolGlobalQueue uint64 `json:"tx-pool-global-queue"`
TxPoolLifetime Duration `json:"tx-pool-lifetime"`

APIMaxDuration Duration `json:"api-max-duration"`
WSCPURefillRate Duration `json:"ws-cpu-refill-rate"`
WSCPUMaxStored Duration `json:"ws-cpu-max-stored"`
MaxBlocksPerRequest int64 `json:"api-max-blocks-per-request"`
AllowUnfinalizedQueries bool `json:"allow-unfinalized-queries"`
AllowUnprotectedTxs bool `json:"allow-unprotected-txs"`
AllowUnprotectedTxHashes []common.Hash `json:"allow-unprotected-tx-hashes"`

// Keystore Settings
KeystoreDirectory string `json:"keystore-directory"` // both absolute and relative supported
KeystoreExternalSigner string `json:"keystore-external-signer"`
KeystoreInsecureUnlockAllowed bool `json:"keystore-insecure-unlock-allowed"`

// Gossip Settings
PushGossipPercentStake float64 `json:"push-gossip-percent-stake"`
PushGossipNumValidators int `json:"push-gossip-num-validators"`
PushGossipNumPeers int `json:"push-gossip-num-peers"`
PushRegossipNumValidators int `json:"push-regossip-num-validators"`
PushRegossipNumPeers int `json:"push-regossip-num-peers"`
PushGossipFrequency Duration `json:"push-gossip-frequency"`
PullGossipFrequency Duration `json:"pull-gossip-frequency"`
RegossipFrequency Duration `json:"regossip-frequency"`
TxRegossipFrequency Duration `json:"tx-regossip-frequency"` // Deprecated: use RegossipFrequency instead

// Log
LogLevel string `json:"log-level"`
LogJSONFormat bool `json:"log-json-format"`

// Offline Pruning Settings
OfflinePruning bool `json:"offline-pruning-enabled"`
OfflinePruningBloomFilterSize uint64 `json:"offline-pruning-bloom-filter-size"`
OfflinePruningDataDirectory string `json:"offline-pruning-data-directory"`

// VM2VM network
MaxOutboundActiveRequests int64 `json:"max-outbound-active-requests"`

// Sync settings
StateSyncEnabled *bool `json:"state-sync-enabled"` // Pointer distinguishes false (no state sync) and not set (state sync only at genesis).
StateSyncSkipResume bool `json:"state-sync-skip-resume"` // Forces state sync to use the highest available summary block
StateSyncServerTrieCache int `json:"state-sync-server-trie-cache"`
StateSyncIDs string `json:"state-sync-ids"`
StateSyncCommitInterval uint64 `json:"state-sync-commit-interval"`
StateSyncMinBlocks uint64 `json:"state-sync-min-blocks"`
StateSyncRequestSize uint16 `json:"state-sync-request-size"`

// Database Settings
InspectDatabase bool `json:"inspect-database"` // Inspects the database on startup if enabled.

// SkipUpgradeCheck disables checking that upgrades must take place before the last
// accepted block. Skipping this check is useful when a node operator does not update
// their node before the network upgrade and their node accepts blocks that have
// identical state with the pre-upgrade ruleset.
SkipUpgradeCheck bool `json:"skip-upgrade-check"`

// AcceptedCacheSize is the depth to keep in the accepted headers cache and the
// accepted logs cache at the accepted tip.
//
// This is particularly useful for improving the performance of eth_getLogs
// on RPC nodes.
AcceptedCacheSize int `json:"accepted-cache-size"`

// TransactionHistory is the maximum number of blocks from head whose tx indices
// are reserved:
// * 0: means no limit
// * N: means N block limit [HEAD-N+1, HEAD] and delete extra indexes
TransactionHistory uint64 `json:"transaction-history"`
// Deprecated, use 'TransactionHistory' instead.
TxLookupLimit uint64 `json:"tx-lookup-limit"`

// SkipTxIndexing skips indexing transactions.
// This is useful for validators that don't need to index transactions.
// TxLookupLimit can be still used to control unindexing old transactions.
SkipTxIndexing bool `json:"skip-tx-indexing"`

// WarpOffChainMessages encodes off-chain messages (unrelated to any on-chain event ie. block or AddressedCall)
// that the node should be willing to sign.
// Note: only supports AddressedCall payloads as defined here:
// https://github.com/ava-labs/avalanchego/tree/7623ffd4be915a5185c9ed5e11fa9be15a6e1f00/vms/platformvm/warp/payload#addressedcall
WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`

// RPC settings
HttpBodyLimit uint64 `json:"http-body-limit"`
}
Loading
Loading