feat: block explorer routes, addressed by hash
deploy / build (push) Successful in 6m33s
deploy / deploy-web (push) Successful in 5s
deploy / deploy-api (push) Successful in 16s

`#/:chain/:height` opens a block and then rewrites the address to
`#/:chain/:hash`. The redirect is the point, not tidiness: `block` is keyed on
(chain, height) and a reorg overwrites, so a height names a *position* and a
link to one comes to mean a different block the moment the chain forks there. A
hash names one block for good — including after it has lost, which is the only
way an orphan is linkable at all.

`GET /v1/chains/{chain}/blocks/{ref}` takes either spelling; a decimal number
and 32 bytes of hex cannot be confused, so a caller holding a number is not made
to guess which one this API wanted. The same reasoning puts block refs in the
second path segment beside the window: no window name is all digits or 0x plus
64 hex characters.

The answer is assembled from two sources because neither is sufficient, and
they fail at different times:

- The node holds the block and forgets it. Non-canonical bodies go once finality
  passes them (blocks-pruning defaults to archive-canonical, and Planck finalises
  ~100 blocks back), and difficulty is a state read behind a 256-block default.
- The observer holds what the node never had — when the block was seen, whether
  that sighting was at the tip — and what it has since forgotten: the difficulty
  read while the state behind it still existed.

So resolution degrades in a stated order rather than failing. Node first; a
header it cannot serve falls back to `block_displacement`, which is what makes
an orphan describable at all; a node that is away falls back to the recorded
row. `from_node` tells the reader which they are looking at, and every value
neither source has is spelled out in words — "the body is pruned", "this
observer never saw this block" — because a blank on a block page reads as zero.

Verified against the live chain: a tip block carries difficulty, one extrinsic,
a 1.9 s gap and 473 ms of propagation; height 1000000 keeps its body and loses
difficulty to state pruning; genesis has no author digest and does not panic; a
seeded displacement serves as an orphan with the winner linked, and the winner
lists it in `also_seen`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jp6a8EDar9ueEhAxzep4V5
This commit is contained in:
2026-09-08 16:30:41 +03:00
co-authored by Claude Opus 5
parent 0ce58094e4
commit 53dac3717b
17 changed files with 1270 additions and 22 deletions
+105
View File
@@ -469,6 +469,111 @@ a {
stroke-width: 1;
}
/* ---- block facts --------------------------------------------------------- */
/* The same grid as the stat tiles: this is the same kind of content — a handful
of single values with a caveat each — and giving it a second look would say
the two are different sorts of fact when they are not. */
.facts {
display: grid;
/* Three, not auto-fit. There are exactly six facts, and auto-fit resolves to
five at this width — leaving one on a row of its own beside four empty
cells that read as a grid that failed to load. Six divides evenly by three
and by two, so every breakpoint below is a full rectangle. A seventh fact
would need this revisited, which is the right amount of friction. */
grid-template-columns: repeat(3, 1fr);
gap: 1px;
background: var(--border);
border-bottom: var(--rule);
}
@media (max-width: 760px) {
.facts {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 460px) {
.facts {
grid-template-columns: 1fr;
}
}
.fact {
background: var(--surface-1);
padding: 14px 18px 15px;
min-width: 0;
}
.fact-label {
font-size: 10px;
font-weight: 600;
letter-spacing: 0.15em;
text-transform: uppercase;
color: var(--text-muted);
}
.fact-value {
font-family: var(--font-mono);
font-size: 17px;
margin-top: 7px;
overflow-wrap: anywhere;
}
.fact-note {
font-size: 11px;
color: var(--text-muted);
margin-top: 5px;
}
/* A value nobody has. Muted and in the body face so it does not read as data —
it is a sentence explaining an absence, and formatting it like a figure would
invite it to be compared with one. */
.fact-unknown {
font-family: var(--font-body);
font-size: 12px;
color: var(--text-muted);
}
.block-links {
padding: 15px 18px 18px;
display: grid;
gap: 12px;
font-size: 12px;
}
.block-links a {
color: var(--text-secondary);
overflow-wrap: anywhere;
}
.block-links a:hover {
color: var(--data-bright);
}
/* The one place the accent hue belongs: not a series, a state. A block that
lost its height is the single most important thing its page can say. */
.badge {
margin-left: 10px;
padding: 2px 7px;
font-family: var(--font-body);
font-size: 10px;
font-weight: 600;
letter-spacing: 0.12em;
text-transform: uppercase;
vertical-align: middle;
}
.badge-warn {
background: var(--accent-wash);
color: var(--accent-bright);
border: 1px solid var(--accent);
}
a.ticker-height:hover {
color: var(--data-bright);
}
/* ---- leaderboard --------------------------------------------------------- */
.board {