Documentation ¶
Index ¶
- Constants
- Variables
- func ArchiveVersion(gitCommit string) string
- func CalculateCoinbaseValueWithLockup(value *big.Int, lockupByte uint8) *big.Int
- func CalculateGasWithStateScaling(stateSize, contractSize *big.Int, baseRate uint64) uint64
- func CallNewAccountGas(stateSize *big.Int) uint64
- func ColdAccountAccessCost(stateSize, contractSize *big.Int) uint64
- func ColdSloadCost(stateSize, contractSize *big.Int) uint64
- func InitVersion()
- func PrimeEntropyTarget(expansionNum uint8) *big.Int
- func RegionEntropyTarget(expansionNum uint8) *big.Int
- func SstoreClearsScheduleRefund(stateSize, contractSize *big.Int) uint64
- func SstoreResetGas(stateSize, contractSize *big.Int) uint64
- func SstoreSentryGas(stateSize, contractSize *big.Int) uint64
- func SstoreSetGas(stateSize, contractSize *big.Int) uint64
- func VersionWithCommit(gitCommit, gitDate string) string
- func WarmStorageReadCost(stateSize, contractSize *big.Int) uint64
- type Blake3powConfig
- type CachedVersion
- type ChainConfig
- type ConfigCompatError
- type ProgpowConfig
- type Rules
Constants ¶
const ( ColosseumName = "colosseum" GardenName = "garden" OrchardName = "orchard" LighthouseName = "lighthouse" LocalName = "local" DevName = "dev" )
Different Network names
const ( Wei = 1 GWei = 1e9 Ether = 1e18 )
These are the multipliers for ether denominations. Example: To get the wei value of an amount in 'gwei', use
new(big.Int).Mul(value, big.NewInt(params.GWei))
const ( // BloomBitsBlocks is the number of blocks a single bloom bit section vector // contains on the server side. BloomBitsBlocks uint64 = 4096 // BloomBitsBlocksClient is the number of blocks a single bloom bit section vector // contains on the light client side BloomBitsBlocksClient uint64 = 32768 // BloomConfirms is the number of confirmation blocks before a bloom section is // considered probably final and its rotated bits are calculated. BloomConfirms = 256 // CHTFrequency is the block frequency for creating CHTs CHTFrequency = 32768 // BloomTrieFrequency is the block frequency for creating BloomTrie on both // server/client sides. BloomTrieFrequency = 32768 // HelperTrieConfirmations is the number of confirmations before a client is expected // to have the given HelperTrie available. HelperTrieConfirmations = 2048 // HelperTrieProcessConfirmations is the number of confirmations before a HelperTrie // is generated HelperTrieProcessConfirmations = 256 // FullImmutabilityThreshold is the number of blocks after which a chain segment is // considered immutable (i.e. soft finality). It is used by the downloader as a // hard limit against deep ancestors, by the blockchain against deep reorgs, by // the freezer as the cutoff threshold. FullImmutabilityThreshold = 90000 // LightImmutabilityThreshold is the number of blocks after which a header chain // segment is considered immutable for light client(i.e. soft finality). It is used by // the downloader as a hard limit against deep ancestors, by the blockchain against deep // reorgs, by the light pruner as the pruning validity guarantee. LightImmutabilityThreshold = 30000 )
const ( GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. PercentGasUsedThreshold uint64 = 50 // Percent Gas used threshold at which the gas limit adjusts GasLimitStepOneBlockThreshold uint64 = 150000 GasLimitStepTwoBlockThreshold uint64 = 300000 GasLimitStepThreeBlockThreshold uint64 = 450000 MinGasLimit uint64 = 40000000 // Minimum the gas limit may ever be. GenesisGasLimit uint64 = 5000000 // Gas limit of the Genesis block. StateCeil uint64 = 40000000 // Maximum the StateCeil may ever be StateLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. PercentStateUsedThreshold uint64 = 90 // Percent Gas used threshold at which the gas limit adjusts EtxStateUsed uint64 = 10000 // state used by a simple etx MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. 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 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. CallStipend uint64 = 2300 // Free gas given at beginning of call. ETXGas uint64 = 21000 // Per ETX generated by opETX or normal cross-chain transfer. // The etx fractions should be based on the current expansion number ETXRegionMaxFraction int = 1 // The maximum fraction of transactions for cross-region ETXs ETXPrimeMaxFraction int = 1 // The maximum fraction of transactions for cross-prime ETXs ETXRLimitMin int = 10 // Minimum possible cross-region ETX limit ETXPLimitMin int = 10 // Minimum possible cross-prime ETX limit EtxExpirationAge uint64 = 100 // Number of blocks an ETX may wait for inclusion at the destination Sha3Gas uint64 = 30 // Once per SHA3 operation. Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. JumpdestGas uint64 = 1 // Once per JUMPDEST operation. EpochDuration uint64 = 30000 // Duration between proof-of-work epochs. 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 SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct 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 = 16 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. TxAccessListAddressGas uint64 = 2400 // Per address specified in access list TxAccessListStorageKeyGas uint64 = 1900 // Per storage key specified in access list // These have been changed during the course of the chain SloadGas uint64 = 800 // This is only used in the Qi tx processing SelfdestructGas uint64 = 5000 // Cost of SELFDESTRUCT // EXP has a dynamic portion depending on the size of the exponent ExpByte uint64 = 50 // was raised to 50 // Extcodecopy has a dynamic AND a static cost. This represents only the // static portion of the gas. ExtcodeCopyBase uint64 = 700 // CreateBySelfdestructGas is used when the refunded account is one that does // not exist. This logic is similar to call. CreateBySelfdestructGas uint64 = 25000 BaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks. ElasticityMultiplier = 2 // Bounds the maximum gas limit a block may have. InitialBaseFee = 1 * GWei // Initial base fee for blocks. MaxBaseFee = 100 * GWei // Maximum base fee for blocks. InitialStateLimit = 5000000 // Initial state fee for blocks. MaxCodeSize = 24576 // Maximum bytecode to permit for a contract 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 Bn256AddGas uint64 = 150 // Gas needed for an elliptic curve addition Bn256ScalarMulGas uint64 = 6000 // Gas needed for an elliptic curve scalar multiplication Bn256PairingBaseGas uint64 = 45000 // Base price for an elliptic curve pairing check Bn256PairingPerPointGas uint64 = 34000 // Per-point price for an elliptic curve pairing check // The Refund Quotient is the cap on how much of the used gas can be refunded RefundQuotient uint64 = 5 MaxAddressGrindAttempts int = 1000 // Maximum number of attempts to grind an address to a valid one MinimumEtxGasDivisor = 5 // The divisor for the minimum gas for inbound ETXs (Block gas limit / MinimumEtxGasDivisor) MaximumEtxGasMultiplier = 2 // Multiplied with the minimum ETX gas for inbound ETXs (Block gas limit / MinimumEtxGasDivisor) * MaximumEtxGasMultiplier // This is the threshold (range 0-100) above which the // score will begin the tree expansion decision process. This threshold should be // chosen high enough to not be easily triggered by minor changes in node // operating behavior, but not so high that the security efficiency becomes // unacceptably low. TREE_EXPANSION_THRESHOLD uint16 = math.MaxUint16 // This is the smoothing factor (range 0-10) used by each zone in its low-pass // filter to gather a long running average of the zone's security efficiency // score. Choosing a larger will make the filter less responsive; the tree // expansion algorithm will be less susceptible to short term variations in the // efficiency score, but will take longer to decide to trigger an expansion when // one becomes necessary. TREE_EXPANSION_FILTER_ALPHA uint16 = 9 // Once all chains have confirmed above TREE_EXPANSION_THRESHOLD, this is // the number of consecutive prime blocks that must remain above the // threshold to confirm the decision to expand the tree. TREE_EXPANSION_TRIGGER_WINDOW uint16 = 144 // Once the network has confirmed the decision to expand the tree, this is // the number of prime blocks to wait until the expansion is activated. This // should be chosen to give node operators some time to adjust their // infrastructure, if needed, to account for the upcoming network change. TREE_EXPANSION_WAIT_COUNT = 1024 ConversionLockPeriod uint64 = 10 // The number of zone blocks that a conversion output is locked for MinQiConversionDenomination = 1 ConversionConfirmationContext = common.PRIME_CTX // A conversion requires a single coincident Dom confirmation )
Variables ¶
var ( // Progpow GenesisHashes ProgpowColosseumGenesisHash = common.HexToHash("0x0548874d6a6b261f1d423c083cb47c3044e549f9e30e634bc7b299f581cea282") ProgpowGardenGenesisHash = common.HexToHash("0x7bef576d9d04108137d14e2ea644f580634b35c37682b555bfb50dfb154501d2") ProgpowOrchardGenesisHash = common.HexToHash("0x0ff7bb95150bcc325ad8578db5698dc296a9f08052cac1b8161ee53c7d3a82dd") ProgpowLighthouseGenesisHash = common.HexToHash("0x46deea7604f0a460369094589c7f39d6822861eeb00014cd55927f19cf01360a") ProgpowLocalGenesisHash = common.HexToHash("0x175e643b5fe6158daca4742959f33ac2a8e9e6fe06cfd7233582827558f934f9") // Blake3GenesisHashes Blake3PowColosseumGenesisHash = common.HexToHash("0xa12a6bb23adf3bebee3a8719e491cde0847cb126d97abcf082e840d5c720b3d8") Blake3PowGardenGenesisHash = common.HexToHash("0x518968927b1c2aa2dd4c9809fe3341d47606652bda6ad99e9c65db77d6f56918") Blake3PowOrchardGenesisHash = common.HexToHash("0x36776a43809ee0e154b85b08ee384bf79b95c3bdb84ba61ddfef66ec8e105b60") Blake3PowLighthouseGenesisHash = common.HexToHash("0x36776a43809ee0e154b85b08ee384bf79b95c3bdb84ba61ddfef66ec8e105b60") Blake3PowLocalGenesisHash = common.HexToHash("0x518968927b1c2aa2dd4c9809fe3341d47606652bda6ad99e9c65db77d6f56918") )
Genesis hashes to enforce below configs on.
var ( // ColosseumChainConfig is the chain parameters to run a node on the Colosseum network. ProgpowColosseumChainConfig = &ChainConfig{ ChainID: big.NewInt(9000), Progpow: new(ProgpowConfig), } Blake3PowColosseumChainConfig = &ChainConfig{ ChainID: big.NewInt(9000), Blake3Pow: new(Blake3powConfig), } // GardenChainConfig contains the chain parameters to run a node on the Garden test network. ProgpowGardenChainConfig = &ChainConfig{ ChainID: big.NewInt(12000), Progpow: new(ProgpowConfig), } Blake3PowGardenChainConfig = &ChainConfig{ ChainID: big.NewInt(12000), Blake3Pow: new(Blake3powConfig), } // OrchardChainConfig contains the chain parameters to run a node on the Orchard test network. ProgpowOrchardChainConfig = &ChainConfig{ ChainID: big.NewInt(15000), Progpow: new(ProgpowConfig), } Blake3PowOrchardChainConfig = &ChainConfig{ ChainID: big.NewInt(15000), Blake3Pow: new(Blake3powConfig), } // LighthouseChainConfig contains the chain parameters to run a node on the Lighthouse test network. ProgpowLighthouseChainConfig = &ChainConfig{ ChainID: big.NewInt(17000), Blake3Pow: new(Blake3powConfig), Progpow: new(ProgpowConfig), } Blake3PowLighthouseChainConfig = &ChainConfig{ ChainID: big.NewInt(17000), Blake3Pow: new(Blake3powConfig), } // LocalChainConfig contains the chain parameters to run a node on the Local test network. ProgpowLocalChainConfig = &ChainConfig{ ChainID: big.NewInt(1337), Progpow: new(ProgpowConfig), } Blake3PowLocalChainConfig = &ChainConfig{ ChainID: big.NewInt(1337), Blake3Pow: new(Blake3powConfig), } // AllProgpowProtocolChanges contains every protocol change introduced // and accepted by the Quai core developers into the Progpow consensus. // // This configuration is intentionally not using keyed fields to force anyone // adding flags to the config to also have to set these fields. AllProgpowProtocolChanges = &ChainConfig{big.NewInt(1337), "progpow", new(Blake3powConfig), new(ProgpowConfig), common.Location{}, common.Hash{}, false} TestChainConfig = &ChainConfig{big.NewInt(1), "progpow", new(Blake3powConfig), new(ProgpowConfig), common.Location{}, common.Hash{}, false} TestRules = TestChainConfig.Rules(new(big.Int)) )
var ( MaxGossipsubPacketSize = 3 << 20 GasCeil uint64 = 20000000 ColosseumGasCeil uint64 = 70000000 GardenGasCeil uint64 = 160000000 OrchardGasCeil uint64 = 50000000 LighthouseGasCeil uint64 = 160000000 LocalGasCeil uint64 = 20000000 DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. ZoneMinDifficulty = big.NewInt(1000) // The minimum difficulty in a zone. Prime & regions should be multiples of this value MinimumDifficulty = ZoneMinDifficulty // The minimum that the difficulty may ever be. GenesisDifficulty = ZoneMinDifficulty // Difficulty of the Genesis block. DurationLimit = big.NewInt(12) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. GardenDurationLimit = big.NewInt(7) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. OrchardDurationLimit = big.NewInt(5) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. LighthouseDurationLimit = big.NewInt(7) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. LocalDurationLimit = big.NewInt(1) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. TimeToStartTx uint64 = 0 * BlocksPerDay BlocksPerDay uint64 = new(big.Int).Div(big.NewInt(86400), DurationLimit).Uint64() // BlocksPerDay is the number of blocks per day assuming 12 second block time DifficultyAdjustmentPeriod = big.NewInt(360) // This is the number of blocks over which the average has to be taken DifficultyAdjustmentFactor int64 = 40 // This is the factor that divides the log of the change in the difficulty MinQuaiConversionAmount = new(big.Int).Mul(big.NewInt(1), big.NewInt(GWei)) // 0.000000001 Quai LockupByteToBlockDepth = make(map[uint8]uint64) LockupByteToRewardsRatio = make(map[uint8]*big.Int) ExchangeRate = big.NewInt(1000000000000000) // This is the initial exchange rate in Qi per Quai in Its/Qit // These numbers should be "equivalent" to the initial conversion rate QuaiToQiConversionBase = big.NewInt(10000000) // Is the starting "historical conversion" in Qits for 10,000 Quai we need 10,000*1e3 QiToQuaiConversionBase = big.NewInt(10000000) // Is the starting "historical conversion" in Qits for 10,000 Qi we need 10,000*1e3 )
Functions ¶
func ArchiveVersion ¶
ArchiveVersion holds the textual version string used for Quai archives. e.g. "1.8.11-dea1ce05" for stable releases, or
"1.8.13-unstable-21c059b6" for unstable releases
func CalculateCoinbaseValueWithLockup ¶ added in v0.34.0
func CalculateGasWithStateScaling ¶ added in v0.32.0
func CallNewAccountGas ¶
func ColdAccountAccessCost ¶
func ColdSloadCost ¶
func InitVersion ¶ added in v0.30.0
func InitVersion()
func PrimeEntropyTarget ¶
This is TimeFactor*TimeFactor*common.NumZonesInRegion*common.NumRegionsInPrime
func RegionEntropyTarget ¶
This is TimeFactor*common.NumZonesInRegion
func SstoreClearsScheduleRefund ¶
SSTORE_CLEARS_SCHEDULE is defined as SSTORE_RESET_GAS + ACCESS_LIST_STORAGE_KEY_COST Which becomes: 5000 - 2100 + 1900 = 4800
func SstoreResetGas ¶
func SstoreSentryGas ¶
func SstoreSetGas ¶
func VersionWithCommit ¶
func WarmStorageReadCost ¶
Types ¶
type Blake3powConfig ¶
type Blake3powConfig struct{}
Blake3powConfig is the consensus engine configs for proof-of-work based sealing.
func (*Blake3powConfig) String ¶
func (c *Blake3powConfig) String() string
String implements the stringer interface, returning the consensus engine details.
type CachedVersion ¶
type CachedVersion struct {
// contains filtered or unexported fields
}
Version contains software version data parsed from the VERSION file
var Version CachedVersion
func (*CachedVersion) Full ¶
func (v *CachedVersion) Full() string
Full loads the cached full version string, or reads it from a file
func (*CachedVersion) Major ¶
func (v *CachedVersion) Major() int
Major loads the cached major version, or reads it from a file
func (*CachedVersion) Meta ¶
func (v *CachedVersion) Meta() string
Meta loads the cached version metadata, or reads it from a file Metadata may be empty if no metadata was provided
func (*CachedVersion) Minor ¶
func (v *CachedVersion) Minor() int
Minor loads the cached minor version, or reads it from a file
func (*CachedVersion) Patch ¶
func (v *CachedVersion) Patch() int
Patch loads the cached patch version, or reads it from a file
func (*CachedVersion) Short ¶
func (v *CachedVersion) Short() string
Full loads the cached full version string, or reads it from a file
type ChainConfig ¶
type ChainConfig struct { ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection // Various consensus engines ConsensusEngine string Blake3Pow *Blake3powConfig `json:"blake3pow,omitempty"` Progpow *ProgpowConfig `json:"progpow,omitempty"` Location common.Location DefaultGenesisHash common.Hash IndexAddressUtxos bool }
ChainConfig is the core 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) Rules ¶
func (c *ChainConfig) Rules(num *big.Int) Rules
Rules ensures c's ChainID is not nil.
func (*ChainConfig) SetLocation ¶
func (cfg *ChainConfig) SetLocation(location common.Location)
SetLocation sets the location on the chain config
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 ProgpowConfig ¶
type ProgpowConfig struct{}
ProgpowConfig is the consensus engine configs for proof-of-work based sealing.
func (*ProgpowConfig) String ¶
func (c *ProgpowConfig) String() string
String implements the stringer interface, returning the consensus engine details.