pub fn compute_block_trie_updates<Provider>(
cache: &ChangesetCache,
provider: &Provider,
block_number: u64,
) -> Result<TrieUpdatesSorted, ProviderError>where
Provider: DBProvider + StageCheckpointReader + ChangeSetReader + StorageChangeSetReader + BlockNumReader,Available on crate features
trie and trie-db only.Expand description
Computes block trie updates using the changeset cache.
§Algorithm
For block N:
- Get cumulative trie reverts from block N+1 to db tip using the cache
- Create an overlay cursor factory with these reverts (representing trie state after block N)
- Walk through account trie changesets for block N
- For each changed path, look up the current value using the overlay cursor
- Walk through storage trie changesets for block N
- For each changed path, look up the current value using the overlay cursor
- Return the collected trie updates
§Arguments
cache- Handle to the changeset cache for retrieving trie revertsprovider- Database provider for accessing changesets and block datablock_number- Block number to compute trie updates for
§Returns
Trie updates representing the state of trie nodes after the block was processed
§Errors
Returns error if:
- Block number exceeds database tip
- Database access fails
- Cache retrieval fails