config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PoWNone is the default empty consensus type specifying no shard.
	PoWNone = "NONE"
	// PoWEthash is the consensus type running ethash algorithm.
	PoWEthash = "POW_ETHASH"
	// PoWDoubleSha256 is the consensus type running double-sha256 algorithm.
	PoWDoubleSha256 = "POW_DOUBLESHA256"
	// PoWSimulate is the simulated consensus type by simply sleeping.
	PoWSimulate = "POW_SIMULATE"
	// PoWQkchash is the consensus type running qkchash algorithm.
	PoWQkchash = "POW_QKCHASH"

	GrpcPort uint16 = 38591
	GrpcHost        = "127.0.0.1"

	HeartbeatInterval = time.Duration(4 * time.Second)
)

Variables

View Source
var (
	QuarkashToJiaozi = big.NewInt(1000000000000000000)
	DefaultNumSlaves = 4
)

Functions

func LoadtestAccounts

func LoadtestAccounts(genesisDir string) []*account.Account

func UpdateGenesisAlloc

func UpdateGenesisAlloc(cluserConfig *ClusterConfig) error

Update ShardConfig.GENESIS.ALLOC

Types

type ChainConfig

type ChainConfig struct {
	ChainID           uint32 `json:"CHAIN_ID"`
	ShardSize         uint32 `json:"SHARD_SIZE"`
	DefaultChainToken string `json:"-"`
	ConsensusType     string `json:"CONSENSUS_TYPE"`

	// Only set when CONSENSUS_TYPE is not NONE
	ConsensusConfig *POWConfig    `json:"CONSENSUS_CONFIG"`
	Genesis         *ShardGenesis `json:"GENESIS"`

	CoinbaseAddress account.Address `json:"-"`
	CoinbaseAmount  *big.Int        `json:"COINBASE_AMOUNT"`

	// Gas Limit
	GasLimitEmaDenominator             uint32      `json:"GAS_LIMIT_EMA_DENOMINATOR"`
	GasLimitAdjustmentFactor           uint32      `json:"GAS_LIMIT_ADJUSTMENT_FACTOR"`
	GasLimitMinimum                    uint64      `json:"GAS_LIMIT_MINIMUM"`
	GasLimitMaximum                    uint64      `json:"GAS_LIMIT_MAXIMUM"`
	GasLimitUsageAdjustmentNumerator   uint32      `json:"GAS_LIMIT_USAGE_ADJUSTMENT_NUMERATOR"`
	GasLimitUsageAdjustmentDenominator uint32      `json:"GAS_LIMIT_USAGE_ADJUSTMENT_DENOMINATOR"`
	DifficultyAdjustmentCutoffTime     uint32      `json:"DIFFICULTY_ADJUSTMENT_CUTOFF_TIME"`
	DifficultyAdjustmentFactor         uint32      `json:"DIFFICULTY_ADJUSTMENT_FACTOR"`
	ExtraShardBlocksInRootBlock        uint32      `json:"EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK"`
	PoswConfig                         *POSWConfig `json:"POSW_CONFIG"`
}

func NewChainConfig

func NewChainConfig() *ChainConfig

func (*ChainConfig) MarshalJSON

func (c *ChainConfig) MarshalJSON() ([]byte, error)

func (*ChainConfig) UnmarshalJSON

func (c *ChainConfig) UnmarshalJSON(input []byte) error

type ChainConfigAlias

type ChainConfigAlias ChainConfig

type ClusterConfig

type ClusterConfig struct {
	P2PPort                  uint16            `json:"P2P_PORT"`
	JSONRPCPort              uint16            `json:"JSON_RPC_PORT"`
	PrivateJSONRPCPort       uint16            `json:"PRIVATE_JSON_RPC_PORT"`
	EnableTransactionHistory bool              `json:"ENABLE_TRANSACTION_HISTORY"`
	DbPathRoot               string            `json:"DB_PATH_ROOT"`
	LogLevel                 string            `json:"LOG_LEVEL"`
	StartSimulatedMining     bool              `json:"START_SIMULATED_MINING"`
	Clean                    bool              `json:"CLEAN"`
	GenesisDir               string            `json:"GENESIS_DIR"`
	Quarkchain               *QuarkChainConfig `json:"QUARKCHAIN"`
	Master                   *MasterConfig     `json:"MASTER"`
	SlaveList                []*SlaveConfig    `json:"SLAVE_LIST"`
	SimpleNetwork            *SimpleNetwork    `json:"SIMPLE_NETWORK,omitempty"`
	P2P                      *P2PConfig        `json:"P2P,omitempty"`
	Monitoring               *MonitoringConfig `json:"MONITORING"`
}

func NewClusterConfig

func NewClusterConfig() *ClusterConfig

func (*ClusterConfig) GetSlaveConfig

func (c *ClusterConfig) GetSlaveConfig(id string) (*SlaveConfig, error)

type GenesisAddress

type GenesisAddress struct {
	Address string `json:"address"`
	PrivKey string `json:"key"`
}

type MasterConfig

type MasterConfig struct {
	// default 1.0
	MasterToSlaveConnectRetryDelay float32 `json:"MASTER_TO_SLAVE_CONNECT_RETRY_DELAY"`
}

func NewMasterConfig

func NewMasterConfig() *MasterConfig

type MonitoringConfig

type MonitoringConfig struct {
	NetworkName      string `json:"NETWORK_NAME"`
	ClusterID        string `json:"CLUSTER_ID"`
	KafkaRestAddress string `json:"KAFKA_REST_ADDRESS"` // REST API endpoint for logging to Kafka, IP[:PORT] format
	MinerTopic       string `json:"MINER_TOPIC"`        // "qkc_miner"
	PropagationTopic string `json:"PROPAGATION_TOPIC"`  // "block_propagation"
	Errors           string `json:"ERRORS"`             // "error"
}

func NewMonitoringConfig

func NewMonitoringConfig() *MonitoringConfig

type NetWorkId

type NetWorkId struct {
	Mainnet        uint32 `json:"MAINNET"`
	TestnetPorsche uint32 `json:"TESTNET_PORSCHE"` // TESTNET_FORD = 2
}

type P2PConfig

type P2PConfig struct {
	// *new p2p module*
	BootNodes        string  `json:"BOOT_NODES"` // comma separated encodes format: encode://PUBKEY@IP:PORT
	PrivKey          string  `json:"PRIV_KEY"`
	MaxPeers         uint64  `json:"MAX_PEERS"`
	UPnP             bool    `json:"UPNP"`
	AllowDialInRatio float32 `json:"ALLOW_DIAL_IN_RATIO"`
	PreferredNodes   string  `json:"PREFERRED_NODES"`
}

TODO move to P2P

func NewP2PConfig

func NewP2PConfig() *P2PConfig

func (*P2PConfig) GetBootNodes

func (s *P2PConfig) GetBootNodes() []string

type POSWConfig

type POSWConfig struct {
	Enabled            bool     `json:"ENABLED"`
	DiffDivider        uint32   `json:"DIFF_DIVIDER"`
	WindowSize         uint32   `json:"WINDOW_SIZE"`
	TotalStakePerBlock *big.Int `json:"TOTAL_STAKE_PER_BLOCK"`
}

func NewPOSWConfig

func NewPOSWConfig() *POSWConfig

type POWConfig

type POWConfig struct {
	TargetBlockTime uint32 `json:"TARGET_BLOCK_TIME"`
	RemoteMine      bool   `json:"REMOTE_MINE"`
}

func NewPOWConfig

func NewPOWConfig() *POWConfig

type QuarkChainConfig

type QuarkChainConfig struct {
	ChainSize                         uint32      `json:"CHAIN_SIZE"`
	MaxNeighbors                      uint32      `json:"MAX_NEIGHBORS"`
	NetworkID                         uint32      `json:"NETWORK_ID"`
	TransactionQueueSizeLimitPerShard uint64      `json:"TRANSACTION_QUEUE_SIZE_LIMIT_PER_SHARD"`
	BlockExtraDataSizeLimit           uint32      `json:"BLOCK_EXTRA_DATA_SIZE_LIMIT"`
	GuardianPublicKey                 string      `json:"GUARDIAN_PUBLIC_KEY"`
	GuardianPrivateKey                []byte      `json:"GUARDIAN_PRIVATE_KEY"`
	P2PProtocolVersion                uint32      `json:"P2P_PROTOCOL_VERSION"`
	P2PCommandSizeLimit               uint32      `json:"P2P_COMMAND_SIZE_LIMIT"`
	SkipRootDifficultyCheck           bool        `json:"SKIP_ROOT_DIFFICULTY_CHECK"`
	SkipRootCoinbaseCheck             bool        `json:"SKIP_ROOT_COINBASE_CHECK"`
	SkipMinorDifficultyCheck          bool        `json:"SKIP_MINOR_DIFFICULTY_CHECK"`
	GenesisToken                      string      `json:"GENESIS_TOKEN"`
	Root                              *RootConfig `json:"ROOT"`

	Chains        map[uint32]*ChainConfig `json:"-"`
	RewardTaxRate *big.Rat                `json:"-"`
	// contains filtered or unexported fields
}

func NewQuarkChainConfig

func NewQuarkChainConfig() *QuarkChainConfig

func (*QuarkChainConfig) GasLimit

func (q *QuarkChainConfig) GasLimit(fullShardID uint32) (*big.Int, error)

func (*QuarkChainConfig) GetFullShardIdByFullShardKey

func (q *QuarkChainConfig) GetFullShardIdByFullShardKey(fullShardKey uint32) (uint32, error)

func (*QuarkChainConfig) GetGenesisRootHeight

func (q *QuarkChainConfig) GetGenesisRootHeight(fullShardId uint32) uint32

Return the root block height at which the shard shall be created

func (*QuarkChainConfig) GetGenesisShardIds

func (q *QuarkChainConfig) GetGenesisShardIds() []uint32

GetGenesisShardIds returns a list of ids for shards that have GENESIS.

func (*QuarkChainConfig) GetInitializedShardIdsBeforeRootHeight

func (q *QuarkChainConfig) GetInitializedShardIdsBeforeRootHeight(rootHeight uint32) []uint32

Return a list of ids of the shards that have been initialized before a certain root height

func (*QuarkChainConfig) GetShardConfigByFullShardID

func (q *QuarkChainConfig) GetShardConfigByFullShardID(fullShardID uint32) *ShardConfig

func (*QuarkChainConfig) GetShardSizeByChainId

func (q *QuarkChainConfig) GetShardSizeByChainId(ID uint32) (uint32, error)

func (*QuarkChainConfig) MarshalJSON

func (q *QuarkChainConfig) MarshalJSON() ([]byte, error)

func (*QuarkChainConfig) SetShardsAndValidate

func (q *QuarkChainConfig) SetShardsAndValidate(shards map[uint32]*ShardConfig)

func (*QuarkChainConfig) UnmarshalJSON

func (q *QuarkChainConfig) UnmarshalJSON(input []byte) error

func (*QuarkChainConfig) Update

func (q *QuarkChainConfig) Update(chainSize, shardSizePerChain, rootBlockTime, minorBlockTime uint32)

type QuarkChainConfigAlias

type QuarkChainConfigAlias QuarkChainConfig

type RootConfig

type RootConfig struct {
	// To ignore super old blocks from peers
	// This means the network will fork permanently after a long partition
	MaxStaleRootBlockHeightDiff    uint64          `json:"MAX_STALE_ROOT_BLOCK_HEIGHT_DIFF"`
	ConsensusType                  string          `json:"CONSENSUS_TYPE"`
	ConsensusConfig                *POWConfig      `json:"CONSENSUS_CONFIG"`
	Genesis                        *RootGenesis    `json:"GENESIS"`
	CoinbaseAddress                account.Address `json:"-"`
	CoinbaseAmount                 *big.Int        `json:"COINBASE_AMOUNT"`
	DifficultyAdjustmentCutoffTime uint32          `json:"DIFFICULTY_ADJUSTMENT_CUTOFF_TIME"`
	DifficultyAdjustmentFactor     uint32          `json:"DIFFICULTY_ADJUSTMENT_FACTOR"`
	GRPCHost                       string          `json:"-"`
	GRPCPort                       uint16          `json:"-"`
}

func NewRootConfig

func NewRootConfig() *RootConfig

func (*RootConfig) MarshalJSON

func (r *RootConfig) MarshalJSON() ([]byte, error)

func (*RootConfig) MaxRootBlocksInMemory

func (r *RootConfig) MaxRootBlocksInMemory() uint64

func (*RootConfig) UnmarshalJSON

func (r *RootConfig) UnmarshalJSON(input []byte) error

type RootConfigAlias

type RootConfigAlias RootConfig

type RootGenesis

type RootGenesis struct {
	Version        uint32 `json:"VERSION"`
	Height         uint32 `json:"HEIGHT"`
	HashPrevBlock  string `json:"HASH_PREV_BLOCK"`
	HashMerkleRoot string `json:"HASH_MERKLE_ROOT"`
	Timestamp      uint64 `json:"TIMESTAMP"`
	Difficulty     uint64 `json:"DIFFICULTY"`
	Nonce          uint32 `json:"NONCE"`
}

func NewRootGenesis

func NewRootGenesis() *RootGenesis

type ShardConfig

type ShardConfig struct {
	ShardID uint32

	*ChainConfig
	// contains filtered or unexported fields
}

func NewShardConfig

func NewShardConfig(chainCfg *ChainConfig) *ShardConfig

func (*ShardConfig) GetFullShardId

func (s *ShardConfig) GetFullShardId() uint32

func (*ShardConfig) GetRootConfig

func (s *ShardConfig) GetRootConfig() *RootConfig

func (*ShardConfig) MaxBlocksPerShardInOneRootBlock

func (s *ShardConfig) MaxBlocksPerShardInOneRootBlock() uint32

func (*ShardConfig) MaxMinorBlocksInMemory

func (s *ShardConfig) MaxMinorBlocksInMemory() uint64

func (*ShardConfig) MaxStaleMinorBlockHeightDiff

func (s *ShardConfig) MaxStaleMinorBlockHeightDiff() uint64

func (*ShardConfig) SetRootConfig

func (s *ShardConfig) SetRootConfig(value *RootConfig)

type ShardGenesis

type ShardGenesis struct {
	RootHeight         uint32                       `json:"ROOT_HEIGHT"`
	Version            uint32                       `json:"VERSION"`
	Height             uint64                       `json:"HEIGHT"`
	HashPrevMinorBlock string                       `json:"HASH_PREV_MINOR_BLOCK"`
	HashMerkleRoot     string                       `json:"HASH_MERKLE_ROOT"`
	ExtraData          []byte                       `json:"-"`
	Timestamp          uint64                       `json:"TIMESTAMP"`
	Difficulty         uint64                       `json:"DIFFICULTY"`
	GasLimit           uint64                       `json:"GAS_LIMIT"`
	Nonce              uint32                       `json:"NONCE"`
	Alloc              map[account.Address]*big.Int `json:"-"`
}

func NewShardGenesis

func NewShardGenesis() *ShardGenesis

func (*ShardGenesis) MarshalJSON

func (s *ShardGenesis) MarshalJSON() ([]byte, error)

func (*ShardGenesis) UnmarshalJSON

func (s *ShardGenesis) UnmarshalJSON(input []byte) error

type ShardGenesisAlias

type ShardGenesisAlias ShardGenesis

type SimpleNetwork

type SimpleNetwork struct {
	BootstrapHost string `json:"BOOT_STRAP_HOST"`
	BootstrapPort uint64 `json:"BOOT_STRAP_PORT"`
}

func NewSimpleNetwork

func NewSimpleNetwork() *SimpleNetwork

type SlaveConfig

type SlaveConfig struct {
	IP            string             `json:"HOST"` // DEFAULT_HOST
	Port          uint16             `json:"PORT"` // 38392
	ID            string             `json:"ID"`
	ChainMaskList []*types.ChainMask `json:"-"`
}

func NewDefaultSlaveConfig

func NewDefaultSlaveConfig() *SlaveConfig

func (*SlaveConfig) MarshalJSON

func (s *SlaveConfig) MarshalJSON() ([]byte, error)

func (*SlaveConfig) UnmarshalJSON

func (s *SlaveConfig) UnmarshalJSON(input []byte) error

type SlaveConfigAlias

type SlaveConfigAlias SlaveConfig

Jump to

Keyboard shortcuts

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