mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
Implement get_attester_head logic
This commit is contained in:
@@ -7267,6 +7267,32 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn set_unsatisfied_inclusion_list_block(self: &Arc<Self>, block_root: Hash256) -> Result<(), Error> {
|
||||
let chain = self.clone();
|
||||
let fork_choice_result = self
|
||||
.spawn_blocking_handle(
|
||||
move || {
|
||||
chain
|
||||
.canonical_head
|
||||
.fork_choice_write_lock()
|
||||
.on_invalid_inclusion_list_payload(block_root)
|
||||
},
|
||||
"invalid_inclusion_list_payload",
|
||||
)
|
||||
.await;
|
||||
|
||||
// Update fork choice.
|
||||
if let Err(e) = fork_choice_result {
|
||||
crit!(
|
||||
self.log,
|
||||
"Failed to process invalid inclusion list payload";
|
||||
"error" => ?e,
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn metrics(&self) -> BeaconChainMetrics {
|
||||
BeaconChainMetrics {
|
||||
reqresp_pre_import_cache_len: self.reqresp_pre_import_cache.read().len(),
|
||||
|
||||
@@ -141,6 +141,7 @@ pub struct BeaconForkChoiceStore<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<
|
||||
proposer_boost_root: Hash256,
|
||||
equivocating_indices: BTreeSet<u64>,
|
||||
inclusion_list_equivocators: HashMap<(Slot, Hash256), BTreeSet<u64>>,
|
||||
unsatisfied_inclusion_list_block: Hash256,
|
||||
_phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
@@ -191,6 +192,7 @@ where
|
||||
proposer_boost_root: Hash256::zero(),
|
||||
equivocating_indices: BTreeSet::new(),
|
||||
inclusion_list_equivocators: HashMap::new(),
|
||||
unsatisfied_inclusion_list_block: Hash256::zero(),
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -208,6 +210,7 @@ where
|
||||
unrealized_finalized_checkpoint: self.unrealized_finalized_checkpoint,
|
||||
proposer_boost_root: self.proposer_boost_root,
|
||||
equivocating_indices: self.equivocating_indices.clone(),
|
||||
unsatisfied_inclusion_list_block: self.unsatisfied_inclusion_list_block,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +233,7 @@ where
|
||||
proposer_boost_root: persisted.proposer_boost_root,
|
||||
equivocating_indices: persisted.equivocating_indices,
|
||||
inclusion_list_equivocators: HashMap::new(),
|
||||
unsatisfied_inclusion_list_block: persisted.unsatisfied_inclusion_list_block,
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -347,6 +351,14 @@ where
|
||||
fn extend_equivocating_indices(&mut self, indices: impl IntoIterator<Item = u64>) {
|
||||
self.equivocating_indices.extend(indices);
|
||||
}
|
||||
|
||||
fn set_unsatisfied_inclusion_list_block(&mut self, block_root: Hash256) {
|
||||
self.unsatisfied_inclusion_list_block = block_root;
|
||||
}
|
||||
|
||||
fn unsatisfied_inclusion_list_block(&self) -> Hash256 {
|
||||
self.unsatisfied_inclusion_list_block
|
||||
}
|
||||
}
|
||||
|
||||
pub type PersistedForkChoiceStore = PersistedForkChoiceStoreV17;
|
||||
@@ -363,4 +375,5 @@ pub struct PersistedForkChoiceStore {
|
||||
pub unrealized_finalized_checkpoint: Checkpoint,
|
||||
pub proposer_boost_root: Hash256,
|
||||
pub equivocating_indices: BTreeSet<u64>,
|
||||
pub unsatisfied_inclusion_list_block: Hash256,
|
||||
}
|
||||
|
||||
@@ -200,6 +200,13 @@ async fn notify_new_payload<'a, T: BeaconChainTypes>(
|
||||
// imported to fork choice was the parent.
|
||||
let latest_root = block.parent_root();
|
||||
|
||||
// If the payload is invalid because it didn't satisfy the inclusion lit
|
||||
// transactions for this slot, update the fork choice store before processing
|
||||
// the invalid EL payload.
|
||||
if *validation_error == Some("INVALID_INCLUSION_LIST".to_string()) {
|
||||
chain.set_unsatisfied_inclusion_list_block(block.tree_hash_root()).await?;
|
||||
}
|
||||
|
||||
chain
|
||||
.process_invalid_execution_payload(&InvalidationOperation::InvalidateMany {
|
||||
head_block_root: latest_root,
|
||||
|
||||
Reference in New Issue
Block a user