Skip to content

Commit 52fb2d5

Browse files
refactor: remove PartialEq from PTCCache
PTCCache comparison excluded via #[derivative(PartialEq = "ignore")] on BeaconState.ptc_cache field (matching cache field pattern). Removes unused derivative PartialEq implementation and comparison functions.
1 parent f36e5d4 commit 52fb2d5

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

types/src/gloas/ptc_cache.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,23 @@
11
use std::{collections::HashMap, sync::Arc};
22

3-
use derivative::Derivative;
43
use once_cell::sync::OnceCell;
54

65
use crate::phase0::primitives::{Epoch, Slot, ValidatorIndex};
76

8-
/// Equivalence function for `ptc_positions` that ignores trailing `None` entries.
9-
/// Will be used in tests.
10-
fn compare_ptc_positions(xs: &Vec<Option<usize>>, ys: &Vec<Option<usize>>) -> bool {
11-
use std::cmp::Ordering;
12-
13-
let (shorter, longer) = match xs.len().cmp(&ys.len()) {
14-
Ordering::Equal => {
15-
return xs == ys;
16-
}
17-
Ordering::Less => (xs, ys),
18-
Ordering::Greater => (ys, xs),
19-
};
20-
21-
shorter == &longer[..shorter.len()]
22-
&& longer[shorter.len()..].iter().all(|new| new.is_none())
23-
}
24-
25-
/// Equivalence function for `multiple_positions` HashMap.
26-
fn compare_multiple_positions(
27-
xs: &HashMap<ValidatorIndex, Vec<(Slot, usize)>>,
28-
ys: &HashMap<ValidatorIndex, Vec<(Slot, usize)>>,
29-
) -> bool {
30-
xs == ys
31-
}
32-
337
/// Cache for Payload Timeliness Committee (PTC) assignments for an entire epoch.
348
///
359
/// Uses a hybrid storage approach:
3610
/// - Most validators have few occurrences: stored in flat Vec
3711
/// - Validators with multiple occurrences: stored in HashMap
38-
#[derive(Clone, Debug, Derivative)]
39-
#[derivative(PartialEq)]
12+
#[derive(Clone, Debug)]
4013
pub struct PTCCache {
4114
/// The epoch this cache was initialized for
4215
pub initialized_epoch: Option<Epoch>,
4316
/// Flat shuffling for all slots in epoch
4417
pub ptc_shuffling: Vec<ValidatorIndex>,
4518
/// Reverse index for single occurrences: validator_index → first position
46-
#[derivative(PartialEq(compare_with = "compare_ptc_positions"))]
4719
pub ptc_positions: Vec<Option<usize>>,
4820
/// HashMap for validators with multiple occurrences
49-
#[derivative(PartialEq(compare_with = "compare_multiple_positions"))]
5021
pub multiple_positions: HashMap<ValidatorIndex, Vec<(Slot, usize)>>,
5122
/// PTC size per slot
5223
pub ptc_size: usize,

0 commit comments

Comments
 (0)