config

package
v0.0.0-...-6ec8c49 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: GPL-3.0 Imports: 21 Imported by: 76

Documentation

Index

Constants

View Source
const (
	DatadirPrivateKey      = "nodekey"            // Path within the datadir to the node's private key
	DatadirDefaultKeyStore = "keystore"           // Path within the datadir to the keystore
	DatadirStaticNodes     = "static-nodes.json"  // Path within the datadir to the static node list
	DatadirTrustedNodes    = "trusted-nodes.json" // Path within the datadir to the trusted node list
	DatadirNodeDatabase    = "nodes"              // Path within the datadir to store the node infos
)
View Source
const (
	MaximumExtraDataSize  uint64 = 32    // Maximum size extra data may be after Genesis.
	ExpByteGas            uint64 = 10    // Times ceil(log256(exponent)) for the EXP instruction.
	SloadGas              uint64 = 50    // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added.
	CallValueTransferGas  uint64 = 9000  // Paid for CALL when the value transfer is non-zero.
	CallNewAccountGas     uint64 = 25000 // Paid for CALL when the destination address didn't exist prior.
	BeforeTxGas           uint64 = 10    // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. brefore  StageNumberNewPrecompiledContract
	TxGas                 uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions.
	TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions.
	TxDataZeroGas         uint64 = 1     // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. //for testnet
	QuadCoeffDiv          uint64 = 512   // Divisor for the quadratic particle of the memory cost equation.
	SstoreSetGas          uint64 = 20000 // Once per SLOAD operation.
	LogDataGas            uint64 = 8     // Per byte in a LOG* operation's data.
	CallStipend           uint64 = 2300  // Free gas given at beginning of call.

	Sha3Gas          uint64 = 30    // Once per SHA3 operation.
	Sha3WordGas      uint64 = 6     // Once per word of the SHA3 operation's data.
	SstoreResetGas   uint64 = 5000  // Once per SSTORE operation if the zeroness changes from zero.
	SstoreClearGas   uint64 = 5000  // Once per SSTORE operation if the zeroness doesn't change.
	SstoreRefundGas  uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero.
	JumpdestGas      uint64 = 1     // Refunded gas, once per SSTORE operation if the zeroness changes to zero.
	EpochDuration    uint64 = 30000 // Duration between proof-of-work epochs.
	CallGas          uint64 = 40    // Once per CALL operation & message call transaction.
	CreateDataGas    uint64 = 200   //
	CallCreateDepth  uint64 = 1024  // Maximum depth of call/create stack.
	ExpGas           uint64 = 10    // Once per EXP instruction
	LogGas           uint64 = 375   // Per LOG* operation.
	CopyGas          uint64 = 3     //
	StackLimit       uint64 = 1024  // Maximum size of VM stack allowed.
	TierStepGas      uint64 = 0     // Once per operation, for a selection of them.
	LogTopicGas      uint64 = 375   // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
	CreateGas        uint64 = 32000 // Once per CREATE operation & contract-creation transaction.
	Create2Gas       uint64 = 32000 // Once per CREATE2 operation
	SuicideRefundGas uint64 = 24000 // Refunded following a suicide operation.
	MemoryGas        uint64 = 3     // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
	TxDataNonZeroGas uint64 = 1     // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. //for testnet

	MaxCodeSize = 24576 // Maximum bytecode to permit for a contract

	ZSCverifyGas        uint64 = 10000 // zscverify
	EcrecoverGas        uint64 = 3000  // Elliptic curve sender recovery gas price
	Sha256BaseGas       uint64 = 60    // Base price for a SHA256 operation
	Sha256PerWordGas    uint64 = 12    // Per-word price for a SHA256 operation
	Ripemd160BaseGas    uint64 = 600   // Base price for a RIPEMD160 operation
	Ripemd160PerWordGas uint64 = 120   // Per-word price for a RIPEMD160 operation
	IdentityBaseGas     uint64 = 15    // Base price for a data copy operation
	IdentityPerWordGas  uint64 = 3     // Per-work price for a data copy operation
	ModExpQuadCoeffDiv  uint64 = 20    // Divisor for the quadratic particle of the big int modular exponentiation

	Bn256AddGasByzantium             uint64 = 500    // Byzantium gas needed for an elliptic curve addition
	Bn256AddGasIstanbul              uint64 = 150    // Gas needed for an elliptic curve addition
	Bn256ScalarMulGasByzantium       uint64 = 40000  // Byzantium gas needed for an elliptic curve scalar multiplication
	Bn256ScalarMulGasIstanbul        uint64 = 6000   // Gas needed for an elliptic curve scalar multiplication
	Bn256PairingBaseGasByzantium     uint64 = 100000 // Byzantium base price for an elliptic curve pairing check
	Bn256PairingBaseGasIstanbul      uint64 = 45000  // Base price for an elliptic curve pairing check
	Bn256PairingPerPointGasByzantium uint64 = 80000  // Byzantium per-point price for an elliptic curve pairing check
	Bn256PairingPerPointGasIstanbul  uint64 = 34000  // Per-point price for an elliptic curve pairing check
)
View Source
const (
	// These are the multipliers for hpber denominations.
	// Example: To get the wei value of an amount in 'douglas', use
	//
	//    new(big.Int).Mul(value, big.NewInt(params.Douglas))
	//
	Wei      = 1
	Ada      = 1e3
	Babbage  = 1e6
	Shannon  = 1e9
	Szabo    = 1e12
	Finney   = 1e15
	Hpber    = 1e18
	Einstein = 1e21
	Douglas  = 1e42
)
View Source
const (
	DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server
	DefaultHTTPPort = 8545        // Default TCP port for the HTTP RPC server
	DefaultWSHost   = "localhost" // Default host interface for the websocket RPC server
	DefaultWSPort   = 8546        // Default TCP port for the websocket RPC server
)
View Source
const (
	MaxGasLimit uint64 = 0x7fffffffffffffff // Maximum the gas limit (2^63-1).

	Keccak256Gas     uint64 = 30 // Once per KECCAK256 operation.
	Keccak256WordGas uint64 = 6  // Once per word of the KECCAK256 operation's data.

	NetSstoreNoopGas  uint64 = 200   // Once per SSTORE operation if the value doesn't change.
	NetSstoreInitGas  uint64 = 20000 // Once per SSTORE operation from clean zero.
	NetSstoreCleanGas uint64 = 5000  // Once per SSTORE operation from clean non-zero.
	NetSstoreDirtyGas uint64 = 200   // Once per SSTORE operation from dirty.

	NetSstoreClearRefund      uint64 = 15000 // Once per SSTORE operation for clearing an originally existing storage slot
	NetSstoreResetRefund      uint64 = 4800  // Once per SSTORE operation for resetting to the original non-zero value
	NetSstoreResetClearRefund uint64 = 19800 // Once per SSTORE operation for resetting to the original zero value

	SstoreSentryGasEIP2200            uint64 = 2300  // Minimum gas required to be present for an SSTORE call, not consumed
	SstoreSetGasEIP2200               uint64 = 20000 // Once per SSTORE operation from clean zero to non-zero
	SstoreResetGasEIP2200             uint64 = 5000  // Once per SSTORE operation from clean non-zero to something else
	SstoreClearsScheduleRefundEIP2200 uint64 = 15000 // Once per SSTORE operation for clearing an originally existing storage slot

	ColdAccountAccessCostEIP2929 = uint64(2600) // COLD_ACCOUNT_ACCESS_COST
	ColdSloadCostEIP2929         = uint64(2100) // COLD_SLOAD_COST
	WarmStorageReadCostEIP2929   = uint64(100)  // WARM_STORAGE_READ_COST

	// In EIP-2200: SstoreResetGas was 5000.
	// In EIP-2929: SstoreResetGas was changed to '5000 - COLD_SLOAD_COST'.
	// In EIP-3529: SSTORE_CLEARS_SCHEDULE is defined as SSTORE_RESET_GAS + ACCESS_LIST_STORAGE_KEY_COST
	// Which becomes: 5000 - 2100 + 1900 = 4800
	SstoreClearsScheduleRefundEIP3529 uint64 = SstoreResetGasEIP2200 - ColdSloadCostEIP2929 + TxAccessListStorageKeyGas

	SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct operation.

	TxDataNonZeroGasFrontier  uint64 = 68   // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
	TxDataNonZeroGasEIP2028   uint64 = 16   // Per byte of non zero data attached to a transaction after EIP 2028 (part in Istanbul)
	TxAccessListAddressGas    uint64 = 2400 // Per address specified in EIP 2930 access list
	TxAccessListStorageKeyGas uint64 = 1900 // Per storage key specified in EIP 2930 access list

	// These have been changed during the course of the chain
	CallGasFrontier              uint64 = 40  // Once per CALL operation & message call transaction.
	CallGasEIP150                uint64 = 700 // Static portion of gas for CALL-derivates after EIP 150 (Tangerine)
	BalanceGasFrontier           uint64 = 20  // The cost of a BALANCE operation
	BalanceGasEIP150             uint64 = 400 // The cost of a BALANCE operation after Tangerine
	BalanceGasEIP1884            uint64 = 700 // The cost of a BALANCE operation after EIP 1884 (part of Istanbul)
	ExtcodeSizeGasFrontier       uint64 = 20  // Cost of EXTCODESIZE before EIP 150 (Tangerine)
	ExtcodeSizeGasEIP150         uint64 = 700 // Cost of EXTCODESIZE after EIP 150 (Tangerine)
	SloadGasFrontier             uint64 = 50
	SloadGasEIP150               uint64 = 200
	SloadGasEIP1884              uint64 = 800  // Cost of SLOAD after EIP 1884 (part of Istanbul)
	SloadGasEIP2200              uint64 = 800  // Cost of SLOAD after EIP 2200 (part of Istanbul)
	ExtcodeHashGasConstantinople uint64 = 400  // Cost of EXTCODEHASH (introduced in Constantinople)
	ExtcodeHashGasEIP1884        uint64 = 700  // Cost of EXTCODEHASH after EIP 1884 (part in Istanbul)
	SelfdestructGasEIP150        uint64 = 5000 // Cost of SELFDESTRUCT post EIP 150 (Tangerine)

	// EXP has a dynamic portion depending on the size of the exponent
	ExpByteFrontier uint64 = 10 // was set to 10 in Frontier
	ExpByteEIP158   uint64 = 50 // was raised to 50 during Eip158 (Spurious Dragon)

	// Extcodecopy has a dynamic AND a static cost. This represents only the
	// static portion of the gas. It was changed during EIP 150 (Tangerine)
	ExtcodeCopyBaseFrontier uint64 = 20
	ExtcodeCopyBaseEIP150   uint64 = 700

	// CreateBySelfdestructGas is used when the refunded account is one that does
	// not exist. This logic is similar to call.
	// Introduced in Tangerine Whistle (Eip 150)
	CreateBySelfdestructGas uint64 = 25000

	BaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
	ElasticityMultiplier     = 2 // Bounds the maximum gas limit an EIP-1559 block may have.

	Bls12381G1AddGas          uint64 = 600    // Price for BLS12-381 elliptic curve G1 point addition
	Bls12381G1MulGas          uint64 = 12000  // Price for BLS12-381 elliptic curve G1 point scalar multiplication
	Bls12381G2AddGas          uint64 = 4500   // Price for BLS12-381 elliptic curve G2 point addition
	Bls12381G2MulGas          uint64 = 55000  // Price for BLS12-381 elliptic curve G2 point scalar multiplication
	Bls12381PairingBaseGas    uint64 = 115000 // Base gas price for BLS12-381 elliptic curve pairing check
	Bls12381PairingPerPairGas uint64 = 23000  // Per-point pair gas price for BLS12-381 elliptic curve pairing check
	Bls12381MapG1Gas          uint64 = 5500   // Gas price for BLS12-381 mapping field element to G1 operation
	Bls12381MapG2Gas          uint64 = 110000 // Gas price for BLS12-381 mapping field element to G2 operation

	// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
	// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
	RefundQuotient        uint64 = 2
	RefundQuotientEIP3529 uint64 = 5
)
View Source
const (
	VersionMajor = 1        // Major version component of the current release
	VersionHardv = 0        // Hardware version component of the current release
	VersionMinor = 9        // Minor version component of the current release
	VersionPatch = 3        // Patch version component of the current release
	VersionMeta  = "stable" // Version metadata to append to the version string
)
View Source
const (
	// BloomBitsBlocks is the number of blocks a single bloom bit section vector
	// contains.
	BloomBitsBlocks uint64 = 4096
)
View Source
const DAOVersion uint64 = 0x0005 // use a version to seperate network. 2021/5/5

!!!every change of version should sub VersionID one number!!!

View Source
const DAOVersion2 uint64 = 0x0007 // use a version to seperate network. 2021/10/21
View Source
const DAOVersion3 uint64 = 0x0008 // use a version to seperate network. 2021/10/21
View Source
const HandShakeNoHIDVersion uint64 = 0x0006 // prepare for handshake not check hid.
View Source
const HandShakeVersion uint64 = DAOVersion3 // current handshake proto version.
View Source
const (
	ProtocolV111 uint = 100 // match up protocol versions and messages versions
)

hpb protocol version control

View Source
const VersionID uint64 = 0x0006 // not used.

Variables

View Source
var (
	MainnetGenesisHash       = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
	TestnetGenesisHash       = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
	StageNumberEvmV2   int64 = 14633000
)
View Source
var (
	MaxHashFetch    = 512 // Amount of hashes to be fetched per retrieval request
	MaxBlockFetch   = 128 // Amount of blocks to be fetched per retrieval request
	MaxHeaderFetch  = 192 // Amount of block headers to be fetched per retrieval request
	MaxSkeletonSize = 128 // Number of header fetches to need for a skeleton assembly
	MaxBodyFetch    = 128 // Amount of block bodies to be fetched per retrieval request
	MaxReceiptFetch = 256 // Amount of transaction receipts to allow fetching per request
	MaxStateFetch   = 384 // Amount of node state values to allow fetching per request

	MaxForkAncestry = 3 * EpochDuration // Maximum chain reorganisation

)

syncer parameter

View Source
var (
	GasLimitBoundDivisor   = big.NewInt(1024)      // The bound divisor of the gas limit, used in update calculations.
	MinGasLimit            = big.NewInt(5000)      // Minimum the gas limit may ever be.
	GenesisGasLimit        = big.NewInt(100000000) // Gas limit of the Genesis block. //for testnet
	NormalGasLimit         = big.NewInt(50000000)
	TargetGasLimit         = new(big.Int).Set(NormalGasLimit) // The artificial target
	DifficultyBoundDivisor = big.NewInt(2048)                 // The bound divisor of the difficulty, used in the update calculations.
	GenesisDifficulty      = big.NewInt(131072)               // Difficulty of the Genesis block.
	MinimumDifficulty      = big.NewInt(131072)               // The minimum that the difficulty may ever be.
	DurationLimit          = big.NewInt(13)                   // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.

	InitialBaseFee = big.NewInt(1000000000)
)
View Source
var Bls12381MultiExpDiscountTable = [128]uint64{} /* 128 elements not displayed */

Gas discount table for BLS12-381 G1 and G2 multi exponentiation operations

View Source
var (
	CompatibleChainId = big.NewInt(1)
)

Compatible ChainID, different with current chainId

View Source
var DefaultBlockChainConfig = ChainConfig{
	ChainId:             MainnetChainConfig.ChainId,
	Prometheus:          &DefaultPrometheusConfig,
	HomesteadBlock:      MainnetChainConfig.HomesteadBlock,
	EIP150Block:         MainnetChainConfig.EIP150Block,
	EIP155Block:         MainnetChainConfig.EIP155Block,
	EIP158Block:         MainnetChainConfig.EIP158Block,
	ByzantiumBlock:      MainnetChainConfig.ByzantiumBlock,
	ConstantinopleBlock: MainnetChainConfig.ConstantinopleBlock,
	PetersburgBlock:     MainnetChainConfig.PetersburgBlock,
	IstanbulBlock:       MainnetChainConfig.IstanbulBlock,
	MuirGlacierBlock:    MainnetChainConfig.MuirGlacierBlock,
	BerlinBlock:         MainnetChainConfig.BerlinBlock,
	LondonBlock:         MainnetChainConfig.LondonBlock,
	ArrowGlacierBlock:   MainnetChainConfig.ArrowGlacierBlock,
}
View Source
var DefaultConfig = Nodeconfig{
	SyncMode:        FastSync,
	DataDir:         DefaultDataDir(),
	NetworkId:       1,
	LightPeers:      20,
	DatabaseCache:   128,
	GasPrice:        big.NewInt(1 * Shannon),
	IPCPath:         "ghpb.ipc",
	MaxTrieCacheGen: uint16(120),
	RPCGasCap:       50000000,
}
View Source
var DefaultGasConfig = GasConfig{
	Blocks:     10,
	Percentile: 50,
}
View Source
var DefaultHTTPTimeouts = HTTPTimeouts{
	ReadTimeout:  60 * time.Second,
	WriteTimeout: 60 * time.Second,
	IdleTimeout:  600 * time.Second,
}

DefaultHTTPTimeouts represents the default timeout values used if further configuration is not provided.

View Source
var DefaultNTConfig = NetworkConfig{

	HTTPPort:         DefaultHTTPPort,
	HTTPModules:      []string{"net", "web3", "prometheus"},
	WSPort:           DefaultWSPort,
	WSModules:        []string{"net", "web3", "prometheus"},
	HTTPVirtualHosts: []string{"localhost"},
	HTTPTimeouts:     DefaultHTTPTimeouts,
	ListenAddr:       ":30303",
	MaxPeers:         50,
	NAT:              nat.Any(),
	IpcEndpoint:      DefaultIPCEndpoint(clientIdentifier),
	HttpEndpoint:     DefaultHTTPEndpoint(),
	WsEndpoint:       DefaultWSEndpoint(),
}
View Source
var DefaultPrometheusConfig = PrometheusConfig{

	Period: 6,
	Epoch:  30000,
}
View Source
var DefaultTxPoolConfig = TxPoolConfiguration{
	PriceLimit:   1,
	PriceBump:    10,
	AccountSlots: 60000,
	GlobalSlots:  1000000,
	AccountQueue: 30000,
	GlobalQueue:  1000000,
	Lifetime:     30 * time.Minute,
}

DefaultTxPoolConfig default txpool config.

View Source
var (
	GasTableEIP158 = GasTable{
		ExtcodeSize: 700,
		ExtcodeCopy: 700,
		Balance:     400,
		SLoad:       200,
		Calls:       700,
		Suicide:     5000,
		ExpByte:     50,

		CreateBySuicide: 25000,
	}
)
View Source
var INSTANCE = atomic.Value{}

INSTANCE config instance

View Source
var MainnetBootnodes = []string{
	"hnode://924548a360bf36833bbf202ea79c66268cda2e12250e94fa2d98a1f7ab2c7d29b3e13f4817d02863323537a12f544231428faec6a64df016384422bb1f96fe7c@bootnode1.hpb.io:30308",
	"hnode://7326ebe616bfe48440b877162dbd19a9689daaacf3d4ff1b9861c3a72657991b58a178cad45a3e632fc32dbe87193bbde6956f0329190f2838236fae0952e687@bootnode2.hpb.io:30308",
	"hnode://0e7c6af2fe5d0a13bf77ada5477b8ac38b0a48be13ce41c72facd20ce08a364070619d515c5d8dca8b346f49be1680408d95fd53b627f8366e0c68bae0f60ee2@bootnode3.hpb.io:30308",
	"hnode://4178ca45f32609cea1f1e75e8b2e57176d951905b5a7e2324026c2f28042d71b0f9bbf830935431326c55180921b587cdb1f686531f2076c0b509ed6ee9a2602@bootnode4.hpb.io:30308",
	"hnode://6c4ac5224a89c24abceb54203f651adfdf77be53c07094cebc9330063bee4a888177054db3055cdd1e7394d5554b7be48eb14d67df7c6f4902c3cd88e02bdd7c@bootnode5.hpb.io:30308",
}
View Source
var MainnetBootnodes_v3 = []string{
	"hnode://0a4ee79961f00dcf3601ae662cf010760c8166a22eac5bfddf28ab16513b497f72a1d6ebc6eb7afdfec391fa2b8997b4a74b33e7f3af5c81205f5ebb167658df@bootnode1.hpb.io:30306",
	"hnode://f31f58a70cd4880f506c8f1038be2c48823bb6f43529b16e82d67f5d74ff3c02e339f6b9ccb61c69c32f798ace3d8c8ac49014e9fefb58d9774c60e6f80c512e@bootnode2.hpb.io:30306",
	"hnode://230af50ef9f6209129be4879e5e0ce53fdce2de1b48a18388bfb15009998a4985eb864459c3c013f999d1ba44748b10a746e20e02da159f10b104025cb7f932a@bootnode3.hpb.io:30306",
	"hnode://283d1de984ee071e322a96e3a2e98cfba1adb4dee23e4af5846f72e23b364c11ab5280d1a8511394e03cb4dc6b3b6d86cf862d87afcbd2f324deb220390bbbae@bootnode4.hpb.io:30306",
	"hnode://33c5b55d6dc4aaf6bcb4502d69bf4ca8db7550e7b01cae1c53fca9ce8b60b440102d4c4dcd578136d64c8934fc90f0ad96bcf828bc611a9bbb7ea33369bc1aa0@bootnode5.hpb.io:30306",
}
View Source
var MainnetChainConfig = &ChainConfig{
	ChainId:             big.NewInt(269),
	Prometheus:          &DefaultPrometheusConfig,
	HomesteadBlock:      big.NewInt(StageNumberEvmV2),
	EIP150Block:         big.NewInt(StageNumberEvmV2),
	EIP155Block:         big.NewInt(StageNumberEvmV2),
	EIP158Block:         big.NewInt(StageNumberEvmV2),
	ByzantiumBlock:      big.NewInt(StageNumberEvmV2),
	ConstantinopleBlock: big.NewInt(StageNumberEvmV2),
	PetersburgBlock:     big.NewInt(StageNumberEvmV2),
	IstanbulBlock:       big.NewInt(StageNumberEvmV2),
	MuirGlacierBlock:    big.NewInt(StageNumberEvmV2),
	BerlinBlock:         big.NewInt(StageNumberEvmV2),
	LondonBlock:         big.NewInt(StageNumberEvmV2),
	ArrowGlacierBlock:   big.NewInt(StageNumberEvmV2),
}

MainnetChainConfig is the chain parameters to run a node on the main network.

View Source
var TestnetBootnodes = []string{}

TestnetBootnodes are the hnode URLs of the P2P bootstrap nodes running on the Ropsten test network.

View Source
var Version = func() string {
	v := fmt.Sprintf("%d.%d.%d.%d", VersionMajor, VersionHardv, VersionMinor, VersionPatch)
	if VersionMeta != "" {
		v += "-" + VersionMeta
	}
	return v
}()

Version holds the textual version string.

Functions

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir is the default data directory to use for the databases and other persistence requirements.

func DefaultHTTPEndpoint

func DefaultHTTPEndpoint() string

DefaultHTTPEndpoint returns the HTTP endpoint used by default.

func DefaultIPCEndpoint

func DefaultIPCEndpoint(clientIdentifier string) string

DefaultIPCEndpoint returns the IPC path used by default.

func DefaultWSEndpoint

func DefaultWSEndpoint() string

DefaultWSEndpoint returns the websocket endpoint used by default.

func VersionWithCommit

func VersionWithCommit(gitCommit string) string

Types

type ChainConfig

type ChainConfig struct {
	ChainId        *big.Int          `json:"chainId"` // Chain id identifies the current chain and is used for replay protection
	Prometheus     *PrometheusConfig `json:"prometheus"`
	HomesteadBlock *big.Int          `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)

	DAOForkBlock   *big.Int `json:"daoForkBlock,omitempty"`   // TheDAO hard-fork switch block (nil = no fork)
	DAOForkSupport bool     `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork

	// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
	EIP150Block *big.Int    `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
	EIP150Hash  common.Hash `json:"eip150Hash,omitempty"`  // EIP150 HF hash (needed for header only clients as only gas pricing changed)

	EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
	EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block

	ByzantiumBlock      *big.Int `json:"byzantiumBlock,omitempty"`      // Byzantium switch block (nil = no fork, 0 = already on byzantium)
	ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
	PetersburgBlock     *big.Int `json:"petersburgBlock,omitempty"`     // Petersburg switch block (nil = same as Constantinople)
	IstanbulBlock       *big.Int `json:"istanbulBlock,omitempty"`       // Istanbul switch block (nil = no fork, 0 = already on istanbul)
	MuirGlacierBlock    *big.Int `json:"muirGlacierBlock,omitempty"`    // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated)
	BerlinBlock         *big.Int `json:"berlinBlock,omitempty"`         // Berlin switch block (nil = no fork, 0 = already on berlin)
	LondonBlock         *big.Int `json:"londonBlock,omitempty"`         // London switch block (nil = no fork, 0 = already on london)
	ArrowGlacierBlock   *big.Int `json:"arrowGlacierBlock,omitempty"`   // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
	MergeForkBlock      *big.Int `json:"mergeForkBlock,omitempty"`      // EIP-3675 (TheMerge) switch block (nil = no fork, 0 = already in merge proceedings)

	// TerminalTotalDifficulty is the amount of total difficulty reached by
	// the network that triggers the consensus upgrade.
	TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty,omitempty"`
}

func (*ChainConfig) CheckCompatible

func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError

CheckCompatible checks whether scheduled fork transitions have been imported with a mismatching chain configuration.

func (*ChainConfig) GasTable

func (c *ChainConfig) GasTable(num *big.Int) GasTable

GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).

The returned GasTable's fields shouldn't, under any circumstances, be changed.

func (*ChainConfig) IsArrowGlacier

func (c *ChainConfig) IsArrowGlacier(num *big.Int) bool

IsArrowGlacier returns whether num is either equal to the Arrow Glacier (EIP-4345) fork block or greater.

func (*ChainConfig) IsBerlin

func (c *ChainConfig) IsBerlin(num *big.Int) bool

IsBerlin returns whether num is either equal to the Berlin fork block or greater.

func (*ChainConfig) IsByzantium

func (c *ChainConfig) IsByzantium(num *big.Int) bool

IsByzantium returns whether num is either equal to the Byzantium fork block or greater.

func (*ChainConfig) IsConstantinople

func (c *ChainConfig) IsConstantinople(num *big.Int) bool

IsConstantinople returns whether num is either equal to the Constantinople fork block or greater.

func (*ChainConfig) IsDAOFork

func (c *ChainConfig) IsDAOFork(num *big.Int) bool

IsDAOFork returns whether num is either equal to the DAO fork block or greater.

func (*ChainConfig) IsEIP150

func (c *ChainConfig) IsEIP150(num *big.Int) bool

IsEIP150 returns whether num is either equal to the EIP150 fork block or greater.

func (*ChainConfig) IsEIP155

func (c *ChainConfig) IsEIP155(num *big.Int) bool

IsEIP155 returns whether num is either equal to the EIP155 fork block or greater.

func (*ChainConfig) IsEIP158

func (c *ChainConfig) IsEIP158(num *big.Int) bool

IsEIP158 returns whether num is either equal to the EIP158 fork block or greater.

func (*ChainConfig) IsHomestead

func (c *ChainConfig) IsHomestead(num *big.Int) bool

IsHomestead returns whether num is either equal to the homestead block or greater.

func (*ChainConfig) IsIstanbul

func (c *ChainConfig) IsIstanbul(num *big.Int) bool

IsIstanbul returns whether num is either equal to the Istanbul fork block or greater.

func (*ChainConfig) IsLondon

func (c *ChainConfig) IsLondon(num *big.Int) bool

IsLondon returns whether num is either equal to the London fork block or greater.

func (*ChainConfig) IsMuirGlacier

func (c *ChainConfig) IsMuirGlacier(num *big.Int) bool

IsMuirGlacier returns whether num is either equal to the Muir Glacier (EIP-2384) fork block or greater.

func (*ChainConfig) IsPetersburg

func (c *ChainConfig) IsPetersburg(num *big.Int) bool

IsPetersburg returns whether num is either - equal to or greater than the PetersburgBlock fork block, - OR is nil, and Constantinople is active

func (*ChainConfig) Rules

func (c *ChainConfig) Rules(num *big.Int) Rules

Rules ensures c's ChainID is not nil.

func (*ChainConfig) String

func (c *ChainConfig) String() string

String implements the fmt.Stringer interface.

type ConfigCompatError

type ConfigCompatError struct {
	What string
	// block numbers of the stored and new configurations
	StoredConfig, NewConfig *big.Int
	// the block number to which the local chain must be rewound to correct the error
	RewindTo uint64
}

ConfigCompatError is raised if the locally-stored blockchain is initialised with a ChainConfig that would alter the past.

func (*ConfigCompatError) Error

func (err *ConfigCompatError) Error() string

type GasConfig

type GasConfig struct {
	Blocks     int
	Percentile int
	Default    *big.Int `toml:",omitempty"`
}

type GasTable

type GasTable struct {
	ExtcodeSize uint64
	ExtcodeCopy uint64
	Balance     uint64
	SLoad       uint64
	Calls       uint64
	Suicide     uint64

	ExpByte uint64

	// CreateBySuicide occurs when the
	// refunded account is one that does
	// not exist. This logic is similar
	// to call. May be left nil. Nil means
	// not charged.
	CreateBySuicide uint64
}

type GpoConfig

type GpoConfig struct {
	Blocks     int
	Percentile int
	Default    *big.Int `toml:",omitempty"`
}

type HTTPTimeouts

type HTTPTimeouts struct {
	// ReadTimeout is the maximum duration for reading the entire
	// request, including the body.
	//
	// Because ReadTimeout does not let Handlers make per-request
	// decisions on each request body's acceptable deadline or
	// upload rate, most users will prefer to use
	// ReadHeaderTimeout. It is valid to use them both.
	ReadTimeout time.Duration

	// WriteTimeout is the maximum duration before timing out
	// writes of the response. It is reset whenever a new
	// request's header is read. Like ReadTimeout, it does not
	// let Handlers make decisions on a per-request basis.
	WriteTimeout time.Duration

	// IdleTimeout is the maximum amount of time to wait for the
	// next request when keep-alives are enabled. If IdleTimeout
	// is zero, the value of ReadTimeout is used. If both are
	// zero, ReadHeaderTimeout is used.
	IdleTimeout time.Duration
}

HTTPTimeouts represents the configuration params for the HTTP RPC server.

type HpbConfig

type HpbConfig struct {
	Node Nodeconfig
	// Configuration of peer-to-peer networking.
	Network NetworkConfig

	//configuration of txpool
	TxPool TxPoolConfiguration

	//configuration of blockchain
	BlockChain ChainConfig

	//configuration of consensus
	Prometheus PrometheusConfig

	Gas GasConfig

	HpbStats hpbStatsConfig
}

HpbConfig represents a small collection of configuration values to fine tune the P2P network layer of a protocol stack. These values can be further extended by all registered services.

var HpbConfigIns *HpbConfig

func GetHpbConfigInstance

func GetHpbConfigInstance() *HpbConfig

func New

func New() *HpbConfig

type NetworkConfig

type NetworkConfig struct {
	// HTTPHost is the host interface on which to start the HTTP RPC server. If this
	// field is empty, no HTTP API endpoint will be started.
	HTTPHost string `toml:",omitempty"`

	// HTTPPort is the TCP port number on which to start the HTTP RPC server. The
	// default zero value is/ valid and will pick a port number randomly (useful
	// for ephemeral nodes).
	HTTPPort int `toml:",omitempty"`

	// HTTPCors is the Cross-Origin Resource Sharing header to send to requesting
	// clients. Please be aware that CORS is a browser enforced security, it's fully
	// useless for custom HTTP clients.
	HTTPCors []string `toml:",omitempty"`

	// HTTPVirtualHosts is the list of virtual hostnames which are allowed on incoming requests.
	// This is by default {'localhost'}. Using this prevents attacks like
	// DNS rebinding, which bypasses SOP by simply masquerading as being within the same
	// origin. These attacks do not utilize CORS, since they are not cross-domain.
	// By explicitly checking the Host-header, the server will not allow requests
	// made against the server with a malicious host domain.
	// Requests using ip address directly are not affected
	HTTPVirtualHosts []string `toml:",omitempty"`

	// HTTPModules is a list of API modules to expose via the HTTP RPC interface.
	// If the module list is empty, all RPC API endpoints designated public will be
	// exposed.
	HTTPModules []string `toml:",omitempty"`

	// HTTPTimeouts allows for customization of the timeout values used by the HTTP RPC
	// interface.
	HTTPTimeouts HTTPTimeouts

	// WSHost is the host interface on which to start the websocket RPC server. If
	// this field is empty, no websocket API endpoint will be started.
	WSHost string `toml:",omitempty"`

	// WSPort is the TCP port number on which to start the websocket RPC server. The
	// default zero value is/ valid and will pick a port number randomly (useful for
	// ephemeral nodes).
	WSPort int `toml:",omitempty"`

	// WSOrigins is the list of domain to accept websocket requests from. Please be
	// aware that the server can only act upon the HTTP request the client sends and
	// cannot verify the validity of the request header.
	WSOrigins []string `toml:",omitempty"`

	// WSModules is a list of API modules to expose via the websocket RPC interface.
	// If the module list is empty, all RPC API endpoints designated public will be
	// exposed.
	WSModules []string `toml:",omitempty"`

	// WSExposeAll exposes all API modules via the WebSocket RPC interface rather
	// than just the public ones.
	//
	// *WARNING* Only set this if the node is running in a trusted network, exposing
	// private APIs to untrusted users is a major security risk.
	WSExposeAll bool `toml:",omitempty"`

	// MaxPeers is the maximum number of peers that can be
	// connected. It must be greater than zero.
	MaxPeers int

	// MaxPendingPeers is the maximum number of peers that can be pending in the
	// handshake phase, counted separately for inbound and outbound connections.
	// Zero defaults to preset values.
	MaxPendingPeers int `toml:",omitempty"`

	// DiscoveryV5 specifies whether the the new topic-discovery based V5 discovery
	// protocol should be started or not.
	//DiscoveryV5 bool `toml:",omitempty"`
	NoDiscovery bool

	// Name sets the node name of this server.
	// Use common.MakeName to create a name that follows existing conventions.
	Name string `toml:"-"`

	// RoleType sets the node type of this server.
	// One of hpnode,prenode,access,light.
	RoleType string

	// Connectivity can be restricted to certain IP networks.
	// If this option is set to a non-nil value, only hosts which match one of the
	// IP networks contained in the list are considered.
	NetRestrict *netutil.Netlist `toml:",omitempty"`

	// NodeDatabase is the path to the database containing the previously seen
	// live nodes in the network.
	NodeDatabase string `toml:",omitempty"`

	// If ListenAddr is set to a non-nil address, the server
	// will listen for incoming connections.
	//
	// If the port is zero, the operating system will pick a port. The
	// ListenAddr field will be updated with the actual address when
	// the server is started.
	ListenAddr string

	// If set to a non-nil value, the given NAT port mapper
	// is used to make the listening port available to the
	// Internet.
	NAT nat.Interface `toml:",omitempty"`

	// If NoDial is true, the server will not dial any peers.
	NoDial bool `toml:",omitempty"`

	// If EnableMsgEvents is set then the server will emit PeerEvents
	// whenever a message is sent to or received from a peer
	EnableMsgEvents bool

	IpcEndpoint     string // IPC endpoint to listen at (empty = IPC disabled)
	HttpEndpoint    string // HTTP endpoint (interface + port) to listen at (empty = HTTP disabled)
	WsEndpoint      string // Websocket endpoint (interface + port) to listen at (empty = websocket disabled)
	GraphQLEndPoint string

	BootstrapNodes []*discover.Node
}

func DefaultNetworkConfig

func DefaultNetworkConfig() NetworkConfig

func (*NetworkConfig) GraphQLEndpoint

func (c *NetworkConfig) GraphQLEndpoint() string

func (*NetworkConfig) HTTPEndpoint

func (c *NetworkConfig) HTTPEndpoint() string

HTTPEndpoint resolves an HTTP endpoint based on the configured host interface and port parameters.

func (*NetworkConfig) WSEndpoint

func (c *NetworkConfig) WSEndpoint() string

WSEndpoint resolves an websocket endpoint based on the configured host interface and port parameters.

type Nodeconfig

type Nodeconfig struct {
	// Name sets the instance name of the node. It must not contain the / character and is
	// used in the devp2p node identifier. The instance name of ghpb is "ghpb". If no
	// value is specified, the basename of the current executable is used.
	Name string `toml:"-"`

	// UserIdent, if set, is used as an additional component in the devp2p node identifier.
	UserIdent string `toml:",omitempty"`

	// Version should be set to the version number of the program. It is used
	// in the devp2p node identifier.
	Version string `toml:"-"`

	// DataDir is the file system folder the node should use for any data storage
	// requirements. The configured data directory will not be directly shared with
	// registered services, instead those can use utility methods to create/access
	// databases or flat files. This enables ephemeral nodes which can fully reside
	// in memory.
	DataDir string

	// Protocol options
	NetworkId uint64 // Network ID to use for selecting peers to connect to
	SyncMode  SyncMode

	// Light client options
	LightServ  int `toml:",omitempty"` // Maximum percentage of time allowed for serving LHS requests
	LightPeers int `toml:",omitempty"` // Maximum number of LHS client peers

	// Database options
	SkipBcVersionCheck bool `toml:"-"`
	DatabaseHandles    int  `toml:"-"`
	DatabaseCache      int

	// Mining-related options
	Hpberbase    common.Address `toml:",omitempty"`
	MinerThreads int            `toml:",omitempty"`
	ExtraData    []byte         `toml:",omitempty"`
	GasPrice     *big.Int

	// Gas Price Oracle options,HPB don't need dynamic gas price
	GPO GpoConfig

	// Enables tracking of SHA3 preimages in the VM
	EnablePreimageRecording bool

	// Miscellaneous options
	DocRoot string `toml:"-"`

	// KeyStoreDir is the file system folder that contains private keys. The directory can
	// be specified as a relative path, in which case it is resolved relative to the
	// current directory.
	//
	// If KeyStoreDir is empty, the default location is the "keystore" subdirectory of
	// DataDir. If DataDir is unspecified and KeyStoreDir is empty, an ephemeral directory
	// is created by New and destroyed when the node is stopped.
	KeyStoreDir string `toml:",omitempty"`

	// UseLightweightKDF lowers the memory and CPU requirements of the key store
	// scrypt KDF at the expense of security.
	UseLightweightKDF bool `toml:",omitempty"`

	MaxTrieCacheGen uint16

	// This field must be set to a valid secp256k1 private key.
	PrivateKey *ecdsa.PrivateKey `toml:"-"`

	// IPCPath is the requested location to place the IPC endpoint. If the path is
	// a simple file name, it is placed inside the data directory (or on the root
	// pipe path on Windows), whereas if it's a resolvable path name (absolute or
	// relative), then that specific path is enforced. An empty path disables IPC.
	IPCPath string `toml:",omitempty"`

	DefaultAddress common.Address

	StartNumber uint64

	//1:testmode and don't nedd boe  0:standard mode and need boe
	TestMode uint8

	//1:test code  0:release code
	TestCodeParam uint8

	//consensus config file name
	FNameConsensusCfg string

	// RPCGasCap is the global gas cap for eth-call variants.
	RPCGasCap uint64 `toml:",omitempty"`

	CriticalFlag       uint64
	CriticalBackNumber uint64
	ArchivedBlock      int64
}

func (*Nodeconfig) IPCEndpoint

func (c *Nodeconfig) IPCEndpoint() string

IPCEndpoint resolves an IPC endpoint based on a configured value, taking into account the set data folders as well as the designated platform we're currently running on.

func (*Nodeconfig) InstanceDir

func (c *Nodeconfig) InstanceDir() string

func (*Nodeconfig) NodeDB

func (c *Nodeconfig) NodeDB() string

NodeDB returns the path to the discovery node database.

func (*Nodeconfig) NodeKey

func (c *Nodeconfig) NodeKey() error

NodeKey retrieves the currently configured private key of the node, checking first any manually set key, falling back to the one found in the configured data folder. If no key can be found, a new one is generated.

func (*Nodeconfig) NodeKeyTemp

func (c *Nodeconfig) NodeKeyTemp() *ecdsa.PrivateKey

NodeKey retrieves the currently configured private key of the node, checking first any manually set key, falling back to the one found in the configured data folder. If no key can be found, a new one is generated.

func (*Nodeconfig) ResolvePath

func (c *Nodeconfig) ResolvePath(path string) string

ResolvePath resolves path in the instance directory.

func (*Nodeconfig) StringName

func (c *Nodeconfig) StringName() string

type PrometheusConfig

type PrometheusConfig struct {
	Period uint64 `json:"period"` // Number of seconds between blocks to enforce
	Epoch  uint64 `json:"epoch"`  // Epoch length to reset votes and checkpoint
}

func (*PrometheusConfig) String

func (c *PrometheusConfig) String() string

PrometheusConfig is the consensus engine configs for proof-of-authority based sealing. String implements the stringer interface, returning the consensus engine details.

type Rules

type Rules struct {
	ChainID                                                 *big.Int
	IsHomestead, IsEIP150, IsEIP155, IsEIP158               bool
	IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
	IsBerlin, IsLondon                                      bool
}

type SyncMode

type SyncMode int

SyncMode represents the synchronisation mode of the downloader.

const (
	FullSync  SyncMode = iota // Synchronise the entire blockchain history from full blocks
	FastSync                  // Quickly download the headers, full sync only at the chain head
	LightSync                 // Download only the headers and terminate afterwards
)

func (SyncMode) IsValid

func (mode SyncMode) IsValid() bool

func (SyncMode) MarshalText

func (mode SyncMode) MarshalText() ([]byte, error)

func (SyncMode) String

func (mode SyncMode) String() string

String implements the stringer interface.

func (*SyncMode) UnmarshalText

func (mode *SyncMode) UnmarshalText(text []byte) error

type TxPoolConfiguration

type TxPoolConfiguration struct {
	PriceLimit   uint64        // Minimum gas price to enforce for acceptance into the pool
	PriceBump    uint64        // Minimum price bump percentage to replace an already existing transaction (nonce)
	AccountSlots uint64        // Minimum number of executable transaction slots guaranteed per account
	GlobalSlots  uint64        // Maximum number of executable transaction slots for all accounts
	AccountQueue uint64        // Maximum number of non-executable transaction slots permitted per account
	GlobalQueue  uint64        // Maximum number of non-executable transaction slots for all accounts
	Lifetime     time.Duration // Maximum amount of time non-executable transaction are queued
}

TxPoolConfiguration txpool config.

Jump to

Keyboard shortcuts

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