mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
payload verification with commitments
This commit is contained in:
@@ -11,7 +11,7 @@ use std::collections::HashSet;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
use types::EthSpec;
|
||||
use types::{EthSpec, VersionedHash};
|
||||
|
||||
pub use deposit_log::{DepositLog, Log};
|
||||
pub use reqwest::Client;
|
||||
@@ -808,8 +808,12 @@ impl HttpJsonRpc {
|
||||
pub async fn new_payload_v3<T: EthSpec>(
|
||||
&self,
|
||||
execution_payload: ExecutionPayload<T>,
|
||||
versioned_hashes: Vec<VersionedHash>,
|
||||
) -> Result<PayloadStatusV1, Error> {
|
||||
let params = json!([JsonExecutionPayload::from(execution_payload)]);
|
||||
let params = json!([
|
||||
JsonExecutionPayload::from(execution_payload),
|
||||
versioned_hashes
|
||||
]);
|
||||
|
||||
let response: JsonPayloadStatusV1 = self
|
||||
.rpc_request(
|
||||
@@ -1099,10 +1103,15 @@ impl HttpJsonRpc {
|
||||
pub async fn new_payload<T: EthSpec>(
|
||||
&self,
|
||||
execution_payload: ExecutionPayload<T>,
|
||||
versioned_hashes_opt: Option<Vec<VersionedHash>>,
|
||||
) -> Result<PayloadStatusV1, Error> {
|
||||
let engine_capabilities = self.get_engine_capabilities(None).await?;
|
||||
if engine_capabilities.new_payload_v3 {
|
||||
self.new_payload_v3(execution_payload).await
|
||||
let Some(versioned_hashes) = versioned_hashes_opt else {
|
||||
return Err(Error::IncorrectStateVariant);
|
||||
};
|
||||
self.new_payload_v3(execution_payload, versioned_hashes)
|
||||
.await
|
||||
} else if engine_capabilities.new_payload_v2 {
|
||||
self.new_payload_v2(execution_payload).await
|
||||
} else if engine_capabilities.new_payload_v1 {
|
||||
|
||||
@@ -1210,6 +1210,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
pub async fn notify_new_payload(
|
||||
&self,
|
||||
execution_payload: &ExecutionPayload<T>,
|
||||
versioned_hashes: Option<Vec<VersionedHash>>,
|
||||
) -> Result<PayloadStatus, Error> {
|
||||
let _timer = metrics::start_timer_vec(
|
||||
&metrics::EXECUTION_LAYER_REQUEST_TIMES,
|
||||
@@ -1226,7 +1227,11 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
|
||||
let result = self
|
||||
.engine()
|
||||
.request(|engine| engine.api.new_payload(execution_payload.clone()))
|
||||
.request(|engine| {
|
||||
engine
|
||||
.api
|
||||
.new_payload(execution_payload.clone(), versioned_hashes)
|
||||
})
|
||||
.await;
|
||||
|
||||
if let Ok(status) = &result {
|
||||
@@ -1237,6 +1242,8 @@ impl<T: EthSpec> ExecutionLayer<T> {
|
||||
}
|
||||
*self.inner.last_new_payload_errored.write().await = result.is_err();
|
||||
|
||||
//TODO(sean) process notify commitments updatE?
|
||||
|
||||
process_payload_status(execution_payload.block_hash(), result, self.log())
|
||||
.map_err(Box::new)
|
||||
.map_err(Error::EngineError)
|
||||
|
||||
@@ -204,7 +204,7 @@ impl<T: EthSpec> MockExecutionLayer<T> {
|
||||
Some(payload.clone())
|
||||
);
|
||||
|
||||
let status = self.el.notify_new_payload(&payload).await.unwrap();
|
||||
let status = self.el.notify_new_payload(&payload, None).await.unwrap();
|
||||
assert_eq!(status, PayloadStatus::Valid);
|
||||
|
||||
// Use junk values for slot/head-root to ensure there is no payload supplied.
|
||||
|
||||
Reference in New Issue
Block a user