NOTE: From Chrio (Orochi Network), appendix to ZK VM spec.
To prove arbitrary computation we need to extract the execution trace and prove that every step of the computation is correct. In our case, we want to prove the execution trace of WebAssembly run-time. We pick the wasmi - WebAssembly (Wasm) Interpreter a light weight and deterministic Wasm run-time to start with.
Predator
, Trace
. Predator
will record every single Trace
to a vector of Trace
.Predator
instance to Executor
of wasmi
and start extracting before the opcode is executed (wasmi have some engineering turning so we might need to transform to the necessary format of the Trace
).Predator
from the construction of Engine
to the EngineExecutor
.After executing a Wasm program we have a Vec<Trace>
with this structure:
local.get <index>
Trace {
iaddr: InstructionPtr {
ptr: 0x0000000131607800,
},
program_counter: 4,
opcode: Return(
DropKeep {
drop: 2,
keep: 1,
},
),
stack: [
UntypedValue {
bits: 9,
},
],
stack_depth: 1,
local: [
UntypedValue {
bits: 4,
},
UntypedValue {
bits: 5,
},
],
local_depth: 2,
calling_frame: [],
calling_frame_depth: 0,
action: None,
memory_address: 0,
memory: [],
}
The source code is available here https://github.com/orochi-network/wasmi
Mul example:
RUST_BACKTRACE=1 cargo run --bin example -- --mul
Add example:
RUST_BACKTRACE=1 cargo run --bin example
A very simple WebAssembly program:
(module
(func (export "add_values") (param i64 i64) (result i64)
local.get 0
local.get 1
i64.add))
This program takes two parameters and calculates the sum of them.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing