Examples#
This gallery walks through blockchainkit.vm, one experiment per
breakthrough on the execution history page: reverse Polish notation, Turing machines and
busy beavers, stack hardware, structured programming and Forth, replicated
and atomic execution, smart contracts and bytecode verification, Bitcoin
Script and hash time-locked contracts, and Ethereum’s gas, repricing,
reentrancy and overflow.
Each script is self-contained and runs with
python examples/vm/<section>/<script>.py.
Contracts and verification#
A contract enforced by code, and checking code before running it.
Bytecode verification: check before you run (Gosling 1995)
Ethereum#
Gas, gas repricing, reentrancy, and integer overflow.
Ethereum: a replicated computer metered by gas (Buterin 2014)
Gas repricing after denial-of-service attacks (EIP-150, 2016)
The DAO and reentrancy: checks, effects, interactions (2016)
Integer overflow: minting tokens from nothing (BeautyChain, 2018)
Foundations of stack machines#
Reverse Polish notation, the halting problem and busy beavers, hardware stacks, structured control flow, and Forth.
Reverse Polish notation: the stack’s natural order (Łukasiewicz 1924, Hamblin 1957)
The halting problem: why every call needs a budget (Turing 1936)
Stack hardware: a bounded stack (Burroughs B5000, Barton 1961)
The busy beaver: the longest a small machine can run (Radó 1962)
Structured programming: sequence, selection, iteration (Böhm and Jacopini 1966)
Replicated and atomic execution#
Deterministic replicas and all-or-nothing transactions.
State-machine replication: same inputs, same order, same state (Lamport 1978, Schneider 1990)
Bitcoin Script#
Spending conditions as loop-free stack programs: pay-to-public-key-hash and hash time-locked contracts.
Bitcoin Script: pay to public-key hash (Nakamoto 2009)
Hash time-locked contracts: pay for a secret, or get a refund (2015-2016)