Commit 0c1c998
authored
Merge commit from fork
The epoch duration subtraction in get_block_epoch was unchecked.
A miner can craft a chain where the previous epoch tail has a higher
timestamp than the next epoch tail (consensus-valid since only median-time
is enforced, not monotonicity). The unchecked subtraction then underflows
in release builds (overflow-checks = true), causing a panic.
Using saturating_sub yields 0 for non-monotonic timestamps, which the
downstream next_epoch_ext already clamps to at least 1 second via
cmp::max(epoch_duration / 1000, 1).1 parent 8f6cacf commit 0c1c998
1 file changed
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 36 | + | |
| 37 | + | |
39 | 38 | | |
40 | | - | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments