From b6ff8241c8356414970d9b0e86395ffa20c32e67 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 26 Jun 2024 16:21:45 +0530 Subject: [PATCH] Add newPayloadWithWitness methods --- .../execution_layer/src/engine_api/http.rs | 23 ++++++++++ .../src/engine_api/json_structures.rs | 43 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 48095870ff..1f5dcd105a 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -34,6 +34,7 @@ pub const ETH_SYNCING_TIMEOUT: Duration = Duration::from_secs(1); pub const ENGINE_NEW_PAYLOAD_V1: &str = "engine_newPayloadV1"; pub const ENGINE_NEW_PAYLOAD_V2: &str = "engine_newPayloadV2"; pub const ENGINE_NEW_PAYLOAD_V3: &str = "engine_newPayloadV3"; +pub const ENGINE_NEW_PAYLOAD_WITH_WITNESS_V3: &str = "engine_newPayloadV3"; pub const ENGINE_NEW_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(8); pub const ENGINE_GET_PAYLOAD_V1: &str = "engine_getPayloadV1"; @@ -66,6 +67,7 @@ pub static LIGHTHOUSE_CAPABILITIES: &[&str] = &[ ENGINE_NEW_PAYLOAD_V1, ENGINE_NEW_PAYLOAD_V2, ENGINE_NEW_PAYLOAD_V3, + ENGINE_NEW_PAYLOAD_WITH_WITNESS_V3, ENGINE_GET_PAYLOAD_V1, ENGINE_GET_PAYLOAD_V2, ENGINE_GET_PAYLOAD_V3, @@ -851,6 +853,27 @@ impl HttpJsonRpc { Ok(response.into()) } + pub async fn new_payload_with_witness_v3( + &self, + new_payload_request_deneb: NewPayloadRequestDeneb<'_, E>, + ) -> Result { + let params = json!([ + JsonExecutionPayload::V3(new_payload_request_deneb.execution_payload.clone().into()), + new_payload_request_deneb.versioned_hashes, + new_payload_request_deneb.parent_beacon_block_root, + ]); + + let response: JsonPayloadStatusWithWitnessV1 = self + .rpc_request( + ENGINE_NEW_PAYLOAD_WITH_WITNESS_V3, + params, + ENGINE_NEW_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier, + ) + .await?; + + Ok(response) + } + pub async fn get_payload_v1( &self, payload_id: PayloadId, diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index 306972ada2..129cb2c2e9 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -786,3 +786,46 @@ impl TryFrom for ClientVersionV1 { }) } } + +/* +// statelessWitnessV1 is the witness data necessary to execute an ExecutableData +// without any local data being present. +var statelessWitnessV1 = { + headers: ["0xhrlp1", "0xhrlp2", ...], + codes: ["0xcode1", "0xcode2", ...], + state: ["0xnode1", "0xnode2", ...] +} + +// statelessPayloadStatusV1 is the result of a stateless payload execution. +var statelessPayloadStatusV1 = { + status: "same as payloadStatusV1.status", + stateRoot: "0x0000000000000000000000000000000000000000000000000000000000000000", + receiptsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000", + validationError: "same as payloadStatusV1.validationError", +} +*/ + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct JsonStatelessWitnessV1 { + headers: Vec, + codes: Vec, + state: Vec, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct JsonStatelessPayloadStatusV1 { + status: JsonPayloadStatusV1Status, + state_root: ExecutionBlockHash, + receipts_root: ExecutionBlockHash, + validation_error: Option, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct JsonPayloadStatusWithWitnessV1 { + #[serde(flatten)] + payload_status: JsonPayloadStatusV1, + witness: JsonStatelessWitnessV1, +}