Modularize beacon node backend (#4718)

#4669


  Modularize the beacon node backend to make it easier to add new database implementations
This commit is contained in:
Eitan Seri-Levi
2025-01-23 09:12:16 +07:00
committed by GitHub
parent 266b241123
commit a1b7d616b4
38 changed files with 1479 additions and 650 deletions

View File

@@ -2,8 +2,8 @@ use crate::chunked_vector::{
load_variable_list_from_db, load_vector_from_db, BlockRootsChunked, HistoricalRoots,
HistoricalSummaries, RandaoMixes, StateRootsChunked,
};
use crate::{Error, KeyValueStore};
use ssz::{Decode, DecodeError};
use crate::{DBColumn, Error, KeyValueStore, KeyValueStoreOp};
use ssz::{Decode, DecodeError, Encode};
use ssz_derive::{Decode, Encode};
use std::sync::Arc;
use types::historical_summary::HistoricalSummary;
@@ -172,6 +172,15 @@ impl<E: EthSpec> PartialBeaconState<E> {
))
}
/// Prepare the partial state for storage in the KV database.
pub fn as_kv_store_op(&self, state_root: Hash256) -> KeyValueStoreOp {
KeyValueStoreOp::PutKeyValue(
DBColumn::BeaconState,
state_root.as_slice().to_vec(),
self.as_ssz_bytes(),
)
}
pub fn load_block_roots<S: KeyValueStore<E>>(
&mut self,
store: &S,