Merge remote-tracking branch 'origin/unstable' into tree-states

This commit is contained in:
Michael Sproul
2022-03-01 16:03:41 +11:00
209 changed files with 6107 additions and 1362 deletions

View File

@@ -432,7 +432,7 @@ where
spec: chain.spec.clone(),
chain: Arc::new(chain),
validator_keypairs,
shutdown_receiver,
shutdown_receiver: Arc::new(Mutex::new(shutdown_receiver)),
mock_execution_layer: self.mock_execution_layer,
execution_layer_runtime: self.execution_layer_runtime,
rng: make_rng(),
@@ -449,7 +449,7 @@ pub struct BeaconChainHarness<T: BeaconChainTypes> {
pub chain: Arc<BeaconChain<T>>,
pub spec: ChainSpec,
pub shutdown_receiver: Receiver<ShutdownReason>,
pub shutdown_receiver: Arc<Mutex<Receiver<ShutdownReason>>>,
pub mock_execution_layer: Option<MockExecutionLayer<T::EthSpec>>,
pub execution_layer_runtime: Option<ExecutionLayerRuntime>,
@@ -502,6 +502,17 @@ where
epoch.start_slot(E::slots_per_epoch()).into()
}
pub fn shutdown_reasons(&self) -> Vec<ShutdownReason> {
let mutex = self.shutdown_receiver.clone();
let mut receiver = mutex.lock();
std::iter::from_fn(move || match receiver.try_next() {
Ok(Some(s)) => Some(s),
Ok(None) => panic!("shutdown sender dropped"),
Err(_) => None,
})
.collect()
}
pub fn get_current_state(&self) -> BeaconState<E> {
self.chain.head().unwrap().beacon_state
}