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::cache::CodeVerifyReport;
9use crate::cold_start::error::ColdStartError;
10use crate::cold_start::roots::RootProbeOutcome;
11use crate::freshness::{SlotChange, SlotOutcome};
12
13use revm::context::result::ExecutionResult;
14
15/// The outcome of executing one [`ColdStartPlan`](crate::cold_start::ColdStartPlan)
16/// round.
17///
18/// `fetched` and `probed` each carry exactly one [`SlotOutcome`] per declared
19/// verify / probe slot, so a fetch failure surfaces as
20/// [`SlotFetch::FetchFailed`](crate::freshness::SlotFetch::FetchFailed) rather
21/// than as absence. `verified` carries only the slots whose value actually changed
22/// (and were injected). `discovered` carries one [`ColdStartCallResult`] per
23/// discover call.
24///
25/// The order of entries in `fetched` / `probed` is unspecified — look up a slot
26/// by `(address, slot)` rather than relying on it matching the plan's order.
27#[derive(Clone, Debug, Default)]
28pub struct ColdStartResults {
29 /// Slots whose value changed and were injected (one per change).
30 pub verified: Vec<SlotChange>,
31 /// One outcome per declared verify slot (`Value` / `Zero` / `FetchFailed`).
32 pub fetched: Vec<SlotOutcome>,
33 /// One outcome per declared probe slot (classified, not injected).
34 pub probed: Vec<SlotOutcome>,
35 /// One outcome per declared probe-roots address (`root: None` when the
36 /// probe failed, the fetcher omitted the address, or the phase never ran).
37 pub probed_roots: Vec<RootProbeOutcome>,
38 /// One result per discover call.
39 pub discovered: Vec<ColdStartCallResult>,
40 /// The `verify_code` phase's report, when the round found pending code
41 /// seeds (`None` means the phase was a no-op). The phase runs **first**,
42 /// so this survives a later phase's hard error. Adapters that require
43 /// verified code before serving gate on its `unverifiable` bucket.
44 pub code_verifications: Option<CodeVerifyReport>,
45}
46
47/// The result of one discover view-call: the raw EVM execution result and the
48/// storage/account access list it touched (filtered by `restrict_to`).
49#[derive(Clone, Debug)]
50pub struct ColdStartCallResult {
51 /// The raw revm execution result of the view-call.
52 pub result: ExecutionResult,
53 /// The storage slots and accounts the call touched (after `restrict_to`).
54 pub access: StorageAccessList,
55}
56
57/// The outcome of a single cold-start round, always carrying the
58/// (possibly partial) [`ColdStartResults`].
59///
60/// `error` is `Some` only when a hard error short-circuited the round (an
61/// accounts- or discover-phase failure in later slices). The verify-only path
62/// never sets `error`. Carrying the results unconditionally lets the driver
63/// absorb partial outcomes into the run report before propagating the error.
64pub struct RoundOutcome {
65 /// The (possibly partial) results computed before any short-circuit.
66 pub results: ColdStartResults,
67 /// `Some` when a hard error aborted the round mid-way.
68 pub error: Option<ColdStartError>,
69}