mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Remove head_payload_status from ForkchoiceUpdateParameters
head_payload_status is internal fork choice state, not an EL forkchoiceUpdated parameter. It already lives on CachedHead — source it directly from get_head() return in recompute_head_at_slot instead of threading through ForkchoiceUpdateParameters. Also add TODO(gloas) for parent_head_hash in re-org path (V29 nodes don't carry execution_status).
This commit is contained in:
@@ -4898,6 +4898,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
return Err(Box::new(DoNotReOrg::HeadNotLate.into()));
|
return Err(Box::new(DoNotReOrg::HeadNotLate.into()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(gloas): V29 nodes don't carry execution_status, so this returns
|
||||||
|
// None for post-Gloas re-orgs. Need to source the EL block hash from
|
||||||
|
// the bid's block_hash instead. Re-org is disabled for Gloas for now.
|
||||||
let parent_head_hash = info
|
let parent_head_hash = info
|
||||||
.parent_node
|
.parent_node
|
||||||
.execution_status()
|
.execution_status()
|
||||||
@@ -4905,7 +4908,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
.and_then(|execution_status| execution_status.block_hash());
|
.and_then(|execution_status| execution_status.block_hash());
|
||||||
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
||||||
head_root: info.parent_node.root(),
|
head_root: info.parent_node.root(),
|
||||||
head_payload_status: canonical_forkchoice_params.head_payload_status,
|
|
||||||
head_hash: parent_head_hash,
|
head_hash: parent_head_hash,
|
||||||
justified_hash: canonical_forkchoice_params.justified_hash,
|
justified_hash: canonical_forkchoice_params.justified_hash,
|
||||||
finalized_hash: canonical_forkchoice_params.finalized_hash,
|
finalized_hash: canonical_forkchoice_params.finalized_hash,
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ impl<E: EthSpec> CachedHead<E> {
|
|||||||
pub fn forkchoice_update_parameters(&self) -> ForkchoiceUpdateParameters {
|
pub fn forkchoice_update_parameters(&self) -> ForkchoiceUpdateParameters {
|
||||||
ForkchoiceUpdateParameters {
|
ForkchoiceUpdateParameters {
|
||||||
head_root: self.snapshot.beacon_block_root,
|
head_root: self.snapshot.beacon_block_root,
|
||||||
head_payload_status: self.head_payload_status,
|
|
||||||
head_hash: self.head_hash,
|
head_hash: self.head_hash,
|
||||||
justified_hash: self.justified_hash,
|
justified_hash: self.justified_hash,
|
||||||
finalized_hash: self.finalized_hash,
|
finalized_hash: self.finalized_hash,
|
||||||
@@ -276,7 +275,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
|||||||
snapshot,
|
snapshot,
|
||||||
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
||||||
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
||||||
head_payload_status: forkchoice_update_params.head_payload_status,
|
head_payload_status: proto_array::PayloadStatus::Pending,
|
||||||
head_hash: forkchoice_update_params.head_hash,
|
head_hash: forkchoice_update_params.head_hash,
|
||||||
justified_hash: forkchoice_update_params.justified_hash,
|
justified_hash: forkchoice_update_params.justified_hash,
|
||||||
finalized_hash: forkchoice_update_params.finalized_hash,
|
finalized_hash: forkchoice_update_params.finalized_hash,
|
||||||
@@ -337,7 +336,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
|||||||
snapshot: Arc::new(snapshot),
|
snapshot: Arc::new(snapshot),
|
||||||
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
||||||
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
||||||
head_payload_status: forkchoice_update_params.head_payload_status,
|
head_payload_status: proto_array::PayloadStatus::Pending,
|
||||||
head_hash: forkchoice_update_params.head_hash,
|
head_hash: forkchoice_update_params.head_hash,
|
||||||
justified_hash: forkchoice_update_params.justified_hash,
|
justified_hash: forkchoice_update_params.justified_hash,
|
||||||
finalized_hash: forkchoice_update_params.finalized_hash,
|
finalized_hash: forkchoice_update_params.finalized_hash,
|
||||||
@@ -615,15 +614,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
// was last run.
|
// was last run.
|
||||||
let old_view = ForkChoiceView {
|
let old_view = ForkChoiceView {
|
||||||
head_block_root: old_cached_head.head_block_root(),
|
head_block_root: old_cached_head.head_block_root(),
|
||||||
head_payload_status: old_cached_head.head_payload_status(),
|
|
||||||
justified_checkpoint: old_cached_head.justified_checkpoint(),
|
justified_checkpoint: old_cached_head.justified_checkpoint(),
|
||||||
finalized_checkpoint: old_cached_head.finalized_checkpoint(),
|
finalized_checkpoint: old_cached_head.finalized_checkpoint(),
|
||||||
};
|
};
|
||||||
|
let old_payload_status = old_cached_head.head_payload_status();
|
||||||
|
|
||||||
let mut fork_choice_write_lock = self.canonical_head.fork_choice_write_lock();
|
let mut fork_choice_write_lock = self.canonical_head.fork_choice_write_lock();
|
||||||
|
|
||||||
// Recompute the current head via the fork choice algorithm.
|
// Recompute the current head via the fork choice algorithm.
|
||||||
let _ = fork_choice_write_lock.get_head(current_slot, &self.spec)?;
|
let (_, new_payload_status) = fork_choice_write_lock.get_head(current_slot, &self.spec)?;
|
||||||
|
|
||||||
// Downgrade the fork choice write-lock to a read lock, without allowing access to any
|
// Downgrade the fork choice write-lock to a read lock, without allowing access to any
|
||||||
// other writers.
|
// other writers.
|
||||||
@@ -668,9 +667,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exit early if the head or justified/finalized checkpoints have not changed, there's
|
// Exit early if the head, checkpoints, and payload status have not changed.
|
||||||
// nothing to do.
|
if new_view == old_view && new_payload_status == old_payload_status {
|
||||||
if new_view == old_view {
|
|
||||||
debug!(
|
debug!(
|
||||||
head = ?new_view.head_block_root,
|
head = ?new_view.head_block_root,
|
||||||
"No change in canonical head"
|
"No change in canonical head"
|
||||||
@@ -727,7 +725,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
snapshot: Arc::new(new_snapshot),
|
snapshot: Arc::new(new_snapshot),
|
||||||
justified_checkpoint: new_view.justified_checkpoint,
|
justified_checkpoint: new_view.justified_checkpoint,
|
||||||
finalized_checkpoint: new_view.finalized_checkpoint,
|
finalized_checkpoint: new_view.finalized_checkpoint,
|
||||||
head_payload_status: new_forkchoice_update_parameters.head_payload_status,
|
head_payload_status: new_payload_status,
|
||||||
head_hash: new_forkchoice_update_parameters.head_hash,
|
head_hash: new_forkchoice_update_parameters.head_hash,
|
||||||
justified_hash: new_forkchoice_update_parameters.justified_hash,
|
justified_hash: new_forkchoice_update_parameters.justified_hash,
|
||||||
finalized_hash: new_forkchoice_update_parameters.finalized_hash,
|
finalized_hash: new_forkchoice_update_parameters.finalized_hash,
|
||||||
@@ -755,7 +753,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
snapshot: old_cached_head.snapshot.clone(),
|
snapshot: old_cached_head.snapshot.clone(),
|
||||||
justified_checkpoint: new_view.justified_checkpoint,
|
justified_checkpoint: new_view.justified_checkpoint,
|
||||||
finalized_checkpoint: new_view.finalized_checkpoint,
|
finalized_checkpoint: new_view.finalized_checkpoint,
|
||||||
head_payload_status: new_forkchoice_update_parameters.head_payload_status,
|
head_payload_status: new_payload_status,
|
||||||
head_hash: new_forkchoice_update_parameters.head_hash,
|
head_hash: new_forkchoice_update_parameters.head_hash,
|
||||||
justified_hash: new_forkchoice_update_parameters.justified_hash,
|
justified_hash: new_forkchoice_update_parameters.justified_hash,
|
||||||
finalized_hash: new_forkchoice_update_parameters.finalized_hash,
|
finalized_hash: new_forkchoice_update_parameters.finalized_hash,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use eth2::{
|
|||||||
BeaconNodeHttpClient, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER,
|
BeaconNodeHttpClient, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER,
|
||||||
Timeouts,
|
Timeouts,
|
||||||
};
|
};
|
||||||
use fork_choice::{ForkchoiceUpdateParameters, PayloadStatus as FcPayloadStatus};
|
use fork_choice::ForkchoiceUpdateParameters;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use sensitive_url::SensitiveUrl;
|
use sensitive_url::SensitiveUrl;
|
||||||
use ssz::Encode;
|
use ssz::Encode;
|
||||||
@@ -934,7 +934,6 @@ impl<E: EthSpec> MockBuilder<E> {
|
|||||||
finalized_hash: Some(finalized_execution_hash),
|
finalized_hash: Some(finalized_execution_hash),
|
||||||
justified_hash: Some(justified_execution_hash),
|
justified_hash: Some(justified_execution_hash),
|
||||||
head_root: head_block_root,
|
head_root: head_block_root,
|
||||||
head_payload_status: FcPayloadStatus::Pending,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let _status = self
|
let _status = self
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ impl<E: EthSpec> MockExecutionLayer<E> {
|
|||||||
let head_block_root = Hash256::repeat_byte(42);
|
let head_block_root = Hash256::repeat_byte(42);
|
||||||
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
||||||
head_root: head_block_root,
|
head_root: head_block_root,
|
||||||
head_payload_status: fork_choice::PayloadStatus::Pending,
|
|
||||||
head_hash: Some(parent_hash),
|
head_hash: Some(parent_hash),
|
||||||
justified_hash: None,
|
justified_hash: None,
|
||||||
finalized_hash: None,
|
finalized_hash: None,
|
||||||
|
|||||||
@@ -342,7 +342,6 @@ pub enum AttestationFromBlock {
|
|||||||
pub struct ForkchoiceUpdateParameters {
|
pub struct ForkchoiceUpdateParameters {
|
||||||
/// The most recent result of running `ForkChoice::get_head`.
|
/// The most recent result of running `ForkChoice::get_head`.
|
||||||
pub head_root: Hash256,
|
pub head_root: Hash256,
|
||||||
pub head_payload_status: PayloadStatus,
|
|
||||||
pub head_hash: Option<ExecutionBlockHash>,
|
pub head_hash: Option<ExecutionBlockHash>,
|
||||||
pub justified_hash: Option<ExecutionBlockHash>,
|
pub justified_hash: Option<ExecutionBlockHash>,
|
||||||
pub finalized_hash: Option<ExecutionBlockHash>,
|
pub finalized_hash: Option<ExecutionBlockHash>,
|
||||||
@@ -351,7 +350,6 @@ pub struct ForkchoiceUpdateParameters {
|
|||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct ForkChoiceView {
|
pub struct ForkChoiceView {
|
||||||
pub head_block_root: Hash256,
|
pub head_block_root: Hash256,
|
||||||
pub head_payload_status: PayloadStatus,
|
|
||||||
pub justified_checkpoint: Checkpoint,
|
pub justified_checkpoint: Checkpoint,
|
||||||
pub finalized_checkpoint: Checkpoint,
|
pub finalized_checkpoint: Checkpoint,
|
||||||
}
|
}
|
||||||
@@ -483,7 +481,6 @@ where
|
|||||||
finalized_hash: None,
|
finalized_hash: None,
|
||||||
// These will be updated during the next call to `Self::get_head`.
|
// These will be updated during the next call to `Self::get_head`.
|
||||||
head_root: Hash256::zero(),
|
head_root: Hash256::zero(),
|
||||||
head_payload_status: PayloadStatus::Pending,
|
|
||||||
},
|
},
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
@@ -588,7 +585,6 @@ where
|
|||||||
.and_then(|b| b.execution_status.block_hash());
|
.and_then(|b| b.execution_status.block_hash());
|
||||||
self.forkchoice_update_parameters = ForkchoiceUpdateParameters {
|
self.forkchoice_update_parameters = ForkchoiceUpdateParameters {
|
||||||
head_root,
|
head_root,
|
||||||
head_payload_status,
|
|
||||||
head_hash,
|
head_hash,
|
||||||
justified_hash,
|
justified_hash,
|
||||||
finalized_hash,
|
finalized_hash,
|
||||||
@@ -684,7 +680,6 @@ where
|
|||||||
pub fn cached_fork_choice_view(&self) -> ForkChoiceView {
|
pub fn cached_fork_choice_view(&self) -> ForkChoiceView {
|
||||||
ForkChoiceView {
|
ForkChoiceView {
|
||||||
head_block_root: self.forkchoice_update_parameters.head_root,
|
head_block_root: self.forkchoice_update_parameters.head_root,
|
||||||
head_payload_status: self.forkchoice_update_parameters.head_payload_status,
|
|
||||||
justified_checkpoint: self.justified_checkpoint(),
|
justified_checkpoint: self.justified_checkpoint(),
|
||||||
finalized_checkpoint: self.finalized_checkpoint(),
|
finalized_checkpoint: self.finalized_checkpoint(),
|
||||||
}
|
}
|
||||||
@@ -1769,7 +1764,6 @@ where
|
|||||||
finalized_hash: None,
|
finalized_hash: None,
|
||||||
// Will be updated in the following call to `Self::get_head`.
|
// Will be updated in the following call to `Self::get_head`.
|
||||||
head_root: Hash256::zero(),
|
head_root: Hash256::zero(),
|
||||||
head_payload_status: PayloadStatus::Pending,
|
|
||||||
},
|
},
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use execution_layer::{
|
|||||||
LATEST_TAG, PayloadAttributes, PayloadParameters, PayloadStatus,
|
LATEST_TAG, PayloadAttributes, PayloadParameters, PayloadStatus,
|
||||||
};
|
};
|
||||||
use fixed_bytes::FixedBytesExtended;
|
use fixed_bytes::FixedBytesExtended;
|
||||||
use fork_choice::{ForkchoiceUpdateParameters, PayloadStatus as FcPayloadStatus};
|
use fork_choice::ForkchoiceUpdateParameters;
|
||||||
use reqwest::{Client, header::CONTENT_TYPE};
|
use reqwest::{Client, header::CONTENT_TYPE};
|
||||||
use sensitive_url::SensitiveUrl;
|
use sensitive_url::SensitiveUrl;
|
||||||
use serde_json::{Value, json};
|
use serde_json::{Value, json};
|
||||||
@@ -294,7 +294,6 @@ impl<Engine: GenericExecutionEngine> TestRig<Engine> {
|
|||||||
let finalized_block_hash = ExecutionBlockHash::zero();
|
let finalized_block_hash = ExecutionBlockHash::zero();
|
||||||
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
let forkchoice_update_params = ForkchoiceUpdateParameters {
|
||||||
head_root,
|
head_root,
|
||||||
head_payload_status: FcPayloadStatus::Pending,
|
|
||||||
head_hash: Some(parent_hash),
|
head_hash: Some(parent_hash),
|
||||||
justified_hash: Some(justified_block_hash),
|
justified_hash: Some(justified_block_hash),
|
||||||
finalized_hash: Some(finalized_block_hash),
|
finalized_hash: Some(finalized_block_hash),
|
||||||
|
|||||||
Reference in New Issue
Block a user