refactor(event-watcher): drop Deno.KV state store; boot syncs from oldest available#123
Merged
Conversation
…dest available Removes the second state store so a Postgres wipe fully resets the instance. - EventWatcher holds no durable cursor. A fresh watcher syncs ALL available history from the oldest ledger the RPC still retains (getHealth.oldestLedger); BOOT_SYNC_START_LEDGER_BLOCK overrides the start. Never defaults to "latest". - ChannelRegistry is rebuilt in-memory each boot (converge-by-query + this PP's own DB are the authoritative sources) — no KV persistence. - Sessions move to a plain in-memory Map; delete persistence/kv/config.ts disk KV and its entity. No Deno.openKv / .data / memory-kvdb anywhere in the path. - Inject rpc + startLedgerBlock into EventWatcher (decouples process.ts from env so the boot-ledger behavior is deterministically testable). Version bump 0.8.0 -> 0.9.0.
Contributor
Author
|
Companion PR (council cursor → Postgres): Moonlight-Protocol/council-platform#48 |
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.
Why
provider-platform kept a second state store outside Postgres: the event-watcher cursor and the channel registry lived in a
Deno.KVfile (./.data/memory-kvdb.db), and that same file also backed in-flight auth sessions. A store outside the DB means wiping Postgres doesn't reset the instance (a testnet-reset blocker), and the KV cursor advance wasn't transactional with the state it gated — a crash (or the ephemeral.datadir vanishing on a Fly redeploy) could silently skip the gap.Everything the watcher derives is authoritatively re-queryable, so provider-platform doesn't need a durable cursor or a persisted registry — it converges by querying the council on boot (existing path) and watches forward.
What
getHealth.oldestLedger);BOOT_SYNC_START_LEDGER_BLOCKoverrides the start. Never defaults to "latest" (that would skip the gap). Out-of-retention recovery still re-queries the council.Map; deletedpersistence/kv/config.ts's disk KV and its entity. NoDeno.openKv/.data/memory-kvdbanywhere in the running path (--unstable-kvdropped fromserve).rpc+startLedgerBlockintoEventWatcher(decouplesprocess.tsfrom env so the boot-ledger behavior is deterministically testable).Net: a wipe of Postgres alone now fully resets the instance — no surviving state file.
Tests
fmt / lint /
check/ test green on Deno 2.8.2 (CI pin). New deterministic unit tests cover: boot start = oldest-available when the override is unset, = the exact ledger when set, and the no-durable-cursor / re-sync-on-restart property.Companion
Paired with council-platform's cursor→Postgres relocation (the event-only root that genuinely needs a durable cursor). Independent at runtime — council still exposes the same public query; this provider still queries it.
Version bump 0.8.0 → 0.9.0.