Summary
Currently, tipset_by_height and load_child_tipset return anyhow::Result<Tipset>,
which means callers cannot distinguish between a genuine "not found" case (e.g., ts is
the current head and has no child yet) and a real storage/blockstore/IO error.
This makes it necessary to call .ok() or unwrap_or(false) at call sites to handle
the "not found" case, which silently swallows genuine errors and hurts the fast-fail
behavior expected by eth_getLogs and related paths.
Proposed Change
Refactor both functions to return anyhow::Result<Option<Tipset>>:
tipset_by_height → anyhow::Result<Option<Tipset>>
load_child_tipset → anyhow::Result<Option<Tipset>>
This allows callers to:
- Treat
Ok(None) as a clean cache miss (e.g., tipset is the current head)
- Propagate or handle
Err(_) as a genuine storage/IO failure, enabling fast-fail
behavior in hot paths like eth_getLogs
Affected Call Sites
src/state_manager/mod.rs — load_executed_tipset_without_events,
load_executed_tipset, and try_lookup_state_from_next_tipset
(around lines 467–468, 482–483, 1764–1768)
- Any other callers of the two functions
Context
Raised during review of #6750 (fix: optimize collect_events in Eth RPC).
See comment: #6750 (comment)