mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Handle new engine api methods in mock EL
This commit is contained in:
@@ -111,20 +111,11 @@ pub async fn handle_rpc<E: EthSpec>(
|
|||||||
.map(|jep| JsonExecutionPayload::V1(jep))
|
.map(|jep| JsonExecutionPayload::V1(jep))
|
||||||
})
|
})
|
||||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||||
ENGINE_NEW_PAYLOAD_V3 => get_param::<JsonExecutionPayloadV4<E>>(params, 0)
|
ENGINE_NEW_PAYLOAD_V3 => get_param::<JsonExecutionPayloadV3<E>>(params, 0)
|
||||||
.map(|jep| JsonExecutionPayload::V4(jep))
|
|
||||||
.or_else(|_| {
|
|
||||||
get_param::<JsonExecutionPayloadV3<E>>(params, 0)
|
|
||||||
.map(|jep| JsonExecutionPayload::V3(jep))
|
.map(|jep| JsonExecutionPayload::V3(jep))
|
||||||
.or_else(|_| {
|
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||||
get_param::<JsonExecutionPayloadV2<E>>(params, 0)
|
ENGINE_NEW_PAYLOAD_V4 => get_param::<JsonExecutionPayloadV4<E>>(params, 0)
|
||||||
.map(|jep| JsonExecutionPayload::V2(jep))
|
.map(|jep| JsonExecutionPayload::V4(jep))
|
||||||
.or_else(|_| {
|
|
||||||
get_param::<JsonExecutionPayloadV1<E>>(params, 0)
|
|
||||||
.map(|jep| JsonExecutionPayload::V1(jep))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
@@ -190,7 +181,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ForkName::Electra => {
|
ForkName::Electra => {
|
||||||
if method == ENGINE_NEW_PAYLOAD_V1 || method == ENGINE_NEW_PAYLOAD_V2 {
|
if method == ENGINE_NEW_PAYLOAD_V1
|
||||||
|
|| method == ENGINE_NEW_PAYLOAD_V2
|
||||||
|
|| method == ENGINE_NEW_PAYLOAD_V3
|
||||||
|
{
|
||||||
return Err((
|
return Err((
|
||||||
format!("{} called after Electra fork!", method),
|
format!("{} called after Electra fork!", method),
|
||||||
GENERIC_ERROR_CODE,
|
GENERIC_ERROR_CODE,
|
||||||
@@ -259,7 +253,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
|||||||
|
|
||||||
Ok(serde_json::to_value(JsonPayloadStatusV1::from(response)).unwrap())
|
Ok(serde_json::to_value(JsonPayloadStatusV1::from(response)).unwrap())
|
||||||
}
|
}
|
||||||
ENGINE_GET_PAYLOAD_V1 | ENGINE_GET_PAYLOAD_V2 | ENGINE_GET_PAYLOAD_V3 => {
|
ENGINE_GET_PAYLOAD_V1
|
||||||
|
| ENGINE_GET_PAYLOAD_V2
|
||||||
|
| ENGINE_GET_PAYLOAD_V3
|
||||||
|
| ENGINE_GET_PAYLOAD_V4 => {
|
||||||
let request: JsonPayloadIdRequest =
|
let request: JsonPayloadIdRequest =
|
||||||
get_param(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
get_param(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||||
let id = request.into();
|
let id = request.into();
|
||||||
@@ -309,7 +306,9 @@ pub async fn handle_rpc<E: EthSpec>(
|
|||||||
.read()
|
.read()
|
||||||
.get_fork_at_timestamp(response.timestamp())
|
.get_fork_at_timestamp(response.timestamp())
|
||||||
== ForkName::Electra
|
== ForkName::Electra
|
||||||
&& method == ENGINE_GET_PAYLOAD_V1
|
&& (method == ENGINE_GET_PAYLOAD_V1
|
||||||
|
|| method == ENGINE_GET_PAYLOAD_V2
|
||||||
|
|| method == ENGINE_GET_PAYLOAD_V3)
|
||||||
{
|
{
|
||||||
return Err((
|
return Err((
|
||||||
format!("{} called after Electra fork!", method),
|
format!("{} called after Electra fork!", method),
|
||||||
@@ -353,6 +352,9 @@ pub async fn handle_rpc<E: EthSpec>(
|
|||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}),
|
||||||
|
ENGINE_GET_PAYLOAD_V4 => Ok(match JsonExecutionPayload::from(response) {
|
||||||
JsonExecutionPayload::V4(execution_payload) => {
|
JsonExecutionPayload::V4(execution_payload) => {
|
||||||
serde_json::to_value(JsonGetPayloadResponseV4 {
|
serde_json::to_value(JsonGetPayloadResponseV4 {
|
||||||
execution_payload,
|
execution_payload,
|
||||||
|
|||||||
Reference in New Issue
Block a user