sc_consensus_subspace

Module archiver

source
Expand description

Consensus archiver responsible for archival of blockchain history, it is driven by block import pipeline.

Implements archiving process in Subspace blockchain that converts blockchain history (blocks) into archived history (pieces).

The main entry point here is create_subspace_archiver that will create a task, which while driven will perform the archiving itself.

Archiving is triggered by block importing notification (SubspaceLink::block_importing_notification_stream) and tries to archive the block at ChainConstants::confirmation_depth_k depth from the block being imported. Block import will then wait for archiver to acknowledge processing, which is necessary for ensuring that when the next block is imported, inherents will contain segment header of newly archived block (must happen exactly in the next block).

Archiving itself will also wait for acknowledgement by various subscribers before proceeding, which includes farmer subscription, in case of reference implementation via RPC (sc-consensus-subspace-rpc), but could also be in other ways.

SegmentHeadersStore is maintained as a data structure containing all known (including future in case of syncing) segment headers. This data structure contents is then made available to other parts of the protocol that need to know what correct archival history of the blockchain looks like. For example, it is used during node sync and farmer plotting in order to verify pieces of archival history received from other network participants.

recreate_genesis_segment is a bit of a hack and is useful for deriving of the genesis segment that is special case since we don’t have enough data in the blockchain history itself during genesis in order to do the archiving.

encode_block and decode_block are symmetric encoding/decoding functions turning [SignedBlock]s into bytes and back.

Structs§

Enums§

Functions§