committeestate

package
v0.0.0-...-7ece11e Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	COMMITTEE_POOL = iota
	PENDING_POOL
	WAITING_POOL
	LOCKING_POOL
)
View Source
const (
	STATE_TEST_VERSION      = 0
	SELF_SWAP_SHARD_VERSION = 1
	STAKING_FLOW_V2         = 2
	STAKING_FLOW_V3         = 3
	STAKING_FLOW_V4         = 4
)
View Source
const (
	ASSIGN_RULE_V1 = 1
	ASSIGN_RULE_V2 = 2
	ASSIGN_RULE_V3 = 3
)
View Source
const (
	ErrSwapInstructionSanity = iota
	ErrStakeInstructionSanity
	ErrStopAutoStakeInstructionSanity
	ErrAssignInstructionSanity
	ErrCommitBeaconCommitteeState
	ErrUpdateCommitteeState
	ErrGenerateBeaconCommitteeStateHash
	ErrCommitShardCommitteeState
	ErrUpdateShardCommitteeState
	ErrGenerateShardCommitteeStateHash
	ErrBuildIncurredInstruction
	ErrUpdateCommitteeStateByBeacon
	ErrNotEnoughReward
)
View Source
const INIT_SHARE_PRICE = 1750 * 1e9

Variables

View Source
var (
	MAX_SWAP_OR_ASSIGN_PERCENT_V2 = 6
	MAX_SLASH_PERCENT_V3          = 3
	MAX_SWAP_OUT_PERCENT_V3       = 8
	MAX_SWAP_IN_PERCENT_V3        = 8
	MAX_ASSIGN_PERCENT_V3         = 8
)
View Source
var ErrCodeMessage = map[int]struct {
	Code    int
	message string
}{
	ErrSwapInstructionSanity:          {-1000, "swap instruction sanity error"},
	ErrStakeInstructionSanity:         {-1001, "stake instruction sanity error"},
	ErrStopAutoStakeInstructionSanity: {-1002, "stop auto stake sanity error"},
	ErrAssignInstructionSanity:        {-1003, "assign sanity error"},

	ErrCommitBeaconCommitteeState:       {-2000, "commit beacon committee state error"},
	ErrUpdateCommitteeState:             {-2001, "update committee state error"},
	ErrGenerateBeaconCommitteeStateHash: {-2002, "generate beacon committee state root hash"},

	ErrCommitShardCommitteeState:       {-3000, "commit shard committee state"},
	ErrUpdateShardCommitteeState:       {-3001, " update shard committee state error"},
	ErrGenerateShardCommitteeStateHash: {-3002, " generate shard committee state root hash"},

	ErrBuildIncurredInstruction: {-4000, "Build Incurred Instruction Error"},

	ErrUpdateCommitteeStateByBeacon: {-5000, "Update Committee State By Beacon Error"},

	ErrNotEnoughReward: {-6000, "Not Enough Reward"},
}
View Source
var Logger = committeeStateLogger{}

Global instant to use

Functions

func DifferentElementStrings

func DifferentElementStrings(src1, src2 []string) []string

DifferentElementStrings : find different elements between 2 strings

func GetKeyStructListFromMapLocking

func GetKeyStructListFromMapLocking(list map[string]*LockingInfo) []incognitokey.CommitteePublicKey

func GetKeyStructListFromMapStaker

func GetKeyStructListFromMapStaker(list map[string]*StakerInfo) []incognitokey.CommitteePublicKey

func NewSwapRuleV2

func NewSwapRuleV2() *swapRuleV2

func NewSwapRuleV3

func NewSwapRuleV3() *swapRuleV3

func ShuffleCandidate

func ShuffleCandidate(candidates []incognitokey.CommitteePublicKey, rand int64) ([]incognitokey.CommitteePublicKey, error)

Shuffle Candidate: suffer unassignedCommonPool with random number and return suffered list Candidate Value Concatenate with Random Number then Hash and Obtain Hash Value Sort Hash Value Then Re-arrange Candidate corresponding to Hash Value

func SnapshotShardCommonPoolV2

func SnapshotShardCommonPoolV2(
	shardCommonPool []string,
	shardCommittee map[byte][]string,
	shardSubstitute map[byte][]string,
	numberOfFixedValidator int,
	minCommitteeSize int,
	swapRule SwapRuleProcessor,
) (numberOfAssignedCandidates int)

func SwapValidator

func SwapValidator(
	pendingValidators []string,
	currentValidators []string,
	maxCommittee int,
	minCommittee int,
	offset int,
	swapOffset int,
) ([]string, []string, []string, []string, error)

SwapValidator consider these list as queue structure unqueue a number of validator out of currentValidators list enqueue a number of validator into currentValidators list <=> unqueue a number of validator out of pendingValidators list return value: #1 remaining pendingValidators, #2 new currentValidators #3 swapped out validator, #4 incoming validator #5 error

func VersionByBeaconHeight

func VersionByBeaconHeight(beaconHeight, stakingV2Height, stakingV3Height uint64) int

VersionByBeaconHeight get version of committee engine by beaconHeight and config of blockchain

Types

type AssignInstructionProcessor

type AssignInstructionProcessor interface {
	ProcessAssignInstructions(env *ShardCommitteeStateEnvironment) []incognitokey.CommitteePublicKey
}

type AssignInstructionsGenerator

type AssignInstructionsGenerator interface {
	GenerateAssignInstructions(env *BeaconCommitteeStateEnvironment) []*instruction.AssignInstruction
}

type AssignRuleProcessor

type AssignRuleProcessor interface {
	Process(candidates []string, numberOfValidators []int, randomNumber int64) map[byte][]string
	Version() int
}

func GetAssignRuleVersion

func GetAssignRuleVersion(beaconHeight, assignRuleV2, assignRuleV3 uint64) AssignRuleProcessor

VersionByBeaconHeight get version of committee engine by beaconHeight and config of blockchain

type AssignRuleV2

type AssignRuleV2 struct {
}

func NewAssignRuleV2

func NewAssignRuleV2() *AssignRuleV2

func (AssignRuleV2) Process

func (AssignRuleV2) Process(candidates []string, numberOfValidators []int, rand int64) map[byte][]string

Process assign unassignedCommonPool into shard pool with random number

func (AssignRuleV2) Version

func (AssignRuleV2) Version() int

type AssignRuleV3

type AssignRuleV3 struct {
}

func NewAssignRuleV3

func NewAssignRuleV3() *AssignRuleV3

func (AssignRuleV3) Process

func (AssignRuleV3) Process(candidates []string, numberOfValidators []int, randomNumber int64) map[byte][]string

func (AssignRuleV3) Version

func (AssignRuleV3) Version() int

type BeaconCommitteeState

type BeaconCommitteeState interface {
	GetAllStaker() (map[byte][]incognitokey.CommitteePublicKey, map[byte][]incognitokey.CommitteePublicKey, map[byte][]incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey, []incognitokey.CommitteePublicKey)
	GetBeaconCommittee() []incognitokey.CommitteePublicKey
	GetBeaconSubstitute() []incognitokey.CommitteePublicKey
	GetBeaconLocking() []incognitokey.CommitteePublicKey
	GetNonSlashingRewardReceiver(staker []incognitokey.CommitteePublicKey) ([]key.PaymentAddress, error)
	GetBeaconWaiting() []incognitokey.CommitteePublicKey
	GetUnsyncBeaconValidator() []incognitokey.CommitteePublicKey
	IsFinishSync(string) bool
	GetCandidateShardWaitingForCurrentRandom() []incognitokey.CommitteePublicKey
	GetCandidateBeaconWaitingForCurrentRandom() []incognitokey.CommitteePublicKey
	GetCandidateBeaconWaitingForNextRandom() []incognitokey.CommitteePublicKey
	GetCandidateShardWaitingForNextRandom() []incognitokey.CommitteePublicKey
	GetOneShardCommittee(shardID byte) []incognitokey.CommitteePublicKey
	GetShardCommittee() map[byte][]incognitokey.CommitteePublicKey
	GetOneShardSubstitute(shardID byte) []incognitokey.CommitteePublicKey
	GetShardSubstitute() map[byte][]incognitokey.CommitteePublicKey
	GetAutoStaking() map[string]bool
	GetStakingTx() map[string]common.Hash
	GetRewardReceiver() map[string]privacy.PaymentAddress
	GetAllCandidateSubstituteCommittee() []string
	GetNumberOfActiveShards() int
	GetBeaconCandidateUID(candidatePK string) (string, error)
	GetShardCommonPool() []incognitokey.CommitteePublicKey
	GetSyncingValidators() map[byte][]incognitokey.CommitteePublicKey

	Version() int
	AssignRuleVersion() int
	Clone(db *statedb.StateDB) BeaconCommitteeState
	UpdateCommitteeState(env *BeaconCommitteeStateEnvironment) (
		*BeaconCommitteeStateHash,
		*CommitteeChange,
		[][]string,
		error)
	Upgrade(*BeaconCommitteeStateEnvironment) BeaconCommitteeState
}

func InitBeaconCommitteeState

func InitBeaconCommitteeState(beaconHeight, stakingFlowV2, stakingFlowV3 uint64,
	env *BeaconCommitteeStateEnvironment) BeaconCommitteeState

func NewBeaconCommitteeState

func NewBeaconCommitteeState(
	stateDB *statedb.StateDB,
	minBeaconCommitteeSize int,
	version int,
	beaconCommittee []incognitokey.CommitteePublicKey,
	shardCommittee map[byte][]incognitokey.CommitteePublicKey,
	shardSubstitute map[byte][]incognitokey.CommitteePublicKey,
	shardCommonPool []incognitokey.CommitteePublicKey,
	numberOfAssignedCandidates int,
	autoStake map[string]bool,
	rewardReceivers map[string]privacy.PaymentAddress,
	stakingTx map[string]common.Hash,
	syncPool map[byte][]incognitokey.CommitteePublicKey,
	swapRule SwapRuleProcessor,
	nextEpochShardCandidate []incognitokey.CommitteePublicKey,
	currentEpochShardCandidate []incognitokey.CommitteePublicKey,
	assignRule AssignRuleProcessor,
	allBeaconBlocks []types.BeaconBlock,
) BeaconCommitteeState

NewBeaconCommitteeState constructor for BeaconCommitteeState by version

type BeaconCommitteeStateEnvironment

type BeaconCommitteeStateEnvironment struct {
	BlockChain                BlockChain
	EpochLengthV1             uint64
	BeaconHeight              uint64
	Epoch                     uint64
	BeaconHeader              types.BeaconHeader
	BeaconInstructions        [][]string
	BeaconHash                common.Hash
	BestShardHash             map[byte]common.Hash
	EpochBreakPointSwapNewKey []uint64
	RandomNumber              int64
	IsFoundRandomNumber       bool
	IsBeaconRandomTime        bool
	AssignOffset              int
	DefaultOffset             int
	SwapOffset                int
	ActiveShards              int
	MinShardCommitteeSize     int
	MinBeaconCommitteeSize    int
	MaxBeaconCommitteeSize    int
	MaxShardCommitteeSize     int
	ConsensusStateDB          *statedb.StateDB
	IsReplace                 bool

	LatestShardsState                map[byte][]types.ShardState
	SwapSubType                      uint
	ShardID                          byte
	TotalReward                      map[common.Hash]uint64
	IsSplitRewardForCustodian        bool
	PercentCustodianReward           uint64
	DAOPercent                       int
	NumberOfFixedShardBlockValidator int
	MissingSignaturePenalty          map[string]signaturecounter.Penalty
	MissingSignature                 map[string]signaturecounter.MissingSignature
	StakingV2Height                  uint64
	AssignRuleV3Height               uint64
	StakingV3Height                  uint64

	PreviousBlockHashes *BeaconCommitteeStateHash
	TriggeredFeature    map[string]uint64
	// contains filtered or unexported fields
}

func NewBeaconCommitteeStateEnvironmentForAssigningToPendingList

func NewBeaconCommitteeStateEnvironmentForAssigningToPendingList(randomNumber int64, assignOffset int, beaconHeight uint64) *BeaconCommitteeStateEnvironment

type BeaconCommitteeStateHash

type BeaconCommitteeStateHash struct {
	BeaconCommitteeAndValidatorHash common.Hash
	BeaconCandidateHash             common.Hash
	ShardSyncValidatorsHash         common.Hash
	ShardCandidateHash              common.Hash
	ShardCommitteeAndValidatorHash  common.Hash
	AutoStakeHash                   common.Hash
}

func NewBeaconCommitteeStateHash

func NewBeaconCommitteeStateHash() *BeaconCommitteeStateHash

type BeaconCommitteeStateV1

type BeaconCommitteeStateV1 struct {
	// contains filtered or unexported fields
}

func NewBeaconCommitteeStateV1

func NewBeaconCommitteeStateV1() *BeaconCommitteeStateV1

func NewBeaconCommitteeStateV1WithValue

func NewBeaconCommitteeStateV1WithValue(
	beaconCommittee []string,
	nextEpochShardCandidate []string,
	currentEpochShardCandidate []string,
	shardCurrentValidator map[byte][]string,
	shardSubstituteValidator map[byte][]string,
	autoStaking map[string]bool,
	rewardReceivers map[string]privacy.PaymentAddress,
	stakingTx map[string]common.Hash,
) *BeaconCommitteeStateV1

func (*BeaconCommitteeStateV1) AssignRuleVersion

func (b *BeaconCommitteeStateV1) AssignRuleVersion() int

func (*BeaconCommitteeStateV1) Clone

func (*BeaconCommitteeStateV1) GenerateAssignInstructions

func (BeaconCommitteeStateV1) GenerateRandomInstructions

func (b BeaconCommitteeStateV1) GenerateRandomInstructions(env *BeaconCommitteeStateEnvironment) (*instruction.RandomInstruction, int64)

func (BeaconCommitteeStateV1) GetAllCandidateSubstituteCommittee

func (b BeaconCommitteeStateV1) GetAllCandidateSubstituteCommittee() []string

func (BeaconCommitteeStateV1) GetAutoStaking

func (b BeaconCommitteeStateV1) GetAutoStaking() map[string]bool

func (*BeaconCommitteeStateV1) GetBeaconCandidateUID

func (b *BeaconCommitteeStateV1) GetBeaconCandidateUID(cPK string) (string, error)

func (BeaconCommitteeStateV1) GetBeaconCommittee

func (b BeaconCommitteeStateV1) GetBeaconCommittee() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetBeaconLocking

func (b BeaconCommitteeStateV1) GetBeaconLocking() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetBeaconSubstitute

func (b BeaconCommitteeStateV1) GetBeaconSubstitute() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetBeaconWaiting

func (b BeaconCommitteeStateV1) GetBeaconWaiting() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetCandidateBeaconWaitingForCurrentRandom

func (b BeaconCommitteeStateV1) GetCandidateBeaconWaitingForCurrentRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetCandidateBeaconWaitingForNextRandom

func (b BeaconCommitteeStateV1) GetCandidateBeaconWaitingForNextRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetCandidateShardWaitingForCurrentRandom

func (b BeaconCommitteeStateV1) GetCandidateShardWaitingForCurrentRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetCandidateShardWaitingForNextRandom

func (b BeaconCommitteeStateV1) GetCandidateShardWaitingForNextRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetNonSlashingRewardReceiver

func (b BeaconCommitteeStateV1) GetNonSlashingRewardReceiver(staker []incognitokey.CommitteePublicKey) ([]key.PaymentAddress, error)

func (*BeaconCommitteeStateV1) GetNumberOfActiveShards

func (b *BeaconCommitteeStateV1) GetNumberOfActiveShards() int

func (BeaconCommitteeStateV1) GetOneShardCommittee

func (b BeaconCommitteeStateV1) GetOneShardCommittee(shardID byte) []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetOneShardSubstitute

func (b BeaconCommitteeStateV1) GetOneShardSubstitute(shardID byte) []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetRewardReceiver

func (b BeaconCommitteeStateV1) GetRewardReceiver() map[string]privacy.PaymentAddress

func (BeaconCommitteeStateV1) GetShardCommittee

func (b BeaconCommitteeStateV1) GetShardCommittee() map[byte][]incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetShardCommonPool

func (b BeaconCommitteeStateV1) GetShardCommonPool() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetShardSubstitute

func (b BeaconCommitteeStateV1) GetShardSubstitute() map[byte][]incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetStakingTx

func (b BeaconCommitteeStateV1) GetStakingTx() map[string]common.Hash

func (BeaconCommitteeStateV1) GetSyncingValidators

func (b BeaconCommitteeStateV1) GetSyncingValidators() map[byte][]incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV1) GetUnsyncBeaconValidator

func (b BeaconCommitteeStateV1) GetUnsyncBeaconValidator() []incognitokey.CommitteePublicKey

func (*BeaconCommitteeStateV1) Hash

func (BeaconCommitteeStateV1) IsFinishSync

func (b BeaconCommitteeStateV1) IsFinishSync(string) bool

func (*BeaconCommitteeStateV1) UpdateCommitteeState

UpdateCommitteeState :

func (*BeaconCommitteeStateV1) Upgrade

Upgrade check interface method for des

func (*BeaconCommitteeStateV1) Version

func (b *BeaconCommitteeStateV1) Version() int

type BeaconCommitteeStateV2

type BeaconCommitteeStateV2 struct {
	// contains filtered or unexported fields
}

func NewBeaconCommitteeStateV2

func NewBeaconCommitteeStateV2() *BeaconCommitteeStateV2

func NewBeaconCommitteeStateV2WithMu

func NewBeaconCommitteeStateV2WithMu(mu *sync.RWMutex) *BeaconCommitteeStateV2

func NewBeaconCommitteeStateV2WithValue

func NewBeaconCommitteeStateV2WithValue(
	beaconCommittee []string,
	shardCommittee map[byte][]string,
	shardSubstitute map[byte][]string,
	shardCommonPool []string,
	numberOfAssignedCandidates int,
	autoStake map[string]bool,
	rewardReceiver map[string]privacy.PaymentAddress,
	stakingTx map[string]common.Hash,
	swapRule SwapRuleProcessor,
	assignRule AssignRuleProcessor,
) *BeaconCommitteeStateV2

func (BeaconCommitteeStateV2) AssignRuleVersion

func (b BeaconCommitteeStateV2) AssignRuleVersion() int

func (*BeaconCommitteeStateV2) Clone

func (*BeaconCommitteeStateV2) GenerateSwapShardInstructions

func (b *BeaconCommitteeStateV2) GenerateSwapShardInstructions(
	env *BeaconCommitteeStateEnvironment) (
	[]*instruction.SwapShardInstruction, error)

func (BeaconCommitteeStateV2) GetAllCandidateSubstituteCommittee

func (b BeaconCommitteeStateV2) GetAllCandidateSubstituteCommittee() []string

func (BeaconCommitteeStateV2) GetCandidateShardWaitingForCurrentRandom

func (b BeaconCommitteeStateV2) GetCandidateShardWaitingForCurrentRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV2) GetCandidateShardWaitingForNextRandom

func (b BeaconCommitteeStateV2) GetCandidateShardWaitingForNextRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV2) GetShardCommonPool

func (b BeaconCommitteeStateV2) GetShardCommonPool() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV2) Hash

func (b BeaconCommitteeStateV2) Hash(committeeChange *CommitteeChange) (*BeaconCommitteeStateHash, error)

func (BeaconCommitteeStateV2) IsFinishSync

func (b BeaconCommitteeStateV2) IsFinishSync(string) bool

func (*BeaconCommitteeStateV2) UpdateCommitteeState

UpdateCommitteeState New flow Store information from instructions into temp stateDB in env When all thing done and no problems, in commit function, we read data in statedb and update

func (*BeaconCommitteeStateV2) Upgrade

Upgrade check interface method for des

func (*BeaconCommitteeStateV2) UpgradeAssignRuleV3

func (b *BeaconCommitteeStateV2) UpgradeAssignRuleV3()

func (*BeaconCommitteeStateV2) Version

func (b *BeaconCommitteeStateV2) Version() int

Version :

type BeaconCommitteeStateV3

type BeaconCommitteeStateV3 struct {
	// contains filtered or unexported fields
}

func NewBeaconCommitteeStateV3

func NewBeaconCommitteeStateV3() *BeaconCommitteeStateV3

func NewBeaconCommitteeStateV3WithValue

func NewBeaconCommitteeStateV3WithValue(
	beaconCommittee []string,
	shardCommittee map[byte][]string,
	shardSubstitute map[byte][]string,
	shardCommonPool []string,
	numberOfAssignedCandidates int,
	autoStake map[string]bool,
	rewardReceiver map[string]privacy.PaymentAddress,
	stakingTx map[string]common.Hash,
	syncPool map[byte][]string,
	swapRule SwapRuleProcessor,
	assignRule AssignRuleProcessor,
) *BeaconCommitteeStateV3

func (*BeaconCommitteeStateV3) AllSyncingValidators

func (b *BeaconCommitteeStateV3) AllSyncingValidators() []string

func (BeaconCommitteeStateV3) AssignRuleVersion

func (b BeaconCommitteeStateV3) AssignRuleVersion() int

func (*BeaconCommitteeStateV3) Clone

func (*BeaconCommitteeStateV3) GenerateSwapShardInstructions

func (b *BeaconCommitteeStateV3) GenerateSwapShardInstructions(
	env *BeaconCommitteeStateEnvironment) (
	[]*instruction.SwapShardInstruction, error)

func (*BeaconCommitteeStateV3) GetAllCandidateSubstituteCommittee

func (b *BeaconCommitteeStateV3) GetAllCandidateSubstituteCommittee() []string

func (BeaconCommitteeStateV3) GetCandidateShardWaitingForCurrentRandom

func (b BeaconCommitteeStateV3) GetCandidateShardWaitingForCurrentRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV3) GetCandidateShardWaitingForNextRandom

func (b BeaconCommitteeStateV3) GetCandidateShardWaitingForNextRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV3) GetShardCommonPool

func (b BeaconCommitteeStateV3) GetShardCommonPool() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV3) GetSyncingValidators

func (b BeaconCommitteeStateV3) GetSyncingValidators() map[byte][]incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV3) Hash

func (BeaconCommitteeStateV3) IsFinishSync

func (b BeaconCommitteeStateV3) IsFinishSync(string) bool

func (*BeaconCommitteeStateV3) UpdateCommitteeState

func (*BeaconCommitteeStateV3) Upgrade

func (*BeaconCommitteeStateV3) Version

func (b *BeaconCommitteeStateV3) Version() int

type BeaconCommitteeStateV4

type BeaconCommitteeStateV4 struct {
	*BeaconCommitteeStateV3
	// contains filtered or unexported fields
}

func NewBeaconCommitteeStateV4

func NewBeaconCommitteeStateV4() *BeaconCommitteeStateV4

func NewBeaconCommitteeStateV4WithValue

func NewBeaconCommitteeStateV4WithValue(
	shardCommittee map[byte][]string,
	shardSubstitute map[byte][]string,
	shardCommonPool []string,
	numberOfAssignedCandidates int,
	autoStake map[string]bool,
	rewardReceiver map[string]privacy.PaymentAddress,
	stakingTx map[string]common.Hash,
	syncPool map[byte][]string,
	swapRule SwapRuleProcessor,
	assignRule AssignRuleProcessor,
) *BeaconCommitteeStateV4

func (BeaconCommitteeStateV4) AssignRuleVersion

func (b BeaconCommitteeStateV4) AssignRuleVersion() int

func (*BeaconCommitteeStateV4) Clone

Review Should we use get/set for newState.stateDB?

func (BeaconCommitteeStateV4) DebugBeaconCommitteeState

func (s BeaconCommitteeStateV4) DebugBeaconCommitteeState() *StateDataDetail

func (BeaconCommitteeStateV4) GenerateSwapShardInstructions

func (b BeaconCommitteeStateV4) GenerateSwapShardInstructions(
	env *BeaconCommitteeStateEnvironment) (
	[]*instruction.SwapShardInstruction, error)

func (*BeaconCommitteeStateV4) GetAllCandidateSubstituteCommittee

func (s *BeaconCommitteeStateV4) GetAllCandidateSubstituteCommittee() []string

func (*BeaconCommitteeStateV4) GetBeaconCandidateUID

func (s *BeaconCommitteeStateV4) GetBeaconCandidateUID(cpk string) (string, error)

func (*BeaconCommitteeStateV4) GetBeaconCommittee

func (s *BeaconCommitteeStateV4) GetBeaconCommittee() []incognitokey.CommitteePublicKey

func (*BeaconCommitteeStateV4) GetBeaconLocking

func (s *BeaconCommitteeStateV4) GetBeaconLocking() []incognitokey.CommitteePublicKey

func (*BeaconCommitteeStateV4) GetBeaconSubstitute

func (s *BeaconCommitteeStateV4) GetBeaconSubstitute() []incognitokey.CommitteePublicKey

func (*BeaconCommitteeStateV4) GetBeaconWaiting

func (s *BeaconCommitteeStateV4) GetBeaconWaiting() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV4) GetCandidateShardWaitingForCurrentRandom

func (b BeaconCommitteeStateV4) GetCandidateShardWaitingForCurrentRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV4) GetCandidateShardWaitingForNextRandom

func (b BeaconCommitteeStateV4) GetCandidateShardWaitingForNextRandom() []incognitokey.CommitteePublicKey

func (BeaconCommitteeStateV4) GetConfig

func (*BeaconCommitteeStateV4) GetNonSlashingRewardReceiver

func (s *BeaconCommitteeStateV4) GetNonSlashingRewardReceiver(staker []incognitokey.CommitteePublicKey) ([]key.PaymentAddress, error)

func (BeaconCommitteeStateV4) GetShardCommonPool

func (b BeaconCommitteeStateV4) GetShardCommonPool() []incognitokey.CommitteePublicKey

func (*BeaconCommitteeStateV4) GetUnsyncBeaconValidator

func (s *BeaconCommitteeStateV4) GetUnsyncBeaconValidator() []incognitokey.CommitteePublicKey

result is not consistent

func (BeaconCommitteeStateV4) IsFinishSync

func (s BeaconCommitteeStateV4) IsFinishSync(key string) bool

func (*BeaconCommitteeStateV4) ProcessBeaconAddStakingAmountInstruction

func (s *BeaconCommitteeStateV4) ProcessBeaconAddStakingAmountInstruction(env ProcessContext) ([][]string, error)

Process add stake amount

func (*BeaconCommitteeStateV4) ProcessBeaconFinishSyncInstruction

func (s *BeaconCommitteeStateV4) ProcessBeaconFinishSyncInstruction(env ProcessContext) ([][]string, error)

func (*BeaconCommitteeStateV4) ProcessBeaconRedelegateInstruction

func (s *BeaconCommitteeStateV4) ProcessBeaconRedelegateInstruction(env ProcessContext) ([][]string, error)

Process add stake amount

func (*BeaconCommitteeStateV4) ProcessBeaconSharePrice

func (s *BeaconCommitteeStateV4) ProcessBeaconSharePrice(env ProcessContext) ([][]string, error)

func (*BeaconCommitteeStateV4) ProcessBeaconStakeInstruction

func (s *BeaconCommitteeStateV4) ProcessBeaconStakeInstruction(env ProcessContext) ([][]string, error)

Process stake instruction -> update waiting -> store beacon staker info

func (*BeaconCommitteeStateV4) ProcessBeaconSwapAndSlash

func (s *BeaconCommitteeStateV4) ProcessBeaconSwapAndSlash(env ProcessContext) ([][]string, error)

Process slash, unstake and swap

func (*BeaconCommitteeStateV4) ProcessBeaconUnlocking

func (s *BeaconCommitteeStateV4) ProcessBeaconUnlocking(env ProcessContext) ([][]string, error)

Process return staking amount (unlocking)

func (*BeaconCommitteeStateV4) ProcessBeaconUnstakeInstruction

func (s *BeaconCommitteeStateV4) ProcessBeaconUnstakeInstruction(env ProcessContext) ([][]string, error)

func (*BeaconCommitteeStateV4) ProcessBeaconWaitingCondition

func (s *BeaconCommitteeStateV4) ProcessBeaconWaitingCondition(env ProcessContext) ([][]string, error)

Process assign beacon pending (sync, sync valid time)

func (*BeaconCommitteeStateV4) ProcessCountShardActiveTime

func (s *BeaconCommitteeStateV4) ProcessCountShardActiveTime(env ProcessContext) ([][]string, error)

Process shard active time

func (*BeaconCommitteeStateV4) ProcessDelegateRewardForReturnValidator

func (s *BeaconCommitteeStateV4) ProcessDelegateRewardForReturnValidator(env ProcessContext) ([][]string, error)

when validator return staking, it will end its delegation reward also update delegator number for the delegated beacon

func (*BeaconCommitteeStateV4) ProcessUpdateBeaconPerformance

func (s *BeaconCommitteeStateV4) ProcessUpdateBeaconPerformance(env ProcessContext) ([][]string, error)

func (*BeaconCommitteeStateV4) ProcessWithdrawDelegationReward

func (s *BeaconCommitteeStateV4) ProcessWithdrawDelegationReward(env ProcessContext) ([][]string, error)

func (*BeaconCommitteeStateV4) RestoreBeaconCommitteeFromDB

func (s *BeaconCommitteeStateV4) RestoreBeaconCommitteeFromDB(stateDB *statedb.StateDB, minBeaconCommitteeSize int, allBeaconBlock []types.BeaconBlock) error

func (*BeaconCommitteeStateV4) UpdateCommitteeState

func (*BeaconCommitteeStateV4) UpgradeFromV3

func (s *BeaconCommitteeStateV4) UpgradeFromV3(stateV3 *BeaconCommitteeStateV3, stateDB *statedb.StateDB, minBeaconCommitteeSize int) error

func (*BeaconCommitteeStateV4) Version

func (s *BeaconCommitteeStateV4) Version() int

type BeaconCommitteeStateV4Config

type BeaconCommitteeStateV4Config struct {
	MAX_SCORE             uint64
	MIN_SCORE             uint64
	DEFAULT_PERFORMING    uint64
	INCREASE_PERFORMING   uint64
	DECREASE_PERFORMING   uint64
	MIN_ACTIVE_SHARD      int
	MIN_WAITING_PERIOD    int64
	MIN_PERFORMANCE       uint64
	LOCKING_PERIOD        uint64
	LOCKING_FACTOR        float64
	BEACON_COMMITTEE_SIZE int
}

must trigger version for new config

func NewBeaconCommitteeStateV4Config

func NewBeaconCommitteeStateV4Config(version int) BeaconCommitteeStateV4Config

type BlockChain

type BlockChain interface {
	GetDelegationRewardAmount(stateDB *statedb.StateDB, pk key.PublicKey) (uint64, error)
}

type CandidateInfoV1

type CandidateInfoV1 struct {
	// contains filtered or unexported fields
}

type CommitteeChange

type CommitteeChange struct {
	NextEpochBeaconCandidateAdded      []incognitokey.CommitteePublicKey
	NextEpochBeaconCandidateRemoved    []incognitokey.CommitteePublicKey
	CurrentEpochBeaconCandidateAdded   []incognitokey.CommitteePublicKey
	CurrentEpochBeaconCandidateRemoved []incognitokey.CommitteePublicKey
	NextEpochShardCandidateAdded       []incognitokey.CommitteePublicKey
	NextEpochShardCandidateRemoved     []incognitokey.CommitteePublicKey
	CurrentEpochShardCandidateAdded    []incognitokey.CommitteePublicKey
	CurrentEpochShardCandidateRemoved  []incognitokey.CommitteePublicKey
	ShardSubstituteAdded               map[byte][]incognitokey.CommitteePublicKey
	ShardSubstituteRemoved             map[byte][]incognitokey.CommitteePublicKey
	SyncingPoolAdded                   map[byte][]incognitokey.CommitteePublicKey
	SyncingPoolRemoved                 map[byte][]incognitokey.CommitteePublicKey
	ShardCommitteeAdded                map[byte][]incognitokey.CommitteePublicKey
	ShardCommitteeRemoved              map[byte][]incognitokey.CommitteePublicKey
	BeaconSubstituteAdded              []incognitokey.CommitteePublicKey
	BeaconSubstituteRemoved            []incognitokey.CommitteePublicKey
	BeaconCommitteeAdded               []incognitokey.CommitteePublicKey
	BeaconCommitteeRemoved             []incognitokey.CommitteePublicKey
	BeaconCommitteeReplaced            [2][]incognitokey.CommitteePublicKey
	ShardCommitteeReplaced             map[byte][2][]incognitokey.CommitteePublicKey
	StopAutoStake                      []string
	RemovedStaker                      []string
	FinishedSyncValidators             map[byte][]string
	SlashingCommittee                  map[byte][]string
}

func NewCommitteeChange

func NewCommitteeChange() *CommitteeChange

func (*CommitteeChange) AddFinishedSyncValidators

func (committeeChange *CommitteeChange) AddFinishedSyncValidators(shardID byte, finishedSyncValidators []string) *CommitteeChange

func (*CommitteeChange) AddNextEpochShardCandidateAdded

func (committeeChange *CommitteeChange) AddNextEpochShardCandidateAdded(nextEpochShardCandidateAdded []string) *CommitteeChange

func (*CommitteeChange) AddNextEpochShardCandidateRemoved

func (committeeChange *CommitteeChange) AddNextEpochShardCandidateRemoved(nextEpochShardCandidateRemoved []string) *CommitteeChange

func (*CommitteeChange) AddRemovedStaker

func (committeeChange *CommitteeChange) AddRemovedStaker(removedStaker string) *CommitteeChange

func (*CommitteeChange) AddRemovedStakers

func (committeeChange *CommitteeChange) AddRemovedStakers(removedStakers []string) *CommitteeChange

func (*CommitteeChange) AddShardCommitteeAdded

func (committeeChange *CommitteeChange) AddShardCommitteeAdded(shardID byte, shardCommitteeAdded []string) *CommitteeChange

func (*CommitteeChange) AddShardCommitteeRemoved

func (committeeChange *CommitteeChange) AddShardCommitteeRemoved(shardID byte, ShardCommitteeRemoved []string) *CommitteeChange

func (*CommitteeChange) AddShardSubstituteAdded

func (committeeChange *CommitteeChange) AddShardSubstituteAdded(shardID byte, shardSubstituteAdded []string) *CommitteeChange

func (*CommitteeChange) AddShardSubstituteRemoved

func (committeeChange *CommitteeChange) AddShardSubstituteRemoved(shardID byte, shardSubstituteRemoved []string) *CommitteeChange

func (*CommitteeChange) AddSlashingCommittees

func (committeeChange *CommitteeChange) AddSlashingCommittees(shardID byte, slashingVaidators []string) *CommitteeChange

func (*CommitteeChange) AddStopAutoStake

func (committeeChange *CommitteeChange) AddStopAutoStake(stopAutoStake string) *CommitteeChange

func (*CommitteeChange) AddStopAutoStakes

func (committeeChange *CommitteeChange) AddStopAutoStakes(stopAutoStakes []string) *CommitteeChange

func (*CommitteeChange) AddSyncingPoolAdded

func (committeeChange *CommitteeChange) AddSyncingPoolAdded(shardID byte, syncingPoolAdded []string) *CommitteeChange

func (*CommitteeChange) AddSyncingPoolRemoved

func (committeeChange *CommitteeChange) AddSyncingPoolRemoved(shardID byte, syncingPoolRemoved []string) *CommitteeChange

func (*CommitteeChange) IsShardCommitteeChange

func (committeeChange *CommitteeChange) IsShardCommitteeChange() bool

func (*CommitteeChange) RemovedStakers

func (committeeChange *CommitteeChange) RemovedStakers() []incognitokey.CommitteePublicKey

func (*CommitteeChange) StakerKeys

func (committeeChange *CommitteeChange) StakerKeys() []incognitokey.CommitteePublicKey

GetStakerKeys ...

func (*CommitteeChange) StopAutoStakeKeys

func (committeeChange *CommitteeChange) StopAutoStakeKeys() []incognitokey.CommitteePublicKey

type CommitteeStateError

type CommitteeStateError struct {
	Code    int
	Message string
	// contains filtered or unexported fields
}

func NewCommitteeStateError

func NewCommitteeStateError(key int, err error) *CommitteeStateError

func (CommitteeStateError) Error

func (e CommitteeStateError) Error() string

type LockingInfo

type LockingInfo struct {
	LockingEpoch  uint64
	LockingReason int
	// contains filtered or unexported fields
}

type LockingInfoDetail

type LockingInfoDetail struct {
	CPK           string
	StakeTime     int64
	PoolEnterTime int64
	LockingEpoch  uint64
	LockingReason int
	ReleaseEpoch  uint64
	ReleaseAmount uint64
}

type NilAssignRule

type NilAssignRule struct {
}

func NewNilAssignRule

func NewNilAssignRule() *NilAssignRule

func (NilAssignRule) Process

func (a NilAssignRule) Process(candidates []string, numberOfValidators []int, randomNumber int64) map[byte][]string

func (NilAssignRule) Version

func (a NilAssignRule) Version() int

type ProcessContext

type ProcessContext struct {
	*BeaconCommitteeStateEnvironment
	RemovedStaker []string
}

type RandomInstructionsGenerator

type RandomInstructionsGenerator interface {
	GenerateRandomInstructions(env *BeaconCommitteeStateEnvironment) (*instruction.RandomInstruction, int64)
}

type RewardSplitRuleV1

type RewardSplitRuleV1 struct{}

func (RewardSplitRuleV1) SplitReward

type RewardSplitRuleV2

type RewardSplitRuleV2 struct{}

func (RewardSplitRuleV2) SplitReward

type RewardSplitRuleV3

type RewardSplitRuleV3 struct {
}

func (RewardSplitRuleV3) SplitReward

type ShardCommitteeState

type ShardCommitteeState interface {
	Version() int
	Clone() ShardCommitteeState
	GetShardCommittee() []incognitokey.CommitteePublicKey
	GetShardSubstitute() []incognitokey.CommitteePublicKey

	UpdateCommitteeState(env *ShardCommitteeStateEnvironment) (*ShardCommitteeStateHash,
		*CommitteeChange, error)

	BuildTotalTxsFeeFromTxs(txs []metadata.Transaction) map[common.Hash]uint64
}

ShardCommitteeState :

func InitGenesisShardCommitteeState

func InitGenesisShardCommitteeState(beaconHeight, stakingFlowV2, stakingFlowV3 uint64,
	env *ShardCommitteeStateEnvironment) ShardCommitteeState

type ShardCommitteeStateEnvironment

type ShardCommitteeStateEnvironment struct {
	ShardHeight                  uint64
	ShardBlockHash               common.Hash
	GenesisBeaconHash            common.Hash
	ShardInstructions            [][]string
	BeaconInstructions           [][]string
	Txs                          []metadata.Transaction
	BeaconHeight                 uint64
	Epoch                        uint64
	EpochBreakPointSwapNewKey    []uint64
	ShardID                      byte
	MaxShardCommitteeSize        int
	MinShardCommitteeSize        int
	Offset                       int
	SwapOffset                   int
	StakingTx                    map[string]string
	NumberOfFixedBlockValidators int
	CommitteesFromBlock          common.Hash
	CommitteesFromBeaconView     []string
}

ShardCommitteeStateEnvironment :

func NewShardCommitteeStateEnvironmentForAssignInstruction

func NewShardCommitteeStateEnvironmentForAssignInstruction(
	beaconInstructions [][]string,
	shardID byte,
	numberOfFixedBlockValidators int,
	shardHeight uint64) *ShardCommitteeStateEnvironment

func NewShardCommitteeStateEnvironmentForSwapInstruction

func NewShardCommitteeStateEnvironmentForSwapInstruction(
	shardHeight uint64,
	shardID byte,
	maxShardCommitteeSize int,
	minShardCommitteeSize int,
	offset int, swapOffset int,
	numberOfFixedBlockValidators int) *ShardCommitteeStateEnvironment

type ShardCommitteeStateHash

type ShardCommitteeStateHash struct {
	ShardCommitteeHash        common.Hash
	ShardSubstituteHash       common.Hash
	CommitteeFromBlock        common.Hash
	SubsetCommitteesFromBlock common.Hash
}

ShardCommitteeStateHash

type ShardCommitteeStateV1

type ShardCommitteeStateV1 struct {
	// contains filtered or unexported fields
}

ShardCommitteeStateV1

func NewShardCommitteeStateV1

func NewShardCommitteeStateV1() *ShardCommitteeStateV1

NewShardCommitteeStateV1 is default constructor for ShardCommitteeStateV1 ... Output: pointer of ShardCommitteeStateV1 struct

func NewShardCommitteeStateV1WithValue

func NewShardCommitteeStateV1WithValue(shardCommittee, shardSubstitute []incognitokey.CommitteePublicKey) *ShardCommitteeStateV1

NewShardCommitteeStateV1WithValue is constructor for ShardCommitteeStateV1 with value Output: pointer of ShardCommitteeStateV1 struct with value

func (ShardCommitteeStateV1) BuildTotalTxsFeeFromTxs

func (s ShardCommitteeStateV1) BuildTotalTxsFeeFromTxs(txs []metadata.Transaction) map[common.Hash]uint64

func (*ShardCommitteeStateV1) Clone

Clone ...

func (*ShardCommitteeStateV1) GenerateSwapInstructions

func (*ShardCommitteeStateV1) GetShardCommittee

func (s *ShardCommitteeStateV1) GetShardCommittee() []incognitokey.CommitteePublicKey

GetShardCommittee get shard committees

func (*ShardCommitteeStateV1) GetShardSubstitute

func (s *ShardCommitteeStateV1) GetShardSubstitute() []incognitokey.CommitteePublicKey

GetShardSubstitute get shard pending validators

func (ShardCommitteeStateV1) ProcessAssignInstructions

ProcessInstructionFromBeacon : process instrucction from beacon

func (*ShardCommitteeStateV1) SubsetCommitteesFromBlock

func (s *ShardCommitteeStateV1) SubsetCommitteesFromBlock() common.Hash

func (*ShardCommitteeStateV1) UpdateCommitteeState

UpdateCommitteeState update committeState from valid data before

  • call process instructions from beacon
  • check conditions for epoch timestamp
  • process shard block instructions for key
  • process shard block instructions normally
  • hash for checking commit later
  • Only call once in new or insert block process

func (*ShardCommitteeStateV1) Version

func (s *ShardCommitteeStateV1) Version() int

Version get version of engine

type ShardCommitteeStateV2

type ShardCommitteeStateV2 struct {
	// contains filtered or unexported fields
}

ShardCommitteeStateV2

func NewShardCommitteeStateV2

func NewShardCommitteeStateV2() *ShardCommitteeStateV2

NewShardCommitteeStateV2 is default constructor for ShardCommitteeStateV2 ... Output: pointer of ShardCommitteeStateV2 struct

func NewShardCommitteeStateV2WithValue

func NewShardCommitteeStateV2WithValue(
	shardCommittee []incognitokey.CommitteePublicKey,
) *ShardCommitteeStateV2

NewShardCommitteeStateV2WithValue is constructor for ShardCommitteeStateV2 with value Output: pointer of ShardCommitteeStateV2 struct with value

func (ShardCommitteeStateV2) BuildTotalTxsFeeFromTxs

func (s ShardCommitteeStateV2) BuildTotalTxsFeeFromTxs(txs []metadata.Transaction) map[common.Hash]uint64

func (*ShardCommitteeStateV2) Clone

Clone ...

func (*ShardCommitteeStateV2) GetShardCommittee

func (s *ShardCommitteeStateV2) GetShardCommittee() []incognitokey.CommitteePublicKey

GetShardCommittee get shard committees

func (*ShardCommitteeStateV2) GetShardSubstitute

func (s *ShardCommitteeStateV2) GetShardSubstitute() []incognitokey.CommitteePublicKey

GetShardSubstitute get shard pending validators

func (*ShardCommitteeStateV2) UpdateCommitteeState

UpdateCommitteeState update committeState from valid data before

  • call process instructions from beacon
  • check conditions for epoch timestamp
  • process shard block instructions for key
  • process shard block instructions normally
  • hash for checking commit later
  • Only call once in new or insert block process

func (*ShardCommitteeStateV2) Version

func (s *ShardCommitteeStateV2) Version() int

Version ...

type ShardCommitteeStateV3

type ShardCommitteeStateV3 struct {
	ShardCommitteeStateV2
}

func NewShardCommitteeStateV3

func NewShardCommitteeStateV3() *ShardCommitteeStateV3

NewShardCommitteeStateV3 is default constructor for ShardCommitteeStateV3 ... Output: pointer of ShardCommitteeStateV3 struct

func NewShardCommitteeStateV3WithValue

func NewShardCommitteeStateV3WithValue(
	shardCommittee []incognitokey.CommitteePublicKey,
) *ShardCommitteeStateV3

NewShardCommitteeStateV3WithValue is constructor for ShardCommitteeStateV3 with value Output: pointer of ShardCommitteeStateV3 struct with value

func (*ShardCommitteeStateV3) BuildTotalTxsFeeFromTxs

func (s *ShardCommitteeStateV3) BuildTotalTxsFeeFromTxs(txs []metadata.Transaction) map[common.Hash]uint64

func (ShardCommitteeStateV3) Clone

func (ShardCommitteeStateV3) GetShardCommittee

func (s ShardCommitteeStateV3) GetShardCommittee() []incognitokey.CommitteePublicKey

func (ShardCommitteeStateV3) GetShardSubstitute

func (s ShardCommitteeStateV3) GetShardSubstitute() []incognitokey.CommitteePublicKey

func (*ShardCommitteeStateV3) UpdateCommitteeState

func (ShardCommitteeStateV3) Version

func (s ShardCommitteeStateV3) Version() int

type SplitRewardEnvironment

type SplitRewardEnvironment struct {
	ShardID                   byte
	SubsetID                  byte
	BeaconHeight              uint64
	TotalReward               map[common.Hash]uint64
	IsSplitRewardForCustodian bool
	PercentCustodianReward    uint64
	DAOPercent                int
	ActiveShards              int
	MaxSubsetCommittees       byte
	BeaconCommittee           []incognitokey.CommitteePublicKey
	ShardCommittee            map[byte][]incognitokey.CommitteePublicKey
}

func NewSplitRewardEnvironmentMultiset

func NewSplitRewardEnvironmentMultiset(
	shardID, subsetID, maxSubsetsCommittee byte, beaconHeight uint64,
	totalReward map[common.Hash]uint64,
	isSplitRewardForCustodian bool,
	percentCustodianReward uint64,
	DAOPercent int,
	beaconCommittee []incognitokey.CommitteePublicKey,
	shardCommittee map[byte][]incognitokey.CommitteePublicKey,
) *SplitRewardEnvironment

func NewSplitRewardEnvironmentV1

func NewSplitRewardEnvironmentV1(
	shardID byte,
	beaconHeight uint64,
	totalReward map[common.Hash]uint64,
	isSplitRewardForCustodian bool,
	percentCustodianReward uint64,
	DAOPercent int,
	activeShards int,
	beaconCommittee []incognitokey.CommitteePublicKey,
	shardCommittee map[byte][]incognitokey.CommitteePublicKey,
) *SplitRewardEnvironment

type SplitRewardRuleProcessor

type SplitRewardRuleProcessor interface {
	SplitReward(environment *SplitRewardEnvironment) (map[common.Hash]uint64, map[common.Hash]uint64, map[common.Hash]uint64, map[common.Hash]uint64, error)
}

func GetRewardSplitRule

func GetRewardSplitRule(blockVersion int) SplitRewardRuleProcessor

type StakerInfo

type StakerInfo struct {
	CPK           string
	StakingAmount uint64
	Unstake       bool
	Performance   uint64
	EpochScore    uint64 // -> sorted list
	FixedNode     bool

	FinishSync      bool
	ShardActiveTime int

	TotalDelegators uint64 `json:"TotalDelegators,omitempty"`
	// contains filtered or unexported fields
}

type StakerInfoDetail

type StakerInfoDetail struct {
	StakeTime     int64
	PoolEnterTime int64
	StakerInfo
}

type StateDataDetail

type StateDataDetail struct {
	Committee []StakerInfoDetail
	Pending   []StakerInfoDetail
	Waiting   []StakerInfoDetail
	Locking   []LockingInfoDetail
}

type SwapInstructionGenerator

type SwapInstructionGenerator interface {
	GenerateSwapInstructions(env *ShardCommitteeStateEnvironment) (*instruction.SwapInstruction, []string, []string, error)
}

type SwapRuleProcessor

type SwapRuleProcessor interface {
	Process(
		shardID byte,
		committees, substitutes []string,
		minCommitteeSize, maxCommitteeSize, typeIns, numberOfFixedValidators int,
		penalty map[string]signaturecounter.Penalty,
	) (
		*instruction.SwapShardInstruction, []string, []string, []string, []string) // instruction, newCommitteees, newSubstitutes, slashingCommittees, normalSwapCommittees
	CalculateAssignOffset(lenSubstitute, lenCommittees, numberOfFixedValidators, minCommitteeSize int) int
	Version() int
}

func GetSwapRuleVersion

func GetSwapRuleVersion(beaconHeight, stakingFlowV3Height uint64) SwapRuleProcessor

type SwapShardInstructionsGenerator

type SwapShardInstructionsGenerator interface {
	GenerateSwapShardInstructions(env *BeaconCommitteeStateEnvironment) ([]*instruction.SwapShardInstruction, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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