mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 02:33:48 +00:00
Fix genesis state storage for genesis sync (#4589)
This commit is contained in:
@@ -337,12 +337,13 @@ where
|
|||||||
.build_caches(&self.spec)
|
.build_caches(&self.spec)
|
||||||
.map_err(|e| format!("Failed to build genesis state caches: {:?}", e))?;
|
.map_err(|e| format!("Failed to build genesis state caches: {:?}", e))?;
|
||||||
|
|
||||||
store
|
info!(store.log, "Storing genesis state"; "state_root" => ?beacon_state_root);
|
||||||
.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
|
store
|
||||||
.put_state(&beacon_state_root, &beacon_state)
|
.put_state(&beacon_state_root, &beacon_state)
|
||||||
.map_err(|e| format!("Failed to store genesis state: {:?}", e))?;
|
.map_err(|e| format!("Failed to store genesis state: {:?}", e))?;
|
||||||
|
store
|
||||||
|
.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 the genesis block's execution payload (if any) in the hot database.
|
// Store the genesis block's execution payload (if any) in the hot database.
|
||||||
if let Some(execution_payload) = &payload {
|
if let Some(execution_payload) = &payload {
|
||||||
|
|||||||
@@ -939,6 +939,11 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
.lock()
|
.lock()
|
||||||
.put_state(*state_root, block_root, state)?
|
.put_state(*state_root, block_root, state)?
|
||||||
{
|
{
|
||||||
|
debug!(
|
||||||
|
self.log,
|
||||||
|
"Skipping storage of cached state";
|
||||||
|
"slot" => state.slot()
|
||||||
|
);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1119,7 +1124,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
|
|
||||||
// If the prior state is the split state and it isn't cached then load it in
|
// If the prior state is the split state and it isn't cached then load it in
|
||||||
// entirety from disk. This should only happen on first start up.
|
// entirety from disk. This should only happen on first start up.
|
||||||
if prior_state_root == split_read_lock.state_root {
|
if prior_state_root == split_read_lock.state_root || prior_summary.slot == 0 {
|
||||||
debug!(
|
debug!(
|
||||||
self.log,
|
self.log,
|
||||||
"Using split state as base state for replay";
|
"Using split state as base state for replay";
|
||||||
@@ -1317,7 +1322,8 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
|||||||
|
|
||||||
if slot >= split.slot {
|
if slot >= split.slot {
|
||||||
Ok(state_root == split.state_root
|
Ok(state_root == split.state_root
|
||||||
|| self.spec.fork_activated_at_slot::<E>(slot).is_some())
|
|| self.spec.fork_activated_at_slot::<E>(slot).is_some()
|
||||||
|
|| slot == 0)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::SlotIsBeforeSplit { slot })
|
Err(Error::SlotIsBeforeSplit { slot })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user