Crate cc_consensus_poa[][src]

Expand description

Proof of Access consensus

Introduction

Proof of Access is a kind of lightweight storage consensus initially adopted by Arweave. In arweave, PoA serves as an enhancement of Proof of Work in which the entire recall block data is included in the material to be hashed for input to the proof of work.

Requiring ProofOfAccess incentivises storage as miners need access to random blocks from the blockweave’s history in order to mine new blocks and receive mining rewards.

Overview

The general workflow of PoA is described briefly below:

  1. Pick a random byte from the whole network storage space, aka BlockWeave.

    • The block weave can be seen as an ever growing gigantic array.
    • Currently, the randome byte is determined by hashing the parent header hash for N times(see calculate_challenge_byte), which will be replaced with another strategy in SPoRA.
  2. Locate the extrinsic in which the random byte is included.

  3. Check if the data of extrinsic located in Step 2 exists in the local storage.

    • If the data does exist locally, create the two merkle proofs of extrinsic and data chunks respectively.
    • If not, repeat from Step 1 by choosing another random byte with N+1 hashing.

Usage

Technically, PoA needs to be used with other traditional consensus algorithems like PoW or PoS together as it’s not typically designed for solving the problem of selecting one from a set of validators to create next block in an unpredictable or fair way. In another word, PoA is not intended for resolving the leader election problem, and is usually exploited as a precondition for PoW or PoS in order to encourage the miners to store more data locally.

This crate implements the core algorithem of Proof of Access in construct_poa and provides the inherent data provider via PoaInherentDataProvider. PurePoaBlockImport implements the BlockImport trait, thus can be wrapped in another block importer.

To use this engine, you can create an inhehrent extrinsic using the data provided by PoaInherentDataProvider in a pallet, refer to pallet_poa::Call::deposit as an example. Furthermore, you need to wrap the PurePoaBlockImport into your existing block import pipeline. Refer to the Substrate docs for more information about creating a nested BlockImport.

Structs

This struct includes the raw bytes of recall chunk as well as the chunk proof stuffs.

A builder for creating a ChunkProof from the entire raw transaction data.

A verifier for chunk proof.

A builder for creating PoaOutcome.

Configuration of the PoA consensus engine.

A type for creating the inherent data for pallet poa.

This struct is used to prove the historical random data access of block author.

A pure block importer for PoA.

All information of recall block that is required to build a ProofOfAccess.

A verifier for tx proof.

Enums

Error type for poa consensus.

This struct represents the outcome of creating the inherent data of ProofOfAccess.

Errors that can occur while checking the validity of ProofOfAccess.

Constants

The engine id for the Proof of Access consensus.

Functions

Returns the calculated merkle proof given extrinsic_index and extrinsics_root.

Returns the position of recall byte in the entire weave.

Returns a PoaOutcome after the poa construction.

Verifies the chunk matches given chunk_root and proof.

Verify the extrinsic proof against the extrinsics root and related encoded extrinsic.