Skip to content

Commit

Permalink
Merge branch 'main' into fix-feature-propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Oct 19, 2024
2 parents cf94e9e + c803012 commit a0a3422
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 57 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/consensus/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ reth-node-types.workspace = true
reth-chainspec = { workspace = true, optional = true }

# ethereum
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true

Expand Down
4 changes: 2 additions & 2 deletions crates/consensus/beacon/src/engine/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
engine::message::OnForkChoiceUpdated, BeaconConsensusEngineEvent, BeaconEngineMessage,
BeaconForkChoiceUpdateError, BeaconOnNewPayloadError,
};
use alloy_primitives::Bytes;
use alloy_eips::eip7685::Requests;
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayload, ForkchoiceState, ForkchoiceUpdated, PayloadStatus,
};
Expand Down Expand Up @@ -48,7 +48,7 @@ where
&self,
payload: ExecutionPayload,
cancun_fields: Option<CancunPayloadFields>,
execution_requests: Option<Vec<Bytes>>,
execution_requests: Option<Requests>,
) -> Result<PayloadStatus, BeaconOnNewPayloadError> {
let (tx, rx) = oneshot::channel();
// HACK(onbjerg): We should have a pectra payload fields struct, this is just a temporary
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus/beacon/src/engine/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::engine::{error::BeaconOnNewPayloadError, forkchoice::ForkchoiceStatus};
use alloy_primitives::Bytes;
use alloy_eips::eip7685::Requests;
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayload, ForkChoiceUpdateResult, ForkchoiceState,
ForkchoiceUpdateError, ForkchoiceUpdated, PayloadId, PayloadStatus, PayloadStatusEnum,
Expand Down Expand Up @@ -150,7 +150,7 @@ pub enum BeaconEngineMessage<Engine: EngineTypes> {
// HACK(onbjerg): We should have a pectra payload fields struct, this is just a temporary
// workaround.
/// The pectra EIP-7685 execution requests.
execution_requests: Option<Vec<Bytes>>,
execution_requests: Option<Requests>,
/// The sender for returning payload status result.
tx: oneshot::Sender<Result<PayloadStatus, BeaconOnNewPayloadError>>,
},
Expand Down
5 changes: 3 additions & 2 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{BlockNumber, Bytes, B256};
use alloy_eips::eip7685::Requests;
use alloy_primitives::{BlockNumber, B256};
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus, PayloadStatusEnum,
PayloadValidationError,
Expand Down Expand Up @@ -1087,7 +1088,7 @@ where
cancun_fields: Option<CancunPayloadFields>,
// HACK(onbjerg): We should have a pectra payload fields struct, this is just a temporary
// workaround.
execution_requests: Option<Vec<Bytes>>,
execution_requests: Option<Requests>,
) -> Result<Either<PayloadStatus, SealedBlock>, BeaconOnNewPayloadError> {
self.metrics.new_payload_messages.increment(1);

Expand Down
6 changes: 3 additions & 3 deletions crates/e2e-test-utils/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<E: EngineTypes> EngineApiTestContext<E> {
pub async fn get_payload_v3(
&self,
payload_id: PayloadId,
) -> eyre::Result<E::ExecutionPayloadV3> {
) -> eyre::Result<E::ExecutionPayloadEnvelopeV3> {
Ok(EngineApiClient::<E>::get_payload_v3(&self.engine_api_client, payload_id).await?)
}

Expand All @@ -50,10 +50,10 @@ impl<E: EngineTypes> EngineApiTestContext<E> {
versioned_hashes: Vec<B256>,
) -> eyre::Result<B256>
where
E::ExecutionPayloadV3: From<E::BuiltPayload> + PayloadEnvelopeExt,
E::ExecutionPayloadEnvelopeV3: From<E::BuiltPayload> + PayloadEnvelopeExt,
{
// setup payload for submission
let envelope_v3: <E as EngineTypes>::ExecutionPayloadV3 = payload.into();
let envelope_v3: <E as EngineTypes>::ExecutionPayloadEnvelopeV3 = payload.into();

// submit payload to engine api
let submission = EngineApiClient::<E>::new_payload_v3(
Expand Down
6 changes: 3 additions & 3 deletions crates/e2e-test-utils/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes + Copy,
) -> eyre::Result<Vec<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)>>
where
Engine::ExecutionPayloadV3: From<Engine::BuiltPayload> + PayloadEnvelopeExt,
Engine::ExecutionPayloadEnvelopeV3: From<Engine::BuiltPayload> + PayloadEnvelopeExt,
AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt + FullEthApiTypes,
{
let mut chain = Vec::with_capacity(length as usize);
Expand All @@ -113,7 +113,7 @@ where
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes,
) -> eyre::Result<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)>
where
<Engine as EngineTypes>::ExecutionPayloadV3:
<Engine as EngineTypes>::ExecutionPayloadEnvelopeV3:
From<Engine::BuiltPayload> + PayloadEnvelopeExt,
{
// trigger new payload building draining the pool
Expand All @@ -135,7 +135,7 @@ where
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes,
) -> eyre::Result<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)>
where
<Engine as EngineTypes>::ExecutionPayloadV3:
<Engine as EngineTypes>::ExecutionPayloadEnvelopeV3:
From<Engine::BuiltPayload> + PayloadEnvelopeExt,
{
let (payload, eth_attr) = self.new_payload(attributes_generator).await?;
Expand Down
30 changes: 24 additions & 6 deletions crates/engine/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,39 @@ use serde::{de::DeserializeOwned, ser::Serialize};
pub trait EngineTypes:
PayloadTypes<
BuiltPayload: TryInto<Self::ExecutionPayloadV1>
+ TryInto<Self::ExecutionPayloadV2>
+ TryInto<Self::ExecutionPayloadV3>
+ TryInto<Self::ExecutionPayloadV4>,
+ TryInto<Self::ExecutionPayloadEnvelopeV2>
+ TryInto<Self::ExecutionPayloadEnvelopeV3>
+ TryInto<Self::ExecutionPayloadEnvelopeV4>,
> + DeserializeOwned
+ Serialize
+ 'static
{
/// Execution Payload V1 type.
type ExecutionPayloadV1: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
/// Execution Payload V2 type.
type ExecutionPayloadV2: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
type ExecutionPayloadEnvelopeV2: DeserializeOwned
+ Serialize
+ Clone
+ Unpin
+ Send
+ Sync
+ 'static;
/// Execution Payload V3 type.
type ExecutionPayloadV3: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
type ExecutionPayloadEnvelopeV3: DeserializeOwned
+ Serialize
+ Clone
+ Unpin
+ Send
+ Sync
+ 'static;
/// Execution Payload V4 type.
type ExecutionPayloadV4: DeserializeOwned + Serialize + Clone + Unpin + Send + Sync + 'static;
type ExecutionPayloadEnvelopeV4: DeserializeOwned
+ Serialize
+ Clone
+ Unpin
+ Send
+ Sync
+ 'static;
}

/// Type that validates the payloads sent to the engine.
Expand Down
5 changes: 3 additions & 2 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
use alloy_eips::BlockNumHash;
use alloy_primitives::{
map::{HashMap, HashSet},
BlockNumber, Bytes, B256, U256,
BlockNumber, B256, U256,
};
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus, PayloadStatusEnum,
Expand Down Expand Up @@ -70,6 +70,7 @@ use crate::{
engine::{EngineApiKind, EngineApiRequest},
tree::metrics::EngineApiMetrics,
};
use alloy_eips::eip7685::Requests;
pub use config::TreeConfig;
pub use invalid_block_hook::{InvalidBlockHooks, NoopInvalidBlockHook};
pub use persistence_state::PersistenceState;
Expand Down Expand Up @@ -721,7 +722,7 @@ where
&mut self,
payload: ExecutionPayload,
cancun_fields: Option<CancunPayloadFields>,
execution_requests: Option<Vec<Bytes>>,
execution_requests: Option<Requests>,
) -> Result<TreeOutcome<PayloadStatus>, InsertBlockFatalError> {
trace!(target: "engine::tree", "invoked new payload");
self.metrics.engine.new_payload_messages.increment(1);
Expand Down
1 change: 1 addition & 0 deletions crates/engine/util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ revm-primitives.workspace = true
reth-trie.workspace = true

# alloy
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-consensus.workspace = true
Expand Down
7 changes: 4 additions & 3 deletions crates/engine/util/src/reorg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Stream wrapper that simulates reorgs.

use alloy_consensus::Transaction;
use alloy_primitives::{Bytes, U256};
use alloy_eips::eip7685::Requests;
use alloy_primitives::U256;
use alloy_rpc_types_engine::{
CancunPayloadFields, ExecutionPayload, ForkchoiceState, PayloadStatus,
};
Expand Down Expand Up @@ -250,8 +251,8 @@ fn create_reorg_head<Provider, Evm, Spec>(
mut depth: usize,
next_payload: ExecutionPayload,
next_cancun_fields: Option<CancunPayloadFields>,
next_execution_requests: Option<Vec<Bytes>>,
) -> RethResult<(ExecutionPayload, Option<CancunPayloadFields>, Option<Vec<Bytes>>)>
next_execution_requests: Option<Requests>,
) -> RethResult<(ExecutionPayload, Option<CancunPayloadFields>, Option<Requests>)>
where
Provider: BlockReader + StateProviderFactory,
Evm: ConfigureEvm<Header = Header>,
Expand Down
6 changes: 3 additions & 3 deletions crates/ethereum/engine-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ where
+ TryInto<ExecutionPayloadEnvelopeV4>,
{
type ExecutionPayloadV1 = ExecutionPayloadV1;
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadV3 = ExecutionPayloadEnvelopeV3;
type ExecutionPayloadV4 = ExecutionPayloadEnvelopeV4;
type ExecutionPayloadEnvelopeV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadEnvelopeV3 = ExecutionPayloadEnvelopeV3;
type ExecutionPayloadEnvelopeV4 = ExecutionPayloadEnvelopeV4;
}

/// A default payload type for [`EthEngineTypes`]
Expand Down
6 changes: 3 additions & 3 deletions crates/optimism/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ where
+ TryInto<OpExecutionPayloadEnvelopeV4>,
{
type ExecutionPayloadV1 = ExecutionPayloadV1;
type ExecutionPayloadV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadV3 = OpExecutionPayloadEnvelopeV3;
type ExecutionPayloadV4 = OpExecutionPayloadEnvelopeV4;
type ExecutionPayloadEnvelopeV2 = ExecutionPayloadEnvelopeV2;
type ExecutionPayloadEnvelopeV3 = OpExecutionPayloadEnvelopeV3;
type ExecutionPayloadEnvelopeV4 = OpExecutionPayloadEnvelopeV4;
}

/// A default payload type for [`OptimismEngineTypes`]
Expand Down
1 change: 0 additions & 1 deletion crates/payload/validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ reth-rpc-types-compat.workspace = true

# alloy
alloy-eips.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types = { workspace = true, features = ["engine"] }
12 changes: 4 additions & 8 deletions crates/payload/validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use alloy_eips::eip7685::Requests;
use alloy_primitives::Bytes;
use alloy_rpc_types::engine::{ExecutionPayload, MaybeCancunPayloadFields, PayloadError};
use reth_chainspec::EthereumHardforks;
use reth_primitives::SealedBlock;
Expand Down Expand Up @@ -114,17 +113,14 @@ impl<ChainSpec: EthereumHardforks> ExecutionPayloadValidator<ChainSpec> {
&self,
payload: ExecutionPayload,
cancun_fields: MaybeCancunPayloadFields,
execution_requests: Option<Vec<Bytes>>,
execution_requests: Option<Requests>,
) -> Result<SealedBlock, PayloadError> {
let expected_hash = payload.block_hash();

// First parse the block
let sealed_block = try_into_block(
payload,
cancun_fields.parent_beacon_block_root(),
execution_requests.map(Requests::new),
)?
.seal_slow();
let sealed_block =
try_into_block(payload, cancun_fields.parent_beacon_block_root(), execution_requests)?
.seal_slow();

// Ensure the hash included in the payload matches the block hash
if expected_hash != sealed_block.hash() {
Expand Down
19 changes: 14 additions & 5 deletions crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This contains the `engine_` namespace and the subset of the `eth_` namespace that is exposed to
//! the consensus client.

use alloy_eips::{eip4844::BlobAndProofV1, BlockId, BlockNumberOrTag};
use alloy_eips::{eip4844::BlobAndProofV1, eip7685::Requests, BlockId, BlockNumberOrTag};
use alloy_json_rpc::RpcObject;
use alloy_primitives::{Address, BlockHash, Bytes, B256, U256, U64};
use alloy_rpc_types::{
Expand Down Expand Up @@ -57,7 +57,7 @@ pub trait EngineApi<Engine: EngineTypes> {
payload: ExecutionPayloadV3,
versioned_hashes: Vec<B256>,
parent_beacon_block_root: B256,
execution_requests: Vec<Bytes>,
execution_requests: Requests,
) -> RpcResult<PayloadStatus>;

/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_forkchoiceupdatedv1>
Expand Down Expand Up @@ -118,7 +118,10 @@ pub trait EngineApi<Engine: EngineTypes> {
/// payload build process at the time of receiving this call. Note:
/// > Provider software MAY stop the corresponding build process after serving this call.
#[method(name = "getPayloadV2")]
async fn get_payload_v2(&self, payload_id: PayloadId) -> RpcResult<Engine::ExecutionPayloadV2>;
async fn get_payload_v2(
&self,
payload_id: PayloadId,
) -> RpcResult<Engine::ExecutionPayloadEnvelopeV2>;

/// Post Cancun payload handler which also returns a blobs bundle.
///
Expand All @@ -128,7 +131,10 @@ pub trait EngineApi<Engine: EngineTypes> {
/// payload build process at the time of receiving this call. Note:
/// > Provider software MAY stop the corresponding build process after serving this call.
#[method(name = "getPayloadV3")]
async fn get_payload_v3(&self, payload_id: PayloadId) -> RpcResult<Engine::ExecutionPayloadV3>;
async fn get_payload_v3(
&self,
payload_id: PayloadId,
) -> RpcResult<Engine::ExecutionPayloadEnvelopeV3>;

/// Post Prague payload handler.
///
Expand All @@ -138,7 +144,10 @@ pub trait EngineApi<Engine: EngineTypes> {
/// payload build process at the time of receiving this call. Note:
/// > Provider software MAY stop the corresponding build process after serving this call.
#[method(name = "getPayloadV4")]
async fn get_payload_v4(&self, payload_id: PayloadId) -> RpcResult<Engine::ExecutionPayloadV4>;
async fn get_payload_v4(
&self,
payload_id: PayloadId,
) -> RpcResult<Engine::ExecutionPayloadEnvelopeV4>;

/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyhashv1>
#[method(name = "getPayloadBodiesByHashV1")]
Expand Down
Loading

0 comments on commit a0a3422

Please sign in to comment.