-
Notifications
You must be signed in to change notification settings - Fork 345
/
Copy pathconsensus_spec.rs
92 lines (82 loc) · 4.28 KB
/
consensus_spec.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use std::fmt::Debug;
use serde::{Deserialize, Serialize};
use typenum::Unsigned;
pub trait ConsensusSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq {
type MaxProposerSlashings: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxAttesterSlashings: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxAttesterSlashingsElectra: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxAttestations: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxAttestationsElectra: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxValidatorsPerSlot: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxCommitteesPerSlot: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxDeposits: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxVoluntaryExits: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxBlsToExecutionChanged: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxBlobKzgCommitments: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxWithdrawals: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxValidatorsPerCommitee: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type SlotsPerEpoch: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type EpochsPerSyncCommiteePeriod: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type SyncCommitteeSize: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxWithdrawalRequests: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxDepositRequests: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
type MaxConsolidationRequests: Unsigned + Default + Debug + Sync + Send + Clone + PartialEq;
fn slots_per_epoch() -> u64 {
Self::SlotsPerEpoch::to_u64()
}
fn epochs_per_sync_commitee_period() -> u64 {
Self::EpochsPerSyncCommiteePeriod::to_u64()
}
fn slots_per_sync_commitee_period() -> u64 {
Self::slots_per_epoch() * Self::epochs_per_sync_commitee_period()
}
fn sync_commitee_size() -> u64 {
Self::SyncCommitteeSize::to_u64()
}
}
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
pub struct MainnetConsensusSpec;
impl ConsensusSpec for MainnetConsensusSpec {
type MaxProposerSlashings = typenum::U16;
type MaxAttesterSlashings = typenum::U2;
type MaxAttesterSlashingsElectra = typenum::U1;
type MaxAttestations = typenum::U128;
type MaxAttestationsElectra = typenum::U8;
type MaxCommitteesPerSlot = typenum::U64;
type MaxValidatorsPerSlot = typenum::U131072;
type MaxDeposits = typenum::U16;
type MaxVoluntaryExits = typenum::U16;
type MaxBlsToExecutionChanged = typenum::U16;
type MaxBlobKzgCommitments = typenum::U4096;
type MaxWithdrawals = typenum::U16;
type MaxValidatorsPerCommitee = typenum::U2048;
type SlotsPerEpoch = typenum::U32;
type EpochsPerSyncCommiteePeriod = typenum::U256;
type SyncCommitteeSize = typenum::U512;
type MaxDepositRequests = typenum::U8192;
type MaxWithdrawalRequests = typenum::U16;
type MaxConsolidationRequests = typenum::U2;
}
#[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)]
pub struct MinimalConsensusSpec;
impl ConsensusSpec for MinimalConsensusSpec {
type MaxProposerSlashings = typenum::U16;
type MaxAttesterSlashings = typenum::U2;
type MaxAttesterSlashingsElectra = typenum::U1;
type MaxAttestations = typenum::U128;
type MaxAttestationsElectra = typenum::U8;
type MaxCommitteesPerSlot = typenum::U4;
type MaxValidatorsPerSlot = typenum::U8192;
type MaxDeposits = typenum::U16;
type MaxVoluntaryExits = typenum::U16;
type MaxBlsToExecutionChanged = typenum::U16;
type MaxBlobKzgCommitments = typenum::U4096;
type MaxWithdrawals = typenum::U16;
type MaxValidatorsPerCommitee = typenum::U2048;
type SlotsPerEpoch = typenum::U8;
type EpochsPerSyncCommiteePeriod = typenum::U8;
type SyncCommitteeSize = typenum::U32;
type MaxDepositRequests = typenum::U4;
type MaxWithdrawalRequests = typenum::U2;
type MaxConsolidationRequests = typenum::U1;
}