mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-22 07:18:25 +00:00
vote sanity and genesis epoch fix
This commit is contained in:
@@ -312,14 +312,6 @@ fn dequeue_payload_attestations(
|
||||
}
|
||||
|
||||
/// Denotes whether an attestation we are processing was received from a block or from gossip.
|
||||
/// Equivalent to the `is_from_block` `bool` in:
|
||||
///
|
||||
/// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/fork-choice.md#validate_on_attestation
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum AttestationFromBlock {
|
||||
True,
|
||||
False,
|
||||
}
|
||||
|
||||
/// Parameters which are cached between calls to `ForkChoice::get_head`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -1056,7 +1048,7 @@ where
|
||||
fn validate_on_attestation(
|
||||
&self,
|
||||
indexed_attestation: IndexedAttestationRef<E>,
|
||||
is_from_block: AttestationFromBlock,
|
||||
is_from_block: bool,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), InvalidAttestation> {
|
||||
// There is no point in processing an attestation with an empty bitfield. Reject
|
||||
@@ -1070,7 +1062,7 @@ where
|
||||
|
||||
let target = indexed_attestation.data().target;
|
||||
|
||||
if matches!(is_from_block, AttestationFromBlock::False) {
|
||||
if !is_from_block {
|
||||
self.validate_target_epoch_against_current_time(target.epoch)?;
|
||||
}
|
||||
|
||||
@@ -1148,7 +1140,7 @@ where
|
||||
fn validate_on_payload_attestation(
|
||||
&self,
|
||||
indexed_payload_attestation: &IndexedPayloadAttestation<E>,
|
||||
_is_from_block: AttestationFromBlock,
|
||||
_is_from_block: bool,
|
||||
) -> Result<(), InvalidAttestation> {
|
||||
if indexed_payload_attestation.attesting_indices.is_empty() {
|
||||
return Err(InvalidAttestation::EmptyAggregationBitfield);
|
||||
@@ -1198,7 +1190,7 @@ where
|
||||
&mut self,
|
||||
system_time_current_slot: Slot,
|
||||
attestation: IndexedAttestationRef<E>,
|
||||
is_from_block: AttestationFromBlock,
|
||||
is_from_block: bool,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error<T::Error>> {
|
||||
let _timer = metrics::start_timer(&metrics::FORK_CHOICE_ON_ATTESTATION_TIMES);
|
||||
@@ -1251,7 +1243,7 @@ where
|
||||
&mut self,
|
||||
system_time_current_slot: Slot,
|
||||
attestation: &IndexedPayloadAttestation<E>,
|
||||
is_from_block: AttestationFromBlock,
|
||||
is_from_block: bool,
|
||||
) -> Result<(), Error<T::Error>> {
|
||||
self.update_time(system_time_current_slot)?;
|
||||
|
||||
@@ -1264,9 +1256,10 @@ where
|
||||
let processing_slot = self.fc_store.get_current_slot();
|
||||
// Payload attestations from blocks can be applied in the next slot (S+1 for data.slot=S),
|
||||
// while non-block payload attestations are delayed one extra slot.
|
||||
let should_process_now = match is_from_block {
|
||||
AttestationFromBlock::True => attestation.data.slot < processing_slot,
|
||||
AttestationFromBlock::False => attestation.data.slot + 1_u64 < processing_slot,
|
||||
let should_process_now = if is_from_block {
|
||||
attestation.data.slot < processing_slot
|
||||
} else {
|
||||
attestation.data.slot.saturating_add(1_u64) < processing_slot
|
||||
};
|
||||
|
||||
if should_process_now {
|
||||
|
||||
@@ -3,7 +3,7 @@ mod fork_choice_store;
|
||||
mod metrics;
|
||||
|
||||
pub use crate::fork_choice::{
|
||||
AttestationFromBlock, Error, ForkChoice, ForkChoiceView, ForkchoiceUpdateParameters,
|
||||
Error, ForkChoice, ForkChoiceView, ForkchoiceUpdateParameters,
|
||||
InvalidAttestation, InvalidBlock, PayloadVerificationStatus, PersistedForkChoice,
|
||||
PersistedForkChoiceV17, PersistedForkChoiceV28, PersistedForkChoiceV29, QueuedAttestation,
|
||||
QueuedPayloadAttestation, ResetPayloadStatuses,
|
||||
|
||||
@@ -10,7 +10,7 @@ use beacon_chain::{
|
||||
use bls::AggregateSignature;
|
||||
use fixed_bytes::FixedBytesExtended;
|
||||
use fork_choice::{
|
||||
AttestationFromBlock, ForkChoiceStore, InvalidAttestation, InvalidBlock,
|
||||
ForkChoiceStore, InvalidAttestation, InvalidBlock,
|
||||
PayloadVerificationStatus, QueuedAttestation, QueuedPayloadAttestation,
|
||||
};
|
||||
use state_processing::state_advance::complete_state_advance;
|
||||
@@ -1033,7 +1033,7 @@ async fn payload_attestation_for_previous_slot_is_accepted_at_next_slot() {
|
||||
.on_payload_attestation(
|
||||
current_slot,
|
||||
&payload_attestation,
|
||||
AttestationFromBlock::True,
|
||||
true,
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -1082,7 +1082,7 @@ async fn non_block_payload_attestation_at_next_slot_is_delayed() {
|
||||
let result = chain
|
||||
.canonical_head
|
||||
.fork_choice_write_lock()
|
||||
.on_payload_attestation(s_plus_1, &payload_attestation, AttestationFromBlock::False);
|
||||
.on_payload_attestation(s_plus_1, &payload_attestation, false);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"payload attestation should be accepted for queueing"
|
||||
|
||||
Reference in New Issue
Block a user