Skip to main content

evm_fork_cache/cold_start/
results.rs

1//! What a cold-start round produced.
2//!
3//! [`ColdStartResults`] carries a per-slot [`SlotOutcome`] for every declared
4//! verify and probe slot — distinguishing a genuine on-chain zero from a fetch
5//! failure — plus the injected [`SlotChange`]s and any discovered access lists.
6
7use crate::access_set::StorageAccessList;
8use crate::cold_start::error::ColdStartError;
9use crate::freshness::{SlotChange, SlotOutcome};
10
11use revm::context::result::ExecutionResult;
12
13/// The outcome of executing one [`ColdStartPlan`](crate::cold_start::ColdStartPlan)
14/// round.
15///
16/// `fetched` and `probed` each carry exactly one [`SlotOutcome`] per declared
17/// verify / probe slot, so a fetch failure surfaces as
18/// [`SlotFetch::FetchFailed`](crate::freshness::SlotFetch::FetchFailed) rather
19/// than as absence. `verified` carries only the slots whose value actually changed
20/// (and were injected). `discovered` carries one [`ColdStartCallResult`] per
21/// discover call.
22///
23/// The order of entries in `fetched` / `probed` is unspecified — look up a slot
24/// by `(address, slot)` rather than relying on it matching the plan's order.
25#[derive(Clone, Debug, Default)]
26pub struct ColdStartResults {
27    /// Slots whose value changed and were injected (one per change).
28    pub verified: Vec<SlotChange>,
29    /// One outcome per declared verify slot (`Value` / `Zero` / `FetchFailed`).
30    pub fetched: Vec<SlotOutcome>,
31    /// One outcome per declared probe slot (classified, not injected).
32    pub probed: Vec<SlotOutcome>,
33    /// One result per discover call.
34    pub discovered: Vec<ColdStartCallResult>,
35}
36
37/// The result of one discover view-call: the raw EVM execution result and the
38/// storage/account access list it touched (filtered by `restrict_to`).
39#[derive(Clone, Debug)]
40pub struct ColdStartCallResult {
41    /// The raw revm execution result of the view-call.
42    pub result: ExecutionResult,
43    /// The storage slots and accounts the call touched (after `restrict_to`).
44    pub access: StorageAccessList,
45}
46
47/// The outcome of a single cold-start round, always carrying the
48/// (possibly partial) [`ColdStartResults`].
49///
50/// `error` is `Some` only when a hard error short-circuited the round (an
51/// accounts- or discover-phase failure in later slices). The verify-only path
52/// never sets `error`. Carrying the results unconditionally lets the driver
53/// absorb partial outcomes into the run report before propagating the error.
54pub struct RoundOutcome {
55    /// The (possibly partial) results computed before any short-circuit.
56    pub results: ColdStartResults,
57    /// `Some` when a hard error aborted the round mid-way.
58    pub error: Option<ColdStartError>,
59}