Squashed reset to unstable

This commit is contained in:
Daniel Knopik
2025-03-13 12:50:29 +01:00
committed by Daniel Knopik
parent b71b5f2231
commit f61f0b654c
416 changed files with 13195 additions and 38478 deletions

View File

@@ -2,9 +2,8 @@ use std::collections::HashMap;
use std::sync::Arc;
use itertools::Itertools;
use slog::{debug, Logger};
use oneshot_broadcast::{oneshot, Receiver, Sender};
use tracing::debug;
use types::{
beacon_state::CommitteeCache, AttestationShufflingId, BeaconState, Epoch, EthSpec, Hash256,
RelativeEpoch,
@@ -61,16 +60,14 @@ pub struct ShufflingCache {
cache: HashMap<AttestationShufflingId, CacheItem>,
cache_size: usize,
head_shuffling_ids: BlockShufflingIds,
logger: Logger,
}
impl ShufflingCache {
pub fn new(cache_size: usize, head_shuffling_ids: BlockShufflingIds, logger: Logger) -> Self {
pub fn new(cache_size: usize, head_shuffling_ids: BlockShufflingIds) -> Self {
Self {
cache: HashMap::new(),
cache_size,
head_shuffling_ids,
logger,
}
}
@@ -138,7 +135,7 @@ impl ShufflingCache {
.get(&key)
// Replace the committee if it's not present or if it's a promise. A bird in the hand is
// worth two in the promise-bush!
.map_or(true, CacheItem::is_promise)
.is_none_or(CacheItem::is_promise)
{
self.insert_cache_item(
key,
@@ -179,10 +176,9 @@ impl ShufflingCache {
for shuffling_id in shuffling_ids_to_prune.iter() {
debug!(
self.logger,
"Removing old shuffling from cache";
"shuffling_epoch" => shuffling_id.shuffling_epoch,
"shuffling_decision_block" => ?shuffling_id.shuffling_decision_block
shuffling_epoch = %shuffling_id.shuffling_epoch,
shuffling_decision_block = ?shuffling_id.shuffling_decision_block,
"Removing old shuffling from cache"
);
self.cache.remove(shuffling_id);
}
@@ -294,10 +290,10 @@ impl BlockShufflingIds {
#[cfg(not(debug_assertions))]
#[cfg(test)]
mod test {
use task_executor::test_utils::test_logger;
use types::*;
use crate::test_utils::EphemeralHarnessType;
use logging::create_test_tracing_subscriber;
use super::*;
@@ -308,6 +304,8 @@ mod test {
// Creates a new shuffling cache for testing
fn new_shuffling_cache() -> ShufflingCache {
create_test_tracing_subscriber();
let current_epoch = 8;
let head_shuffling_ids = BlockShufflingIds {
current: shuffling_id(current_epoch),
@@ -315,8 +313,8 @@ mod test {
previous: Some(shuffling_id(current_epoch - 1)),
block_root: Hash256::from_low_u64_le(0),
};
let logger = test_logger();
ShufflingCache::new(TEST_CACHE_SIZE, head_shuffling_ids, logger)
ShufflingCache::new(TEST_CACHE_SIZE, head_shuffling_ids)
}
/// Returns two different committee caches for testing.