Remove CountUnrealized (#4357)

## Issue Addressed

Closes #4332

## Proposed Changes

Remove the `CountUnrealized` type, defaulting unrealized justification to _on_. This fixes the #4332 issue by ensuring that importing the same block to fork choice always results in the same outcome.

Finalized sync speed may be slightly impacted by this change, but that is deemed an acceptable trade-off until the optimisation from #4118 is implemented.

TODO:

- [x] Also check that the block isn't a duplicate before importing
This commit is contained in:
Michael Sproul
2023-06-16 06:44:31 +00:00
parent 77fc511170
commit affea585f4
19 changed files with 229 additions and 266 deletions

View File

@@ -17,9 +17,7 @@ use execution_layer::{
test_utils::ExecutionBlockGenerator,
ExecutionLayer, ForkchoiceState, PayloadAttributes,
};
use fork_choice::{
CountUnrealized, Error as ForkChoiceError, InvalidationOperation, PayloadVerificationStatus,
};
use fork_choice::{Error as ForkChoiceError, InvalidationOperation, PayloadVerificationStatus};
use logging::test_logger;
use proto_array::{Error as ProtoArrayError, ExecutionStatus};
use slot_clock::SlotClock;
@@ -698,7 +696,6 @@ async fn invalidates_all_descendants() {
.process_block(
fork_block.canonical_root(),
Arc::new(fork_block),
CountUnrealized::True,
NotifyExecutionLayer::Yes,
)
.await
@@ -795,7 +792,6 @@ async fn switches_heads() {
.process_block(
fork_block.canonical_root(),
Arc::new(fork_block),
CountUnrealized::True,
NotifyExecutionLayer::Yes,
)
.await
@@ -1050,7 +1046,7 @@ async fn invalid_parent() {
// Ensure the block built atop an invalid payload is invalid for import.
assert!(matches!(
rig.harness.chain.process_block(block.canonical_root(), block.clone(), CountUnrealized::True, NotifyExecutionLayer::Yes).await,
rig.harness.chain.process_block(block.canonical_root(), block.clone(), NotifyExecutionLayer::Yes).await,
Err(BlockError::ParentExecutionPayloadInvalid { parent_root: invalid_root })
if invalid_root == parent_root
));
@@ -1065,7 +1061,7 @@ async fn invalid_parent() {
&state,
PayloadVerificationStatus::Optimistic,
&rig.harness.chain.spec,
CountUnrealized::True,
),
Err(ForkChoiceError::ProtoArrayStringError(message))
if message.contains(&format!(
@@ -1336,12 +1332,7 @@ async fn build_optimistic_chain(
for block in blocks {
rig.harness
.chain
.process_block(
block.canonical_root(),
block,
CountUnrealized::True,
NotifyExecutionLayer::Yes,
)
.process_block(block.canonical_root(), block, NotifyExecutionLayer::Yes)
.await
.unwrap();
}
@@ -1900,7 +1891,6 @@ async fn recover_from_invalid_head_by_importing_blocks() {
.process_block(
fork_block.canonical_root(),
fork_block.clone(),
CountUnrealized::True,
NotifyExecutionLayer::Yes,
)
.await