Skip to content

Commit 0c0d797

Browse files
author
Arnaud Bailly
authored
Publish site (#184)
1 parent ccbccd1 commit 0c0d797

File tree

111 files changed

+10929
-937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+10929
-937
lines changed

.github/workflows/ci.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ jobs:
126126
- name: 🏗️ Agda-to-HTML
127127
run: |
128128
nix develop --command bash -c ".github/workflows/scripts/agda-2-html.sh"
129+
129130
- name: Publish Docusaurus build
130131
uses: actions/upload-artifact@v4
131132
with:
@@ -134,8 +135,50 @@ jobs:
134135
path: |
135136
html/*
136137
138+
build-pdf-report:
139+
runs-on: ubuntu-22.04
140+
steps:
141+
- name: 📥 Checkout repository
142+
uses: actions/checkout@v4
143+
144+
- name: 🔧 Massage markdown
145+
run: |
146+
cat site/docs/reports/tech-report-1.md| sed -e 's/\/img/site\/static\/img/g' | sed -e 's/#scale50)/){ width=50% }/g' | sed -e 's/^#//g' > tech-report-1.md
147+
cat site/docs/reports/tech-report-2.md| sed -e 's/\/img/site\/static\/img/g' | sed -e 's/#scale50)/){ width=50% }/g' | sed -e 's/^#//g' > tech-report-2.md
148+
149+
- name: 📓 Build PDF
150+
uses: docker://pandoc/latex:3.2.0
151+
with:
152+
args: >- # allows you to break string into multiple lines
153+
--pdf-engine=xelatex
154+
-N
155+
--standalone
156+
--output=tech-report-1.pdf
157+
tech-report-1.md
158+
159+
- name: 📓 Build PDF
160+
uses: docker://pandoc/latex:3.2.0
161+
with:
162+
args: >- # allows you to break string into multiple lines
163+
--pdf-engine=xelatex
164+
-N
165+
--standalone
166+
--output=tech-report-2.pdf
167+
tech-report-2.md
168+
169+
- name: 📤 Upload PDF
170+
uses: actions/upload-artifact@v4
171+
with:
172+
name: tech-reports
173+
if-no-files-found: error
174+
path: |
175+
tech-report-*.pdf
176+
137177
build-docusaurus:
138178
runs-on: ubuntu-22.04
179+
needs:
180+
- build-specification
181+
- build-pdf-report
139182
steps:
140183
- name: 📥 Checkout repository
141184
uses: actions/checkout@v4
@@ -151,6 +194,18 @@ jobs:
151194
working-directory: site
152195
run: npm ci
153196

197+
- name: 📥 Download Agda specification
198+
uses: actions/download-artifact@v4
199+
with:
200+
name: agda-specification
201+
path: ./site/static/agda_html/
202+
203+
- name: 📥 Download PDF
204+
uses: actions/download-artifact@v4
205+
with:
206+
name: tech-reports
207+
path: ./site/static/
208+
154209
- name: 🏗️ Build Docusaurus site
155210
working-directory: site
156211
run: |
@@ -164,6 +219,37 @@ jobs:
164219
path: |
165220
site/build/*
166221
222+
# FIXME: remove once merged
223+
publish-staging-docs:
224+
environment: 'staging'
225+
runs-on: ubuntu-latest
226+
needs:
227+
- build-docusaurus
228+
steps:
229+
- name: 📥 Download Docusaurus build
230+
uses: actions/download-artifact@v4
231+
with:
232+
name: docusaurus-build
233+
path: ./site
234+
235+
- name: 🔑 Install SSH Key
236+
uses: shimataro/ssh-key-action@v2
237+
with:
238+
key: ${{ secrets.SSH_KEY }}
239+
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
240+
- name: 🔍 Adding Known Hosts
241+
run: ssh-keyscan -H ${{ secrets.STAGING_HOST }} >> ~/.ssh/known_hosts
242+
243+
- name: 🚅 Deploy with rsync
244+
uses: burnett01/rsync-deployments@7.0.1
245+
with:
246+
switches: -avzr
247+
path: site/
248+
remote_path: /var/www/${{ secrets.STAGING_HOST }}/public_html
249+
remote_host: ${{ secrets.STAGING_HOST }}
250+
remote_user: ${{ secrets.SSH_USER }}
251+
remote_key: ${{ secrets.SSH_KEY }}
252+
167253
publish-docs:
168254
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
169255
runs-on: ubuntu-22.04
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22
rm -f html/*.md html/*.html
33
agda --html --html-highlight=auto --css=Agda.css src/Peras/SmallStep.lagda.md
4-
for f in html/*.md; do pandoc $f -o ${f%.md}.html -s --css=Agda.css; done
4+
for f in html/*.md; do
5+
pandoc $f -o ${f%.md}.html -s --css=Agda.css;
6+
rm $f;
7+
done
58

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,49 @@
66

77
This repository is intended to host more or less formal specifications, experiments, models for the Ouroboros Peras protocol.
88

9+
## Roadmap
10+
11+
- Complete proofs.
12+
- Voting strings.
13+
- Liveness of the protocol.
14+
- Soundness of the executable specification.
15+
- Synchronize with Praos formalization.
16+
- Prepare a publication or online supplement.
17+
- Complete conformance suite.
18+
- Tests for non-voting parts of the protocol.
19+
- Serialization format and inter-process communication for testing third-party implementations.
20+
- Package for easy installation and use.
21+
- Recommend parameter values.
22+
- Seek and analyze stakeholder requirements, especially from partner chains.
23+
- Develop a parameter-evaluation tool (based on the Markov-chain simulator) that provides a full set of impact metrics for a given set of parameters.
24+
- Reach out to stakeholders.
25+
- Populate website with latest results.
26+
- Online versions of all analysis, simulation, and visualization tools.
27+
- Organize a stakeholder workshop and/or a Intersect Consensus Technical WG.
28+
- Feedback on specification format.
29+
- Feedback on conformance suite.
30+
- Feedback on and refinement of the draft CIP.
31+
- Tooling fixes and enhancements
32+
- Improve the usability, efficiency, and testing of the ΔQ software.
33+
- Provide out-of-the-box and possibly interactive visualization.
34+
- Provide faster numeric computations (e.g. using discretized CDFs and fast vector operations, possibly offloaded to GPU).
35+
- Provide additional combinators (e.g., quantile-arrival time) for the DSL.
36+
- Improve the protocol visualizer.
37+
- Allow users to inject adversarial behavior or network disruptions (e.g., "split brain" scenarios).
38+
- Make visualization scalable in the browser to long chains (i.e., hours of simulated block production) and large networks.
39+
- Improve the prototype simulator.
40+
- Add an efficient implementation suitable for large networks and long simulations.
41+
- Create a simple DSL for inputting simulation scenarios for both honest and adversarial behavior.
42+
- Improve the Markov-chain analyzer.
43+
- Add a DSL for defining scenarios.
44+
- Add visualization and analysis tools.
45+
- Collaborate with higher-resolution network simulation efforts, potentially implementing Peras on them.
46+
- PeerNet
47+
- ce-netsim
48+
- Move from the "pre-alpha" to the "alpha" version of the protocol.
49+
- Requires completion of the Peras paper.
50+
- Formalize and implement the preagreement YOSO abstraction.
51+
952
## Documentation
1053

1154
* [Weekly updates](docs/weekly) provide regular "heartbeat" about the

infra/cloud-run.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ resource "google_cloud_run_v2_service" "peras_server" {
3939
"managed-by" = "github-actions"
4040
}
4141
}
42+
43+
lifecycle {
44+
ignore_changes = [
45+
template, client, client_version
46+
]
47+
}
4248
}
4349

4450
resource "google_cloud_run_v2_service_iam_member" "noauth" {
@@ -59,4 +65,10 @@ resource "google_cloud_run_domain_mapping" "peras_server_domain_mapping" {
5965
spec {
6066
route_name = google_cloud_run_v2_service.peras_server.name
6167
}
68+
lifecycle {
69+
ignore_changes = [
70+
metadata,
71+
spec
72+
]
73+
}
6274
}

infra/ssh_keys

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
curry:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8aDeQyneOJA8KJegRWsJyf7qWbyKet5j0GACCDw7KS
2+
root:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8aDeQyneOJA8KJegRWsJyf7qWbyKet5j0GACCDw7KS

infra/staging.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
resource "google_compute_firewall" "allow-http-https" {
2+
name = "allow-http-https"
3+
network = "default"
4+
5+
allow {
6+
protocol = "tcp"
7+
ports = ["80", "443", "22"]
8+
}
9+
10+
// Allow traffic from everywhere to instances with an http-server tag
11+
source_ranges = ["0.0.0.0/0"]
12+
target_tags = ["staging"]
13+
}
14+
15+
resource "google_compute_address" "staging-external-address" {
16+
name = "staging-ip"
17+
}
18+
19+
resource "google_compute_instance" "staging-vm" {
20+
name = "staging-vm"
21+
machine_type = "n1-standard-1"
22+
tags = ["staging"]
23+
24+
allow_stopping_for_update = true
25+
26+
metadata = {
27+
sshKeys = file("./ssh_keys")
28+
}
29+
30+
boot_disk {
31+
initialize_params {
32+
image = "debian-cloud/debian-11"
33+
}
34+
}
35+
36+
network_interface {
37+
network = "default"
38+
access_config {
39+
nat_ip = google_compute_address.staging-external-address.address
40+
}
41+
}
42+
}
43+
44+
output "external-ip" {
45+
value = google_compute_address.staging-external-address.address
46+
}

site/docs/intro.md

Lines changed: 100 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,106 @@
1+
---
2+
sidebar_label: 'Introduction'
3+
sidebar_position: 1
4+
---
5+
16
# What is Peras?
27

3-
Peras, or more precisely Ouroboros Peras, is an extension of [Ouroboros Praos](https://iohk.io/en/research/library/papers/ouroboros-praos-an-adaptively-secure-semi-synchronous-proof-of-stake-protocol/) that addresses one of the known issues of blockchains based on Nakamoto-style consensus, namely _settlement time_.
8+
Peras, or more precisely Ouroboros Peras, is an extension of [Ouroboros Praos](https://iohk.io/en/research/library/papers/ouroboros-praos-an-adaptively-secure-semi-synchronous-proof-of-stake-protocol/) that addresses one of the known issues of blockchains based on Nakamoto-style consensus, namely _settlement time_. Peras achieves that goal while being _self-healing_, preserving the security of Praos, and being light on resources.
9+
10+
:::important
411

5-
:::warning
12+
This site documents the **pre-alpha** version of the protocol, which already provides strong guarantees of settlement bounds, adapts to fluctuating participation, and can recover from failures.
613

7-
Coming soon! We are working on providing documentation at various levels of details for Peras. Stay tuned.
14+
Research work is still ongoing to refine the protocol and provide even better guarantees in the face of high adversarial stake.
815

916
:::
17+
18+
## What is settlement?
19+
20+
Recall that in Cardano, like in all Nakamoto-style consensus blockchains, new blocks are added to the chain in a probabilistic way. The protocol gives each _Stake-Pool Operator_ (SPO) the right to _forge_ a new block every slot depending on the amount of stake they represent, and the protocol parameters are defined in such a way that one new block is created every 20 slots. A newly forged block is then propagated across the network and adopted by other nodes following the _longest chain_ principle: when a given node receives a new chain, i.e. a chain extended with a new block, it adopts it as its own if and only if the new chain is longer than any other previously known chain.
21+
22+
Because of the distributed, decentralized and probabilistic nature of the protocol, it's perfectly possible that two or more chains coexist simultaneously across the network:
23+
24+
* More than one SPO can be elected to create a new block at approximately the same time,
25+
* Blocks take some time to reach all network nodes giving rise to the possibility of different nodes having different views of the best chain,
26+
* Nodes come and go,
27+
* Transactions included in blocks also need to travel across the network before reaching the SPO that will forge a block including them,
28+
* ...
29+
30+
This phenomenon is known as _forking_: a node's current best chain can be superseded by a new best chain which is very similar but for the last few blocks. Short (eg. a couple of blocks long) forks happen all the time, and they are usually non-problematic: rolled back blocks will be mostly identical, including the same transactions perhaps distributed differently among blocks, or with minor differences. But they can be harmful: if an end-user takes a decision, for example to ship some goods to another user, based on some transaction that's later rolled back and never appears again because it was actually invalid, double-spending some UTxO, this opens up the possibility of fraud.
31+
32+
Therefore, from the point of view of an end-user submitting to or depending on a specific transaction, the important question is: _When can they consider their transaction will never be rolled back_? In other words, when can they consider the transaction to be _settled_?
33+
34+
In the context of this work, settlement is henceforth defined from an _observability_ perspective:
35+
36+
> Settlement time is the duration after which a block (or transaction) added to node's best chain has a negligible probability of being rolled back because of a fork
37+
38+
## What's current settlement value?
39+
40+
It turns out giving a precise answer to this question is convoluted, and depends on various characteristics of the protocol, most notably the expected diffusion time (Δ) across the network, and assumptions about the fraction of _adversarial stake_. When reasoning about blockchain properties, the relative power between _honest_ nodes, i.e. the nodes that respect the protocol, and _adversarial_ nodes, i.e. the ones that can do whatever they want, is extremely important.
41+
42+
Ouroboros Praos has been [proven to be safe](https://iohk.io/en/research/library/papers/ouroboros-praos-an-adaptively-secure-semi-synchronous-proof-of-stake-protocol/) up to 50% adversarial stake: as long as the adversary does not control majority of the stake, it guarantees various key properties of the chain which we can summarize informally by saying all honest nodes will ultimately agree on the same, honest, chain. However, this robustness comes at a price which is the time nodes have to wait to consider a block (therefore a chain) _settled_.
43+
44+
In Cardano a node considers a block definitely _settled_, or _immutable_, once it is $k$ blocks behind the current tip of its best chain, where $k=2160$. Assuming average interblock arrival rate of 20 seconds, this means a block is settled after about 12 hours.
45+
46+
### How is $k$ determined?
47+
48+
The question of settlement time has been given a mathematically rigorous treatment in the paper [Practical Settlement Bounds for Longest-Chain consensus](https://iohk.io/en/research/library/papers/practical-settlement-bounds-for-longest-chain-consensus/), whose main findings can be summarized in the following picture.
49+
50+
![Fork probability for 10% adversarial stake](/img/settlement-failure-probability.png#scale50)
51+
52+
This graph reads as follows: assuming an adversarial stake of at most 10%, and a diffusion bound Δ of 5 seconds, the probability of a block being rolled back after a node has observed 20 blocks is 0.001%.
53+
54+
If Δ drops to 2s, e.g. if we consider the network to be faster and more reliable, then this probability also drops to 0.0001%.
55+
56+
On Cardano's mainnet, because of the much more stringent security requirements, we'll require a much lower failure rate of $2^60$. Assuming the adversary has at most 35% stake and huge _grinding power_, and network propagation delay $Δ=5s$, the same computation yields roughly the current value of $k$, i.e. a bit over 2000 blocks.
57+
58+
### What happens in practice?
59+
60+
In practice we know that _core nodes_, e.g.. block producing nodes or relays, seldom observe forks longer than 2 blocks. And most wallets, explorers, DApps, and other end-user facing systems provide feedback about transaction settlement under the name _number of confirmations_ which is exactly the same thing: the number of blocks past current best chain's tip of the block containing the transaction. A _number of confirmations_ higher than 10 is considered _high_.
61+
62+
However, it's quite possible an adversary is "lurking in the shadows", building a _private chain_ and awaiting the best time to take over the network and roll back transactions which would have normally be considered safe. This idea of private chains or "selfish mining" has been detailed in the classical paper [Majority is not enough](https://arxiv.org/abs/1311.0243), and it is critical to address this problem to ensure the security of any decentralised blockchain. This explains why we observe such a difference between the theoretical settlement bound provided by the protocol, and the practically observed one.
63+
64+
## How does Peras work?
65+
66+
Peras exists to bridge that gap and make settlement bounds closer to practical values, e.g. to dramatically decrease the probability of a fork even after only a few blocks.
67+
68+
The key idea of Peras is to use stake-based voting to _boost_ the weight of blocks on which a majority of SPOs agree. The chain selection rule is then modified to select the _heaviest_ chain instead of the _longest_ one.
69+
70+
### How does the protocol work?
71+
72+
From a high-level perspective, the protocol works as follows:
73+
74+
* At the beginning of each _round_, a randomly selected _committee_ of SPOs _vote_ for the block at a fixed depth from their current best chain tip, with each vote having a weight correlated to the SPO's stake,
75+
* Time is divided in fixed-length _rounds_ with a duration in the order of a few tens of slots,
76+
* The votes are broadcast to all nodes across the network,
77+
* If a node sees a _quorum_ of vote for the same block, it can issue a _certificate_ which _boosts_ the weight of this block,
78+
* Certificates are also diffused across the network on demand, to those nodes which don't have equivalent votes,
79+
* If a node does not receive a quorum for a round, either from votes or a certificate, it enters a _cooldown_ period during which any vote or certificate are _ignored_,
80+
* A node exits cooldown after a fixed number of rounds, and starts voting again.
81+
* When it enters cooldown, a block producer also appends the latest certificate to the block it forges.
82+
83+
### What are the benefits?
84+
85+
The exact effect of Peras depends on the values of various protocol parameters which are detailed in the [Technical Report](/docs/reports/tech-report-2). Based on the [recommendations](/docs/reports/tech-report-2#recommendations-for-peras-parameters) provided in the report
86+
87+
> anyone seeing a transaction appearing in a block need wait no more
88+
> than two minutes to be certain whether the transaction is on the
89+
> preferred chain (effectively permanently, less than a one in a
90+
> trillion probability even at 45% adversarial stake) versus having
91+
> been discarded because of a roll back
92+
93+
Importantly, Peras does not change the underlying security guarantees of Ouroboros Praos, and reverts to it in the event of a cooldown. Moreover, it adapts to fluctuating participation of SPOs and can recover from temporary "failures", e.g. if an adversary manages to temporarily reach a _quorum_, they only will be able to takeover the chain if they manage to maintain that superiority over time, otherwise the honest parties will take over.
94+
95+
## Where to go from here?
96+
97+
A lot more details about Peras protocol can be found in various places:
98+
99+
* For detailed analysis of the protocol, please refer to [Technical Report #2](/docs/reports/tech-report-2)
100+
* For a formal description, refer to the [Agda Specification](pathname:///agda_html/Peras.SmallStep.html)
101+
* Conformance tests are available in the [Peras repository](https://github.com/input-output-hk/peras-design)
102+
* A live simulation of the protocol is available https://peras-simulation.cardano-scaling.org
103+
104+
105+
<!-- Localwords: Peras Ouroboros Praos Nakamoto SPO observability
106+
-->

site/docs/reports/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
sidebar_label: 'Reports'
3+
sidebar_position: 2
4+
---
5+
6+
# Reports
7+
8+
This page groups "reports" on the project's results.
9+
10+
For convenience we provide PDF versions of technical reports:
11+
12+
* [Technical report #1](/tech-report-1.pdf)
13+
* [Technical report #2](/tech-report-2.pdf)

0 commit comments

Comments
 (0)