Talk given by Marianne Goldin to the Seattle Women in Blockchain Meetup group on June 16, 2022.
For deck with embedded links: https://docs.google.com/presentation/d/10DrpqHfaBPW5vhwLPnmkOlvmxFaLXEhnbzIL0ZC0B4A/edit?usp=drivesdk
29. Chainspec - network “recipe” + DNA
Network settings:
● Unique Ids
● Storage data items
● Error reasons
● Network modes
● Voting settings
● Network entity roles
● Banned/Allowlisted
roles
● Other network
customizations…
Genesis settings:
● Initial token balances
● Accounts initially part
of a governance
council
● Holder of the
“master” sudo key for
admin transactions.
● Starting runtime logic
(as compiled WASM
blob)
Source: Chain Specification. Substrate v.3.0 Developer Docs.
+
Builds
Genesis
Block
30. Steps in Writing Blocks
Source: Transaction Pool. Substrate v.3.0 Developer Docs.
1. Validator collects transactions and validates it
2. Validator transmits transaction to shared transaction pool
3. Transaction pool checks transaction validity
4. Transaction pool assigns transaction to ready/future queue
5. Transactions in “ready” queue gossiped to all network parties
6. Validators use block authoring consensus to create blocks
7. Validators use finality consensus to finalize blocks
8. Finalized block is broadcast to the network
9. Each validator updates its chain with the new block
31. How a Transaction Becomes a Block
Source: Polkadot Consensus Part 2: GRANDPA. Medium.com. Joe Petrowski, 18 Dec 2019.
Transaction Pool
Pending blocks
(with
transactions)
New blocks
(ready for
finalization)
Existing chain
(for finalization)
32. Goal: One “Canonical” (Authoritative) Chain
Source: Web3 Foundation Consensus Tutorial - Bill Laboon - #CryptoEconSys20. 18 Mar 2020.
33. Block Authoring/Production Algorithms
Aura (PoAuthority)
Turn-taking order consistent
Limited by slot duration
Forks uncommon
Babe (PoStake)
Weighted authority mechanism. Turn taking
order changes every block
Forks more common
Proof of Work
(PoW)
Similar to Bitcoin,
Ethereum
Source: Consensus. Substrate Version 3.0 Docs.
Slot-Based Voting Rounds, Known Validators No Slots or Validators - Open Block Production
34. BABE authors blocks
Source: Consensus. Substrate Version 3.0 Docs.
Longest Chain Rule
“Best Chain is the
Longest Chain”
35. Block Finalization Algorithms
Provable methods
- GRANDPA
Verifies BABE.
Chooses “canonical chain” through voting: 2 rounds
of voting, result called when voting quorum reached
(⅔ of all consensus nodes voted).
Probabilistic
methods
Chooses longest chain as the “canonical chain”.
Used in Bitcoin-like systems
Source: Consensus. Substrate Version 3.0 Docs.
*GRANDPA: GHOST-based Recursive ANcestor
Deriving Prefix Agreement
*GHOST: Greedy Heaviest Observed SubTree
36. GRANDPA verifies BABE’s block production and finalizes
Source: Consensus. Substrate Version 3.0 Docs.
GHOST (Greedy Heaviest Observed SubTree)
“Choose the branch
that has the most
blocks built on it
recursively”
Can override BABE
37. Without Finalization, Forks Can Form
Authoring
Finalization
Fork 1
Fork 2
Fork 3
Canonical Chain
Consensus
(Node = Validator, aka Consensus Node)
48. Interoperability: A definition
Source: Interoperability in the Age of Siloed Blockchains Pt. 1. Lucas Nuzzi. Medium.com. 19 Aug 2019.
“the ultimate goal [of blockchain interoperability] is the
same:
take asset/information from one blockchain chain,
validate its existence and preconditions (e.g. time-locks),
and recreate it synthetically in chain B”
49. Para…stuff
“One can imagine that a chain developed with
Substrate can at different points in its lifetime
assume one of three states:
an independent chain with secured bridge,
a parachain,
or a parathread.”
Source: Learn Parathreads. Polkadot Network Wiki
50. A Means of Sending Messages Across Chains
Source: Japan Rail (JR) Metro Line in Tokyo, Japan
51. Source: The Polkadot & Kusama Ecosystem. Messari.com. Mira Christanto 20 May 2021.
52. Parachain Components
Source: The Polkadot Architecture and Introduction to the Substrate Infrastructure. CoinTelegraph via Dot
Pulse.
58. Platform Comparison
Name (Company) Differentiator License Pros Cons
Substrate (Parity)
Separate node authoring
and finalization
Provable finality with low
stalling
Forkless upgrades
GPL 3.0, Apache 2.0
Out of the box consensus
Highly modular
Active community
Many docs
Written in Rust
Complex Rust
implementation
Esoteric documentation
and concepts
Sawtooth & Fabric
(Hyperledger)
Integrated with DAML
Designed for scalability &
security
Apache 2.0
Open Source
Many docs
Few proven use cases
Few developers
Licensing challenge for
enterprise
Upgrade difficulties
Corda
Fine grained permissioning
for network access
Apache 2.0
Scalable and performant
Active community
Financial use cases
Difficult network
maintenance
Cardano
Lower energy consumption
Scalable
MIT
Scalable
Network-level
programmable privacy
Speed of development
Lacking smart contract-
specific privacy, requires
zCash impl.
63. Substrate Learning
SUBSTRATE RUNTIME TRAINING
Training - Getting Started | System Intro | YouTube Channel | Seminars | Developer Hub
Developer Resource - Walkthrough Video | Resource Page
Examples, Templates, Libraries, Announcements, Jobs - Awesome Substrate
Developer Forum - Stack Exchange
Developer Ecosystem - Resources and Overview
Code Training - Substrate Runtime Code Intro Video | Pallet Fundamentals Video
Conference - Parity Sub0 2021 Recorded Talks
SUBSTRATE SMART CONTRACT TRAINING
First Impressions working with Substrate and Ink (WASM Smart contracts) - Part 1 | Part 2 | Part 3
Substrate Official Ink (WASM Smart contracts) Tutorial
BOOTCAMPS
Substrate Dev Camp - Mailing list for next intake - requires Rust experience
64. Other Learning
RUST LANGUAGE TRAINING
Rust Official - Learning resources | Rust Book
Rust Conf ‘22 - Aug 5, 2022 - Portland, OR + Livestream
BLOCKCHAIN TRAINING
Web3 Blockhain Fundamentals
65. Opportunities
GRANTS/PRIZES/STIPENDS
Polkadot Ambassadors Program
Web3 Foundation Grants
Substrate Builders Program
Polkadot Hackathon (through July 18, 2022)
Incentivized Proposals for Services on Polkadot Network
JOBS
Parity Jobs - Company that builds Substrate
Substrate Job Board
Web3 Jobs
Rust In Blockchain Job Board - Jobs for Blockchain programmers using Rust
66. Engineering Job Examples
Aptos Labs - React Native
Engineer |
Software Engineer, Ecosystem |
Front End Engineer
Subspace Labs - Protocol
Engineer (Core)
ChainSafe Systems - Rust
Engineer (Substrate)
T3rn - Rust/Substrate Engineer
Definity - Web3 Software
Engineer Apprentice, SDK
Nori - Test Automation
Engineer, Web3 (SDET)
Trail of Bits - Remote
Blockchain Security
Apprenticeship
Transparent Systems -
General Application
67. Non-Engineering Job Examples
Analog - Community Lead |
Blockchain Research Analyst |
Crypto Marketing Lead
Proof of Learn -
Web3 Content Copywriter,
Remote
Magic Labs, Inc. -
Developer Advocacy Lead,
Web3
Transparent Systems -
General Application
68. CREDITS: This presentation template was created
by Slidesgo, including icons by Flaticon, and
infographics & images by Freepik
Thanks!
marianne.goldin
@gmail.com
Elections Phragmen: based on the Phragmen paper which introduced a method for electing a number of winners from a pool of candidates. Used for Proof of Stake systems such as in the Polkadot network, to elect validators based on their own qualification (self-stake or votes for themselves) and based on the stake that is voted to them from other nominators (other validators or consensus nodes). Voting is performed in multiple rounds in order to equalize weights between the consensus (voting) nodes after each election round. See also: https://wiki.polkadot.network/docs/learn-phragmen
See also: https://www.youtube.com/watch?v=1CuTSluL7v4Finality in a Proof-of-Stake (PoS) blockchain refers to the condition where reverting to a previous state would result in a significant amount of staked tokens being slashed because a supermajority of the chain’s validators had approved the final state. Although reverting a finalized block is technically possible, it would represent a large error by the validator set. It is not possible to have this type of finality - where reversion represents an error by a supermajority of the validators - in a PoW chain because the set of validators (miners) is theoretically infinite. PoW chains, therefore, have “probabilistic” finality, because at some point the probability of reversion is considered negligible.
Finalizes blocks produced by BABE
Aura
Aura primarily provides block authoring. In aura a known set of authorities are allowed to produce blocks. The authorities must be chosen before block production begins and all authorities must know the entire authority set. Time is divided up into "slots" of a fixed length. During each slot one block is produced, and the authorities take turns producing blocks in order forever.
In Aura, forks only happen when it takes longer than the slot duration for a block to traverse the network. Thus forks are uncommon in good network conditions.
Babe
Babe also primarily provides block authoring. Like, Aura, it is a slot-based consensus algorithm with a known set of validators. In addition, each validator is assigned a weight which must be assigned before block production begins. Unlike Aura, the authorities don't take turns in order. Instead, during each round, each authority generates a pseudorandom number using a VRF. If the random number is lower than their weight, they are allowed to produce a block.
Because multiple validators may be able to produce a block during the same slot, forks are more common in Babe than they are in Aura, and are common even in good network conditions.
Substrate's implementation of Babe also has a fallback mechanism for when no authorities are chosen in a given slot.
Proof of Work
Proof of Work also provides block authoring. Unlike Babe and Aura, it is not slot-based, and does not have a known authority set. In proof of Work, anyone can produce a block at any time, so long as they can solve a computationally challenging problem (typically a hash preimage search). The difficulty of this problem can be tuned to provide a statistical target block time.
Validators randomly select themselves to produce blocks
Validators selected by amount of stake (tokens)
In charge of block production (before finalization)
Finalizes blocks produced by BABE
Block Authoring. Nodes create new blocks. Each new block contains a reference to a parent block.
Block Finalization. When forks appear in the chain, Nodes must choose which side of the fork to consider the real or "canonical" one. Once a block is Finalized, the canonical chain will always contain it.
In this example, there are 10 validators, meaning 3 is the maximum number of faulty validators the system can withstand (f = (10–1) / 3). With 4 faulty validators (red) and a network partition, each group of honest validators (blue) can think a different block is final
To create a blockchain and connect it to Polkadot, on a technical level, you could build your own blockchain from scratch and equip it with a block validation function in WebAssembly. From scratch means that you have to implement your own node, RPC synchronization, networking, cryptography, database, storage, consensus, as well as extended features such as a light client and telemetry. This bare-bones approach is known as Polkadot Core.
If you don’t want to create all of those for scratch, you can start with Substrate Core. Substrate Core provides you with all the above functionalities, only requiring you to code your own runtime (state transition function), but also offers the possibility to customize networking, block authoring, and the transaction queue functionality.
If you decide to use the Substrate Runtime Module Library (SRML), then all you have to do is pick the modules you need from the library and configure them with your desired parameters. Your blockchain will work with tools such as event tracking and a blockchain explorer. Additionally, you are able to modify the existing modules or write your own ones, if needed.
The blockchain development equivalent of room service is Substrate Node. With Substrate Node, you get a complete smart contract blockchain just by providing a JSON config file.
The benefits of connecting to the Polkadot or Kusama network includes enabling a cheap but secure way for blockchains and apps to launch with forkless upgrades, scalability, and some governance structure. Within the network and bridges, projects can leverage the security and inter-parachain communication offered by Polkadot or Kusama. Projects don’t need to spend the time and money establishing a validator set and building up enough economic security to make attacks cost-prohibitive. Polkadot and Kusama are plug-and-play options for developers looking to launch new networks.
Parachains, blockchains in the Polkadot network, are secured by Polkadot’s relay chain and thus are not able to select their own consensus mechanism. If a blockchain wants to use its own consensus mechanism, it can use a parachain as a “bridge” to connect to Polkadot’s network.
One could argue that parachains are optimized for _inter_operability (communication between separate applications/chains), while smart contracts are optimized for _intra_operability (communication within a chain runtime).
The parachain functionality with pooled security in this case only extends to the bridge, whereas Ethereum, connected to the other side of the bridge, resembles more of a sidechain with the chains’ mutual ability to interpret each other’s block headers, state transition, and finality.Bridging chains that have probabilistic finality will also have implications on latency. This means that it will be reasonable to wait an appropriate time period to consider a transaction coming from e.g. Ethereum to the relay chain as final. Transactions within, and coming from, the Polkadot network with its adaptive, progressive finality can be considered final much faster,almost instantly. This results in waiting time for a transaction exiting a bridged chain, but almost no waiting for all the other transactions in the Polkadot network.