Revert bad blocks on missed fork (#2529)

## Issue Addressed

Closes #2526

## Proposed Changes

If the head block fails to decode on start up, do two things:

1. Revert all blocks between the head and the most recent hard fork (to `fork_slot - 1`).
2. Reset fork choice so that it contains the new head, and all blocks back to the new head's finalized checkpoint.

## Additional Info

I tweaked some of the beacon chain test harness stuff in order to make it generic enough to test with a non-zero slot clock on start-up. In the process I consolidated all the various `new_` methods into a single generic one which will hopefully serve all future uses 🤞
This commit is contained in:
Michael Sproul
2021-08-30 06:41:31 +00:00
parent 6b65b6f3bd
commit 10945e0619
16 changed files with 683 additions and 213 deletions

View File

@@ -840,11 +840,10 @@ fn verify_block_for_gossip_slashing_detection() {
.unwrap(),
);
let harness = BeaconChainHarness::new_with_mutator(
let harness = BeaconChainHarness::ephemeral_with_mutator(
MainnetEthSpec,
None,
KEYPAIRS.to_vec(),
1 << 32,
StoreConfig::default(),
ChainConfig::default(),
|builder| builder.slasher(slasher.clone()),
@@ -927,7 +926,6 @@ fn add_base_block_to_altair_chain() {
MainnetEthSpec,
Some(spec),
KEYPAIRS[..].to_vec(),
1 << 32,
StoreConfig::default(),
ChainConfig::default(),
);
@@ -1047,7 +1045,6 @@ fn add_altair_block_to_base_chain() {
MainnetEthSpec,
Some(spec),
KEYPAIRS[..].to_vec(),
1 << 32,
StoreConfig::default(),
ChainConfig::default(),
);