github.com/theQRL/go-zond@v0.2.1/zond/zondconfig/config.go (about)

     1  // Copyright 2021 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 ethconfig contains the configuration of the ZOND protocol.
    18  package zondconfig
    19  
    20  import (
    21  	"time"
    22  
    23  	"github.com/theQRL/go-zond/common"
    24  	"github.com/theQRL/go-zond/consensus"
    25  	"github.com/theQRL/go-zond/consensus/beacon"
    26  	"github.com/theQRL/go-zond/core"
    27  	"github.com/theQRL/go-zond/core/rawdb"
    28  	"github.com/theQRL/go-zond/core/txpool/legacypool"
    29  	"github.com/theQRL/go-zond/miner"
    30  	"github.com/theQRL/go-zond/params"
    31  	"github.com/theQRL/go-zond/zond/downloader"
    32  	"github.com/theQRL/go-zond/zond/gasprice"
    33  )
    34  
    35  // FullNodeGPO contains default gasprice oracle settings for full node.
    36  var FullNodeGPO = gasprice.Config{
    37  	Blocks:           20,
    38  	Percentile:       60,
    39  	MaxHeaderHistory: 1024,
    40  	MaxBlockHistory:  1024,
    41  	MaxPrice:         gasprice.DefaultMaxPrice,
    42  	IgnorePrice:      gasprice.DefaultIgnorePrice,
    43  }
    44  
    45  // Defaults contains default settings for use on the Zond main net.
    46  var Defaults = Config{
    47  	SyncMode:           downloader.SnapSync,
    48  	NetworkId:          1,
    49  	TransactionHistory: 2350000,
    50  	StateHistory:       params.FullImmutabilityThreshold,
    51  	StateScheme:        rawdb.HashScheme,
    52  	DatabaseCache:      512,
    53  	TrieCleanCache:     154,
    54  	TrieDirtyCache:     256,
    55  	TrieTimeout:        60 * time.Minute,
    56  	SnapshotCache:      102,
    57  	FilterLogCacheSize: 32,
    58  	Miner:              miner.DefaultConfig,
    59  	TxPool:             legacypool.DefaultConfig,
    60  	RPCGasCap:          50000000,
    61  	RPCZVMTimeout:      5 * time.Second,
    62  	GPO:                FullNodeGPO,
    63  	RPCTxFeeCap:        1, // 1 ether
    64  }
    65  
    66  //go:generate go run github.com/fjl/gencodec -type Config -formats toml -out gen_config.go
    67  
    68  // Config contains configuration options for of the Zond protocol.
    69  type Config struct {
    70  	// The genesis block, which is inserted if the database is empty.
    71  	// If nil, the Zond main net block is used.
    72  	Genesis *core.Genesis `toml:",omitempty"`
    73  
    74  	// Network ID separates blockchains on the peer-to-peer networking level. When left
    75  	// zero, the chain ID is used as network ID.
    76  	NetworkId uint64
    77  	SyncMode  downloader.SyncMode
    78  
    79  	// This can be set to list of enrtree:// URLs which will be queried for
    80  	// for nodes to connect to.
    81  	ZondDiscoveryURLs []string
    82  	SnapDiscoveryURLs []string
    83  
    84  	NoPruning  bool // Whether to disable pruning and flush everything to disk
    85  	NoPrefetch bool // Whether to disable prefetching and only load state on demand
    86  
    87  	TransactionHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved.
    88  	StateHistory       uint64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved.
    89  
    90  	// State scheme represents the scheme used to store zond states and trie
    91  	// nodes on top. It can be 'hash', 'path', or none which means use the scheme
    92  	// consistent with persistent state.
    93  	StateScheme string `toml:",omitempty"`
    94  
    95  	// RequiredBlocks is a set of block number -> hash mappings which must be in the
    96  	// canonical chain of all remote peers. Setting the option makes gzond verify the
    97  	// presence of these blocks for every new peer connection.
    98  	RequiredBlocks map[uint64]common.Hash `toml:"-"`
    99  
   100  	// Database options
   101  	SkipBcVersionCheck bool `toml:"-"`
   102  	DatabaseHandles    int  `toml:"-"`
   103  	DatabaseCache      int
   104  	DatabaseFreezer    string
   105  
   106  	TrieCleanCache int
   107  	TrieDirtyCache int
   108  	TrieTimeout    time.Duration
   109  	SnapshotCache  int
   110  	Preimages      bool
   111  
   112  	// This is the number of blocks for which logs will be cached in the filter system.
   113  	FilterLogCacheSize int
   114  
   115  	// Mining options
   116  	Miner miner.Config
   117  
   118  	// Transaction pool options
   119  	TxPool legacypool.Config
   120  
   121  	// Gas Price Oracle options
   122  	GPO gasprice.Config
   123  
   124  	// Enables tracking of SHA3 preimages in the VM
   125  	EnablePreimageRecording bool
   126  
   127  	// Miscellaneous options
   128  	DocRoot string `toml:"-"`
   129  
   130  	// RPCGasCap is the global gas cap for zond-call variants.
   131  	RPCGasCap uint64
   132  
   133  	// RPCZVMTimeout is the global timeout for zond-call.
   134  	RPCZVMTimeout time.Duration
   135  
   136  	// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
   137  	// send-transaction variants. The unit is ether.
   138  	RPCTxFeeCap float64
   139  }
   140  
   141  // CreateConsensusEngine creates a consensus engine for the given chain config.
   142  func CreateConsensusEngine() consensus.Engine {
   143  	return beacon.New()
   144  }