mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-30 03:03:45 +00:00
Clarify name of on_valid_payload_envelope_received
This commit is contained in:
@@ -253,9 +253,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// avoiding taking other locks whilst holding this lock.
|
||||
let mut fork_choice = parking_lot::RwLockUpgradableReadGuard::upgrade(fork_choice_reader);
|
||||
|
||||
// Update the node's payload_status from PENDING to FULL in fork choice.
|
||||
// Update the block's payload to received in fork choice, which creates the `Full` virtual
|
||||
// node which can be eligible for head.
|
||||
fork_choice
|
||||
.on_execution_payload(block_root)
|
||||
.on_valid_payload_envelope_received(block_root)
|
||||
.map_err(|e| EnvelopeError::InternalError(format!("{e:?}")))?;
|
||||
|
||||
// TODO(gloas) emit SSE event if the payload became the new head payload
|
||||
|
||||
@@ -654,6 +654,20 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark a Gloas payload envelope as valid and received.
|
||||
///
|
||||
/// This must only be called for valid Gloas payloads.
|
||||
pub fn on_valid_payload_envelope_received(
|
||||
&mut self,
|
||||
block_root: Hash256,
|
||||
) -> Result<(), Error<T::Error>> {
|
||||
self.proto_array
|
||||
.on_valid_payload_envelope_received(block_root)
|
||||
.map_err(Error::FailedToProcessValidExecutionPayload)
|
||||
}
|
||||
|
||||
/// Pre-Gloas only.
|
||||
///
|
||||
/// See `ProtoArrayForkChoice::process_execution_payload_validation` for documentation.
|
||||
pub fn on_valid_execution_payload(
|
||||
&mut self,
|
||||
@@ -664,6 +678,8 @@ where
|
||||
.map_err(Error::FailedToProcessValidExecutionPayload)
|
||||
}
|
||||
|
||||
/// Pre-Gloas only.
|
||||
///
|
||||
/// See `ProtoArrayForkChoice::process_execution_payload_invalidation` for documentation.
|
||||
pub fn on_invalid_execution_payload(
|
||||
&mut self,
|
||||
@@ -977,12 +993,6 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn on_execution_payload(&mut self, block_root: Hash256) -> Result<(), Error<T::Error>> {
|
||||
self.proto_array
|
||||
.on_execution_payload(block_root)
|
||||
.map_err(Error::FailedToProcessValidExecutionPayload)
|
||||
}
|
||||
|
||||
/// Update checkpoints in store if necessary
|
||||
fn update_checkpoints(
|
||||
&mut self,
|
||||
|
||||
@@ -502,7 +502,7 @@ impl ForkChoiceTestDefinition {
|
||||
}
|
||||
Operation::ProcessExecutionPayload { block_root } => {
|
||||
fork_choice
|
||||
.on_execution_payload(block_root)
|
||||
.on_valid_payload_envelope_received(block_root)
|
||||
.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"on_execution_payload op at index {} returned error: {}",
|
||||
|
||||
@@ -768,12 +768,10 @@ impl ProtoArray {
|
||||
Ok(!has_equivocation)
|
||||
}
|
||||
|
||||
/// Process an execution payload for a Gloas block.
|
||||
/// Process a valid execution payload envelope for a Gloas block.
|
||||
///
|
||||
/// Sets `payload_received` to true, which makes `is_payload_timely` and
|
||||
/// `is_payload_data_available` return true regardless of PTC votes.
|
||||
/// This maps to `store.payload_states[root] = state` in the spec.
|
||||
pub fn on_valid_execution_payload(&mut self, block_root: Hash256) -> Result<(), Error> {
|
||||
/// Sets `payload_received` to true.
|
||||
pub fn on_valid_payload_envelope_received(&mut self, block_root: Hash256) -> Result<(), Error> {
|
||||
let index = *self
|
||||
.indices
|
||||
.get(&block_root)
|
||||
@@ -809,6 +807,8 @@ impl ProtoArray {
|
||||
|
||||
/// Updates the `verified_node_index` and all ancestors to have validated execution payloads.
|
||||
///
|
||||
/// This function is a no-op if called for a Gloas block.
|
||||
///
|
||||
/// Returns an error if:
|
||||
///
|
||||
/// - The `verified_node_index` is unknown.
|
||||
@@ -852,18 +852,10 @@ impl ProtoArray {
|
||||
});
|
||||
}
|
||||
},
|
||||
// Gloas nodes don't carry `ExecutionStatus`. Mark the validated
|
||||
// block as payload-received so that `is_payload_timely` /
|
||||
// `is_payload_data_available` and `index == 1` attestations work.
|
||||
ProtoNode::V29(node) => {
|
||||
if index == verified_node_index {
|
||||
node.payload_received = true;
|
||||
}
|
||||
if let Some(parent_index) = node.parent {
|
||||
parent_index
|
||||
} else {
|
||||
return Ok(());
|
||||
}
|
||||
// Gloas nodes should not be marked valid by this function, which exists only
|
||||
// for pre-Gloas fork choice.
|
||||
ProtoNode::V29(_) => {
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -874,6 +866,7 @@ impl ProtoArray {
|
||||
/// Invalidate zero or more blocks, as specified by the `InvalidationOperation`.
|
||||
///
|
||||
/// See the documentation of `InvalidationOperation` for usage.
|
||||
// TODO(gloas): this needs some tests for the mixed Gloas/pre-Gloas case.
|
||||
pub fn propagate_execution_payload_invalidation<E: EthSpec>(
|
||||
&mut self,
|
||||
op: &InvalidationOperation,
|
||||
|
||||
@@ -567,11 +567,18 @@ impl ProtoArrayForkChoice {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn on_execution_payload(&mut self, block_root: Hash256) -> Result<(), String> {
|
||||
/// Mark a Gloas payload envelope as valid and received.
|
||||
///
|
||||
/// This must only be called for valid Gloas payloads.
|
||||
pub fn on_valid_payload_envelope_received(
|
||||
&mut self,
|
||||
block_root: Hash256,
|
||||
) -> Result<(), String> {
|
||||
self.proto_array
|
||||
.on_valid_execution_payload(block_root)
|
||||
.on_valid_payload_envelope_received(block_root)
|
||||
.map_err(|e| format!("Failed to process execution payload: {:?}", e))
|
||||
}
|
||||
|
||||
/// See `ProtoArray::propagate_execution_payload_validation` for documentation.
|
||||
pub fn process_execution_payload_validation(
|
||||
&mut self,
|
||||
|
||||
@@ -1018,7 +1018,7 @@ impl<E: EthSpec> Tester<E> {
|
||||
.chain
|
||||
.canonical_head
|
||||
.fork_choice_write_lock()
|
||||
.on_execution_payload(block_root);
|
||||
.on_valid_payload_envelope_received(block_root);
|
||||
|
||||
if valid {
|
||||
result.map_err(|e| {
|
||||
|
||||
Reference in New Issue
Block a user