Coursework for Introduction to Blockchain class at UChicago Summer 2018.
A simple blockchain simulation involving 1 DNS seed and 3 Full Nodes. gRPC is used to communicate with other nodes. Initially, each node registers itself with the DNS seed which then sends the previous registered full node as a response back. The first registering node gets a null response back from the DNS seed. When a full node receives a non-null response from the DNS seed, it handshakes with the node from the response. It then continutes handshaking with the response peer nodes from the first handshaked node and this process continutes until all the nodes are aware of it's peers. This procedure is illustrated with the following images with times steps T1 - T4
Once each full node has 2 peers, it will then be able to mine. The full nodes create transactions in a seperate thread randomly and communicate with other peers when a new transaction is created or a new block is mined so that the peers can update themselves. When a full node mines a block, all the full nodes (including the winner) will sleep for a random number of seconds between (1-3) to prevent race conditions. For mining, a fixed difficulty of 0x1e200000 is used.
- dns_seed has the source code to behave as a dns seed.
- dns_seed.proto - proto3 file for dns seed
- dns_seed_pb2 - generated message classes by grpc
- dns_seed_pb2_grpc - generated server and client classes by grpc
- server.py - dns seed server source code
- full_node has the source code to behave as a full node.
- blockchain.py - contains the class representation of blockchain components
- full_node.proto - proto3 file for full node
- full_node_pb2 - generated message classes by grpc
- full_node_pb2_grpc - generated server and client classes by grpc
- merkel_tree.py - merkel tree implementation
- server.py - full node server source code
Docker containers can be used to simulate the dns seed and full nodes. Each full node docker container must be linked to the dns seed on creation.
The following code for instance will link the full node a container called "full_node_a" to the dns seed container called "dns_seed".
docker run -it --name full_node_a --link dns_seed:full_node_a ubuntu:16.04
The same to be repeated for full nodes b and c.
Execute the server.py under dns_seed src package in dns_seed container first and then server.py under full_node src package for each of the full node containers.




