github.com/MetalBlockchain/subnet-evm@v0.4.9/eth/ethconfig/config.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc.
     2  //
     3  // This file is a derived work, based on the go-ethereum library whose original
     4  // notices appear below.
     5  //
     6  // It is distributed under a license compatible with the licensing terms of the
     7  // original code from which it is derived.
     8  //
     9  // Much love to the original authors for their work.
    10  // **********
    11  // Copyright 2017 The go-ethereum Authors
    12  // This file is part of the go-ethereum library.
    13  //
    14  // The go-ethereum library is free software: you can redistribute it and/or modify
    15  // it under the terms of the GNU Lesser General Public License as published by
    16  // the Free Software Foundation, either version 3 of the License, or
    17  // (at your option) any later version.
    18  //
    19  // The go-ethereum library is distributed in the hope that it will be useful,
    20  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    21  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    22  // GNU Lesser General Public License for more details.
    23  //
    24  // You should have received a copy of the GNU Lesser General Public License
    25  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    26  
    27  package ethconfig
    28  
    29  import (
    30  	"time"
    31  
    32  	"github.com/MetalBlockchain/subnet-evm/core"
    33  	"github.com/MetalBlockchain/subnet-evm/eth/gasprice"
    34  	"github.com/MetalBlockchain/subnet-evm/miner"
    35  	"github.com/ethereum/go-ethereum/common"
    36  )
    37  
    38  // DefaultFullGPOConfig contains default gasprice oracle settings for full node.
    39  var DefaultFullGPOConfig = gasprice.Config{
    40  	Blocks:              40,
    41  	Percentile:          60,
    42  	MaxLookbackSeconds:  gasprice.DefaultMaxLookbackSeconds,
    43  	MaxCallBlockHistory: gasprice.DefaultMaxCallBlockHistory,
    44  	MaxBlockHistory:     gasprice.DefaultMaxBlockHistory,
    45  	MinPrice:            gasprice.DefaultMinPrice,
    46  	MaxPrice:            gasprice.DefaultMaxPrice,
    47  	MinGasUsed:          gasprice.DefaultMinGasUsed,
    48  }
    49  
    50  // DefaultConfig contains default settings for use on the Metal main net.
    51  var DefaultConfig = NewDefaultConfig()
    52  
    53  func NewDefaultConfig() Config {
    54  	return Config{
    55  		NetworkId:             1,
    56  		TrieCleanCache:        512,
    57  		TrieDirtyCache:        256,
    58  		TrieDirtyCommitTarget: 20,
    59  		SnapshotCache:         256,
    60  		AcceptedCacheSize:     32,
    61  		Miner:                 miner.Config{},
    62  		TxPool:                core.DefaultTxPoolConfig,
    63  		RPCGasCap:             25000000,
    64  		RPCEVMTimeout:         5 * time.Second,
    65  		GPO:                   DefaultFullGPOConfig,
    66  		RPCTxFeeCap:           1,
    67  	}
    68  }
    69  
    70  //go:generate go run github.com/fjl/gencodec -type Config -formats toml -out gen_config.go
    71  
    72  // Config contains configuration options for of the ETH and LES protocols.
    73  type Config struct {
    74  	// The genesis block, which is inserted if the database is empty.
    75  	// If nil, the Ethereum main net block is used.
    76  	Genesis *core.Genesis `toml:",omitempty"`
    77  
    78  	// Protocol options
    79  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    80  
    81  	Pruning                         bool    // Whether to disable pruning and flush everything to disk
    82  	AcceptorQueueLimit              int     // Maximum blocks to queue before blocking during acceptance
    83  	CommitInterval                  uint64  // If pruning is enabled, specified the interval at which to commit an entire trie to disk.
    84  	PopulateMissingTries            *uint64 // Height at which to start re-populating missing tries on startup.
    85  	PopulateMissingTriesParallelism int     // Number of concurrent readers to use when re-populating missing tries on startup.
    86  	AllowMissingTries               bool    // Whether to allow an archival node to run with pruning enabled and corrupt a complete index.
    87  	SnapshotDelayInit               bool    // Whether snapshot tree should be initialized on startup or delayed until explicit call
    88  	SnapshotAsync                   bool    // Whether to generate the initial snapshot in async mode
    89  	SnapshotVerify                  bool    // Whether to verify generated snapshots
    90  	SkipSnapshotRebuild             bool    // Whether to skip rebuilding the snapshot in favor of returning an error (only set to true for tests)
    91  
    92  	// Database options
    93  	SkipBcVersionCheck bool `toml:"-"`
    94  
    95  	// TrieDB and snapshot options
    96  	TrieCleanCache        int
    97  	TrieCleanJournal      string
    98  	TrieCleanRejournal    time.Duration
    99  	TrieDirtyCache        int
   100  	TrieDirtyCommitTarget int
   101  	SnapshotCache         int
   102  	Preimages             bool
   103  
   104  	// AcceptedCacheSize is the depth of accepted headers cache and accepted
   105  	// logs cache at the accepted tip.
   106  	AcceptedCacheSize int
   107  
   108  	// Mining options
   109  	Miner miner.Config
   110  
   111  	// Transaction pool options
   112  	TxPool core.TxPoolConfig
   113  
   114  	// Gas Price Oracle options
   115  	GPO gasprice.Config
   116  
   117  	// Enables tracking of SHA3 preimages in the VM
   118  	EnablePreimageRecording bool
   119  
   120  	// RPCGasCap is the global gas cap for eth-call variants.
   121  	RPCGasCap uint64 `toml:",omitempty"`
   122  
   123  	// RPCEVMTimeout is the global timeout for eth-call.
   124  	RPCEVMTimeout time.Duration
   125  
   126  	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
   127  	// send-transaction variants. The unit is ether.
   128  	RPCTxFeeCap float64 `toml:",omitempty"`
   129  
   130  	// AllowUnfinalizedQueries allow unfinalized queries
   131  	AllowUnfinalizedQueries bool
   132  
   133  	// AllowUnprotectedTxs allow unprotected transactions to be locally issued.
   134  	// Unprotected transactions are transactions that are signed without EIP-155
   135  	// replay protection.
   136  	AllowUnprotectedTxs bool
   137  	// AllowUnprotectedTxHashes provides a list of transaction hashes, which will be allowed
   138  	// to be issued without replay protection over the API even if AllowUnprotectedTxs is false.
   139  	AllowUnprotectedTxHashes []common.Hash
   140  
   141  	// OfflinePruning enables offline pruning on startup of the node. If a node is started
   142  	// with this configuration option, it must finish pruning before resuming normal operation.
   143  	OfflinePruning                bool
   144  	OfflinePruningBloomFilterSize uint64
   145  	OfflinePruningDataDirectory   string
   146  
   147  	// SkipUpgradeCheck disables checking that upgrades must take place before the last
   148  	// accepted block. Skipping this check is useful when a node operator does not update
   149  	// their node before the network upgrade and their node accepts blocks that have
   150  	// identical state with the pre-upgrade ruleset.
   151  	SkipUpgradeCheck bool
   152  
   153  	// TxLookupLimit is the maximum number of blocks from head whose tx indices
   154  	// are reserved:
   155  	//  * 0:   means no limit
   156  	//  * N:   means N block limit [HEAD-N+1, HEAD] and delete extra indexes
   157  	TxLookupLimit uint64
   158  }