mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Delete OnDiskConsensusContext (#8824)
Remove the `OnDiskConsensusContext` type which is no longer used at all after the merge of: - https://github.com/sigp/lighthouse/pull/8724 This type was not necessary since the merge of Lion's change which removed the on-disk storage: - https://github.com/sigp/lighthouse/pull/5891 Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -1,65 +0,0 @@
|
|||||||
use ssz_derive::{Decode, Encode};
|
|
||||||
use state_processing::ConsensusContext;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use types::{EthSpec, Hash256, IndexedAttestation, Slot};
|
|
||||||
|
|
||||||
/// The consensus context is stored on disk as part of the data availability overflow cache.
|
|
||||||
///
|
|
||||||
/// We use this separate struct to keep the on-disk format stable in the presence of changes to the
|
|
||||||
/// in-memory `ConsensusContext`. You MUST NOT change the fields of this struct without
|
|
||||||
/// superstructing it and implementing a schema migration.
|
|
||||||
#[derive(Debug, PartialEq, Clone, Encode, Decode)]
|
|
||||||
pub struct OnDiskConsensusContext<E: EthSpec> {
|
|
||||||
/// Slot to act as an identifier/safeguard
|
|
||||||
slot: Slot,
|
|
||||||
/// Proposer index of the block at `slot`.
|
|
||||||
proposer_index: Option<u64>,
|
|
||||||
/// Block root of the block at `slot`.
|
|
||||||
current_block_root: Option<Hash256>,
|
|
||||||
/// We keep the indexed attestations in the *in-memory* version of this struct so that we don't
|
|
||||||
/// need to regenerate them if roundtripping via this type *without* going to disk.
|
|
||||||
///
|
|
||||||
/// They are not part of the on-disk format.
|
|
||||||
#[ssz(skip_serializing, skip_deserializing)]
|
|
||||||
indexed_attestations: HashMap<Hash256, IndexedAttestation<E>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<E: EthSpec> OnDiskConsensusContext<E> {
|
|
||||||
pub fn from_consensus_context(ctxt: ConsensusContext<E>) -> Self {
|
|
||||||
// Match exhaustively on fields here so we are forced to *consider* updating the on-disk
|
|
||||||
// format when the `ConsensusContext` fields change.
|
|
||||||
let ConsensusContext {
|
|
||||||
slot,
|
|
||||||
previous_epoch: _,
|
|
||||||
current_epoch: _,
|
|
||||||
proposer_index,
|
|
||||||
current_block_root,
|
|
||||||
indexed_attestations,
|
|
||||||
} = ctxt;
|
|
||||||
OnDiskConsensusContext {
|
|
||||||
slot,
|
|
||||||
proposer_index,
|
|
||||||
current_block_root,
|
|
||||||
indexed_attestations,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn into_consensus_context(self) -> ConsensusContext<E> {
|
|
||||||
let OnDiskConsensusContext {
|
|
||||||
slot,
|
|
||||||
proposer_index,
|
|
||||||
current_block_root,
|
|
||||||
indexed_attestations,
|
|
||||||
} = self;
|
|
||||||
|
|
||||||
let mut ctxt = ConsensusContext::new(slot);
|
|
||||||
|
|
||||||
if let Some(proposer_index) = proposer_index {
|
|
||||||
ctxt = ctxt.set_proposer_index(proposer_index);
|
|
||||||
}
|
|
||||||
if let Some(block_root) = current_block_root {
|
|
||||||
ctxt = ctxt.set_current_block_root(block_root);
|
|
||||||
}
|
|
||||||
ctxt.set_indexed_attestations(indexed_attestations)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
//! tests for implementation examples.
|
//! tests for implementation examples.
|
||||||
pub mod blob_sidecar_list_from_root;
|
pub mod blob_sidecar_list_from_root;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod consensus_context;
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
mod forwards_iter;
|
mod forwards_iter;
|
||||||
pub mod hdiff;
|
pub mod hdiff;
|
||||||
@@ -27,7 +26,6 @@ pub mod iter;
|
|||||||
|
|
||||||
pub use self::blob_sidecar_list_from_root::BlobSidecarListFromRoot;
|
pub use self::blob_sidecar_list_from_root::BlobSidecarListFromRoot;
|
||||||
pub use self::config::StoreConfig;
|
pub use self::config::StoreConfig;
|
||||||
pub use self::consensus_context::OnDiskConsensusContext;
|
|
||||||
pub use self::hot_cold_store::{HotColdDB, HotStateSummary, Split};
|
pub use self::hot_cold_store::{HotColdDB, HotStateSummary, Split};
|
||||||
pub use self::memory_store::MemoryStore;
|
pub use self::memory_store::MemoryStore;
|
||||||
pub use crate::metadata::BlobInfo;
|
pub use crate::metadata::BlobInfo;
|
||||||
|
|||||||
Reference in New Issue
Block a user