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