Nervos will hold an event with the theme of "Say Hello to RISC-V" in San Francisco. Unexpectedly, the event itself attracted the attention of Zaki Mania, a senior blockchain expert and Cosmos project consultant, and launched a very interesting event on Twitter. discussion. The focus of the discussion was that Zaki believed that he chose WebAssembly (WASM) compared to other blockchain projects, and he expressed doubts about Nervos's plan to implement VM with RISC-V instruction set.
background knowledge
background knowledge
First, introduce the two main topics of this discussion - WebAssembly and RISC-V:
WebAssembly (WASM) is a new way of coding that can run in modern web browsers. It is a low-level assembly-like language with a compact binary format that can run at near-native performance, and for languages such as C/ Languages like C++/Rust provide a compilation target so they can run on the web. The development teams of WebAssembly come from Mozilla, Google, Microsoft, Apple and other companies, and the standard is formulated by W3C. Currently, WebAssembly is used in the Ethereum Next Generation Virtual Machine (EWASM), EOS, and Dfinity projects.
The RISC-V instruction set is an open instruction set architecture (ISA) based on the principle of reduced instruction set computing (RISC). The project began in 2010 and was led by Professor David Patterson of the University of California, Berkeley. It has received strong support from the community. RISC-V is a new instruction based on the continuous development and maturity of the instruction set. The RISC-V instruction set is completely open source, simple in design, easy to port to Unix systems, modular design, complete tool chain, and there are a large number of open source implementations and tape-out cases.
At the moment when x86 and ARM are monopolized, RISC-V has brought some light to emerging markets. Chip design and manufacturing companies in many countries have joined its foundation and participated in related ecological construction. As an instruction set architecture verified on the CPU, RISC-V is indeed a bold attempt in the blockchain field, because it builds virtual machines instead of processor hardware on blockchain projects.
Posted by Zaki Mania, an early investor in the blockchain space. He himself is the executive director of the Trusted IoT Alliance (an organization dedicated to PoS security research), a project consultant for Cosmos, and a member of the board of directors of Restore The 4th!
participating in the discussion@defmacro, Xiao Xuejie, the core engineer of the Nervos project, is also the main implementer of CKB-VM. For the introduction of the Nervos virtual machine he implemented, please refer to the article "An Introduction to Nervos CKB-VM" [1].
Others involved in the discussion were Loom Principal Investigator, Plasma ResearcherGeorgios Konstantopoulos, by SolanaLabs CEO Anatoly Yakovenko, Qtum DeveloperJordan Earls, Co-Founder of Nervos Projectsecondary titlewait.
abstract
abstract
Zaki Mania first asked the question:Seriously doubt that RISC-V is better than WASM for virtual machines.
Followed by Loom Principal InvestigatorGeorgios Konstantopoulos follow up, I hope he will evaluate the advantages and disadvantages of the two in detail.
Zaki Mania added:RISC-V is a specification for Silicon (meaning chip)/FPGA design. Efficient emulation on x86, ARM, PowerPC is not the goal. WASM is a specification independent of ISA (Open Instruction Set Architecture), which can be efficiently implemented on various CPUs. WASM itself, is specifically designed for compilation, so when compiling x86 or ARM machine code, the result is almost the same as native compilation. But RISC-V was not designed to compile to x86 and ARM.
Xiao Xuejie put forward a different view on this:He questioned which features of WASM are easier to implement than RISC-V. WASM is easier to implement than JS, but compared with RISC-V, there is no advantage. Because it has nothing to do with building an effective implementation, it's the ecosystem. I agree that LLVM's support for WASM is better, but there are two points to point out - (1) RISC-V supports GCC, and (2) LLVM for RISC-V only needs a few more patches.
Emulating RISC-V runs in the same way that WASM runs as an abstract virtual machine.
As for how the other party said WASM was "specially designed" to deal with this goal? He saw in the specification that a RISC-V implementation could be implemented like WASM. JIT is not just for WASM.
Follow-up: "rv8: A High-Performance Binary Translator from RISC-V to x86" [2].
After several rounds of heated discussions, many people joined the debate: Tarun Chitra felt that the two were out of the scope of the discussion:RISC-V software will never compete with resources in WASM development.
SolanaLabs CEO Anatoly Yakovenko asked Zaki Mania:Can you imagine a blockchain to run a website? Or a million independent nodes running at the same time? Kudos to Nervos for making a big push, they didn't follow the herd.
Qtum developer Jordan Earls commented: It sounds like it lacks all the benefits of WASM (over any random CPU architecture), while also not getting the ecosystem benefits of x86, since RISC-V is pretty vague. It was interesting to see native smart contract hardware.
Xie Hanjian, co-founder of Nervos, said:Targeting hardware (RISC-V) is a big benefit in my opinion. Layer 1 blockchain is hardware-like software that is difficult to upgrade. Instruction sets designed for hardware happen to have the same properties.
Zaki Mania sums it up:I'm a big fan of RISC-V, just not because of the code that the consensus layer runs. Compiler toolchains will be top notch, hardware (implemented in RISC-V architecture) will be widespread, but no other use cases that depend on a high performance and reliable x86/ARM JIT
Xiao Xuejie finally concluded:The difference between implementing RISC-V and implementing WASM is much smaller, and we even think it's easier to make a more efficient implementation in RISC-V. True, one technology here (WASM or RISC-V) may be easier to implement than the other (RISC-V or WASM) in a detail or two, but (in general) they are There isn't a very noticeable difference in difficulty, and they really aren't all that different when implemented.
At the same time, when choosing a blockchain virtual machine, it is not only the difficulty of high-performance implementation that needs to be considered. Using RISC-V, we can get the following benefits (WASM is difficult to match):
1. Real hardware is used to ensure stable implementation, not the version bit guarantee agreed by browser vendors;
2. Stable upstream GNU toolchain with ongoing LLVM support instead of understaffed Emscripten;
3. Specifications with cutting-edge technology, currently not limited to JS engine architecture, such as V extension;
4. A reasonable runtime model, a more natural and future-oriented runtime overhead model;
5. The potential to greatly speed up transaction verification using coprocessors.
Looking forward to seeing more wonderful knowledge collisions like this in the future!
[1]https://medium.com/nervosnetwork/an-introduction-to-ckb-vm-9d95678a7757
[2]https://carrv.github.io/2017/papers/clark-rv8-carrv2017.pdf
