Principles of Blockchains

Instructor

Prof. Pramod Viswanath, pramodv@princeton.edu

Teaching assistants

Zerui Cheng, zerui.cheng@princeton.edu

Mahsa Bastankhah, mhs.bastankhah@princeton.edu

Jianzhu Yao, jy0246@princeton.edu

Niusha Moshrefi, niusha@princeton.edu

Grading

The grade of this course will consist of 4 parts.

[Note: The schedule and grading is tentative now.]
  1. Coding Assignment (56% = 7% * 8) : You will get a joyful and hands-on experience building your own Bitcoin client from scratch. The client will be built with 8 step-by-step assignments, and each assignment will make up 7% of your final grade.
  2. Written Homework (12% = 4% * 3): 3 problemsets will be released to help you enhance your understanding of the lectures. Each problemset will make up 4% of your final grade.
  3. Course Project (26%): You will work in groups and have fun creating a crowdsourced dataset and building your own AI assistant for this course. Deliverables are dataset entries submission due Oct 30, peer evaluation due Nov 7, a brief interim report due Nov 14, demo day on Nov 15 and 22, and final report/code submission due Dec 13. Link to final project intro slides Link to more details on GitHub
  4. Attendance (6%): We encourage active participation from all of you, and the reward for you are designated NFTs for each lecture you attend. You will use the minted NFTs to claim your credits for attendance. 8/12 attendances are good for full marks, and if your attendance is x/12, your grade for attendance will be assessed with max(0, min(6, x-2)).

Course Syllabus and Material

All assignments and homeworks are due 10PM the next Wednesday after the class.

Office hours will be held by TAs on Mondays and Tuesdays each week since Sep 16.

Detailed Office Hour Schedule

In-person Office Hour 1: Every Monday, 5-6pm, EQuad J323

In-person Office Hour 2: Every Tuesday, 3:30-4:30pm, EQuad J323

Virtual Office Hour: Every Tuesday, 8-9pm: Link to Zoom Meeting

Note: The last meeting day of the course is Nov 26 (Tuesday) due to academic calendar adjustments for the Thanksgiving holiday.

Lec No. Date Theme Topic Lecture notes Full video Course materials Homework
1 Sep 06 Lec 1 Bitcoin Introduction Notes Video Slides  
2 Sep 06 Lec 2 Cryptographic primitives Notes Video Slides  
3 Sep 13 Lec 1 Nakamoto consensus Notes Video Slides  
4 Sep 13 Lec 2 P2P network Notes Video Slides Part 1
Due 9/18
5 Sep 20 Lec 1 Bitcoin system Notes Video Slides HW 1
Due 9/25
6 Sep 20 Lec 2 Bitcoin safety Notes Video Slides Part 2
Due 9/25
7 Sep 27 Lec 1 Bitcoin liveness Notes Video Slides  
8 Sep 27 Lec 2 Scaling Bitcoin: Layer 1 Scaling Scaling throughput Notes Video Slides Part 3
Due 10/2
9 Oct 04 Lec 1 Scaling latency Notes Video Slides HW 2
Due 10/9
10 Oct 04 Lec 2 Sharding Notes Video Slides Part 4
Due 10/9
11 Oct 11 Lec 1 Proof of stake Notes Video Slides
12 Oct 11 Lec 2 Scaling Bitcoin: Layer 2 Scaling Side Blockchains Notes Video Slides Part 5
Due 10/23
13 Oct 25 Lec 1 Payment Channels Notes Slides HW 3
Due 10/30
14 Oct 25 Lec 2 Rollups Notes Video Slides Part 6
Due 10/30
15 Nov 01 Lec 1 Beyond Bitcoin Streamlet and Hotstuff Notes Video Slides
16 Nov 01 Lec 2 Finality gadget: bridge BFT and
longest chain protocols
Notes Video Slides
17 Nov 08 Lec 1 Accountability Video Slides
18 Nov 08 Lec 2 Data Privacy via ZK Notes Video Slides Part 7
Due 11/13
21 Nov 15 Project Presentation Demo Day 1
22 Nov 22 Demo Day 2
19 Nov 26 Lec 1 Wrap up Bridges Video Slides
20 Nov 26 Lec 2 Summary Video Slides Part 8
Due 11/27

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 8 programming assignments in the Rust programming language. Students will form groups of 2 or 3 and work on their own machines on the sequence of tasks. 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 18, 2024.

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 25, 2024.

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, October 2, 2024.

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 9, 2024.

[Fall Recess: Oct 12 – Oct 20. No assignments. Enjoy!]

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 23, 2024.

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 30, 2024.

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 13, 2024.

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 27, 2024.

Final Project: Crowdsourcing to Build a Powerful AI Course Assistant

In recent years, generative AI tools like GPT and GitHub Copilot have transformed the way we tackle assignments and projects, especially in technically demanding fields like blockchain. These tools can speed up processes, offer quick insights, and serve as excellent helpers on a variety of tasks. Many students have likely used these tools to assist with their thomework and projects in this course. But, as you might have noticed, they’re far from perfect when it comes to dealing with the complex and specific nature of blockchain technologies.

Often, these tools fail to grasp the multi-layered logic or intricate details required for advanced blockchain assignments. They may oversimplify answers or even misunderstand fundamental concepts. This is where our final project comes in. Our mission is to collaboratively design and fine-tune an AI assistant that better understands the challenges you face in this course. We’re aiming to create an AI that’s not just useful but genuinely insightful and capable of supporting your learning in a meaningful way.

Intro slides: Link (Google Drive)

More details on GitHub: Link (GitHub)