CKB Pulse

All lessons · Other · Start here · Glossary

Range check since epoch fields instead of masking themWorkingFrom one fix

From one fix · Check: right · Checked 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.

Why it matters: 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.

Pattern

Avoid
((epoch & NUMBER_MASK) << NUMBER_OFFSET)

Taken from the commit, shortened.

A test changed in the same commit

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

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

Sources (1)

More about Other

All 10 in this topic

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

Cite this lesson
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.

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.