Skip to content

Site sync: the explorer belongs to one chain and says so on every page - #3

Merged
dendisuhubdy merged 5 commits into
mainfrom
test/site-sync
Oct 27, 2026
Merged

dendisuhubdy merged 5 commits into
mainfrom
test/site-sync

Conversation

@dendisuhubdy

Copy link
Copy Markdown
Member

Summary

  • Migration 015 chain_meta: the database records the genesis it indexes. On first deploy it adopts block 0's hash (chain 21, ca76c276…), so live indexing carries on.
  • Behaviour change: when the node moves to a genesis that isn't the pin, the indexer stops writing and reports wrong_chain instead of wiping and re-indexing. At a chain cut, set RANDSCAN_EXPECTED_CHAIN_ID / RANDSCAN_EXPECTED_GENESIS and restart.
  • GET /api/v1/chain: chain id, genesis, head height and timestamp, node height, lag, state (live / behind / stalled / wrong_chain / unreachable). Cross-origin readable.
  • /api/v1/health gains genesis_hash, head_timestamp_ms, stalled and wrong_chain, and reports degraded when either of the last two is true.
  • Frontend: a status pill on every page, a red role=alert banner, <meta name=rand-genesis> / rand-chain-id; 20 languages.

Tests

  • cargo test --workspace (local Postgres): 176 passed.
  • real_node against rand-node 0.8.0: 2 passed (the chain view; the node killed, unreachable then stalled). Wired into the CI real-node job.
  • frontend npm test: 76 pass, 0 fail, 1 skipped (geoip). tsc, lint, next build and cargo fmt --check clean.

Design: monorepo docs/superpowers/specs/2026-10-27-site-sync-design.md (monorepo PR test/site-sync).

🤖 Generated with Claude Code

dendisuhubdy and others added 5 commits October 27, 2026 11:19
…chain 21 / ca76c276…, RANDSCAN_EXPECTED_CHAIN_ID / RANDSCAN_EXPECTED_GENESIS), ChainView, classify() into unreachable / wrong_chain / stalled / behind / live with STALL_MS 60 000 and MAX_LAG 10, unit tests on every boundary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_meta (adopts the indexed chain's id and block-0 hash, so the live chain-21 database carries on), the indexer checks rand_chainId + rand_getGenesisHash every pass and stops writing while the node reports another chain (re-indexing only when the node moves to the pinned chain), GET /api/v1/chain, and /health gains genesis_hash, head_timestamp_ms, stalled, wrong_chain

The old behaviour — wipe and re-index whenever the node's chain id or genesis changed — is kept
only for a database with no recorded chain. The mock hard-fork test now covers the three paths
(cut to the pinned chain, an unpinned genesis that halts the indexer, a restart pinned to it),
and tests/chain_sync.rs covers /chain live, behind, unreachable, stalled and a genesis switch
that halts and then resumes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…enesis and head, unreachable then stalled once the node is killed, wrong_chain with nothing written when pointed at a second dev chain; the CI real-node job runs it beside the contract test

The two real-node tests share the database, so they now take turns behind one lock, and the
binary/env gate both use is one function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er on every page, from /api/v1/chain every 15 s, classified against the build's pin (src/lib/chainPin.ts) by a pure classifier with node:test coverage; the pin printed as <meta name="rand-genesis"> / <meta name="rand-chain-id"> in every page's HTML; Health typed with the new fields; 20 languages

The pill has its own line under the top bar: the bar is already full at every width, and the
pill in it widened a phone page to 436 px. The banner keeps the page's numbers visible and
names the last good block and its age.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he configuration table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92308% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/randscan-indexer/src/service.rs 89.39% 7 Missing ⚠️
crates/randscan-db/src/queries/indexer.rs 84.61% 4 Missing ⚠️
crates/randscan-core/src/types/chain.rs 99.56% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dendisuhubdy
dendisuhubdy merged commit 80c1ded into main Oct 27, 2026
7 checks passed
@dendisuhubdy
dendisuhubdy deleted the test/site-sync branch October 27, 2026 04:57
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