Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

riscvdemo/v0 package

Overview

Package riscvdemo runs real compiled machine code on chain, a slice at a time.

It is a demo of two libraries and carries no logic of its own: p/moul/x/vm/riscv(/p/moul/x/vm/riscv/v0) is the RV32IM hart, and p/moul/x/vm/vmkit(/p/moul/x/vm/vmkit/v0) is the host ABI, the fuel meter and the instance store.

What it exists to show is that the guest was not written for gno. The programs on the front page are flat .text images: the same bytes `rustc --target riscv32im-unknown-none-elf` emits, uploaded as hex. The realm holds the snapshot between transactions, so one computation finishes across several of them, and realm code cannot do that for itself.

Function

Upload

func Upload(cur realm, hexImage, input string, budget int64) string

Upload stores a hex-encoded text image as a new instance and returns its id.

The image is loaded here rather than at the first Step, so a misaligned or oversized one is rejected by the transaction that submitted it instead of costing somebody else the gas later.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/vm/riscvdemo/v0" -func "Upload" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/vm/riscvdemo/v0" -func "Upload" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx