A full blockchain in Go;
- Nakamoto consensus.
- Hashcash.
- Dynamic difficulty retargeting (epochs).
- Proof-of-work consensus - longest/heaviest chain rule.
- Merklized transaction tree.
- Ethereum-like coin state machine - basic ERC20 transfers.
- ECDSA (curve P256) wallets for signing transactions.
- Core data structures: RawBlock, RawTx, Block, Tx, Epoch, BlockDAG, current tip, Miner, NetPeer, Node
- Networking: HTTP peer interface, messages/methods include [bootstrap peers, gossip blocks, gossip txs].
- Miner: mine new blocks on the tip, measure hashrate.
- CLI: start a node, connect to the network, mine blocks.
Make sure you have Go 1.2.3+ installed.
make && cd build/ && ./tinychain node --port 8121 --db testnet.dbWork breakdown:
- building a simple block
- hashing a simple block
- building a proof of work solution
- building a chain of blocks
- computing the epoch/difficulty window for a chain of blocks
- creating a merkle tree accumulation of transactions
- computing the cumulative work in a chain of blocks
- constructing a blockdag and then choosing a tip
- improve txs
- replay protection for txs, tx nonce
- add version to RawBlock, RawTransaction for future prosperity
- block sync algorithm between nodes
- simple coin state machine
- coinbase
- state snapshots
- state diffs
- state checkpoints
- build a simple mempool module
- adding a simple state machine
- ValidateBlock
- first transaction is the coinbase
- maintain a uxto set - unspent transaction outputs
- validate txs - validate signature, transfer the coins
- ValidateBlock
- adding a method to recompute the state machine and using cached state
- implementing networking
- simple wrapper for sockets - address, port, and hof's to wrap the latency delays dropped packets etc
- peers connect
- peers can send messages, peers can register message handlers
- implement simple peer
- can send and receive blocks via network
- gossip block, gossip tx, get blocks, sync tip
- implement peer discovery and bootstrapping
- implement wallet and cli tool
- implement miner process
- implement admin api
- finally implement the CLI tool
- start miner
- stop miner
- check balance
- check network online nodes
- send coins
- receive coins
- add nonce to tx
- refactor miner code to be pretty
- improve robustness of sql queries- need to verify we use right number of columns and ?'s
- improve block/rawblock. missing fields, unset fields etc. tests for this.
- double check big endian canonical encoding
