Skip to content

Commit

Permalink
Remove inconsistent head errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jun 28, 2022
1 parent 161c923 commit 1a4bb67
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
2 changes: 0 additions & 2 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1798,8 +1798,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let _timer = metrics::start_timer(&metrics::FORK_CHOICE_PROCESS_ATTESTATION_TIMES);

self.canonical_head
// TODO(paul): consider the implications of each attestation taking a write-lock on
// fork choice.
.write()
.fork_choice
.on_attestation(
Expand Down
16 changes: 1 addition & 15 deletions beacon_node/beacon_chain/src/canonical_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,12 @@ impl FastCanonicalHead {
let state = &head_snapshot.beacon_state;
let fork_choice_view = fork_choice.cached_fork_choice_view();

if fork_choice_view.head_block_root != head_snapshot.beacon_block_root {
return Err(Error::InconsistentForkChoiceView {
view: fork_choice_view.head_block_root,
snapshot: head_snapshot.beacon_block_root,
});
}

let active_validator_count = state
.get_active_validator_indices(state.current_epoch(), spec)?
.len();

Ok(Self {
head_block_root: fork_choice_view.head_block_root,
head_block_root: head_snapshot.beacon_block_root,
head_block_slot: head_snapshot.beacon_block.slot(),
justified_checkpoint: fork_choice_view.justified_checkpoint,
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
Expand Down Expand Up @@ -144,13 +137,6 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
) -> Result<Self, Error> {
let fork_choice_view = fork_choice.cached_fork_choice_view();

if fork_choice_view.head_block_root != head_snapshot.beacon_block_root {
return Err(Error::InconsistentForkChoiceView {
view: fork_choice_view.head_block_root,
snapshot: head_snapshot.beacon_block_root,
});
}

Ok(Self {
fork_choice,
justified_checkpoint: fork_choice_view.justified_checkpoint,
Expand Down
4 changes: 0 additions & 4 deletions beacon_node/beacon_chain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ pub enum BeaconChainError {
},
AttestationHeadNotInForkChoice(Hash256),
MissingPersistedForkChoice,
InconsistentForkChoiceView {
view: Hash256,
snapshot: Hash256,
},
}

easy_from_to!(SlotProcessingError, BeaconChainError);
Expand Down

0 comments on commit 1a4bb67

Please sign in to comment.