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.

Smart contracts: the vending machine (Szabo 1994)

Smart contracts: the vending machine (Szabo 1994)

Bytecode verification: check before you run (Gosling 1995)

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)

Ethereum: a replicated computer metered by gas (Buterin 2014)

Gas repricing after denial-of-service attacks (EIP-150, 2016)

Gas repricing after denial-of-service attacks (EIP-150, 2016)

The DAO and reentrancy: checks, effects, interactions (2016)

The DAO and reentrancy: checks, effects, interactions (2016)

Integer overflow: minting tokens from nothing (BeautyChain, 2018)

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)

Reverse Polish notation: the stack's natural order (Łukasiewicz 1924, Hamblin 1957)

The halting problem: why every call needs a budget (Turing 1936)

The halting problem: why every call needs a budget (Turing 1936)

Stack hardware: a bounded stack (Burroughs B5000, Barton 1961)

Stack hardware: a bounded stack (Burroughs B5000, Barton 1961)

The busy beaver: the longest a small machine can run (Radó 1962)

The busy beaver: the longest a small machine can run (Radó 1962)

Structured programming: sequence, selection, iteration (Böhm and Jacopini 1966)

Structured programming: sequence, selection, iteration (Böhm and Jacopini 1966)

Forth: programming with stack words (Moore 1970)

Forth: programming with stack words (Moore 1970)

Replicated and atomic execution#

Deterministic replicas and all-or-nothing transactions.

State-machine replication: same inputs, same order, same state (Lamport 1978, Schneider 1990)

State-machine replication: same inputs, same order, same state (Lamport 1978, Schneider 1990)

Atomic transactions: all or nothing (Gray 1981)

Atomic transactions: all or nothing (Gray 1981)

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)

Bitcoin Script: pay to public-key hash (Nakamoto 2009)

Hash time-locked contracts: pay for a secret, or get a refund (2015-2016)

Hash time-locked contracts: pay for a secret, or get a refund (2015-2016)

Gallery generated by Sphinx-Gallery