Skip to content

Add reactive runtime + cold-start sync (the state-engine substrate the ecosystem consumes)#14

Merged
KaiCode2 merged 3 commits into
mainfrom
cold-start-sync
Jun 26, 2026
Merged

Add reactive runtime + cold-start sync (the state-engine substrate the ecosystem consumes)#14
KaiCode2 merged 3 commits into
mainfrom
cold-start-sync

Conversation

@KaiCode2

Copy link
Copy Markdown
Owner

Lands the reactive runtime and cold-start modules onto main. These are the substrate that evm-amm-state and evm-oracle-state are built on — both currently pin this branch by git rev (903af3df) because the API does not exist on main, which blocks publishing the whole ecosystem to crates.io. They are core shipping features, not optional add-ons.

What this adds

src/cold_start/ — protocol-neutral cold-start: declaratively warm a working set of accounts/storage slots into the cache in one batched pass (config, driver, plan, planner, results, error), driven via EvmCache::run_cold_start. This is how a consumer adopts a working set of pools/feeds into the fork without hand-wiring fetches.

src/reactive/mod.rs (+488) — the reactive runtime: ReactiveRuntime / ReactiveHandler / ReactiveHook / HookSignal, with the reorg-detection core (journaled heads, ParentMismatch detection, ChainStatus, reorg_to recovery, RemovedLog handling) and ingest_batch. This is the event→state control plane the domain crates decode into.

Supporting changes to src/cache/mod.rs (+98) and src/freshness.rs (+47), plus tests/cold_start.rs (1,051 lines) and tests/reactive_reorg.rs (612 lines).

Why now

The ecosystem (evm-amm-state, evm-oracle-state) compiles against this surface today via a pinned git rev. Until it lands on main and publishes, an outside developer cannot assemble the stack from crates.io.

Sequencing note

The open release-readiness PR (#13) hardened the older events-API line and predates these modules. Per plan, once this merges, the release-readiness pass will be re-run on the combined main (covering the reactive + cold-start surface too), superseding #13.

🤖 Generated with Claude Code

KaiCode2 and others added 3 commits June 21, 2026 16:26
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>
@KaiCode2
KaiCode2 merged commit 1c8134a into main Jun 26, 2026
4 checks passed
@KaiCode2
KaiCode2 deleted the cold-start-sync branch June 30, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant