As part of our continued improvement of the Nervos Network, and in alignment with the project roadmap, we have initiated a major protocol upgrade which will be implemented in three stages and will look to be complete by October.
This protocol upgrade is a planned one, and one that’s key purpose is to upgrade the CKB mainnet with new features, as well as bug fixes. The upgrade will improve the layer one CKB chain in a number of ways:
- The official RISC-V B extension (https://github.com/riscv/riscv-bitmanip) will be introduced to CKB-VM, so more efficient implementation of crypto algorithms can be provided. With B extension enabled the cost of sophisticated lock scripts will be reduced.
- A new concept called macro-op fusion (https://en.wikichip.org/wiki/macro-operation_fusion) will be introduced to CKB-VM. A 30,000 foot view of macro-op fusion, is that when certain RISC-V instructions are used together, CPUs will be able to execute them together in a more efficient way. CKB-VM will thus charge less cycles to the instruction patterns forming macro-op fusion. Notice that modern compilers already leverage macro-op fusions extensively, so the only outcome you might notice is that CKB-VM charges less cycles for a smart contract than before the upgrade. Please refer to here (https://riscv.org/wp-content/uploads/2016/07/Tue1130celio-fusion-finalV2.pdf) for a more detailed introduction on macro-op fusions in RISC-V.
- The upgrade will allow multiple dep match in transaction. CKB cell uses data hash or type script hash to match the script binary indirectly. The cells storing the binaries must be added via cell dep. Currently CKB does not allow multiple matches in cell deps to avoid ambiguity. However if the same cell appears several times in cell deps, usually via dep group, it is safe to bypass this error.
- The upgrade will also simplify the rules on transaction input. This change will make it easier to write smart contracts depending on on-chain time.
One major rationale behind the changes in CKB-VM(apart from bug fixes), is about reducing overheads. CKB-VM is already a thin abstraction layer on top of your native CPUs. With the upgrade in place, we do want to make the abstraction layer even thinner: RISC-V B extension allows us to map RISC-V instructions directly with native instructions provided by x86-64 CPUs, while macro-op fusion goes even deeper to exploit modern micro-architectures in our CPUs. All of those efforts are made so crypto algorithms can run even more efficiently on CKB-VM, unlocking more potential use cases of Nervos CKB.
More than adding features this upgrade also includes housekeeping tasks, like re-fixing several CKB-VM bugs in a cleaner way. Those bugs are found after mainnet launch and fixed in an ad-hoc way temporarily right now. The cleanup will make the code base healthier and CKB easier to maintain in future.
The consensus rules on block/transaction version fields will also be tweaked to make future soft forks easier. This change will give us more options when we want to bring new features to CKB.
One major improvement made possible by the coming upgrade is efficient implementation of more cryptographic algorithms. One such example is the BLS signature verification lock. Due to algorithmic complexity, BLS, while theoretically possible, consumes far too many cycles on CKB now. With the help of B extension, together with macro-op, we managed to bring the cycles consumed by a BLS signature verification operation down to a feasible rate on CKB. The same techniques used to power the BLS implementation, can also be ported and used to optimize more algorithms, such as RSA, secp256r1, etc.
We included Flyclient support in the upgrade previously. We had several scheme designs in the last months, but after evaluation we think it would be better to postpone its implementation, due to its relatively large change and unclear impact/benefit at this stage due to the lack of peripheral support. There will be another post on this and we’ll continue working on light client protocol.
The mainnet upgrade will be divided into three phases:
Stage 1: RC version 0.100.0 (https://github.com/nervosnetwork/ckb/releases) was released on July16th, including all functions and corresponding tools, excluding specific upgrade time (epoch), mainly for testing and adapting tools. First round of audit starts.
Developers can use Tippy – https://www.nervos.org/blog/develop-deploy-and-test-dapps-on-nervos-with-tippy/ – to start a new chain for testing.
Stage 2 (Estimated in August): An updated RC version will be activated on Aggron testnet. Second round of audit starts.
Stage 3 (Estimated in September): Release the final version and the epoch information for when to activate on mainnet.
The mainnet upgrade of our PoW chain requires the support of miners, wallets, and exchanges. We aim to have the mainnet upgrade in October.
Most upcoming changes are already published on Github:
https://github.com/nervosnetwork/rfcs/pulls, suggestions/comments are welcome!
Coordinating an upgrade like this is never an easy task. We’re still learning and we’ll do our best to fully communicate with the community and ensure a stable and graceful upgrade.
To stay updated on all things Nervos: