mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Remove INVALID_TERMINAL_BLOCK (#3385)
## Issue Addressed Resolves #3379 ## Proposed Changes Remove instances of `InvalidTerminalBlock` in lighthouse and use `Invalid {latest_valid_hash: "0x0000000000000000000000000000000000000000000000000000000000000000"}` to represent that status.
This commit is contained in:
@@ -4084,21 +4084,32 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
"Fork choice update invalidated payload";
|
||||
"status" => ?status
|
||||
);
|
||||
// The execution engine has stated that all blocks between the
|
||||
// `head_execution_block_hash` and `latest_valid_hash` are invalid.
|
||||
self.process_invalid_execution_payload(
|
||||
&InvalidationOperation::InvalidateMany {
|
||||
head_block_root,
|
||||
always_invalidate_head: true,
|
||||
latest_valid_ancestor: latest_valid_hash,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
// This implies that the terminal block was invalid. We are being explicit in
|
||||
// invalidating only the head block in this case.
|
||||
if latest_valid_hash == ExecutionBlockHash::zero() {
|
||||
self.process_invalid_execution_payload(
|
||||
&InvalidationOperation::InvalidateOne {
|
||||
block_root: head_block_root,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
// The execution engine has stated that all blocks between the
|
||||
// `head_execution_block_hash` and `latest_valid_hash` are invalid.
|
||||
self.process_invalid_execution_payload(
|
||||
&InvalidationOperation::InvalidateMany {
|
||||
head_block_root,
|
||||
always_invalidate_head: true,
|
||||
latest_valid_ancestor: latest_valid_hash,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Err(BeaconChainError::ExecutionForkChoiceUpdateInvalid { status })
|
||||
}
|
||||
PayloadStatus::InvalidTerminalBlock { .. }
|
||||
| PayloadStatus::InvalidBlockHash { .. } => {
|
||||
PayloadStatus::InvalidBlockHash { .. } => {
|
||||
warn!(
|
||||
self.log,
|
||||
"Fork choice update invalidated payload";
|
||||
|
||||
@@ -114,6 +114,11 @@ async fn notify_new_payload<'a, T: BeaconChainTypes>(
|
||||
PayloadStatus::Invalid {
|
||||
latest_valid_hash, ..
|
||||
} => {
|
||||
// latest_valid_hash == 0 implies that this was the terminal block
|
||||
// Hence, we don't need to run `BeaconChain::process_invalid_execution_payload`.
|
||||
if latest_valid_hash == ExecutionBlockHash::zero() {
|
||||
return Err(ExecutionPayloadError::RejectedByExecutionEngine { status }.into());
|
||||
}
|
||||
// This block has not yet been applied to fork choice, so the latest block that was
|
||||
// imported to fork choice was the parent.
|
||||
let latest_root = block.parent_root();
|
||||
@@ -127,7 +132,7 @@ async fn notify_new_payload<'a, T: BeaconChainTypes>(
|
||||
|
||||
Err(ExecutionPayloadError::RejectedByExecutionEngine { status }.into())
|
||||
}
|
||||
PayloadStatus::InvalidTerminalBlock { .. } | PayloadStatus::InvalidBlockHash { .. } => {
|
||||
PayloadStatus::InvalidBlockHash { .. } => {
|
||||
// Returning an error here should be sufficient to invalidate the block. We have no
|
||||
// information to indicate its parent is invalid, so no need to run
|
||||
// `BeaconChain::process_invalid_execution_payload`.
|
||||
|
||||
Reference in New Issue
Block a user