mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 10:43:42 +00:00
Gloas spec v1.7.0-alpha.5 and beacon_chain tests (#8998)
Fix database pruning post-Gloas - Fix DB pruning logic (and state summaries DAG) - Get the `beacon_chain` tests running with `FORK_NAME=gloas` 🎉 Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com> Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com> Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
@@ -23,7 +23,7 @@ use crate::{
|
||||
use bls::Signature;
|
||||
use execution_layer::ExecutionLayer;
|
||||
use fixed_bytes::FixedBytesExtended;
|
||||
use fork_choice::{ForkChoice, ResetPayloadStatuses};
|
||||
use fork_choice::{ForkChoice, PayloadStatus, ResetPayloadStatuses};
|
||||
use futures::channel::mpsc::Sender;
|
||||
use kzg::Kzg;
|
||||
use logging::crit;
|
||||
@@ -34,7 +34,9 @@ use rand::RngCore;
|
||||
use rayon::prelude::*;
|
||||
use slasher::Slasher;
|
||||
use slot_clock::{SlotClock, TestingSlotClock};
|
||||
use state_processing::{AllCaches, per_slot_processing};
|
||||
use state_processing::AllCaches;
|
||||
use state_processing::genesis::genesis_block;
|
||||
use state_processing::per_slot_processing;
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -44,8 +46,8 @@ use tracing::{debug, error, info, warn};
|
||||
use tree_hash::TreeHash;
|
||||
use types::data::CustodyIndex;
|
||||
use types::{
|
||||
BeaconBlock, BeaconState, BlobSidecarList, ChainSpec, ColumnIndex, DataColumnSidecarList,
|
||||
Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot,
|
||||
BeaconState, BlobSidecarList, ChainSpec, ColumnIndex, DataColumnSidecarList, Epoch, EthSpec,
|
||||
Hash256, SignedBeaconBlock, Slot,
|
||||
};
|
||||
|
||||
/// An empty struct used to "witness" all the `BeaconChainTypes` traits. It has no user-facing
|
||||
@@ -321,7 +323,7 @@ where
|
||||
.clone()
|
||||
.ok_or("set_genesis_state requires a store")?;
|
||||
|
||||
let beacon_block = genesis_block(&mut beacon_state, &self.spec)?;
|
||||
let beacon_block = make_genesis_block(&mut beacon_state, &self.spec)?;
|
||||
|
||||
beacon_state
|
||||
.build_caches(&self.spec)
|
||||
@@ -374,7 +376,7 @@ where
|
||||
// Since v4.4.0 we will set the anchor with a dummy state upper limit in order to prevent
|
||||
// historic states from being retained (unless `--archive` is set).
|
||||
let retain_historic_states = self.chain_config.archive;
|
||||
let genesis_beacon_block = genesis_block(&mut beacon_state, &self.spec)?;
|
||||
let genesis_beacon_block = make_genesis_block(&mut beacon_state, &self.spec)?;
|
||||
self.pending_io_batch.push(
|
||||
store
|
||||
.init_anchor_info(
|
||||
@@ -617,7 +619,6 @@ where
|
||||
.map_err(|e| format!("Failed to initialize data column info: {:?}", e))?,
|
||||
);
|
||||
|
||||
// TODO(gloas): add check that checkpoint state is Pending
|
||||
let snapshot = BeaconSnapshot {
|
||||
beacon_block_root: weak_subj_block_root,
|
||||
execution_envelope: None,
|
||||
@@ -786,23 +787,26 @@ where
|
||||
.map_err(|e| descriptive_db_error("head block", &e))?
|
||||
.ok_or("Head block not found in store")?;
|
||||
|
||||
let state_payload_status = head_payload_status.as_state_payload_status();
|
||||
|
||||
let (_head_state_root, head_state) = store
|
||||
.get_advanced_hot_state(
|
||||
head_block_root,
|
||||
state_payload_status,
|
||||
current_slot,
|
||||
head_block.state_root(),
|
||||
)
|
||||
.get_advanced_hot_state(head_block_root, current_slot, head_block.state_root())
|
||||
.map_err(|e| descriptive_db_error("head state", &e))?
|
||||
.ok_or("Head state not found in store")?;
|
||||
|
||||
let head_shuffling_ids = BlockShufflingIds::try_from_head(head_block_root, &head_state)?;
|
||||
|
||||
// Load the execution envelope from the store if the head has a Full payload.
|
||||
let execution_envelope = if head_payload_status == PayloadStatus::Full {
|
||||
store
|
||||
.get_payload_envelope(&head_block_root)
|
||||
.map_err(|e| format!("Error loading head execution envelope: {:?}", e))?
|
||||
.map(Arc::new)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut head_snapshot = BeaconSnapshot {
|
||||
beacon_block_root: head_block_root,
|
||||
execution_envelope: None,
|
||||
execution_envelope,
|
||||
beacon_block: Arc::new(head_block),
|
||||
beacon_state: head_state,
|
||||
};
|
||||
@@ -1166,17 +1170,19 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn genesis_block<E: EthSpec>(
|
||||
fn make_genesis_block<E: EthSpec>(
|
||||
genesis_state: &mut BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<SignedBeaconBlock<E>, String> {
|
||||
let mut genesis_block = BeaconBlock::empty(spec);
|
||||
*genesis_block.state_root_mut() = genesis_state
|
||||
let mut block = genesis_block(genesis_state, spec)
|
||||
.map_err(|e| format!("Error building genesis block: {:?}", e))?;
|
||||
|
||||
*block.state_root_mut() = genesis_state
|
||||
.update_tree_hash_cache()
|
||||
.map_err(|e| format!("Error hashing genesis state: {:?}", e))?;
|
||||
|
||||
Ok(SignedBeaconBlock::from_block(
|
||||
genesis_block,
|
||||
block,
|
||||
// Empty signature, which should NEVER be read. This isn't to-spec, but makes the genesis
|
||||
// block consistent with every other block.
|
||||
Signature::empty(),
|
||||
|
||||
Reference in New Issue
Block a user