mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-01 05:37:05 +00:00
Add getBlobsV1 and getBlobsV2 support to mock EL server (#8870)
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -468,6 +468,35 @@ 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 => {
|
||||
|
||||
Reference in New Issue
Block a user