Add protocol-neutral cold-start sync (reactive feature) - #12
Merged
Conversation
Adds a cold-start sync mechanism gated under the existing `reactive` feature:
a consumer declares the storage to warm on startup (verify / probe / accounts /
discover) and drives a bounded multi-round loop via a pure `ColdStartPlanner`.
Surfaces a per-slot `SlotFetch` (Value / Zero / FetchFailed / NotAttempted)
that closes the archive-miss gap — distinguishing a genuine on-chain zero from
a fetch failure, which `verify_slots` could not express.
- src/cold_start/: ColdStartPlan/Call/Results/CallResult/RoundOutcome,
ColdStartPlanner/Step, ColdStartConfig/Pin/RunReport, ColdStartError, and the
driver methods EvmCache::{execute_cold_start_round, run_cold_start}.
- src/freshness.rs: SlotOutcome / SlotFetch (ungated, beside SlotChange).
- src/cache/mod.rs: verify_slots_core extraction (verify_slots / reconcile_slots
behaviour unchanged), verify_slots_with_outcomes, ensure_account_blocking;
classify and block_in_place_handle widened to pub(crate).
- 19 offline acceptance tests (tests/cold_start.rs) + setup_cache_with_asserter.
Composes existing primitives (verify_slots_inner, inject_storage_batch_fresh,
call_raw_with_access_list, ensure_account, StorageBatchFetchFn). No AMM concepts
enter evm-fork-cache. `cargo test --no-default-features` stays green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- ColdStartRunReport / run_cold_start: clarify the report is returned only on the Ok path; on error it is dropped (use execute_cold_start_round to observe a failed round's partial outcomes). - discovered_accounts / discovered_slots: drop "distinct" — they are sums across calls and rounds, not de-duplicated. - ColdStartResults: document that fetched/probed order is unspecified (look up by (address, slot)). Doc-only; no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a protocol-neutral cold-start sync mechanism to
evm-fork-cache, gated under the existingreactivefeature. A consumer declares the storage it needs warmed on startup and drives a bounded multi-round loop via a pureColdStartPlanner— the driver owns all fetch/call IO, the planner owns all protocol decisions.The headline win is a per-slot
SlotFetch(Value/Zero/FetchFailed/NotAttempted) that closes the archive-miss gap: a fetch failure is now distinct from a genuine on-chain zero, whichverify_slotscould not express (it dropped per-slotErrs and kept only an aggregate count).Base: this PR stacks on
codex/reactive-reorg-recovery(the revevm-amm-statepins). Motivating consumer: the AMM cold-start work inevm-amm-state(V3slot0, V2 reserves, BalancergetPoolTokensaccess-list discovery) — adoption is a separate follow-up in that repo.What's in it
A
ColdStartPlandeclares four independent, optional phases run in fixed order accounts → verify → probe → discover:inject_storage_batch_fresh), with a per-slot outcome.ensure_accountpre-seeding before discovery.call_raw_with_access_list, with an optionalrestrict_tofilter.A
Done | Continue(next_plan)continuation drives data-dependent multi-round cold starts;ColdStartPin::Hash { require_canonical }pins a whole run to a hash and restores the prior block on every exit path.New / changed
src/cold_start/(new, gated):ColdStartPlan/Call/Results/CallResult/RoundOutcome,ColdStartPlanner/Step,ColdStartConfig/Pin/RunReport/RoundSummary,ColdStartError, andEvmCache::{execute_cold_start_round, run_cold_start}.src/freshness.rs:SlotOutcome/SlotFetch(ungated, besideSlotChange).src/cache/mod.rs:verify_slots_coreextraction (verify_slots/reconcile_slotsbehaviour unchanged),verify_slots_with_outcomes,ensure_account_blocking;classify+block_in_place_handlewidened topub(crate).tests/cold_start.rs(new): 19 offline acceptance tests;setup_cache_with_asserteradded totests/common.Design notes
verify_slots_inner,inject_storage_batch_fresh,call_raw_with_access_list,ensure_account,StorageBatchFetchFn);SlotChangeandStorageAccessListare reused verbatim.evm-fork-cache.execute_cold_start_roundreturnsRoundOutcome { results, error }, carrying partial results in the return type; on an accounts-phase hard error every unreached verify/probe slot is markedNotAttempted, the round is absorbed into the report, andon_resultsis skipped.EvmCache-level mechanism (noReactiveRuntimecoupling);require_canonical: truehash-pinning is its standalone reorg defense.Validation (full release gate, all green)
cargo test·cargo test --no-default-features·cargo fmt --all --check·cargo clippy --all-targets --no-deps -- -D warnings·RUSTDOCFLAGS="-D warnings" cargo doc --no-deps(default +--no-default-features) ·cargo +1.88.0 check --lib --locked·git diff --check. 19/19 cold-start tests pass; existing suite unaffected.Not in scope (follow-up)
Consumer adoption in
evm-amm-state(V2/V3/BalancerColdStartPlannerimpls, migrating itscold_starttests, bumping the pinned rev) — handoff doc to follow.🤖 Generated with Claude Code