add engine_getBlobV1

This commit is contained in:
realbigsean 2022-02-20 14:54:35 -07:00
parent 3f1e5cee78
commit 203418ffc9
No known key found for this signature in database
GPG Key ID: B372B64D866BF8CC
3 changed files with 29 additions and 2 deletions

View File

@ -11,6 +11,10 @@ pub use types::{
}; };
pub mod auth; pub mod auth;
use crate::engines::ForkChoiceState;
pub use types::{Address, EthSpec, ExecutionPayload, Hash256, Uint256};
use types::{Blob, KZGCommitment};
pub mod http; pub mod http;
pub mod json_structures; pub mod json_structures;
@ -166,3 +170,9 @@ pub struct ProposeBlindedBlockResponse {
pub latest_valid_hash: Option<Hash256>, pub latest_valid_hash: Option<Hash256>,
pub validation_error: Option<String>, pub validation_error: Option<String>,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BlobDetailsV1 {
kzg: KZGCommitment,
blob: Vec<Hash256>,
}

View File

@ -34,6 +34,9 @@ pub const ENGINE_NEW_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(8);
pub const ENGINE_GET_PAYLOAD_V1: &str = "engine_getPayloadV1"; pub const ENGINE_GET_PAYLOAD_V1: &str = "engine_getPayloadV1";
pub const ENGINE_GET_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(2); pub const ENGINE_GET_PAYLOAD_TIMEOUT: Duration = Duration::from_secs(2);
pub const ENGINE_GET_BLOB_V1: &str = "engine_getBlobV1";
pub const ENGINE_GET_BLOB_TIMEOUT: Duration = Duration::from_secs(2);
pub const ENGINE_FORKCHOICE_UPDATED_V1: &str = "engine_forkchoiceUpdatedV1"; pub const ENGINE_FORKCHOICE_UPDATED_V1: &str = "engine_forkchoiceUpdatedV1";
pub const ENGINE_FORKCHOICE_UPDATED_TIMEOUT: Duration = Duration::from_secs(8); pub const ENGINE_FORKCHOICE_UPDATED_TIMEOUT: Duration = Duration::from_secs(8);
@ -664,6 +667,20 @@ impl HttpJsonRpc {
Ok(response.into()) Ok(response.into())
} }
async fn get_blob_v1<T: EthSpec>(
&self,
payload_id: PayloadId,
versioned_hash: Hash256,
) -> Result<BlobDetailsV1, Error> {
let params = json!([JsonPayloadIdRequest::from(payload_id), versioned_hash]);
let response: BlobDetailsV1 = self
.rpc_request(ENGINE_GET_BLOB_V1, params, ENGINE_GET_BLOB_TIMEOUT)
.await?;
Ok(response.into())
}
pub async fn forkchoice_updated_v1( pub async fn forkchoice_updated_v1(
&self, &self,
forkchoice_state: ForkChoiceState, forkchoice_state: ForkChoiceState,

View File

@ -1,6 +1,6 @@
use crate::{Blob, EthSpec, Hash256, SignedBeaconBlock, Slot}; use crate::{Blob, EthSpec, Hash256, Slot};
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, Encode}; use ssz::Encode;
use ssz_derive::{Decode, Encode}; use ssz_derive::{Decode, Encode};
use ssz_types::VariableList; use ssz_types::VariableList;
use tree_hash::TreeHash; use tree_hash::TreeHash;