Skip to content

New storage model (CAS?) #533

@Shimuuar

Description

@Shimuuar

In PoW we lost block uniqueness: there could be multiple blocks at same height. Thus we can't store blocks using height as key. Only other choice is to switch to block hash as key. Obvious consequence of this approach is content addressable storage (CAS). Even PBFT will benefit since we'll be able to deduplicate some values (validator sets for example).

It's not quite clear how we should design API for such store. Let take definition of block:

data GBlock f a = Block
  { blockHeight           :: !Height
  , blockPrevBlockID      :: !(Maybe (BlockID a))
  , blockValidators       :: !(Hashed (Alg a) (ValidatorSet (Alg a)))
  , blockNewValidators    :: !(Hashed (Alg a) (ValidatorSet (Alg a)))
  , blockPrevCommit       :: !(Maybe (MerkleNode f (Alg a) (Commit a)))
  , blockEvidence         :: !(MerkleNode f (Alg a) [ByzantineEvidence a])
  , blockData             :: !(MerkleNode f (Alg a) a)
  , blockStateHash        :: !(Hashed (Alg a) (BlockchainState a))
  }

We want to be able to fetch both block header and complete block. This means we need to store GBlock Hashed a in database and store commit, evidence, and data as separate entries using their hash as key.

This brings us to question of garbage collection. Primarily it's about removing old state snapshots. State snapshots are naturally stored using hash as key however some optimized representation could be used. Anyhow we'll need to prune old snapshots regularly. It's even more complicated for PoW. There inevitably will be blocks which will be abandoned and fall back enough that it could be pruned from BCH.

Additionally we'll need to track head of blockchain and corresponding amount of work for PoW.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions