mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-29 02:33:48 +00:00
Disallow attesting to optimistic head (#3140)
## Issue Addressed NA ## Proposed Changes Disallow the production of attestations and retrieval of unaggregated attestations when they reference an optimistic head. Add tests to this end. I also moved `BeaconChain::produce_unaggregated_attestation_for_block` to the `BeaconChainHarness`. It was only being used during tests, so it's nice to stop pretending it's production code. I also needed something that could produce attestations to optimistic blocks in order to simulate scenarios where the justified checkpoint is determined invalid (if no one would attest to an optimistic block, we could never justify it and then flip it to invalid). ## Additional Info - ~~Blocked on #3126~~
This commit is contained in:
@@ -122,11 +122,22 @@ pub enum PayloadVerificationStatus {
|
||||
/// An EL has declared the execution payload to be valid.
|
||||
Verified,
|
||||
/// An EL has not yet made a determination about the execution payload.
|
||||
NotVerified,
|
||||
Optimistic,
|
||||
/// The block is either pre-merge-fork, or prior to the terminal PoW block.
|
||||
Irrelevant,
|
||||
}
|
||||
|
||||
impl PayloadVerificationStatus {
|
||||
/// Returns `true` if the payload was optimistically imported.
|
||||
pub fn is_optimistic(&self) -> bool {
|
||||
match self {
|
||||
PayloadVerificationStatus::Verified => false,
|
||||
PayloadVerificationStatus::Optimistic => true,
|
||||
PayloadVerificationStatus::Irrelevant => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate how far `slot` lies from the start of its epoch.
|
||||
///
|
||||
/// ## Specification
|
||||
@@ -668,7 +679,9 @@ where
|
||||
} else {
|
||||
match payload_verification_status {
|
||||
PayloadVerificationStatus::Verified => ExecutionStatus::Valid(block_hash),
|
||||
PayloadVerificationStatus::NotVerified => ExecutionStatus::Unknown(block_hash),
|
||||
PayloadVerificationStatus::Optimistic => {
|
||||
ExecutionStatus::Optimistic(block_hash)
|
||||
}
|
||||
// It would be a logic error to declare a block irrelevant if it has an
|
||||
// execution payload with a non-zero block hash.
|
||||
PayloadVerificationStatus::Irrelevant => {
|
||||
@@ -944,6 +957,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an `ExecutionStatus` if the block is known **and** a descendant of the finalized root.
|
||||
pub fn get_block_execution_status(&self, block_root: &Hash256) -> Option<ExecutionStatus> {
|
||||
if self.is_descendant_of_finalized(*block_root) {
|
||||
self.proto_array.get_block_execution_status(block_root)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the `ProtoBlock` for the justified checkpoint.
|
||||
///
|
||||
/// ## Notes
|
||||
|
||||
@@ -6,4 +6,4 @@ pub use crate::fork_choice::{
|
||||
PayloadVerificationStatus, PersistedForkChoice, QueuedAttestation,
|
||||
};
|
||||
pub use fork_choice_store::ForkChoiceStore;
|
||||
pub use proto_array::{Block as ProtoBlock, InvalidationOperation};
|
||||
pub use proto_array::{Block as ProtoBlock, ExecutionStatus, InvalidationOperation};
|
||||
|
||||
Reference in New Issue
Block a user