mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
Fix genesis block handling
This commit is contained in:
@@ -318,6 +318,7 @@ where
|
||||
.ok_or("set_genesis_state requires a store")?;
|
||||
|
||||
let beacon_block = genesis_block(&mut beacon_state, &self.spec)?;
|
||||
let blinded_block = beacon_block.clone_as_blinded();
|
||||
|
||||
beacon_state
|
||||
.build_all_caches(&self.spec)
|
||||
@@ -330,12 +331,12 @@ where
|
||||
.put_state(&beacon_state_root, &beacon_state)
|
||||
.map_err(|e| format!("Failed to store genesis state: {:?}", e))?;
|
||||
store
|
||||
.put_block(&beacon_block_root, beacon_block.clone())
|
||||
.put_cold_blinded_block(&beacon_block_root, &blinded_block)
|
||||
.map_err(|e| format!("Failed to store genesis block: {:?}", e))?;
|
||||
|
||||
// Store the genesis block under the `ZERO_HASH` key.
|
||||
store
|
||||
.put_block(&Hash256::zero(), beacon_block.clone())
|
||||
.put_cold_blinded_block(&Hash256::zero(), &blinded_block)
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to store genesis block under 0x00..00 alias: {:?}",
|
||||
|
||||
@@ -410,7 +410,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
slot: Option<Slot>,
|
||||
) -> Result<Option<SignedBlindedBeaconBlock<E>>, Error> {
|
||||
if let Some(slot) = slot {
|
||||
if slot < self.get_split_slot() {
|
||||
if slot < self.get_split_slot() || slot == 0 {
|
||||
// To the freezer DB.
|
||||
self.get_cold_blinded_block_by_slot(slot)
|
||||
} else {
|
||||
@@ -469,6 +469,16 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
)?))
|
||||
}
|
||||
|
||||
pub fn put_cold_blinded_block(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
block: &SignedBlindedBeaconBlock<E>,
|
||||
) -> Result<(), Error> {
|
||||
let mut ops = Vec::with_capacity(2);
|
||||
self.blinded_block_as_cold_kv_store_ops(block_root, block, &mut ops)?;
|
||||
self.cold_db.do_atomically(ops)
|
||||
}
|
||||
|
||||
pub fn blinded_block_as_cold_kv_store_ops(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
|
||||
Reference in New Issue
Block a user