mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Fix rpc decoding for blobs by range/root
This commit is contained in:
@@ -682,10 +682,15 @@ fn handle_rpc_response<E: EthSpec>(
|
|||||||
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
SignedBeaconBlock::Base(SignedBeaconBlockBase::from_ssz_bytes(decoded_buffer)?),
|
||||||
)))),
|
)))),
|
||||||
SupportedProtocol::BlobsByRangeV1 => match fork_name {
|
SupportedProtocol::BlobsByRangeV1 => match fork_name {
|
||||||
Some(ForkName::Deneb) => Ok(Some(RpcSuccessResponse::BlobsByRange(Arc::new(
|
Some(ForkName::Deneb) | Some(ForkName::Electra) => {
|
||||||
|
Ok(Some(RpcSuccessResponse::BlobsByRange(Arc::new(
|
||||||
BlobSidecar::from_ssz_bytes(decoded_buffer)?,
|
BlobSidecar::from_ssz_bytes(decoded_buffer)?,
|
||||||
)))),
|
))))
|
||||||
Some(_) => Err(RPCError::ErrorResponse(
|
}
|
||||||
|
Some(ForkName::Base)
|
||||||
|
| Some(ForkName::Altair)
|
||||||
|
| Some(ForkName::Bellatrix)
|
||||||
|
| Some(ForkName::Capella) => Err(RPCError::ErrorResponse(
|
||||||
RpcErrorResponse::InvalidRequest,
|
RpcErrorResponse::InvalidRequest,
|
||||||
"Invalid fork name for blobs by range".to_string(),
|
"Invalid fork name for blobs by range".to_string(),
|
||||||
)),
|
)),
|
||||||
@@ -698,10 +703,15 @@ fn handle_rpc_response<E: EthSpec>(
|
|||||||
)),
|
)),
|
||||||
},
|
},
|
||||||
SupportedProtocol::BlobsByRootV1 => match fork_name {
|
SupportedProtocol::BlobsByRootV1 => match fork_name {
|
||||||
Some(ForkName::Deneb) => Ok(Some(RpcSuccessResponse::BlobsByRoot(Arc::new(
|
Some(ForkName::Deneb) | Some(ForkName::Electra) => {
|
||||||
|
Ok(Some(RpcSuccessResponse::BlobsByRoot(Arc::new(
|
||||||
BlobSidecar::from_ssz_bytes(decoded_buffer)?,
|
BlobSidecar::from_ssz_bytes(decoded_buffer)?,
|
||||||
)))),
|
))))
|
||||||
Some(_) => Err(RPCError::ErrorResponse(
|
}
|
||||||
|
Some(ForkName::Base)
|
||||||
|
| Some(ForkName::Altair)
|
||||||
|
| Some(ForkName::Bellatrix)
|
||||||
|
| Some(ForkName::Capella) => Err(RPCError::ErrorResponse(
|
||||||
RpcErrorResponse::InvalidRequest,
|
RpcErrorResponse::InvalidRequest,
|
||||||
"Invalid fork name for blobs by root".to_string(),
|
"Invalid fork name for blobs by root".to_string(),
|
||||||
)),
|
)),
|
||||||
@@ -1376,6 +1386,16 @@ mod tests {
|
|||||||
Ok(Some(RpcSuccessResponse::BlobsByRange(empty_blob_sidecar()))),
|
Ok(Some(RpcSuccessResponse::BlobsByRange(empty_blob_sidecar()))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_then_decode_response(
|
||||||
|
SupportedProtocol::BlobsByRangeV1,
|
||||||
|
RpcResponse::Success(RpcSuccessResponse::BlobsByRange(empty_blob_sidecar())),
|
||||||
|
ForkName::Electra,
|
||||||
|
&chain_spec
|
||||||
|
),
|
||||||
|
Ok(Some(RpcSuccessResponse::BlobsByRange(empty_blob_sidecar()))),
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
encode_then_decode_response(
|
encode_then_decode_response(
|
||||||
SupportedProtocol::BlobsByRootV1,
|
SupportedProtocol::BlobsByRootV1,
|
||||||
@@ -1386,6 +1406,16 @@ mod tests {
|
|||||||
Ok(Some(RpcSuccessResponse::BlobsByRoot(empty_blob_sidecar()))),
|
Ok(Some(RpcSuccessResponse::BlobsByRoot(empty_blob_sidecar()))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_then_decode_response(
|
||||||
|
SupportedProtocol::BlobsByRootV1,
|
||||||
|
RpcResponse::Success(RpcSuccessResponse::BlobsByRoot(empty_blob_sidecar())),
|
||||||
|
ForkName::Electra,
|
||||||
|
&chain_spec
|
||||||
|
),
|
||||||
|
Ok(Some(RpcSuccessResponse::BlobsByRoot(empty_blob_sidecar()))),
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
encode_then_decode_response(
|
encode_then_decode_response(
|
||||||
SupportedProtocol::DataColumnsByRangeV1,
|
SupportedProtocol::DataColumnsByRangeV1,
|
||||||
@@ -1400,6 +1430,20 @@ mod tests {
|
|||||||
))),
|
))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_then_decode_response(
|
||||||
|
SupportedProtocol::DataColumnsByRangeV1,
|
||||||
|
RpcResponse::Success(RpcSuccessResponse::DataColumnsByRange(
|
||||||
|
empty_data_column_sidecar()
|
||||||
|
)),
|
||||||
|
ForkName::Electra,
|
||||||
|
&chain_spec
|
||||||
|
),
|
||||||
|
Ok(Some(RpcSuccessResponse::DataColumnsByRange(
|
||||||
|
empty_data_column_sidecar()
|
||||||
|
))),
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
encode_then_decode_response(
|
encode_then_decode_response(
|
||||||
SupportedProtocol::DataColumnsByRootV1,
|
SupportedProtocol::DataColumnsByRootV1,
|
||||||
@@ -1413,6 +1457,20 @@ mod tests {
|
|||||||
empty_data_column_sidecar()
|
empty_data_column_sidecar()
|
||||||
))),
|
))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
encode_then_decode_response(
|
||||||
|
SupportedProtocol::DataColumnsByRootV1,
|
||||||
|
RpcResponse::Success(RpcSuccessResponse::DataColumnsByRoot(
|
||||||
|
empty_data_column_sidecar()
|
||||||
|
)),
|
||||||
|
ForkName::Electra,
|
||||||
|
&chain_spec
|
||||||
|
),
|
||||||
|
Ok(Some(RpcSuccessResponse::DataColumnsByRoot(
|
||||||
|
empty_data_column_sidecar()
|
||||||
|
))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test RPCResponse encoding/decoding for V1 messages
|
// Test RPCResponse encoding/decoding for V1 messages
|
||||||
|
|||||||
Reference in New Issue
Block a user