mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
Remove recursion from DB state lookup
This commit is contained in:
@@ -29,8 +29,8 @@ use std::time::Duration;
|
||||
use store::{Error as StoreError, HotColdDB, ItemStore, KeyValueStoreOp};
|
||||
use task_executor::{ShutdownReason, TaskExecutor};
|
||||
use types::{
|
||||
BeaconBlock, BeaconState, ChainSpec, Checkpoint, Epoch, EthSpec, Graffiti, Hash256,
|
||||
PublicKeyBytes, Signature, SignedBeaconBlock, Slot,
|
||||
BeaconBlock, BeaconState, ChainSpec, Checkpoint, EthSpec, Graffiti, Hash256, PublicKeyBytes,
|
||||
Signature, SignedBeaconBlock, Slot,
|
||||
};
|
||||
|
||||
/// An empty struct used to "witness" all the `BeaconChainTypes` traits. It has no user-facing
|
||||
@@ -313,12 +313,7 @@ where
|
||||
let beacon_block_root = beacon_block.canonical_root();
|
||||
|
||||
store
|
||||
.update_finalized_state(
|
||||
beacon_state_root,
|
||||
beacon_block_root,
|
||||
Epoch::new(0),
|
||||
beacon_state.clone(),
|
||||
)
|
||||
.update_finalized_state(beacon_state_root, beacon_block_root, beacon_state.clone())
|
||||
.map_err(|e| format!("Failed to set genesis state as finalized state: {:?}", e))?;
|
||||
|
||||
store
|
||||
@@ -447,12 +442,11 @@ where
|
||||
.update_finalized_state(
|
||||
weak_subj_state_root,
|
||||
weak_subj_block_root,
|
||||
weak_subj_slot.epoch(TEthSpec::slots_per_epoch()),
|
||||
weak_subj_state.clone(),
|
||||
)
|
||||
.map_err(|e| format!("Failed to set checkpoint state as finalized state: {:?}", e))?;
|
||||
store
|
||||
.store_full_state(&weak_subj_state_root, &weak_subj_state)
|
||||
.put_state(&weak_subj_state_root, &weak_subj_state)
|
||||
.map_err(|e| format!("Failed to store weak subjectivity state: {:?}", e))?;
|
||||
store
|
||||
.put_block(&weak_subj_block_root, weak_subj_block.clone())
|
||||
|
||||
@@ -38,7 +38,7 @@ fn get_state_by_replay<T: BeaconChainTypes>(
|
||||
// Replay blocks to reach the target state.
|
||||
let blocks = db.load_blocks_to_replay(epoch_boundary_state.slot(), slot, latest_block_root)?;
|
||||
|
||||
db.replay_blocks(epoch_boundary_state, blocks, slot, std::iter::empty())
|
||||
db.replay_blocks(epoch_boundary_state, blocks, slot, std::iter::empty(), None)
|
||||
}
|
||||
|
||||
pub fn upgrade_to_v20<T: BeaconChainTypes>(
|
||||
|
||||
@@ -445,7 +445,7 @@ fn block_replayer_hooks() {
|
||||
let mut post_block_slots = vec![];
|
||||
|
||||
let mut replay_state = BlockReplayer::<MinimalEthSpec>::new(state, &chain.spec)
|
||||
.pre_slot_hook(Box::new(|state| {
|
||||
.pre_slot_hook(Box::new(|_, state| {
|
||||
pre_slots.push(state.slot());
|
||||
Ok(())
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user