Commit 96d22fa
committed
Guard
`verify_inferior_chain_macro_block_proposal` calls `fork_chain.remove(0)`
to strip the proposed block before invoking `rebranch_to`. If the
proposal's parent is the common ancestor, `fork_chain` becomes empty,
and `rebranch_to` would panic on `target_chain.last().unwrap()` when
updating `main_chain_successor`.
This state is not reachable under normal protocol invariants (the
non-inferior path would be taken, or `verify_macro_successor` would
reject the proposal), but guard defensively so a broken invariant
elsewhere cannot turn into a validator-wide crash. Returning `Err(vec![])`
funnels into the existing error handling in both callers, which abort
the write transaction and surface `PushError::InvalidFork`.rebranch_to against empty target_chain
1 parent 01cc6db commit 96d22fa
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
95 | 102 | | |
96 | 103 | | |
97 | 104 | | |
| |||
0 commit comments