mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Persistent committee caches and exit cache
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::*;
|
||||
use ssz::{DecodeError, Encode};
|
||||
use ssz_derive::Encode;
|
||||
use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
use types::beacon_state::{CloneConfig, CommitteeCache, CACHED_EPOCHS};
|
||||
|
||||
pub fn store_full_state<E: EthSpec>(
|
||||
@@ -48,7 +49,7 @@ pub fn get_full_state<KV: KeyValueStore<E>, E: EthSpec>(
|
||||
#[derive(Encode)]
|
||||
pub struct StorageContainer<T: EthSpec> {
|
||||
state: BeaconState<T>,
|
||||
committee_caches: Vec<CommitteeCache>,
|
||||
committee_caches: Vec<Arc<CommitteeCache>>,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> StorageContainer<T> {
|
||||
|
||||
@@ -409,15 +409,15 @@ mod test {
|
||||
let mut hashes = (0..).map(Hash256::from_low_u64_be);
|
||||
let roots_a = state_a.block_roots_mut();
|
||||
for i in 0..roots_a.len() {
|
||||
roots_a[i] = hashes.next().unwrap()
|
||||
*roots_a.get_mut(i).unwrap() = hashes.next().unwrap()
|
||||
}
|
||||
let roots_b = state_b.block_roots_mut();
|
||||
for i in 0..roots_b.len() {
|
||||
roots_b[i] = hashes.next().unwrap()
|
||||
*roots_b.get_mut(i).unwrap() = hashes.next().unwrap()
|
||||
}
|
||||
|
||||
let state_a_root = hashes.next().unwrap();
|
||||
state_b.state_roots_mut()[0] = state_a_root;
|
||||
*state_b.state_roots_mut().get_mut(0).unwrap() = state_a_root;
|
||||
store.put_state(&state_a_root, &state_a).unwrap();
|
||||
|
||||
let iter = BlockRootsIterator::new(&store, &state_b);
|
||||
|
||||
@@ -25,6 +25,7 @@ pub mod metadata;
|
||||
pub mod metrics;
|
||||
mod partial_beacon_state;
|
||||
pub mod reconstruct;
|
||||
mod state_cache;
|
||||
|
||||
pub mod iter;
|
||||
|
||||
|
||||
18
beacon_node/store/src/state_cache.rs
Normal file
18
beacon_node/store/src/state_cache.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::mem::size_of;
|
||||
use types::{
|
||||
beacon_state::PubkeyCache, BeaconBlockHeader, BeaconState, BeaconStateAltair,
|
||||
BeaconStateMerge, MainnetEthSpec,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn state_size() {
|
||||
println!("{}", size_of::<BeaconStateAltair<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<BeaconStateMerge<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<BeaconState<MainnetEthSpec>>());
|
||||
println!("{}", size_of::<PubkeyCache>());
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user