foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Optimize transaction and transaction result db

Open sgkim126 opened this issue 6 years ago • 0 comments

Currently, the storage of transaction and transaction result is not organized well.

The current implementation uses five columns to store data. Two of them are used to store a state trie and a mempool backup. You don't need to change these columns. Other columns are used to store headers, bodies, and extra information. I think they can be optimized.

Below describes the current implementation for those columns.

HEADER

  • block hash => BlockHeader

BlockHeader

field name type
parent_hash H256
author Address
state_root H256
transactions_root H256
results_root H256
score U256
number u64
timestamp u64
extra_data Bytes
seals ...Bytes[]

BODY

  • block hash => BlockBody

BlockBody

field name type description
header Bytes rlp of header
transactions UnverifiedTransaction[]

EXTRA

  • block hash => BlockDetails
  • transaction hash => TransactionAddress
  • transaction tracker => TransactionAddress[]
  • block hash => Invoice[]
  • and epoch transactions which are not used yet.

Invoice

[0x1] or [0x2, error_hint]

TransactionAddress

field name type
block hash H256
index usize

BlockDetails

field name type
number u64
total score U256
parent H256

sgkim126 avatar Feb 27 '19 10:02 sgkim126