CKB Pulse

All lessons · CKB node, RPC and indexer · Start here · Glossary

Validate header and epoch lookups before using timestampsWorkingFrom one fix

From one fix · Check: right · Checked 2026-11-19

After get_header_by_number or get_epoch_by_number, treat a null result as unavailable and check that the returned number equals the one you asked for. To get an epoch's start time, read the header at the EpochView's start_number. Then check that this header's epoch field has the epoch number in its low 24 bits and 0 in bits 24 to 39 (the block's index within the epoch), so the block really is the first block of that epoch.

Why it matters: Without these checks a node that answers for a neighbouring block or epoch gets that block's time shown as this one's exact date, and it is then cached as if it were correct.

Pattern

const h = await rpc.call('get_header_by_number',[hex]); if(!h || BigInt(h.number)!==wanted) throw ...; return BigInt(h.timestamp)
readBlockTime(rpc, epoch.start_number) trusted blindly → check (header.epoch & 0xffffff)==epoch && ((header.epoch>>24)&0xffff)==0

A test changed in the same commit

It sits next to the fix. We did not run it.

Concepts
Network and RPC reliability, Since and time locks, Data encoding (molecule, hex, bigints)
Evidence
From one fix: from one project, checked against its commit
First seen
2026-11-12
Last changed
2026-11-12
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (2)

More about CKB node, RPC and indexer

All 45 in this topic

Do you maintain a project this lesson came from? Confirm or correct it

Cite this lesson
LusoCryptoLabs, "Validate header and epoch lookups before using timestamps", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/validate-header-and-epoch-lookups-before-using-timestamps, CC BY 4.0, last changed 2026-11-12.

Drawn from public commits and checked against the commit each one came from and the project's code today. Read the source before you rely on one. Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. Want a lesson changed or removed? Open an issue.