CKB Pulse

Todas as lições · CKB node, RPC and indexer · Começa aqui · Glossário

Validate header and epoch lookups before using timestampsPráticoDe uma correção

De uma correção · Verificação: certa · Verificada em 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.

Porque importa: 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.

Padrão

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

Um teste mudou no mesmo commit

Está ao lado da correcção. Nós não o corremos.

Conceitos
Network and RPC reliability, Since and time locks, Data encoding (molecule, hex, bigints)
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-11-12
Última mudança
2026-11-12
Última verificação
2026-11-19
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (2)

Mais sobre CKB node, RPC and indexer

Ver as 45 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
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.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.