Nervos CKB Development Update #2

Ian Yang
Nervos Network
Published in
3 min readJan 16, 2019

Covering Dec22, 2018–Jan 13, 2019

Happy New Year! Here is the first report in 2019. Thanks to Xuejie Xiao, James Chen, Jiang Jinyang, they have also contributed to this writing.

TL;DR

  • Proposed RFC0013 block template protocol and RFC0014 cycle limit.
  • Implemented RFC0011 transaction filter protocol and RFC0014 cycle limit.
  • Added new consensus rule to verify block timestamp.
  • Working on VM JIT.

Changes in RFCs

New RFC

  • RFC0013: block template RFC describes the decentralized CKB mining protocol.
  • RFC0014: cycle limit RFC describes cycle limits used to regulate VM scripts. CKB VM is a flexible VM that is free to implement many control flow constructs, such as loops or branches. As a result, we will need to enforce certain rules in CKB VM to prevent malicious scripts, such as a script with infinite loops.

Updates

  • RFC0003: update CKB VM examples based on latest development (#63)
  • RFC0006: use more reasonable proof structure (#62)

Changes in CKB

CKB has released v0.4.0.

This version includes the implementations of several RFCs, including the two new ones.

  • RFC0011, transaction filter protocol, allows peers to reduce the amount of transaction data they send.
  • RFC0014: cycle limit RFC.

The implementation of RFC0013 block template has started and is scheduled to release in the next version.

CKB has adopted a new consensus rule to verify block timestamp based on the past blocks median time (c63d64b). It will also print a warning message when the node finds out its local time has a big difference with its peers.

We have removed the broken KAD discovery protocol (f2d86ba). Thus the node only connects to the peers listed in the configuration file. The new P2P framework will include the discovery protocol as mentioned in RFC0012.

The peer store uses SQLite now to ease implementing rules defined in RFC0007.

There is also a bundle of incompatible refactorings:

  • CellStatus uses dead and live now. CellOutput#contract is renamed to CellOutput#_type.
  • JSONRPC encodes binary fields in hex.
  • P2P encodes H256 and ProposalShortId using the FlatBuffers struct instead of bytes array before.

See the change log in the release about all the breaking changes.

Changes in VM

  • Add support for RFC0014, the cycle limit RFC.
  • Use checked_add when calculating cycles to avoid integer overflows.
  • CKB VM JIT research and initial implementation (ckb-vm#20).

CKB VM JIT will be a 2-level JIT:

  • A baseline JIT which handles most common code segments, which works quite like QEMU’s TCG or rv8. At this level, JIT compilation time will be as important as execution speed of generated code, so we would only employ certain easier optimizations here.
  • A more sophisticated SSA-based JIT for handling very hot code segments. At this layer, the execution speed of generated code will take much higher priority than JIT compilation time, so more effective but time-consuming optimizations would occur here. We might also introduce existing compiling frameworks to solve this.

Changes in P2P

  • Refactor network service API (PR#9)

Thanks for checking, we plan to have this development update on a bi-weekly basis. See you next time!

--

--