From 3be635406f3f37a65d1fe390fb9abf1939691d00 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 May 2023 13:56:39 +0200 Subject: [PATCH] docs: add a few notes about where states point to (#2535) --- crates/storage/provider/src/traits/state.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/storage/provider/src/traits/state.rs b/crates/storage/provider/src/traits/state.rs index 9f63909fa7..464b916a0a 100644 --- a/crates/storage/provider/src/traits/state.rs +++ b/crates/storage/provider/src/traits/state.rs @@ -86,6 +86,16 @@ pub trait StateProvider: /// /// Note: the `pending` block is considered the block that extends the canonical chain but one and /// has the `latest` block as its parent. +/// +/// All states are _inclusive_, meaning they include _all_ all changes made (executed transactions) +/// in their respective blocks. For example [StateProviderFactory::history_by_block_number] for +/// block number `n` will return the state after block `n` was executed (transactions, withdrawals). +/// In other words, all states point to the end of the state's respective block, which is equivalent +/// to state at the beginning of the child block. +/// +/// This affects tracing, or replaying blocks, which will need to be executed on top of the state of +/// the parent block. For example, in order to trace block `n`, the state after block `n - 1` needs +/// to be used, since block `n` was executed on its parent block's state. pub trait StateProviderFactory: Send + Sync { /// Storage provider for latest block. fn latest(&self) -> Result>;