Programs and the VM
A program on Ting, called a contract, is immutable WebAssembly code plus the records it stores. A deployment installs it, and it runs whenever a transaction or another contract calls it.
The VM is unusual less for what it can do than for how exactly it is defined:
- It accepts a precise integer subset of WebAssembly Core 1.0, with three additions taken from Release 2.0 and the four wide-arithmetic instructions, and rejects everything else.
- Each instruction has one exactly defined meaning, written down in this section instruction by instruction, and a measured price. The definitions follow the dated WebAssembly standard so ordinary compilers target the profile; Ting adds rules only for what a program may import, how resources are charged, and how calls and failures behave.
- The whole machine, from the bytes of a module to the last counter of a receipt, is implemented in Ting's own code and checked against independent evidence.
- Every invocation starts from scratch, with fresh memory and fresh globals. Anything that should last goes into storage through the host interface.
- Programs cannot reach a filesystem, a network, a clock or a source of randomness. Given the same state and input, a program does the same thing on every node.
The pages of this section define the VM in full: the profile and the binary format a module must fit, how it is validated, what every instruction does, how the abstract machine runs it, what happens at deployment and invocation, the host interface, calls and rollback, and exact metering. Where another page of the wiki describes the VM in passing, these pages decide.
In this section
The execution profileThe exact integer WebAssembly subset every node accepts.The binary formatThe exact bytes a module may consist of, with one encoding per construct.ValidationHow a module is typed, bounded and measured before it can run.Instruction referenceAll 111 accepted instructions with their encodings and exact meaning.The abstract machineValues, the stack, labels, instances, host calls and how an invocation ends.Deploy and invokeWhat happens when code is installed and each time it runs.The host interfaceThe twelve imports a program uses to talk to the chain.Calls, rollback and read-onlyNested invocations, checkpoints and inherited restrictions.Exact meteringHow every instruction is counted the same way on every node.