Commit b34c360
authored
fix: fee related overflows (#20362)
There were a couple of potential issues with fee related overflows.
- The prover cost was stored in 63 bits but it is possible to overflow
that in multiple cases:
- The prover cost per mana could be up to 64 bits, so as long as aztec <
ether it can overflow for any sufficiently large prover cost per mana
defined by governance
- The L1 costs could be very high which together with token price and
the raw proving cost moves it beyond the limit
- The congestion cost likewise get impacted by the L1 costs and prover
costs, but also the congestion multiplier of.
- Given sufficiently high excess mana, it is possible for the congestion
multiplier computation to overflow.
- Given sufficiently high excess mana, it is possible for the next
header to overflow when trying to compress it.
To encounter any of these, the values must be absurd, e.g., we are
talking multiple thousands if not millions of gwei in gasprices on L1,
thousands of x of congestion multiplier and large small aztec token
prices.
However, as they are fairly simple to mitigate we will be doing so.
Mitigation for the congestion multiplier is especially important, since
overflows in there could be impossible to leave again as they "lag" and
only depends on the excess.
---
Mitigations:
- For the fee header we apply to the values that does not depend on the
current values only, e.g., `excessMana`, `congestionCost` and
`proverCost`
- When computing the summed fee we make a bound at uint128
- When computing the congestion multiplier we allow at most 100x the
denominator to keep it safe, but still insanely high.
The issues were pointed by spearbit, but as diving in found issues
around the max value `summedMinFee` being potentially larger then
`uint128` which would make it impossible to provide a matching header,
thereby causing infinite reverts. Similar for the `excessMana` as it
only depends on historical values could end up always reverting if
overflowing.
Hitting any of those cases is completely unrealistic (fee would be
e^100). But better safe than sorry on this, as it could happen and that
case would be a real pain.File tree
3 files changed
+422
-8
lines changed- l1-contracts
- src/core/libraries
- compressed-data/fees
- rollup
- test/fees
3 files changed
+422
-8
lines changedLines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | | - | |
| 106 | + | |
| 107 | + | |
106 | 108 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
312 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
313 | 317 | | |
314 | 318 | | |
315 | 319 | | |
| |||
342 | 346 | | |
343 | 347 | | |
344 | 348 | | |
345 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
346 | 353 | | |
347 | 354 | | |
348 | 355 | | |
| |||
0 commit comments