github.com/ethereum-optimism/optimism/l2geth@v0.0.0-20230612200230-50b04ade19e3/eth/config.go (about) 1 // Copyright 2017 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 eth 18 19 import ( 20 "math/big" 21 "os" 22 "os/user" 23 "path/filepath" 24 "runtime" 25 "time" 26 27 "github.com/ethereum-optimism/optimism/l2geth/common" 28 "github.com/ethereum-optimism/optimism/l2geth/consensus/ethash" 29 "github.com/ethereum-optimism/optimism/l2geth/core" 30 "github.com/ethereum-optimism/optimism/l2geth/eth/downloader" 31 "github.com/ethereum-optimism/optimism/l2geth/eth/gasprice" 32 "github.com/ethereum-optimism/optimism/l2geth/miner" 33 "github.com/ethereum-optimism/optimism/l2geth/params" 34 "github.com/ethereum-optimism/optimism/l2geth/rollup" 35 ) 36 37 // DefaultConfig contains default settings for use on the Ethereum main net. 38 var DefaultConfig = Config{ 39 SyncMode: downloader.FastSync, 40 Ethash: ethash.Config{ 41 CacheDir: "ethash", 42 CachesInMem: 2, 43 CachesOnDisk: 3, 44 DatasetsInMem: 1, 45 DatasetsOnDisk: 2, 46 }, 47 NetworkId: 1, 48 LightPeers: 100, 49 UltraLightFraction: 75, 50 DatabaseCache: 512, 51 TrieCleanCache: 256, 52 TrieDirtyCache: 256, 53 TrieTimeout: 60 * time.Minute, 54 Miner: miner.Config{ 55 GasFloor: 8000000, 56 GasCeil: 8000000, 57 GasPrice: big.NewInt(params.GWei), 58 Recommit: 3 * time.Second, 59 }, 60 TxPool: core.DefaultTxPoolConfig, 61 RPCGasCap: new(big.Int).SetUint64(25_000_000), 62 RPCEVMTimeout: 5 * time.Second, 63 GPO: gasprice.Config{ 64 Blocks: 20, 65 Percentile: 60, 66 }, 67 Rollup: rollup.Config{ 68 // The max size of a transaction that is sent over the p2p network is 128kb 69 // https://github.com/ethereum-optimism/optimism/l2geth/blob/c2d2f4ed8f232bb11663a1b01a2e578aa22f24bd/core/tx_pool.go#L51 70 // The batch overhead is: 71 // 4 bytes function selector 72 // 5 bytes shouldStartAtElement 73 // 3 bytes totalElementsToAppend 74 // 3 bytes context header 75 // 16 bytes for a single batch context 76 // 3 bytes for tx size 77 // the rest of the data can be used for the transaction 78 // Therefore, the max safe tx size to accept via the sequencer is: 79 // 128000 - (5+3+3+16+4+3) = 127966 80 // The mempool would need to be bypassed if a transaction any larger was 81 // accepted. This option applies to the transaction calldata, so there 82 // is additional overhead that is unaccounted. Round down to 127000 for 83 // safety. 84 MaxCallDataSize: 127000, 85 }, 86 } 87 88 func init() { 89 home := os.Getenv("HOME") 90 if home == "" { 91 if user, err := user.Current(); err == nil { 92 home = user.HomeDir 93 } 94 } 95 if runtime.GOOS == "darwin" { 96 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash") 97 } else if runtime.GOOS == "windows" { 98 localappdata := os.Getenv("LOCALAPPDATA") 99 if localappdata != "" { 100 DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash") 101 } else { 102 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash") 103 } 104 } else { 105 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 106 } 107 } 108 109 //go:generate gencodec -type Config -formats toml -out gen_config.go 110 111 type Config struct { 112 // The genesis block, which is inserted if the database is empty. 113 // If nil, the Ethereum main net block is used. 114 Genesis *core.Genesis `toml:",omitempty"` 115 116 // Protocol options 117 NetworkId uint64 // Network ID to use for selecting peers to connect to 118 SyncMode downloader.SyncMode 119 120 NoPruning bool // Whether to disable pruning and flush everything to disk 121 NoPrefetch bool // Whether to disable prefetching and only load state on demand 122 123 // Whitelist of required block number -> hash values to accept 124 Whitelist map[uint64]common.Hash `toml:"-"` 125 126 // Light client options 127 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 128 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 129 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 130 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 131 132 // Ultra Light client options 133 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 134 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 135 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 136 137 // Database options 138 SkipBcVersionCheck bool `toml:"-"` 139 DatabaseHandles int `toml:"-"` 140 DatabaseCache int 141 DatabaseFreezer string 142 143 TrieCleanCache int 144 TrieDirtyCache int 145 TrieTimeout time.Duration 146 147 // Mining options 148 Miner miner.Config 149 150 // Ethash options 151 Ethash ethash.Config 152 153 // Transaction pool options 154 TxPool core.TxPoolConfig 155 156 // Gas Price Oracle options 157 GPO gasprice.Config 158 159 // Enables tracking of SHA3 preimages in the VM 160 EnablePreimageRecording bool 161 162 // Miscellaneous options 163 DocRoot string `toml:"-"` 164 165 // Type of the EWASM interpreter ("" for default) 166 EWASMInterpreter string 167 168 // Type of the EVM interpreter ("" for default) 169 EVMInterpreter string 170 171 // RPCGasCap is the global gas cap for eth-call variants. 172 RPCGasCap *big.Int `toml:",omitempty"` 173 174 // RPCEVMTimeout is the global timeout for eth-call. (0=infinite) 175 RPCEVMTimeout time.Duration 176 177 // Checkpoint is a hardcoded checkpoint which can be nil. 178 Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` 179 180 // CheckpointOracle is the configuration for checkpoint oracle. 181 CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` 182 183 // Istanbul block override (TODO: remove after the fork) 184 OverrideIstanbul *big.Int 185 186 // MuirGlacier block override (TODO: remove after the fork) 187 OverrideMuirGlacier *big.Int 188 189 // Optimism Rollup Config 190 Rollup rollup.Config 191 }