Skip to main content

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-db and trie only.
Expand description

Computes trie changesets for a block.

§Algorithm

For block N:

  1. Query cumulative HashedPostState revert from the database tip to after N.
  2. Calculate cumulative TrieUpdates revert from the database tip to after N.
  3. Query per-block HashedPostState revert for block N.
  4. Overlay the post-N trie and calculate trie updates to the pre-N state.

§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
  • Database access fails
  • State root computation fails