Start Your Own Blockchain
In this activity, you will get hands on experience operating a blockchain node and seeing it interact with other blockchain nodes.
📥 Clone to start: Academy PoW Node
See the README included in the repository for further instructions.
Learning objectives:
- How to run a node
- What the log messages mean
- Preview: How to configure a network with a chain spec
- Experience peer connections coming and going
- Practice checking for common not-peering issues (different genesis, firewall)
Outline
Clone & Compile
⏰ Because the compile time is quite long, this should be done in advance of class.
Ideally, compilation will be given to you as as homework on the day before to run (at worst) over night. The faculty may also have a docker image ready to go, please request this if needed.
Generate User Keys
With Polkadot JS
Get Tokens
You request tokens from the teacher by sharing your address with the teachers in a public channel. After the first five you have tokens, we pass them on to your peers. This manual approach allows you to get familiar with sending and receiving tokens in your wallet.
Optionally, we may install a faucet or UBI pallet in the chain to allow you to self service after the initial manual distribution.
Optional Treasure Hunt
You could have tokens stored at eg the Alice key or other leaked keys and challenge you to find and recover the tokens. Make up a story/myth about some mysterious figure who lost your key and left clues, etc.
Run Nodes
You start your own nodes and join the network
Start Mining
Node runners can contribute PoW hashrate to the network in exchange for tokens.
Fork the Network
In BA we forked the difficulty, but maybe there is something more compelling. Maybe fork to adjust max block size. Nice because it happened for real in bitcoin. Maybe hard because I believe max block size is controlled in the runtime.
Another idea:
When we launch the chain, we allow PoW block to have either of two valid kinds of seals.
For example, one based on sha3
and another based on keccak
.
Then we pretend there is a cultural war and some people like one function or the other hand some people don't care.
When the time comes to fork, we have three different versions of the node available: 1 only accepts sha3
, 2 only accepts keccak
, 3 is the original that accepts either.
In this way we can see that there will be at least two viable chains (the sha 3 chain and the keccak
chain).
If there are a lot of nodes that still run the old version and accept either hash, we will form a third chain.
But if there are only a few such nodes, we will re-org into one of the other two chains, and potentially reorg back and forth between them.
Smart Contracts
The Smart Contracts module has an activity about launching smart contracts on a running chain. When these modules are run back-to-back, it makes an excellent learning experience to use this same chain we just launched to also launch the smart contracts.