mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-01 05:37:05 +00:00
resolve merge conflicts
This commit is contained in:
@@ -5,6 +5,7 @@ use crate::test_utils::{DEFAULT_CLIENT_VERSION, DEFAULT_MOCK_EL_PAYLOAD_VALUE_WE
|
||||
use serde::{Deserialize, de::DeserializeOwned};
|
||||
use serde_json::Value as JsonValue;
|
||||
use std::sync::Arc;
|
||||
use tracing::debug;
|
||||
use types::Transaction;
|
||||
|
||||
pub const GENERIC_ERROR_CODE: i64 = -1234;
|
||||
@@ -29,6 +30,8 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
.ok_or_else(|| "missing/invalid params field".to_string())
|
||||
.map_err(|s| (s, GENERIC_ERROR_CODE))?;
|
||||
|
||||
debug!(method, "Mock execution engine");
|
||||
|
||||
match method {
|
||||
ETH_SYNCING => ctx
|
||||
.syncing_response
|
||||
@@ -100,7 +103,8 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
ENGINE_NEW_PAYLOAD_V1
|
||||
| ENGINE_NEW_PAYLOAD_V2
|
||||
| ENGINE_NEW_PAYLOAD_V3
|
||||
| ENGINE_NEW_PAYLOAD_V4 => {
|
||||
| ENGINE_NEW_PAYLOAD_V4
|
||||
| ENGINE_NEW_PAYLOAD_V5 => {
|
||||
let request = match method {
|
||||
ENGINE_NEW_PAYLOAD_V1 => JsonExecutionPayload::Bellatrix(
|
||||
get_param::<JsonExecutionPayloadBellatrix<E>>(params, 0)
|
||||
@@ -116,21 +120,16 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
ENGINE_NEW_PAYLOAD_V3 => get_param::<JsonExecutionPayloadDeneb<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Deneb(jep))
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||
ENGINE_NEW_PAYLOAD_V4 => get_param::<JsonExecutionPayloadGloas<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Gloas(jep))
|
||||
.or_else(|_| {
|
||||
get_param::<JsonExecutionPayloadFulu<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Fulu(jep))
|
||||
})
|
||||
ENGINE_NEW_PAYLOAD_V4 => get_param::<JsonExecutionPayloadFulu<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Fulu(jep))
|
||||
.or_else(|_| {
|
||||
get_param::<JsonExecutionPayloadElectra<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Electra(jep))
|
||||
})
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||
// TODO(EIP7805) fix
|
||||
// ENGINE_NEW_PAYLOAD_V5 => get_param::<JsonExecutionPayloadV5<E>>(params, 0)
|
||||
// .map(|jep| JsonExecutionPayload::V5(jep))
|
||||
// .map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||
ENGINE_NEW_PAYLOAD_V5 => get_param::<JsonExecutionPayloadGloas<E>>(params, 0)
|
||||
.map(|jep| JsonExecutionPayload::Gloas(jep))
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@@ -232,6 +231,14 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
));
|
||||
}
|
||||
}
|
||||
ForkName::Gloas => {
|
||||
if method != ENGINE_NEW_PAYLOAD_V5 {
|
||||
return Err((
|
||||
format!("{} called after Gloas fork!", method),
|
||||
GENERIC_ERROR_CODE,
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
@@ -270,8 +277,9 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
ENGINE_GET_PAYLOAD_V1
|
||||
| ENGINE_GET_PAYLOAD_V2
|
||||
| ENGINE_GET_PAYLOAD_V3
|
||||
| ENGINE_GET_PAYLOAD_V4
|
||||
| ENGINE_GET_PAYLOAD_V5
|
||||
| ENGINE_GET_PAYLOAD_V4 => {
|
||||
| ENGINE_GET_PAYLOAD_V6 => {
|
||||
let request: JsonPayloadIdRequest =
|
||||
get_param(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||
let id = request.into();
|
||||
@@ -288,6 +296,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
})?;
|
||||
|
||||
let maybe_blobs = ctx.execution_block_generator.write().get_blobs_bundle(&id);
|
||||
let maybe_execution_requests = ctx
|
||||
.execution_block_generator
|
||||
.read()
|
||||
.get_execution_requests(&id);
|
||||
|
||||
// validate method called correctly according to shanghai fork time
|
||||
if ctx
|
||||
@@ -356,7 +368,8 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
&& (method == ENGINE_GET_PAYLOAD_V1
|
||||
|| method == ENGINE_GET_PAYLOAD_V2
|
||||
|| method == ENGINE_GET_PAYLOAD_V3
|
||||
|| method == ENGINE_GET_PAYLOAD_V4)
|
||||
|| method == ENGINE_GET_PAYLOAD_V4
|
||||
|| method == ENGINE_GET_PAYLOAD_V5)
|
||||
{
|
||||
return Err((
|
||||
format!("{} called after Gloas fork!", method),
|
||||
@@ -423,8 +436,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
))?
|
||||
.into(),
|
||||
should_override_builder: false,
|
||||
// TODO(electra): add EL requests in mock el
|
||||
execution_requests: Default::default(),
|
||||
execution_requests: maybe_execution_requests
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
@@ -444,7 +459,10 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
))?
|
||||
.into(),
|
||||
should_override_builder: false,
|
||||
execution_requests: Default::default(),
|
||||
execution_requests: maybe_execution_requests
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
@@ -463,18 +481,25 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
_ => unreachable!(),
|
||||
})
|
||||
}
|
||||
ENGINE_GET_PAYLOAD_V6 => {
|
||||
Ok(match JsonExecutionPayload::try_from(response).unwrap() {
|
||||
JsonExecutionPayload::Gloas(execution_payload) => {
|
||||
serde_json::to_value(JsonGetPayloadResponseGloas {
|
||||
execution_payload,
|
||||
block_value: Uint256::from(DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI),
|
||||
blobs_bundle: maybe_blobs
|
||||
.ok_or((
|
||||
"No blobs returned despite V5 Payload".to_string(),
|
||||
"No blobs returned despite V6 Payload".to_string(),
|
||||
GENERIC_ERROR_CODE,
|
||||
))?
|
||||
.into(),
|
||||
should_override_builder: false,
|
||||
execution_requests: Default::default(),
|
||||
execution_requests: maybe_execution_requests
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
})
|
||||
.unwrap()
|
||||
}
|
||||
@@ -484,9 +509,39 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
ENGINE_GET_BLOBS_V1 => {
|
||||
let versioned_hashes =
|
||||
get_param::<Vec<Hash256>>(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||
let generator = ctx.execution_block_generator.read();
|
||||
// V1: per-element nullable array, positionally matching the request.
|
||||
let response: Vec<Option<BlobAndProofV1<E>>> = versioned_hashes
|
||||
.iter()
|
||||
.map(|hash| match generator.get_blob_and_proof(hash) {
|
||||
Some(BlobAndProof::V1(v1)) => Some(v1),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
Ok(serde_json::to_value(response).unwrap())
|
||||
}
|
||||
ENGINE_GET_BLOBS_V2 => {
|
||||
let versioned_hashes =
|
||||
get_param::<Vec<Hash256>>(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||
let generator = ctx.execution_block_generator.read();
|
||||
// V2: all-or-nothing — null if any blob is missing.
|
||||
let results: Vec<Option<BlobAndProofV2<E>>> = versioned_hashes
|
||||
.iter()
|
||||
.map(|hash| match generator.get_blob_and_proof(hash) {
|
||||
Some(BlobAndProof::V2(v2)) => Some(v2),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let response: Option<Vec<BlobAndProofV2<E>>> = results.into_iter().collect();
|
||||
Ok(serde_json::to_value(response).unwrap())
|
||||
}
|
||||
ENGINE_FORKCHOICE_UPDATED_V1
|
||||
| ENGINE_FORKCHOICE_UPDATED_V2
|
||||
| ENGINE_FORKCHOICE_UPDATED_V3 => {
|
||||
| ENGINE_FORKCHOICE_UPDATED_V3
|
||||
| ENGINE_FORKCHOICE_UPDATED_V4 => {
|
||||
let forkchoice_state: JsonForkchoiceStateV1 =
|
||||
get_param(params, 0).map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?;
|
||||
let payload_attributes = match method {
|
||||
@@ -533,9 +588,20 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
.map(|opt| opt.map(JsonPayloadAttributes::V3))
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?
|
||||
}
|
||||
ENGINE_FORKCHOICE_UPDATED_V4 => {
|
||||
get_param::<Option<JsonPayloadAttributesV4>>(params, 1)
|
||||
.map(|opt| opt.map(JsonPayloadAttributes::V4))
|
||||
.map_err(|s| (s, BAD_PARAMS_ERROR_CODE))?
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
debug!(
|
||||
?payload_attributes,
|
||||
?forkchoice_state,
|
||||
"ENGINE_FORKCHOICE_UPDATED"
|
||||
);
|
||||
|
||||
// validate method called correctly according to fork time
|
||||
if let Some(pa) = payload_attributes.as_ref() {
|
||||
match ctx
|
||||
@@ -598,6 +664,14 @@ pub async fn handle_rpc<E: EthSpec>(
|
||||
));
|
||||
}
|
||||
}
|
||||
ForkName::Gloas => {
|
||||
if method != ENGINE_FORKCHOICE_UPDATED_V4 {
|
||||
return Err((
|
||||
format!("{} called after Gloas fork! Use V4.", method),
|
||||
FORK_REQUEST_MISMATCH_ERROR_CODE,
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user