mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
Gloas alpha spec 8 (#9315)
https://github.com/ethereum/consensus-specs/releases/tag/v1.7.0-alpha.8 Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu> Co-Authored-By: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -91,8 +91,8 @@ SYNC_MESSAGE_DUE_BPS: 3333
|
||||
CONTRIBUTION_DUE_BPS: 6667
|
||||
|
||||
# Gloas
|
||||
# 2**6 (= 64) epochs
|
||||
MIN_BUILDER_WITHDRAWABILITY_DELAY: 64
|
||||
# 2**13 (= 8192) epochs
|
||||
MIN_BUILDER_WITHDRAWABILITY_DELAY: 8192
|
||||
# 2500 basis points, 25% of SLOT_DURATION_MS
|
||||
ATTESTATION_DUE_BPS_GLOAS: 2500
|
||||
# 5000 basis points, 50% of SLOT_DURATION_MS
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct ProposerPreferences {
|
||||
pub proposal_slot: Slot,
|
||||
pub validator_index: u64,
|
||||
pub fee_recipient: Address,
|
||||
pub gas_limit: u64,
|
||||
pub target_gas_limit: u64,
|
||||
}
|
||||
|
||||
impl SignedRoot for ProposerPreferences {}
|
||||
|
||||
@@ -108,6 +108,7 @@ pub struct ChainSpec {
|
||||
pub proposer_reorg_cutoff_bps: u64,
|
||||
pub attestation_due_bps: u64,
|
||||
pub attestation_due_bps_gloas: u64,
|
||||
pub payload_due_bps: u64,
|
||||
pub payload_attestation_due_bps: u64,
|
||||
pub aggregate_due_bps: u64,
|
||||
pub sync_message_due_bps: u64,
|
||||
@@ -118,6 +119,7 @@ pub struct ChainSpec {
|
||||
*/
|
||||
pub unaggregated_attestation_due: Duration,
|
||||
pub unaggregated_attestation_due_gloas: Duration,
|
||||
pub payload_due: Duration,
|
||||
pub payload_attestation_due: Duration,
|
||||
pub aggregate_attestation_due: Duration,
|
||||
pub sync_message_due: Duration,
|
||||
@@ -894,6 +896,11 @@ impl ChainSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// Spec: `get_payload_due_ms`.
|
||||
pub fn get_payload_due(&self) -> Duration {
|
||||
self.payload_due
|
||||
}
|
||||
|
||||
/// Spec: `get_payload_attestation_due_ms`.
|
||||
pub fn get_payload_attestation_due(&self) -> Duration {
|
||||
self.payload_attestation_due
|
||||
@@ -974,6 +981,9 @@ impl ChainSpec {
|
||||
self.unaggregated_attestation_due_gloas = self
|
||||
.compute_slot_component_duration(self.attestation_due_bps_gloas)
|
||||
.expect("invalid chain spec: cannot compute unaggregated_attestation_due_gloas");
|
||||
self.payload_due = self
|
||||
.compute_slot_component_duration(self.payload_due_bps)
|
||||
.expect("invalid chain spec: cannot compute payload_due");
|
||||
self.payload_attestation_due = self
|
||||
.compute_slot_component_duration(self.payload_attestation_due_bps)
|
||||
.expect("invalid chain spec: cannot compute payload_attestation_due");
|
||||
@@ -1108,6 +1118,7 @@ impl ChainSpec {
|
||||
proposer_reorg_cutoff_bps: 1667,
|
||||
attestation_due_bps: 3333,
|
||||
attestation_due_bps_gloas: 2500,
|
||||
payload_due_bps: 7500,
|
||||
payload_attestation_due_bps: 7500,
|
||||
aggregate_due_bps: 6667,
|
||||
sync_message_due_bps: 3333,
|
||||
@@ -1118,6 +1129,7 @@ impl ChainSpec {
|
||||
*/
|
||||
unaggregated_attestation_due: Duration::from_millis(3999),
|
||||
unaggregated_attestation_due_gloas: Duration::from_millis(3000),
|
||||
payload_due: Duration::from_millis(9000),
|
||||
payload_attestation_due: Duration::from_millis(9000),
|
||||
aggregate_attestation_due: Duration::from_millis(8000),
|
||||
sync_message_due: Duration::from_millis(3999),
|
||||
@@ -1270,7 +1282,7 @@ impl ChainSpec {
|
||||
gloas_fork_epoch: None,
|
||||
builder_payment_threshold_numerator: 6,
|
||||
builder_payment_threshold_denominator: 10,
|
||||
min_builder_withdrawability_delay: Epoch::new(64),
|
||||
min_builder_withdrawability_delay: Epoch::new(8192),
|
||||
churn_limit_quotient_gloas: option_wrapper(|| u64::checked_pow(2, 15))
|
||||
.expect("calculation does not overflow"),
|
||||
consolidation_churn_limit_quotient: option_wrapper(|| u64::checked_pow(2, 16))
|
||||
@@ -1440,6 +1452,7 @@ impl ChainSpec {
|
||||
*/
|
||||
unaggregated_attestation_due: Duration::from_millis(1999),
|
||||
unaggregated_attestation_due_gloas: Duration::from_millis(1500),
|
||||
payload_due: Duration::from_millis(4500),
|
||||
payload_attestation_due: Duration::from_millis(4500),
|
||||
aggregate_attestation_due: Duration::from_millis(4000),
|
||||
sync_message_due: Duration::from_millis(1999),
|
||||
@@ -1531,6 +1544,7 @@ impl ChainSpec {
|
||||
proposer_reorg_cutoff_bps: 1667,
|
||||
attestation_due_bps: 3333,
|
||||
attestation_due_bps_gloas: 2500,
|
||||
payload_due_bps: 7500,
|
||||
payload_attestation_due_bps: 7500,
|
||||
aggregate_due_bps: 6667,
|
||||
|
||||
@@ -1540,6 +1554,7 @@ impl ChainSpec {
|
||||
*/
|
||||
unaggregated_attestation_due: Duration::from_millis(1666),
|
||||
unaggregated_attestation_due_gloas: Duration::from_millis(1250),
|
||||
payload_due: Duration::from_millis(3750),
|
||||
payload_attestation_due: Duration::from_millis(3750),
|
||||
aggregate_attestation_due: Duration::from_millis(3333),
|
||||
sync_message_due: Duration::from_millis(1666),
|
||||
@@ -1693,7 +1708,7 @@ impl ChainSpec {
|
||||
gloas_fork_epoch: None,
|
||||
builder_payment_threshold_numerator: 6,
|
||||
builder_payment_threshold_denominator: 10,
|
||||
min_builder_withdrawability_delay: Epoch::new(64),
|
||||
min_builder_withdrawability_delay: Epoch::new(8192),
|
||||
churn_limit_quotient_gloas: option_wrapper(|| u64::checked_pow(2, 15))
|
||||
.expect("calculation does not overflow"),
|
||||
consolidation_churn_limit_quotient: option_wrapper(|| u64::checked_pow(2, 16))
|
||||
@@ -2136,6 +2151,9 @@ pub struct Config {
|
||||
#[serde(default = "default_attestation_due_bps_gloas")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
attestation_due_bps_gloas: u64,
|
||||
#[serde(default = "default_payload_due_bps")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
payload_due_bps: u64,
|
||||
#[serde(default = "default_payload_attestation_due_bps")]
|
||||
#[serde(with = "serde_utils::quoted_u64")]
|
||||
payload_attestation_due_bps: u64,
|
||||
@@ -2379,6 +2397,10 @@ const fn default_attestation_due_bps_gloas() -> u64 {
|
||||
2500
|
||||
}
|
||||
|
||||
const fn default_payload_due_bps() -> u64 {
|
||||
7500
|
||||
}
|
||||
|
||||
const fn default_payload_attestation_due_bps() -> u64 {
|
||||
7500
|
||||
}
|
||||
@@ -2396,7 +2418,7 @@ const fn default_contribution_due_bps() -> u64 {
|
||||
}
|
||||
|
||||
const fn default_min_builder_withdrawability_delay() -> u64 {
|
||||
64
|
||||
8192
|
||||
}
|
||||
|
||||
const fn default_churn_limit_quotient_gloas() -> u64 {
|
||||
@@ -2656,6 +2678,7 @@ impl Config {
|
||||
proposer_reorg_cutoff_bps: spec.proposer_reorg_cutoff_bps,
|
||||
attestation_due_bps: spec.attestation_due_bps,
|
||||
attestation_due_bps_gloas: spec.attestation_due_bps_gloas,
|
||||
payload_due_bps: spec.payload_due_bps,
|
||||
payload_attestation_due_bps: spec.payload_attestation_due_bps,
|
||||
aggregate_due_bps: spec.aggregate_due_bps,
|
||||
sync_message_due_bps: spec.sync_message_due_bps,
|
||||
@@ -2759,6 +2782,7 @@ impl Config {
|
||||
proposer_reorg_cutoff_bps,
|
||||
attestation_due_bps,
|
||||
attestation_due_bps_gloas,
|
||||
payload_due_bps,
|
||||
payload_attestation_due_bps,
|
||||
aggregate_due_bps,
|
||||
sync_message_due_bps,
|
||||
@@ -2867,6 +2891,7 @@ impl Config {
|
||||
proposer_reorg_cutoff_bps,
|
||||
attestation_due_bps,
|
||||
attestation_due_bps_gloas,
|
||||
payload_due_bps,
|
||||
payload_attestation_due_bps,
|
||||
aggregate_due_bps,
|
||||
sync_message_due_bps,
|
||||
@@ -3694,6 +3719,30 @@ mod yaml_tests {
|
||||
let custom_spec = custom_spec.compute_derived_values::<MainnetEthSpec>();
|
||||
let tiny_due = custom_spec.get_unaggregated_attestation_due();
|
||||
assert_eq!(tiny_due, Duration::from_millis(1)); // 12000 * 1 / 10000 = 1.2 -> 1
|
||||
|
||||
// Test payload due (7500 bps = 75% of 12s = 9s)
|
||||
let spec = ChainSpec::mainnet().compute_derived_values::<MainnetEthSpec>();
|
||||
let payload_due = spec.get_payload_due();
|
||||
assert_eq!(payload_due, Duration::from_millis(9000)); // 12000 * 7500 / 10000
|
||||
|
||||
// Test payload attestation due (7500 bps = 75% of 12s = 9s)
|
||||
let payload_att_due = spec.get_payload_attestation_due();
|
||||
assert_eq!(payload_att_due, Duration::from_millis(9000)); // 12000 * 7500 / 10000
|
||||
|
||||
// Test gloas attestation due (2500 bps = 25% of 12s = 3s)
|
||||
assert_eq!(
|
||||
spec.unaggregated_attestation_due_gloas,
|
||||
Duration::from_millis(3000)
|
||||
); // 12000 * 2500 / 10000
|
||||
|
||||
// Test gloas with custom bps
|
||||
let mut custom_spec = spec;
|
||||
custom_spec.attestation_due_bps_gloas = 5000;
|
||||
let custom_spec = custom_spec.compute_derived_values::<MainnetEthSpec>();
|
||||
assert_eq!(
|
||||
custom_spec.unaggregated_attestation_due_gloas,
|
||||
Duration::from_millis(6000)
|
||||
); // 12000 * 5000 / 10000
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3715,6 +3764,19 @@ mod yaml_tests {
|
||||
Duration::from_millis(8000)
|
||||
);
|
||||
|
||||
// Mainnet payload due: 12000ms slots, 7500 bps = 9000ms
|
||||
assert_eq!(mainnet.get_payload_due(), Duration::from_millis(9000));
|
||||
assert_eq!(
|
||||
mainnet.get_payload_attestation_due(),
|
||||
Duration::from_millis(9000)
|
||||
);
|
||||
|
||||
// Mainnet gloas: 12000ms slots, 2500 bps = 3000ms
|
||||
assert_eq!(
|
||||
mainnet.unaggregated_attestation_due_gloas,
|
||||
Duration::from_millis(3000)
|
||||
);
|
||||
|
||||
// Minimal spec: 6000ms slots, 3333 bps = 1999ms, 6667 bps = 4000ms
|
||||
let minimal = ChainSpec::minimal();
|
||||
assert_eq!(
|
||||
@@ -3730,6 +3792,18 @@ mod yaml_tests {
|
||||
minimal.get_contribution_message_due(),
|
||||
Duration::from_millis(4000)
|
||||
);
|
||||
// Minimal payload due: 6000ms slots, 7500 bps = 4500ms
|
||||
assert_eq!(minimal.get_payload_due(), Duration::from_millis(4500));
|
||||
assert_eq!(
|
||||
minimal.get_payload_attestation_due(),
|
||||
Duration::from_millis(4500)
|
||||
);
|
||||
|
||||
// Minimal gloas: 6000ms slots, 2500 bps = 1500ms
|
||||
assert_eq!(
|
||||
minimal.unaggregated_attestation_due_gloas,
|
||||
Duration::from_millis(1500)
|
||||
);
|
||||
|
||||
// Gnosis spec: 5000ms slots, 3333 bps = 1666ms, 6667 bps = 3333ms
|
||||
let gnosis = ChainSpec::gnosis();
|
||||
@@ -3746,6 +3820,18 @@ mod yaml_tests {
|
||||
gnosis.get_contribution_message_due(),
|
||||
Duration::from_millis(3333)
|
||||
);
|
||||
// Gnosis payload due: 5000ms slots, 7500 bps = 3750ms
|
||||
assert_eq!(gnosis.get_payload_due(), Duration::from_millis(3750));
|
||||
assert_eq!(
|
||||
gnosis.get_payload_attestation_due(),
|
||||
Duration::from_millis(3750)
|
||||
);
|
||||
|
||||
// Gnosis gloas: 5000ms slots, 2500 bps = 1250ms
|
||||
assert_eq!(
|
||||
gnosis.unaggregated_attestation_due_gloas,
|
||||
Duration::from_millis(1250)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1333,6 +1333,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
pub fn is_valid_proposal_slot(
|
||||
&self,
|
||||
preferences: &ProposerPreferences,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<bool, BeaconStateError> {
|
||||
let current_epoch = self.current_epoch();
|
||||
let proposal_epoch = preferences.proposal_slot.epoch(E::slots_per_epoch());
|
||||
@@ -1341,8 +1342,7 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let next_epoch = current_epoch.saturating_add(1u64);
|
||||
if proposal_epoch > next_epoch {
|
||||
if proposal_epoch > current_epoch.saturating_add(spec.min_seed_lookahead) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user