Documentation
¶
Index ¶
- Variables
- type BlockSink
- type BlockSinkFn
- type BlockSlotKey
- type Chain
- type ChainEntry
- type ChainID
- type ChainIter
- type Chains
- type ChainsMap
- type Checkpoint
- type ColdChain
- type ColdChainIter
- type Epoch
- type FinalizedChain
- func (f *FinalizedChain) ByBlockRoot(root Root) (ChainEntry, error)
- func (f *FinalizedChain) BySlot(slot Slot) (ChainEntry, error)
- func (f *FinalizedChain) ByStateRoot(root Root) (ChainEntry, error)
- func (f *FinalizedChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
- func (f *FinalizedChain) End() Slot
- func (f *FinalizedChain) Iter() (ChainIter, error)
- func (f *FinalizedChain) OnFinalizedEntry(entry *HotEntry) error
- func (f *FinalizedChain) Start() Slot
- type FinalizedEntryView
- func (e *FinalizedEntryView) BlockRoot() (root Root)
- func (e *FinalizedEntryView) EpochsContext(ctx context.Context) (*beacon.EpochsContext, error)
- func (e *FinalizedEntryView) IsEmpty() bool
- func (e *FinalizedEntryView) ParentRoot() (root Root)
- func (e *FinalizedEntryView) Slot() Slot
- func (e *FinalizedEntryView) State(ctx context.Context) (*beacon.BeaconStateView, error)
- func (e *FinalizedEntryView) StateRoot() Root
- type FullChain
- type FullChainIter
- type Gwei
- type HotChain
- type HotChainIter
- type HotColdChain
- func (hc *HotColdChain) ByBlockRoot(root Root) (ChainEntry, error)
- func (hc *HotColdChain) BySlot(slot Slot) (ChainEntry, error)
- func (hc *HotColdChain) ByStateRoot(root Root) (ChainEntry, error)
- func (hc *HotColdChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
- func (hc *HotColdChain) Iter() (ChainIter, error)
- type HotEntry
- func (e *HotEntry) BlockRoot() (root Root)
- func (e *HotEntry) EpochsContext(ctx context.Context) (*beacon.EpochsContext, error)
- func (e *HotEntry) IsEmpty() bool
- func (e *HotEntry) ParentRoot() (root Root)
- func (e *HotEntry) Slot() Slot
- func (e *HotEntry) State(ctx context.Context) (*beacon.BeaconStateView, error)
- func (e *HotEntry) StateRoot() Root
- type Root
- type Slot
- type UnfinalizedChain
- func (uc *UnfinalizedChain) AddAttestation(att *beacon.Attestation) error
- func (uc *UnfinalizedChain) AddBlock(ctx context.Context, signedBlock *beacon.SignedBeaconBlock) error
- func (uc *UnfinalizedChain) ByBlockRoot(root Root) (ChainEntry, error)
- func (uc *UnfinalizedChain) ByBlockSlot(key BlockSlotKey) (ChainEntry, error)
- func (uc *UnfinalizedChain) BySlot(slot Slot) (ChainEntry, error)
- func (uc *UnfinalizedChain) ByStateRoot(root Root) (ChainEntry, error)
- func (uc *UnfinalizedChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
- func (uc *UnfinalizedChain) Finalized() Checkpoint
- func (uc *UnfinalizedChain) Head() (ChainEntry, error)
- func (uc *UnfinalizedChain) Iter() (ChainIter, error)
- func (uc *UnfinalizedChain) Justified() Checkpoint
- func (uc *UnfinalizedChain) OnPrunedBlock(node *forkchoice.ProtoNode, canonical bool) error
- type ValidatorIndex
Constants ¶
This section is empty.
Variables ¶
View Source
var UnknownRootErr = errors.New("unknown root")
Functions ¶
This section is empty.
Types ¶
type BlockSinkFn ¶
type BlockSlotKey ¶
type BlockSlotKey [32 + 8]byte
func NewBlockSlotKey ¶
func NewBlockSlotKey(block Root, slot Slot) (out BlockSlotKey)
func (*BlockSlotKey) Root ¶
func (key *BlockSlotKey) Root() (out Root)
func (*BlockSlotKey) Slot ¶
func (key *BlockSlotKey) Slot() Slot
type Chain ¶
type Chain interface {
ByStateRoot(root Root) (ChainEntry, error)
ByBlockRoot(root Root) (ChainEntry, error)
ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
BySlot(slot Slot) (ChainEntry, error)
Iter() (ChainIter, error)
}
type ChainEntry ¶
type ChainEntry interface {
// Slot of this entry
Slot() Slot
// BlockRoot returns the last block root, replicating the previous block root if the current slot has none.
BlockRoot() (root Root)
// The parent block root. If this is an empty slot, it will just be previous block root. Can also be zeroed if unknown.
ParentRoot() (root Root)
// If this is an empty slot, i.e. no block
IsEmpty() bool
// State root (of the post-state of this entry). Should match state-root in the block at the same slot (if any)
StateRoot() Root
// The context of this chain entry (shuffling, proposers, etc.)
EpochsContext(ctx context.Context) (*beacon.EpochsContext, error)
// State of the entry, a data-sharing view. Call .Copy() before modifying this to preserve validity.
State(ctx context.Context) (*beacon.BeaconStateView, error)
}
type ChainIter ¶
type ChainIter interface {
// Start is the minimum slot to reach to, inclusive.
Start() Slot
// End is the maximum slot to reach to, exclusive.
End() Slot
// Entry fetches the chain entry at the given slot.
// If it does not exist, entry=nil, err=nil.
// If the request is out of bounds or fails, an error may be returned.
Entry(slot Slot) (entry ChainEntry, err error)
}
type ChainsMap ¶
type ChainsMap struct {
// contains filtered or unexported fields
}
type Checkpoint ¶
type Checkpoint = beacon.Checkpoint
type ColdChainIter ¶
func (*ColdChainIter) End ¶
func (fi *ColdChainIter) End() Slot
func (*ColdChainIter) Entry ¶
func (fi *ColdChainIter) Entry(slot Slot) (entry ChainEntry, err error)
func (*ColdChainIter) Start ¶
func (fi *ColdChainIter) Start() Slot
type FinalizedChain ¶
type FinalizedChain struct {
// Cache of pubkeys, may contain pubkeys that are not finalized,
// but finalized state will not be in conflict with this cache.
PubkeyCache *beacon.PubkeyCache
// Start of the historical data
AnchorSlot Slot
// Block roots, starting at AnchorSlot
// A blockRoot can be a copy of the previous root if current entry is empty
BlockRoots []Root
// State roots, starting at AnchorSlot
StateRoots []Root
// BlockRoots maps the canonical chain block roots to the block slot
SlotsByBlockRoot map[Root]Slot
// BlockRoots maps the canonical chain state roots to the state slot
SlotsByStateRoot map[Root]Slot
}
func NewFinalizedChain ¶
func NewFinalizedChain(anchorSlot Slot) *FinalizedChain
func (*FinalizedChain) ByBlockRoot ¶
func (f *FinalizedChain) ByBlockRoot(root Root) (ChainEntry, error)
func (*FinalizedChain) BySlot ¶
func (f *FinalizedChain) BySlot(slot Slot) (ChainEntry, error)
func (*FinalizedChain) ByStateRoot ¶
func (f *FinalizedChain) ByStateRoot(root Root) (ChainEntry, error)
func (*FinalizedChain) ClosestFrom ¶
func (f *FinalizedChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
func (*FinalizedChain) End ¶
func (f *FinalizedChain) End() Slot
func (*FinalizedChain) Iter ¶
func (f *FinalizedChain) Iter() (ChainIter, error)
func (*FinalizedChain) OnFinalizedEntry ¶
func (f *FinalizedChain) OnFinalizedEntry(entry *HotEntry) error
func (*FinalizedChain) Start ¶
func (f *FinalizedChain) Start() Slot
type FinalizedEntryView ¶
type FinalizedEntryView struct {
// contains filtered or unexported fields
}
func (*FinalizedEntryView) BlockRoot ¶
func (e *FinalizedEntryView) BlockRoot() (root Root)
func (*FinalizedEntryView) EpochsContext ¶
func (e *FinalizedEntryView) EpochsContext(ctx context.Context) (*beacon.EpochsContext, error)
func (*FinalizedEntryView) IsEmpty ¶
func (e *FinalizedEntryView) IsEmpty() bool
func (*FinalizedEntryView) ParentRoot ¶
func (e *FinalizedEntryView) ParentRoot() (root Root)
func (*FinalizedEntryView) Slot ¶
func (e *FinalizedEntryView) Slot() Slot
func (*FinalizedEntryView) State ¶
func (e *FinalizedEntryView) State(ctx context.Context) (*beacon.BeaconStateView, error)
func (*FinalizedEntryView) StateRoot ¶
func (e *FinalizedEntryView) StateRoot() Root
type FullChain ¶
type FullChain interface {
Chain
Justified() Checkpoint
Finalized() Checkpoint
Head() (ChainEntry, error)
AddBlock(ctx context.Context, signedBlock *beacon.SignedBeaconBlock) error
AddAttestation(att *beacon.Attestation) error
Start() Slot
End() Slot
OnFinalizedEntry(entry *HotEntry) error
}
TODO: in Go 1.15 this can be overlapping embedded interfaces
type FullChainIter ¶
func (*FullChainIter) End ¶
func (fi *FullChainIter) End() Slot
func (*FullChainIter) Entry ¶
func (fi *FullChainIter) Entry(slot Slot) (entry ChainEntry, err error)
func (*FullChainIter) Start ¶
func (fi *FullChainIter) Start() Slot
type HotChain ¶
type HotChain interface {
Chain
Justified() Checkpoint
Finalized() Checkpoint
Head() (ChainEntry, error)
// Process a block. If there is an error, the chain is not mutated, and can be continued to use.
AddBlock(ctx context.Context, signedBlock *beacon.SignedBeaconBlock) error
// Process an attestation. If there is an error, the chain is not mutated, and can be continued to use.
AddAttestation(att *beacon.Attestation) error
}
type HotChainIter ¶
type HotChainIter struct {
// contains filtered or unexported fields
}
func (*HotChainIter) End ¶
func (fi *HotChainIter) End() Slot
func (*HotChainIter) Entry ¶
func (fi *HotChainIter) Entry(slot Slot) (entry ChainEntry, err error)
func (*HotChainIter) Start ¶
func (fi *HotChainIter) Start() Slot
type HotColdChain ¶
func (*HotColdChain) ByBlockRoot ¶
func (hc *HotColdChain) ByBlockRoot(root Root) (ChainEntry, error)
func (*HotColdChain) BySlot ¶
func (hc *HotColdChain) BySlot(slot Slot) (ChainEntry, error)
func (*HotColdChain) ByStateRoot ¶
func (hc *HotColdChain) ByStateRoot(root Root) (ChainEntry, error)
func (*HotColdChain) ClosestFrom ¶
func (hc *HotColdChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
func (*HotColdChain) Iter ¶
func (hc *HotColdChain) Iter() (ChainIter, error)
type HotEntry ¶
type HotEntry struct {
// contains filtered or unexported fields
}
func NewHotEntry ¶
func NewHotEntry( slot Slot, blockRoot Root, parentRoot Root, state *beacon.BeaconStateView, epc *beacon.EpochsContext) *HotEntry
func (*HotEntry) EpochsContext ¶
func (*HotEntry) ParentRoot ¶
type UnfinalizedChain ¶
type UnfinalizedChain struct {
ForkChoice *forkchoice.ForkChoice
AnchorSlot Slot
// block++slot -> Entry
Entries map[BlockSlotKey]*HotEntry
// state root -> block+slot key
State2Key map[Root]BlockSlotKey
// BlockSink takes pruned entries and their canon status, and processes them.
// Empty-slot entries will only occur for canonical chain,
// non-canonical empty entries are ignored, as there can theoretically be an unlimited number of.
// Non-canonical non-empty entries are still available, to track what is getting abandoned by the chain
BlockSink BlockSink
}
func NewUnfinalizedChain ¶
func NewUnfinalizedChain(finalizedBlock *HotEntry, sink BlockSink) (*UnfinalizedChain, error)
func (*UnfinalizedChain) AddAttestation ¶
func (uc *UnfinalizedChain) AddAttestation(att *beacon.Attestation) error
func (*UnfinalizedChain) AddBlock ¶
func (uc *UnfinalizedChain) AddBlock(ctx context.Context, signedBlock *beacon.SignedBeaconBlock) error
func (*UnfinalizedChain) ByBlockRoot ¶
func (uc *UnfinalizedChain) ByBlockRoot(root Root) (ChainEntry, error)
func (*UnfinalizedChain) ByBlockSlot ¶
func (uc *UnfinalizedChain) ByBlockSlot(key BlockSlotKey) (ChainEntry, error)
func (*UnfinalizedChain) BySlot ¶
func (uc *UnfinalizedChain) BySlot(slot Slot) (ChainEntry, error)
func (*UnfinalizedChain) ByStateRoot ¶
func (uc *UnfinalizedChain) ByStateRoot(root Root) (ChainEntry, error)
func (*UnfinalizedChain) ClosestFrom ¶
func (uc *UnfinalizedChain) ClosestFrom(fromBlockRoot Root, toSlot Slot) (ChainEntry, error)
func (*UnfinalizedChain) Finalized ¶
func (uc *UnfinalizedChain) Finalized() Checkpoint
func (*UnfinalizedChain) Head ¶
func (uc *UnfinalizedChain) Head() (ChainEntry, error)
func (*UnfinalizedChain) Iter ¶
func (uc *UnfinalizedChain) Iter() (ChainIter, error)
func (*UnfinalizedChain) Justified ¶
func (uc *UnfinalizedChain) Justified() Checkpoint
func (*UnfinalizedChain) OnPrunedBlock ¶
func (uc *UnfinalizedChain) OnPrunedBlock(node *forkchoice.ProtoNode, canonical bool) error
type ValidatorIndex ¶
type ValidatorIndex = beacon.ValidatorIndex
Click to show internal directories.
Click to hide internal directories.