beacon

package
v0.6.4-2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 12 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttestationDataAndCustodyBitSSZ = zssz.GetSSZ((*AttestationDataAndCustodyBit)(nil))
View Source
var BeaconBlockBodySSZ = zssz.GetSSZ((*BeaconBlockBody)(nil))
View Source
var BeaconBlockHeaderSSZ = zssz.GetSSZ((*BeaconBlockHeader)(nil))
View Source
var BeaconBlockSSZ = zssz.GetSSZ((*BeaconBlock)(nil))
View Source
var BeaconStateSSZ = zssz.GetSSZ((*BeaconState)(nil))
View Source
var CrosslinkSSZ = zssz.GetSSZ((*Crosslink)(nil))
View Source
var DepositDataSSZ = zssz.GetSSZ((*DepositData)(nil))
View Source
var HistoricalBatchSSZ = zssz.GetSSZ((*HistoricalBatch)(nil))
View Source
var TransferSSZ = zssz.GetSSZ((*Transfer)(nil))
View Source
var ValidatorIndexListSSZ = zssz.GetSSZ((*[]ValidatorIndex)(nil))
View Source
var VoluntaryExitSSZ = zssz.GetSSZ((*VoluntaryExit)(nil))

Functions

This section is empty.

Types

type Attestation

type Attestation struct {
	// Attester aggregation bitfield
	AggregationBitfield bitfield.Bitfield
	// Attestation data
	Data AttestationData
	// Custody bitfield
	CustodyBitfield bitfield.Bitfield
	// BLS aggregate signature
	Signature BLSSignature
}

type AttestationData

type AttestationData struct {
	// Root of the signed beacon block
	BeaconBlockRoot Root

	// FFG vote
	SourceEpoch Epoch
	SourceRoot  Root
	TargetEpoch Epoch
	TargetRoot  Root

	// Crosslink vote
	Shard                 Shard
	PreviousCrosslinkRoot Root
	CrosslinkDataRoot     Root
}

type AttestationDataAndCustodyBit

type AttestationDataAndCustodyBit struct {
	// Attestation data
	Data AttestationData
	// Custody bit
	CustodyBit bool
}

type AttesterSlashing

type AttesterSlashing struct {
	// First attestation
	Attestation1 IndexedAttestation
	// Second attestation
	Attestation2 IndexedAttestation
}

type BeaconBlock

type BeaconBlock struct {
	// Header
	Slot              Slot
	PreviousBlockRoot Root
	StateRoot         Root

	// Body
	Body BeaconBlockBody
	// Signature
	Signature BLSSignature
}

type BeaconBlockBody

type BeaconBlockBody struct {
	RandaoReveal BLSSignature
	Eth1Data     Eth1Data
	Graffiti     Root

	ProposerSlashings []ProposerSlashing
	AttesterSlashings []AttesterSlashing
	Attestations      []Attestation
	Deposits          []Deposit
	VoluntaryExits    []VoluntaryExit
	Transfers         []Transfer
}

type BeaconBlockHeader

type BeaconBlockHeader struct {
	Slot              Slot
	PreviousBlockRoot Root
	StateRoot         Root

	// Where the body would be, just a root embedded here.
	BlockBodyRoot Root
	// Signature
	Signature BLSSignature
}

type BeaconState

type BeaconState struct {
	// Misc
	Slot        Slot
	GenesisTime Timestamp
	Fork        Fork

	// Validator registry
	ValidatorRegistry ValidatorRegistry
	Balances          []Gwei

	// Randomness and committees
	LatestRandaoMixes [LATEST_RANDAO_MIXES_LENGTH]Root
	LatestStartShard  Shard

	// Finality
	PreviousEpochAttestations []*PendingAttestation
	CurrentEpochAttestations  []*PendingAttestation
	PreviousJustifiedEpoch    Epoch
	CurrentJustifiedEpoch     Epoch
	PreviousJustifiedRoot     Root
	CurrentJustifiedRoot      Root
	JustificationBitfield     uint64
	FinalizedEpoch            Epoch
	FinalizedRoot             Root

	// Recent state
	CurrentCrosslinks      [SHARD_COUNT]Crosslink
	PreviousCrosslinks     [SHARD_COUNT]Crosslink
	LatestBlockRoots       [SLOTS_PER_HISTORICAL_ROOT]Root
	LatestStateRoots       [SLOTS_PER_HISTORICAL_ROOT]Root
	LatestActiveIndexRoots [LATEST_ACTIVE_INDEX_ROOTS_LENGTH]Root
	// Balances slashed at every withdrawal period
	LatestSlashedBalances [LATEST_SLASHED_EXIT_LENGTH]Gwei
	LatestBlockHeader     BeaconBlockHeader
	HistoricalRoots       []Root

	// Ethereum 1.0 chain data
	LatestEth1Data Eth1Data
	Eth1DataVotes  []Eth1Data
	DepositIndex   DepositIndex
}

func (*BeaconState) ApplyDeltas

func (state *BeaconState) ApplyDeltas(deltas *Deltas)

func (*BeaconState) ConvertToIndexed

func (state *BeaconState) ConvertToIndexed(attestation *Attestation) (*IndexedAttestation, error)

Convert attestation to (almost) indexed-verifiable form

func (*BeaconState) Copy

func (state *BeaconState) Copy() *BeaconState

Make a deep copy of the state object

func (*BeaconState) DecreaseBalance

func (state *BeaconState) DecreaseBalance(index ValidatorIndex, delta Gwei)

func (*BeaconState) Epoch

func (state *BeaconState) Epoch() Epoch

Get current epoch

func (*BeaconState) ExitValidator

func (state *BeaconState) ExitValidator(index ValidatorIndex)

Exit the validator with the given index

func (*BeaconState) FilterUnslashed

func (state *BeaconState) FilterUnslashed(indices []ValidatorIndex) []ValidatorIndex

Filters a slice in-place. Only keeps the unslashed validators. If input is sorted, then the result will be sorted.

func (*BeaconState) GenerateSeed

func (state *BeaconState) GenerateSeed(epoch Epoch) Root

Generate a seed for the given epoch

func (*BeaconState) GetActiveIndexRoot

func (state *BeaconState) GetActiveIndexRoot(epoch Epoch) Root

func (*BeaconState) GetAttestationSlot

func (state *BeaconState) GetAttestationSlot(attData *AttestationData) Slot

TODO: spec should refer to AttestationData here instead of Attestation

func (*BeaconState) GetAttesters

func (state *BeaconState) GetAttesters(attestations []*PendingAttestation, filter func(att *AttestationData) bool) ValidatorSet

func (*BeaconState) GetAttestingIndices

func (state *BeaconState) GetAttestingIndices(attestationData *AttestationData, bitfield *bitfield.Bitfield) (ValidatorSet, error)

Return the sorted attesting indices at for the attestation_data and bitfield

func (*BeaconState) GetAttestingIndicesUnsorted

func (state *BeaconState) GetAttestingIndicesUnsorted(attestationData *AttestationData, bitfield *bitfield.Bitfield) ([]ValidatorIndex, error)

Return the sorted attesting indices at for the attestation_data and bitfield

func (*BeaconState) GetBeaconProposerIndex

func (state *BeaconState) GetBeaconProposerIndex() ValidatorIndex

Return the beacon proposer index for the current slot

func (*BeaconState) GetBlockRoot

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

Return the block root at a recent epoch

func (*BeaconState) GetBlockRootAtSlot

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

Return the block root at the given slot (a recent one)

func (*BeaconState) GetChurnLimit

func (state *BeaconState) GetChurnLimit() uint64

func (*BeaconState) GetCrosslinkCommittee

func (state *BeaconState) GetCrosslinkCommittee(epoch Epoch, shard Shard) []ValidatorIndex

func (*BeaconState) GetCrosslinkFromAttestationData

func (state *BeaconState) GetCrosslinkFromAttestationData(data *AttestationData) *Crosslink

func (*BeaconState) GetDomain

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

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

func (*BeaconState) GetEpochCommitteeCount

func (state *BeaconState) GetEpochCommitteeCount(epoch Epoch) uint64

Return the number of committees in one epoch.

func (*BeaconState) GetEpochStartShard

func (state *BeaconState) GetEpochStartShard(epoch Epoch) Shard

func (*BeaconState) GetRandaoMix

func (state *BeaconState) GetRandaoMix(epoch Epoch) Root

func (*BeaconState) GetShardDelta

func (state *BeaconState) GetShardDelta(epoch Epoch) Shard

Return the number of shards to increment state.latest_start_shard during epoch

func (*BeaconState) GetTotalBalance

func (state *BeaconState) GetTotalBalance() (sum Gwei)

Return the total balance sum

func (*BeaconState) GetTotalBalanceOf

func (state *BeaconState) GetTotalBalanceOf(indices []ValidatorIndex) (sum Gwei)

Return the combined effective balance of an array of validators.

func (*BeaconState) GetWinningCrosslinkAndAttestingIndices

func (state *BeaconState) GetWinningCrosslinkAndAttestingIndices(shard Shard, epoch Epoch) (Crosslink, ValidatorSet)

func (*BeaconState) IncreaseBalance

func (state *BeaconState) IncreaseBalance(index ValidatorIndex, delta Gwei)

func (*BeaconState) InitiateValidatorExit

func (state *BeaconState) InitiateValidatorExit(index ValidatorIndex)

Initiate the validator of the given index

func (*BeaconState) PreviousEpoch

func (state *BeaconState) PreviousEpoch() Epoch

Return previous epoch.

func (*BeaconState) SlashValidator

func (state *BeaconState) SlashValidator(slashedIndex ValidatorIndex, whistleblowerIndex *ValidatorIndex) error

Slash the validator with the given index.

func (*BeaconState) VerifyIndexedAttestation

func (state *BeaconState) VerifyIndexedAttestation(indexedAttestation *IndexedAttestation) error

Verify validity of slashable_attestation fields.

type Crosslink struct {
	// Epoch number
	Epoch Epoch
	// Root of the previous crosslink
	PreviousCrosslinkRoot Root
	// Root of the crosslinked shard data since the previous crosslink
	CrosslinkDataRoot Root
}

type Deltas

type Deltas struct {
	// element for each validator in registry
	Rewards []Gwei
	// element for each validator in registry
	Penalties []Gwei
}

func NewDeltas

func NewDeltas(validatorCount uint64) *Deltas

func (*Deltas) Add

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

type DeltasCalculator

type DeltasCalculator func(state *BeaconState) *Deltas

type Deposit

type Deposit struct {
	// Branch in the deposit tree
	Proof [DEPOSIT_CONTRACT_TREE_DEPTH]Root
	// Index in the deposit tree
	Index DepositIndex
	// Data
	Data DepositData
}

type DepositData

type DepositData struct {
	// BLS pubkey
	Pubkey BLSPubkey
	// Withdrawal credentials
	WithdrawalCredentials Root
	// Amount in Gwei
	Amount Gwei
	// Container self-signature
	Signature BLSSignature
}

type Eth1Data

type Eth1Data struct {
	// Root of the deposit tree
	DepositRoot Root
	// Total number of deposits
	DepositCount DepositIndex
	// Block hash
	BlockHash Root
}

type Fork

type Fork struct {
	// Previous fork version
	PreviousVersion ForkVersion
	// Current fork version
	CurrentVersion ForkVersion
	// Fork epoch number
	Epoch Epoch
}

type HistoricalBatch

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

type IndexedAttestation

type IndexedAttestation struct {
	// Validator Indices
	CustodyBit0Indices []ValidatorIndex
	CustodyBit1Indices []ValidatorIndex
	// Attestation data
	Data AttestationData
	// BLS aggregate signature
	Signature BLSSignature
}

type PendingAttestation

type PendingAttestation struct {
	// Attester aggregation bitfield
	AggregationBitfield bitfield.Bitfield
	// Attestation data
	Data AttestationData
	// Inclusion delay
	InclusionDelay Slot
	// Proposer index
	ProposerIndex ValidatorIndex
}

type ProposerSlashing

type ProposerSlashing struct {
	// Proposer index
	ProposerIndex ValidatorIndex
	// First proposal
	Header1 BeaconBlockHeader
	// Second proposal
	Header2 BeaconBlockHeader
}

type Transfer

type Transfer struct {
	// Sender index
	Sender ValidatorIndex
	// Recipient index
	Recipient ValidatorIndex
	// Amount in Gwei
	Amount Gwei
	// Fee in Gwei for block proposer
	Fee Gwei
	// Inclusion slot
	Slot Slot
	// Sender withdrawal pubkey
	Pubkey BLSPubkey
	// Sender signature
	Signature BLSSignature
}

type Validator

type Validator struct {
	// BLS public key
	Pubkey BLSPubkey
	// Withdrawal credentials
	WithdrawalCredentials Root
	// Epoch when became eligible for activation
	ActivationEligibilityEpoch Epoch
	// Epoch when validator activated
	ActivationEpoch Epoch
	// Epoch when validator exited
	ExitEpoch Epoch
	// Epoch when validator is eligible to withdraw
	WithdrawableEpoch Epoch
	// Was the validator slashed
	Slashed bool
	// Effective balance
	EffectiveBalance Gwei
}

func (*Validator) Copy

func (v *Validator) Copy() *Validator

func (*Validator) IsActive

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

func (*Validator) IsSlashable

func (v *Validator) IsSlashable(epoch Epoch) bool

type ValidatorRegistry

type ValidatorRegistry []*Validator

func (ValidatorRegistry) GetActiveValidatorCount

func (vr ValidatorRegistry) GetActiveValidatorCount(epoch Epoch) (count uint64)

func (ValidatorRegistry) GetActiveValidatorIndices

func (vr ValidatorRegistry) GetActiveValidatorIndices(epoch Epoch) []ValidatorIndex

func (ValidatorRegistry) IsValidatorIndex

func (vr ValidatorRegistry) IsValidatorIndex(index ValidatorIndex) bool

type VoluntaryExit

type VoluntaryExit struct {
	// Minimum epoch for processing exit
	Epoch Epoch
	// Index of the exiting validator
	ValidatorIndex ValidatorIndex
	// Validator signature
	Signature BLSSignature
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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