config.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. package eth
  17. import (
  18. "math/big"
  19. "os"
  20. "os/user"
  21. "path/filepath"
  22. "runtime"
  23. "time"
  24. "github.com/ethereum/go-ethereum/common"
  25. "github.com/ethereum/go-ethereum/consensus/ethash"
  26. "github.com/ethereum/go-ethereum/core"
  27. "github.com/ethereum/go-ethereum/eth/downloader"
  28. "github.com/ethereum/go-ethereum/eth/gasprice"
  29. "github.com/ethereum/go-ethereum/miner"
  30. "github.com/ethereum/go-ethereum/params"
  31. )
  32. // DefaultConfig contains default settings for use on the Ethereum main net.
  33. var DefaultConfig = Config{
  34. SyncMode: downloader.FastSync,
  35. Ethash: ethash.Config{
  36. CacheDir: "ethash",
  37. CachesInMem: 2,
  38. CachesOnDisk: 3,
  39. CachesLockMmap: false,
  40. DatasetsInMem: 1,
  41. DatasetsOnDisk: 2,
  42. DatasetsLockMmap: false,
  43. },
  44. NetworkId: 1,
  45. LightPeers: 100,
  46. UltraLightFraction: 75,
  47. DatabaseCache: 512,
  48. TrieCleanCache: 256,
  49. TrieDirtyCache: 256,
  50. TrieTimeout: 60 * time.Minute,
  51. SnapshotCache: 256,
  52. Miner: miner.Config{
  53. GasFloor: 8000000,
  54. GasCeil: 8000000,
  55. GasPrice: big.NewInt(params.GWei),
  56. Recommit: 3 * time.Second,
  57. },
  58. TxPool: core.DefaultTxPoolConfig,
  59. GPO: gasprice.Config{
  60. Blocks: 20,
  61. Percentile: 60,
  62. OracleThreshold: 1000,
  63. },
  64. }
  65. func init() {
  66. home := os.Getenv("HOME")
  67. if home == "" {
  68. if user, err := user.Current(); err == nil {
  69. home = user.HomeDir
  70. }
  71. }
  72. if runtime.GOOS == "darwin" {
  73. DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash")
  74. } else if runtime.GOOS == "windows" {
  75. localappdata := os.Getenv("LOCALAPPDATA")
  76. if localappdata != "" {
  77. DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash")
  78. } else {
  79. DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash")
  80. }
  81. } else {
  82. DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash")
  83. }
  84. }
  85. //go:generate gencodec -type Config -formats toml -out gen_config.go
  86. type Config struct {
  87. // The genesis block, which is inserted if the database is empty.
  88. // If nil, the Ethereum main net block is used.
  89. Genesis *core.Genesis `toml:",omitempty"`
  90. // Protocol options
  91. NetworkId uint64 // Network ID to use for selecting peers to connect to
  92. SyncMode downloader.SyncMode
  93. // This can be set to list of enrtree:// URLs which will be queried for
  94. // for nodes to connect to.
  95. DiscoveryURLs []string
  96. NoPruning bool // Whether to disable pruning and flush everything to disk
  97. NoPrefetch bool // Whether to disable prefetching and only load state on demand
  98. DirectBroadcast bool
  99. // Whitelist of required block number -> hash values to accept
  100. Whitelist map[uint64]common.Hash `toml:"-"`
  101. // Light client options
  102. LightServ int `toml:",omitempty"` // Maximum percentage of time allowed for serving LES requests
  103. LightIngress int `toml:",omitempty"` // Incoming bandwidth limit for light servers
  104. LightEgress int `toml:",omitempty"` // Outgoing bandwidth limit for light servers
  105. LightPeers int `toml:",omitempty"` // Maximum number of LES client peers
  106. // Ultra Light client options
  107. UltraLightServers []string `toml:",omitempty"` // List of trusted ultra light servers
  108. UltraLightFraction int `toml:",omitempty"` // Percentage of trusted servers to accept an announcement
  109. UltraLightOnlyAnnounce bool `toml:",omitempty"` // Whether to only announce headers, or also serve them
  110. // Database options
  111. SkipBcVersionCheck bool `toml:"-"`
  112. DatabaseHandles int `toml:"-"`
  113. DatabaseCache int
  114. DatabaseFreezer string
  115. TrieCleanCache int
  116. TrieDirtyCache int
  117. TrieTimeout time.Duration
  118. SnapshotCache int
  119. // Mining options
  120. Miner miner.Config
  121. // Ethash options
  122. Ethash ethash.Config `toml:",omitempty"`
  123. // Transaction pool options
  124. TxPool core.TxPoolConfig
  125. // Gas Price Oracle options
  126. GPO gasprice.Config
  127. // Enables tracking of SHA3 preimages in the VM
  128. EnablePreimageRecording bool
  129. // Miscellaneous options
  130. DocRoot string `toml:"-"`
  131. // Type of the EWASM interpreter ("" for default)
  132. EWASMInterpreter string
  133. // Type of the EVM interpreter ("" for default)
  134. EVMInterpreter string
  135. // RPCGasCap is the global gas cap for eth-call variants.
  136. RPCGasCap *big.Int `toml:",omitempty"`
  137. // Checkpoint is a hardcoded checkpoint which can be nil.
  138. Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
  139. // CheckpointOracle is the configuration for checkpoint oracle.
  140. CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
  141. // Istanbul block override (TODO: remove after the fork)
  142. OverrideIstanbul *big.Int `toml:",omitempty"`
  143. // MuirGlacier block override (TODO: remove after the fork)
  144. OverrideMuirGlacier *big.Int `toml:",omitempty"`
  145. }