params

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package params contains configuration parameters for Klaytn.

Index

Constants

View Source
const (
	// Computation cost for opcodes
	ShlComputationCost            = 1603
	ShrComputationCost            = 1346
	SarComputationCost            = 1815
	ExtCodeHashComputationCost    = 1000
	Create2ComputationCost        = 10000
	StaticCallComputationCost     = 10000
	ReturnDataSizeComputationCost = 10
	ReturnDataCopyComputationCost = 40
	RevertComputationCost         = 0
	DelegateCallComputationCost   = 696
	StopComputationCost           = 0
	AddComputationCost            = 150
	MulComputationCost            = 200
	SubComputationCost            = 219
	DivComputationCost            = 404
	SdivComputationCost           = 739
	ModComputationCost            = 812
	SmodComputationCost           = 560
	AddmodComputationCost         = 3349
	MulmodComputationCost         = 4757
	ExpComputationCost            = 5000
	SignExtendComputationCost     = 481
	LtComputationCost             = 201
	GtComputationCost             = 264
	SltComputationCost            = 176
	SgtComputationCost            = 222
	EqComputationCost             = 220
	IszeroComputationCost         = 165
	AndComputationCost            = 288
	XorComputationCost            = 657
	OrComputationCost             = 160
	NotComputationCost            = 1289
	ByteComputationCost           = 589
	Sha3ComputationCost           = 2465
	AddressComputationCost        = 284
	BalanceComputationCost        = 1407
	OriginComputationCost         = 210
	CallerComputationCost         = 188
	CallValueComputationCost      = 149
	CallDataLoadComputationCost   = 596
	CallDataSizeComputationCost   = 194
	CallDataCopyComputationCost   = 100
	CodeSizeComputationCost       = 145
	CodeCopyComputationCost       = 898
	GasPriceComputationCost       = 131
	ExtCodeSizeComputationCost    = 1481
	ExtCodeCopyComputationCost    = 1000
	BlockHashComputationCost      = 500
	CoinbaseComputationCost       = 189
	TimestampComputationCost      = 265
	NumberComputationCost         = 202
	DifficultyComputationCost     = 180
	GasLimitComputationCost       = 166
	PopComputationCost            = 140
	MloadComputationCost          = 376
	MstoreComputationCost         = 288
	Mstore8ComputationCost        = 5142
	SloadComputationCost          = 835
	SstoreComputationCost         = 1548
	JumpComputationCost           = 253
	JumpiComputationCost          = 176
	PcComputationCost             = 147
	MsizeComputationCost          = 137
	GasComputationCost            = 230
	JumpDestComputationCost       = 10
	PushComputationCost           = 120
	Dup1ComputationCost           = 190
	Dup2ComputationCost           = 190
	Dup3ComputationCost           = 176
	Dup4ComputationCost           = 142
	Dup5ComputationCost           = 177
	Dup6ComputationCost           = 165
	Dup7ComputationCost           = 147
	Dup8ComputationCost           = 157
	Dup9ComputationCost           = 138
	Dup10ComputationCost          = 174
	Dup11ComputationCost          = 141
	Dup12ComputationCost          = 144
	Dup13ComputationCost          = 157
	Dup14ComputationCost          = 143
	Dup15ComputationCost          = 237
	Dup16ComputationCost          = 149
	Swap1ComputationCost          = 141
	Swap2ComputationCost          = 156
	Swap3ComputationCost          = 145
	Swap4ComputationCost          = 135
	Swap5ComputationCost          = 115
	Swap6ComputationCost          = 146
	Swap7ComputationCost          = 199
	Swap8ComputationCost          = 130
	Swap9ComputationCost          = 160
	Swap10ComputationCost         = 134
	Swap11ComputationCost         = 147
	Swap12ComputationCost         = 128
	Swap13ComputationCost         = 121
	Swap14ComputationCost         = 114
	Swap15ComputationCost         = 197
	Swap16ComputationCost         = 128
	Log0ComputationCost           = 100
	Log1ComputationCost           = 1000
	Log2ComputationCost           = 1000
	Log3ComputationCost           = 1000
	Log4ComputationCost           = 1000
	CreateComputationCost         = 2094
	CallComputationCost           = 5000
	CallCodeComputationCost       = 4000
	ReturnComputationCost         = 0
	SelfDestructComputationCost   = 0

	// Computation cost for precompiled contracts
	EcrecoverComputationCost            = 113150
	Sha256PerWordComputationCost        = 100
	Sha256BaseComputationCost           = 1000
	Ripemd160PerWordComputationCost     = 10
	Ripemd160BaseComputationCost        = 100
	IdentityPerWordComputationCost      = 0
	IdentityBaseComputationCost         = 0
	BigModExpPerGasComputationCost      = 10
	BigModExpBaseComputationCost        = 100
	Bn256AddComputationCost             = 8000
	Bn256ScalarMulComputationCost       = 100000
	Bn256ParingBaseComputationCost      = 2000000
	Bn256ParingPerPointComputationCost  = 1000000
	VMLogPerByteComputationCost         = 0
	VMLogBaseComputationCost            = 10
	FeePayerComputationCost             = 10
	ValidateSenderPerSigComputationCost = 180000
	ValidateSenderBaseComputationCost   = 10000
)
View Source
const (
	VMLogToFile   = 0x1
	VMLogToStdout = 0x2
	VMLogToAll    = VMLogToFile | VMLogToStdout

	UpperGasLimit = uint64(999999999999)
)
View Source
const (
	Peb      = 1    // official notation 'peb'
	Kpeb     = 1e3  // official notation 'kpeb'
	Mpeb     = 1e6  // same
	Gpeb     = 1e9  // same
	Ston     = 1e9  // official notation 'ston'
	UKLAY    = 1e12 // official notation 'uKLAY'
	MiliKLAY = 1e15 // official notation 'mKLAY'
	KLAY     = 1e18 // same
	KKLAY    = 1e21 // official notation 'kKLAY'
	MKLAY    = 1e24 // same
	GKLAY    = 1e27 // same
)

These are the multipliers for KLAY denominations. Example: To get the peb value of an amount in 'ston', use

new(big.Int).Mul(value, big.NewInt(params.Ston))
View Source
const (
	DefaultCNRewardRatio  = 34 // Default CN reward ratio 34%
	DefaultPoCRewardRatio = 54 // Default PoC ratio 54%
	DefaultKIRRewardRatio = 12 // Default KIR ratio 12%
)
View Source
const (
	// Block reward will be separated by three pieces and distributed
	RewardSliceCount = 3
	// GovernanceConfig is stored in a cache which has below capacity
	GovernanceCacheLimit    = 3
	GovernanceIdxCacheLimit = 1000
	// The prefix for governance cache
	GovernanceCachePrefix = "governance"
)
View Source
const (
	// Governance Key
	GovernanceMode int = iota
	GoverningNode
	Epoch
	Policy
	CommitteeSize
	UnitPrice
	MintingAmount
	Ratio
	UseGiniCoeff
	DeferredTxFee
	MinimumStake
	AddValidator
	RemoveValidator
	StakeUpdateInterval
	ProposerRefreshInterval
	ConstTxGasHumanReadable
	CliqueEpoch
)
View Source
const (
	GovernanceMode_None = iota
	GovernanceMode_Single
	GovernanceMode_Ballot
)
View Source
const (
	// Proposer policy
	// At the moment this is duplicated in istanbul/config.go, not to make a cross reference
	// TODO-Klatn-Governance: Find a way to manage below constants at single location
	RoundRobin = iota
	Sticky
	WeightedRandom
)
View Source
const (
	// Default Values: Constants used for getting default values for configuration
	DefaultGovernanceMode = "none"
	DefaultGoverningNode  = "0x0000000000000000000000000000000000000000"
	DefaultEpoch          = uint64(604800)
	DefaultProposerPolicy = uint64(0)
	DefaultSubGroupSize   = uint64(21)
	DefaultMintingAmount  = 0
	DefaultRatio          = "100/0/0"
	DefaultUseGiniCoeff   = false
	DefaultDefferedTxFee  = false
	DefaultUnitPrice      = uint64(250000000000)
	DefaultPeriod         = 1
)
View Source
const (
	CallValueTransferGas  uint64 = 9000  // Paid for CALL when the value transfer is non-zero.                  // G_callvalue
	CallNewAccountGas     uint64 = 25000 // Paid for CALL when the destination address didn't exist prior.      // G_newaccount
	TxGas                 uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. // G_transaction
	TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. // G_transaction + G_create
	TxDataZeroGas         uint64 = 4     // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. // G_txdatazero
	QuadCoeffDiv          uint64 = 512   // Divisor for the quadratic particle of the memory cost equation.
	SstoreSetGas          uint64 = 20000 // Once per SLOAD operation.                                           // G_sset
	LogDataGas            uint64 = 8     // Per byte in a LOG* operation's data.                                // G_logdata
	CallStipend           uint64 = 2300  // Free gas given at beginning of call.                                // G_callstipend
	Sha3Gas               uint64 = 30    // Once per SHA3 operation.                                                 // G_sha3
	Sha3WordGas           uint64 = 6     // Once per word of the SHA3 operation's data.                              // G_sha3word
	SstoreResetGas        uint64 = 5000  // Once per SSTORE operation if the zeroness changes from zero.             // G_sreset
	SstoreClearGas        uint64 = 5000  // Once per SSTORE operation if the zeroness doesn't change.                // G_sreset
	SstoreRefundGas       uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero.               // R_sclear
	JumpdestGas           uint64 = 1     // Once per JUMPDEST operation.
	CreateDataGas         uint64 = 200   // Paid per byte for a CREATE operation to succeed in placing code into state. // G_codedeposit
	ExpGas                uint64 = 10    // Once per EXP instruction
	LogGas                uint64 = 375   // Per LOG* operation.                                                          // G_log
	CopyGas               uint64 = 3     // Partial payment for COPY operations, multiplied by words copied, rounded up. // G_copy
	CreateGas             uint64 = 32000 // Once per CREATE operation & contract-creation transaction.               // G_create
	Create2Gas            uint64 = 32000 // Once per CREATE2 operation
	SuicideRefundGas      uint64 = 24000 // Refunded following a suicide operation.                                  // R_selfdestruct
	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. // G_memory
	LogTopicGas           uint64 = 375   // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.   // G_logtopic
	TxDataNonZeroGas      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. // G_txdatanonzero

	// Fee for Service Chain
	// TODO-Klaytn-ServiceChain The following parameters should be fixed.
	// TODO-Klaytn-Governance The following parameters should be able to be modified by governance.
	TxChainDataAnchoringGas uint64 = 21000 // Per transaction anchoring chain data. NOTE: Not payable on data of calls between transactions. // G_transactionchaindataanchoring
	ChainDataAnchoringGas   uint64 = 100   // Per byte of anchoring chain data NOTE: Not payable on data of calls between transactions. // G_chaindataanchoring

	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
	Bn256AddGas             uint64 = 500    // Gas needed for an elliptic curve addition
	Bn256ScalarMulGas       uint64 = 40000  // Gas needed for an elliptic curve scalar multiplication
	Bn256PairingBaseGas     uint64 = 100000 // Base price for an elliptic curve pairing check
	Bn256PairingPerPointGas uint64 = 80000  // Per-point price for an elliptic curve pairing check
	VMLogBaseGas            uint64 = 100    // Base price for a VMLOG operation
	VMLogPerByteGas         uint64 = 20     // Per-byte price for a VMLOG operation
	FeePayerGas             uint64 = 300    // Gas needed for calculating the fee payer of the transaction in a smart contract.
	ValidateSenderGas       uint64 = 5000   // Gas needed for validating the signature of a message.

	GasLimitBoundDivisor uint64 = 1024    // The bound divisor of the gas limit, used in update calculations.
	MinGasLimit          uint64 = 5000    // Minimum the gas limit may ever be.
	GenesisGasLimit      uint64 = 4712388 // Gas limit of the Genesis block.

	MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis.

	EpochDuration   uint64 = 30000 // Duration between proof-of-work epochs.
	CallCreateDepth uint64 = 1024  // Maximum depth of call/create stack.
	StackLimit      uint64 = 1024  // Maximum size of VM stack allowed.

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

	// istanbul BFT
	BFTMaximumExtraDataSize uint64 = 65 // Maximum size extra data may be after Genesis.

	// AccountKey
	// TODO-Klaytn: Need to fix below values.
	TxAccountCreationGasDefault uint64 = 0
	TxValidationGasDefault      uint64 = 0
	TxAccountCreationGasPerKey  uint64 = 20000 // WARNING: With integer overflow in mind before changing this value.
	TxValidationGasPerKey       uint64 = 15000 // WARNING: With integer overflow in mind before changing this value.

	// Fee for new tx types
	// TODO-Klaytn: Need to fix values
	TxGasAccountCreation       uint64 = 21000
	TxGasAccountUpdate         uint64 = 21000
	TxGasFeeDelegated          uint64 = 10000
	TxGasFeeDelegatedWithRatio uint64 = 15000
	TxGasCancel                uint64 = 21000

	// Network Id
	UnusedNetworkId  uint64 = 0
	AspenNetworkId   uint64 = 1000
	BaobabNetworkId  uint64 = 1001
	CypressNetworkId uint64 = 8217

	TxGasValueTransfer     uint64 = 21000
	TxGasContractExecution uint64 = 21000

	TxDataGas uint64 = 100
)
View Source
const (
	ReleaseNum   = 1
	VersionMajor = 1 // Major version component of the current release
	VersionMinor = 0 // Minor version component of the current release
	VersionPatch = 0 // Patch version component of the current release
)
View Source
const (
	// BloomBitsBlocks is the number of blocks a single bloom bit section vector
	// contains.
	BloomBitsBlocks uint64 = 4096
)
View Source
const (
	ChainIDBaobab = 1001
)

Variables

View Source
var (
	MainnetGenesisHash      = common.HexToHash("// todo generate new hash for mainnet") // Mainnet genesis hash to enforce below configs on
	TestnetGenesisHash      = common.HexToHash("// todo generate new hash for testnet") // Testnet genesis hash to enforce below configs on
	AuthorAddressForTesting = common.HexToAddress("0xc0ea08a2d404d3172d2add29a45be56da40e2949")
)

Genesis hashes to enforce below configs on.

View Source
var (
	// MainnetChainConfig is the chain parameters to run a node on the main network.
	MainnetChainConfig = &ChainConfig{
		ChainID: big.NewInt(1),
		Gxhash:  new(GxhashConfig),
	}

	// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
	TestnetChainConfig = &ChainConfig{
		ChainID: big.NewInt(2),
		Gxhash:  new(GxhashConfig),
	}

	// AllGxhashProtocolChanges contains every protocol change (GxIPs) introduced
	// and accepted by the klaytn developers into the Klaytn consensus.
	//
	// This configuration is intentionally not using keyed fields to force anyone
	// adding flags to the config to also have to set these fields.
	AllGxhashProtocolChanges = &ChainConfig{
		ChainID:  big.NewInt(0),
		Gxhash:   new(GxhashConfig),
		Clique:   nil,
		Istanbul: nil,
	}

	// AllCliqueProtocolChanges contains every protocol change (GxIPs) introduced
	// and accepted by the klaytn developers into the Clique consensus.
	//
	// This configuration is intentionally not using keyed fields to force anyone
	// adding flags to the config to also have to set these fields.
	AllCliqueProtocolChanges = &ChainConfig{
		ChainID:  big.NewInt(0),
		Gxhash:   nil,
		Clique:   &CliqueConfig{Period: 0, Epoch: 30000},
		Istanbul: nil,
	}

	TestChainConfig = &ChainConfig{
		ChainID:       big.NewInt(1),
		Gxhash:        new(GxhashConfig),
		Clique:        nil,
		Istanbul:      nil,
		UnitPrice:     1,
		DeriveShaImpl: 0,
	}
	TestRules = TestChainConfig.Rules(new(big.Int))

	// istanbul BFT
	BFTTestChainConfig = &ChainConfig{
		ChainID:  big.NewInt(1),
		Gxhash:   new(GxhashConfig),
		Clique:   nil,
		Istanbul: nil,
	}
)
View Source
var (
	// TODO-Klaytn-Issue1587 Decide whether to remove below three variables after discussing token economy policy for service chain and private network
	RewardContractIncentive = big.NewInt(0).Mul(big.NewInt(rewardContractIncentiveInSton), big.NewInt(Ston))
	KIRContractIncentive    = big.NewInt(0).Mul(big.NewInt(kirContractIncentiveInSton), big.NewInt(Ston))
	PoCContractIncentive    = big.NewInt(0).Mul(big.NewInt(pocContractIncentiveInSton), big.NewInt(Ston))

	DefaultMintedKLAY = big.NewInt(0).Mul(big.NewInt(defaultMintedKLAYInSton), big.NewInt(Ston))
)
View Source
var (
	TxGasHumanReadable     uint64 = 4000000000
	BlockScoreBoundDivisor        = big.NewInt(2048)   // The bound divisor of the blockscore, used in the update calculations.
	GenesisBlockScore             = big.NewInt(131072) // BlockScore of the Genesis block.
	MinimumBlockScore             = big.NewInt(131072) // The minimum that the blockscore may ever be.
	DurationLimit                 = big.NewInt(13)     // The decision boundary on the blocktime duration used to determine whether blockscore should go up or not.
)
View Source
var (
	// TODO-Klaytn Determine more practical values through actual running experience
	TotalTimeLimit             = 250 * time.Millisecond // Execution time limit for all txs in a block
	OpcodeComputationCostLimit = uint64(100000000)      // Computation cost limit for a tx. For now, it is approximately 100 ms.
)

Parameters for execution time limit

View Source
var BaobabBootnodes = map[p2p.ConnType]bootnodesByTypes{
	p2p.CONSENSUSNODE: {
		[]string{
			"kni://d8adb5a300d7ee0fcde4d6777362c1e0e03d208a2f3978d6d3993a2ada4a64af2580b97d4b4bf21201b1596cea761ecf53f196153bae8bbb0948b3c6397303b2@ston98.baobab.klaytn.net:32323?ntype=bn",
		},
	},
	p2p.ENDPOINTNODE: {
		[]string{
			"kni://779d766628247ebda5f3e108e9303bd8efdb8eba9fd8d6c529e2614aec7207ebf6614fe7e61d0d99b75e8b23dd3a679b112fd0de7e4e71a7008f0718710da48f@ston45.baobab.klaytn.net:32323?ntype=bn",
		},
	},
	p2p.PROXYNODE: {
		[]string{
			"kni://779d766628247ebda5f3e108e9303bd8efdb8eba9fd8d6c529e2614aec7207ebf6614fe7e61d0d99b75e8b23dd3a679b112fd0de7e4e71a7008f0718710da48f@ston45.baobab.klaytn.net:32323?ntype=bn",
		},
	},
}

BaobabBootnodes are the URLs of bootnodes running on the Baobab test network.

View Source
var (
	// GasTableCypress contains the gas prices for the Klaytn mainnet, Cypress.
	GasTableCypress = GasTable{
		ExtcodeSize: 700,
		ExtcodeCopy: 700,
		ExtcodeHash: 400,
		Balance:     400,
		SLoad:       200,
		Calls:       700,
		Suicide:     5000,
		ExpByte:     50,

		CreateBySuicide: 25000,
	}
)

Variables containing gas prices for different Klaytn phases.

View Source
var MainnetBootnodes = map[p2p.ConnType]bootnodesByTypes{
	p2p.CONSENSUSNODE: {
		[]string{},
	},
	p2p.PROXYNODE: {
		[]string{
			"kni://18b36118cce093673499fc6e9aa196f047fe17a0de35b6f2a76a4557802f6abf9f89aa5e7330e93c9014b714b9df6378393611efe39aec9d3d831d6aa9d617ae@ston65.cypress.klaytn.net:32323?ntype=bn",
			"kni://63f1c96874da85140ecca3ce24875cb5ef28fa228bc3572e16f690db4a48fc8067502d2f6e8f0c66fb558276a5ada1e4906852c7ae42b0003e9f9f25d1e123b1@ston873.cypress.klaytn.net:32323?ntype=bn",
			"kni://94cc15e2014b86584908707de55800c0a2ea8a24dc5550dcb507043e4cf18ff04f21dc86ed17757dc63b1fa85bb418b901e5e24e4197ad4bbb0d96cd9389ed98@ston106.cypress.klaytn.net:32323?ntype=bn",
		},
	},
	p2p.ENDPOINTNODE: {
		[]string{
			"kni://18b36118cce093673499fc6e9aa196f047fe17a0de35b6f2a76a4557802f6abf9f89aa5e7330e93c9014b714b9df6378393611efe39aec9d3d831d6aa9d617ae@ston65.cypress.klaytn.net:32323?ntype=bn",
			"kni://63f1c96874da85140ecca3ce24875cb5ef28fa228bc3572e16f690db4a48fc8067502d2f6e8f0c66fb558276a5ada1e4906852c7ae42b0003e9f9f25d1e123b1@ston873.cypress.klaytn.net:32323?ntype=bn",
			"kni://94cc15e2014b86584908707de55800c0a2ea8a24dc5550dcb507043e4cf18ff04f21dc86ed17757dc63b1fa85bb418b901e5e24e4197ad4bbb0d96cd9389ed98@ston106.cypress.klaytn.net:32323?ntype=bn",
		},
	},
}

MainnetBootnodes are the URLs of bootnodes running on the Klaytn main network.

View Source
var (
	TargetGasLimit = GenesisGasLimit // The artificial target
)
View Source
var (
	// VMLogTarget sets the output target of vmlog.
	// The values below can be OR'ed.
	//  - 0x0: no output (default)
	//  - 0x1: file (DATADIR/logs/vm.log)
	//  - 0x2: stdout (like logger.DEBUG)
	VMLogTarget = 0x0
)
View Source
var Version = func() string {
	v := fmt.Sprintf("v%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
	return v
}()

Version holds the textual version string.

Functions

func CalcProposerBlockNumber

func CalcProposerBlockNumber(blockNum uint64) uint64

CalcProposerBlockNumber returns number of block where list of proposers is updated for block blockNum

func CalcStakingBlockNumber

func CalcStakingBlockNumber(blockNum uint64) uint64

CalcStakingBlockNumber returns number of block which contains staking information required to make a new block with blockNum.

func GetMaximumExtraDataSize

func GetMaximumExtraDataSize() uint64

istanbul BFT

func IsProposerUpdateInterval

func IsProposerUpdateInterval(blockNum uint64) (bool, uint64)

func IsStakingUpdateInterval

func IsStakingUpdateInterval(blockNum uint64) bool

func ProposerUpdateInterval

func ProposerUpdateInterval() uint64

func SetProposerUpdateInterval

func SetProposerUpdateInterval(num uint64)

func SetStakingUpdateInterval

func SetStakingUpdateInterval(num uint64)

func StakingUpdateInterval

func StakingUpdateInterval() uint64

func VersionWithCommit

func VersionWithCommit(gitCommit string) string

Types

type ChainConfig

type ChainConfig struct {
	ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection

	// Various consensus engines
	Gxhash   *GxhashConfig   `json:"gxhash,omitempty"`
	Clique   *CliqueConfig   `json:"clique,omitempty"`
	Istanbul *IstanbulConfig `json:"istanbul,omitempty"`

	UnitPrice     uint64            `json:"unitPrice"`
	DeriveShaImpl int               `json:"deriveShaImpl"`
	Governance    *GovernanceConfig `json:"governance"`
}

ChainConfig is the blockchain config which determines the blockchain settings.

ChainConfig is stored in the database on a per block basis. This means that any network, identified by its genesis block, can have its own set of configuration options.

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.

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

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 CliqueConfig

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

CliqueConfig is the consensus engine configs for proof-of-authority based sealing.

func (*CliqueConfig) String

func (c *CliqueConfig) String() string

String implements the stringer interface, returning the consensus engine details.

type CodeFormat

type CodeFormat uint8
const (
	CodeFormatEVM CodeFormat = iota
	CodeFormatLast
)

func (CodeFormat) String

func (t CodeFormat) String() string

func (CodeFormat) Validate

func (t CodeFormat) Validate() bool

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 EngineType

type EngineType int
const (
	// Engine type
	UseIstanbul EngineType = iota
	UseClique
)

type GasTable

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

	ExpByte uint64

	// not exist. This logic is similar
	// to call. May be left nil. Nil means
	// not charged.
	CreateBySuicide uint64
}

GasTable organizes gas prices for different Klaytn phases.

type GovernanceConfig

type GovernanceConfig struct {
	GoverningNode  common.Address `json:"governingNode"`
	GovernanceMode string         `json:"governanceMode"`
	Reward         *RewardConfig  `json:"reward,omitempty"`
}

GovernanceConfig stores governance information for a network

func (*GovernanceConfig) Copy

Copy copies self to a new governance config and return it

func (*GovernanceConfig) DeferredTxFee

func (g *GovernanceConfig) DeferredTxFee() bool

type GxhashConfig

type GxhashConfig struct{}

GxhashConfig is the consensus engine configs for proof-of-work based sealing.

func (*GxhashConfig) String

func (c *GxhashConfig) String() string

String implements the stringer interface, returning the consensus engine details.

type IstanbulConfig

type IstanbulConfig struct {
	Epoch          uint64 `json:"epoch"`  // Epoch length to reset votes and checkpoint
	ProposerPolicy uint64 `json:"policy"` // The policy for proposer selection
	SubGroupSize   uint64 `json:"sub"`
}

IstanbulConfig is the consensus engine configs for Istanbul based sealing.

func (*IstanbulConfig) Copy

func (c *IstanbulConfig) Copy() *IstanbulConfig

func (*IstanbulConfig) String

func (c *IstanbulConfig) String() string

String implements the stringer interface, returning the consensus engine details.

type RewardConfig

type RewardConfig struct {
	MintingAmount          *big.Int `json:"mintingAmount"`
	Ratio                  string   `json:"ratio"`                  // Define how much portion of reward be distributed to CN/PoC/KIR
	UseGiniCoeff           bool     `json:"useGiniCoeff"`           // Decide if Gini Coefficient will be used or not
	DeferredTxFee          bool     `json:"deferredTxFee"`          // Decide if TX fee will be handled instantly or handled later at block finalization
	StakingUpdateInterval  uint64   `json:"stakingUpdateInterval"`  // Interval when staking information is updated
	ProposerUpdateInterval uint64   `json:"proposerUpdateInterval"` // Interval when proposer information is updated
	MinimumStake           *big.Int `json:"minimumStake"`           // Minimum amount of peb to join CCO
}

RewardConfig stores information about the network's token economy

type Rules

type Rules struct {
	ChainID *big.Int
}

Rules wraps ChainConfig and is merely syntatic sugar or can be used for functions that do not have or require information about the block.

Rules is a one time interface meaning that it shouldn't be used in between transition phases.

Jump to

Keyboard shortcuts

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