Principles of Blockchains

Instructor

Prof. Pramod Viswanath, pramodv@princeton.edu

Teaching assistants

Ashwin Hebbar – hebbar@princeton.edu
Tianle Cai – tianle.cai@princeton.edu
Benjamin Finch – btfinch@princeton.edu

Course Material

Lecture Number Date Theme Topic Lecture notes Summary video Full video Course materials HW Due
1 Sep 05 Bitcoin Introduction Notes Video Slides  
2 Sep 07 Cryptographic primitives Notes Video Slides  
3 Sep 12 Nakamoto consensus Notes Video Slides  
4 Sep 14 P2P network Notes Video Slides Part 1
5 Sep 19 Bitcoin system Notes Video Slides HW 1
6 Sep 21 Bitcoin safety Notes Video Slides Part 2
7 Sep 26 Bitcoin liveness Notes Video Slides  
8 Sep 28 Scaling Bitcoin: Layer 1 Scaling Scaling throughput Notes Video Slides Part 3
9 Oct 03 Scaling latency Notes Video Slides HW 2
10 Oct 05 Sharding Notes Video Slides Part 4
11 Oct 10 Proof of stake Notes Video Slides
12 Oct 12 Scaling Bitcoin: Layer 2 Scaling Side Blockchains Notes Video Slides Part 5
13 Oct 24 Payment Channels Notes Slides HW 3
14 Oct 26 Rollups Notes Video Slides Part 6
15 Oct 31 Beyond Bitcoin Streamlet and Hotstuff Notes Video Slides
16 Nov 02 Finality gadget: bridge BFT and
longest chain protocols
Notes Video Slides
17 Nov 07 Accountability Video Slides
18 Nov 09 Data Privacy via ZK Notes Video Slides Part 7
19 Nov 14 Bridges Video Slides
20 Nov 16 Summary Video Slides Part 8
Nov 30 HW 4

Course Outline

Blockchains are decentralized digital trust engines and are a potential replacement to “digital platforms” that we encounter in today’s world. Digital platform companies occupy 7 of the largest companies in the world based on market capitalization (eg: Apple, Google, Microsoft, Amazon, Alibaba, Tencent). Blockchains came into prominence through Bitcoin, a cryptocurrency, introduced in 2009. In the decade since its inception, blockchain designs have evolved significantly, although the corresponding evolution of applications (beyond cryptocurrencies) have not caught up yet. In this course, we study a full-stack design of blockchains: we view the blockchains as a whole integrated system involving networking, incentives, consensus, application layer support. The course covers the foundations of blockchains, and is divided into 3 parts: in the first part we study the Bitcoin design in detail. Although very secure and remarkably incentive compatible in the real world, Bitcoin has very poor performance in many ways: throughput, latency, energy, compute, storage and communication. In the second part we study the various efforts to scale the performance of Bitcoin in all the different dimensions, while maintaining the incentive compatibility and security of Bitcoin. In the final part, we study aspects of blockchain design that were simply not considered in Bitcoin (e.g., privacy, finality). In the spirit of Nakamoto (who implemented and tested the Bitcoin client before writing the white paper), this course will be implementation-heavy. We will use the Rust programming language for our assignments and projects for the foundation component of the course. By the end of the course, you will implement a Bitcoin client in Rust. 

Course Notes

  • Lecture notes, slides and supplementary reading material will be provided for each lecture.
  • Supplemental reading:
    • Bitcoin and Cryptocurrency Technologies, A. Narayanan, J. Bonneau, E. Felten, A. Miller and S. Goldfeder, Princeton University Press. Henceforth termed as PUP (Princeton university press).
    • Introduction to Cryptocurrencies, a basic online course by Haseeb Qureshi.

Pre-requisites

The basic technical prerequisites are a background in probability and algorithms. Decent amount of software programming background is essential. 

Bitcoin Client Project

We are going to build a simplified Bitcoin client with full node functionality as part of the course assessment. The client is built over the course of 8 programming assignments in the Rust programming language. Each student will work on their own on the sequence machine problems. At the end of the project, students will create a private test net amongst themselves and have fun changing various parameters of the client.

Part 1: In this introductory assignment, you will get to learn the basics of Rust programming language and useful libraries. The assignment will be accessed and completed on Github, available here: [ Part 1 ]. Due date: 10PM, September 14, 2022.

Part 2: In this assignment, you will get to learn to basic cryptographic primitives (hash functions and signatures) and build fundamental data structures that form the core of blockchains: block chains and Merkle trees. The assignment will be accessed and completed on Github, available here: [ Part 2 ]. Due date: 10PM, September 21, 2023.

Part 3: Block and Blockchain structure – Create block and blockchain struct and add some functions related to it. More detailed instructions can be found at [ Part 3 ]. Due date: 10PM, September 28, 2023.

Part 4: Mining – Implement a mining module of the bitcoin client. The mining module(miner) will produce blocks by solving the proof-of-work puzzle. More detailed instructions can be found at [ Part 4 ]. Due date: 10PM, October 5, 2023.

Part 5: Network – Implement the network module of Bitcoin client. The network module is in charge of communicating with other nodes/clients. It forms the peer-to-peer (p2p) network and uses gossip protocol to exchange data, including blocks and transactions. More detailed instructions can be found at [ Part 5 ]. Due date: 10PM, October 12, 2023.

Part 6: Putting together a data blockchain – Combine last 3 week’s work to make a functioning data blockchain. Most of this week’s work will be combining mining, network, and blockchain modules. You will need to add PoW validation and a block buffer to handle orphan blocks. More detailed instructions can be found at [ Part 6 ]. Due date: 10PM, October 26, 2023.

Part 7: Transactions – Include transactions in the codebase. Integrate the transaction structure inside the block content, add network functionality to transaction propagation and adding a transaction mempool to be used by the miner to include transaction content in the block being mined. More detailed instructions can be found at [ Part 7 ]. Due date: 10PM, November 9, 2023.

Part 8: State transition and validation – This is the last part of midterm project, and you are going to finish the Bitcoin client. You need to maintain a state for the ledger that the blockchain creates and add all the necessary checks related to it. More detailed instructions can be found at [ Part 8 ]. Due date: 10PM, November 16, 2023.