forked from grandinetech/grandine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollections.rs
62 lines (46 loc) · 2.55 KB
/
collections.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Collections used in `BeaconState`.
//!
//! Persistent SSZ collections are optimized for fast state transitions and low memory usage when
//! multiple consecutive states exist. This comes at the cost of slower (de)serialization with both
//! Serde and SSZ. If there is a need for fast (de)serialization in the future, it could be achieved
//! by defining alternate `BeaconState` structs containing contiguous collections.
//!
//! All bundle sizes are currently set to minimize rehashing at the cost of higher memory usage.
use ssz::{PersistentList, PersistentVector, UnhashedBundleSize};
use crate::{
altair::primitives::ParticipationFlags,
capella::containers::HistoricalSummary,
electra::containers::{PendingConsolidation, PendingDeposit, PendingPartialWithdrawal},
phase0::{
containers::{Eth1Data, PendingAttestation, Validator},
primitives::{Gwei, H256},
},
preset::{MaxAttestationsPerEpoch, Preset, SlotsPerEth1VotingPeriod, SlotsPerHistoricalRoot},
};
pub type RecentRoots<P> =
PersistentVector<H256, SlotsPerHistoricalRoot<P>, UnhashedBundleSize<H256>>;
pub type HistoricalRoots<P> =
PersistentList<H256, <P as Preset>::HistoricalRootsLimit, UnhashedBundleSize<H256>>;
pub type Eth1DataVotes<P> = PersistentList<Eth1Data, SlotsPerEth1VotingPeriod<P>>;
pub type Validators<P> = PersistentList<Validator, <P as Preset>::ValidatorRegistryLimit>;
pub type Balances<P> =
PersistentList<Gwei, <P as Preset>::ValidatorRegistryLimit, UnhashedBundleSize<Gwei>>;
pub type RandaoMixes<P> =
PersistentVector<H256, <P as Preset>::EpochsPerHistoricalVector, UnhashedBundleSize<H256>>;
pub type Slashings<P> =
PersistentVector<Gwei, <P as Preset>::EpochsPerSlashingsVector, UnhashedBundleSize<Gwei>>;
pub type Attestations<P> = PersistentList<PendingAttestation<P>, MaxAttestationsPerEpoch<P>>;
pub type EpochParticipation<P> = PersistentList<
ParticipationFlags,
<P as Preset>::ValidatorRegistryLimit,
UnhashedBundleSize<ParticipationFlags>,
>;
pub type InactivityScores<P> =
PersistentList<u64, <P as Preset>::ValidatorRegistryLimit, UnhashedBundleSize<u64>>;
pub type HistoricalSummaries<P> =
PersistentList<HistoricalSummary, <P as Preset>::HistoricalRootsLimit>;
pub type PendingDeposits<P> = PersistentList<PendingDeposit, <P as Preset>::PendingDepositsLimit>;
pub type PendingPartialWithdrawals<P> =
PersistentList<PendingPartialWithdrawal, <P as Preset>::PendingPartialWithdrawalsLimit>;
pub type PendingConsolidations<P> =
PersistentList<PendingConsolidation, <P as Preset>::PendingConsolidationsLimit>;