github.com/ethereum/go-ethereum@v1.16.1/eth/ethconfig/config.go (about) 1 // Copyright 2021 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 // Package ethconfig contains the configuration of the ETH and LES protocols. 18 package ethconfig 19 20 import ( 21 "fmt" 22 "time" 23 24 "github.com/ethereum/go-ethereum/common" 25 "github.com/ethereum/go-ethereum/consensus" 26 "github.com/ethereum/go-ethereum/consensus/beacon" 27 "github.com/ethereum/go-ethereum/consensus/clique" 28 "github.com/ethereum/go-ethereum/consensus/ethash" 29 "github.com/ethereum/go-ethereum/core" 30 "github.com/ethereum/go-ethereum/core/history" 31 "github.com/ethereum/go-ethereum/core/txpool/blobpool" 32 "github.com/ethereum/go-ethereum/core/txpool/legacypool" 33 "github.com/ethereum/go-ethereum/eth/gasprice" 34 "github.com/ethereum/go-ethereum/ethdb" 35 "github.com/ethereum/go-ethereum/log" 36 "github.com/ethereum/go-ethereum/miner" 37 "github.com/ethereum/go-ethereum/params" 38 ) 39 40 // FullNodeGPO contains default gasprice oracle settings for full node. 41 var FullNodeGPO = gasprice.Config{ 42 Blocks: 20, 43 Percentile: 60, 44 MaxHeaderHistory: 1024, 45 MaxBlockHistory: 1024, 46 MaxPrice: gasprice.DefaultMaxPrice, 47 IgnorePrice: gasprice.DefaultIgnorePrice, 48 } 49 50 // Defaults contains default settings for use on the Ethereum main net. 51 var Defaults = Config{ 52 HistoryMode: history.KeepAll, 53 SyncMode: SnapSync, 54 NetworkId: 0, // enable auto configuration of networkID == chainID 55 TxLookupLimit: 2350000, 56 TransactionHistory: 2350000, 57 LogHistory: 2350000, 58 StateHistory: params.FullImmutabilityThreshold, 59 DatabaseCache: 512, 60 TrieCleanCache: 154, 61 TrieDirtyCache: 256, 62 TrieTimeout: 60 * time.Minute, 63 SnapshotCache: 102, 64 FilterLogCacheSize: 32, 65 Miner: miner.DefaultConfig, 66 TxPool: legacypool.DefaultConfig, 67 BlobPool: blobpool.DefaultConfig, 68 RPCGasCap: 50000000, 69 RPCEVMTimeout: 5 * time.Second, 70 GPO: FullNodeGPO, 71 RPCTxFeeCap: 1, // 1 ether 72 } 73 74 //go:generate go run github.com/fjl/gencodec -type Config -formats toml -out gen_config.go 75 76 // Config contains configuration options for ETH and LES protocols. 77 type Config struct { 78 // The genesis block, which is inserted if the database is empty. 79 // If nil, the Ethereum main net block is used. 80 Genesis *core.Genesis `toml:",omitempty"` 81 82 // Network ID separates blockchains on the peer-to-peer networking level. When left 83 // zero, the chain ID is used as network ID. 84 NetworkId uint64 85 SyncMode SyncMode 86 87 // HistoryMode configures chain history retention. 88 HistoryMode history.HistoryMode 89 90 // This can be set to list of enrtree:// URLs which will be queried for 91 // nodes to connect to. 92 EthDiscoveryURLs []string 93 SnapDiscoveryURLs []string 94 95 // State options. 96 NoPruning bool // Whether to disable pruning and flush everything to disk 97 NoPrefetch bool // Whether to disable prefetching and only load state on demand 98 99 // Deprecated: use 'TransactionHistory' instead. 100 TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 101 102 TransactionHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 103 LogHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head where a log search index is maintained. 104 LogNoHistory bool `toml:",omitempty"` // No log search index is maintained. 105 LogExportCheckpoints string // export log index checkpoints to file 106 StateHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved. 107 108 // State scheme represents the scheme used to store ethereum states and trie 109 // nodes on top. It can be 'hash', 'path', or none which means use the scheme 110 // consistent with persistent state. 111 StateScheme string `toml:",omitempty"` 112 113 // RequiredBlocks is a set of block number -> hash mappings which must be in the 114 // canonical chain of all remote peers. Setting the option makes geth verify the 115 // presence of these blocks for every new peer connection. 116 RequiredBlocks map[uint64]common.Hash `toml:"-"` 117 118 // Database options 119 SkipBcVersionCheck bool `toml:"-"` 120 DatabaseHandles int `toml:"-"` 121 DatabaseCache int 122 DatabaseFreezer string 123 DatabaseEra string 124 125 TrieCleanCache int 126 TrieDirtyCache int 127 TrieTimeout time.Duration 128 SnapshotCache int 129 Preimages bool 130 131 // This is the number of blocks for which logs will be cached in the filter system. 132 FilterLogCacheSize int 133 134 // Mining options 135 Miner miner.Config 136 137 // Transaction pool options 138 TxPool legacypool.Config 139 BlobPool blobpool.Config 140 141 // Gas Price Oracle options 142 GPO gasprice.Config 143 144 // Enables tracking of SHA3 preimages in the VM 145 EnablePreimageRecording bool 146 147 // Enables VM tracing 148 VMTrace string 149 VMTraceJsonConfig string 150 151 // RPCGasCap is the global gas cap for eth-call variants. 152 RPCGasCap uint64 153 154 // RPCEVMTimeout is the global timeout for eth-call. 155 RPCEVMTimeout time.Duration 156 157 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for 158 // send-transaction variants. The unit is ether. 159 RPCTxFeeCap float64 160 161 // OverrideOsaka (TODO: remove after the fork) 162 OverrideOsaka *uint64 `toml:",omitempty"` 163 164 // OverrideVerkle (TODO: remove after the fork) 165 OverrideVerkle *uint64 `toml:",omitempty"` 166 } 167 168 // CreateConsensusEngine creates a consensus engine for the given chain config. 169 // Clique is allowed for now to live standalone, but ethash is forbidden and can 170 // only exist on already merged networks. 171 func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database) (consensus.Engine, error) { 172 if config.TerminalTotalDifficulty == nil { 173 log.Error("Geth only supports PoS networks. Please transition legacy networks using Geth v1.13.x.") 174 return nil, fmt.Errorf("'terminalTotalDifficulty' is not set in genesis block") 175 } 176 // Wrap previously supported consensus engines into their post-merge counterpart 177 if config.Clique != nil { 178 return beacon.New(clique.New(config.Clique, db)), nil 179 } 180 return beacon.New(ethash.NewFaker()), nil 181 }