github.com/klaytn/klaytn@v1.10.2/node/cn/config.go (about) 1 // Modifications Copyright 2018 The klaytn Authors 2 // Copyright 2017 The go-ethereum Authors 3 // This file is part of go-ethereum. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 // 18 // This file is derived from eth/config.go (2018/06/04). 19 // Modified and improved for the klaytn development. 20 21 package cn 22 23 import ( 24 "math/big" 25 "os" 26 "os/user" 27 "time" 28 29 "github.com/klaytn/klaytn/storage/statedb" 30 31 "github.com/klaytn/klaytn/blockchain" 32 "github.com/klaytn/klaytn/blockchain/vm" 33 "github.com/klaytn/klaytn/common" 34 "github.com/klaytn/klaytn/common/hexutil" 35 "github.com/klaytn/klaytn/consensus/istanbul" 36 "github.com/klaytn/klaytn/datasync/downloader" 37 "github.com/klaytn/klaytn/log" 38 "github.com/klaytn/klaytn/node/cn/gasprice" 39 "github.com/klaytn/klaytn/params" 40 "github.com/klaytn/klaytn/storage/database" 41 ) 42 43 var logger = log.NewModuleLogger(log.NodeCN) 44 45 // GetDefaultConfig returns default settings for use on the Klaytn main net. 46 func GetDefaultConfig() *Config { 47 return &Config{ 48 SyncMode: downloader.FullSync, 49 NetworkId: params.CypressNetworkId, 50 LevelDBCacheSize: 768, 51 TrieCacheSize: 512, 52 TrieTimeout: 5 * time.Minute, 53 TrieBlockInterval: blockchain.DefaultBlockInterval, 54 TrieNodeCacheConfig: *statedb.GetEmptyTrieNodeCacheConfig(), 55 TriesInMemory: blockchain.DefaultTriesInMemory, 56 GasPrice: big.NewInt(18 * params.Ston), 57 58 TxPool: blockchain.DefaultTxPoolConfig, 59 GPO: gasprice.Config{ 60 Blocks: 20, 61 Percentile: 60, 62 MaxHeaderHistory: 1024, 63 MaxBlockHistory: 1024, 64 }, 65 WsEndpoint: "localhost:8546", 66 67 Istanbul: *istanbul.DefaultConfig, 68 RPCEVMTimeout: 5 * time.Second, 69 } 70 } 71 72 func init() { 73 home := os.Getenv("HOME") 74 if home == "" { 75 if user, err := user.Current(); err == nil { 76 home = user.HomeDir 77 } 78 } 79 } 80 81 //go:generate gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go 82 83 type Config struct { 84 // The genesis block, which is inserted if the database is empty. 85 // If nil, the Klaytn main net block is used. 86 Genesis *blockchain.Genesis `toml:",omitempty"` 87 88 // Protocol options 89 NetworkId uint64 // Network ID to use for selecting peers to connect to 90 SyncMode downloader.SyncMode 91 NoPruning bool 92 WorkerDisable bool // disables worker and does not start istanbul 93 94 // KES options 95 DownloaderDisable bool 96 FetcherDisable bool 97 98 // Service chain options 99 ParentOperatorAddr *common.Address `toml:",omitempty"` // A hex account address in the parent chain used to sign a child chain transaction. 100 AnchoringPeriod uint64 // Period when child chain sends an anchoring transaction to the parent chain. Default value is 1. 101 SentChainTxsLimit uint64 // Number of chain transactions stored for resending. Default value is 1000. 102 103 // Light client options 104 // LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests 105 // LightPeers int `toml:",omitempty"` // Maximum number of LES client peers 106 107 OverwriteGenesis bool 108 StartBlockNumber uint64 109 110 // Database options 111 DBType database.DBType 112 SkipBcVersionCheck bool `toml:"-"` 113 SingleDB bool 114 NumStateTrieShards uint 115 EnableDBPerfMetrics bool 116 LevelDBCompression database.LevelDBCompressionType 117 LevelDBBufferPool bool 118 LevelDBCacheSize int 119 DynamoDBConfig database.DynamoDBConfig 120 TrieCacheSize int 121 TrieTimeout time.Duration 122 TrieBlockInterval uint 123 TriesInMemory uint64 124 SenderTxHashIndexing bool 125 ParallelDBWrite bool 126 TrieNodeCacheConfig statedb.TrieNodeCacheConfig 127 SnapshotCacheSize int 128 SnapshotAsyncGen bool 129 130 // Mining-related options 131 ServiceChainSigner common.Address `toml:",omitempty"` 132 ExtraData []byte `toml:",omitempty"` 133 GasPrice *big.Int 134 135 // Reward 136 Rewardbase common.Address `toml:",omitempty"` 137 138 // Transaction pool options 139 TxPool blockchain.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 // Enables collecting internal transaction data during processing a block 147 EnableInternalTxTracing bool 148 // Istanbul options 149 Istanbul istanbul.Config 150 151 // Miscellaneous options 152 DocRoot string `toml:"-"` 153 154 WsEndpoint string `toml:",omitempty"` 155 156 // Tx Resending options 157 TxResendInterval uint64 158 TxResendCount int 159 TxResendUseLegacy bool 160 161 // Service Chain 162 NoAccountCreation bool 163 164 // use separate network different from baobab or cypress 165 IsPrivate bool 166 167 // Restart 168 AutoRestartFlag bool 169 RestartTimeOutFlag time.Duration 170 DaemonPathFlag string 171 172 // RPCGasCap is the global gas cap for eth-call variants. 173 RPCGasCap *big.Int `toml:",omitempty"` 174 175 // RPCEVMTimeout is the global timeout for klay/eth-call. 176 RPCEVMTimeout time.Duration 177 178 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for 179 // send-transction variants. The unit is klay. 180 // This is used by eth namespace RPC APIs 181 RPCTxFeeCap float64 182 183 // Disable option for unsafe debug APIs 184 DisableUnsafeDebug bool `toml:",omitempty"` 185 } 186 187 type configMarshaling struct { 188 ExtraData hexutil.Bytes 189 } 190 191 func (c *Config) getVMConfig() vm.Config { 192 return vm.Config{ 193 EnablePreimageRecording: c.EnablePreimageRecording, 194 EnableInternalTxTracing: c.EnableInternalTxTracing, 195 } 196 }