Permit a null LVH from an INVALID response to newPayload (#4037)

## Issue Addressed

NA

## Proposed Changes

As discovered in #4034, Lighthouse is not accepting `latest_valid_hash == None` in an `INVALID` response to `newPayload`. The `null`/`None` response *was* illegal at one point, however it was added in https://github.com/ethereum/execution-apis/pull/254.

This PR brings Lighthouse in line with the standard and should fix the root cause of what #4034 patched around.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2023-03-03 04:12:50 +00:00
parent 2b6348781a
commit cac3a66be4
5 changed files with 81 additions and 54 deletions

View File

@@ -10,7 +10,9 @@ use types::ExecutionBlockHash;
pub enum PayloadStatus {
Valid,
Invalid {
latest_valid_hash: ExecutionBlockHash,
/// The EE will provide a `None` LVH when it is unable to determine the
/// latest valid ancestor.
latest_valid_hash: Option<ExecutionBlockHash>,
validation_error: Option<String>,
},
Syncing,
@@ -55,22 +57,10 @@ pub fn process_payload_status(
})
}
}
PayloadStatusV1Status::Invalid => {
if let Some(latest_valid_hash) = response.latest_valid_hash {
// The response is only valid if `latest_valid_hash` is not `null`.
Ok(PayloadStatus::Invalid {
latest_valid_hash,
validation_error: response.validation_error.clone(),
})
} else {
Err(EngineError::Api {
error: ApiError::BadResponse(
"new_payload: response.status = INVALID but null latest_valid_hash"
.to_string(),
),
})
}
}
PayloadStatusV1Status::Invalid => Ok(PayloadStatus::Invalid {
latest_valid_hash: response.latest_valid_hash,
validation_error: response.validation_error,
}),
PayloadStatusV1Status::InvalidBlockHash => {
// In the interests of being liberal with what we accept, only raise a
// warning here.