RFC30:当交易中的 since 使用 epoch 字段的时候,严格验证其规则

CKB 支持在交易中通过 since 字段来限制 交易 上链的(时间)行为,而 since 是一套非常复杂的方案,通过相对(绝对)块高、相对(绝对) epoch 的排列组合,使其更加复杂了,具体怎么使用 since 表达限定时间的含义可以参考 RFC 17.

RFC 30 描述 since 在 2019 版本的 CKB 实现中,存在一点问题,在使用基于 epoch 的 since 方案时,并没有限制用户填奇怪的数据,形如,epoch number 100,epoch index 500,epoch length 300,这样的数据是没有校验并且可以验证成功的,但是,这其实是错误的实现。

在这次 hardfork 的之后,epoch index > epoch length 的交易将被拒绝执行,也就是交易无法通过验证。只有 epoch index == epoch length == 0 或者 epoch index < epoch length 才是合法的交易

Q: epoch 是什么?
A:在 ckb 中,epoch 是一个调整周期,它的长度是变化的,从 300-1800 个块不等,它的调整目标是一个 epoch 周期对应现实时间在 4 个小时左右。基于 epoch 的 since 表达,可以近似将 epoch 时长认为是 4 个小时,就可以从链上映射真实时间,这是一种近似的时间验证解决方案

Q: epoch index 是什么?
A: epoch 长度在 300-1800 不等,高度在当前 epoch 中的定位就是 epoch index

Since RFC 有一版改写的 rfcs/0017-tx-valid-since.md at revise-since-rfc · doitian/rfcs · GitHub

应该是 epoch index == epoch length == 0 或者 epoch index < epoch length 才是合法的,其它都不合法。