github.com/Debrief-BC/go-debrief@v0.0.0-20200420203408-0c26ca968123/eth/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 eth
    18  
    19  import (
    20  	"math/big"
    21  	"os"
    22  	"os/user"
    23  	"path/filepath"
    24  	"runtime"
    25  	"time"
    26  
    27  	"github.com/Debrief-BC/go-debrief/common"
    28  	"github.com/Debrief-BC/go-debrief/consensus/ethash"
    29  	"github.com/Debrief-BC/go-debrief/core"
    30  	"github.com/Debrief-BC/go-debrief/eth/downloader"
    31  	"github.com/Debrief-BC/go-debrief/eth/gasprice"
    32  	"github.com/Debrief-BC/go-debrief/miner"
    33  	"github.com/Debrief-BC/go-debrief/params"
    34  )
    35  
    36  // DefaultConfig contains default settings for use on the Ethereum main net.
    37  var DefaultConfig = Config{
    38  	SyncMode: downloader.FullSync,
    39  	Ethash: ethash.Config{
    40  		CacheDir:         "ethash",
    41  		CachesInMem:      2,
    42  		CachesOnDisk:     3,
    43  		CachesLockMmap:   false,
    44  		DatasetsInMem:    1,
    45  		DatasetsOnDisk:   2,
    46  		DatasetsLockMmap: false,
    47  	},
    48  	NetworkId:          3839,
    49  	LightPeers:         100,
    50  	UltraLightFraction: 75,
    51  	DatabaseCache:      512,
    52  	TrieCleanCache:     256,
    53  	TrieDirtyCache:     256,
    54  	TrieTimeout:        60 * time.Minute,
    55  	SnapshotCache:      256,
    56  	Miner: miner.Config{
    57  		GasFloor: 8000000,
    58  		GasCeil:  8000000,
    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  }
    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  	if runtime.GOOS == "darwin" {
    77  		DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "Library", "Ethash")
    78  	} else if runtime.GOOS == "windows" {
    79  		localappdata := os.Getenv("LOCALAPPDATA")
    80  		if localappdata != "" {
    81  			DefaultConfig.Ethash.DatasetDir = filepath.Join(localappdata, "Ethash")
    82  		} else {
    83  			DefaultConfig.Ethash.DatasetDir = filepath.Join(home, "AppData", "Local", "Ethash")
    84  		}
    85  	} else {
    86  		DefaultConfig.Ethash.DatasetDir = filepath.Join(home, ".ethash")
    87  	}
    88  }
    89  
    90  //go:generate gencodec -type Config -formats toml -out gen_config.go
    91  
    92  type Config struct {
    93  	// The genesis block, which is inserted if the database is empty.
    94  	// If nil, the Ethereum main net block is used.
    95  	Genesis *core.Genesis `toml:",omitempty"`
    96  
    97  	// Protocol options
    98  	NetworkId uint64 // Network ID to use for selecting peers to connect to
    99  	SyncMode  downloader.SyncMode
   100  
   101  	// This can be set to list of enrtree:// URLs which will be queried for
   102  	// for nodes to connect to.
   103  	DiscoveryURLs []string
   104  
   105  	NoPruning  bool // Whether to disable pruning and flush everything to disk
   106  	NoPrefetch bool // Whether to disable prefetching and only load state on demand
   107  
   108  	// Whitelist of required block number -> hash values to accept
   109  	Whitelist map[uint64]common.Hash `toml:"-"`
   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  	SnapshotCache  int
   132  
   133  	// Mining options
   134  	Miner miner.Config
   135  
   136  	// Ethash options
   137  	Ethash ethash.Config
   138  
   139  	// Transaction pool options
   140  	TxPool core.TxPoolConfig
   141  
   142  	// Gas Price Oracle options
   143  	GPO gasprice.Config
   144  
   145  	// Enables tracking of SHA3 preimages in the VM
   146  	EnablePreimageRecording bool
   147  
   148  	// Miscellaneous options
   149  	DocRoot string `toml:"-"`
   150  
   151  	// Type of the EWASM interpreter ("" for default)
   152  	EWASMInterpreter string
   153  
   154  	// Type of the EVM interpreter ("" for default)
   155  	EVMInterpreter string
   156  
   157  	// RPCGasCap is the global gas cap for eth-call variants.
   158  	RPCGasCap *big.Int `toml:",omitempty"`
   159  
   160  	// Checkpoint is a hardcoded checkpoint which can be nil.
   161  	Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
   162  
   163  	// CheckpointOracle is the configuration for checkpoint oracle.
   164  	CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
   165  
   166  	// Istanbul block override (TODO: remove after the fork)
   167  	OverrideIstanbul *big.Int `toml:",omitempty"`
   168  
   169  	// MuirGlacier block override (TODO: remove after the fork)
   170  	OverrideMuirGlacier *big.Int `toml:",omitempty"`
   171  }