github.com/kisexp/xdchain@v0.0.0-20211206025815-490d6b732aa7/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/kisexp/xdchain/common" 28 "github.com/kisexp/xdchain/consensus/ethash" 29 "github.com/kisexp/xdchain/consensus/istanbul" 30 "github.com/kisexp/xdchain/core" 31 "github.com/kisexp/xdchain/eth/downloader" 32 "github.com/kisexp/xdchain/eth/gasprice" 33 "github.com/kisexp/xdchain/miner" 34 "github.com/kisexp/xdchain/params" 35 ) 36 37 // DefaultFullGPOConfig contains default gasprice oracle settings for full node. 38 var DefaultFullGPOConfig = gasprice.Config{ 39 Blocks: 20, 40 Percentile: 60, 41 MaxPrice: gasprice.DefaultMaxPrice, 42 } 43 44 // DefaultLightGPOConfig contains default gasprice oracle settings for light client. 45 var DefaultLightGPOConfig = gasprice.Config{ 46 Blocks: 2, 47 Percentile: 60, 48 MaxPrice: gasprice.DefaultMaxPrice, 49 } 50 51 // DefaultConfig contains default settings for use on the Ethereum main net. 52 //DefaultConfig包含在以太坊主网络上使用的默认设置。 53 var DefaultConfig = Config{ 54 SyncMode: downloader.FastSync, 55 Ethash: ethash.Config{ 56 CacheDir: "ethash", 57 CachesInMem: 2, 58 CachesOnDisk: 3, 59 CachesLockMmap: false, 60 DatasetsInMem: 1, 61 DatasetsOnDisk: 2, 62 DatasetsLockMmap: false, 63 }, 64 NetworkId: 1337, 65 LightPeers: 100, 66 UltraLightFraction: 75, 67 DatabaseCache: 768, 68 TrieCleanCache: 154, 69 TrieCleanCacheJournal: "triecache", 70 TrieCleanCacheRejournal: 60 * time.Minute, 71 TrieDirtyCache: 256, 72 TrieTimeout: 60 * time.Minute, 73 SnapshotCache: 102, 74 Miner: miner.Config{ 75 GasFloor: params.MinGasLimit, 76 GasCeil: params.GenesisGasLimit, 77 GasPrice: big.NewInt(params.GWei), 78 Recommit: 3 * time.Second, 79 }, 80 TxPool: core.DefaultTxPoolConfig, 81 RPCGasCap: 25000000, 82 GPO: DefaultFullGPOConfig, 83 RPCTxFeeCap: 1, // 1 ether 84 85 // Quorum 86 Istanbul: *istanbul.DefaultConfig, // Quorum 87 PrivateTrieCleanCacheJournal: "privatetriecache", 88 } 89 90 func init() { 91 home := os.Getenv("HOME") 92 if home == "" { 93 if user, err := user.Current(); err == nil { 94 home = user.HomeDir 95 } 96 } 97 if runtime.GOOS == "darwin" { 98 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash") 99 } else if runtime.GOOS == "windows" { 100 localappdata := os.Getenv("LOCALAPPDATA") 101 if localappdata != "" { 102 DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash") 103 } else { 104 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash") 105 } 106 } else { 107 DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash") 108 } 109 } 110 111 //go:generate gencodec -type Config -formats toml -out gen_config.go 112 113 type Config struct { 114 // The genesis block, which is inserted if the database is empty. 115 // If nil, the Ethereum main net block is used. 116 Genesis *core.Genesis `toml:",omitempty"` 117 118 // Protocol options 119 NetworkId uint64 // Network ID to use for selecting peers to connect to 120 SyncMode downloader.SyncMode 121 122 // This can be set to list of enrtree:// URLs which will be queried for 123 // for nodes to connect to. 124 DiscoveryURLs []string 125 126 NoPruning bool // Whether to disable pruning and flush everything to disk 127 NoPrefetch bool // Whether to disable prefetching and only load state on demand 128 129 TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 130 131 // AuthorizationList of required block number -> hash values to accept 132 AuthorizationList map[uint64]common.Hash `toml:"-"` // not in the TOML configuration 133 134 // Light client options 135 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 136 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 137 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 138 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 139 LightNoPrune bool `toml:",omitempty"` // Whether to disable light chain pruning 140 141 // Ultra Light client options 142 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 143 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 144 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 145 146 // Database options 147 SkipBcVersionCheck bool `toml:"-"` 148 DatabaseHandles int `toml:"-"` 149 DatabaseCache int 150 DatabaseFreezer string 151 152 TrieCleanCache int 153 TrieCleanCacheJournal string `toml:",omitempty"` // Disk journal directory for trie cache to survive node restarts 154 TrieCleanCacheRejournal time.Duration `toml:",omitempty"` // Time interval to regenerate the journal for clean cache 155 TrieDirtyCache int 156 TrieTimeout time.Duration 157 SnapshotCache int 158 Preimages bool 159 160 // Mining options 161 Miner miner.Config 162 163 // Ethash options 164 Ethash ethash.Config 165 166 // Transaction pool options 167 TxPool core.TxPoolConfig 168 169 // Gas Price Oracle options 170 GPO gasprice.Config 171 172 // Enables tracking of SHA3 preimages in the VM 173 EnablePreimageRecording bool 174 175 RaftMode bool 176 EnableNodePermission bool 177 // Istanbul options 178 Istanbul istanbul.Config 179 180 // Miscellaneous options 181 DocRoot string `toml:"-"` 182 183 // Type of the EWASM interpreter ("" for default) 184 EWASMInterpreter string 185 186 // Type of the EVM interpreter ("" for default) 187 EVMInterpreter string 188 189 // RPCGasCap is the global gas cap for eth-call variants. 190 RPCGasCap uint64 `toml:",omitempty"` 191 192 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for 193 // send-transction variants. The unit is ether. 194 RPCTxFeeCap float64 `toml:",omitempty"` 195 196 // Checkpoint is a hardcoded checkpoint which can be nil. 197 Checkpoint *params.TrustedCheckpoint `toml:",omitempty"` 198 199 // CheckpointOracle is the configuration for checkpoint oracle. 200 CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` 201 202 // Quorum 203 // timeout value for call 204 EVMCallTimeOut time.Duration 205 206 // Quorum 207 core.QuorumChainConfig `toml:"-"` 208 209 // Quorum 210 PrivateTrieCleanCacheJournal string `toml:",omitempty"` // Disk journal directory for private trie cache to survive node restarts 211 }