fuel-core
fuel-core copied to clipboard
Support arbitrary state block access
For ability to fast index and reexecute block in past we need to add few things to present db columns and add some new ones for indexing for contract storage.
- [ ] Modify Spendable Coins: UtxoId->Coin column: Should include block hash, created block height, and spend block height. so when we want to know the state of any block, we could check if coin is valid or not by checking heights and if the block is in canonical main chain.
- [ ] Modify Contract bytecode root column: ContractId->(Salt, Bytes32): We need to add block height when this contract is created so that we know for any block height if this contract exists or not. Check if this the best place?
- [ ] Add Contract Change Sets: BlockHeight->BlockDiff (For storage slots and contract coins) column: Diff should only contains storage slot changes and contract coins change. Should contain list of old values of storage and coin that got updated. Based on erigon: https://github.com/ledgerwatch/erigon/blob/devel/docs/programmers_guide/db_walkthrough.MD#table-change-sets
- [ ] Add Contract Storage history index: (ContractId, Bytes32)->Vec<BlockHeight> column: Contains a list of BlockHeight's where change happened, with this we can easily traverse the history of any storage change.
As Brandon wrote here it is probably worth investigating the suffix approach, I agree with this, but for the first iteration, indexing is something that is already proven to work for big amount of data/transactions that are in ethereum.