mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-01 05:37:05 +00:00
got interop working~
This commit is contained in:
@@ -65,7 +65,7 @@ pub struct JsonPayloadIdResponse {
|
||||
}
|
||||
|
||||
#[superstruct(
|
||||
variants(V1, V2, V3, V4, V5),
|
||||
variants(V1, V2, V3, V4, V5, V6),
|
||||
variant_attributes(
|
||||
derive(Debug, PartialEq, Default, Serialize, Deserialize,),
|
||||
serde(bound = "E: EthSpec", rename_all = "camelCase"),
|
||||
@@ -100,12 +100,12 @@ pub struct JsonExecutionPayload<E: EthSpec> {
|
||||
pub block_hash: ExecutionBlockHash,
|
||||
#[serde(with = "ssz_types::serde_utils::list_of_hex_var_list")]
|
||||
pub transactions: Transactions<E>,
|
||||
#[superstruct(only(V2, V3, V4, V5))]
|
||||
#[superstruct(only(V2, V3, V4, V5, V6))]
|
||||
pub withdrawals: VariableList<JsonWithdrawal, E::MaxWithdrawalsPerPayload>,
|
||||
#[superstruct(only(V3, V4, V5))]
|
||||
#[superstruct(only(V3, V4, V5, V6))]
|
||||
#[serde(with = "serde_utils::u64_hex_be")]
|
||||
pub blob_gas_used: u64,
|
||||
#[superstruct(only(V3, V4, V5))]
|
||||
#[superstruct(only(V3, V4, V5, V6))]
|
||||
#[serde(with = "serde_utils::u64_hex_be")]
|
||||
pub excess_blob_gas: u64,
|
||||
}
|
||||
@@ -243,6 +243,35 @@ impl<E: EthSpec> From<ExecutionPayloadEip7805<E>> for JsonExecutionPayloadV5<E>
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<ExecutionPayloadFulu<E>> for JsonExecutionPayloadV6<E> {
|
||||
fn from(payload: ExecutionPayloadFulu<E>) -> Self {
|
||||
JsonExecutionPayloadV6 {
|
||||
parent_hash: payload.parent_hash,
|
||||
fee_recipient: payload.fee_recipient,
|
||||
state_root: payload.state_root,
|
||||
receipts_root: payload.receipts_root,
|
||||
logs_bloom: payload.logs_bloom,
|
||||
prev_randao: payload.prev_randao,
|
||||
block_number: payload.block_number,
|
||||
gas_limit: payload.gas_limit,
|
||||
gas_used: payload.gas_used,
|
||||
timestamp: payload.timestamp,
|
||||
extra_data: payload.extra_data,
|
||||
base_fee_per_gas: payload.base_fee_per_gas,
|
||||
block_hash: payload.block_hash,
|
||||
transactions: payload.transactions,
|
||||
withdrawals: payload
|
||||
.withdrawals
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect::<Vec<_>>()
|
||||
.into(),
|
||||
blob_gas_used: payload.blob_gas_used,
|
||||
excess_blob_gas: payload.excess_blob_gas,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<ExecutionPayload<E>> for JsonExecutionPayload<E> {
|
||||
fn from(execution_payload: ExecutionPayload<E>) -> Self {
|
||||
match execution_payload {
|
||||
@@ -251,7 +280,7 @@ impl<E: EthSpec> From<ExecutionPayload<E>> for JsonExecutionPayload<E> {
|
||||
ExecutionPayload::Deneb(payload) => JsonExecutionPayload::V3(payload.into()),
|
||||
ExecutionPayload::Electra(payload) => JsonExecutionPayload::V4(payload.into()),
|
||||
ExecutionPayload::Eip7805(payload) => JsonExecutionPayload::V5(payload.into()),
|
||||
ExecutionPayload::Fulu(_) => unreachable!("DONT USE FULU"),
|
||||
ExecutionPayload::Fulu(payload) => JsonExecutionPayload::V6(payload.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -390,6 +419,35 @@ impl<E: EthSpec> From<JsonExecutionPayloadV5<E>> for ExecutionPayloadEip7805<E>
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<JsonExecutionPayloadV6<E>> for ExecutionPayloadFulu<E> {
|
||||
fn from(payload: JsonExecutionPayloadV6<E>) -> Self {
|
||||
ExecutionPayloadFulu {
|
||||
parent_hash: payload.parent_hash,
|
||||
fee_recipient: payload.fee_recipient,
|
||||
state_root: payload.state_root,
|
||||
receipts_root: payload.receipts_root,
|
||||
logs_bloom: payload.logs_bloom,
|
||||
prev_randao: payload.prev_randao,
|
||||
block_number: payload.block_number,
|
||||
gas_limit: payload.gas_limit,
|
||||
gas_used: payload.gas_used,
|
||||
timestamp: payload.timestamp,
|
||||
extra_data: payload.extra_data,
|
||||
base_fee_per_gas: payload.base_fee_per_gas,
|
||||
block_hash: payload.block_hash,
|
||||
transactions: payload.transactions,
|
||||
withdrawals: payload
|
||||
.withdrawals
|
||||
.into_iter()
|
||||
.map(Into::into)
|
||||
.collect::<Vec<_>>()
|
||||
.into(),
|
||||
blob_gas_used: payload.blob_gas_used,
|
||||
excess_blob_gas: payload.excess_blob_gas,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<JsonExecutionPayload<E>> for ExecutionPayload<E> {
|
||||
fn from(json_execution_payload: JsonExecutionPayload<E>) -> Self {
|
||||
match json_execution_payload {
|
||||
@@ -398,6 +456,7 @@ impl<E: EthSpec> From<JsonExecutionPayload<E>> for ExecutionPayload<E> {
|
||||
JsonExecutionPayload::V3(payload) => ExecutionPayload::Deneb(payload.into()),
|
||||
JsonExecutionPayload::V4(payload) => ExecutionPayload::Electra(payload.into()),
|
||||
JsonExecutionPayload::V5(payload) => ExecutionPayload::Eip7805(payload.into()),
|
||||
JsonExecutionPayload::V6(payload) => ExecutionPayload::Fulu(payload.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,7 +542,7 @@ impl<E: EthSpec> TryFrom<JsonExecutionRequests> for ExecutionRequests<E> {
|
||||
}
|
||||
|
||||
#[superstruct(
|
||||
variants(V1, V2, V3, V4, V5),
|
||||
variants(V1, V2, V3, V4, V5, V6),
|
||||
variant_attributes(
|
||||
derive(Debug, PartialEq, Serialize, Deserialize),
|
||||
serde(bound = "E: EthSpec", rename_all = "camelCase")
|
||||
@@ -504,13 +563,15 @@ pub struct JsonGetPayloadResponse<E: EthSpec> {
|
||||
pub execution_payload: JsonExecutionPayloadV4<E>,
|
||||
#[superstruct(only(V5), partial_getter(rename = "execution_payload_v5"))]
|
||||
pub execution_payload: JsonExecutionPayloadV5<E>,
|
||||
#[superstruct(only(V6), partial_getter(rename = "execution_payload_v6"))]
|
||||
pub execution_payload: JsonExecutionPayloadV6<E>,
|
||||
#[serde(with = "serde_utils::u256_hex_be")]
|
||||
pub block_value: Uint256,
|
||||
#[superstruct(only(V3, V4, V5))]
|
||||
#[superstruct(only(V3, V4, V5, V6))]
|
||||
pub blobs_bundle: JsonBlobsBundleV1<E>,
|
||||
#[superstruct(only(V3, V4, V5))]
|
||||
#[superstruct(only(V3, V4, V5, V6))]
|
||||
pub should_override_builder: bool,
|
||||
#[superstruct(only(V4, V5))]
|
||||
#[superstruct(only(V4, V5, V6))]
|
||||
pub execution_requests: JsonExecutionRequests,
|
||||
}
|
||||
|
||||
@@ -560,6 +621,17 @@ impl<E: EthSpec> TryFrom<JsonGetPayloadResponse<E>> for GetPayloadResponse<E> {
|
||||
})?,
|
||||
}))
|
||||
}
|
||||
JsonGetPayloadResponse::V6(response) => {
|
||||
Ok(GetPayloadResponse::Fulu(GetPayloadResponseFulu {
|
||||
execution_payload: response.execution_payload.into(),
|
||||
block_value: response.block_value,
|
||||
blobs_bundle: response.blobs_bundle.into(),
|
||||
should_override_builder: response.should_override_builder,
|
||||
requests: response.execution_requests.try_into().map_err(|e| {
|
||||
format!("Failed to convert json to execution requests {:?}", e)
|
||||
})?,
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user