availability

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MinCommissionRate = numeric.MustNewDecFromStr("0.05")
	// ErrDivByZero ..
	ErrDivByZero = errors.New("toSign of availability cannot be 0, mistake in protocol")
)

Functions

func BallotResult

func BallotResult(
	parentHeader, header RoundHeader, parentShardState *shard.State, shardID uint32,
) (shard.SlotList, shard.SlotList, shard.SlotList, error)

BallotResult returns (parentCommittee.Slots, payable, missings, err)

func BlockSigners

func BlockSigners(
	bitmap []byte, parentCommittee *shard.Committee,
) (shard.SlotList, shard.SlotList, error)

BlockSigners ..

func ComputeAndMutateEPOSStatus

func ComputeAndMutateEPOSStatus(
	bc Reader,
	state ValidatorState,
	addr common.Address,
) error

ComputeAndMutateEPOSStatus sets the validator to inactive and thereby keeping it out of consideration in the pool of validators for whenever committee selection happens in future, the signing threshold is 66%

func ComputeCurrentSigning

func ComputeCurrentSigning(
	snapshot, wrapper *staking.ValidatorWrapper,
) *staking.Computed

ComputeCurrentSigning returns (signed, toSign, quotient, error)

func IncrementValidatorSigningCounts

func IncrementValidatorSigningCounts(
	bc Reader,
	staked *shard.StakedSlots,
	state ValidatorState,
	signers, missing shard.SlotList,
) error

IncrementValidatorSigningCounts ..

func IsBelowSigningThreshold

func IsBelowSigningThreshold(quotient numeric.Dec) bool

IsBelowSigningThreshold ..

func UpdateMinimumCommissionFee

func UpdateMinimumCommissionFee(
	electionEpoch *big.Int,
	state *state.DB,
	addr common.Address,
	promoPeriod int64,
) error

UpdateMinimumCommissionFee update the validator commission fee to the minimum 5% if the validator has a lower commission rate and 100 epochs have passed after the validator was first elected.

Types

type Reader

type Reader interface {
	ReadValidatorSnapshot(
		addr common.Address,
	) (*staking.ValidatorSnapshot, error)
}

Reader ..

type RoundHeader

type RoundHeader interface {
	Number() *big.Int
	ShardID() uint32
	LastCommitBitmap() []byte
}

RoundHeader is the interface of block.Header for calculating the BallotResult.

type ValidatorState

type ValidatorState interface {
	ValidatorWrapper(common.Address, bool, bool) (*staking.ValidatorWrapper, error)
	UpdateValidatorWrapper(common.Address, *staking.ValidatorWrapper) error
}

ValidatorState is the interface of state.DB

Jump to

Keyboard shortcuts

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