diff --git a/beacon_node/beacon_chain/src/beacon_chain_builder.rs b/beacon_node/beacon_chain/src/beacon_chain_builder.rs index e59aae22b..ef25c33ec 100644 --- a/beacon_node/beacon_chain/src/beacon_chain_builder.rs +++ b/beacon_node/beacon_chain/src/beacon_chain_builder.rs @@ -243,6 +243,9 @@ fn interop_genesis_state( state.genesis_time = genesis_time; + // Invalid all the caches after all the manual state surgery. + state.drop_all_caches(); + Ok(state) } diff --git a/beacon_node/beacon_chain/tests/tests.rs b/beacon_node/beacon_chain/tests/tests.rs index bf853f284..82fc88216 100644 --- a/beacon_node/beacon_chain/tests/tests.rs +++ b/beacon_node/beacon_chain/tests/tests.rs @@ -465,12 +465,10 @@ fn free_attestations_added_to_fork_choice_all_updated() { } } -#[test] -fn produces_and_processes_with_genesis_skip_slots() { +fn run_skip_slot_test(skip_slots: u64) { let num_validators = 8; let harness_a = get_harness(num_validators); let harness_b = get_harness(num_validators); - let skip_slots = 9; for _ in 0..skip_slots { harness_a.advance_slot(); @@ -484,6 +482,12 @@ fn produces_and_processes_with_genesis_skip_slots() { AttestationStrategy::SomeValidators(vec![]), ); + assert_eq!( + harness_a.chain.head().beacon_block.slot, + Slot::new(skip_slots + 1) + ); + assert_eq!(harness_b.chain.head().beacon_block.slot, Slot::new(0)); + assert_eq!( harness_b .chain @@ -492,4 +496,16 @@ fn produces_and_processes_with_genesis_skip_slots() { block_root: harness_a.chain.head().beacon_block_root }) ); + + assert_eq!( + harness_b.chain.head().beacon_block.slot, + Slot::new(skip_slots + 1) + ); +} + +#[test] +fn produces_and_processes_with_genesis_skip_slots() { + for i in 0..MinimalEthSpec::slots_per_epoch() * 4 { + run_skip_slot_test(i) + } }