or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Important
Decisions needed:
.lagda.md
file.src/
files into a single filesrc/
folder within the CIP's folder.src/
can be copied over into the CIP, after a little clean-upsrc/
into the CIPperas-design
Note
A "Consensus" category must be created by a new CIP before this CIP can be submitted within that category.
Existing categories:
Abstract
We propose Peras, an enhancement to the Ouroboros Praos protocol that introduces a voting layer for optimistic fast settlement.
Peras, or more precisely Ouroboros Peras, is an extension of Ouroboros Praos 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.
Motivation: why is this CIP necessary?
Define clearly what settlement is (and how it differs from finality)
Explain settlement on Cardano with Ouroboros Praos
Explain the required changes to Praos maybe in terms of current limitations of Praos
Distinguish from orthogonal protocol upgrades such as Genesis, Leios, etc.
Worst-case vs. optimistic case
Specification
Non-normative overview of the Peras protocol
The following informal, non-normative, pseudo-imperative summary of the Peras protocol is provided as an index into the formal Agda specification. Peras relies on a few key concepts:
Important
If we retain this subsection, provide links from it to the corresponding parts of the Agda specification later in this document.
The text needs review by the research team because it risks self-plagarizing.
The protocol keeps track of the following variables, initialized to the values below:
A fetching operation occurs at the beginning of each slot:
Block creation occurs whenever party \(\mathsf{P}\) is slot leader in a slot \(s\), belonging to some round \(r\):
During voting, each party \(\mathsf{P}\) does the following at the beginning of each voting round \(r\):
Normative protocol specification in Agda
The following relational specification for Peras uses Agda 2.6.4.1 and the Agda Standard Library 2.0. The repository github:input-output-hk/peras-design provides a Nix-based environment for compiling and executing Peras's specification.
Important
Brian would like to signifcantly expand the explanatory text in this section and import the definitions for
Block
etc. However, we first need to figure out how to sync theperas-design
repo with this document.––- START OF PASTED TEXT ––-
The small-step semantics of the Ouroboros Peras protocol define the
evolution of the global state of the system modelling honest and adversarial
parties. The number of parties is fixed during the execution of the protocol and
the list of parties has to be provided as a module parameter. In addition the
model is parameterized by the lotteries (for slot leadership and voting
committee membership) as well as the type of the block tree. Furthermore
adversarial parties share generic, adversarial state.
References:
Parameters
The parameters for the Peras protocol and hash functions are defined as
instance arguments of the module.
The block tree, resp. the validity of the chain is defined with respect of the
parameters.
Messages
Messages for sending and receiving chains and votes. Note, in the Peras protocol
certificates are not diffused explicitly.
Block-tree
A block-tree is defined by properties - an implementation of the block-tree
has to fulfil all the properties mentioned below:
Properties that must hold with respect to chains, certificates and votes.
In addition to chains the block-tree manages votes and certificates as well.
The block-tree type is defined as follows:
Additional parameters
In order to define the semantics the following parameters are required
additionally:
Block-tree update
Updating the block-tree upon receiving a message for vote and block messages.
Vote in round
When does a party vote in a round? The protocol expects regular voting, i.e. if
in the previous round a quorum has been achieved or that voting resumes after a
cool-down phase.
BlockSelection
Voting rules
VR-1A: A party has seen a certificate cert-r−1 for round r−1
VR-1B: The extends the block certified by cert-r−1,
VR-1: Both VR-1A and VR-1B hold
VR-2A: The last certificate a party has seen is from a round at least R rounds back
VR-2B: The last certificate included in a party's current chain is from a round exactly
c⋆K rounds ago for some c : ℕ, c ≥ 0
VR-2: Both VR-2A and VR-2B hold
If either VR-1A and VR-1B or VR-2A and VR-2B hold, voting is expected
State
The small-step semantics rely on a global state, which consists of the following fields:
Progress
Rather than keeping track of progress, we introduce a predicate stating that all
messages that are not delayed have been delivered. This is a precondition that
must hold before transitioning to the next slot.
Predicate for a global state stating that the current slot is the last slot of
a voting round.
Predicate for a global state stating that the next slot will be in a new voting
round.
Predicate for a global state asserting that parties of the voting committee for
a the current voting round have voted. This is needed as a condition when
transitioning from one voting round to another.
TODO: Properly define the condition for required votes
Ticking the global clock increments the slot number and decrements the delay of
all the messages in the message buffer.
Updating the global state inserting the updated block-tree for a given party,
adding messages to the message buffer for the other parties and appending the
history
Fetching
A party receives messages from the global state by fetching messages assigned to
the party, updating the local block tree and putting the local state back into
the global state.
An honest party consumes a message from the global message buffer and updates
the local state
An adversarial party might delay a message
Voting
Helper function for creating a vote
A party can vote for a block, if
Voting updates the party's local state and for all other parties a message
is added to be consumed immediately.
Rather than creating a delayed vote, an adversary can honestly create it and
delay the message.
Block creation
Certificates are conditionally added to a block. The following function determines
if there needs to be a certificate provided for a given voting round and a local
block-tree. The conditions are as follows
a) There is no certificate from 2 rounds ago in certs
b) The last seen certificate is not expired
c) The last seen certificate is from a later round than
the last certificate on chain
Helper function for creating a block
A party can create a new block by adding it to the local block tree and
diffuse the block creation messages to the other parties. Block creation is
possible, if as in Praos
Block creation updates the party's local state and for all other parties a
message is added to the message buffer
Small-step semantics
The small-step semantics describe the evolution of the global state.
The relation allows
Note, when transitioning to the next slot we need to distinguish whether the
next slot is in the same or a new voting round. This is necessary in order to
detect adversarial behaviour with respect to voting (adversarialy not voting
in a voting round)
Reflexive, transitive closure
List-like structure for defining execution paths.
Transitions of voting rounds
Transitioning of voting rounds can be described with respect of the small-step
semantics.
Reflexive, transitive closure
List-like structure for executions for voting round transitions
Important
––- END OF PASTED TEXT ––-
Specification of votes
Overview
Voting in Peras is mimicked after the sortition algorithm used in Praos, e.g it is based on the use of a Verifiable Random Function (VRF) by each stake-pool operator guaranteeing the following properties:
Additionally we would like the following property to be provided by our voting scheme:
We have experimented with two different algorithms for voting, which we detail below.
Structure of votes
We have used an identical structure for single
Vote
s, for both algorithms. We define this structure as a CDDL grammar, inspired by the block header definition from cardano-ledger:This definition relies on the following primitive types (drawn from Ledger definitions in crypto.cddl)
As already mentioned,
Vote
mimicks the block header's structure which allows Cardano nodes to reuse their existing VRF and KES keys. Some additional notes:hash
function exclusively uses 32-bytes Blake2b-256 hashes,voter_id
is it's pool identifier, ie. the hash of the node's cold key.Casting a vote
A vote is cast by a node using the following process which paraphrases the actual code
peras
string and the round number voted for encoded as 64-bits big endian value,nonce
,Verifying a vote
Vote verification requires access to the current epoch's stake distribution and stake pool registration information.
voter_id
in the stake distribution and registration map to retrieve their current stake and VRF verification key,Approaches to voter election
Important
These subsections are about implementation more than about specification. Should we rewrite this purely as a specification? We could link to the two implementations.
Leader-election like voting
The first algorithm is basically identical to the one used for Mithril signatures, and is also the one envisioned for Leios (see Appendix D of the recent Leios paper). It is based on the following principles:
We prototyped this approach in Haskell.
Sortition-like voting
The second algorithm is based on the sortition process initially invented by Algorand and implemented in their node. It is based on the same idea, namely that a node should have a number of votes proportional to their fraction of total stake, given a target "committee size" expressed as a fraction of total stake \(p\). And it uses the fact the number of votes a single node should get based on these parameters follows a binomial distribution.
The process for voting is thus:
This yields a vote with some weight attached to it "randomly" computed so that the overall sum of weights should be around expected committee size.
This method has also been prototyped in Haskell.
Specification of certificates
Caution
We need to commit solely to ALBA or to Mirthril, and edit this section accordingly.
Mithril certificates
Mithril certificates' construction is described in details in the Mithril paper and is implemented in the mithril network. It's also described in the Leios paper, in the appendix, as a potential voting scheme for Leios, and implicitly Peras.
Mithril certificates have the following features:
ALBA
Approximate Lower Bound Arguments or ALBAs in short, are a novel cryptographic algorithm based on a telescope construction providing a fast way to build compact certificates out of a large number of unique items. A lot more details are provided in the paper, on the website and the GitHub repository where implementation is being developed, we only provide here some key information relevant to the use of ALBAs in Peras.
Proving & verification time
ALBA's expected proving time is benchmarked in the following picture which shows mean execution time for generating a proof depending on: The total number of votes, the actual number of votes (\(s_p\)), the honest ratio (\(n_p\)). Note that as proving time increases exponentially when \(s_p \rightarrow total \cdot n_p\), we only show here the situation when \(s_p = total\) and \(s_p = total - total \cdot n_p / 2\) to ensure graph stays legible.

The following diagram is an excerpt from the ALBA benchmarks highlighting verification. Note these numbers do not take into account the time for verifying individual votes. As one can observe directly from these graphs, verification time is independent from the number of items and only depends on the \(n_p/n_f\) ratio.

In practice, as the number of votes is expected to be in the 1000-2000 range, and there is ample time in a round to guarantee those votes are properly delivered to all potential voting nodes (see below), we can safely assume proving time of about 5 ms, and verification time under a millisecond.
Certificate size
For a given set of parameters, namely fixed values for \(\lambda_{sec}\), \(\lambda_{rel}\), and \(n_p/n_f\), the proof size is perfectly linear and only depends on the size of each vote.
Varying the security parameter and the honest votes ratio for a fixed set of 1000 votes of size 200 yields the following diagram, showing the critical factor in proof size increase is the \(n_p/n_f\) ratio: As this ratio decreases, the number of votes to include in proof grows superlinearly.
Benchmarks
Warning
The benchmarking data should be moved to the Resources section.
In the following tables we compare some relevant metrics between the two different kind of certificates we studied, Mithril certificates (using BLS signatures) and ALBA certificates (using KES signatures): Size of certificate in bytes, proving time (e.g., the time to construct a single vote), aggregation time (the time to build a certificate), and verification time.
For Mithril certificates, assuming parameters similar to mainnet's (\(k=2422, m=20973, f=0.2\)):
For ALBA certificates, assuming 1000 votes, a honest to faulty ratio of 80/20, and security parameter \(λ=128\). Note the proving time does not take into account individual vote verification time, whereas certificate's verification time includes votes verification time.
Network diffusion of votes
Building on previous work, we built a ΔQ model to evaluate the expected delay to reach quorum.
The model works as follows:
NToFinish 75
combinator to this distribution to compute the expected distribution to reach 75% of the votes (quorum).Using the "old" version of ΔQ library based on numerical (e.g., Monte-Carlo) sampling, yields the following graph:

This graph tends to demonstrate vote diffusion should be non-problematic, with a quorum expected to be reached in under 1 second most of the time to compare with a round length of about 2 minutes.
At the time of this writing, a newer version of the ΔQ library based on piecewise polynomials is available. Our attempts to use it to model votes diffusion were blocked by the high computational cost of this approach and the time it takes to compute a model, specifically about 10 minutes in our case. The code for this experiment is available as a draft PR #166.
In the old version of ΔQ based on numerical sampling, which have vendored in our codebase, we introduced a
NToFinish
combinator to model the fact we only take into account some fraction of the underlying model. In our case, we model the case where we only care about the first 75% of votes that reach a node.Given convolutions are the most computationally intensive part of a ΔQ model, it seems to us a modeling approach based on discrete sampling and vector/matrices operations would be quite efficient. We did some experiment in that direction, assessing various approaches in Haskell: A naive direct computation using Vectors, FFT-based convolution using vectors, and hmatrix' convolution function.
This quick-and-dirty spike lead us to believe we could provide a fast and accurate ΔQ modelling library using native vector operations provided by all modern architectures, and even scale to very large model using GPU libraries.
Rationale: how does this CIP achieve its goals?
We have refined our analysis and understanding of Peras protocol, taking into account its latest evolution:
Peras provides demonstrably fast settlement without weakening security or burdening nodes. The settlement time varies as a function of the protocol-parameter settings and the prevalence of adversarial stake. For a use case that emphasizes rapid determination of whether a block is effectively finally incorporated into the preferred chain, it is possible to achieve settlement times as short as two minutes, but at the expense of having to resubmit rolled-back transactions in cases where there is a strong adversarial stake.
The impact of Peras upon nodes falls into four categories: network, CPU, memory, and storage. We have provided evidence that the CPU time required to construct and verify votes and certificates is much smaller than the duration of a voting round. Similarly, the memory needed to cache votes and certificates and the disk space needed to persist certificates is trivial compared to the memory needed for the UTXO set and the disk needed for the blocks.
On the networking side, our ΔQ studies demonstrate that diffusion of Peras votes and certificates consumes minimal bandwidth and would not interfere with other node operations such as memory-pool and block diffusion. However, diffusion of votes and certificates across a network will still have a noticeable impact on the volume of data transfer, in the order of 20%, which might translate to increased operating costs for nodes deployed in cloud providers.
In terms of development impacts and resources, Peras requires only a minimal modification to the ledger CDDL and block header. Around cool-down periods, a certificate hash will need to be included in the block header and the certificate itself in the block. Implementing Peras does not require any new cryptographic keys, as the existing VRF/KES will be leveraged. It will require an implementation of the ALBA algorithm for creating certificates. It does require a new mini-protocol for diffusion of votes and certificates. The node's logic for computing the chain weight needs to be modified to account for the boosts provided by certificates. Nodes will have to persist all certificates and will have to cache unexpired votes. They will need a thread (or equivalent) for verifying votes and certificates. Peras only interacts with Genesis and Leios in the chain-selection function and it is compatible with the historical evolution of the blockchain. A node-level specification and conformance test will also need to be written.
In no way does Peras weaken any of the security guarantees provided by Praos or Genesis. Under strongly adversarial conditions, where an adversary can trigger a Peras voting cool-down period, the protocol in essence reverts to the Praos (or Genesis) protocol, but for a duration somewhat longer than the Praos security parameter. Otherwise, settlement occurs after each Peras round. This document has approximately mapped the trade-off between having a short duration for each round (and hence faster settlement) versus having a high resistance to an adversary forcing the protocol into a cool-down period. It also estimates the tradeoff between giving chains a larger boost for each certificate (and hence stronger anchoring of that chain) versus keeping the cool-down period shorter.
Use Cases
Main benefit is that Peras drastically decreases the need to wait for confirmation for transactions, from minutes/hours to seconds/minutes
Attacks and Mitigations
Resource Requirements
In this section, we evaluate the impact on the day-to-day operations of the Cardano network and cardano nodes of the deployment of Peras protocol, based on the data gathered over the course of project.
In this section, we evaluate the impact on the day-to-day operations of the Cardano network and cardano nodes of the deployment of Peras protocol, based on the data gathered over the course of project.
Network
Network traffic
For a fully synced nodes, the impact of Peras on network traffic is modest:
A non fully synced nodes will have to catch-up with the tip of the chain and therefore download all relevant blocks and certificates. At 50% load (current monthly load is 34% as of this writing), the chain produces a 45 kB block every 20 s on average. Here are back-of-the-napkin estimates of the amount of data a node would have to download (and store) for synchronizing, depending on how long it has been offline:
Network costs
We did some research on network pricing for a few major Cloud and well-known VPS providers, based on the share of stakes each provider is reported to support, and some typical traffic pattern as exemplified by the following picture (courtesy of Markus Gufler).
The next table compares the cost (in US$/month) for different outgoing data transfer volumes expressed as bytes/seconds, on similar VMs tailored to cardano-node's hardware requirements (32GB RAM, 4+ Cores, 500GB+ SSD disk). The base cost of the VM is added to the network cost to yield total costs depending on transfer rate.
Note
For an AWS hosted SPO, which represent about 20% of the SPOs, a 14 kB/s increase in traffic would lead to a cost increase of $3.8/mo (34 GB times $0.11/GB). This represents an average across the whole network: depending on the source of the vote and its diffusion pattern, some nodes might need to send a vote to more than one downstream peer which will increase their traffic, while other nodes might end up not needing to send a single vote to their own peers. Any single node in the network is expected to download each vote at most once.
Persistent storage
Under similar assumptions, we can estimate the storage requirements entailed by Peras: Ignoring the impact of cooldown periods, which last for a period at least as long as \(k\) blocks, the requirement to store certificates for every round increases node's storage by about 20%.
Votes are expected to be kept in memory so their impact on storage will be null.
CPU
In the Votes & Certificates section we've provided some models and benchmarks for votes generation, votes verification, certificates proving and certificates verification, and votes diffusion. Those benchmarks are based on efficient sortition-based voting and ALBAs certificate, and demonstrate the impact of Peras on computational resources for a node will be minimal. Moreover, the most recent version of the algorithm detailed in this report is designed in such a way the voting process runs in parallel with block production and diffusion and therefore is not on this critical path.
Voting:
The implementation takes some liberty with the necessary rigor suitable for cryptographic code, but the timings provided should be consistent with real-world production grade code. In particular, when using nonce as a random value, we only use the low order 64 bits of the nonce, not the full 256 bits.
Memory
A node is expected to need to keep in memory:
Peras should not have any significant impact on the memory requirements of a node.
Path to Active
Acceptance Criteria
Implementation Plan
Integration into Cardano Node
In the previous report, we already studied how Peras could be concretely implemented in a Cardano node. Most of the comments there are still valid, and we only provide here corrections and additions when needed. We have addressed resources-related issue in a previous section.
The following picture summarizes a possible architecture for Peras highlighting its interactions with other components of the system.
The main impacts identified so far are:
Defining Protocol Parameters values
In order to provide useful recommendations for the protocol parameters, we first need to understand what is their admissible range of values, e.g. the constraints stemming from practical and theoretical needs, and to analyse their impact on the settlement probabilities.
Constraints on Peras Parameters
The following constraints on Peras parameters arise for both theoretical and practical considerations.
Settlement probabilities
In the estimates below, we define the non-settlement probability as the probability that a transaction (or block) is rolled back. Note that this does not preclude the possibility that the transaction could be included in a later block because it remained in the memory pool of a node that produced a subsequent block. Because there are approximately 1.5 million blocks produced per year, even small probabilities of non-settlement can amount to an appreciable number of discarded blocks.
Case 1: Blocks without boosted descendants
Blocks that are not cemented by a boost to one of their descendant (successor) blocks are most at risk for being rolled back because they are not secured by the extra weight provided by a boost.
The Variant 2 scenario in the Adversarial chain receives boost section above dominates the situation where a transaction is recorded in a block but an adversarial fork later is boosted by a certificate to become the preferred chain. This scenario plays out as follows:
Note that this is different from the situation where a transaction is included on honest forks because such a transaction typically reaches the memory pool of the block producers on each fork and is included on each. The adversary refrains from including the transaction on their private chain.
The active-slot coefficient (assumed to be 5%), the length of the rounds, and the adversary's fraction of stake determine the probability of non-settlement in such a scenario. The table below estimates this probability. For example, in the presence of a 5% adversary and a round length of 360 slots, one could expect about two blocks to be reverted per year in such an attack.
Using the approach of Gaži, Ren, and Russell (2023) and setting \(\Delta = 5 \text{\,slots}\) to compute the upper bound on the probability of failure to settle results in similar, but not identical probabilities.
Case 2: Blocks with boosted descendants
Once one of a block's descendants (successors) has been boosted by a certificate, it is much more difficult for an adversary to cause it to be rolled back because they adversary must overcome both count of blocks on the preferred, honest chain and the boost that chain has already received.
The Healing from adversarial boost section above provides the machinery for estimating the probability of an adversary building a private fork that has more weight than a preferred, honest chain that has been boosted. The scenario plays out as follows:
Typically, the adversary would only have a round's length of slots to build sufficient blocks to overcome the boosted, honest, preferred fork. After that, the preferred fork would typically receive another boost, making it even more difficult for the adversary to overcome it. The table below shows the probability that of non-settlement for a block after the common prefix but not after the subsequent boosted block on the honest chain, given a 5% active slot coefficient and a 5 blocks/certificate boost.
A boost of 10 blocks/certificate makes the successful adversarial behavior even less likely.
A boost of 15 blocks/certificate makes the successful adversarial behavior even less likely.
Recommendations for Peras parameters
Based on the analysis of adversarial scenarios, a reasonable set of default protocol parameters for further study and simulation is show in the table below. The optimal values for a real-life blockchain would depend strongly upon external requirements such as balancing settlement time against resisting adversarial behavior at high values of adversarial stake. This set of parameters is focused on the use case of knowing soon whether a block is settled or rolled back; other sets of parameters would be optimal for use cases that reduce the probability of roll-back at the expense of waiting longer for settlement.
A block-selection offset of \(L = 30 \text{\,slots}\) allows plenty of time for blocks to diffuse to voters before a vote occurs. Combining this with a round length of \(U = 90 \text{\, slots}\) ensures that there is certainty in \(U + L = 120 \text{\,slots}\) as to whether a block has been cemented onto the preferred chain by the presence of a certificate for a subsequent block. That certainty of not rolling back certified blocks is provided by a certification boost of \(B = 15 \text{\,blocks}\) because of the infinitesimal probability of forging that many blocks on a non-preferred fork within the time \(U\). Thus, anyone seeing a transaction appearing in a block need wait no more than two minutes to be certain whether the transaction is on the preferred chain (effectively permanently, less than a one in a trillion probability even at 45% adversarial stake) versus having been discarded because of a roll back. Unless the transaction has a stringent time-to-live (TTL) constraint, it can be resubmitted in the first \(U - L = 60 \text{\,slots}\) of the current round, or in a subsequent round.
Warning
The security-related computations in the next paragraph are not rigorous with respect to the healing, chain-quality, and common-prefix times, so they need correction after the research team reviews them and proposes a better approach.
The Praos security parameter \(k_\text{praos} = 2160 \text{\,blocks} \approx 43200 \text{\,slots} = 12 \text{\,hours}\) implies a ~17% probability of a longer private adversarial chain at 49% adversarial stake. At that same probability, having to overcome a \(B = 15 \text{\,blocks}\) adversarial boost would require \(k_\text{peras} \approx 70200 \text{\,slots} = 3510 \text{\,blocks} = 19.5 \text{\,hours}\). This determines the certificate-expiration time as \(A = k_\text{peras} - k_\text{praos} = 27000 \text{\,slots}\), the chain-ignorance period as \(R = \left\lceil A / U \right\rceil = 300 \text{\,rounds}\), and the cool-down period as \(K = \left\lceil k_\text{peras} / U \right\rceil = 780 \text{\,rounds}\).
The committee size of \(n = 900 \text{\,parties}\) corresponds to a one in a million chance of not reaching a quorum if 10% of the parties do not vote for the majority block (either because they are adversarial, offline, didn't receive the block, or chose to vote for a block on a non-preferred fork). This "no quorum" probability is equivalent to one missed quorum in every 1.2 years. The quorum size of \(\tau = \left\lceil 3 n / 4 \right\rceil = 675 \text{\,parties}\) is computed from this.
Copyright
This CIP is licensed under Apache-2.0.