Documentation ¶
Overview ¶
Package sync TODO(3147): Add details on how sync works.
Package sync includes all chain-synchronization logic for the beacon node, including gossip-sub validators for blocks, attestations, and other p2p messages, as well as ability to process and respond to block requests by peers.
Index ¶
- Variables
- func BlobRPCMinValidSlot(current primitives.Slot) (primitives.Slot, error)
- func ReadChunkedBlock(stream libp2pcore.Stream, tor blockchain.TemporalOracle, ...) (interfaces.ReadOnlySignedBeaconBlock, error)
- func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (uint8, string, error)
- func SendBeaconBlocksByRangeRequest(ctx context.Context, tor blockchain.TemporalOracle, ...) ([]interfaces.ReadOnlySignedBeaconBlock, error)
- func SendBeaconBlocksByRootRequest(ctx context.Context, clock blockchain.TemporalOracle, p2pProvider p2p.P2P, ...) ([]interfaces.ReadOnlySignedBeaconBlock, error)
- func SendBlobSidecarByRoot(ctx context.Context, tor blockchain.TemporalOracle, p2pApi p2p.P2P, ...) ([]blocks.ROBlob, error)
- func SendBlobsByRangeRequest(ctx context.Context, tor blockchain.TemporalOracle, p2pApi p2p.SenderEncoder, ...) ([]blocks.ROBlob, error)
- func SetRPCStreamDeadlines(stream network.Stream)
- func SetStreamReadDeadline(stream network.Stream, duration time.Duration)
- func SetStreamWriteDeadline(stream network.Stream, duration time.Duration)
- func WriteBlobSidecarChunk(stream libp2pcore.Stream, tor blockchain.TemporalOracle, ...) error
- func WriteBlockChunk(stream libp2pcore.Stream, tor blockchain.TemporalOracle, ...) error
- type BeaconBlockProcessor
- type BlobResponseValidation
- type Checker
- type ContextByteVersions
- type Option
- func WithAttestationNotifier(notifier operation.Notifier) Option
- func WithAttestationPool(attPool attestations.Pool) Option
- func WithAvailableBlocker(avb coverage.AvailableBlocker) Option
- func WithBlobStorage(b *filesystem.BlobStorage) Option
- func WithBlockNotifier(blockNotifier blockfeed.Notifier) Option
- func WithBlsToExecPool(blsToExecPool blstoexec.PoolManager) Option
- func WithChainService(chain blockchainService) Option
- func WithClockWaiter(cw startup.ClockWaiter) Option
- func WithDatabase(db db.NoHeadAccessDatabase) Option
- func WithExitPool(exitPool voluntaryexits.PoolManager) Option
- func WithInitialSync(initialSync Checker) Option
- func WithInitialSyncComplete(c chan struct{}) Option
- func WithOperationNotifier(operationNotifier operation.Notifier) Option
- func WithP2P(p2p p2p.P2P) Option
- func WithPayloadReconstructor(r execution.PayloadReconstructor) Option
- func WithSlasherAttestationsFeed(slasherAttestationsFeed *event.Feed) Option
- func WithSlasherBlockHeadersFeed(slasherBlockHeadersFeed *event.Feed) Option
- func WithSlashingPool(slashingPool slashings.PoolManager) Option
- func WithStateGen(stateGen *stategen.State) Option
- func WithStateNotifier(n statefeed.Notifier) Option
- func WithSyncCommsPool(syncCommsPool synccommittee.Pool) Option
- func WithVerifierWaiter(v *verification.InitializerWaiter) Option
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidFetchedData is used to signal that an error occurred which should result in peer downscoring. ErrInvalidFetchedData = errors.New("invalid data returned from peer") )
Any error from the following declaration block should result in peer downscoring.
var ErrNoValidDigest = errors.New("no valid digest matched")
var (
ErrOptimisticParent = errors.New("parent of the block is optimistic")
)
var ErrUnrecognizedVersion = errors.New("cannot determine context bytes for unrecognized object")
Functions ¶
func BlobRPCMinValidSlot ¶ added in v5.0.2
func BlobRPCMinValidSlot(current primitives.Slot) (primitives.Slot, error)
BlobRPCMinValidSlot returns the lowest slot that we should expect peers to respect as the start slot in a BlobSidecarsByRange request. This can be used to validate incoming requests and to avoid pestering peers with requests for blobs that are outside the retention window.
func ReadChunkedBlock ¶
func ReadChunkedBlock(stream libp2pcore.Stream, tor blockchain.TemporalOracle, p2p p2p.EncodingProvider, isFirstChunk bool) (interfaces.ReadOnlySignedBeaconBlock, error)
ReadChunkedBlock handles each response chunk that is sent by the peer and converts it into a beacon block.
func ReadStatusCode ¶
ReadStatusCode response from a RPC stream.
func SendBeaconBlocksByRangeRequest ¶
func SendBeaconBlocksByRangeRequest( ctx context.Context, tor blockchain.TemporalOracle, p2pProvider p2p.SenderEncoder, pid peer.ID, req *pb.BeaconBlocksByRangeRequest, blockProcessor BeaconBlockProcessor, ) ([]interfaces.ReadOnlySignedBeaconBlock, error)
SendBeaconBlocksByRangeRequest sends BeaconBlocksByRange and returns fetched blocks, if any.
func SendBeaconBlocksByRootRequest ¶
func SendBeaconBlocksByRootRequest( ctx context.Context, clock blockchain.TemporalOracle, p2pProvider p2p.P2P, pid peer.ID, req *p2ptypes.BeaconBlockByRootsReq, blockProcessor BeaconBlockProcessor, ) ([]interfaces.ReadOnlySignedBeaconBlock, error)
SendBeaconBlocksByRootRequest sends BeaconBlocksByRoot and returns fetched blocks, if any.
func SendBlobSidecarByRoot ¶
func SendBlobSidecarByRoot( ctx context.Context, tor blockchain.TemporalOracle, p2pApi p2p.P2P, pid peer.ID, ctxMap ContextByteVersions, req *p2ptypes.BlobSidecarsByRootReq, ) ([]blocks.ROBlob, error)
func SendBlobsByRangeRequest ¶
func SendBlobsByRangeRequest(ctx context.Context, tor blockchain.TemporalOracle, p2pApi p2p.SenderEncoder, pid peer.ID, ctxMap ContextByteVersions, req *pb.BlobSidecarsByRangeRequest, bvs ...BlobResponseValidation) ([]blocks.ROBlob, error)
func SetRPCStreamDeadlines ¶
SetRPCStreamDeadlines sets read and write deadlines for libp2p-based connection streams.
func SetStreamReadDeadline ¶
SetStreamReadDeadline for reading from libp2p connection streams, deciding when to close a connection based on a particular duration.
NOTE: libp2p uses the system clock time for determining the deadline so we use time.Now() instead of the synchronized roughtime.Now(). If the system time is corrupted (i.e. time does not advance), the node will experience issues being able to properly close streams, leading to unexpected failures and possible memory leaks.
func SetStreamWriteDeadline ¶
SetStreamWriteDeadline for writing to libp2p connection streams, deciding when to close a connection based on a particular duration.
NOTE: libp2p uses the system clock time for determining the deadline so we use time.Now() instead of the synchronized roughtime.Now(). If the system time is corrupted (i.e. time does not advance), the node will experience issues being able to properly close streams, leading to unexpected failures and possible memory leaks.
func WriteBlobSidecarChunk ¶
func WriteBlobSidecarChunk(stream libp2pcore.Stream, tor blockchain.TemporalOracle, encoding encoder.NetworkEncoding, sidecar blocks.VerifiedROBlob) error
WriteBlobSidecarChunk writes blob chunk object to stream. response_chunk ::= <result> | <context-bytes> | <encoding-dependent-header> | <encoded-payload>
func WriteBlockChunk ¶
func WriteBlockChunk(stream libp2pcore.Stream, tor blockchain.TemporalOracle, encoding encoder.NetworkEncoding, blk interfaces.ReadOnlySignedBeaconBlock) error
WriteBlockChunk writes block chunk object to stream. response_chunk ::= <result> | <context-bytes> | <encoding-dependent-header> | <encoded-payload>
Types ¶
type BeaconBlockProcessor ¶
type BeaconBlockProcessor func(block interfaces.ReadOnlySignedBeaconBlock) error
BeaconBlockProcessor defines a block processing function, which allows to start utilizing blocks even before all blocks are ready.
type BlobResponseValidation ¶
BlobResponseValidation represents a function that can validate aspects of a single unmarshaled blob that was received from a peer in response to an rpc request.
type Checker ¶
type Checker interface { Initialized() bool Syncing() bool Synced() bool Status() error Resync() error }
Checker defines a struct which can verify whether a node is currently synchronizing a chain with the rest of peers in the network.
type ContextByteVersions ¶
ContextByteVersions is a mapping between expected values for context bytes and the runtime/version identifier they correspond to. This can be used to look up the type needed to unmarshal a wire-encoded value.
func ContextByteVersionsForValRoot ¶
func ContextByteVersionsForValRoot(valRoot [32]byte) (ContextByteVersions, error)
ContextByteVersionsForValRoot computes a mapping between all possible context bytes values and the runtime/version identifier for the corresponding fork.
type Option ¶
func WithAttestationNotifier ¶
func WithAttestationPool ¶
func WithAttestationPool(attPool attestations.Pool) Option
func WithAvailableBlocker ¶
func WithAvailableBlocker(avb coverage.AvailableBlocker) Option
WithAvailableBlocker allows the sync package to access the current status of backfill.
func WithBlobStorage ¶
func WithBlobStorage(b *filesystem.BlobStorage) Option
WithBlobStorage gives the sync package direct access to BlobStorage.
func WithBlockNotifier ¶
func WithBlsToExecPool ¶
func WithBlsToExecPool(blsToExecPool blstoexec.PoolManager) Option
func WithChainService ¶
func WithChainService(chain blockchainService) Option
func WithClockWaiter ¶
func WithClockWaiter(cw startup.ClockWaiter) Option
func WithDatabase ¶
func WithDatabase(db db.NoHeadAccessDatabase) Option
func WithExitPool ¶
func WithExitPool(exitPool voluntaryexits.PoolManager) Option
func WithInitialSync ¶
func WithInitialSyncComplete ¶
func WithInitialSyncComplete(c chan struct{}) Option
func WithOperationNotifier ¶
func WithPayloadReconstructor ¶
func WithPayloadReconstructor(r execution.PayloadReconstructor) Option
func WithSlashingPool ¶
func WithSlashingPool(slashingPool slashings.PoolManager) Option
func WithStateGen ¶
func WithStateNotifier ¶
WithStateNotifier to notify an event feed of state processing.
func WithSyncCommsPool ¶
func WithSyncCommsPool(syncCommsPool synccommittee.Pool) Option
func WithVerifierWaiter ¶
func WithVerifierWaiter(v *verification.InitializerWaiter) Option
WithVerifierWaiter gives the sync package direct access to the verifier waiter.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is responsible for handling all run time p2p related operations as the main entry point for network messages.
func NewService ¶
NewService initializes new regular sync service.
Source Files ¶
- batch_verifier.go
- block_batcher.go
- broadcast_bls_changes.go
- context.go
- deadlines.go
- decode_pubsub.go
- doc.go
- error.go
- fork_watcher.go
- log.go
- metrics.go
- options.go
- pending_attestations_queue.go
- pending_blocks_queue.go
- rate_limiter.go
- rpc.go
- rpc_beacon_blocks_by_range.go
- rpc_beacon_blocks_by_root.go
- rpc_blob_sidecars_by_range.go
- rpc_blob_sidecars_by_root.go
- rpc_chunked_response.go
- rpc_goodbye.go
- rpc_metadata.go
- rpc_ping.go
- rpc_send_request.go
- rpc_status.go
- service.go
- subscriber.go
- subscriber_beacon_aggregate_proof.go
- subscriber_beacon_attestation.go
- subscriber_beacon_blocks.go
- subscriber_blob_sidecar.go
- subscriber_bls_to_execution_change.go
- subscriber_handlers.go
- subscriber_sync_committee_message.go
- subscriber_sync_contribution_proof.go
- subscription_topic_handler.go
- validate_aggregate_proof.go
- validate_attester_slashing.go
- validate_beacon_attestation.go
- validate_beacon_blocks.go
- validate_blob.go
- validate_bls_to_execution_change.go
- validate_proposer_slashing.go
- validate_sync_committee_message.go
- validate_sync_contribution_proof.go
- validate_voluntary_exit.go
Directories ¶
Path | Synopsis |
---|---|
Package initialsync includes all initial block download and processing logic for the beacon node, using a round robin strategy and a finite-state-machine to handle edge-cases in a beacon node's sync status.
|
Package initialsync includes all initial block download and processing logic for the beacon node, using a round robin strategy and a finite-state-machine to handle edge-cases in a beacon node's sync status. |
testing
Package testing includes useful mocks for testing initial sync status in unit tests.
|
Package testing includes useful mocks for testing initial sync status in unit tests. |