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