mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-21 14:58:31 +00:00
Merge and test fixups
This commit is contained in:
@@ -70,6 +70,11 @@ impl MigratorConfig {
|
||||
self.blocking = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn epochs_per_run(mut self, epochs_per_run: u64) -> Self {
|
||||
self.epochs_per_run = epochs_per_run;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Pruning can be successful, or in rare cases deferred to a later point.
|
||||
|
||||
@@ -316,6 +316,12 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn logger(mut self, log: Logger) -> Self {
|
||||
self.log = log.clone();
|
||||
self.runtime.set_logger(log);
|
||||
self
|
||||
}
|
||||
|
||||
/// This mutator will be run before the `store_mutator`.
|
||||
pub fn initial_mutator(mut self, mutator: BoxedMutator<E, Hot, Cold>) -> Self {
|
||||
assert!(
|
||||
|
||||
@@ -981,7 +981,7 @@ async fn attestation_that_skips_epochs() {
|
||||
let block_slot = harness
|
||||
.chain
|
||||
.store
|
||||
.get_blinded_block(&block_root)
|
||||
.get_blinded_block(&block_root, None)
|
||||
.expect("should not error getting block")
|
||||
.expect("should find attestation block")
|
||||
.message()
|
||||
|
||||
@@ -1141,7 +1141,6 @@ async fn add_base_block_to_altair_chain() {
|
||||
let mut state = state;
|
||||
let mut ctxt = ConsensusContext::new(base_block.slot());
|
||||
per_slot_processing(&mut state, None, &harness.chain.spec).unwrap();
|
||||
let mut ctxt = ConsensusContext::new(state.slot());
|
||||
assert!(matches!(
|
||||
per_block_processing(
|
||||
&mut state,
|
||||
@@ -1275,7 +1274,6 @@ async fn add_altair_block_to_base_chain() {
|
||||
let mut state = state;
|
||||
let mut ctxt = ConsensusContext::new(altair_block.slot());
|
||||
per_slot_processing(&mut state, None, &harness.chain.spec).unwrap();
|
||||
let mut ctxt = ConsensusContext::new(state.slot());
|
||||
assert!(matches!(
|
||||
per_block_processing(
|
||||
&mut state,
|
||||
|
||||
@@ -215,7 +215,7 @@ impl InvalidPayloadRig {
|
||||
let mock_execution_layer = self.harness.mock_execution_layer.as_ref().unwrap();
|
||||
|
||||
let head = self.harness.chain.head_snapshot();
|
||||
let state = head.beacon_state.clone_with_only_committee_caches();
|
||||
let state = head.beacon_state.clone();
|
||||
let slot = slot_override.unwrap_or(state.slot() + 1);
|
||||
let (block, post_state) = self.harness.make_block(state, slot).await;
|
||||
let block_root = block.canonical_root();
|
||||
@@ -308,7 +308,7 @@ impl InvalidPayloadRig {
|
||||
self.harness
|
||||
.chain
|
||||
.store
|
||||
.get_full_block(&block_root)
|
||||
.get_full_block(&block_root, None)
|
||||
.unwrap()
|
||||
.unwrap(),
|
||||
block,
|
||||
@@ -2000,7 +2000,7 @@ async fn weights_after_resetting_optimistic_status() {
|
||||
.fork_choice_read_lock()
|
||||
.get_block_weight(&head.head_block_root())
|
||||
.unwrap(),
|
||||
head.snapshot.beacon_state.validators()[0].effective_balance,
|
||||
head.snapshot.beacon_state.validators().get(0).unwrap().effective_balance(),
|
||||
"proposer boost should be removed from the head block and the vote of a single validator applied"
|
||||
);
|
||||
|
||||
|
||||
@@ -64,11 +64,20 @@ fn get_harness(
|
||||
store: Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>>,
|
||||
validator_count: usize,
|
||||
) -> TestHarness {
|
||||
// Most tests were written expecting instant migration on finalization.
|
||||
let migrator_config = MigratorConfig::default().blocking().epochs_per_run(0);
|
||||
|
||||
let log = store.log.clone();
|
||||
|
||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
||||
.logger(log)
|
||||
.default_spec()
|
||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||
.fresh_disk_store(store)
|
||||
.mock_execution_layer()
|
||||
.initial_mutator(Box::new(|builder: BeaconChainBuilder<_>| {
|
||||
builder.store_migrator_config(migrator_config)
|
||||
}))
|
||||
.build();
|
||||
harness.advance_slot();
|
||||
harness
|
||||
@@ -272,6 +281,9 @@ async fn split_slot_restore() {
|
||||
)
|
||||
.await;
|
||||
|
||||
// Uhmm. FIXME(sproul)
|
||||
// tokio::time::sleep(std::time::Duration::from_secs(10)).await;
|
||||
|
||||
store.get_split_slot()
|
||||
};
|
||||
assert_ne!(split_slot, Slot::new(0));
|
||||
@@ -561,7 +573,7 @@ async fn delete_blocks_and_states() {
|
||||
);
|
||||
|
||||
let faulty_head_block = store
|
||||
.get_blinded_block(&faulty_head.into())
|
||||
.get_blinded_block(&faulty_head.into(), None)
|
||||
.expect("no errors")
|
||||
.expect("faulty head block exists");
|
||||
|
||||
@@ -603,7 +615,7 @@ async fn delete_blocks_and_states() {
|
||||
break;
|
||||
}
|
||||
store.delete_block(&block_root).unwrap();
|
||||
assert_eq!(store.get_blinded_block(&block_root).unwrap(), None);
|
||||
assert_eq!(store.get_blinded_block(&block_root, None).unwrap(), None);
|
||||
}
|
||||
|
||||
// Deleting frozen states should do nothing
|
||||
@@ -847,7 +859,7 @@ fn get_state_for_block(harness: &TestHarness, block_root: Hash256) -> BeaconStat
|
||||
let head_block = harness
|
||||
.chain
|
||||
.store
|
||||
.get_blinded_block(&block_root)
|
||||
.get_blinded_block(&block_root, None)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
harness
|
||||
@@ -887,9 +899,17 @@ fn check_shuffling_compatible(
|
||||
|committee_cache, _| {
|
||||
let state_cache = head_state.committee_cache(RelativeEpoch::Current).unwrap();
|
||||
if current_epoch_shuffling_is_compatible {
|
||||
assert_eq!(committee_cache, state_cache, "block at slot {slot}");
|
||||
assert_eq!(
|
||||
committee_cache,
|
||||
state_cache.as_ref(),
|
||||
"block at slot {slot}"
|
||||
);
|
||||
} else {
|
||||
assert_ne!(committee_cache, state_cache, "block at slot {slot}");
|
||||
assert_ne!(
|
||||
committee_cache,
|
||||
state_cache.as_ref(),
|
||||
"block at slot {slot}"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
@@ -919,9 +939,9 @@ fn check_shuffling_compatible(
|
||||
|committee_cache, _| {
|
||||
let state_cache = head_state.committee_cache(RelativeEpoch::Previous).unwrap();
|
||||
if previous_epoch_shuffling_is_compatible {
|
||||
assert_eq!(committee_cache, state_cache);
|
||||
assert_eq!(committee_cache, state_cache.as_ref());
|
||||
} else {
|
||||
assert_ne!(committee_cache, state_cache);
|
||||
assert_ne!(committee_cache, state_cache.as_ref());
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
@@ -2019,7 +2039,7 @@ async fn weak_subjectivity_sync() {
|
||||
let wss_block = harness
|
||||
.chain
|
||||
.store
|
||||
.get_full_block(&wss_checkpoint.root)
|
||||
.get_full_block(&wss_checkpoint.root, None)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let wss_state = full_store
|
||||
@@ -2164,7 +2184,7 @@ async fn weak_subjectivity_sync() {
|
||||
.unwrap()
|
||||
.map(Result::unwrap)
|
||||
{
|
||||
let block = store.get_blinded_block(&block_root).unwrap().unwrap();
|
||||
let block = store.get_blinded_block(&block_root, None).unwrap().unwrap();
|
||||
assert_eq!(block.slot(), slot);
|
||||
}
|
||||
|
||||
@@ -2490,8 +2510,8 @@ fn assert_chains_pretty_much_the_same<T: BeaconChainTypes>(a: &BeaconChain<T>, b
|
||||
// Clone with committee caches only to prevent other caches from messing with the equality
|
||||
// check.
|
||||
assert_eq!(
|
||||
a_head.beacon_state.clone_with_only_committee_caches(),
|
||||
b_head.beacon_state.clone_with_only_committee_caches(),
|
||||
a_head.beacon_state.clone(),
|
||||
b_head.beacon_state.clone(),
|
||||
"head states should be equal"
|
||||
);
|
||||
assert_eq!(a.heads(), b.heads(), "heads() should be equal");
|
||||
|
||||
Reference in New Issue
Block a user