[Merge] Optimistic EL verification (#2683)

* Ignore payload errors

* Only return payload handle on valid response

* Push some engine logs down to debug

* Push ee fork choice log to debug

* Push engine call failure to debug

* Push some more errors to debug

* Fix panic at startup
This commit is contained in:
Paul Hauner
2021-10-07 00:34:17 +11:00
parent 35350dff75
commit 67a6f91df6
6 changed files with 80 additions and 62 deletions

View File

@@ -2,7 +2,7 @@
use crate::engine_api::{EngineApi, Error as EngineApiError};
use futures::future::join_all;
use slog::{crit, debug, error, info, warn, Logger};
use slog::{crit, debug, info, warn, Logger};
use std::future::Future;
use tokio::sync::RwLock;
use types::Hash256;
@@ -89,7 +89,7 @@ impl<T: EngineApi> Engines<T> {
.forkchoice_updated(head.head_block_hash, head.finalized_block_hash)
.await
{
error!(
debug!(
self.log,
"Failed to issue latest head to engine";
"error" => ?e,
@@ -225,7 +225,7 @@ impl<T: EngineApi> Engines<T> {
match func(engine).await {
Ok(result) => return Ok(result),
Err(error) => {
error!(
debug!(
self.log,
"Execution engine call failed";
"error" => ?error,
@@ -291,7 +291,7 @@ impl<T: EngineApi> Engines<T> {
let is_offline = *engine.state.read().await == EngineState::Offline;
if !is_offline {
func(engine).await.map_err(|error| {
error!(
debug!(
self.log,
"Execution engine call failed";
"error" => ?error,

View File

@@ -8,7 +8,7 @@ use engine_api::{Error as ApiError, *};
use engines::{Engine, EngineError, Engines, ForkChoiceHead, Logging};
use lru::LruCache;
use sensitive_url::SensitiveUrl;
use slog::{crit, error, info, Logger};
use slog::{crit, debug, error, info, Logger};
use slot_clock::SlotClock;
use std::future::Future;
use std::sync::Arc;
@@ -249,7 +249,7 @@ impl ExecutionLayer {
random: Hash256,
) -> Result<PayloadId, Error> {
let fee_recipient = self.fee_recipient()?;
info!(
debug!(
self.log(),
"Issuing engine_preparePayload";
"fee_recipient" => ?fee_recipient,
@@ -285,7 +285,7 @@ impl ExecutionLayer {
random: Hash256,
) -> Result<ExecutionPayload<T>, Error> {
let fee_recipient = self.fee_recipient()?;
info!(
debug!(
self.log(),
"Issuing engine_getPayload";
"fee_recipient" => ?fee_recipient,
@@ -323,8 +323,8 @@ impl ExecutionLayer {
pub async fn execute_payload<T: EthSpec>(
&self,
execution_payload: &ExecutionPayload<T>,
) -> Result<(ExecutePayloadResponse, ExecutePayloadHandle), Error> {
info!(
) -> Result<(ExecutePayloadResponse, Option<ExecutePayloadHandle>), Error> {
debug!(
self.log(),
"Issuing engine_executePayload";
"parent_hash" => ?execution_payload.parent_hash,
@@ -358,23 +358,20 @@ impl ExecutionLayer {
);
}
let execute_payload_response = if valid > 0 {
ExecutePayloadResponse::Valid
if valid > 0 {
let handle = ExecutePayloadHandle {
block_hash: execution_payload.block_hash,
execution_layer: Some(self.clone()),
log: self.log().clone(),
};
Ok((ExecutePayloadResponse::Valid, Some(handle)))
} else if invalid > 0 {
ExecutePayloadResponse::Invalid
Ok((ExecutePayloadResponse::Invalid, None))
} else if syncing > 0 {
ExecutePayloadResponse::Syncing
Ok((ExecutePayloadResponse::Syncing, None))
} else {
return Err(Error::EngineErrors(errors));
};
let execute_payload_handle = ExecutePayloadHandle {
block_hash: execution_payload.block_hash,
execution_layer: Some(self.clone()),
log: self.log().clone(),
};
Ok((execute_payload_response, execute_payload_handle))
Err(Error::EngineErrors(errors))
}
}
/// Maps to the `engine_consensusValidated` JSON-RPC call.
@@ -392,7 +389,7 @@ impl ExecutionLayer {
block_hash: Hash256,
status: ConsensusStatus,
) -> Result<(), Error> {
info!(
debug!(
self.log(),
"Issuing engine_consensusValidated";
"status" => ?status,
@@ -430,7 +427,7 @@ impl ExecutionLayer {
head_block_hash: Hash256,
finalized_block_hash: Hash256,
) -> Result<(), Error> {
info!(
debug!(
self.log(),
"Issuing engine_forkchoiceUpdated";
"finalized_block_hash" => ?finalized_block_hash,

View File

@@ -123,11 +123,13 @@ impl<T: EthSpec> MockExecutionLayer<T> {
assert_eq!(payload.timestamp, timestamp);
assert_eq!(payload.random, random);
let (payload_response, mut payload_handle) =
self.el.execute_payload(&payload).await.unwrap();
let (payload_response, payload_handle) = self.el.execute_payload(&payload).await.unwrap();
assert_eq!(payload_response, ExecutePayloadResponse::Valid);
payload_handle.publish_async(ConsensusStatus::Valid).await;
payload_handle
.unwrap()
.publish_async(ConsensusStatus::Valid)
.await;
self.el
.forkchoice_updated(block_hash, Hash256::zero())