Compare commits

...

1 Commits

Author SHA1 Message Date
Pawan Dhananjay
b6ff8241c8 Add newPayloadWithWitness methods 2024-06-26 16:21:45 +05:30
2 changed files with 66 additions and 0 deletions

View File

@@ -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<E: EthSpec>(
&self,
new_payload_request_deneb: NewPayloadRequestDeneb<'_, E>,
) -> Result<JsonPayloadStatusWithWitnessV1, Error> {
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<E: EthSpec>(
&self,
payload_id: PayloadId,

View File

@@ -786,3 +786,46 @@ impl TryFrom<JsonClientVersionV1> 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<serde_json::Value>,
codes: Vec<serde_json::Value>,
state: Vec<serde_json::Value>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JsonStatelessPayloadStatusV1 {
status: JsonPayloadStatusV1Status,
state_root: ExecutionBlockHash,
receipts_root: ExecutionBlockHash,
validation_error: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JsonPayloadStatusWithWitnessV1 {
#[serde(flatten)]
payload_status: JsonPayloadStatusV1,
witness: JsonStatelessWitnessV1,
}