mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(engine): future payload handling (#2124)
This commit is contained in:
@ -193,7 +193,10 @@ where
|
||||
///
|
||||
/// These responses should adhere to the [Engine API Spec for
|
||||
/// `engine_newPayload`](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#specification).
|
||||
fn on_new_payload(&mut self, payload: ExecutionPayload) -> PayloadStatus {
|
||||
fn on_new_payload(
|
||||
&mut self,
|
||||
payload: ExecutionPayload,
|
||||
) -> Result<PayloadStatus, reth_interfaces::Error> {
|
||||
let block_number = payload.block_number.as_u64();
|
||||
let block_hash = payload.block_hash;
|
||||
trace!(target: "consensus::engine", ?block_hash, block_number, "Received new payload");
|
||||
@ -201,9 +204,9 @@ where
|
||||
Ok(block) => block,
|
||||
Err(error) => {
|
||||
error!(target: "consensus::engine", ?block_hash, block_number, ?error, "Invalid payload");
|
||||
return PayloadStatus::from_status(PayloadStatusEnum::InvalidBlockHash {
|
||||
return Ok(PayloadStatus::from_status(PayloadStatusEnum::InvalidBlockHash {
|
||||
validation_error: error.to_string(),
|
||||
})
|
||||
}))
|
||||
}
|
||||
};
|
||||
|
||||
@ -224,17 +227,31 @@ where
|
||||
let latest_valid_hash =
|
||||
matches!(error, Error::Execution(ExecutorError::BlockPreMerge { .. }))
|
||||
.then_some(H256::zero());
|
||||
PayloadStatus::new(
|
||||
PayloadStatusEnum::Invalid { validation_error: error.to_string() },
|
||||
latest_valid_hash,
|
||||
)
|
||||
let status = match error {
|
||||
Error::Execution(ExecutorError::PendingBlockIsInFuture { .. }) => {
|
||||
if let Some(ForkchoiceState { head_block_hash, .. }) =
|
||||
self.forkchoice_state
|
||||
{
|
||||
if self
|
||||
.db
|
||||
.view(|tx| tx.get::<tables::HeaderNumbers>(head_block_hash))??
|
||||
.is_none()
|
||||
{
|
||||
self.require_pipeline_run(PipelineTarget::Head);
|
||||
}
|
||||
}
|
||||
PayloadStatusEnum::Syncing
|
||||
}
|
||||
error => PayloadStatusEnum::Invalid { validation_error: error.to_string() },
|
||||
};
|
||||
PayloadStatus::new(status, latest_valid_hash)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PayloadStatus::from_status(PayloadStatusEnum::Syncing)
|
||||
};
|
||||
trace!(target: "consensus::engine", ?block_hash, block_number, ?status, "Returning payload status");
|
||||
status
|
||||
Ok(status)
|
||||
}
|
||||
|
||||
/// Returns the next pipeline state depending on the current value of the next action.
|
||||
@ -341,7 +358,13 @@ where
|
||||
}
|
||||
}
|
||||
BeaconEngineMessage::NewPayload { payload, tx } => {
|
||||
let response = this.on_new_payload(payload);
|
||||
let response = match this.on_new_payload(payload) {
|
||||
Ok(response) => response,
|
||||
Err(error) => {
|
||||
error!(target: "consensus::engine", ?error, "Error getting new payload response");
|
||||
return Poll::Ready(Err(error.into()))
|
||||
}
|
||||
};
|
||||
let _ = tx.send(Ok(response));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user