Module grin_chain::pipe

source ·
Expand description

Implementation of the chain block acceptance (or refusal) pipeline.

Structs§

  • Contextual information required to process a new block and either reject or accept it.

Functions§

  • Runs the block processing pipeline, including validation and finding a place for the new block in the chain. Returns new head if chain head updated and the “fork point” rewound to when processing the new block.
  • Process a block header. Update the header MMR and corresponding header_head if this header increases the total work relative to header_head. Note: In contrast to processing a full block we treat “already known” as success to allow processing to continue (for header itself).
  • Process a batch of sequential block headers. This is only used during header sync. Will update header_head locally if this batch of headers increases total work. Returns the updated sync_head, which may be on a fork.
  • Utility function to handle forks. From the forked block, jump backward to find to fork point. Rewind the txhashset to the fork point and apply all necessary blocks prior to the one being processed to set the txhashset in the expected state. Returns the “fork point” that we rewound to.
  • Rewind the header chain and reapply headers on a fork.
  • Validate header against an explicit “denylist” of header hashes. Returns a “Block” error which is “bad_data” and will result in peer being banned.