CKB Pulse

All lessons · Rust scripts and ckb-std · Start here · Glossary

Comparing packed epoch valuesWorkingSeen again

Seen again · Check: right · Checked 2026-11-19

Decode epochs into (number, index, length) before comparing them. Compare the fractional parts by cross-multiplying (index_a*length_b vs index_b*length_a), because epoch length varies and raw packed integers don't order correctly.

Why it matters: Without decoding, a test or script judges epoch maturity wrongly, because the packed layout puts length and index above the epoch number. The daowow test would then expect an Immature refusal after the savings term had already ended.

Pattern

term_over = tip_n > term_n or (tip_n == term_n and tip_i*term_l >= term_i*tip_l); since = hex(0x2000000000000000 | epoch)

A test changed in the same commit

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

Concepts
Since and time locks
Evidence
Seen again: seen in two or more projects
First seen
2026-11-18
Last changed
2026-11-18
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 Rust scripts and ckb-std

All 35 in this topic

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

Cite this lesson
LusoCryptoLabs, "Comparing packed epoch values", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/comparing-packed-epoch-values, CC BY 4.0, last changed 2026-11-18.

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.