xcom

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefualtRule = iota
	StakingRule
	SlashingRule
	RestrictingRule
	RewardRule
	GovernanceRule
	CollectDeclareVersionRule
)

plugin rule key

View Source
const (
	Zero                      = 0
	Eighty                    = 80
	Hundred                   = 100
	TenThousand               = 10000
	CeilBlocksReward          = 50000
	CeilMaxValidators         = 201
	FloorMaxConsensusVals     = 4
	CeilMaxConsensusVals      = 25
	PositiveInfinity          = "+∞"
	CeilUnStakeFreezeDuration = 168 * 2
	CeilMaxEvidenceAge        = CeilUnStakeFreezeDuration - 1

	RewardPerMaxChangeRangeUpperLimit = 2000
	RewardPerMaxChangeRangeLowerLimit = 1
	RewardPerChangeIntervalUpperLimit = 28
	RewardPerChangeIntervalLowerLimit = 2
	IncreaseIssuanceRatioUpperLimit   = 2000
	IncreaseIssuanceRatioLowerLimit   = 0

	// When electing consensus nodes, it is used to calculate the P value of the binomial distribution
	ElectionBase = 25 // New expectations

	ElectionBaseL1 = 3000
	ElectionBaseL2 = 6000

	AlayaNetECHash = "0x828aafb72c19203ad930cb21cee8c9887fcd59eaa44f5c4a24f4cab7cfb80ad0"
)
View Source
const (
	DefaultAlayaNet    = iota // PlatON default Alaya net flag
	DefaultTestNet            // PlatON default test net flag
	DefaultUnitTestNet        // PlatON default unit test
)

Variables

View Source
var (

	// 1 ATP
	DelegateLowerLimit, _ = new(big.Int).SetString("1000000000000000000", 10)

	// 1W ATP
	DelegateUpperLimit, _ = new(big.Int).SetString("10000000000000000000000", 10)

	// hard code genesis staking balance
	// 10500 ATP
	GeneStakingAmount, _ = new(big.Int).SetString("10500000000000000000000", 10)

	// 1W
	StakeLowerLimit, _ = new(big.Int).SetString("10000000000000000000000", 10)
	// 100W ATP
	StakeUpperLimit, _ = new(big.Int).SetString("1000000000000000000000000", 10)
)
View Source
var (
	AvgPackTimeKey       = []byte("AvgPackTimeKey")
	IncIssuanceNumberKey = []byte("IncIssuanceNumberKey")
	IncIssuanceTimeKey   = []byte("IncIssuanceTimeKey")
)

Functions

func AddLog

func AddLog(state StateDB, blockNumber uint64, contractAddr common.Address, event, data string)

addLog let the result add to event.

func AddLogWithRes

func AddLogWithRes(state StateDB, blockNumber uint64, contractAddr common.Address, event, code string, res interface{})

addLog let the result add to event.

func AdditionalCycleTime

func AdditionalCycleTime() uint64

func BlocksWillCreate

func BlocksWillCreate() uint64

func CDFAccount

func CDFAccount() common.Address

func CDFBalance

func CDFBalance() *big.Int

func CalcP

func CalcP(totalWeight float64, sqrtWeight float64) float64

Calculate the P value of the binomial distribution Parameter: The total weight of the election

func CalcPNew

func CalcPNew(sqrtWeight float64) float64

func CancelProposal_SupportRate

func CancelProposal_SupportRate() uint64

func CancelProposal_VoteRate

func CancelProposal_VoteRate() uint64

func CheckDuplicateSignReportReward

func CheckDuplicateSignReportReward(fraction int) error

func CheckEconomicModel

func CheckEconomicModel() error

func CheckIncreaseIssuanceRatio

func CheckIncreaseIssuanceRatio(increaseIssuanceRatio uint16) error

func CheckMaxEvidenceAge

func CheckMaxEvidenceAge(age, unStakeFreezeDuration int) error

func CheckMaxValidators

func CheckMaxValidators(num int) error

func CheckOperatingThreshold

func CheckOperatingThreshold(threshold *big.Int) error

func CheckRewardPerChangeInterval

func CheckRewardPerChangeInterval(rewardPerChangeInterval uint16) error

func CheckRewardPerMaxChangeRange

func CheckRewardPerMaxChangeRange(rewardPerMaxChangeRange uint16) error

func CheckSlashBlocksReward

func CheckSlashBlocksReward(rewards int) error

func CheckSlashFractionDuplicateSign

func CheckSlashFractionDuplicateSign(fraction int) error

func CheckStakeThreshold

func CheckStakeThreshold(threshold *big.Int) error

func CheckUnStakeFreezeDuration

func CheckUnStakeFreezeDuration(duration, maxEvidenceAge, zeroProduceFreezeDuration int) error

func CheckZeroProduceCumulativeTime

func CheckZeroProduceCumulativeTime(zeroProduceCumulativeTime uint16, zeroProduceNumberThreshold uint16) error

func CheckZeroProduceFreezeDuration

func CheckZeroProduceFreezeDuration(zeroProduceFreezeDuration uint64, unStakeFreezeDuration uint64) error

func CheckZeroProduceNumberThreshold

func CheckZeroProduceNumberThreshold(zeroProduceCumulativeTime uint16, zeroProduceNumberThreshold uint16) error

func ConsensusSize

func ConsensusSize() uint64

func DuplicateSignReportReward

func DuplicateSignReportReward() uint32

func EcParams0140

func EcParams0140() ([]byte, error)

New parameters added in version 0.14.0 need to be saved on the chain. Calculate the rlp of the new parameter and return it to the upper storage.

func EconomicString

func EconomicString() string

func ElectionDistance

func ElectionDistance() uint64

func EpochSize

func EpochSize() uint64

func HesitateRatio

func HesitateRatio() uint64

func IncreaseIssuanceRatio

func IncreaseIssuanceRatio() uint16

func Interval

func Interval() uint64

func IsYearEnd

func IsYearEnd(hash common.Hash, blockNumber uint64) (bool, error)

Determine whether the block height belongs to the last block at the end of the year according to the passed blockNumber

func LoadAvgPackTime

func LoadAvgPackTime(hash common.Hash, snapshotDB snapshotdb.DB) (uint64, error)

gets block average pack time (millisecond) from snapshot db.

func LoadCurrentAvgPackTime

func LoadCurrentAvgPackTime() (uint64, error)

gets block average pack time (millisecond) from snapshot db.

func LoadIncIssuanceNumber

func LoadIncIssuanceNumber(hash common.Hash, snapshotDB snapshotdb.DB) (uint64, error)

func LoadIncIssuanceTime

func LoadIncIssuanceTime(hash common.Hash, snapshotDB snapshotdb.DB) (int64, error)

func MaxConsensusVals

func MaxConsensusVals() uint64

func MaxEpochMinutes

func MaxEpochMinutes() uint64

*****

  • Common configure *****

func MaxEvidenceAge

func MaxEvidenceAge() uint32

func MaxValidators

func MaxValidators() uint64

func NewBlockRewardRate

func NewBlockRewardRate() uint64

*****

  • Reward config *****

func NewResult

func NewResult(err *common.BizError, data interface{}) []byte

func OperatingThreshold

func OperatingThreshold() *big.Int

func ParamProposalVote_DurationSeconds

func ParamProposalVote_DurationSeconds() uint64

func ParamProposal_SupportRate

func ParamProposal_SupportRate() uint64

func ParamProposal_VoteRate

func ParamProposal_VoteRate() uint64

func PlatONFoundationYear

func PlatONFoundationYear() uint32

func PlatONFundAccount

func PlatONFundAccount() common.Address

*****

  • Inner Account Config *****

func PlatONFundBalance

func PlatONFundBalance() *big.Int

func ResetEconomicDefaultConfig

func ResetEconomicDefaultConfig(newEc *EconomicModel)

func ResetEconomicExtendConfig

func ResetEconomicExtendConfig(newEc *EconomicModelExtend)

func RestrictingMinimumRelease

func RestrictingMinimumRelease() *big.Int

func RewardPerChangeInterval

func RewardPerChangeInterval() uint16

func RewardPerMaxChangeRange

func RewardPerMaxChangeRange() uint16

func SetNodeBlockTimeWindow

func SetNodeBlockTimeWindow(period uint64)

set the value by genesis block

func SetPerRoundBlocks

func SetPerRoundBlocks(amount uint64)

func ShiftValidatorNum

func ShiftValidatorNum() uint64

func SlashBlocksReward

func SlashBlocksReward() uint32

func SlashFractionDuplicateSign

func SlashFractionDuplicateSign() uint32

*****

  • Slashing config *****

func StakeThreshold

func StakeThreshold() *big.Int

*****

  • Staking configure *****

func StorageAvgPackTime

func StorageAvgPackTime(hash common.Hash, snapshotDB snapshotdb.DB, avgPackTime uint64) error

saves block average pack time (millisecond) to snapshot db.

func StorageIncIssuanceNumber

func StorageIncIssuanceNumber(hash common.Hash, snapshotDB snapshotdb.DB, incIssuanceNumber uint64) error

Stored the height of the block that was actually issuance

func StorageIncIssuanceTime

func StorageIncIssuanceTime(hash common.Hash, snapshotDB snapshotdb.DB, incTime int64) error

Store the expected time for increase issuance

func TextProposalVote_DurationSeconds

func TextProposalVote_DurationSeconds() uint64
func TextProposalVote_ConsensusRounds() uint64 {
	return ec.Gov.TextProposalVoteDurationSeconds / (Interval() * ec.Common.PerRoundBlocks * ec.Common.MaxConsensusVals)
}

func TextProposal_SupportRate

func TextProposal_SupportRate() uint64

func TextProposal_VoteRate

func TextProposal_VoteRate() uint64

func TheNumberOfDelegationsReward

func TheNumberOfDelegationsReward() uint16

func UnStakeFreezeDuration

func UnStakeFreezeDuration() uint64

func VersionProposalVote_DurationSeconds

func VersionProposalVote_DurationSeconds() uint64

func VersionProposal_SupportRate

func VersionProposal_SupportRate() uint64

func ZeroProduceCumulativeTime

func ZeroProduceCumulativeTime() uint16

func ZeroProduceFreezeDuration

func ZeroProduceFreezeDuration() uint64

func ZeroProduceNumberThreshold

func ZeroProduceNumberThreshold() uint16

Types

type EconomicModel

type EconomicModel struct {
	Common   commonConfig     `json:"common"`
	Staking  stakingConfig    `json:"staking"`
	Slashing slashingConfig   `json:"slashing"`
	Gov      governanceConfig `json:"gov"`
	Reward   rewardConfig     `json:"reward"`
	InnerAcc innerAccount     `json:"innerAcc"`
}

Genesis parameters, once the chain is started, the structure and value cannot be changed This will change the hash of the genesis block

func GetEc

func GetEc(netId int8) *EconomicModel

Getting the global EconomicModel single instance

type EconomicModelExtend

type EconomicModelExtend struct {
	Reward      rewardConfigExtend      `json:"reward"`
	Restricting restrictingConfigExtend `json:"restricting"`
}

When the chain is started, if new parameters are added, add them to this structure

func GetEce

func GetEce() *EconomicModelExtend

type Result

type Result struct {
	Code uint32
	Ret  interface{}
}

type StateDB

type StateDB interface {
	CreateAccount(common.Address)

	SubBalance(common.Address, *big.Int)
	AddBalance(common.Address, *big.Int)
	GetBalance(common.Address) *big.Int

	GetNonce(common.Address) uint64
	SetNonce(common.Address, uint64)

	GetCodeHash(common.Address) common.Hash
	GetCode(common.Address) []byte
	SetCode(common.Address, []byte)
	GetCodeSize(common.Address) int

	AddRefund(uint64)
	SubRefund(uint64)
	GetRefund() uint64

	GetCommittedState(common.Address, []byte) []byte
	//GetState(common.Address, common.Hash) common.Hash
	//SetState(common.Address, common.Hash, common.Hash)
	GetState(common.Address, []byte) []byte
	SetState(common.Address, []byte, []byte)

	Suicide(common.Address) bool
	HasSuicided(common.Address) bool

	// Exist reports whether the given account exists in state.
	// Notably this should also return true for suicided accounts.
	Exist(common.Address) bool
	// Empty returns whether the given account is empty. Empty
	// is defined according to EIP161 (balance = nonce = code = 0).
	Empty(common.Address) bool

	RevertToSnapshot(int)
	Snapshot() int

	AddLog(*types.Log)
	AddPreimage(common.Hash, []byte)

	ForEachStorage(common.Address, func([]byte, []byte) bool)

	//ppos add
	TxHash() common.Hash
	TxIdx() uint32

	IntermediateRoot(deleteEmptyObjects bool) common.Hash
}

StateDB is an Plugin database for full state querying.

Jump to

Keyboard shortcuts

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