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