EC Finality Calculator (FRC-0089) #919
Replies: 6 comments 7 replies
-
it would be beneficial to link filecoins EC specs in the first line |
Beta Was this translation helpful? Give feedback.
-
Please attach the google doc as a PDF or in the markdown so that if we ever lose it, its content survives! |
Beta Was this translation helpful? Give feedback.
-
Selected Q&A from Slack |
Beta Was this translation helpful? Give feedback.
-
FRC PR created: #941 |
Beta Was this translation helpful? Give feedback.
-
We also gave a brief presentation at Core Devs 66. Recording here. |
Beta Was this translation helpful? Give feedback.
-
Links in the Evaluation section seem to return 404? |
Beta Was this translation helpful? Give feedback.
-
A Finality Calculator for Expected Consensus
FRC: https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0089.md
authors: @guy-goren, @jsoares
Summary
Filecoin's Expected Consensus (EC) comes with probabilistic finality and a 900-epoch soft finality threshold, intended to achieve a finality guarantee (tipset replacement probability) of$2^{-30}$ . While network participants (e.g. exchanges, L2 operators, application developers) use different confirmation thresholds, they pessimistically wait between 100-900 epochs before considering a transaction final, leading to delays in the order of hours.
Instead of naively counting the number of epochs, we propose a finality calculator that considers what takes place during those epochs and, under expected operating conditions, can attain the same level of certainty in fewer epochs. For example, consider two cases: in case A, the chain grew by 5 blocks per epoch over the last 50 epochs; in case B, the chain grew by a mere 2 blocks per epoch over the same 50 epochs. The probability of a chain reconfiguration longer than 50 epochs is much smaller in case A than in case B, allowing us to make an earlier finality determination.
We embark on an analysis of Filecoin's finality, i.e., the probabilistic guarantees that a given tipset will always be in the canonical chain. The analysis involves distributed computing and stochastic arguments and provides upper bounds for the error probabilities, i.e., the probability that a reorg would override a given tipset. We show that, in real operating conditions, the same error probability$2^{-30}$ can be achieved in ~30 epochs (15 minutes) -- a 30x improvement.
This algorithm is practical, only requires access to a node's local view, and can be implemented by clients or off-chain applications without requiring any changes to the protocol. We plan to propose an FRC outlining the recommended procedure for finality calculation.
Motivation
This proposal has two main goals:
Users and applications (e.g. exchanges, IPC subnets) that choose to implement these recommendations won't need to wait a fixed period of up to 900 epochs; they can benefit from faster finalization times and increased visibility into the security guarantees they are receiving.
F3 will also address these points (with even faster finality). This work does not conflict with F3 and independently provides several benefits:
Notably, (1) implies that our proposal can be an interim solution for Filecoin until F3 goes live on the network.
Proposal
Our analysis draws inspiration from techniques developed in an AFT’22 paper combined with techniques from an ICDCS’20 paper and applying them to the observed chain history of Filecoin (when possible). In summary, we consider an observed addition of$k$ blocks on top of the target tipset produced at epoch $s$ . We then look at:
We then use the data from the three stages to determine the probability that the adversary will overtake the observed chain. The analysis detailing how we bound the finality of a given input can be found here. We aim to provide a more digestible version soon.
A Python prototype is available here. This implementation tries to translate the specification with minimal changes rather than optimize for performance. As an application-side optimization with no interoperability requirement, implementers in different clients and languages may freely diverge from the prototype.
Evaluation
We have run our algorithm on past chain data from the Filecoin mainnet. The periods analyzed are heights 3,349,680 to 3,433,200, a typical healthy state, and heights 2,684,400 to 2,773,680, at the tail end of which there is a particularly unhealthy period. The figures below show the results of quantifying the finality of tipsets after a 30-epoch delay. The potential adversarial power we considered is 30%. We note that one may choose other questions to analyze, such as when a specific tipset reaches a given finality threshold.
The figure below shows the results of applying the analysis to a typical healthy chain period, when tipsets are almost full (5 blocks) on average. On the$x$ -axis we have the epoch numbers. We have a double $y$ -axis: on the right axis, we have the number of blocks in tipsets (plotted in green, as well as the moving average), and on the left axis we have the error probabilities after 30 epochs (plotted in blue). It is mostly below $10^{-10}$ , implying that a reorg of this tipset is, at most, a once in 10,000 years event. It is clear how a higher number of blocks per epoch typically results in better finality measurement (smaller error probability).
The figure below shows the results of applying the analysis on a period when the Filecoin blockchain was less healthy (around the end of March 2023). Starting around epoch 2,750,000, tipsets show, on average, fewer blocks than expected --- often falling to below 4 blocks per tipset when averaged over 30 epochs. As expected, the finality measurement is worse than in the typical "good case"; that is, the error probabilities are higher by several orders of magnitude at times.
Security
Beta Was this translation helpful? Give feedback.
All reactions