CKB Pulse

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

Median time vs tip timestamp for deadlinesWorkingSeen again

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

On-chain since checks use the median time of past blocks, but clients often use the tip header's timestamp, and the two can diverge widely after devnet time travel. Compute deadlines from max(ceil(tipMs/1000), medianSeconds) so minimum-term checks hold on both sides.

Why it matters: If the deadline is computed from the median time alone, a client that measures the minimum term from the tip timestamp rejects the deadline as too short. This happens after devnet time travel, when the tip runs far ahead of the median.

Pattern

deadline = medianSeconds() + term  →  deadline = max(ceil(tipMs/1000), medianSeconds()) + term

A test changed in the same commit

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

Concepts
Since and time locks, Testing and devnet
Evidence
Seen again: seen in two or more projects
First seen
2026-11-15
Last changed
2026-11-15
Last checked
2026-11-19
Check against the commit
right: the lesson follows from its commit and still holds in the code today

Sources (3)

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, "Median time vs tip timestamp for deadlines", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/median-time-vs-tip-timestamp-for-deadlines, CC BY 4.0, last changed 2026-11-15.

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.