You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/website/contents/for-developers/Ticking.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ The ledger state that resulted from some block thus needs to be ticked across so
10
10
Some crucial things can happen when ticking between blocks: deadlines come and go, epochs end and begin, protocol parameters change, or even the ledger rules themselves might change.
11
11
12
12
However, applying blocks is not the only reason the Consensus Layer ticks.
13
-
If it were, then ticking wouldn't need to be separately identified: it'd just be the first of however many "hidden" steps involved in applying a block.
13
+
If it were, then ticking wouldn't need to be separately identified: it'd just be the first of however many "hidden" steps are involved in applying a block.
14
14
Instead, ticking is used in a few places, some of which don't involve immediately subsequent header/block application.
15
15
16
16
- Ticking advances protocol state between headers.
@@ -33,10 +33,9 @@ In Cardano, the only thing we ever need to forecast is the part of the ledger st
33
33
This can be fully determined regardless of intervening blocks because the ledger rules ensure the relevant parts of the ledger state do not change without a minimum duration of forewarning (eg by retaining occasional snapshots of this data).
34
34
That minimum duration of stability is therefore _the forecast range_, beyond which the code cannot necessarily do correct forecasting.
35
35
36
-
Thus forecasting from an (unticked) ledger state in slot X to slot Y -- within the forecast range --- must be equivalent to ticking from X to Y and then "forecasting" from X to Y.
36
+
Thus forecasting from an (unticked) ledger state in slot X to slot Y -- within the forecast range --- must be equivalent to ticking from X to Y and then "forecasting" from Y to Y.
37
37
That'd be visualized as a square commuting diagram.
38
-
Note that ticking from X to Y is usually only sound if there's no blocks in that slot interval.
39
-
But the part of the ledger that we forecast is stable, and so cannot be affected by those blocks, and so the ticking is sound in the specific context of constraining forecasting.
38
+
Note that ticking from X to Y is usually only sound if there's no blocks in that slot interval, but the part of the ledger that we forecast is stable, and so cannot be affected by those blocks, and so the ticking is sound in the specific context of characterizing forecasting.
40
39
41
40
## `Ticked` data family
42
41
@@ -49,7 +48,7 @@ By encoding this alternation between ticking and application in the types of the
49
48
50
49
In our code base, ticking is a total function.
51
50
Forecasting, on the other hand, is partial, since it is able to reject requests that violate the forecast range.
52
-
(It's important to node that such a request is not doomed: the node might need to process another block or two before the slot of interest will be within the forecast range of its selected chain's tip.)
51
+
(It's important to note that such a request is not doomed: the node might just need to process another block or two before the slot of interest will be within the forecast range of its selected chain's tip.)
53
52
54
53
However, the Consensus Layer itself will never need to tick farther than the forecast range.
55
54
The ledger rules might actually be able to do so, since it's mostly just a matter of the state _not_ changing.
@@ -63,9 +62,9 @@ The inductive argument is that all the ticking the Consensus Layer does is ultim
63
62
The mint only proceeds if the leadership succeeded.
64
63
- The ChainSync client forecasts the `LedgerView` before it applies any header.
65
64
- The ChainSel logic only applies blocks whose headers arrived via a ChainSync client or were minted by this node.
66
-
The node also processes blocks from its on-disk storage when initializing, but those blocks were either minted by this node, acquired by this node via ChainSync, written by another trusted node (eg via Mithril) between executions, or written by some other means that is not explicitly unsupported.
65
+
The node also processes blocks from its on-disk storage when initializing, but those blocks were either minted by this node, acquired by this node via ChainSync (and BlockFetch), written by another trusted node (eg via Mithril) between executions, or written by some other means that is not explicitly unsupported.
67
66
68
-
Thus, it's reasonable for the ticking function to have a total type because none of its calls within the node can fail; it's always guarded a forecast.
67
+
Thus, it's reasonable for the ticking function to have a total type because none of its calls within the node can fail; it's always guarded by a forecast.
69
68
70
69
## Cross-Era Ticking
71
70
@@ -82,10 +81,10 @@ We could introduce a similar interface for ticking across eras.
82
81
The implementation, which is lower-level than the `Ticked`-based interface, could use the less surprising tick-translate-tick scheme.
83
82
84
83
Moreover, that cross-era ticking would still be guarded by cross-era forecasting, and so it would be bounded by the cross-era forecast range (which is not necessarily equivalent to either era's internal forecast range).
85
-
In particular, the cross-era forecast range cannot cross multiple era boundaries, which is justified due and other assumptions about how much warning there is ahead of an era transition.
84
+
In particular, the cross-era forecast range cannot cross multiple era boundaries, which is justified by lower bounds on how much warning there is within an era ahead of the next era transition.
86
85
Thus the HFC only requires a cross-era ticking function from each era to the next, rather than to even later eras.
87
86
88
-
## Bounding Ticking/Forecasting Computations
87
+
## Bounding Ticking and Forecasting Computations
89
88
90
89
On a single valid chain, the Consensus Layer will never tick across the same slots multiple times.
91
90
However, Ouroboros involves short forks and potentially invalid blocks.
@@ -94,6 +93,6 @@ On the other hand, even for a single chain, the Consensus Layer would forecast a
94
93
Ideally all ticks would be inexpensive, but the occasional spike is managable, since short forks are short lived.
95
94
An expensive forecast, on the other hand, can be disastrous.
96
95
If the leadership check's forecast takes too long, then the node might be late to produce its block.
97
-
If that forecast takes longer than a slot, then the node might not check every slot, which is unacceptable.
96
+
If that forecast takes longer than a slot, then the node might not even check every slot, which is unacceptable.
98
97
99
-
For these reasons, there the ledger rules contain certain optimizations that either prevent forecasts from ever paying certain costs or else ensure that forecasting across some particular slot is only expensive the first time it happens and subsequent forecasts will then avoid those costs via memoization.
98
+
For these reasons, the ledger rules contain certain optimizations that either prevent forecasts from ever paying certain costs or else ensure that forecasting across some particular slot is only expensive the first time it happens and subsequent forecasts will then avoid those costs via memoization.
0 commit comments