compute_block_trie_changesets

Function compute_block_trie_changesets 

Source
pub fn compute_block_trie_changesets<Provider>(
    provider: &Provider,
    block_number: u64,
) -> Result<TrieUpdatesSorted, ProviderError>
Available on crate features trie and trie-db only.
Expand description

Computes trie changesets for a block.

§Algorithm

For block N:

  1. Query cumulative HashedPostState revert for block N-1 (from db tip to after N-1)
  2. Use that to calculate cumulative TrieUpdates revert for block N-1
  3. Query per-block HashedPostState revert for block N
  4. Create prefix sets from the per-block revert (step 3)
  5. Create overlay with cumulative trie updates and cumulative state revert for N-1
  6. Calculate trie updates for block N using the overlay and per-block HashedPostState.
  7. Compute changesets using the N-1 overlay and the newly calculated trie updates for N

§Arguments

  • provider - Database provider with changeset access
  • block_number - Block number to compute changesets for

§Returns

Changesets (old trie node values) for the specified block

§Errors

Returns error if:

  • Block number exceeds database tip (based on Finish stage checkpoint)
  • Database access fails
  • State root computation fails