github.com/coltonfike/e2c@v21.1.0+incompatible/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/go-ethereum/common" 28 "github.com/ethereum/go-ethereum/consensus/ethash" 29 "github.com/ethereum/go-ethereum/consensus/istanbul" 30 "github.com/ethereum/go-ethereum/core" 31 "github.com/ethereum/go-ethereum/eth/downloader" 32 "github.com/ethereum/go-ethereum/eth/gasprice" 33 "github.com/ethereum/go-ethereum/miner" 34 "github.com/ethereum/go-ethereum/params" 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: 1337, 48 LightPeers: 100, 49 UltraLightFraction: 75, 50 DatabaseCache: 768, 51 TrieCleanCache: 256, 52 TrieDirtyCache: 256, 53 TrieTimeout: 60 * time.Minute, 54 Miner: miner.Config{ 55 GasFloor: params.MinGasLimit, 56 GasCeil: params.GenesisGasLimit, 57 GasPrice: big.NewInt(params.GWei), 58 Recommit: 3 * time.Second, 59 }, 60 TxPool: core.DefaultTxPoolConfig, 61 GPO: gasprice.Config{ 62 Blocks: 20, 63 Percentile: 60, 64 }, 65 66 Istanbul: *istanbul.DefaultConfig, 67 } 68 69 func init() { 70 home := os.Getenv("HOME") 71 if home == "" { 72 if user, err := user.Current(); err == nil { 73 home = user.HomeDir 74 } 75 } 76 if runtime.GOOS == "darwin" { 77 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash") 78 } else if runtime.GOOS == "windows" { 79 localappdata := os.Getenv("LOCALAPPDATA") 80 if localappdata != "" { 81 DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash") 82 } else { 83 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash") 84 } 85 } else { 86 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 87 } 88 } 89 90 //go:generate gencodec -type Config -formats toml -out gen_config.go 91 92 type Config struct { 93 // The genesis block, which is inserted if the database is empty. 94 // If nil, the Ethereum main net block is used. 95 Genesis *core.Genesis `toml:",omitempty"` 96 97 // Protocol options 98 NetworkId uint64 // Network ID to use for selecting peers to connect to 99 SyncMode downloader.SyncMode 100 101 NoPruning bool // Whether to disable pruning and flush everything to disk 102 NoPrefetch bool // Whether to disable prefetching and only load state on demand 103 104 // Whitelist of required block number -> hash values to accept 105 Whitelist map[uint64]common.Hash `toml:"-"` 106 107 // Light client options 108 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 109 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 110 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 111 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 112 113 // Ultra Light client options 114 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 115 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 116 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 117 118 // Database options 119 SkipBcVersionCheck bool `toml:"-"` 120 DatabaseHandles int `toml:"-"` 121 DatabaseCache int 122 DatabaseFreezer string 123 124 TrieCleanCache int 125 TrieDirtyCache int 126 TrieTimeout time.Duration 127 128 // Mining options 129 Miner miner.Config 130 131 // Ethash options 132 Ethash ethash.Config 133 134 // Transaction pool options 135 TxPool core.TxPoolConfig 136 137 // Gas Price Oracle options 138 GPO gasprice.Config 139 140 // Enables tracking of SHA3 preimages in the VM 141 EnablePreimageRecording bool 142 143 RaftMode bool 144 EnableNodePermission bool 145 // Istanbul options 146 Istanbul istanbul.Config 147 148 // Miscellaneous options 149 DocRoot string `toml:"-"` 150 151 // Type of the EWASM interpreter ("" for default) 152 EWASMInterpreter string 153 154 // Type of the EVM interpreter ("" for default) 155 EVMInterpreter string 156 157 // RPCGasCap is the global gas cap for eth-call variants. 158 RPCGasCap *big.Int `toml:",omitempty"` 159 160 // Checkpoint is a hardcoded checkpoint which can be nil. 161 Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` 162 163 // CheckpointOracle is the configuration for checkpoint oracle. 164 CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` 165 166 // Istanbul block override (TODO: remove after the fork) 167 OverrideIstanbul *big.Int 168 169 // timeout value for call 170 EVMCallTimeOut time.Duration 171 172 EnableMultitenancy bool 173 }