hexresearch / hexresearch/hschain

New storage model (CAS?)

Open
#533 1 comment 0 reactions 0 assignees View on GitHub
DB enhancement
Dominant language
C
Stars
4
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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:
```haskell
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.