github.com/celestiaorg/celestia-node@v0.15.0-beta.1/header/doc.go (about)

     1  /*
     2  Package header contains all services related to generating, requesting, syncing and storing
     3  ExtendedHeaders.
     4  
     5  An ExtendedHeader is similar to a regular block header from celestia-core, but "extended" by adding
     6  the DataAvailabilityHeader (DAH), ValidatorSet and Commit in order to allow for light and full nodes
     7  to reconstruct block data by referencing the DAH.
     8  
     9  ExtendedHeaders are generated by bridge nodes that listen to the celestia-core network for blocks,
    10  validate and extend the block data in order to generate the DAH, and request both the ValidatorSet
    11  and Commit for that block height from the celestia-core network. Bridge nodes then package that data
    12  up into an ExtendedHeader and broadcast it to the 'header-sub' GossipSub topic (HeaderSub). All nodes subscribed
    13  to HeaderSub will receive and validate the ExtendedHeader, and store it, making it available to all
    14  other dependent services (such as the DataAvailabilitySampler, or DASer) to access.
    15  
    16  There are 5 main components in the header package:
    17   1. core.Listener listens for new blocks from the celestia-core network (run by bridge nodes only),
    18      extends them, generates a new ExtendedHeader, and publishes it to the HeaderSub.
    19   2. p2p.Subscriber listens for new ExtendedHeaders from the Celestia Data Availability (DA) network (via
    20      the HeaderSub)
    21   3. p2p.Exchange or core.Exchange request ExtendedHeaders from other celestia DA nodes (default for
    22      full and light nodes) or from a celestia-core node connection (bridge nodes only)
    23   4. Syncer manages syncing of past and recent ExtendedHeaders from either the DA network or a celestia-core
    24      connection (bridge nodes only).
    25   5. Store manages storing ExtendedHeaders and making them available for access by other dependent services.
    26  
    27  For bridge nodes, the general flow of the header Service is as follows:
    28   1. core.Listener listens for new blocks from the celestia-core connection
    29   2. core.Listener validates the block and generates the ExtendedHeader, simultaneously storing the
    30      extended block shares to disk
    31   3. core.Listener publishes the new ExtendedHeader to HeaderSub, notifying all subscribed peers of the new
    32      ExtendedHeader
    33   4. Syncer is already subscribed to the HeaderSub, so it receives new ExtendedHeaders locally from
    34      the core.Listener and stores them to disk via Store.
    35      - If the celestia-core connection is started simultaneously with the bridge node, then the celestia-core
    36      connection will handle the syncing component, piping every synced block to the core.Listener
    37      - If the celestia-core connection is already synced to the network, the Syncer handles requesting past
    38      headers up to the network head from the celestia-core connection (using core.Exchange rather than p2p.Exchange).
    39  
    40  For full and light nodes, the general flow of the header Service is as follows:
    41   1. Syncer listens for new ExtendedHeaders from HeaderSub
    42   2. If there is a gap between the local head of chain and the new, validated network head, the Syncer
    43      kicks off a sync routine to request all ExtendedHeaders between local head and network head.
    44   3. While the Syncer requests headers between the local head and network head in batches, it appends them to the
    45      subjective chain via Store with the last batched header as the new local head.
    46  */
    47  package header