config

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ELAAssetID represents the asset ID of ELA coin.
	ELAAssetID = elaAsset.Hash()

	// DestructionAddress indicates the "ELANULLXXXXXXXXXXXXXXXXXXXXXYvs3rr"
	// destruction address.
	DestructionAddress = common.Uint168{
		0x21, 0x20, 0xfe, 0xe5, 0xd7, 0xeb, 0x3e,
		0x5c, 0x7d, 0x31, 0x97, 0xfe, 0xcf, 0x6c,
		0x0d, 0xe3, 0x0f, 0x88, 0x9a, 0xce, 0xf7,
	}
)

These variables are the chain consensus parameters for each default network.

View Source
var DefaultParams = Params{
	Magic:       2017001,
	DefaultPort: 20338,

	DNSSeeds: []string{
		"node-mainnet-005.elastos.org:20338",
		"node-mainnet-010.elastos.org:20338",
		"node-mainnet-015.elastos.org:20338",
		"node-mainnet-020.elastos.org:20338",
		"node-mainnet-025.elastos.org:20338",
	},

	Foundation:   mainNetFoundation,
	CRCAddress:   mainNetCRCAddress,
	GenesisBlock: GenesisBlock(&mainNetFoundation),

	DPoSMagic:       2019000,
	DPoSDefaultPort: 20339,
	OriginArbiters: []string{
		"0248df6705a909432be041e0baa25b8f648741018f70d1911f2ed28778db4b8fe4",
		"02771faf0f4d4235744b30972d5f2c470993920846c761e4d08889ecfdc061cddf",
		"0342196610e57d75ba3afa26e030092020aec56822104e465cba1d8f69f8d83c8e",
		"02fa3e0d14e0e93ca41c3c0f008679e417cf2adb6375dd4bbbee9ed8e8db606a56",
		"03ab3ecd1148b018d480224520917c6c3663a3631f198e3b25cf4c9c76786b7850",
	},
	CRCArbiters: []string{
		"02089d7e878171240ce0e3633d3ddc8b1128bc221f6b5f0d1551caa717c7493062",
		"0268214956b8421c0621d62cf2f0b20a02c2dc8c2cc89528aff9bd43b45ed34b9f",
		"03cce325c55057d2c8e3fb03fb5871794e73b85821e8d0f96a7e4510b4a922fad5",
		"02661637ae97c3af0580e1954ee80a7323973b256ca862cfcf01b4a18432670db4",
		"027d816821705e425415eb64a9704f25b4cd7eaca79616b0881fc92ac44ff8a46b",
		"02d4a8f5016ae22b1acdf8a2d72f6eb712932213804efd2ce30ca8d0b9b4295ac5",
		"029a4d8e4c99a1199f67a25d79724e14f8e6992a0c8b8acf102682bd8f500ce0c1",
		"02871b650700137defc5d34a11e56a4187f43e74bb078e147dd4048b8f3c81209f",
		"02fc66cba365f9957bcb2030e89a57fb3019c57ea057978756c1d46d40dfdd4df0",
		"03e3fe6124a4ea269224f5f43552250d627b4133cfd49d1f9e0283d0cd2fd209bc",
		"02b95b000f087a97e988c24331bf6769b4a75e4b7d5d2a38105092a3aa841be33b",
		"02a0aa9eac0e168f3474c2a0d04e50130833905740a5270e8a44d6c6e85cf6d98c",
	},
	PowLimit:                    powLimit,
	PowLimitBits:                0x1f0008ff,
	TargetTimespan:              24 * time.Hour,
	TargetTimePerBlock:          2 * time.Minute,
	AdjustmentFactor:            4,
	RewardPerBlock:              rewardPerBlock(2 * time.Minute),
	CoinbaseMaturity:            100,
	MinTransactionFee:           100,
	MinCrossChainTxFee:          10000,
	CheckAddressHeight:          88812,
	VoteStartHeight:             290000,
	CRCOnlyDPOSHeight:           343400,
	PublicDPOSHeight:            402680,
	EnableActivateIllegalHeight: 439000,
	CRVotingStartHeight:         537670,
	CRCommitteeStartHeight:      2000000,
	CheckRewardHeight:           436812,
	VoteStatisticsHeight:        512881,
	RegisterCRByDIDHeight:       598000,
	ToleranceDuration:           5 * time.Second,
	MaxInactiveRounds:           720 * 2,
	InactivePenalty:             0,
	EmergencyInactivePenalty:    0,
	GeneralArbiters:             24,
	CandidateArbiters:           72,
	PreConnectOffset:            360,
	CRMemberCount:               12,
	CRVotingPeriod:              30 * 720,
	CRDutyPeriod:                365 * 720,
	EnableUtxoDB:                true,
	CkpManager: checkpoint.NewManager(&checkpoint.Config{
		EnableHistory:      false,
		HistoryStartHeight: uint32(0),
	}),
}

DefaultParams defines the default network parameters.

Functions

func GenesisBlock added in v0.3.0

func GenesisBlock(foundation *common.Uint168) *types.Block

GenesisBlock creates a genesis block by the specified foundation address. The genesis block goes different because the foundation address in each network is different.

Types

type CRConfiguration added in v0.4.0

type CRConfiguration struct {
	MemberCount           uint32 `json:"MemberCount"`
	VotingPeriod          uint32 `json:"VotingPeriod"`
	DutyPeriod            uint32 `json:"DutyPeriod"`
	RegisterCRByDIDHeight uint32 `json:"RegisterCRByDIDHeight"`
}

type Configuration

type Configuration struct {
	ActiveNet                   string            `json:"ActiveNet"`
	Magic                       uint32            `json:"Magic"`
	DNSSeeds                    []string          `json:"DNSSeeds"`
	DisableDNS                  bool              `json:"DisableDNS"`
	PermanentPeers              []string          `json:"PermanentPeers"`
	HttpInfoPort                uint16            `json:"HttpInfoPort"`
	HttpInfoStart               bool              `json:"HttpInfoStart"`
	HttpRestPort                int               `json:"HttpRestPort"`
	HttpRestStart               bool              `json:"HttpRestStart"`
	HttpWsPort                  int               `json:"HttpWsPort"`
	HttpWsStart                 bool              `json:"HttpWsStart"`
	HttpJsonPort                int               `json:"HttpJsonPort"`
	EnableRPC                   bool              `json:"EnableRPC"`
	NodePort                    uint16            `json:"NodePort"`
	PrintLevel                  elalog.Level      `json:"PrintLevel"`
	MaxLogsSize                 int64             `json:"MaxLogsSize"`
	MaxPerLogSize               int64             `json:"MaxPerLogSize"`
	RestCertPath                string            `json:"RestCertPath"`
	RestKeyPath                 string            `json:"RestKeyPath"`
	MinCrossChainTxFee          common.Fixed64    `json:"MinCrossChainTxFee"`
	FoundationAddress           string            `json:"FoundationAddress"`
	CRCAddress                  string            `json:"CRCAddress"`
	PowConfiguration            PowConfiguration  `json:"PowConfiguration"`
	RpcConfiguration            RpcConfiguration  `json:"RpcConfiguration"`
	DPoSConfiguration           DPoSConfiguration `json:"DPoSConfiguration"`
	CRConfiguration             CRConfiguration   `json:"CRConfiguration"`
	CheckAddressHeight          uint32            `json:"CheckAddressHeight"`
	VoteStartHeight             uint32            `json:"VoteStartHeight"`
	CRCOnlyDPOSHeight           uint32            `json:"CRCOnlyDPOSHeight"`
	PublicDPOSHeight            uint32            `json:"PublicDPOSHeight"`
	EnableActivateIllegalHeight uint32            `json:"EnableActivateIllegalHeight"`
	CRVotingStartHeight         uint32            `json:"CRVotingStartHeight"`
	CRCommitteeStartHeight      uint32            `json:"CRCommitteeStartHeight"`
	CheckRewardHeight           uint32            `json:"CheckRewardHeight"`
	VoteStatisticsHeight        uint32            `json:"VoteStatisticsHeight"`
	ProfilePort                 uint32            `json:"ProfilePort"`
	MaxBlockSize                uint32            `json:"MaxBlockSize"`
	EnableHistory               bool              `json:"EnableHistory"`
	HistoryStartHeight          uint32            `json:"HistoryStartHeight"`
	EnableUtxoDB                bool              `json:"EnableUtxoDB"`
}

Configuration defines the configurable parameters to run a ELA node.

var (
	Parameters *Configuration
)

type DPoSConfiguration added in v0.3.2

type DPoSConfiguration struct {
	EnableArbiter            bool           `json:"EnableArbiter"`
	Magic                    uint32         `json:"Magic"`
	IPAddress                string         `json:"IPAddress"`
	DPoSPort                 uint16         `json:"DPoSPort"`
	SignTolerance            time.Duration  `json:"SignTolerance"`
	OriginArbiters           []string       `json:"OriginArbiters"`
	CRCArbiters              []string       `json:"CRCArbiters"`
	NormalArbitratorsCount   int            `json:"NormalArbitratorsCount"`
	CandidatesCount          int            `json:"CandidatesCount"`
	EmergencyInactivePenalty common.Fixed64 `json:"EmergencyInactivePenalty"`
	MaxInactiveRounds        uint32         `json:"MaxInactiveRounds"`
	InactivePenalty          common.Fixed64 `json:"InactivePenalty"`
	PreConnectOffset         uint32         `json:"PreConnectOffset"`
}

DPoSConfiguration defines the DPoS consensus parameters.

type Params added in v0.3.0

type Params struct {
	// Magic defines the magic number of the peer-to-peer network.
	Magic uint32

	// DefaultPort defines the default peer-to-peer port for the network.
	DefaultPort uint16

	// DNSSeeds defines a list of DNS seeds for the network to discover peers.
	DNSSeeds []string

	// The interface/port to listen for connections.
	ListenAddrs []string

	// PermanentPeers defines peers seeds for node to initialize p2p connection.
	PermanentPeers []string

	// Foundation defines the foundation address which receiving mining
	// rewards.
	Foundation common.Uint168

	// CRCAddress defines the CRC address which receiving mining rewards.
	CRCAddress common.Uint168

	// GenesisBlock defines the first block of the chain.
	GenesisBlock *types.Block

	// PowLimit defines the highest allowed proof of work value for a block
	// as a uint256.
	PowLimit *big.Int

	// PowLimitBits defines the highest allowed proof of work value for a
	// block in compact form.
	PowLimitBits uint32

	// TargetTimespan is the desired amount of time that should elapse
	// before the block difficulty requirement is examined to determine how
	// it should be changed in order to maintain the desired block
	// generation rate.
	TargetTimespan time.Duration

	// TargetTimePerBlock is the desired amount of time to generate each
	// block.
	TargetTimePerBlock time.Duration

	// AdjustmentFactor is the adjustment factor used to limit the minimum
	// and maximum amount of adjustment that can occur between difficulty
	// retargets.
	AdjustmentFactor int64

	// RewardPerBlock is the reward amount per block.
	RewardPerBlock common.Fixed64

	// CoinbaseMaturity is the number of blocks required before newly mined
	// coins (coinbase transactions) can be spent.
	CoinbaseMaturity uint32

	// Disable transaction filter supports, include bloom filter tx type filter
	// etc.
	DisableTxFilters bool

	// MinTransactionFee defines the minimum fee of a transaction.
	MinTransactionFee common.Fixed64

	// MinCrossChainTxFee defines the min fee of cross chain transaction
	MinCrossChainTxFee common.Fixed64

	// OriginArbiters defines the original arbiters producing the block.
	OriginArbiters []string

	// CheckAddressHeight defines the height begin to check output hash.
	CheckAddressHeight uint32

	// VoteStartHeight indicates the height of starting register producer and
	// vote related.
	VoteStartHeight uint32

	// CRCOnlyDPOSHeight (H1) indicates the height of DPOS consensus begins with
	// only CRC producers participate in producing blocks.
	CRCOnlyDPOSHeight uint32

	// PublicDPOSHeight (H2) indicates the height when public registered and
	// elected producers participate in DPOS consensus.
	PublicDPOSHeight uint32

	// CRVotingStartHeight defines the height of CR voting started.
	CRVotingStartHeight uint32

	// CRCommitteeStartHeight defines the height of CR Committee started.
	CRCommitteeStartHeight uint32

	// PublicDPOSHeight defines the start height to enable activate illegal
	// producer though activate tx.
	EnableActivateIllegalHeight uint32

	// CheckRewardHeight defines the height to check reward in coin base
	// with new check function.
	CheckRewardHeight uint32

	// VoteStatisticsHeight defines the height to deal with block with vote
	// statistics error.
	VoteStatisticsHeight uint32

	// RegisterCRByDIDHeight defines the height to support register and update
	// CR by CID and DID.
	RegisterCRByDIDHeight uint32

	// CRCArbiters defines the fixed CRC arbiters producing the block.
	CRCArbiters []string

	// DPoSMagic defines the magic number used in the DPoS network.
	DPoSMagic uint32

	// DPoSIPAddress defines the IP address for the DPoS network.
	DPoSIPAddress string

	// DPoSDefaultPort defines the default port for the DPoS network.
	DPoSDefaultPort uint16

	// PreConnectOffset defines the offset blocks to pre-connect to the block
	// producers.
	PreConnectOffset uint32

	// GeneralArbiters defines the number of general(no-CRC) arbiters.
	GeneralArbiters int

	// CandidateArbiters defines the number of needed candidate arbiters.
	CandidateArbiters int

	// ToleranceDuration defines the tolerance duration of the DPoS consensus.
	ToleranceDuration time.Duration

	// MaxInactiveRounds defines the maximum inactive rounds before producer
	// takes penalty.
	MaxInactiveRounds uint32

	// InactivePenalty defines the penalty amount the producer takes.
	InactivePenalty common.Fixed64

	// EmergencyInactivePenalty defines the penalty amount the emergency
	// producer takes.
	EmergencyInactivePenalty common.Fixed64

	// CRMemberCount defines the number of CR committee members
	CRMemberCount uint32

	// CRVotingPeriod defines the duration of voting period which measured by
	// block height
	CRVotingPeriod uint32

	// CRDutyPeriod defines the duration of a normal duty period which
	// measured by block height
	CRDutyPeriod uint32

	// CkpManager holds checkpoints save automatically.
	CkpManager *checkpoint.Manager

	// EnableUtxoDB indicate whether to enable utxo database.
	EnableUtxoDB bool
}

func (*Params) InstantBlock added in v0.3.0

func (p *Params) InstantBlock() *Params

InstantBlock returns the network parameters for generate instant block.

func (*Params) RegNet added in v0.3.0

func (p *Params) RegNet() *Params

RegNet returns the network parameters for the test network.

func (*Params) TestNet added in v0.3.0

func (p *Params) TestNet() *Params

TestNet returns the network parameters for the test network.

type PowConfiguration

type PowConfiguration struct {
	PayToAddr    string `json:"PayToAddr"`
	AutoMining   bool   `json:"AutoMining"`
	MinerInfo    string `json:"MinerInfo"`
	MinTxFee     int    `json:"MinTxFee"`
	InstantBlock bool   `json:"InstantBlock"`
}

PowConfiguration defines the Proof-of-Work parameters.

type RpcConfiguration added in v0.2.2

type RpcConfiguration struct {
	User        string   `json:"User"`
	Pass        string   `json:"Pass"`
	WhiteIPList []string `json:"WhiteIPList"`
}

RpcConfiguration defines the JSON-RPC authenticate parameters.

Jump to

Keyboard shortcuts

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