Back to Home

PBA-X

1. Cryptography

1.1 Kerckhoff's Principle:

A cryptographic system should be secure even if everything about the system, except the key, is public knowledge.

1.2 Hashing attacks

1.3 Encryption

1.4 Wallet and Accounts

1.5 Digital Signatures

1.6 Hash Based Data Structures

1.6.1 Hash Chains

1.6.2 Merkle Tries

Diagram Description

1.6.3 Merkle Mountain Range

Diagram Description

1.6.4 Radix/Patricia Tries

Diagram Description

1.7 Advanced Cryptography Topics

1.7.1 Shamir Secret Sharing

1.7.2 Verifiable Random Functions (VRFs)

A VRF is a cryptographic function that:

1.7.3 Zero-Knowledge Proofs (ZKPs)

2. Fundamentals of blockchains

2.1 Blockchain Concepts Pre-Quiz:

2.2 Blockchain Networks:

2.2.1 Types of Decentralization

2.3 Blockchain Architecture

Diagram Description

Diagram Description

2.4 Blockchain Trilemma

2.5 Blockchain Consensus

2.5.1 Layers of Consensus

These are used in consensus mechanisms to filter out chains until we find the canonical chain.

2.5.2 Consensus Mechanisms

2.5.3 Block Finality Mechanisms

2.5.3.1 Probabilistic Finality
2.5.3.2 Deterministic Finality
2.5.3.3 GRANDPA

2.5.4 Forks in Blockchain

2.6 Blockchain Node v/s Runtime

Diagram Description

3. Polkadot

3.1 Blockchain

A blockchain is, in its essence, a distributed and decentralized key-value database. The principle of a blockchain is to make it possible for any participant to perform modifications to this database, and for all participants to eventually agree on the current state of said database.

In Polkadot and Substrate-compatible chains, the state of this database is referred to as "the storage". The storage can be seen more or less as a very large HashMap.

A blockchain therefore consists in three main things:

  1. The initial state of the storage at the moment when the blockchain starts
  2. A list of blocks, where each block represents a group of modifications performed to the storage
  3. A peer-to-peer network of clients connected to each other and exchanging information such as newly-produced blocks

Blocks are built on top of each other, forming a sequential list of modifications to the storage on top of its initial state.

3.2 Polkadot Architecture

Polkadot is a heterogeneous multichain with shared security and interoperability.

Diagram Description

3.2.1 Relay Chain - A Layer 0 Blockchain

The Relay Chain is the central chain of Polkadot. The Relay Chain has deliberately minimal functionality - for instance, smart contracts are not supported. The main responsibility is to coordinate the system as a whole, including parachains. Other specific work is delegated to the parachains, which have different implementations and features.

3.2.2 Parachains and Parathreads

Polkadot can support a number of execution slots. These slots are like cores on a computer's processor (a modern laptop's processor may have eight cores, for example). Each one of these cores can run one process at a time.

Polkadot allows these slots using two subscription models:

3.2.3 Validator

Validators are the Relay chain nodes that, if elected to the validator set, produce blocks on the Relay Chain. They are incentivized to act in the best interests of the network through rewards.

3.2.4 Collator

Collators are full nodes on both a parachain and the Relay Chain. They:

3.2.5 Bridges

A blockchain bridge is a connection that allows for arbitrary data to transfer from one network to another. These chains are interoperable through the bridge but can exist as standalone chains with different protocols, rules, and governance models.

In Polkadot, bridges:

4. Polkadot SDK

4.1 Polkadot SDK Overview

4.2 Substrate (PolkadotSDK's blockchain building framework)

4.2.1 Substrate Wasm Meta Protocol

Diagram Description

Diagram Description

Diagram Description

4.3 Polkadot SDK Storage Overview

4.4 Extrinsics in Polkadot SDK

In Polkadot SDK based blockchains, the transactions (extrinsics) can be:

4.5 Off Chain Workers (OWCs) and Oracles in Polkadot SDK

  Use Case    → Implementation Choice

  Low-value data     → OCW direct fetch
  High-value data    → Oracle service
  Complex compute    → OCW processing
  Critical data      → Multiple oracles
  Parachain A                    Parachain B
      ├── OCW fetches data          ├── Uses oracle data
      ├── Validates locally         ├── Pays for access
      └── Submits to chain          └── Trusts oracle source

5. FRAME

5.1 Pallets

Diagram Description

6. XCM

7. Parachains

7.1 Collators

7.2 Backing Group / Polkadot Core / Execution Core

Diagram Description

7.3 Parachain Block Validation and Inclusion

                            Polkadot Data Availability Process
                                     +-----------------------+
                                     |     Parachain Block    |
                                     | (Collation by Collator)|
                                     +-----------+-----------+
                                                 |
                                                 v
                                     +-----------------------+
                                     |   Backing Group       |
                                     | (Validate Correctness)|
                                     +-----------+-----------+
                                                 |
                                                 v
                                     +-----------------------+
                                     | Reed-Solomon Erasure  |
                                     | Coding & Distribution |
                                     +-----------+-----------+
                                                 |
                                                 v
               +---------------------+--------------------------+---------------------+
               |                     |                          |                     |
               v                     v                          v                     v
      +----------------+   +----------------+         +----------------+   +----------------+
      | Validator 1    |   | Validator 2    |   ...   | Validator N    |   | Validator N+1  |
      | (Chunk Storage)|   | (Chunk Storage)|         | (Chunk Storage)|   | (Chunk Storage)|
      +----------------+   +----------------+         +----------------+   +----------------+
                                                 |
                                                 v
                                     +-----------------------+
                                     | Relay Chain Block     |
                                     | - Parachain Header    |
                                     | - Erasure-Coded Root  |
                                     | - Validity Proofs     |
                                     +-----------------------+

7.3.1 Overview

After a collator creates a parachain block (collation), it undergoes two critical stages before being included in the Relay Chain block:

  1. Backing Process: The collation is validated by a subset of Relay Chain validators (the backing group) to ensure correctness.
  2. Data Availability Stage: Ensures the collation's data is stored redundantly across the network so it can be reconstructed later if needed.
  3. Approval Checking and Disputes: A random subset of validators (not in the backing group) is selected to re-check the block. Validators submit approval votes to the Relay Chain. If there is even one validator which rejected the collation, it creates a Dispute and all validators in the relay chain then verify the collation and the stake of the malicious actor gets slashed.
  4. Finalization: In the end, the block is finalized via GRANDPA (Polkadot's finality gadget). GRANDPA would never finalize a disputed block.

7.3.2 Collation vs PoV (Proof of Validity) Block

Key Differences

Aspect Collation Proof of Validity (PoV)

Content Transactions, state changes, block data. Cryptographic proof of the collation's validity.

Created By Collators (parachain-specific nodes). Collators (using the parachain's logic).

Role in Validation Raw data to be validated. Enables efficient validation by Relay Chain.

Storage Stored on parachain nodes. Submitted to Relay Chain alongside collations.

Dependency Standalone block data. Dependent on the collation it proves.

7.3.3 Key Steps

Diagram Description