github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/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 "os" 23 "os/user" 24 "time" 25 26 "github.com/unicornultrafoundation/go-u2u/common" 27 "github.com/unicornultrafoundation/go-u2u/core" 28 "github.com/unicornultrafoundation/go-u2u/eth/gasprice" 29 "github.com/unicornultrafoundation/go-u2u/evmcore" 30 "github.com/unicornultrafoundation/go-u2u/miner" 31 "github.com/unicornultrafoundation/go-u2u/params" 32 ) 33 34 // FullNodeGPO contains default gasprice oracle settings for full node. 35 var FullNodeGPO = gasprice.Config{ 36 Blocks: 20, 37 Percentile: 60, 38 MaxHeaderHistory: 1024, 39 MaxBlockHistory: 1024, 40 MaxPrice: gasprice.DefaultMaxPrice, 41 IgnorePrice: gasprice.DefaultIgnorePrice, 42 } 43 44 // Defaults contains default settings for use on the Ethereum main net. 45 var Defaults = Config{ 46 SyncMode: SnapSync, 47 NetworkId: 1, 48 TxLookupLimit: 2350000, 49 LightPeers: 100, 50 UltraLightFraction: 75, 51 DatabaseCache: 512, 52 TrieCleanCache: 154, 53 TrieCleanCacheJournal: "triecache", 54 TrieCleanCacheRejournal: 60 * time.Minute, 55 TrieDirtyCache: 256, 56 TrieTimeout: 60 * time.Minute, 57 SnapshotCache: 102, 58 Miner: miner.Config{ 59 GasCeil: 8000000, 60 GasPrice: big.NewInt(params.GWei), 61 Recommit: 3 * time.Second, 62 }, 63 TxPool: evmcore.DefaultTxPoolConfig, 64 RPCGasCap: 50000000, 65 GPO: FullNodeGPO, 66 RPCTxFeeCap: 1, // 1 ether 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 } 77 78 //go:generate gencodec -type Config -formats toml -out gen_config.go 79 80 // Config contains configuration options for of the ETH and LES protocols. 81 type Config struct { 82 // The genesis block, which is inserted if the database is empty. 83 // If nil, the Ethereum main net block is used. 84 Genesis *core.Genesis `toml:",omitempty"` 85 86 // Protocol options 87 NetworkId uint64 // Network ID to use for selecting peers to connect to 88 SyncMode SyncMode 89 90 // This can be set to list of enrtree:// URLs which will be queried for 91 // for nodes to connect to. 92 EthDiscoveryURLs []string 93 SnapDiscoveryURLs []string 94 95 NoPruning bool // Whether to disable pruning and flush everything to disk 96 NoPrefetch bool // Whether to disable prefetching and only load state on demand 97 98 TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved. 99 100 // Whitelist of required block number -> hash values to accept 101 Whitelist map[uint64]common.Hash `toml:"-"` 102 103 // Light client options 104 LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 105 LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers 106 LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers 107 LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 108 LightNoPrune bool `toml:",omitempty"` // Whether to disable light chain pruning 109 LightNoSyncServe bool `toml:",omitempty"` // Whether to serve light clients before syncing 110 SyncFromCheckpoint bool `toml:",omitempty"` // Whether to sync the header chain from the configured checkpoint 111 112 // Ultra Light client options 113 UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers 114 UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement 115 UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them 116 117 // Database options 118 SkipBcVersionCheck bool `toml:"-"` 119 DatabaseHandles int `toml:"-"` 120 DatabaseCache int 121 DatabaseFreezer string 122 123 TrieCleanCache int 124 TrieCleanCacheJournal string `toml:",omitempty"` // Disk journal directory for trie cache to survive node restarts 125 TrieCleanCacheRejournal time.Duration `toml:",omitempty"` // Time interval to regenerate the journal for clean cache 126 TrieDirtyCache int 127 TrieTimeout time.Duration 128 SnapshotCache int 129 Preimages bool 130 131 // Mining options 132 Miner miner.Config 133 134 // Transaction pool options 135 TxPool evmcore.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 // Berlin block override (TODO: remove after the fork) 154 OverrideLondon *big.Int `toml:",omitempty"` 155 }