Gloas cold DB (#8991)

Closes:

- https://github.com/sigp/lighthouse/issues/8958


  - Update the `HotColdStore` to handle storage of cold states.
- Update `BeaconSnapshot` to hold the execution envelope. This is required to make `chain_dump`-related checks sane, and will be generally useful (see: https://github.com/sigp/lighthouse/issues/8956).
- Bug fix in the `BlockReplayer` for the case where the starting state is already `Full` (we should not try to apply another payload). This happens on the cold DB path because we try to replay from the closest cached state (which is often full).
- Update `test_gloas_hot_state_hierarchy` to cover the cold DB migration.


Co-Authored-By: Michael Sproul <michael@sigmaprime.io>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
Michael Sproul
2026-03-19 20:09:13 +11:00
committed by GitHub
parent a965bfdf77
commit 06025228ae
9 changed files with 139 additions and 25 deletions

View File

@@ -2,7 +2,7 @@ use serde::Serialize;
use std::sync::Arc;
use types::{
AbstractExecPayload, BeaconState, EthSpec, FullPayload, Hash256, SignedBeaconBlock,
SignedBlindedBeaconBlock,
SignedBlindedBeaconBlock, SignedExecutionPayloadEnvelope,
};
/// Represents some block and its associated state. Generally, this will be used for tracking the
@@ -10,6 +10,7 @@ use types::{
#[derive(Clone, Serialize, PartialEq, Debug)]
pub struct BeaconSnapshot<E: EthSpec, Payload: AbstractExecPayload<E> = FullPayload<E>> {
pub beacon_block: Arc<SignedBeaconBlock<E, Payload>>,
pub execution_envelope: Option<Arc<SignedExecutionPayloadEnvelope<E>>>,
pub beacon_block_root: Hash256,
pub beacon_state: BeaconState<E>,
}
@@ -31,33 +32,42 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> BeaconSnapshot<E, Payload> {
/// Create a new checkpoint.
pub fn new(
beacon_block: Arc<SignedBeaconBlock<E, Payload>>,
execution_envelope: Option<Arc<SignedExecutionPayloadEnvelope<E>>>,
beacon_block_root: Hash256,
beacon_state: BeaconState<E>,
) -> Self {
Self {
beacon_block,
execution_envelope,
beacon_block_root,
beacon_state,
}
}
/// Returns the state root from `self.beacon_block`.
/// Returns the state root from `self.beacon_block` or `self.execution_envelope` as
/// appropriate.
///
/// ## Caution
///
/// It is not strictly enforced that `root(self.beacon_state) == self.beacon_state_root()`.
pub fn beacon_state_root(&self) -> Hash256 {
self.beacon_block.message().state_root()
if let Some(ref envelope) = self.execution_envelope {
envelope.message.state_root
} else {
self.beacon_block.message().state_root()
}
}
/// Update all fields of the checkpoint.
pub fn update(
&mut self,
beacon_block: Arc<SignedBeaconBlock<E, Payload>>,
execution_envelope: Option<Arc<SignedExecutionPayloadEnvelope<E>>>,
beacon_block_root: Hash256,
beacon_state: BeaconState<E>,
) {
self.beacon_block = beacon_block;
self.execution_envelope = execution_envelope;
self.beacon_block_root = beacon_block_root;
self.beacon_state = beacon_state;
}