Documentation ¶
Index ¶
- Constants
- Variables
- func DoNotValidate(cfg Config) error
- func ValidateAPI(cfg Config) error
- func ValidateActPool(cfg Config) error
- func ValidateArchiveMode(cfg Config) error
- func ValidateDispatcher(cfg Config) error
- func ValidateForkHeights(cfg Config) error
- func ValidateRollDPoS(cfg Config) error
- type API
- type ActPool
- type BlockSync
- type Chain
- type Config
- type Consensus
- type ConsensusTiming
- type DB
- type Dispatcher
- type GasStation
- type HeightName
- type HeightUpgrade
- func (hu *HeightUpgrade) AleutianBlockHeight() uint64
- func (hu *HeightUpgrade) BeringBlockHeight() uint64
- func (hu *HeightUpgrade) CookBlockHeight() uint64
- func (hu *HeightUpgrade) DardanellesBlockHeight() uint64
- func (hu *HeightUpgrade) DaytonaBlockHeight() uint64
- func (hu *HeightUpgrade) EasterBlockHeight() uint64
- func (hu *HeightUpgrade) FairbankBlockHeight() uint64
- func (hu *HeightUpgrade) FbkMigrationBlockHeight() uint64
- func (hu *HeightUpgrade) GreenlandBlockHeight() uint64
- func (hu *HeightUpgrade) HawaiiBlockHeight() uint64
- func (hu *HeightUpgrade) IsPost(name HeightName, height uint64) bool
- func (hu *HeightUpgrade) IsPre(name HeightName, height uint64) bool
- func (hu *HeightUpgrade) PacificBlockHeight() uint64
- type Indexer
- type Network
- type RollDPoS
- type System
- type Validate
Constants ¶
const ( // RollDPoSScheme means randomized delegated proof of stake RollDPoSScheme = "ROLLDPOS" // StandaloneScheme means that the node creates a block periodically regardless of others (if there is any) StandaloneScheme = "STANDALONE" // NOOPScheme means that the node does not create only block NOOPScheme = "NOOP" )
const ( DardanellesUnmatchedEventTTL = 2 * time.Second DardanellesUnmatchedEventInterval = 100 * time.Millisecond DardanellesAcceptBlockTTL = 2 * time.Second DardanellesAcceptProposalEndorsementTTL = time.Second DardanellesAcceptLockEndorsementTTL = time.Second DardanellesCommitTTL = time.Second DardanellesBlockInterval = 5 * time.Second DardanellesDelay = 2 * time.Second SigP256k1 = "secp256k1" SigP256sm2 = "p256sm2" )
Dardanelles consensus config
const ( Pacific = iota Aleutian Bering Cook Dardanelles Daytona Easter Fairbank FbkMigration Greenland Hawaii )
Codename for height upgrades
const ( // GatewayPlugin is the plugin of accepting user API requests and serving blockchain data to users GatewayPlugin = iota )
Variables ¶
var ( // Default is the default config Default = Config{ Plugins: make(map[int]interface{}), SubLogs: make(map[string]log.GlobalConfig), Network: Network{ Host: "0.0.0.0", Port: 4689, ExternalHost: "", ExternalPort: 4689, BootstrapNodes: []string{}, MasterKey: "", RateLimit: p2p.DefaultRatelimitConfig, EnableRateLimit: true, PrivateNetworkPSK: "", }, Chain: Chain{ ChainDBPath: "/var/data/chain.db", TrieDBPath: "/var/data/trie.db", IndexDBPath: "/var/data/index.db", BloomfilterIndexDBPath: "/var/data/bloomfilter.index.db", CandidateIndexDBPath: "/var/data/candidate.index.db", StakingIndexDBPath: "/var/data/staking.index.db", ID: 1, Address: "", ProducerPrivKey: generateRandomKey(SigP256k1), SignatureScheme: []string{SigP256k1}, EmptyGenesis: false, GravityChainDB: DB{DbPath: "/var/data/poll.db", NumRetries: 10}, Committee: committee.Config{ GravityChainAPIs: []string{}, }, EnableTrielessStateDB: true, EnableStateDBCaching: false, EnableArchiveMode: false, EnableAsyncIndexWrite: true, EnableSystemLogIndexer: false, EnableStakingProtocol: true, EnableStakingIndexer: false, CompressBlock: false, AllowedBlockGasResidue: 10000, MaxCacheSize: 0, PollInitialCandidatesInterval: 10 * time.Second, StateDBCacheSize: 1000, WorkingSetCacheSize: 20, }, ActPool: ActPool{ MaxNumActsPerPool: 32000, MaxGasLimitPerPool: 320000000, MaxNumActsPerAcct: 2000, ActionExpiry: 10 * time.Minute, MinGasPriceStr: big.NewInt(unit.Qev).String(), BlackList: []string{}, }, Consensus: Consensus{ Scheme: StandaloneScheme, RollDPoS: RollDPoS{ FSM: ConsensusTiming{ UnmatchedEventTTL: 3 * time.Second, UnmatchedEventInterval: 100 * time.Millisecond, AcceptBlockTTL: 4 * time.Second, AcceptProposalEndorsementTTL: 2 * time.Second, AcceptLockEndorsementTTL: 2 * time.Second, CommitTTL: 2 * time.Second, EventChanSize: 10000, }, ToleratedOvertime: 2 * time.Second, Delay: 5 * time.Second, ConsensusDBPath: "/var/data/consensus.db", }, }, BlockSync: BlockSync{ Interval: 10 * time.Second, ProcessSyncRequestTTL: 10 * time.Second, BufferSize: 200, IntervalSize: 20, MaxRepeat: 3, RepeatDecayStep: 1, }, Dispatcher: Dispatcher{ EventChanSize: 10000, }, API: API{ UseRDS: false, Port: 14014, TpsWindow: 10, GasStation: GasStation{ SuggestBlockWindow: 20, DefaultGas: uint64(unit.Qev), Percentile: 60, }, RangeQueryLimit: 1000, }, System: System{ Active: true, HeartbeatInterval: 10 * time.Second, HTTPStatsPort: 8080, HTTPAdminPort: 9009, StartSubChainInterval: 10 * time.Second, SystemLogDBPath: "/var/data/systemlog.db", }, DB: DB{ NumRetries: 3, MaxCacheSize: 64, BlockStoreBatchSize: 16, V2BlocksToSplitDB: 1000000, Compressor: "Snappy", CompressLegacy: false, SplitDBSizeMB: 0, SplitDBHeight: 900000, HistoryStateRetention: 2000, }, Indexer: Indexer{ RangeBloomFilterNumElements: 100000, RangeBloomFilterSize: 1200000, RangeBloomFilterNumHash: 8, }, Genesis: genesis.Default, } // ErrInvalidCfg indicates the invalid config value ErrInvalidCfg = errors.New("invalid config value") // Validates is the collection config validation functions Validates = []Validate{ ValidateRollDPoS, ValidateArchiveMode, ValidateDispatcher, ValidateAPI, ValidateActPool, ValidateForkHeights, } )
Functions ¶
func DoNotValidate ¶ added in v0.3.0
DoNotValidate validates the given config
func ValidateAPI ¶ added in v0.5.0
ValidateAPI validates the api configs
func ValidateActPool ¶ added in v0.3.0
ValidateActPool validates the given config
func ValidateArchiveMode ¶ added in v0.11.0
ValidateArchiveMode validates the state factory setting
func ValidateDispatcher ¶ added in v0.3.0
ValidateDispatcher validates the dispatcher configs
func ValidateForkHeights ¶ added in v1.1.0
ValidateForkHeights validates the forked heights
func ValidateRollDPoS ¶ added in v0.3.0
ValidateRollDPoS validates the roll-DPoS configs
Types ¶
type API ¶ added in v0.5.0
type API struct { UseRDS bool `yaml:"useRDS"` Port int `yaml:"port"` TpsWindow int `yaml:"tpsWindow"` GasStation GasStation `yaml:"gasStation"` RangeQueryLimit uint64 `yaml:"rangeQueryLimit"` }
API is the api service config
type ActPool ¶ added in v0.3.0
type ActPool struct { // MaxNumActsPerPool indicates maximum number of actions the whole actpool can hold MaxNumActsPerPool uint64 `yaml:"maxNumActsPerPool"` // MaxGasLimitPerPool indicates maximum gas limit the whole actpool can hold MaxGasLimitPerPool uint64 `yaml:"maxGasLimitPerPool"` // MaxNumActsPerAcct indicates maximum number of actions an account queue can hold MaxNumActsPerAcct uint64 `yaml:"maxNumActsPerAcct"` // ActionExpiry defines how long an action will be kept in action pool. ActionExpiry time.Duration `yaml:"actionExpiry"` // MinGasPriceStr defines the minimal gas price the delegate will accept for an action MinGasPriceStr string `yaml:"minGasPrice"` // BlackList lists the account address that are banned from initiating actions BlackList []string `yaml:"blackList"` }
ActPool is the actpool config
func (ActPool) MinGasPrice ¶ added in v0.5.0
MinGasPrice returns the minimal gas price threshold
type BlockSync ¶ added in v0.2.0
type BlockSync struct { Interval time.Duration `yaml:"interval"` // update duration ProcessSyncRequestTTL time.Duration `yaml:"processSyncRequestTTL"` BufferSize uint64 `yaml:"bufferSize"` IntervalSize uint64 `yaml:"intervalSize"` // MaxRepeat is the maximal number of repeat of a block sync request MaxRepeat int `yaml:"maxRepeat"` // RepeatDecayStep is the step for repeat number decreasing by 1 RepeatDecayStep int `yaml:"repeatDecayStep"` }
BlockSync is the config struct for the BlockSync
type Chain ¶
type Chain struct { ChainDBPath string `yaml:"chainDBPath"` TrieDBPath string `yaml:"trieDBPath"` IndexDBPath string `yaml:"indexDBPath"` BloomfilterIndexDBPath string `yaml:"bloomfilterIndexDBPath"` CandidateIndexDBPath string `yaml:"candidateIndexDBPath"` StakingIndexDBPath string `yaml:"stakingIndexDBPath"` ID uint32 `yaml:"id"` Address string `yaml:"address"` ProducerPrivKey string `yaml:"producerPrivKey"` SignatureScheme []string `yaml:"signatureScheme"` EmptyGenesis bool `yaml:"emptyGenesis"` GravityChainDB DB `yaml:"gravityChainDB"` Committee committee.Config `yaml:"committee"` EnableTrielessStateDB bool `yaml:"enableTrielessStateDB"` // EnableStateDBCaching enables cachedStateDBOption EnableStateDBCaching bool `yaml:"enableStateDBCaching"` // EnableArchiveMode is only meaningful when EnableTrielessStateDB is false EnableArchiveMode bool `yaml:"enableArchiveMode"` // EnableAsyncIndexWrite enables writing the block actions' and receipts' index asynchronously EnableAsyncIndexWrite bool `yaml:"enableAsyncIndexWrite"` // deprecated EnableSystemLogIndexer bool `yaml:"enableSystemLog"` // EnableStakingProtocol enables staking protocol EnableStakingProtocol bool `yaml:"enableStakingProtocol"` // EnableStakingIndexer enables staking indexer EnableStakingIndexer bool `yaml:"enableStakingIndexer"` // deprecated by DB.CompressBlock CompressBlock bool `yaml:"compressBlock"` // AllowedBlockGasResidue is the amount of gas remained when block producer could stop processing more actions AllowedBlockGasResidue uint64 `yaml:"allowedBlockGasResidue"` // MaxCacheSize is the max number of blocks that will be put into an LRU cache. 0 means disabled MaxCacheSize int `yaml:"maxCacheSize"` // PollInitialCandidatesInterval is the config for committee init db PollInitialCandidatesInterval time.Duration `yaml:"pollInitialCandidatesInterval"` // StateDBCacheSize is the max size of statedb LRU cache StateDBCacheSize int `yaml:"stateDBCacheSize"` // WorkingSetCacheSize is the max size of workingset cache in state factory WorkingSetCacheSize uint64 `yaml:"workingSetCacheSize"` }
Chain is the config struct for blockchain package
type Config ¶
type Config struct { Plugins map[int]interface{} `ymal:"plugins"` Network Network `yaml:"network"` Chain Chain `yaml:"chain"` ActPool ActPool `yaml:"actPool"` Consensus Consensus `yaml:"consensus"` BlockSync BlockSync `yaml:"blockSync"` Dispatcher Dispatcher `yaml:"dispatcher"` API API `yaml:"api"` System System `yaml:"system"` DB DB `yaml:"db"` Indexer Indexer `yaml:"indexer"` Log log.GlobalConfig `yaml:"log"` SubLogs map[string]log.GlobalConfig `yaml:"subLogs"` Genesis genesis.Genesis `yaml:"genesis"` }
Config is the root config struct, each package's config should be put as its sub struct
func New ¶ added in v0.3.0
New creates a config instance. It first loads the default configs. If the config path is not empty, it will read from the file and override the default configs. By default, it will apply all validation functions. To bypass validation, use DoNotValidate instead.
func (Config) ProducerAddress ¶ added in v0.5.0
ProducerAddress returns the configured producer address derived from key
func (Config) ProducerPrivateKey ¶ added in v0.5.0
func (cfg Config) ProducerPrivateKey() crypto.PrivateKey
ProducerPrivateKey returns the configured private key
type Consensus ¶
type Consensus struct { // There are three schemes that are supported Scheme string `yaml:"scheme"` RollDPoS RollDPoS `yaml:"rollDPoS"` }
Consensus is the config struct for consensus package
type ConsensusTiming ¶ added in v0.10.0
type ConsensusTiming struct { EventChanSize uint `yaml:"eventChanSize"` UnmatchedEventTTL time.Duration `yaml:"unmatchedEventTTL"` UnmatchedEventInterval time.Duration `yaml:"unmatchedEventInterval"` AcceptBlockTTL time.Duration `yaml:"acceptBlockTTL"` AcceptProposalEndorsementTTL time.Duration `yaml:"acceptProposalEndorsementTTL"` AcceptLockEndorsementTTL time.Duration `yaml:"acceptLockEndorsementTTL"` CommitTTL time.Duration `yaml:"commitTTL"` }
ConsensusTiming defines a set of time durations used in fsm and event queue size
type DB ¶ added in v0.4.0
type DB struct { DbPath string `yaml:"dbPath"` // NumRetries is the number of retries NumRetries uint8 `yaml:"numRetries"` // MaxCacheSize is the max number of blocks that will be put into an LRU cache. 0 means disabled MaxCacheSize int `yaml:"maxCacheSize"` // BlockStoreBatchSize is the number of blocks to be stored together as a unit (to get better compression) BlockStoreBatchSize int `yaml:"blockStoreBatchSize"` // V2BlocksToSplitDB is the accumulated number of blocks to split a new file after v1.1.2 V2BlocksToSplitDB uint64 `yaml:"v2BlocksToSplitDB"` // Compressor is the compression used on block data, used by new DB file after v1.1.2 Compressor string `yaml:"compressor"` // CompressLegacy enables gzip compression on block data, used by legacy DB file before v1.1.2 CompressLegacy bool `yaml:"compressLegacy"` // SplitDBSize is the config for DB's split file size SplitDBSizeMB uint64 `yaml:"splitDBSizeMB"` // SplitDBHeight is the config for DB's split start height SplitDBHeight uint64 `yaml:"splitDBHeight"` // HistoryStateRetention is the number of blocks account/contract state will be retained HistoryStateRetention uint64 `yaml:"historyStateRetention"` }
DB is the config for database
func (DB) SplitDBSize ¶ added in v0.8.1
SplitDBSize returns the configured SplitDBSizeMB
type Dispatcher ¶ added in v0.2.0
type Dispatcher struct {
EventChanSize uint `yaml:"eventChanSize"`
}
Dispatcher is the dispatcher config
type GasStation ¶ added in v0.4.4
type GasStation struct { SuggestBlockWindow int `yaml:"suggestBlockWindow"` DefaultGas uint64 `yaml:"defaultGas"` Percentile int `yaml:"Percentile"` }
GasStation is the gas station config
type HeightUpgrade ¶ added in v0.8.1
type HeightUpgrade struct {
// contains filtered or unexported fields
}
HeightUpgrade lists heights at which certain fixes take effect prior to Dardanelles, each epoch consists of 360 blocks (10s/block) so height = 360k + 1 starting Dardanelles, each epoch consists of 720 blocks (5s/block) however, DardanellesHeight is set to 360(2k + 1) + 1 (instead of 720k + 1) so height afterwards must be set to 360(2k + 1) + 1
func NewHeightUpgrade ¶ added in v0.8.1
func NewHeightUpgrade(cfg *genesis.Genesis) HeightUpgrade
NewHeightUpgrade creates a height upgrade config
func (*HeightUpgrade) AleutianBlockHeight ¶ added in v0.8.3
func (hu *HeightUpgrade) AleutianBlockHeight() uint64
AleutianBlockHeight returns the aleutian height
func (*HeightUpgrade) BeringBlockHeight ¶ added in v0.8.3
func (hu *HeightUpgrade) BeringBlockHeight() uint64
BeringBlockHeight returns the bering height
func (*HeightUpgrade) CookBlockHeight ¶ added in v0.9.0
func (hu *HeightUpgrade) CookBlockHeight() uint64
CookBlockHeight returns the cook height
func (*HeightUpgrade) DardanellesBlockHeight ¶ added in v0.10.0
func (hu *HeightUpgrade) DardanellesBlockHeight() uint64
DardanellesBlockHeight returns the dardanelles height
func (*HeightUpgrade) DaytonaBlockHeight ¶ added in v0.10.2
func (hu *HeightUpgrade) DaytonaBlockHeight() uint64
DaytonaBlockHeight returns the daytona height
func (*HeightUpgrade) EasterBlockHeight ¶ added in v0.11.0
func (hu *HeightUpgrade) EasterBlockHeight() uint64
EasterBlockHeight returns the easter height
func (*HeightUpgrade) FairbankBlockHeight ¶ added in v0.11.0
func (hu *HeightUpgrade) FairbankBlockHeight() uint64
FairbankBlockHeight returns the fairbank height
func (*HeightUpgrade) FbkMigrationBlockHeight ¶ added in v1.0.0
func (hu *HeightUpgrade) FbkMigrationBlockHeight() uint64
FbkMigrationBlockHeight returns the fairbank migration height
func (*HeightUpgrade) GreenlandBlockHeight ¶ added in v1.1.0
func (hu *HeightUpgrade) GreenlandBlockHeight() uint64
GreenlandBlockHeight returns the greenland height
func (*HeightUpgrade) HawaiiBlockHeight ¶ added in v1.1.4
func (hu *HeightUpgrade) HawaiiBlockHeight() uint64
HawaiiBlockHeight returns the hawaii height
func (*HeightUpgrade) IsPost ¶ added in v0.8.1
func (hu *HeightUpgrade) IsPost(name HeightName, height uint64) bool
IsPost return true if height is after the height upgrade
func (*HeightUpgrade) IsPre ¶ added in v0.8.1
func (hu *HeightUpgrade) IsPre(name HeightName, height uint64) bool
IsPre return true if height is before the height upgrade
func (*HeightUpgrade) PacificBlockHeight ¶ added in v0.8.3
func (hu *HeightUpgrade) PacificBlockHeight() uint64
PacificBlockHeight returns the pacific height
type Indexer ¶ added in v0.4.0
type Indexer struct { // RangeBloomFilterNumElements is the number of elements each rangeBloomfilter will store in bloomfilterIndexer RangeBloomFilterNumElements uint64 `yaml:"rangeBloomFilterNumElements"` // RangeBloomFilterSize is the size (in bits) of rangeBloomfilter RangeBloomFilterSize uint64 `yaml:"rangeBloomFilterSize"` // RangeBloomFilterNumHash is the number of hash functions of rangeBloomfilter RangeBloomFilterNumHash uint64 `yaml:"rangeBloomFilterNumHash"` }
Indexer is the config for indexer
type Network ¶
type Network struct { Host string `yaml:"host"` Port int `yaml:"port"` ExternalHost string `yaml:"externalHost"` ExternalPort int `yaml:"externalPort"` BootstrapNodes []string `yaml:"bootstrapNodes"` MasterKey string `yaml:"masterKey"` // master key will be PrivateKey if not set. // RelayType is the type of P2P network relay. By default, the value is empty, meaning disabled. Two relay types // are supported: active, nat. RelayType string `yaml:"relayType"` RateLimit p2p.RateLimitConfig `yaml:"rateLimit"` EnableRateLimit bool `yaml:"enableRateLimit"` PrivateNetworkPSK string `yaml:"privateNetworkPSK"` }
Network is the config struct for network package
type RollDPoS ¶ added in v0.2.0
type RollDPoS struct { FSM ConsensusTiming `yaml:"fsm"` ToleratedOvertime time.Duration `yaml:"toleratedOvertime"` Delay time.Duration `yaml:"delay"` ConsensusDBPath string `yaml:"consensusDBPath"` }
RollDPoS is the config struct for RollDPoS consensus package
type System ¶ added in v0.2.0
type System struct { // Active is the status of the node. True means active and false means stand-by Active bool `yaml:"active"` HeartbeatInterval time.Duration `yaml:"heartbeatInterval"` // HTTPProfilingPort is the port number to access golang performance profiling data of a blockchain node. It is // 0 by default, meaning performance profiling has been disabled HTTPAdminPort int `yaml:"httpAdminPort"` HTTPStatsPort int `yaml:"httpStatsPort"` StartSubChainInterval time.Duration `yaml:"startSubChainInterval"` SystemLogDBPath string `yaml:"systemLogDBPath"` }
System is the system config