Building a VM
in Rust
that also runs Rust

About us

Aimee

Brian

Building a VM in Rust
that also runs Rust

  • Part 1: VMs, CKB-VM and RISC-V
  • Part 2: Rust on CKB-VM

Part 1:
VMs
RISC-V
CKB-VM

Virtual
Machines

Why build a VM?

  • Hardware Emulation
  • Runtime Platform
  • Sandboxing
  • Education

VMs are cool!

Blockchain VM Use Cases

  • Crypto algorithm as a contract
  • Higher level languages
  • Existing blockchain VMs
  • WebAssembly

Why RISC-V?

An open & frozen ISA

Flexible & Extensible

Language support:

Rust, C/C++, Go, Ruby,
Python, JavaScript …

RISC-V is cool!

Part 2:
Rust
on
CKB-VM

Part 2 Overview

  • Live-coding main on bare-metal RISC-V
  • Hosting an exe on CKB-VM
  • CKB-VM exe loading and instruction dispatch
  • RISC-V / CKB-VM syscalls

Source code

Quick demo

Live-coding

Watch me
attempt to build Rust code
for RISC-V
and run it on CKB-VM

Coding

Hosting RISC-V
code on CKB-VM

Coding

Naive main

Coding

#![no_std]

Coding

[panic_handler]

Coding

Naive start

Coding

Correct start

Coding

Running the bin

Coding

Working start

WTF is _start?

Coding

What's the error?

Syscalls in RISC-V and CKB-VM

ckb_vm_glue

example_bot

Building a
Virtual Machine

Further exploring

Nervos Network

[email protected]

Thanks

ferrisfencing.org

nervos.org