This commit is contained in:
realbigsean
2022-10-03 21:48:02 -04:00
parent 88006735c4
commit e81dbbfea4
46 changed files with 373 additions and 571 deletions

View File

@@ -6,11 +6,9 @@ use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use strum::IntoStaticStr;
pub use types::{
Address, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader, FixedVector,
Hash256, Uint256, VariableList, kzg_proof::KzgProof, kzg_commitment::KzgCommitment, blob::Blob,
blob::Blob, Address, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
FixedVector, Hash256, KzgCommitment, KzgProof, Uint256, VariableList,
};
use types::{KzgCommitment};
pub mod auth;
pub mod http;

View File

@@ -10,7 +10,7 @@ use serde::de::DeserializeOwned;
use serde_json::json;
use std::time::Duration;
use types::{EthSpec, FullPayload, execution_payload::BlobsBundle};
use types::{EthSpec, FullPayload};
pub use deposit_log::{DepositLog, Log};
pub use reqwest::Client;
@@ -671,14 +671,18 @@ impl HttpJsonRpc {
pub async fn get_blobs_bundle_v1<T: EthSpec>(
&self,
payload_id: PayloadId,
) -> Result<BlobsBundle<T>, Error> {
) -> Result<JsonBlobBundlesV1<T>, Error> {
let params = json!([JsonPayloadIdRequest::from(payload_id)]);
let response: JsonBlobBundlesV1<T> = self
.rpc_request(ENGINE_GET_BLOBS_BUNDLE_V1, params, ENGINE_GET_BLOBS_BUNDLE_TIMEOUT)
.rpc_request(
ENGINE_GET_BLOBS_BUNDLE_V1,
params,
ENGINE_GET_BLOBS_BUNDLE_TIMEOUT,
)
.await?;
Ok(response.into())
Ok(response)
}
pub async fn forkchoice_updated_v1(

View File

@@ -1,6 +1,6 @@
use super::*;
use serde::{Deserialize, Serialize};
use types::{EthSpec, ExecutionBlockHash, FixedVector, Transaction, Unsigned, VariableList, execution_payload::BlobsBundle};
use types::{EthSpec, ExecutionBlockHash, FixedVector, Transaction, Unsigned, VariableList};
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -278,45 +278,6 @@ pub struct JsonBlobBundlesV1<T: EthSpec> {
pub aggregated_proof: KzgProof,
}
impl <T: EthSpec> From<BlobsBundle<T>> for JsonBlobBundlesV1<T> {
fn from(p: BlobsBundle<T>) -> Self {
// Use this verbose deconstruction pattern to ensure no field is left unused.
let BlobsBundle {
block_hash,
aggregated_proof,
blobs,
kzgs,
} = p;
Self {
block_hash,
aggregated_proof,
blobs,
kzgs,
}
}
}
impl <T: EthSpec> From<JsonBlobBundlesV1<T>> for BlobsBundle<T> {
fn from(j: JsonBlobBundlesV1<T>) -> Self {
// Use this verbose deconstruction pattern to ensure no field is left unused.
let JsonBlobBundlesV1 {
block_hash,
aggregated_proof,
blobs,
kzgs,
} = j;
Self {
block_hash,
aggregated_proof,
blobs,
kzgs,
}
}
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JsonForkChoiceStateV1 {

View File

@@ -4,6 +4,7 @@
//! This crate only provides useful functionality for "The Merge", it does not provide any of the
//! deposit-contract functionality that the `beacon_node/eth1` crate already provides.
use crate::json_structures::JsonBlobBundlesV1;
use crate::payload_cache::PayloadCache;
use auth::{strip_prefix, Auth, JwtKey};
use builder_client::BuilderHttpClient;
@@ -787,10 +788,10 @@ impl<T: EthSpec> ExecutionLayer<T> {
timestamp: u64,
prev_randao: Hash256,
suggested_fee_recipient: Address,
) -> Result<BlobsBundle<T>, Error> {
) -> Result<JsonBlobBundlesV1<T>, Error> {
debug!(
self.log(),
"Issuing engine_getPayload";
"Issuing engine_getBlobsBundle";
"suggested_fee_recipient" => ?suggested_fee_recipient,
"prev_randao" => ?prev_randao,
"timestamp" => timestamp,
@@ -808,22 +809,15 @@ impl<T: EthSpec> ExecutionLayer<T> {
&[metrics::HIT],
);
id
} else {
} else {
error!(
self.log(),
"Exec engine unable to produce blobs, did you call get_payload before?",
);
return Err(ApiError::PayloadIdUnavailable);
return Err(ApiError::PayloadIdUnavailable);
};
engine
.api
.get_blobs_bundle_v1::<T>(payload_id)
.await
.map(|bundle| {
// TODO verify the blob bundle here?
bundle.into()
})
engine.api.get_blobs_bundle_v1::<T>(payload_id).await
})
.await
.map_err(Box::new)
@@ -937,18 +931,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
.map_err(Error::EngineError)
}
pub async fn get_blob<T: EthSpec>(
&self,
_parent_hash: Hash256,
_timestamp: u64,
_random: Hash256,
_finalized_block_hash: Hash256,
_proposer_index: u64,
_versioned_hash: Hash256,
) -> Result<BlobDetailsV1, Error> {
todo!()
}
/// Maps to the `engine_newPayload` JSON-RPC call.
///
/// ## Fallback Behaviour