mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
perf(engine): skip redundant db fetch in prepare_invalid_response (#22718)
This commit is contained in:
@@ -2103,16 +2103,16 @@ where
|
||||
/// Prepares the invalid payload response for the given hash, checking the
|
||||
/// database for the parent hash and populating the payload status with the latest valid hash
|
||||
/// according to the engine api spec.
|
||||
fn prepare_invalid_response(&mut self, mut parent_hash: B256) -> ProviderResult<PayloadStatus> {
|
||||
// Edge case: the `latestValid` field is the zero hash if the parent block is the terminal
|
||||
// PoW block, which we need to identify by looking at the parent's block difficulty
|
||||
if let Some(parent) = self.sealed_header_by_hash(parent_hash)? &&
|
||||
!parent.difficulty().is_zero()
|
||||
{
|
||||
parent_hash = B256::ZERO;
|
||||
}
|
||||
fn prepare_invalid_response(&mut self, parent_hash: B256) -> ProviderResult<PayloadStatus> {
|
||||
let valid_parent_hash = match self.sealed_header_by_hash(parent_hash)? {
|
||||
// Edge case: the `latestValid` field is the zero hash if the parent block is the
|
||||
// terminal PoW block, which we need to identify by looking at the parent's block
|
||||
// difficulty
|
||||
Some(parent) if !parent.difficulty().is_zero() => Some(B256::ZERO),
|
||||
Some(_) => Some(parent_hash),
|
||||
None => self.latest_valid_hash_for_invalid_payload(parent_hash)?,
|
||||
};
|
||||
|
||||
let valid_parent_hash = self.latest_valid_hash_for_invalid_payload(parent_hash)?;
|
||||
Ok(PayloadStatus::from_status(PayloadStatusEnum::Invalid {
|
||||
validation_error: PayloadValidationError::LinksToRejectedPayload.to_string(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user