Closed andrewnguyen22 closed 1 year ago
@andrewnguyen22 I had closed #1442 per the comment
closes https://github.com/pokt-network/pocket-core/issues/1442
in favor of this ticket #1467
Lmk if that makes sense! CC @oten91
Rebased and continued here : https://github.com/pokt-network/pocket-core/pull/1500
tl;dr Better, faster, smaller, simpler persistence layer
closes #1442
Pocket Network Persistence Replacement
Background:
The IAVL store (Cosmos’ app level storage tree) is the legacy implementation that serves as both the merkle root integrity structure and the general purpose database structure for reads. Though the structure is seemingly efficient at generating merkle roots for the ABCI AppHash, Pocket Network observes a considerable downgrade in performance for historical queries, block processing, and overall disk size management. The idea behind Pocket Network’s Persistence Replacement is to preserve the efficient state commitment root generation while providing an alternative implementation for DB reads. The idea is to prune N-X IAVL versions in order to enable merkle tree generation, while maintaining a completely separate storage layer for efficient storage, historical queries, and block processing. The idea and design is very similar to Cosmos’ ADR-40.
Required Goals:
Additional Goals:
Approaches Considered / Tested / Combined for the query database:
Cache with warmup (load last N heights into memory).
Postgres implementation
Straight K/V (AKA Waves)
Deduplicated Waves Using Index Store
Two Datastores:
Link Store (Indexing) - index keys recorded at every possible height that ‘links’ to the data blob
Data Store (Data Bytes) - hash keys that contains the actual data value
Link Store:
KEY: height uint32 + prefixByte byte + dataKey
VAL: 16 Byte Hash Of LinkKEY
Data Store
KEY: 16 Byte Hash Of LinkKEY
VAL: Data Blob
Deduplication (2) Using 'Heights' Index
Two Datastores:
Link Store (Indexing) - index keys recorded at every possible height that ‘links’ to the data blob
Data Store (Data Bytes) - hash keys that contains the actual data value
Link Store:
Data Store
SET/DEL // first write