config.go 5.2 KB

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