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.
- toastmanAu/daowow:
tests/devnet/reorg_history.py,tests/devnet/test_round_creation.py - salmansarwarr/Tranfr:
tests/src/tests.rs
- 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)
- 2026-11-18 · toastmanAu/daowow · more from this project
- 2026-10-01 · salmansarwarr/Tranfr · more from this project
More about Rust scripts and ckb-std
- Median time vs tip timestamp for deadlines
- 24-bit epoch number overflow
- Absolute epoch since needs the 0x20 metric flag in the top byte
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.