Documentation ¶
Index ¶
- Variables
- func SetGenesisTimestamp(ts int64)
- func Timestamp() int64
- func WithGenesisContext(ctx context.Context, g Genesis) context.Context
- type Account
- type Blockchain
- func (g *Blockchain) BlockGasLimitByHeight(height uint64) uint64
- func (g *Blockchain) IsAleutian(height uint64) bool
- func (g *Blockchain) IsBering(height uint64) bool
- func (g *Blockchain) IsCook(height uint64) bool
- func (g *Blockchain) IsDardanelles(height uint64) bool
- func (g *Blockchain) IsDaytona(height uint64) bool
- func (g *Blockchain) IsEaster(height uint64) bool
- func (g *Blockchain) IsFairbank(height uint64) bool
- func (g *Blockchain) IsFbkMigration(height uint64) bool
- func (g *Blockchain) IsGreenland(height uint64) bool
- func (g *Blockchain) IsHawaii(height uint64) bool
- func (g *Blockchain) IsIceland(height uint64) bool
- func (g *Blockchain) IsJutland(height uint64) bool
- func (g *Blockchain) IsKamchatka(height uint64) bool
- func (g *Blockchain) IsLordHowe(height uint64) bool
- func (g *Blockchain) IsMidway(height uint64) bool
- func (g *Blockchain) IsNewfoundland(height uint64) bool
- func (g *Blockchain) IsOkhotsk(height uint64) bool
- func (g *Blockchain) IsPacific(height uint64) bool
- func (g *Blockchain) IsPalau(height uint64) bool
- func (g *Blockchain) IsQuebec(height uint64) bool
- func (g *Blockchain) IsRedsea(height uint64) bool
- func (g *Blockchain) IsSumatra(height uint64) bool
- func (g *Blockchain) IsToBeEnabled(height uint64) bool
- func (g *Blockchain) IsTsunami(height uint64) bool
- func (g *Blockchain) IsUpernavik(height uint64) bool
- type BootstrapCandidate
- type Delegate
- type Genesis
- type Poll
- type RegistrationConsts
- type Rewarding
- func (r *Rewarding) AleutianEpochReward() *big.Int
- func (r *Rewarding) BlockReward() *big.Int
- func (r *Rewarding) DardanellesBlockReward() *big.Int
- func (r *Rewarding) EpochReward() *big.Int
- func (r *Rewarding) ExemptAddrsFromEpochReward() []address.Address
- func (r *Rewarding) FoundationBonus() *big.Int
- func (r *Rewarding) InitBalance() *big.Int
- type Staking
- type VoteWeightCalConsts
Constants ¶
This section is empty.
Variables ¶
var (
// Default contains the default genesis config
Default = defaultConfig()
)
Functions ¶
func SetGenesisTimestamp ¶
func SetGenesisTimestamp(ts int64)
SetGenesisTimestamp sets the genesis timestamp
Types ¶
type Account ¶
type Account struct { // InitBalanceMap is the address and initial balance mapping before the first block. InitBalanceMap map[string]string `yaml:"initBalances"` // ReplayDeployerWhitelist is the whitelist address for unprotected (pre-EIP155) transaction ReplayDeployerWhitelist []string `yaml:"replayDeployerWhitelist"` }
Account contains the configs for account protocol
func (*Account) InitBalances ¶
InitBalances returns the address that have initial balances and the corresponding amounts. The i-th amount is the i-th address' balance.
type Blockchain ¶
type Blockchain struct { // Timestamp is the timestamp of the genesis block Timestamp int64 // BlockGasLimit is the total gas limit could be consumed in a block BlockGasLimit uint64 `yaml:"blockGasLimit"` // TsunamiBlockGasLimit is the block gas limit starting Tsunami height (raised to 50M by default) TsunamiBlockGasLimit uint64 `yaml:"tsunamiBlockGasLimit"` // ActionGasLimit is the per action gas limit cap ActionGasLimit uint64 `yaml:"actionGasLimit"` // BlockInterval is the interval between two blocks BlockInterval time.Duration `yaml:"blockInterval"` // NumSubEpochs is the number of sub epochs in one epoch of block production NumSubEpochs uint64 `yaml:"numSubEpochs"` // DardanellesNumSubEpochs is the number of sub epochs starts from dardanelles height in one epoch of block production DardanellesNumSubEpochs uint64 `yaml:"dardanellesNumSubEpochs"` // NumDelegates is the number of delegates that participate into one epoch of block production NumDelegates uint64 `yaml:"numDelegates"` // NumCandidateDelegates is the number of candidate delegates, who may be selected as a delegate via roll dpos NumCandidateDelegates uint64 `yaml:"numCandidateDelegates"` // TimeBasedRotation is the flag to enable rotating delegates' time slots on a block height TimeBasedRotation bool `yaml:"timeBasedRotation"` // PacificBlockHeight is the start height of using the logic of Pacific version // TODO: PacificBlockHeight is not added into protobuf definition for backward compatibility PacificBlockHeight uint64 `yaml:"pacificHeight"` // AleutianBlockHeight is the start height of adding bloom filter of all events into block header AleutianBlockHeight uint64 `yaml:"aleutianHeight"` // BeringBlockHeight is the start height of evm upgrade BeringBlockHeight uint64 `yaml:"beringHeight"` // CookBlockHeight is the start height of native staking CookBlockHeight uint64 `yaml:"cookHeight"` // DardanellesBlockHeight is the start height of 5s block internal DardanellesBlockHeight uint64 `yaml:"dardanellesHeight"` // DaytonaBlockHeight is the height to fix low gas for read native staking contract DaytonaBlockHeight uint64 `yaml:"daytonaBlockHeight"` // EasterBlockHeight is the start height of probation for slashing EasterBlockHeight uint64 `yaml:"easterHeight"` // FbkMigrationBlockHeight is the start height for fairbank migration FbkMigrationBlockHeight uint64 `yaml:"fbkMigrationHeight"` // FairbankBlockHeight is the start height to switch to native staking V2 FairbankBlockHeight uint64 `yaml:"fairbankHeight"` // GreenlandBlockHeight is the start height of storing latest 720 block meta and rewarding/staking bucket pool GreenlandBlockHeight uint64 `yaml:"greenlandHeight"` // HawaiiBlockHeight is the start height to // 1. fix GetBlockHash in EVM // 2. add revert message to log // 3. fix change to same candidate in staking protocol // 4. fix sorted map in StateDBAdapter // 5. use pending nonce in EVM HawaiiBlockHeight uint64 `yaml:"hawaiiHeight"` // IcelandBlockHeight is the start height to support chainID opcode and EVM Istanbul IcelandBlockHeight uint64 `yaml:"icelandHeight"` // JutlandBlockHeight is the start height to // 1. report more EVM error codes // 2. enable the opCall fix JutlandBlockHeight uint64 `yaml:"jutlandHeight"` // KamchatkaBlockHeight is the start height to // 1. fix EVM snapshot order // 2. extend foundation bonus KamchatkaBlockHeight uint64 `yaml:"kamchatkaHeight"` // LordHoweBlockHeight is the start height to // 1. recover the smart contracts affected by snapshot order // 2. clear snapshots in Revert() LordHoweBlockHeight uint64 `yaml:"lordHoweHeight"` // MidwayBlockHeight is the start height to // 1. allow correct and default ChainID // 2. fix GetHashFunc in EVM // 3. correct tx/log index for transaction receipt and EVM log // 4. revert logs upon tx reversion in EVM MidwayBlockHeight uint64 `yaml:"midwayHeight"` // NewfoundlandBlockHeight is the start height to // 1. use correct chainID // 2. check legacy address // 3. enable web3 staking transaction NewfoundlandBlockHeight uint64 `yaml:"newfoundlandHeight"` // OkhotskBlockHeight is the start height to // 1. enable London EVM // 2. create zero-nonce account // 3. fix gas and nonce update // 4. fix unproductive delegates in staking protocol OkhotskBlockHeight uint64 `yaml:"okhotskHeight"` // PalauBlockHeight is the the start height to // 1. enable rewarding action via web3 // 2. broadcast node info into the p2p network PalauBlockHeight uint64 `yaml:"palauHeight"` // QuebecBlockHeight is the start height to // 1. enforce using correct chainID only // 2. enable IIP-13 liquidity staking // 3. valiate system action layout QuebecBlockHeight uint64 `yaml:"quebecHeight"` // RedseaBlockHeight is the start height to // 1. upgrade go-ethereum to Bellatrix release // 2. correct weighted votes for contract staking bucket RedseaBlockHeight uint64 `yaml:"redseaHeight"` // SumatraBlockHeight is the start height to enable Shanghai EVM SumatraBlockHeight uint64 `yaml:"sumatraHeight"` // TsunamiBlockHeight is the start height to // 1. enable delegate endorsement // 2. generate transaction log for SelfDestruct() call in EVM // 3. raise block gas limit to 50M TsunamiBlockHeight uint64 `yaml:"tsunamiHeight"` // 1. enable Cancun EVM UpernavikBlockHeight uint64 `yaml:"upernavikHeight"` // ToBeEnabledBlockHeight is a fake height that acts as a gating factor for WIP features // upon next release, change IsToBeEnabled() to IsNextHeight() for features to be released ToBeEnabledBlockHeight uint64 `yaml:"toBeEnabledHeight"` }
Blockchain contains blockchain level configs
func (*Blockchain) BlockGasLimitByHeight ¶
func (g *Blockchain) BlockGasLimitByHeight(height uint64) uint64
func (*Blockchain) IsAleutian ¶
func (g *Blockchain) IsAleutian(height uint64) bool
IsAleutian checks whether height is equal to or larger than aleutian height
func (*Blockchain) IsBering ¶
func (g *Blockchain) IsBering(height uint64) bool
IsBering checks whether height is equal to or larger than bering height
func (*Blockchain) IsCook ¶
func (g *Blockchain) IsCook(height uint64) bool
IsCook checks whether height is equal to or larger than cook height
func (*Blockchain) IsDardanelles ¶
func (g *Blockchain) IsDardanelles(height uint64) bool
IsDardanelles checks whether height is equal to or larger than dardanelles height
func (*Blockchain) IsDaytona ¶
func (g *Blockchain) IsDaytona(height uint64) bool
IsDaytona checks whether height is equal to or larger than daytona height
func (*Blockchain) IsEaster ¶
func (g *Blockchain) IsEaster(height uint64) bool
IsEaster checks whether height is equal to or larger than easter height
func (*Blockchain) IsFairbank ¶
func (g *Blockchain) IsFairbank(height uint64) bool
IsFairbank checks whether height is equal to or larger than fairbank height
func (*Blockchain) IsFbkMigration ¶
func (g *Blockchain) IsFbkMigration(height uint64) bool
IsFbkMigration checks whether height is equal to or larger than fbk migration height
func (*Blockchain) IsGreenland ¶
func (g *Blockchain) IsGreenland(height uint64) bool
IsGreenland checks whether height is equal to or larger than greenland height
func (*Blockchain) IsHawaii ¶
func (g *Blockchain) IsHawaii(height uint64) bool
IsHawaii checks whether height is equal to or larger than hawaii height
func (*Blockchain) IsIceland ¶
func (g *Blockchain) IsIceland(height uint64) bool
IsIceland checks whether height is equal to or larger than iceland height
func (*Blockchain) IsJutland ¶
func (g *Blockchain) IsJutland(height uint64) bool
IsJutland checks whether height is equal to or larger than jutland height
func (*Blockchain) IsKamchatka ¶
func (g *Blockchain) IsKamchatka(height uint64) bool
IsKamchatka checks whether height is equal to or larger than kamchatka height
func (*Blockchain) IsLordHowe ¶
func (g *Blockchain) IsLordHowe(height uint64) bool
IsLordHowe checks whether height is equal to or larger than lordHowe height
func (*Blockchain) IsMidway ¶
func (g *Blockchain) IsMidway(height uint64) bool
IsMidway checks whether height is equal to or larger than midway height
func (*Blockchain) IsNewfoundland ¶
func (g *Blockchain) IsNewfoundland(height uint64) bool
IsNewfoundland checks whether height is equal to or larger than newfoundland height
func (*Blockchain) IsOkhotsk ¶
func (g *Blockchain) IsOkhotsk(height uint64) bool
IsOkhotsk checks whether height is equal to or larger than okhotsk height
func (*Blockchain) IsPacific ¶
func (g *Blockchain) IsPacific(height uint64) bool
IsPacific checks whether height is equal to or larger than pacific height
func (*Blockchain) IsPalau ¶
func (g *Blockchain) IsPalau(height uint64) bool
IsPalau checks whether height is equal to or larger than palau height
func (*Blockchain) IsQuebec ¶
func (g *Blockchain) IsQuebec(height uint64) bool
IsQuebec checks whether height is equal to or larger than quebec height
func (*Blockchain) IsRedsea ¶
func (g *Blockchain) IsRedsea(height uint64) bool
IsRedsea checks whether height is equal to or larger than redsea height
func (*Blockchain) IsSumatra ¶
func (g *Blockchain) IsSumatra(height uint64) bool
IsSumatra checks whether height is equal to or larger than sumatra height
func (*Blockchain) IsToBeEnabled ¶
func (g *Blockchain) IsToBeEnabled(height uint64) bool
IsToBeEnabled checks whether height is equal to or larger than toBeEnabled height
func (*Blockchain) IsTsunami ¶
func (g *Blockchain) IsTsunami(height uint64) bool
IsTsunami checks whether height is equal to or larger than tsunami height
func (*Blockchain) IsUpernavik ¶
func (g *Blockchain) IsUpernavik(height uint64) bool
IsUpernavik checks whether height is equal to or larger than upernavik height
type BootstrapCandidate ¶
type BootstrapCandidate struct { OwnerAddress string `yaml:"ownerAddress"` OperatorAddress string `yaml:"operatorAddress"` RewardAddress string `yaml:"rewardAddress"` Name string `yaml:"name"` SelfStakingTokens string `yaml:"selfStakingTokens"` }
BootstrapCandidate is the candidate data need to be provided to bootstrap candidate.
type Delegate ¶
type Delegate struct { // OperatorAddrStr is the address who will operate the node OperatorAddrStr string `yaml:"operatorAddr"` // RewardAddrStr is the address who will get the reward when operator produces blocks RewardAddrStr string `yaml:"rewardAddr"` // VotesStr is the score for the operator to rank and weight for rewardee to split epoch reward VotesStr string `yaml:"votes"` }
Delegate defines a delegate with address and votes
func (*Delegate) OperatorAddr ¶
OperatorAddr is the address of operator
func (*Delegate) RewardAddr ¶
RewardAddr is the address of rewardee, which is allowed to be nil
type Genesis ¶
type Genesis struct { Blockchain `yaml:"blockchain"` Account `yaml:"account"` Poll `yaml:"poll"` Rewarding `yaml:"rewarding"` Staking `yaml:"staking"` }
Genesis is the root level of genesis config. Genesis config is the network-wide blockchain config. All the nodes participating into the same network should use EXACTLY SAME genesis config.
func ExtractGenesisContext ¶
ExtractGenesisContext extracts genesis from context if available
func MustExtractGenesisContext ¶
MustExtractGenesisContext extracts genesis from context if available, else panic
type Poll ¶
type Poll struct { // PollMode is different based on chain type or poll input data source PollMode string `yaml:"pollMode"` // EnableGravityChainVoting is a flag whether read voting from gravity chain EnableGravityChainVoting bool `yaml:"enableGravityChainVoting"` // GravityChainStartHeight is the height in gravity chain where the init poll result stored GravityChainStartHeight uint64 `yaml:"gravityChainStartHeight"` // GravityChainCeilingHeight is the height in gravity chain where the poll is no longer needed GravityChainCeilingHeight uint64 `yaml:"gravityChainCeilingHeight"` // GravityChainHeightInterval the height interval on gravity chain to pull delegate information GravityChainHeightInterval uint64 `yaml:"gravityChainHeightInterval"` // RegisterContractAddress is the address of register contract RegisterContractAddress string `yaml:"registerContractAddress"` // StakingContractAddress is the address of staking contract StakingContractAddress string `yaml:"stakingContractAddress"` // NativeStakingContractAddress is the address of native staking contract NativeStakingContractAddress string `yaml:"nativeStakingContractAddress"` // NativeStakingContractCode is the code of native staking contract NativeStakingContractCode string `yaml:"nativeStakingContractCode"` // ConsortiumCommitteeCode is the code of consortiumCommittee contract ConsortiumCommitteeContractCode string `yaml:"consortiumCommitteeContractCode"` // VoteThreshold is the vote threshold amount in decimal string format VoteThreshold string `yaml:"voteThreshold"` // ScoreThreshold is the score threshold amount in decimal string format ScoreThreshold string `yaml:"scoreThreshold"` // SelfStakingThreshold is self-staking vote threshold amount in decimal string format SelfStakingThreshold string `yaml:"selfStakingThreshold"` // Delegates is a list of delegates with votes Delegates []Delegate `yaml:"delegates"` // ProbationEpochPeriod is a duration of probation after delegate's productivity is lower than threshold ProbationEpochPeriod uint64 `yaml:"probationEpochPeriod"` // ProbationIntensityRate is a intensity rate of probation range from [0, 100], where 100 is hard-probation ProbationIntensityRate uint32 `yaml:"probationIntensityRate"` // UnproductiveDelegateMaxCacheSize is a max cache size of upd which is stored into state DB (probationEpochPeriod <= UnproductiveDelegateMaxCacheSize) UnproductiveDelegateMaxCacheSize uint64 `yaml:"unproductiveDelegateMaxCacheSize"` // SystemStakingContractAddress is the address of system staking contract SystemStakingContractAddress string `yaml:"systemStakingContractAddress"` // SystemStakingContractHeight is the height of system staking contract SystemStakingContractHeight uint64 `yaml:"systemStakingContractHeight"` // SystemSGDContractAddress is the address of system sgd contract SystemSGDContractAddress string `yaml:"systemSGDContractAddress"` // SystemSGDContractHeight is the height of system sgd contract SystemSGDContractHeight uint64 `yaml:"systemSGDContractHeight"` // SystemStakingContractV2Address is the address of system staking contract SystemStakingContractV2Address string `yaml:"systemStakingContractV2Address"` // SystemStakingContractV2Height is the height of system staking contract SystemStakingContractV2Height uint64 `yaml:"systemStakingContractV2Height"` }
Poll contains the configs for poll protocol
type RegistrationConsts ¶
type RegistrationConsts struct { Fee string `yaml:"fee"` MinSelfStake string `yaml:"minSelfStake"` }
RegistrationConsts contains the configs for candidate registration
type Rewarding ¶
type Rewarding struct { // InitBalanceStr is the initial balance of the rewarding protocol in decimal string format InitBalanceStr string `yaml:"initBalance"` // BlockReward is the block reward amount in decimal string format BlockRewardStr string `yaml:"blockReward"` // DardanellesBlockReward is the block reward amount starts from dardanelles height in decimal string format DardanellesBlockRewardStr string `yaml:"dardanellesBlockReward"` // EpochReward is the epoch reward amount in decimal string format EpochRewardStr string `yaml:"epochReward"` // AleutianEpochRewardStr is the epoch reward amount in decimal string format after aleutian fork AleutianEpochRewardStr string `yaml:"aleutianEpochReward"` // NumDelegatesForEpochReward is the number of top candidates that will share a epoch reward NumDelegatesForEpochReward uint64 `yaml:"numDelegatesForEpochReward"` // ExemptAddrStrsFromEpochReward is the list of addresses in encoded string format that exempt from epoch reward ExemptAddrStrsFromEpochReward []string `yaml:"exemptAddrsFromEpochReward"` // FoundationBonusStr is the bootstrap bonus in decimal string format FoundationBonusStr string `yaml:"foundationBonus"` // NumDelegatesForFoundationBonus is the number of top candidate that will get the bootstrap bonus NumDelegatesForFoundationBonus uint64 `yaml:"numDelegatesForFoundationBonus"` // FoundationBonusLastEpoch is the last epoch number that bootstrap bonus will be granted FoundationBonusLastEpoch uint64 `yaml:"foundationBonusLastEpoch"` // FoundationBonusP2StartEpoch is the start epoch number for part 2 foundation bonus FoundationBonusP2StartEpoch uint64 `yaml:"foundationBonusP2StartEpoch"` // FoundationBonusP2EndEpoch is the end epoch number for part 2 foundation bonus FoundationBonusP2EndEpoch uint64 `yaml:"foundationBonusP2EndEpoch"` // ProductivityThreshold is the percentage number that a delegate's productivity needs to reach not to get probation ProductivityThreshold uint64 `yaml:"productivityThreshold"` }
Rewarding contains the configs for rewarding protocol
func (*Rewarding) AleutianEpochReward ¶
AleutianEpochReward returns the epoch reward amount after Aleutian fork
func (*Rewarding) BlockReward ¶
BlockReward returns the block reward amount
func (*Rewarding) DardanellesBlockReward ¶
DardanellesBlockReward returns the block reward amount after dardanelles fork
func (*Rewarding) EpochReward ¶
EpochReward returns the epoch reward amount
func (*Rewarding) ExemptAddrsFromEpochReward ¶
ExemptAddrsFromEpochReward returns the list of addresses that exempt from epoch reward
func (*Rewarding) FoundationBonus ¶
FoundationBonus returns the bootstrap bonus amount rewarded per epoch
func (*Rewarding) InitBalance ¶
InitBalance returns the init balance of the rewarding fund
type Staking ¶
type Staking struct { VoteWeightCalConsts VoteWeightCalConsts `yaml:"voteWeightCalConsts"` RegistrationConsts RegistrationConsts `yaml:"registrationConsts"` WithdrawWaitingPeriod time.Duration `yaml:"withdrawWaitingPeriod"` MinStakeAmount string `yaml:"minStakeAmount"` BootstrapCandidates []BootstrapCandidate `yaml:"bootstrapCandidates"` EndorsementWithdrawWaitingBlocks uint64 `yaml:"endorsementWithdrawWaitingBlocks"` }
Staking contains the configs for staking protocol
type VoteWeightCalConsts ¶
type VoteWeightCalConsts struct { DurationLg float64 `yaml:"durationLg"` AutoStake float64 `yaml:"autoStake"` SelfStake float64 `yaml:"selfStake"` }
VoteWeightCalConsts contains the configs for calculating vote weight