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()) + termA test changed in the same commit
It sits next to the fix. We did not run it.
- toastmanAu/openswap:
sdk/test/v2-vm-bridge.ts,solver/test/v2.test.ts - toastmanAu/openswap:
frontend/test/pool-wallet-helper.ts,frontend/test/pools.spec.ts,sdk/test/frontend-review.test.ts
- 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)
- 2026-11-15 · psawyerberlin/ckb-revocable-timelock · more from this project
- 2026-10-29 · toastmanAu/openswap · more from this project
- 2026-10-29 · toastmanAu/openswap · more from this project
More about Rust scripts and ckb-std
- Cheque lock sender withdrawal requires exact since 0xA000000000000006
- ckb-std C shim needs a RISC-V C toolchain (clang) in CI
- Comparing packed epoch values
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.