Documentation ¶
Overview ¶
Package blockchain defines the life-cycle and status of the beacon chain as well as the Ethereum Serenity beacon chain fork-choice rule based on Casper Proof of Stake finality.
Index ¶
- type AttestationReceiver
- type BlockReceiver
- type CanonicalRootFetcher
- type ChainFeeds
- type ChainInfoFetcher
- type Config
- type FinalizationFetcher
- type ForkFetcher
- type GenesisTimeFetcher
- type HeadFetcher
- type NewHeadNotifier
- type Service
- func (s *Service) CanonicalRoot(slot uint64) []byte
- func (s *Service) CurrentFork() *pb.Fork
- func (s *Service) FinalizedCheckpt() *ethpb.Checkpoint
- func (s *Service) GenesisTime() time.Time
- func (s *Service) HeadBlock() *ethpb.BeaconBlock
- func (s *Service) HeadRoot() []byte
- func (s *Service) HeadSlot() uint64
- func (s *Service) HeadState() *pb.BeaconState
- func (s *Service) HeadUpdatedFeed() *event.Feed
- func (s *Service) HeadsHandler(w http.ResponseWriter, _ *http.Request)
- func (s *Service) ReceiveAttestation(ctx context.Context, att *ethpb.Attestation) error
- func (s *Service) ReceiveAttestationNoPubsub(ctx context.Context, att *ethpb.Attestation) error
- func (s *Service) ReceiveBlock(ctx context.Context, block *ethpb.BeaconBlock) error
- func (s *Service) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconBlock) error
- func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.BeaconBlock) error
- func (s *Service) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.BeaconBlock) error
- func (s *Service) Start()
- func (s *Service) StateInitializedFeed() *event.Feed
- func (s *Service) Status() error
- func (s *Service) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttestationReceiver ¶
type AttestationReceiver interface { ReceiveAttestation(ctx context.Context, att *ethpb.Attestation) error ReceiveAttestationNoPubsub(ctx context.Context, att *ethpb.Attestation) error }
AttestationReceiver interface defines the methods of chain service receive and processing new attestations.
type BlockReceiver ¶
type BlockReceiver interface { ReceiveBlock(ctx context.Context, block *ethpb.BeaconBlock) error ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconBlock) error ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.BeaconBlock) error ReceiveBlockNoVerify(ctx context.Context, block *ethpb.BeaconBlock) error }
BlockReceiver interface defines the methods of chain service receive and processing new blocks.
type CanonicalRootFetcher ¶
CanonicalRootFetcher defines a common interface for methods in blockchain service which directly retrieves canonical roots related data.
type ChainFeeds ¶
ChainFeeds interface defines the methods of the Service which provide state related information feeds to consumers.
type ChainInfoFetcher ¶
type ChainInfoFetcher interface { HeadFetcher CanonicalRootFetcher FinalizationFetcher }
ChainInfoFetcher defines a common interface for methods in blockchain service which directly retrieves chain info related data.
type Config ¶
type Config struct { BeaconBlockBuf int ChainStartFetcher powchain.ChainStartFetcher BeaconDB db.Database DepositCache *depositcache.DepositCache OpsPoolService operations.OperationFeeds P2p p2p.Broadcaster MaxRoutines int64 }
Config options for the service.
type FinalizationFetcher ¶
type FinalizationFetcher interface {
FinalizedCheckpt() *ethpb.Checkpoint
}
FinalizationFetcher defines a common interface for methods in blockchain service which directly retrieves finalization related data.
type ForkFetcher ¶
ForkFetcher retrieves the current fork information of the Ethereum beacon chain.
type GenesisTimeFetcher ¶
GenesisTimeFetcher retrieves the Eth2 genesis timestamp.
type HeadFetcher ¶
type HeadFetcher interface { HeadSlot() uint64 HeadRoot() []byte HeadBlock() *ethpb.BeaconBlock HeadState() *pb.BeaconState }
HeadFetcher defines a common interface for methods in blockchain service which directly retrieves head related data.
type NewHeadNotifier ¶
NewHeadNotifier defines a struct which can notify many consumers of a new, canonical chain head event occuring in the node.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents a service that handles the internal logic of managing the full PoS beacon chain.
func NewService ¶
NewService instantiates a new block service instance that will be registered into a running beacon node.
func (*Service) CanonicalRoot ¶
CanonicalRoot returns the canonical root of a given slot.
func (*Service) CurrentFork ¶
CurrentFork retrieves the latest fork information of the beacon chain.
func (*Service) FinalizedCheckpt ¶
func (s *Service) FinalizedCheckpt() *ethpb.Checkpoint
FinalizedCheckpt returns the latest finalized checkpoint tracked in fork choice service.
func (*Service) GenesisTime ¶
GenesisTime returns the genesis time of beacon chain.
func (*Service) HeadBlock ¶
func (s *Service) HeadBlock() *ethpb.BeaconBlock
HeadBlock returns the head block of the chain.
func (*Service) HeadState ¶
func (s *Service) HeadState() *pb.BeaconState
HeadState returns the head state of the chain.
func (*Service) HeadUpdatedFeed ¶
HeadUpdatedFeed is a feed containing the head block root and is written to when a new head block is saved to DB.
func (*Service) HeadsHandler ¶
func (s *Service) HeadsHandler(w http.ResponseWriter, _ *http.Request)
HeadsHandler is a handler to serve /heads page in metrics.
func (*Service) ReceiveAttestation ¶
ReceiveAttestation is a function that defines the operations that are preformed on attestation that is received from regular sync. The operations consist of:
- Gossip attestation to other peers
- Validate attestation, update validator's latest vote
- Apply fork choice to the processed attestation
- Save latest head info
func (*Service) ReceiveAttestationNoPubsub ¶
ReceiveAttestationNoPubsub is a function that defines the operations that are preformed on attestation that is received from regular sync. The operations consist of:
- Validate attestation, update validator's latest vote
- Apply fork choice to the processed attestation
- Save latest head info
func (*Service) ReceiveBlock ¶
ReceiveBlock is a function that defines the operations that are preformed on blocks that is received from rpc service. The operations consists of:
- Gossip block to other peers
- Validate block, apply state transition and update check points
- Apply fork choice to the processed block
- Save latest head info
func (*Service) ReceiveBlockNoPubsub ¶
ReceiveBlockNoPubsub is a function that defines the the operations (minus pubsub) that are preformed on blocks that is received from regular sync service. The operations consists of:
- Validate block, apply state transition and update check points
- Apply fork choice to the processed block
- Save latest head info
func (*Service) ReceiveBlockNoPubsubForkchoice ¶
func (s *Service) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.BeaconBlock) error
ReceiveBlockNoPubsubForkchoice is a function that defines the all operations (minus pubsub and forkchoice) that are preformed blocks that is received from initial sync service. The operations consists of:
- Validate block, apply state transition and update check points
- Save latest head info
func (*Service) ReceiveBlockNoVerify ¶
ReceiveBlockNoVerify runs state transition on a input block without verifying the block's BLS contents. Depends on the security model, this is the "minimal" work a node can do to sync the chain. It simulates light client behavior and assumes 100% trust with the syncing peer.
func (*Service) StateInitializedFeed ¶
StateInitializedFeed returns a feed that is written to when the beacon state is first initialized.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package forkchoice implements the Latest Message Driven GHOST (Greediest Heaviest Observed Sub-Tree) algorithm as the Ethereum Serenity beacon chain fork choice rule.
|
Package forkchoice implements the Latest Message Driven GHOST (Greediest Heaviest Observed Sub-Tree) algorithm as the Ethereum Serenity beacon chain fork choice rule. |