github.com/dominant-strategies/go-quai@v0.28.2/eth/ethconfig/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 ethconfig contains the configuration of the ETH and LES protocols. 18 package ethconfig 19 20 import ( 21 "math/big" 22 "time" 23 24 "github.com/dominant-strategies/go-quai/common" 25 "github.com/dominant-strategies/go-quai/consensus" 26 "github.com/dominant-strategies/go-quai/consensus/blake3pow" 27 "github.com/dominant-strategies/go-quai/consensus/progpow" 28 "github.com/dominant-strategies/go-quai/core" 29 "github.com/dominant-strategies/go-quai/eth/downloader" 30 "github.com/dominant-strategies/go-quai/eth/gasprice" 31 "github.com/dominant-strategies/go-quai/ethdb" 32 "github.com/dominant-strategies/go-quai/log" 33 "github.com/dominant-strategies/go-quai/node" 34 "github.com/dominant-strategies/go-quai/params" 35 ) 36 37 // FullNodeGPO contains default gasprice oracle settings for full node. 38 var FullNodeGPO = gasprice.Config{ 39 Blocks: 20, 40 Percentile: 60, 41 MaxHeaderHistory: 0, 42 MaxBlockHistory: 0, 43 MaxPrice: gasprice.DefaultMaxPrice, 44 IgnorePrice: gasprice.DefaultIgnorePrice, 45 } 46 47 // LightClientGPO contains default gasprice oracle settings for light client. 48 var LightClientGPO = gasprice.Config{ 49 Blocks: 2, 50 Percentile: 60, 51 MaxHeaderHistory: 300, 52 MaxBlockHistory: 5, 53 MaxPrice: gasprice.DefaultMaxPrice, 54 IgnorePrice: gasprice.DefaultIgnorePrice, 55 } 56 57 // Defaults contains default settings for use on the Quai main net. 58 var Defaults = Config{ 59 SyncMode: downloader.FullSync, 60 Progpow: progpow.Config{}, 61 NetworkId: 1, 62 TxLookupLimit: 2350000, 63 DatabaseCache: 512, 64 TrieCleanCache: 154, 65 TrieCleanCacheJournal: "triecache", 66 TrieCleanCacheRejournal: 60 * time.Minute, 67 TrieDirtyCache: 256, 68 TrieTimeout: 60 * time.Minute, 69 SnapshotCache: 102, 70 Miner: core.Config{ 71 GasCeil: 18000000, 72 GasPrice: big.NewInt(params.GWei), 73 Recommit: 3 * time.Second, 74 }, 75 TxPool: core.DefaultTxPoolConfig, 76 RPCGasCap: 50000000, 77 GPO: FullNodeGPO, 78 RPCTxFeeCap: 1, // 1 ether 79 DomUrl: "ws://127.0.0.1:8546", 80 SubUrls: []string{"ws://127.0.0.1:8546", "ws://127.0.0.1:8546", "ws://127.0.0.1:8546"}, 81 } 82 83 //go:generate gencodec -type Config -formats toml -out gen_config.go 84 85 // Config contains configuration options for of the ETH and LES protocols. 86 type Config struct { 87 // The genesis block, which is inserted if the database is empty. 88 // If nil, the Quai main net block is used. 89 Genesis *core.Genesis `toml:",omitempty"` 90 91 // Protocol options 92 NetworkId uint64 // Network ID to use for selecting peers to connect to 93 SyncMode downloader.SyncMode 94 95 // This can be set to list of enrtree:// URLs which will be queried for 96 // for nodes to connect to. 97 EthDiscoveryURLs []string 98 SnapDiscoveryURLs []string 99 100 NoPruning bool // Whether to disable pruning and flush everything to disk 101 NoPrefetch bool // Whether to disable prefetching and only load state on demand 102 103 TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 104 105 // Whitelist of required block number -> hash values to accept 106 Whitelist map[uint64]common.Hash `toml:"-"` 107 108 // Database options 109 SkipBcVersionCheck bool `toml:"-"` 110 DatabaseHandles int `toml:"-"` 111 DatabaseCache int 112 DatabaseFreezer string 113 114 TrieCleanCache int 115 TrieCleanCacheJournal string `toml:",omitempty"` // Disk journal directory for trie cache to survive node restarts 116 TrieCleanCacheRejournal time.Duration `toml:",omitempty"` // Time interval to regenerate the journal for clean cache 117 TrieDirtyCache int 118 TrieTimeout time.Duration 119 SnapshotCache int 120 Preimages bool 121 122 // Mining options 123 Miner core.Config 124 125 // Consensus Engine 126 ConsensusEngine string 127 128 // Progpow options 129 Progpow progpow.Config 130 131 // Blake3 options 132 Blake3Pow blake3pow.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 // Miscellaneous options 144 DocRoot string `toml:"-"` 145 146 // RPCGasCap is the global gas cap for eth-call variants. 147 RPCGasCap uint64 148 149 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for 150 // send-transction variants. The unit is ether. 151 RPCTxFeeCap float64 152 153 // Region location options 154 Region int 155 156 // Zone location options 157 Zone int 158 159 // Dom node websocket url 160 DomUrl string 161 162 // Sub node websocket urls 163 SubUrls []string 164 165 // Slices running on the node 166 SlicesRunning []common.Location 167 } 168 169 // CreateProgpowConsensusEngine creates a progpow consensus engine for the given chain configuration. 170 func CreateProgpowConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *progpow.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { 171 // Otherwise assume proof-of-work 172 switch config.PowMode { 173 case progpow.ModeFake: 174 log.Warn("Progpow used in fake mode") 175 case progpow.ModeTest: 176 log.Warn("Progpow used in test mode") 177 case progpow.ModeShared: 178 log.Warn("Progpow used in shared mode") 179 } 180 engine := progpow.New(progpow.Config{ 181 PowMode: config.PowMode, 182 NotifyFull: config.NotifyFull, 183 DurationLimit: config.DurationLimit, 184 GasCeil: config.GasCeil, 185 MinDifficulty: config.MinDifficulty, 186 }, notify, noverify) 187 engine.SetThreads(-1) // Disable CPU mining 188 return engine 189 } 190 191 // CreateBlake3ConsensusEngine creates a progpow consensus engine for the given chain configuration. 192 func CreateBlake3ConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *blake3pow.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { 193 // Otherwise assume proof-of-work 194 switch config.PowMode { 195 case blake3pow.ModeFake: 196 log.Warn("Progpow used in fake mode") 197 case blake3pow.ModeTest: 198 log.Warn("Progpow used in test mode") 199 case blake3pow.ModeShared: 200 log.Warn("Progpow used in shared mode") 201 } 202 engine := blake3pow.New(blake3pow.Config{ 203 PowMode: config.PowMode, 204 NotifyFull: config.NotifyFull, 205 DurationLimit: config.DurationLimit, 206 GasCeil: config.GasCeil, 207 MinDifficulty: config.MinDifficulty, 208 }, notify, noverify) 209 engine.SetThreads(-1) // Disable CPU mining 210 return engine 211 }