CKB Pulse

Todas as lições · Other · Começa aqui · Glossário

Range check since epoch fields instead of masking themPráticoDe uma correção

De uma correção · Verificação: certa · Verificada em 2026-11-21

When packing an epoch-based since value (24-bit epoch number, 16-bit index, 16-bit length), masking an out-of-range epoch silently wraps it into a much earlier deadline. This commit's packSince now throws a RangeError for any field outside its bit width, and createTranfr/renewTranfr check that tip epoch plus duration fits within 0xFFFFFF before packing.

Porque importa: Masking an epoch number above 0xFFFFFF silently wraps it into a much earlier since deadline, so the time lock can open far sooner than the caller intended with no error raised.

The existing since lesson covers the metric flag bits. This card is about range checking the epoch number, index and length fields rather than masking them.

Padrão

Evitar
((epoch & NUMBER_MASK) << NUMBER_OFFSET)

Tirado do commit, encurtado.

Um teste mudou no mesmo commit

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

Conceitos
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-20
Última mudança
2026-11-20
Última verificação
2026-11-21
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (1)

Mais sobre Other

Ver as 10 deste tema

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

Citar esta lição
LusoCryptoLabs, "Range check since epoch fields instead of masking them", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/range-check-since-epoch-fields-instead-of-masking-them, CC BY 4.0, last changed 2026-11-20.

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.