config

package
v1.8.3-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 15 Imported by: 44

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	// GatewayPlugin is the plugin of accepting user API requests and serving blockchain data to users
	GatewayPlugin = iota
)

Variables

View Source
var (
	// Default is the default config
	Default = Config{
		Plugins: make(map[int]interface{}),
		SubLogs: make(map[string]log.GlobalConfig),
		Network: p2p.DefaultConfig,
		Chain:   blockchain.DefaultConfig,
		ActPool: actpool.DefaultConfig,
		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",
			},
		},
		DardanellesUpgrade: DardanellesUpgrade{
			UnmatchedEventTTL:            2 * time.Second,
			UnmatchedEventInterval:       100 * time.Millisecond,
			AcceptBlockTTL:               2 * time.Second,
			AcceptProposalEndorsementTTL: time.Second,
			AcceptLockEndorsementTTL:     time.Second,
			CommitTTL:                    time.Second,
			BlockInterval:                5 * time.Second,
			Delay:                        2 * time.Second,
		},
		BlockSync: BlockSync{
			Interval:              30 * time.Second,
			ProcessSyncRequestTTL: 10 * time.Second,
			BufferSize:            200,
			IntervalSize:          20,
			MaxRepeat:             3,
			RepeatDecayStep:       1,
		},
		Dispatcher: dispatcher.DefaultConfig,
		API: API{
			UseRDS:        false,
			GRPCPort:      14014,
			HTTPPort:      15014,
			WebSocketPort: 16014,
			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:         0,
			StartSubChainInterval: 10 * time.Second,
			SystemLogDBPath:       "/var/log",
		},
		DB:      db.DefaultConfig,
		Indexer: blockindex.DefaultConfig,
		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,
	}
)

Dardanelles consensus config

Functions

func DoNotValidate added in v0.3.0

func DoNotValidate(cfg Config) error

DoNotValidate validates the given config

func ValidateAPI added in v0.5.0

func ValidateAPI(cfg Config) error

ValidateAPI validates the api configs

func ValidateActPool added in v0.3.0

func ValidateActPool(cfg Config) error

ValidateActPool validates the given config

func ValidateArchiveMode added in v0.11.0

func ValidateArchiveMode(cfg Config) error

ValidateArchiveMode validates the state factory setting

func ValidateDispatcher added in v0.3.0

func ValidateDispatcher(cfg Config) error

ValidateDispatcher validates the dispatcher configs

func ValidateForkHeights added in v1.1.0

func ValidateForkHeights(cfg Config) error

ValidateForkHeights validates the forked heights

func ValidateRollDPoS added in v0.3.0

func ValidateRollDPoS(cfg Config) error

ValidateRollDPoS validates the roll-DPoS configs

Types

type API added in v0.5.0

type API struct {
	UseRDS          bool          `yaml:"useRDS"`
	GRPCPort        int           `yaml:"port"`
	HTTPPort        int           `yaml:"web3port"`
	WebSocketPort   int           `yaml:"webSocketPort"`
	RedisCacheURL   string        `yaml:"redisCacheURL"`
	TpsWindow       int           `yaml:"tpsWindow"`
	GasStation      GasStation    `yaml:"gasStation"`
	RangeQueryLimit uint64        `yaml:"rangeQueryLimit"`
	Tracer          tracer.Config `yaml:"tracer"`
}

API is the api service config

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 Config

type Config struct {
	Plugins            map[int]interface{}         `ymal:"plugins"`
	Network            p2p.Config                  `yaml:"network"`
	Chain              blockchain.Config           `yaml:"chain"`
	ActPool            actpool.Config              `yaml:"actPool"`
	Consensus          Consensus                   `yaml:"consensus"`
	DardanellesUpgrade DardanellesUpgrade          `yaml:"dardanellesUpgrade"`
	BlockSync          BlockSync                   `yaml:"blockSync"`
	Dispatcher         dispatcher.Config           `yaml:"dispatcher"`
	API                API                         `yaml:"api"`
	System             System                      `yaml:"system"`
	DB                 db.Config                   `yaml:"db"`
	Indexer            blockindex.Config           `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

func New(configPaths []string, _plugins []string, validates ...Validate) (Config, error)

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 NewSub added in v0.4.0

func NewSub(configPaths []string, validates ...Validate) (Config, error)

NewSub create config for sub chain.

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 DardanellesUpgrade added in v1.2.1

type DardanellesUpgrade struct {
	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"`
	BlockInterval                time.Duration `yaml:"blockInterval"`
	Delay                        time.Duration `yaml:"delay"`
}

DardanellesUpgrade is the config for dardanelles upgrade

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 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

type Validate added in v0.3.0

type Validate func(Config) error

Validate is the interface of validating the config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL