Below are my notes from investigating the Lighthouse code base, with a focus on understanding the CL client and eip-4844 functionalities.
Tokio is an event-driven, non-blocking I/O platform for writing asynchronous I/O backed applications. It is used in Lighthouse for communication between asynchronous tasks.
NOTE: This diagram is not complete. My goal right now is to try to understand how the Lighthouse consensus layer works at a high level, so I have intentionally skipped some functionalities (metrics, validator etc), error paths and details. Any feedback is welcomed!
Main
Entry point of the Lighthouse program. Parses CLI args, network configs and pass all parameters to beacon_node
constructor when the beacon_node
subcommand is used.
ProductionBeaconNode
constructorhead_block
and head_state
from store
(code)community_caches
, pubkey_cache
, exit_cache
Router
: Handles messages received from the network and client and organises syncing. See Router
section below.AttestationService
SyncCommitteeService
NetworkService
and spawn the taskexchange_transition_configuration
endpoint.Router
Processor
. codeProcessor
BeaconProcessor
"manager" task which checks the receiver end of the channelBeaconBlockAndBlobsSidecars
message is received, it sends WorkEvent<GossipBlockAndBlobsSidecar>
to a mpsc
channel using an mpsc::Sender
. This is then handled by the BeaconProcessor
below.BeaconProcessor
Handles events produced by beacon_processor_send
via a mpsc
channel.
spawn_worker
: called by the "manager" task to spawns a blocking worker thread to process some Work
.GossipBlockAndBlobsSidecar
Work type is handled hereper_block_processing
logic is another interesting area to look into as part of eip-4844 implementation, as it's now processes blob kzg commitments. code
per_block_processing
is called in various places:
beacon_chain/src/beacon_chain.rs
: unable to find referencebeacon_chain/src/block_verification.rs
: used when:
Work::ChainSegment
Work::RpcBlock
Work::GossipBlock
Work::DelayedImportBlock
beacon_chain/src/fork_revert.rs
store/src/reconstruct.rs
consensus/state_processing/src/block_replyer.rs