beacon

package
v0.12.2-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: MIT Imports: 19 Imported by: 41

Documentation

Index

Constants

View Source
const BASE_REWARDS_PER_EPOCH = 4
View Source
const BASE_REWARD_FACTOR = generated.BASE_REWARD_FACTOR

Reward and penalty quotients

View Source
const BLS_WITHDRAWAL_PREFIX byte = generated.BLS_WITHDRAWAL_PREFIX
View Source
const Bytes32Type = RootType
View Source
const CHURN_LIMIT_QUOTIENT = generated.CHURN_LIMIT_QUOTIENT
View Source
const CommitteeIndexType = Uint64Type
View Source
const DEPOSIT_CONTRACT_TREE_DEPTH = 32
View Source
const EpochType = Uint64Type
View Source
const FAR_FUTURE_EPOCH = Epoch(^uint64(0))
View Source
const GweiType = Uint64Type
View Source
const HISTORICAL_ROOTS_LIMIT = generated.HISTORICAL_ROOTS_LIMIT
View Source
const HYSTERESIS_DOWNWARD_MULTIPLIER uint64 = generated.HYSTERESIS_DOWNWARD_MULTIPLIER
View Source
const HYSTERESIS_QUOTIENT uint64 = generated.HYSTERESIS_QUOTIENT
View Source
const HYSTERESIS_UPWARD_MULTIPLIER uint64 = generated.HYSTERESIS_UPWARD_MULTIPLIER
View Source
const INACTIVITY_PENALTY_QUOTIENT = generated.INACTIVITY_PENALTY_QUOTIENT
View Source
const JUSTIFICATION_BITS_LENGTH = 4
View Source
const MAX_ATTESTATIONS = generated.MAX_ATTESTATIONS
View Source
const MAX_ATTESTER_SLASHINGS = generated.MAX_ATTESTER_SLASHINGS
View Source
const MAX_COMMITTEES_PER_SLOT = generated.MAX_COMMITTEES_PER_SLOT

Misc.

View Source
const MAX_DEPOSITS = generated.MAX_DEPOSITS
View Source
const MAX_PROPOSER_SLASHINGS = generated.MAX_PROPOSER_SLASHINGS

Max transactions per block

View Source
const MAX_VALIDATORS_PER_COMMITTEE = generated.MAX_VALIDATORS_PER_COMMITTEE
View Source
const MAX_VOLUNTARY_EXITS = generated.MAX_VOLUNTARY_EXITS
View Source
const MIN_GENESIS_ACTIVE_VALIDATOR_COUNT = generated.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT

Genesis

View Source
const MIN_GENESIS_TIME = generated.MIN_GENESIS_TIME
View Source
const MIN_PER_EPOCH_CHURN_LIMIT = generated.MIN_PER_EPOCH_CHURN_LIMIT
View Source
const MIN_SLASHING_PENALTY_QUOTIENT = generated.MIN_SLASHING_PENALTY_QUOTIENT
View Source
const PRESET_NAME = generated.PRESET_NAME

Helper to know what preset is active

View Source
const PROPOSER_REWARD_QUOTIENT = generated.PROPOSER_REWARD_QUOTIENT
View Source
const SECONDS_PER_DAY = 24 * 60 * 60
View Source
const SHUFFLE_ROUND_COUNT uint8 = generated.SHUFFLE_ROUND_COUNT
View Source
const SLOTS_PER_ETH1_VOTING_PERIOD = Slot(EPOCHS_PER_ETH1_VOTING_PERIOD) * SLOTS_PER_EPOCH
View Source
const ShardType = Uint64Type
View Source
const SlotType = Uint64Type
View Source
const TARGET_COMMITTEE_SIZE = generated.TARGET_COMMITTEE_SIZE
View Source
const VALIDATOR_REGISTRY_LIMIT = generated.VALIDATOR_REGISTRY_LIMIT
View Source
const ValidatorIndexMarker = ValidatorIndex(^uint64(0))

Custom constant, not in spec: An impossible high validator index used to mark special internal cases. (all 1s binary)

View Source
const ValidatorIndexType = Uint64Type
View Source
const VersionType = Bytes4Type
View Source
const WHISTLEBLOWER_REWARD_QUOTIENT = generated.WHISTLEBLOWER_REWARD_QUOTIENT

Variables

View Source
var AttestationDataSSZ = zssz.GetSSZ((*AttestationData)(nil))
View Source
var AttestationDataType = ContainerType("AttestationData", []FieldDef{
	{"slot", SlotType},
	{"index", CommitteeIndexType},

	{"beacon_block_root", RootType},

	{"source", CheckpointType},
	{"target", CheckpointType},
})
View Source
var AttestationSSZ = zssz.GetSSZ((*Attestation)(nil))
View Source
var AttestationType = ContainerType("Attestation", []FieldDef{
	{"aggregation_bits", CommitteeBitsType},
	{"data", AttestationDataType},
	{"signature", BLSSignatureType},
})
View Source
var AttestationsType = ListType(AttestationType, MAX_ATTESTATIONS)
View Source
var AttesterSlashingSSZ = zssz.GetSSZ((*AttesterSlashing)(nil))
View Source
var AttesterSlashingType = ContainerType("AttesterSlashing", []FieldDef{
	{"attestation_1", IndexedAttestationType},
	{"attestation_2", IndexedAttestationType},
})
View Source
var AttesterSlashingsType = ListType(AttesterSlashingType, MAX_ATTESTER_SLASHINGS)
View Source
var BLSPubkeyType = BasicVectorType(ByteType, 48)
View Source
var BLSSignatureType = BasicVectorType(ByteType, 96)
View Source
var BatchRootsType = VectorType(RootType, uint64(SLOTS_PER_HISTORICAL_ROOT))
View Source
var BeaconBlockBodySSZ = zssz.GetSSZ((*BeaconBlockBody)(nil))
View Source
var BeaconBlockBodyType = ContainerType("BeaconBlockBody", []FieldDef{
	{"randao_reveal", BLSSignatureType},
	{"eth1_data", Eth1DataType},
	{"graffiti", Bytes32Type},

	{"proposer_slashings", ProposerSlashingsType},
	{"attester_slashings", AttesterSlashingsType},
	{"attestations", AttestationsType},
	{"deposits", DepositsType},
	{"voluntary_exits", VoluntaryExitsType},
})
View Source
var BeaconBlockHeaderSSZ = zssz.GetSSZ((*BeaconBlockHeader)(nil))
View Source
var BeaconBlockHeaderType = ContainerType("BeaconBlockHeader", []FieldDef{
	{"slot", SlotType},
	{"proposer_index", ValidatorIndexType},
	{"parent_root", RootType},
	{"state_root", RootType},
	{"body_root", RootType},
})
View Source
var BeaconBlockSSZ = zssz.GetSSZ((*BeaconBlock)(nil))
View Source
var BeaconBlockType = ContainerType("BeaconBlock", []FieldDef{
	{"slot", SlotType},
	{"proposer_index", ValidatorIndexType},
	{"parent_root", RootType},
	{"state_root", RootType},
	{"body", BeaconBlockBodyType},
})
View Source
var BeaconStateSSZ = zssz.GetSSZ((*BeaconState)(nil))
View Source
var BeaconStateType = ContainerType("BeaconState", []FieldDef{

	{"genesis_time", Uint64Type},
	{"genesis_validators_root", RootType},
	{"slot", SlotType},
	{"fork", ForkType},

	{"latest_block_header", BeaconBlockHeaderType},
	{"block_roots", BatchRootsType},
	{"state_roots", BatchRootsType},
	{"historical_roots", HistoricalRootsType},

	{"eth1_data", Eth1DataType},
	{"eth1_data_votes", Eth1DataVotesType},
	{"eth1_deposit_index", Uint64Type},

	{"validators", ValidatorsRegistryType},
	{"balances", RegistryBalancesType},

	{"randao_mixes", RandaoMixesType},

	{"slashings", SlashingsType},

	{"previous_epoch_attestations", PendingAttestationsType},
	{"current_epoch_attestations", PendingAttestationsType},

	{"justification_bits", JustificationBitsType},
	{"previous_justified_checkpoint", CheckpointType},
	{"current_justified_checkpoint", CheckpointType},
	{"finalized_checkpoint", CheckpointType},
})

Beacon state

View Source
var CheckpointType = ContainerType("Checkpoint", []FieldDef{
	{"epoch", EpochType},
	{"root", RootType},
})
View Source
var CommitteeBitsType = BitListType(MAX_VALIDATORS_PER_COMMITTEE)
View Source
var CommitteeIndicesType = ListType(ValidatorIndexType, MAX_VALIDATORS_PER_COMMITTEE)
View Source
var DeltasSSZ = zssz.GetSSZ((*Deltas)(nil))
View Source
var DepositDataSSZ = zssz.GetSSZ((*DepositData)(nil))
View Source
var DepositDataType = ContainerType("DepositData", []FieldDef{
	{"pubkey", BLSPubkeyType},
	{"withdrawal_credentials", Bytes32Type},
	{"amount", GweiType},
	{"signature", BLSSignatureType},
})
View Source
var DepositMessageSSZ = zssz.GetSSZ((*DepositMessage)(nil))
View Source
var DepositProofType = VectorType(Bytes32Type, DEPOSIT_CONTRACT_TREE_DEPTH+1)
View Source
var DepositRootsType = ComplexListType(RootType, 1<<DEPOSIT_CONTRACT_TREE_DEPTH)
View Source
var DepositSSZ = zssz.GetSSZ((*Deposit)(nil))
View Source
var DepositType = ContainerType("Deposit", []FieldDef{
	{"proof", DepositProofType},
	{"data", DepositDataType},
})
View Source
var DepositsType = ListType(DepositType, MAX_DEPOSITS)
View Source
var Eth1DataType = ContainerType("Eth1Data", []FieldDef{
	{"deposit_root", RootType},
	{"deposit_count", Uint64Type},
	{"block_hash", Bytes32Type},
})
View Source
var Eth1DataVotesType = ListType(Eth1DataType, uint64(SLOTS_PER_ETH1_VOTING_PERIOD))
View Source
var ForkDataSSZ = zssz.GetSSZ((*ForkData)(nil))
View Source
var ForkType = ContainerType("Fork", []FieldDef{
	{"previous_version", VersionType},
	{"current_version", VersionType},
	{"epoch", EpochType},
})
View Source
var GENESIS_FORK_VERSION = parseVersion(generated.GENESIS_FORK_VERSION)

Initial values

View Source
var HistoricalBatchType = ContainerType("HistoricalBatch", []FieldDef{
	{"block_roots", BatchRootsType},
	{"state_roots", BatchRootsType},
})
View Source
var HistoricalRootsType = ListType(RootType, HISTORICAL_ROOTS_LIMIT)
View Source
var IndexedAttestationType = ContainerType("IndexedAttestation", []FieldDef{
	{"attesting_indices", CommitteeIndicesType},
	{"data", AttestationDataType},
	{"signature", BLSSignatureType},
})
View Source
var JustificationBitsType = BitVectorType(JUSTIFICATION_BITS_LENGTH)
View Source
var PendingAttestationType = ContainerType("PendingAttestation", []FieldDef{
	{"aggregation_bits", CommitteeBitsType},
	{"data", AttestationDataType},
	{"inclusion_delay", SlotType},
	{"proposer_index", ValidatorIndexType},
})
View Source
var PendingAttestationsType = ComplexListType(PendingAttestationType, uint64(MAX_ATTESTATIONS*SLOTS_PER_EPOCH))
View Source
var ProposerSlashingSSZ = zssz.GetSSZ((*ProposerSlashing)(nil))
View Source
var ProposerSlashingType = ContainerType("ProposerSlashing", []FieldDef{
	{"header_1", SignedBeaconBlockHeaderType},
	{"header_2", SignedBeaconBlockHeaderType},
})

Beacon operations

View Source
var ProposerSlashingsType = ListType(ProposerSlashingType, MAX_PROPOSER_SLASHINGS)
View Source
var RandaoEpochSSZ = zssz.GetSSZ((*Epoch)(nil))
View Source
var RandaoMixesType = VectorType(Bytes32Type, uint64(EPOCHS_PER_HISTORICAL_VECTOR))
View Source
var RegistryBalancesSSZ = zssz.GetSSZ((*Balances)(nil))
View Source
var RegistryBalancesType = BasicListType(GweiType, VALIDATOR_REGISTRY_LIMIT)
View Source
var SignedBeaconBlockHeaderSSZ = zssz.GetSSZ((*SignedBeaconBlockHeader)(nil))
View Source
var SignedBeaconBlockHeaderType = ContainerType("SignedBeaconBlockHeader", []FieldDef{
	{"message", BeaconBlockHeaderType},
	{"signature", BLSSignatureType},
})
View Source
var SignedBeaconBlockSSZ = zssz.GetSSZ((*SignedBeaconBlock)(nil))
View Source
var SignedBeaconBlockType = ContainerType("SignedBeaconBlock", []FieldDef{
	{"message", BeaconBlockType},
	{"signature", BLSSignatureType},
})
View Source
var SignedVoluntaryExitSSZ = zssz.GetSSZ((*SignedVoluntaryExit)(nil))
View Source
var SignedVoluntaryExitType = ContainerType("SignedVoluntaryExit", []FieldDef{
	{"message", VoluntaryExitType},
	{"signature", BLSSignatureType},
})
View Source
var SigningDataSSZ = zssz.GetSSZ((*SigningData)(nil))
View Source
var SlashingsType = VectorType(GweiType, uint64(EPOCHS_PER_SLASHINGS_VECTOR))

Balances slashed at every withdrawal period

View Source
var TransitionCancelErr = errors.New("state transition was cancelled")
View Source
var ValidatorType = ContainerType("Validator", []FieldDef{
	{"pubkey", BLSPubkeyType},
	{"withdrawal_credentials", Bytes32Type},
	{"effective_balance", GweiType},
	{"slashed", BoolType},

	{"activation_eligibility_epoch", EpochType},
	{"activation_epoch", EpochType},
	{"exit_epoch", EpochType},
	{"withdrawable_epoch", EpochType},
})
View Source
var ValidatorsRegistryType = ComplexListType(ValidatorType, VALIDATOR_REGISTRY_LIMIT)
View Source
var VoluntaryExitSSZ = zssz.GetSSZ((*VoluntaryExit)(nil))
View Source
var VoluntaryExitType = ContainerType("VoluntaryExit", []FieldDef{
	{"epoch", EpochType},
	{"validator_index", ValidatorIndexType},
})
View Source
var VoluntaryExitsType = ListType(SignedVoluntaryExitType, MAX_VOLUNTARY_EXITS)

Functions

func CommitteeCount added in v0.12.1

func CommitteeCount(activeValidators uint64) uint64

func GenesisFromEth1 added in v0.12.1

func GenesisFromEth1(eth1BlockHash Root, time Timestamp, deps []Deposit, ignoreSignaturesAndProofs bool) (*BeaconStateView, *EpochsContext, error)

func GetChurnLimit added in v0.12.1

func GetChurnLimit(activeValidatorCount uint64) uint64

func IsDoubleVote added in v0.12.1

func IsDoubleVote(a *AttestationData, b *AttestationData) bool

Check if a and b have the same target epoch.

func IsSlashableAttestationData added in v0.12.1

func IsSlashableAttestationData(a *AttestationData, b *AttestationData) bool

func IsSurroundVote added in v0.12.1

func IsSurroundVote(a *AttestationData, b *AttestationData) bool

Check if a surrounds b, i.E. source(a) < source(b) and target(a) > target(b)

func IsValidGenesisState added in v0.12.1

func IsValidGenesisState(state *BeaconStateView) (bool, error)

func KickStartState added in v0.12.1

func KickStartState(eth1BlockHash Root, time Timestamp, validators []KickstartValidatorData) (*BeaconStateView, *EpochsContext, error)

To build a genesis state without Eth 1.0 deposits, i.e. directly from a sequence of minimal validator data.

func KickStartStateWithSignatures added in v0.12.1

func KickStartStateWithSignatures(eth1BlockHash Root, time Timestamp, validators []KickstartValidatorData, keys [][32]byte) (*BeaconStateView, *EpochsContext, error)

To build a genesis state without Eth 1.0 deposits, i.e. directly from a sequence of minimal validator data.

func ShuffleList added in v0.12.1

func ShuffleList(input []ValidatorIndex, seed Root)

ShuffleList shuffles a list, using the given seed for randomness.

func UnshuffleList added in v0.12.1

func UnshuffleList(input []ValidatorIndex, seed Root)

UnshuffleList undoes a list shuffling using the seed of the shuffling.

Types

type Attestation

type Attestation struct {
	AggregationBits CommitteeBits
	Data            AttestationData
	Signature       BLSSignature
}

func (*Attestation) ConvertToIndexed added in v0.12.1

func (attestation *Attestation) ConvertToIndexed(committee []ValidatorIndex) (*IndexedAttestation, error)

Convert attestation to (almost) indexed-verifiable form

type AttestationData

type AttestationData struct {
	Slot  Slot
	Index CommitteeIndex

	// LMD GHOST vote
	BeaconBlockRoot Root

	// FFG vote
	Source Checkpoint
	Target Checkpoint
}

func (*AttestationData) View added in v0.12.1

func (data *AttestationData) View() *AttestationDataView

type AttestationDataView added in v0.12.1

type AttestationDataView struct{ *ContainerView }

func AsAttestationData added in v0.12.1

func AsAttestationData(v View, err error) (*AttestationDataView, error)

func (*AttestationDataView) Raw added in v0.12.1

type Attestations added in v0.12.1

type Attestations []Attestation

func (*Attestations) Limit added in v0.12.1

func (*Attestations) Limit() uint64

type AttesterFlag added in v0.12.1

type AttesterFlag uint8
const (
	PrevSourceAttester AttesterFlag = 1 << iota
	PrevTargetAttester
	PrevHeadAttester

	CurrSourceAttester
	CurrTargetAttester
	CurrHeadAttester

	UnslashedAttester
	EligibleAttester
)

func (AttesterFlag) HasMarkers added in v0.12.1

func (flags AttesterFlag) HasMarkers(markers AttesterFlag) bool

type AttesterSlashing

type AttesterSlashing struct {
	Attestation1 IndexedAttestation
	Attestation2 IndexedAttestation
}

type AttesterSlashings added in v0.12.1

type AttesterSlashings []AttesterSlashing

func (*AttesterSlashings) Limit added in v0.12.1

func (*AttesterSlashings) Limit() uint64

type AttesterStatus added in v0.12.1

type AttesterStatus struct {
	// The delay of inclusion of the latest attestation by the attester.
	// No delay (i.e. 0) by default
	InclusionDelay Slot
	// The validator index of the proposer of the attested beacon block.
	// Only valid if the validator has an attesting flag set.
	AttestedProposer ValidatorIndex
	// A bitfield of markers describing the recent actions of the validator
	Flags     AttesterFlag
	Validator *FlatValidator
	// If the validator is active
	Active bool
}

type BLSDomain added in v0.12.1

type BLSDomain [32]byte

BLS domain (8 bytes): fork version (32 bits) concatenated with BLS domain type (32 bits)

func ComputeDomain added in v0.12.1

func ComputeDomain(domainType BLSDomainType, forkVersion Version, genesisValidatorsRoot Root) (out BLSDomain)

type BLSDomainType added in v0.12.1

type BLSDomainType [4]byte

Mixed into a BLS domain to define its type

var (
	DOMAIN_BEACON_PROPOSER     BLSDomainType = parseDomain(generated.DOMAIN_BEACON_PROPOSER)
	DOMAIN_RANDAO              BLSDomainType = parseDomain(generated.DOMAIN_RANDAO)
	DOMAIN_BEACON_ATTESTER     BLSDomainType = parseDomain(generated.DOMAIN_BEACON_ATTESTER)
	DOMAIN_DEPOSIT             BLSDomainType = parseDomain(generated.DOMAIN_DEPOSIT)
	DOMAIN_VOLUNTARY_EXIT      BLSDomainType = parseDomain(generated.DOMAIN_VOLUNTARY_EXIT)
	DOMAIN_SELECTION_PROOF     BLSDomainType = parseDomain(generated.DOMAIN_SELECTION_PROOF)
	DOMAIN_AGGREGATE_AND_PROOF BLSDomainType = parseDomain(generated.DOMAIN_AGGREGATE_AND_PROOF)
)

Signature domains

type BLSPubkey added in v0.12.1

type BLSPubkey = bls.BLSPubkey

func AsBLSPubkey added in v0.12.1

func AsBLSPubkey(v View, err error) (BLSPubkey, error)

type BLSPubkeyView added in v0.12.1

type BLSPubkeyView struct {
	*BasicVectorView
}

func ViewPubkey added in v0.12.1

func ViewPubkey(pub *BLSPubkey) *BLSPubkeyView

type BLSSignature added in v0.12.1

type BLSSignature = bls.BLSSignature

func AsBLSSignature added in v0.12.1

func AsBLSSignature(v View, err error) (BLSSignature, error)

type BLSSignatureView added in v0.12.1

type BLSSignatureView struct {
	*BasicVectorView
}

func ViewSignature added in v0.12.1

func ViewSignature(sig *BLSSignature) *BLSSignatureView

type Balances added in v0.12.1

type Balances []Gwei

func (*Balances) Limit added in v0.12.1

func (_ *Balances) Limit() uint64

type BatchRootsView added in v0.12.1

type BatchRootsView struct{ *ComplexVectorView }

func AsBatchRoots added in v0.12.1

func AsBatchRoots(v View, err error) (*BatchRootsView, error)

func (*BatchRootsView) GetRoot added in v0.12.1

func (v *BatchRootsView) GetRoot(slot Slot) (Root, error)

Return the root at the given slot. Only valid to SLOTS_PER_HISTORICAL_ROOT slots ago.

func (*BatchRootsView) SetRoot added in v0.12.1

func (v *BatchRootsView) SetRoot(slot Slot, r Root) error

type BeaconBlock

type BeaconBlock struct {
	Slot          Slot
	ProposerIndex ValidatorIndex
	ParentRoot    Root
	StateRoot     Root
	Body          BeaconBlockBody
}

func (*BeaconBlock) HashTreeRoot added in v0.12.1

func (b *BeaconBlock) HashTreeRoot() Root

func (*BeaconBlock) Header added in v0.12.1

func (block *BeaconBlock) Header() *BeaconBlockHeader

type BeaconBlockBody

type BeaconBlockBody struct {
	RandaoReveal BLSSignature
	Eth1Data     Eth1Data // Eth1 data vote
	Graffiti     Root     // Arbitrary data

	ProposerSlashings ProposerSlashings
	AttesterSlashings AttesterSlashings
	Attestations      Attestations
	Deposits          Deposits
	VoluntaryExits    VoluntaryExits
}

func (*BeaconBlockBody) HashTreeRoot added in v0.12.1

func (b *BeaconBlockBody) HashTreeRoot() Root

type BeaconBlockHeader

type BeaconBlockHeader struct {
	Slot          Slot
	ProposerIndex ValidatorIndex
	ParentRoot    Root
	StateRoot     Root
	BodyRoot      Root
}

func (*BeaconBlockHeader) HashTreeRoot added in v0.12.1

func (b *BeaconBlockHeader) HashTreeRoot() Root

func (*BeaconBlockHeader) View added in v0.12.1

type BeaconBlockHeaderView added in v0.12.1

type BeaconBlockHeaderView struct {
	*ContainerView
}

func AsBeaconBlockHeader added in v0.12.1

func AsBeaconBlockHeader(v View, err error) (*BeaconBlockHeaderView, error)

func (*BeaconBlockHeaderView) BodyRoot added in v0.12.1

func (v *BeaconBlockHeaderView) BodyRoot() (Root, error)

func (*BeaconBlockHeaderView) ParentRoot added in v0.12.1

func (v *BeaconBlockHeaderView) ParentRoot() (Root, error)

func (*BeaconBlockHeaderView) ProposerIndex added in v0.12.1

func (v *BeaconBlockHeaderView) ProposerIndex() (ValidatorIndex, error)

func (*BeaconBlockHeaderView) Raw added in v0.12.1

func (*BeaconBlockHeaderView) SetStateRoot added in v0.12.1

func (v *BeaconBlockHeaderView) SetStateRoot(root Root) error

func (*BeaconBlockHeaderView) Slot added in v0.12.1

func (v *BeaconBlockHeaderView) Slot() (Slot, error)

func (*BeaconBlockHeaderView) StateRoot added in v0.12.1

func (v *BeaconBlockHeaderView) StateRoot() (Root, error)

type BeaconState

type BeaconState struct {
	// Versioning
	GenesisTime           Timestamp
	GenesisValidatorsRoot Root
	Slot                  Slot
	Fork                  Fork
	// History
	LatestBlockHeader BeaconBlockHeader
	BlockRoots        [SLOTS_PER_HISTORICAL_ROOT]Root
	StateRoots        [SLOTS_PER_HISTORICAL_ROOT]Root
	HistoricalRoots   HistoricalRoots
	// Eth1
	Eth1Data      Eth1Data
	Eth1DataVotes Eth1DataVotes
	DepositIndex  DepositIndex
	// Registry
	Validators ValidatorRegistry
	Balances   Balances
	// Randomness
	RandaoMixes [EPOCHS_PER_HISTORICAL_VECTOR]Root
	// Slashings
	Slashings [EPOCHS_PER_SLASHINGS_VECTOR]Gwei
	// Attestations
	PreviousEpochAttestations PendingAttestations
	CurrentEpochAttestations  PendingAttestations
	// Finality
	JustificationBits           JustificationBits
	PreviousJustifiedCheckpoint Checkpoint
	CurrentJustifiedCheckpoint  Checkpoint
	FinalizedCheckpoint         Checkpoint
}

type BeaconStateView added in v0.12.1

type BeaconStateView struct {
	*ContainerView
}

func AsBeaconStateView added in v0.12.1

func AsBeaconStateView(v View, err error) (*BeaconStateView, error)

To load a state:

state, err := beacon.AsBeaconStateView(beacon.BeaconStateType.Deserialize(reader, size))

func NewBeaconStateView added in v0.12.1

func NewBeaconStateView() *BeaconStateView

func (*BeaconStateView) AttestationRewardsAndPenalties added in v0.12.1

func (state *BeaconStateView) AttestationRewardsAndPenalties(
	ctx context.Context, epc *EpochsContext, process *EpochProcess) (*RewardsAndPenalties, error)

func (*BeaconStateView) Balances added in v0.12.1

func (state *BeaconStateView) Balances() (*RegistryBalancesView, error)

func (*BeaconStateView) BlockRoots added in v0.12.1

func (state *BeaconStateView) BlockRoots() (*BatchRootsView, error)

func (*BeaconStateView) CurrentEpochAttestations added in v0.12.1

func (state *BeaconStateView) CurrentEpochAttestations() (*PendingAttestationsView, error)

func (*BeaconStateView) CurrentJustifiedCheckpoint added in v0.12.1

func (state *BeaconStateView) CurrentJustifiedCheckpoint() (*CheckpointView, error)

func (*BeaconStateView) DepositIndex added in v0.12.1

func (state *BeaconStateView) DepositIndex() (DepositIndex, error)

func (*BeaconStateView) Eth1Data added in v0.12.1

func (state *BeaconStateView) Eth1Data() (*Eth1DataView, error)

func (*BeaconStateView) Eth1DataVotes added in v0.12.1

func (state *BeaconStateView) Eth1DataVotes() (*Eth1DataVotesView, error)

func (*BeaconStateView) FinalizedCheckpoint added in v0.12.1

func (state *BeaconStateView) FinalizedCheckpoint() (*CheckpointView, error)

func (*BeaconStateView) Fork added in v0.12.1

func (state *BeaconStateView) Fork() (*ForkView, error)

func (*BeaconStateView) GenesisTime added in v0.12.1

func (state *BeaconStateView) GenesisTime() (Timestamp, error)

func (*BeaconStateView) GenesisValidatorsRoot added in v0.12.1

func (state *BeaconStateView) GenesisValidatorsRoot() (Root, error)

func (*BeaconStateView) GetBlockRoot added in v0.12.1

func (state *BeaconStateView) GetBlockRoot(epoch Epoch) (Root, error)

Return the block root at a recent epoch. Only valid to SLOTS_PER_HISTORICAL_ROOT slots ago.

func (*BeaconStateView) GetBlockRootAtSlot added in v0.12.1

func (state *BeaconStateView) GetBlockRootAtSlot(slot Slot) (Root, error)

Return the block root at a recent slot. Only valid to SLOTS_PER_HISTORICAL_ROOT slots ago.

func (*BeaconStateView) GetDomain added in v0.12.1

func (state *BeaconStateView) GetDomain(dom BLSDomainType, messageEpoch Epoch) (BLSDomain, error)

Return the signature domain (fork version concatenated with domain type) of a message.

func (*BeaconStateView) HistoricalRoots added in v0.12.1

func (state *BeaconStateView) HistoricalRoots() (*HistoricalRootsView, error)

func (*BeaconStateView) IncrementDepositIndex added in v0.12.1

func (state *BeaconStateView) IncrementDepositIndex() error

func (*BeaconStateView) InitiateValidatorExit added in v0.12.1

func (state *BeaconStateView) InitiateValidatorExit(epc *EpochsContext, index ValidatorIndex) error

Initiate the exit of the validator of the given index

func (*BeaconStateView) IsValidIndex added in v0.12.1

func (state *BeaconStateView) IsValidIndex(index ValidatorIndex) (bool, error)

func (*BeaconStateView) JustificationBits added in v0.12.1

func (state *BeaconStateView) JustificationBits() (*JustificationBitsView, error)

func (*BeaconStateView) LatestBlockHeader added in v0.12.1

func (state *BeaconStateView) LatestBlockHeader() (*BeaconBlockHeaderView, error)

func (*BeaconStateView) NewEpochsContext added in v0.12.1

func (state *BeaconStateView) NewEpochsContext() (*EpochsContext, error)

NewEpochsContext constructs a new context for the processing of the current epoch.

func (*BeaconStateView) PrepareEpochProcess added in v0.12.1

func (state *BeaconStateView) PrepareEpochProcess(ctx context.Context, epc *EpochsContext) (out *EpochProcess, err error)

func (*BeaconStateView) PreviousEpochAttestations added in v0.12.1

func (state *BeaconStateView) PreviousEpochAttestations() (*PendingAttestationsView, error)

func (*BeaconStateView) PreviousJustifiedCheckpoint added in v0.12.1

func (state *BeaconStateView) PreviousJustifiedCheckpoint() (*CheckpointView, error)

func (*BeaconStateView) ProcessAttestation added in v0.12.1

func (state *BeaconStateView) ProcessAttestation(epc *EpochsContext, attestation *Attestation) error

func (*BeaconStateView) ProcessAttestations added in v0.12.1

func (state *BeaconStateView) ProcessAttestations(ctx context.Context, epc *EpochsContext, ops []Attestation) error

func (*BeaconStateView) ProcessAttesterSlashing added in v0.12.1

func (state *BeaconStateView) ProcessAttesterSlashing(epc *EpochsContext, attesterSlashing *AttesterSlashing) error

func (*BeaconStateView) ProcessAttesterSlashings added in v0.12.1

func (state *BeaconStateView) ProcessAttesterSlashings(ctx context.Context, epc *EpochsContext, ops []AttesterSlashing) error

func (*BeaconStateView) ProcessBlock added in v0.12.1

func (state *BeaconStateView) ProcessBlock(ctx context.Context, epc *EpochsContext, block *BeaconBlock) error

func (*BeaconStateView) ProcessDeposit added in v0.12.1

func (state *BeaconStateView) ProcessDeposit(epc *EpochsContext, dep *Deposit, ignoreSignatureAndProof bool) error

Process an Eth1 deposit, registering a validator or increasing its balance.

func (*BeaconStateView) ProcessDeposits added in v0.12.1

func (state *BeaconStateView) ProcessDeposits(ctx context.Context, epc *EpochsContext, ops []Deposit) error

Verify that outstanding deposits are processed up to the maximum number of deposits, then process all in order.

func (*BeaconStateView) ProcessEpoch added in v0.12.1

func (state *BeaconStateView) ProcessEpoch(ctx context.Context, epc *EpochsContext) error

func (*BeaconStateView) ProcessEpochFinalUpdates added in v0.12.1

func (state *BeaconStateView) ProcessEpochFinalUpdates(ctx context.Context, epc *EpochsContext, process *EpochProcess) error

func (*BeaconStateView) ProcessEpochJustification added in v0.12.1

func (state *BeaconStateView) ProcessEpochJustification(ctx context.Context, epc *EpochsContext, process *EpochProcess) error

func (*BeaconStateView) ProcessEpochRegistryUpdates added in v0.12.1

func (state *BeaconStateView) ProcessEpochRegistryUpdates(ctx context.Context, epc *EpochsContext, process *EpochProcess) error

func (*BeaconStateView) ProcessEpochRewardsAndPenalties added in v0.12.1

func (state *BeaconStateView) ProcessEpochRewardsAndPenalties(ctx context.Context, epc *EpochsContext, process *EpochProcess) error

func (*BeaconStateView) ProcessEpochSlashings added in v0.12.1

func (state *BeaconStateView) ProcessEpochSlashings(ctx context.Context, epc *EpochsContext, process *EpochProcess) error

func (*BeaconStateView) ProcessEth1Vote added in v0.12.1

func (state *BeaconStateView) ProcessEth1Vote(ctx context.Context, epc *EpochsContext, data Eth1Data) error

func (*BeaconStateView) ProcessHeader added in v0.12.1

func (state *BeaconStateView) ProcessHeader(ctx context.Context, epc *EpochsContext, header *BeaconBlock) error

func (*BeaconStateView) ProcessProposerSlashing added in v0.12.1

func (state *BeaconStateView) ProcessProposerSlashing(epc *EpochsContext, ps *ProposerSlashing) error

func (*BeaconStateView) ProcessProposerSlashings added in v0.12.1

func (state *BeaconStateView) ProcessProposerSlashings(ctx context.Context, epc *EpochsContext, ops []ProposerSlashing) error

func (*BeaconStateView) ProcessRandaoReveal added in v0.12.1

func (state *BeaconStateView) ProcessRandaoReveal(ctx context.Context, epc *EpochsContext, reveal BLSSignature) error

func (*BeaconStateView) ProcessSlot added in v0.12.1

func (state *BeaconStateView) ProcessSlot(ctx context.Context) error

func (*BeaconStateView) ProcessSlots added in v0.12.1

func (state *BeaconStateView) ProcessSlots(ctx context.Context, epc *EpochsContext, slot Slot) error

Process the state to the given slot. Returns an error if the slot is older than the state is already at. Mutates the state, does not copy.

func (*BeaconStateView) ProcessVoluntaryExit added in v0.12.1

func (state *BeaconStateView) ProcessVoluntaryExit(epc *EpochsContext, signedExit *SignedVoluntaryExit) error

func (*BeaconStateView) ProcessVoluntaryExits added in v0.12.1

func (state *BeaconStateView) ProcessVoluntaryExits(ctx context.Context, epc *EpochsContext, ops []SignedVoluntaryExit) error

func (*BeaconStateView) RandaoMixes added in v0.12.1

func (state *BeaconStateView) RandaoMixes() (*RandaoMixesView, error)

func (*BeaconStateView) Raw added in v0.12.1

func (state *BeaconStateView) Raw() (*BeaconState, error)

Raw converts the tree-structured state into a flattened native Go structure.

func (*BeaconStateView) ResetEth1Votes added in v0.12.1

func (state *BeaconStateView) ResetEth1Votes() error

Done at the end of every voting period

func (*BeaconStateView) SetEth1Data added in v0.12.1

func (state *BeaconStateView) SetEth1Data(v *Eth1DataView) error

func (*BeaconStateView) SetFork added in v0.12.1

func (state *BeaconStateView) SetFork(f Fork) error

func (*BeaconStateView) SetGenesisTime added in v0.12.1

func (state *BeaconStateView) SetGenesisTime(t Timestamp) error

func (*BeaconStateView) SetGenesisValidatorsRoot added in v0.12.1

func (state *BeaconStateView) SetGenesisValidatorsRoot(r Root) error

func (*BeaconStateView) SetLatestBlockHeader added in v0.12.1

func (state *BeaconStateView) SetLatestBlockHeader(v *BeaconBlockHeaderView) error

func (*BeaconStateView) SetRandaoMixes added in v0.12.1

func (state *BeaconStateView) SetRandaoMixes(v *RandaoMixesView) error

func (*BeaconStateView) SetRecentRoots added in v0.12.1

func (state *BeaconStateView) SetRecentRoots(slot Slot, blockRoot Root, stateRoot Root) error

func (*BeaconStateView) SetSlot added in v0.12.1

func (state *BeaconStateView) SetSlot(slot Slot) error

func (*BeaconStateView) ShufflingEpoch added in v0.12.1

func (state *BeaconStateView) ShufflingEpoch(indicesBounded []BoundedIndex, epoch Epoch) (*ShufflingEpoch, error)

func (*BeaconStateView) SlashValidator added in v0.12.1

func (state *BeaconStateView) SlashValidator(epc *EpochsContext, slashedIndex ValidatorIndex, whistleblowerIndex *ValidatorIndex) error

Slash the validator with the given index.

func (*BeaconStateView) Slashings added in v0.12.1

func (state *BeaconStateView) Slashings() (*SlashingsView, error)

func (*BeaconStateView) Slot added in v0.12.1

func (state *BeaconStateView) Slot() (Slot, error)

func (*BeaconStateView) StateRoots added in v0.12.1

func (state *BeaconStateView) StateRoots() (*BatchRootsView, error)

func (*BeaconStateView) StateTransition added in v0.12.1

func (state *BeaconStateView) StateTransition(ctx context.Context, epc *EpochsContext, block *SignedBeaconBlock, validateResult bool) error

Transition the state to the slot of the given block, then processes the block. Returns an error if the slot is older than the state is already at. Mutates the state, does not copy.

func (*BeaconStateView) UpdateHistoricalRoots added in v0.12.1

func (state *BeaconStateView) UpdateHistoricalRoots() error

func (*BeaconStateView) ValidateIndexedAttestation added in v0.12.1

func (state *BeaconStateView) ValidateIndexedAttestation(epc *EpochsContext, indexedAttestation *IndexedAttestation) error

Verify validity of slashable_attestation fields.

func (*BeaconStateView) Validators added in v0.12.1

func (state *BeaconStateView) Validators() (*ValidatorsRegistryView, error)

func (*BeaconStateView) VerifySignature added in v0.12.1

func (state *BeaconStateView) VerifySignature(epc *EpochsContext, block *SignedBeaconBlock, validateProposerIndex bool) bool

Assuming the slot is valid, and optionally assume the proposer index is valid, check if the signature is valid

type BoundedIndex added in v0.12.1

type BoundedIndex struct {
	Index      ValidatorIndex
	Activation Epoch
	Exit       Epoch
}

type Bytes added in v0.12.1

type Bytes []byte

type CachedPubkey added in v0.12.1

type CachedPubkey = bls.CachedPubkey

type Checkpoint added in v0.12.1

type Checkpoint struct {
	Epoch Epoch
	Root  Root
}

func (*Checkpoint) View added in v0.12.1

func (c *Checkpoint) View() *CheckpointView

type CheckpointView added in v0.12.1

type CheckpointView struct {
	*ContainerView
}

func AsCheckPoint added in v0.12.1

func AsCheckPoint(v View, err error) (*CheckpointView, error)

func (*CheckpointView) Epoch added in v0.12.1

func (v *CheckpointView) Epoch() (Epoch, error)

func (*CheckpointView) Raw added in v0.12.1

func (v *CheckpointView) Raw() (Checkpoint, error)

func (*CheckpointView) Root added in v0.12.1

func (v *CheckpointView) Root() (Root, error)

func (*CheckpointView) Set added in v0.12.1

func (v *CheckpointView) Set(ch *Checkpoint) error

type CommitteeBits added in v0.12.1

type CommitteeBits []byte

func (CommitteeBits) BitLen added in v0.12.1

func (cb CommitteeBits) BitLen() uint64

func (CommitteeBits) FilterNonParticipants added in v0.12.1

func (cb CommitteeBits) FilterNonParticipants(committee []ValidatorIndex) []ValidatorIndex

In-place filters a list of committees indices to only keep the bitfield NON-participants. The result is not sorted. Returns the re-sliced filtered non-participants list.

func (CommitteeBits) FilterParticipants added in v0.12.1

func (cb CommitteeBits) FilterParticipants(committee []ValidatorIndex) []ValidatorIndex

In-place filters a list of committees indices to only keep the bitfield participants. The result is not sorted. Returns the re-sliced filtered participants list.

func (CommitteeBits) GetBit added in v0.12.1

func (cb CommitteeBits) GetBit(i uint64) bool

func (*CommitteeBits) Limit added in v0.12.1

func (cb *CommitteeBits) Limit() uint64

func (CommitteeBits) Or added in v0.12.1

func (cb CommitteeBits) Or(other CommitteeBits)

Sets the bits to true that are true in other. (in place)

func (CommitteeBits) SetBit added in v0.12.1

func (cb CommitteeBits) SetBit(i uint64, v bool)

func (CommitteeBits) View added in v0.12.1

func (cb CommitteeBits) View() *CommitteeBitsView

type CommitteeBitsView added in v0.12.1

type CommitteeBitsView struct {
	*BitListView
}

func AsCommitteeBits added in v0.12.1

func AsCommitteeBits(v View, err error) (*CommitteeBitsView, error)

func (*CommitteeBitsView) Raw added in v0.12.1

type CommitteeIndex added in v0.12.1

type CommitteeIndex Uint64View

func AsCommitteeIndex added in v0.12.1

func AsCommitteeIndex(v View, err error) (CommitteeIndex, error)

type CommitteeIndices added in v0.12.1

type CommitteeIndices []ValidatorIndex

func (*CommitteeIndices) Limit added in v0.12.1

func (ci *CommitteeIndices) Limit() uint64

type Deltas

type Deltas struct {
	Rewards   GweiList
	Penalties GweiList
}

func NewDeltas

func NewDeltas(validatorCount uint64) *Deltas

func (*Deltas) Add

func (deltas *Deltas) Add(other *Deltas)

type Deposit

type Deposit struct {
	Proof [DEPOSIT_CONTRACT_TREE_DEPTH + 1]Root // Merkle-path to deposit root
	Data  DepositData
}

type DepositData

type DepositData struct {
	Pubkey                BLSPubkey
	WithdrawalCredentials Root
	Amount                Gwei
	// Signing over DepositMessage
	Signature BLSSignature
}

func (*DepositData) MessageRoot added in v0.12.1

func (d *DepositData) MessageRoot() Root

func (*DepositData) ToMessage added in v0.12.1

func (d *DepositData) ToMessage() *DepositMessage

type DepositIndex added in v0.12.1

type DepositIndex Uint64View

Eth1 deposit ordering

func AsDepositIndex added in v0.12.1

func AsDepositIndex(v View, err error) (DepositIndex, error)

type DepositMessage added in v0.12.1

type DepositMessage struct {
	Pubkey                BLSPubkey
	WithdrawalCredentials Root
	Amount                Gwei
}

type DepositRootsView added in v0.12.1

type DepositRootsView struct {
	*ComplexListView
}

func AsDepositRootsView added in v0.12.1

func AsDepositRootsView(v View, err error) (*DepositRootsView, error)

func NewDepositRootsView added in v0.12.1

func NewDepositRootsView() *DepositRootsView

type Deposits added in v0.12.1

type Deposits []Deposit

func (*Deposits) Limit added in v0.12.1

func (*Deposits) Limit() uint64

type Epoch added in v0.12.1

type Epoch Uint64View
const EPOCHS_PER_ETH1_VOTING_PERIOD Epoch = generated.EPOCHS_PER_ETH1_VOTING_PERIOD
const EPOCHS_PER_HISTORICAL_VECTOR Epoch = generated.EPOCHS_PER_HISTORICAL_VECTOR

State list lengths

const EPOCHS_PER_SLASHINGS_VECTOR Epoch = generated.EPOCHS_PER_SLASHINGS_VECTOR
const GENESIS_EPOCH Epoch = 0
const MAX_EPOCHS_PER_CROSSLINK Epoch = generated.MAX_EPOCHS_PER_CROSSLINK
const MAX_SEED_LOOKAHEAD Epoch = generated.MAX_SEED_LOOKAHEAD
const MIN_EPOCHS_TO_INACTIVITY_PENALTY Epoch = generated.MIN_EPOCHS_TO_INACTIVITY_PENALTY
const MIN_SEED_LOOKAHEAD Epoch = generated.MIN_SEED_LOOKAHEAD
const MIN_VALIDATOR_WITHDRAWABILITY_DELAY Epoch = generated.MIN_VALIDATOR_WITHDRAWABILITY_DELAY
const SHARD_COMMITTEE_PERIOD Epoch = generated.SHARD_COMMITTEE_PERIOD

func AsEpoch added in v0.12.1

func AsEpoch(v View, err error) (Epoch, error)

func (Epoch) ComputeActivationExitEpoch added in v0.12.1

func (e Epoch) ComputeActivationExitEpoch() Epoch

Return the epoch at which an activation or exit triggered in epoch takes effect.

func (Epoch) GetStartSlot added in v0.12.1

func (e Epoch) GetStartSlot() Slot

func (Epoch) Previous added in v0.12.1

func (e Epoch) Previous() Epoch

type EpochProcess added in v0.12.1

type EpochProcess struct {
	PrevEpoch Epoch
	CurrEpoch Epoch

	Statuses []AttesterStatus

	TotalActiveStake Gwei

	PrevEpochUnslashedStake EpochStakeSummary
	PrevEpochTargetStake    Gwei
	CurrEpochTargetStake    Gwei

	// Thanks to exit delay, this does not change within the epoch processing.
	ActiveValidators uint64

	IndicesToSlash                    []ValidatorIndex
	IndicesToSetActivationEligibility []ValidatorIndex
	// Ignores churn. Apply churn-limit manually.
	// Maybe, because finality affects it still.
	IndicesToMaybeActivate []ValidatorIndex

	IndicesToEject []ValidatorIndex

	ExitQueueEnd      Epoch
	ExitQueueEndChurn uint64
	ChurnLimit        uint64
}

type EpochStakeSummary added in v0.12.1

type EpochStakeSummary struct {
	SourceStake Gwei
	TargetStake Gwei
	HeadStake   Gwei
}

type EpochsContext added in v0.12.1

type EpochsContext struct {
	// PubkeyCache may be replaced when a new forked-out cache takes over to process an alternative Eth1 deposit chain.
	PubkeyCache *PubkeyCache
	Proposers   *[SLOTS_PER_EPOCH]ValidatorIndex

	PreviousEpoch *ShufflingEpoch
	CurrentEpoch  *ShufflingEpoch
	NextEpoch     *ShufflingEpoch
}

func (*EpochsContext) Clone added in v0.12.1

func (epc *EpochsContext) Clone() *EpochsContext

func (*EpochsContext) GetBeaconCommittee added in v0.12.1

func (epc *EpochsContext) GetBeaconCommittee(slot Slot, index CommitteeIndex) ([]ValidatorIndex, error)

Return the beacon committee at slot for index.

func (*EpochsContext) GetBeaconProposer added in v0.12.1

func (epc *EpochsContext) GetBeaconProposer(slot Slot) (ValidatorIndex, error)

func (*EpochsContext) GetCommitteeCountAtSlot added in v0.12.1

func (epc *EpochsContext) GetCommitteeCountAtSlot(slot Slot) (uint64, error)

func (*EpochsContext) LoadProposers added in v0.12.1

func (epc *EpochsContext) LoadProposers(state *BeaconStateView) error

func (*EpochsContext) LoadShuffling added in v0.12.1

func (epc *EpochsContext) LoadShuffling(state *BeaconStateView) error

func (*EpochsContext) RotateEpochs added in v0.12.1

func (epc *EpochsContext) RotateEpochs(state *BeaconStateView) error

type Eth1Data

type Eth1Data struct {
	DepositRoot  Root // Hash-tree-root of DepositData tree.
	DepositCount DepositIndex
	BlockHash    Root
}

func (*Eth1Data) View added in v0.12.1

func (dat *Eth1Data) View() *Eth1DataView

type Eth1DataView added in v0.12.1

type Eth1DataView struct{ *ContainerView }

func AsEth1Data added in v0.12.1

func AsEth1Data(v View, err error) (*Eth1DataView, error)

func (*Eth1DataView) DepositCount added in v0.12.1

func (v *Eth1DataView) DepositCount() (DepositIndex, error)

func (*Eth1DataView) DepositIndex added in v0.12.1

func (v *Eth1DataView) DepositIndex() (DepositIndex, error)

func (*Eth1DataView) DepositRoot added in v0.12.1

func (v *Eth1DataView) DepositRoot() (Root, error)

func (*Eth1DataView) SetDepositRoot added in v0.12.1

func (v *Eth1DataView) SetDepositRoot(r Root) error

type Eth1DataVotes added in v0.12.1

type Eth1DataVotes []Eth1Data

func (*Eth1DataVotes) Limit added in v0.12.1

func (_ *Eth1DataVotes) Limit() uint64

type Eth1DataVotesView added in v0.12.1

type Eth1DataVotesView struct{ *ComplexListView }

func AsEth1DataVotes added in v0.12.1

func AsEth1DataVotes(v View, err error) (*Eth1DataVotesView, error)

type FlatValidator added in v0.12.1

type FlatValidator struct {
	EffectiveBalance           Gwei
	Slashed                    bool
	ActivationEligibilityEpoch Epoch
	ActivationEpoch            Epoch
	ExitEpoch                  Epoch
	WithdrawableEpoch          Epoch
}

func ToFlatValidator added in v0.12.1

func ToFlatValidator(v *ValidatorView) (*FlatValidator, error)

func (*FlatValidator) IsActive added in v0.12.1

func (v *FlatValidator) IsActive(epoch Epoch) bool

type Fork

type Fork struct {
	PreviousVersion Version
	CurrentVersion  Version
	Epoch           Epoch
}

func (*Fork) View added in v0.12.1

func (f *Fork) View() *ForkView

type ForkData added in v0.12.1

type ForkData struct {
	CurrentVersion        Version
	GenesisValidatorsRoot Root
}

type ForkDigest added in v0.12.1

type ForkDigest [4]byte

A digest of the current fork data

func ComputeForkDigest added in v0.12.1

func ComputeForkDigest(currentVersion Version, genesisValidatorsRoot Root) ForkDigest

type ForkView added in v0.12.1

type ForkView struct{ *ContainerView }

func AsFork added in v0.12.1

func AsFork(v View, err error) (*ForkView, error)

func (*ForkView) CurrentVersion added in v0.12.1

func (f *ForkView) CurrentVersion() (Version, error)

func (*ForkView) Epoch added in v0.12.1

func (f *ForkView) Epoch() (Epoch, error)

func (*ForkView) PreviousVersion added in v0.12.1

func (f *ForkView) PreviousVersion() (Version, error)

func (*ForkView) Raw added in v0.12.1

func (f *ForkView) Raw() (*Fork, error)

type Gwei added in v0.12.1

type Gwei Uint64View
const EFFECTIVE_BALANCE_INCREMENT Gwei = generated.EFFECTIVE_BALANCE_INCREMENT
const EJECTION_BALANCE Gwei = generated.EJECTION_BALANCE

unused const FORK_CHOICE_BALANCE_INCREMENT Gwei = generated.FORK_CHOICE_BALANCE_INCREMENT

const MAX_EFFECTIVE_BALANCE Gwei = generated.MAX_EFFECTIVE_BALANCE
const MIN_DEPOSIT_AMOUNT Gwei = generated.MIN_DEPOSIT_AMOUNT

Gwei values

func AsGwei added in v0.12.1

func AsGwei(v View, err error) (Gwei, error)

type GweiList added in v0.12.1

type GweiList []Gwei

func (*GweiList) Limit added in v0.12.1

func (_ *GweiList) Limit() uint64

type HistoricalBatch

type HistoricalBatch struct {
	BlockRoots [SLOTS_PER_HISTORICAL_ROOT]Root
	StateRoots [SLOTS_PER_HISTORICAL_ROOT]Root
}

type HistoricalBatchView added in v0.12.1

type HistoricalBatchView struct{ *ContainerView }

func AsHistoricalBatch added in v0.12.1

func AsHistoricalBatch(v View, err error) (*HistoricalBatchView, error)

func (*HistoricalBatchView) BlockRoots added in v0.12.1

func (v *HistoricalBatchView) BlockRoots() (*BatchRootsView, error)

func (*HistoricalBatchView) StateRoots added in v0.12.1

func (v *HistoricalBatchView) StateRoots() (*BatchRootsView, error)

type HistoricalRoots added in v0.12.1

type HistoricalRoots []Root

roots of HistoricalBatch

func (*HistoricalRoots) Limit added in v0.12.1

func (_ *HistoricalRoots) Limit() uint64

type HistoricalRootsView added in v0.12.1

type HistoricalRootsView struct{ *ComplexListView }

roots of HistoricalBatch

func AsHistoricalRoots added in v0.12.1

func AsHistoricalRoots(v View, err error) (*HistoricalRootsView, error)

type IndexedAttestation

type IndexedAttestation struct {
	AttestingIndices CommitteeIndices
	Data             AttestationData
	Signature        BLSSignature
}

type JustificationBits added in v0.12.1

type JustificationBits [1]byte

func (*JustificationBits) BitLen added in v0.12.1

func (jb *JustificationBits) BitLen() uint64

func (*JustificationBits) IsJustified added in v0.12.1

func (jb *JustificationBits) IsJustified(epochsAgo ...Epoch) bool

func (*JustificationBits) NextEpoch added in v0.12.1

func (jb *JustificationBits) NextEpoch()

Prepare bitfield for next epoch by shifting previous bits (truncating to bitfield length)

type JustificationBitsView added in v0.12.1

type JustificationBitsView struct {
	*BitVectorView
}

func AsJustificationBits added in v0.12.1

func AsJustificationBits(v View, err error) (*JustificationBitsView, error)

func (*JustificationBitsView) Raw added in v0.12.1

func (*JustificationBitsView) Set added in v0.12.1

type KickstartValidatorData added in v0.12.1

type KickstartValidatorData struct {
	Pubkey                BLSPubkey
	WithdrawalCredentials Root
	Balance               Gwei
}

type PendingAttestation

type PendingAttestation struct {
	AggregationBits CommitteeBits
	Data            AttestationData
	InclusionDelay  Slot
	ProposerIndex   ValidatorIndex
}

func (*PendingAttestation) View added in v0.12.1

type PendingAttestationView added in v0.12.1

type PendingAttestationView struct{ *ContainerView }

func AsPendingAttestation added in v0.12.1

func AsPendingAttestation(v View, err error) (*PendingAttestationView, error)

func (*PendingAttestationView) Raw added in v0.12.1

type PendingAttestations added in v0.12.1

type PendingAttestations []*PendingAttestation

func (*PendingAttestations) Limit added in v0.12.1

func (*PendingAttestations) Limit() uint64

type PendingAttestationsView added in v0.12.1

type PendingAttestationsView struct{ *ComplexListView }

func AsPendingAttestations added in v0.12.1

func AsPendingAttestations(v View, err error) (*PendingAttestationsView, error)

type ProposerSlashing

type ProposerSlashing struct {
	SignedHeader1 SignedBeaconBlockHeader
	SignedHeader2 SignedBeaconBlockHeader
}

type ProposerSlashings added in v0.12.1

type ProposerSlashings []ProposerSlashing

func (*ProposerSlashings) Limit added in v0.12.1

func (*ProposerSlashings) Limit() uint64

type PubkeyCache added in v0.12.1

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

PubkeyCache is shared between any state. However, if .Append(index, pubkey) conflicts, a new cache will be forked out.

func EmptyPubkeyCache added in v0.12.1

func EmptyPubkeyCache() *PubkeyCache

func NewPubkeyCache added in v0.12.1

func NewPubkeyCache(state *BeaconStateView) (*PubkeyCache, error)

func (*PubkeyCache) AddValidator added in v0.12.1

func (pc *PubkeyCache) AddValidator(index ValidatorIndex, pub BLSPubkey) (*PubkeyCache, error)

AddValidator appends the (index, pubkey) pair to the pubkey cache. It returns the same cache if the added entry is not conflicting. If it conflicts, the common part is inherited, and a forked pubkey cache is returned.

func (*PubkeyCache) Pubkey added in v0.12.1

func (pc *PubkeyCache) Pubkey(index ValidatorIndex) (pub *CachedPubkey, ok bool)

Get the pubkey of a validator index. Note: this does not mean the validator is part of the current state. It merely means that this is a known pubkey for that particular validator (could be in a later part of a forked version of the state).

func (*PubkeyCache) ValidatorIndex added in v0.12.1

func (pc *PubkeyCache) ValidatorIndex(pubkey BLSPubkey) (index ValidatorIndex, ok bool)

Get the validator index of a pubkey. Note: this does not mean the validator is part of the current state. It merely means that this is a known pubkey for that particular validator (could be in a later part of a forked version of the state).

type RandaoMixesView added in v0.12.1

type RandaoMixesView struct{ *ComplexVectorView }

Randomness and committees

func AsRandaoMixes added in v0.12.1

func AsRandaoMixes(v View, err error) (*RandaoMixesView, error)

func SeedRandao added in v0.12.1

func SeedRandao(seed Root) (*RandaoMixesView, error)

func (*RandaoMixesView) GetRandomMix added in v0.12.1

func (mixes *RandaoMixesView) GetRandomMix(epoch Epoch) (Root, error)

Provides a source of randomness for the state, for e.g. shuffling

func (*RandaoMixesView) GetSeed added in v0.12.1

func (mixes *RandaoMixesView) GetSeed(epoch Epoch, domainType BLSDomainType) (Root, error)

func (*RandaoMixesView) PrepareRandao added in v0.12.1

func (mixes *RandaoMixesView) PrepareRandao(epoch Epoch) error

Prepare the randao mix for the given epoch by copying over the mix from the previous epoch.

func (*RandaoMixesView) SetRandomMix added in v0.12.1

func (mixes *RandaoMixesView) SetRandomMix(epoch Epoch, mix Root) error

type RegistryBalancesView added in v0.12.1

type RegistryBalancesView struct {
	*BasicListView
}

func AsRegistryBalances added in v0.12.1

func AsRegistryBalances(v View, err error) (*RegistryBalancesView, error)

func (*RegistryBalancesView) DecreaseBalance added in v0.12.1

func (v *RegistryBalancesView) DecreaseBalance(index ValidatorIndex, delta Gwei) error

func (*RegistryBalancesView) GetBalance added in v0.12.1

func (v *RegistryBalancesView) GetBalance(index ValidatorIndex) (Gwei, error)

func (*RegistryBalancesView) IncreaseBalance added in v0.12.1

func (v *RegistryBalancesView) IncreaseBalance(index ValidatorIndex, delta Gwei) error

func (*RegistryBalancesView) SetBalance added in v0.12.1

func (v *RegistryBalancesView) SetBalance(index ValidatorIndex, bal Gwei) error

type RegistryIndices added in v0.12.1

type RegistryIndices []ValidatorIndex

func (*RegistryIndices) HashTreeRoot added in v0.12.1

func (v *RegistryIndices) HashTreeRoot() Root

func (*RegistryIndices) Limit added in v0.12.1

func (*RegistryIndices) Limit() uint64

type RewardsAndPenalties added in v0.12.1

type RewardsAndPenalties struct {
	Source         *Deltas
	Target         *Deltas
	Head           *Deltas
	InclusionDelay *Deltas
	Inactivity     *Deltas
}

func NewRewardsAndPenalties added in v0.12.1

func NewRewardsAndPenalties(validatorCount uint64) *RewardsAndPenalties

type Root added in v0.12.1

type Root = tree.Root

func ComputeForkDataRoot added in v0.12.1

func ComputeForkDataRoot(currentVersion Version, genesisValidatorsRoot Root) Root

func ComputeSigningRoot added in v0.12.1

func ComputeSigningRoot(msgRoot Root, dom BLSDomain) Root

type Shard added in v0.12.1

type Shard Uint64View

type ShufflingEpoch added in v0.12.1

type ShufflingEpoch struct {
	Epoch         Epoch
	ActiveIndices []ValidatorIndex
	Shuffling     []ValidatorIndex // the active validator indices, shuffled into their committee
	// slot -> index of committee (< MAX_COMMITTEES_PER_SLOT) -> index of validator within committee -> validator
	Committees [SLOTS_PER_EPOCH][][]ValidatorIndex // slices of Shuffling, 1 per slot. Committee can be nil slice.
}

With a high amount of shards, or low amount of validators, some shards may not have a committee this epoch.

func NewShufflingEpoch added in v0.12.1

func NewShufflingEpoch(indicesBounded []BoundedIndex, seed Root, epoch Epoch) *ShufflingEpoch

type SignedBeaconBlock added in v0.12.1

type SignedBeaconBlock struct {
	Message   BeaconBlock
	Signature BLSSignature
}

func (*SignedBeaconBlock) SignedHeader added in v0.12.1

func (block *SignedBeaconBlock) SignedHeader() *SignedBeaconBlockHeader

type SignedBeaconBlockHeader added in v0.12.1

type SignedBeaconBlockHeader struct {
	Message   BeaconBlockHeader
	Signature BLSSignature
}

func (*SignedBeaconBlockHeader) HashTreeRoot added in v0.12.1

func (b *SignedBeaconBlockHeader) HashTreeRoot() Root

type SignedVoluntaryExit added in v0.12.1

type SignedVoluntaryExit struct {
	Message   VoluntaryExit
	Signature BLSSignature
}

type SigningData added in v0.12.1

type SigningData struct {
	ObjectRoot Root
	Domain     BLSDomain
}

type SlashingsView added in v0.12.1

type SlashingsView struct{ *BasicVectorView }

func AsSlashings added in v0.12.1

func AsSlashings(v View, err error) (*SlashingsView, error)

func (*SlashingsView) AddSlashing added in v0.12.1

func (sl *SlashingsView) AddSlashing(epoch Epoch, add Gwei) error

func (*SlashingsView) GetSlashingsValue added in v0.12.1

func (sl *SlashingsView) GetSlashingsValue(epoch Epoch) (Gwei, error)

func (*SlashingsView) ResetSlashings added in v0.12.1

func (sl *SlashingsView) ResetSlashings(epoch Epoch) error

func (*SlashingsView) Total added in v0.12.1

func (sl *SlashingsView) Total() (sum Gwei, err error)

type Slot added in v0.12.1

type Slot Uint64View
const GENESIS_SLOT Slot = 0
const MIN_ATTESTATION_INCLUSION_DELAY Slot = generated.MIN_ATTESTATION_INCLUSION_DELAY
const SLOTS_PER_EPOCH Slot = generated.SLOTS_PER_EPOCH
const SLOTS_PER_HISTORICAL_ROOT Slot = generated.SLOTS_PER_HISTORICAL_ROOT

func AsSlot added in v0.12.1

func AsSlot(v View, err error) (Slot, error)

func (Slot) ToEpoch added in v0.12.1

func (s Slot) ToEpoch() Epoch

type Timestamp added in v0.12.1

type Timestamp Uint64View

Unix timestamp

const GENESIS_DELAY Timestamp = generated.GENESIS_DELAY

Time parameters

const SECONDS_PER_SLOT Timestamp = generated.SECONDS_PER_SLOT

func AsTimestamp added in v0.12.1

func AsTimestamp(v View, err error) (Timestamp, error)

func (Timestamp) ToSlot added in v0.12.1

func (t Timestamp) ToSlot(genesisTime Timestamp) Slot

type Validator

type Validator struct {
	Pubkey                BLSPubkey
	WithdrawalCredentials Root // Commitment to pubkey for withdrawals
	EffectiveBalance      Gwei // Balance at stake
	Slashed               bool

	// Status epochs
	ActivationEligibilityEpoch Epoch // When criteria for activation were met
	ActivationEpoch            Epoch
	ExitEpoch                  Epoch
	WithdrawableEpoch          Epoch // When validator can withdraw funds
}

func (*Validator) View added in v0.12.1

func (v *Validator) View() *ValidatorView

type ValidatorIndex added in v0.12.1

type ValidatorIndex Uint64View

Index of a validator, pointing to a validator registry location

func AsValidatorIndex added in v0.12.1

func AsValidatorIndex(v View, err error) (ValidatorIndex, error)

func PermuteIndex added in v0.12.1

func PermuteIndex(index ValidatorIndex, listSize uint64, seed Root) ValidatorIndex

PermuteIndex shuffles an individual list item without allocating a complete list. Returns the index in the would-be shuffled list.

func UnpermuteIndex added in v0.12.1

func UnpermuteIndex(index ValidatorIndex, listSize uint64, seed Root) ValidatorIndex

UnpermuteIndex does the inverse of PermuteIndex, it returns the original index when given the same shuffling context parameters and permuted index.

type ValidatorRegistry

type ValidatorRegistry []*Validator

func (*ValidatorRegistry) Limit added in v0.12.1

func (_ *ValidatorRegistry) Limit() uint64

type ValidatorSet added in v0.12.1

type ValidatorSet []ValidatorIndex

Collection of validators, should always be sorted.

func (*ValidatorSet) Dedup added in v0.12.1

func (vs *ValidatorSet) Dedup()

De-duplicates entries in the set in-place. (util to make a valid set from a list with duplicates)

func (ValidatorSet) Intersects added in v0.12.1

func (vs ValidatorSet) Intersects(target ValidatorSet) bool

Joins two validator sets: check if there is any overlap

func (ValidatorSet) Len added in v0.12.1

func (vs ValidatorSet) Len() int

func (ValidatorSet) Less added in v0.12.1

func (vs ValidatorSet) Less(i int, j int) bool

func (ValidatorSet) MergeDisjoint added in v0.12.1

func (vs ValidatorSet) MergeDisjoint(other ValidatorSet) ValidatorSet

merges with other disjoint set, producing a new set.

func (ValidatorSet) Swap added in v0.12.1

func (vs ValidatorSet) Swap(i int, j int)

func (ValidatorSet) ZigZagJoin added in v0.12.1

func (vs ValidatorSet) ZigZagJoin(target ValidatorSet, onIn func(i ValidatorIndex), onOut func(i ValidatorIndex))

Joins two validator sets: reports all indices of source that are in the target (call onIn), and those that are not (call onOut)

type ValidatorView added in v0.12.1

type ValidatorView struct {
	*ContainerView
}

func AsValidator added in v0.12.1

func AsValidator(v View, err error) (*ValidatorView, error)

func NewValidatorView added in v0.12.1

func NewValidatorView() *ValidatorView

func (*ValidatorView) ActivationEligibilityEpoch added in v0.12.1

func (v *ValidatorView) ActivationEligibilityEpoch() (Epoch, error)

func (*ValidatorView) ActivationEpoch added in v0.12.1

func (v *ValidatorView) ActivationEpoch() (Epoch, error)

func (*ValidatorView) EffectiveBalance added in v0.12.1

func (v *ValidatorView) EffectiveBalance() (Gwei, error)

func (*ValidatorView) ExitEpoch added in v0.12.1

func (v *ValidatorView) ExitEpoch() (Epoch, error)

func (*ValidatorView) IsActive added in v0.12.1

func (v *ValidatorView) IsActive(epoch Epoch) (bool, error)

func (*ValidatorView) IsEligibleForActivation added in v0.12.1

func (v *ValidatorView) IsEligibleForActivation(finalizedEpoch Epoch) (bool, error)

func (*ValidatorView) IsEligibleForActivationQueue added in v0.12.1

func (v *ValidatorView) IsEligibleForActivationQueue() (bool, error)

func (*ValidatorView) IsSlashable added in v0.12.1

func (v *ValidatorView) IsSlashable(epoch Epoch) (bool, error)

func (*ValidatorView) MakeSlashed added in v0.12.1

func (v *ValidatorView) MakeSlashed() error

func (*ValidatorView) Pubkey added in v0.12.1

func (v *ValidatorView) Pubkey() (BLSPubkey, error)

func (*ValidatorView) SetActivationEligibilityEpoch added in v0.12.1

func (v *ValidatorView) SetActivationEligibilityEpoch(epoch Epoch) error

func (*ValidatorView) SetActivationEpoch added in v0.12.1

func (v *ValidatorView) SetActivationEpoch(epoch Epoch) error

func (*ValidatorView) SetEffectiveBalance added in v0.12.1

func (v *ValidatorView) SetEffectiveBalance(b Gwei) error

func (*ValidatorView) SetExitEpoch added in v0.12.1

func (v *ValidatorView) SetExitEpoch(ep Epoch) error

func (*ValidatorView) SetWithdrawableEpoch added in v0.12.1

func (v *ValidatorView) SetWithdrawableEpoch(epoch Epoch) error

func (*ValidatorView) Slashed added in v0.12.1

func (v *ValidatorView) Slashed() (BoolView, error)

func (*ValidatorView) WithdrawableEpoch added in v0.12.1

func (v *ValidatorView) WithdrawableEpoch() (Epoch, error)

func (*ValidatorView) WithdrawalCredentials added in v0.12.1

func (v *ValidatorView) WithdrawalCredentials() (out Root, err error)

type ValidatorsRegistryView added in v0.12.1

type ValidatorsRegistryView struct{ *ComplexListView }

func AsValidatorsRegistry added in v0.12.1

func AsValidatorsRegistry(v View, err error) (*ValidatorsRegistryView, error)

func (*ValidatorsRegistryView) Validator added in v0.12.1

func (registry *ValidatorsRegistryView) Validator(index ValidatorIndex) (*ValidatorView, error)

func (*ValidatorsRegistryView) ValidatorCount added in v0.12.1

func (registry *ValidatorsRegistryView) ValidatorCount() (uint64, error)

type Version added in v0.12.1

type Version [4]byte

32 bits, not strictly an integer, hence represented as 4 bytes (bytes not necessarily corresponding to versions)

func AsVersion added in v0.12.1

func AsVersion(v View, err error) (Version, error)

func (Version) ToUint32 added in v0.12.1

func (v Version) ToUint32() uint32

func (Version) View added in v0.12.1

func (v Version) View() SmallByteVecView

type VoluntaryExit

type VoluntaryExit struct {
	Epoch          Epoch // Earliest epoch when voluntary exit can be processed
	ValidatorIndex ValidatorIndex
}

func (*VoluntaryExit) HashTreeRoot added in v0.12.1

func (v *VoluntaryExit) HashTreeRoot() Root

type VoluntaryExits added in v0.12.1

type VoluntaryExits []SignedVoluntaryExit

func (*VoluntaryExits) Limit added in v0.12.1

func (*VoluntaryExits) Limit() uint64

Jump to

Keyboard shortcuts

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