feat: integrate payload store in BeaconEngine (#2146)

This commit is contained in:
Dan Cline
2023-04-07 16:45:44 -04:00
committed by GitHub
parent 72e7b5693a
commit 1bf5c7dce3
11 changed files with 158 additions and 33 deletions

View File

@ -3,9 +3,7 @@ use futures::StreamExt;
use reth_beacon_consensus::BeaconEngineMessage;
use reth_primitives::{BlockHash, BlockId, BlockNumber, ChainSpec, Hardfork};
use reth_provider::{BlockProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory};
use reth_rpc_types::engine::{
ExecutionPayloadBodies, ExecutionPayloadEnvelope, PayloadId, TransitionConfiguration,
};
use reth_rpc_types::engine::{ExecutionPayloadBodies, TransitionConfiguration};
use std::{
future::Future,
pin::Pin,
@ -57,7 +55,8 @@ impl<Client: HeaderProvider + BlockProvider + StateProviderFactory + EvmEnvProvi
let _ = tx.send(self.exchange_transition_configuration(config));
}
EngineApiMessage::GetPayload(payload_id, tx) => {
let _ = tx.send(self.get_payload(payload_id).ok_or(EngineApiError::PayloadUnknown));
// forward message to the consensus engine
let _ = self.engine_tx.send(BeaconEngineMessage::GetPayload { payload_id, tx });
}
EngineApiMessage::GetPayloadBodiesByHash(hashes, tx) => {
let _ = tx.send(self.get_payload_bodies_by_hash(hashes));
@ -80,15 +79,6 @@ impl<Client: HeaderProvider + BlockProvider + StateProviderFactory + EvmEnvProvi
}
}
/// Called to retrieve the latest state of the network, validate new blocks, and maintain
/// consistency between the Consensus and Execution layers.
///
/// NOTE: Will always result in `PayloadUnknown` since we don't support block
/// building for now.
pub fn get_payload(&self, _payload_id: PayloadId) -> Option<ExecutionPayloadEnvelope> {
None
}
/// Called to retrieve execution payload bodies by range.
pub fn get_payload_bodies_by_range(
&self,

View File

@ -11,7 +11,7 @@ use reth_rpc_types::engine::{
#[derive(Debug)]
pub enum EngineApiMessage {
/// Get payload message
GetPayload(PayloadId, EngineApiSender<ExecutionPayloadEnvelope>),
GetPayload(PayloadId, BeaconEngineSender<ExecutionPayloadEnvelope>),
/// Get payload bodies by range message
GetPayloadBodiesByRange(BlockNumber, u64, EngineApiSender<ExecutionPayloadBodies>),
/// Get payload bodies by hash message