checkpoint: the no-certificate reason names the DAA 7,200 window, not a wall-clock (main, 8 Oct 2026); live_daa from the dn4_ blocks in the JSON, no estimate

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-08 17:25:19 +00:00
parent cff31427bb
commit 2d60bf8a18

View file

@ -37,7 +37,12 @@ const liveNetwork = () => process.env.LIVE_NETWORK || (/^dn(\d+)_$/.test(tablePr
// the finality test network's fixture (fintest_live_certificates) is served only to a request carrying the ops key (main, 8 Oct 2026 18:4x:
// a fixture chain answered on the public 2.0 site as source test, network igneum-devnet-7); with no IGNEUM_OPS_KEY set it is never served
const opsOk = req => { const k = process.env.IGNEUM_OPS_KEY || ''; const h = String((req.headers && req.headers['x-igneum-ops-key']) || ''); return k.length > 0 && h === k; };
const noCertificate = source => ({ source, network: liveNetwork(), certificate: null, reason: 'no finality certificate yet; the first lock is expected about 23:00 BST' });
// the latest DAA the observer has seen on the live chain, or null (the window fills to DAA 7,200 before the first lock; no wall-clock estimate, main 8 Oct 2026)
async function liveDaa(sql) {
const rows = await sql(`SELECT max(daa_score) AS daa FROM ${tablePrefix()}live_blocks`).catch(() => []);
const d = rows && rows[0] && rows[0].daa; return d === null || d === undefined ? null : Number(d);
}
const noCertificate = (source, daa) => ({ source, network: liveNetwork(), certificate: null, live_daa: daa, finality_window_daa: 7200, reason: 'no finality certificate yet; the first lock comes when the weight window fills at DAA 7,200' });
async function latest(sql, table, index = null) {
// A table the observer has not created yet (the live chain before the cut-over) reads as "no certificate"
const rows = await (index === null ? sql(`SELECT * FROM ${table} ORDER BY index DESC LIMIT 1`) : sql(`SELECT * FROM ${table} WHERE index = $1 LIMIT 1`, [index])).catch(() => []);
@ -134,7 +139,7 @@ export default async function handler(req, res) {
if (!row) {
res.setHeader('Cache-Control', 'public, max-age=5');
if (idx !== null) return res.status(404).json({ ok: false, network: liveNetwork(), error: `no certified checkpoint at index ${idx} yet` });
return res.status(200).json({ ok: true, now: new Date().toISOString(), ...noCertificate(source) });
return res.status(200).json({ ok: true, now: new Date().toISOString(), ...noCertificate(source, await liveDaa(sql)) });
}
// the hand merge of 12:22 BST (a0b62cf7) returned `...cp` with no cp bound: every caller read "cp is not defined" (8 Oct 2026, build-server lane)
return res.status(200).json({ ok: true, now: new Date().toISOString(), ...shape(row, source) });