Skip to content

Commit

Permalink
feat: remove unused payload validator dependency and streamline engin…
Browse files Browse the repository at this point in the history
…e imports
  • Loading branch information
johntaiko committed Dec 24, 2024
1 parent 652a469 commit 1abccba
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 148 deletions.
6 changes: 1 addition & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/engine/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod error;
use core::fmt;

use alloy_consensus::BlockHeader;
use alloy_rpc_types_engine::{ExecutionPayload, ExecutionPayloadSidecar, PayloadError};
use alloy_rpc_types_engine::{ExecutionPayloadSidecar, PayloadError};
pub use error::BeaconOnNewPayloadError;

mod forkchoice;
Expand Down
5 changes: 3 additions & 2 deletions crates/engine/primitives/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{BeaconOnNewPayloadError, EngineApiMessageVersion, EngineTypes, ForkchoiceStatus};
use alloy_rpc_types_engine::{
ExecutionPayload, ExecutionPayloadSidecar, ForkChoiceUpdateResult, ForkchoiceState,
ForkchoiceUpdateError, ForkchoiceUpdated, PayloadId, PayloadStatus, PayloadStatusEnum,
ExecutionPayloadSidecar, ForkChoiceUpdateResult, ForkchoiceState, ForkchoiceUpdateError,
ForkchoiceUpdated, PayloadId, PayloadStatus, PayloadStatusEnum,
};
use futures::{future::Either, FutureExt};
use reth_errors::RethResult;
Expand Down Expand Up @@ -160,6 +160,7 @@ pub enum BeaconEngineMessage<Engine: EngineTypes> {
version: EngineApiMessageVersion,
/// The sender for returning forkchoice updated result.
tx: oneshot::Sender<RethResult<OnForkChoiceUpdated>>,
/// Debug mode flag.
debug: bool,
},
/// Message with exchanged transition configuration.
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/engine-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
mod payload;
use std::sync::Arc;

use alloy_rpc_types_engine::{ExecutionPayload, ExecutionPayloadSidecar, PayloadError};
pub use alloy_rpc_types_engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
ExecutionPayloadV1, PayloadAttributes as EthPayloadAttributes,
};
use alloy_rpc_types_engine::{ExecutionPayloadSidecar, PayloadError};
pub use payload::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_chainspec::ChainSpec;
use reth_engine_primitives::{EngineTypes, EngineValidator, PayloadValidator};
Expand Down
1 change: 0 additions & 1 deletion crates/node/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ reth-node-core.workspace = true
reth-node-events.workspace = true
reth-node-metrics.workspace = true
reth-payload-builder.workspace = true
reth-payload-validator.workspace = true
reth-primitives.workspace = true
reth-provider.workspace = true
reth-prune.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/payload/primitives/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{MessageValidationKind, PayloadAttributes};
use alloy_eips::eip4895::Withdrawal;
use alloy_primitives::B256;
use alloy_rpc_types_engine::ExecutionPayload;
use reth_taiko_engine_types::TaikoExecutionPayload;

/// Either an [`ExecutionPayload`] or a types that implements the [`PayloadAttributes`] trait.
Expand Down
23 changes: 12 additions & 11 deletions crates/payload/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloy_primitives::{Address, B256, U256};
use alloy_rpc_types_engine::{PayloadAttributes as EthPayloadAttributes, PayloadId};
use reth_chain_state::ExecutedBlock;
use reth_primitives::SealedBlock;
use reth_taiko_engine_types::TaikoPayloadAttributes;

/// Represents a built payload type that contains a built [`SealedBlock`] and can be converted into
/// engine API execution payloads.
Expand Down Expand Up @@ -100,19 +101,19 @@ impl PayloadAttributes for EthPayloadAttributes {
}
}

// impl PayloadAttributes for TaikoPayloadAttributes {
// fn timestamp(&self) -> u64 {
// self.payload_attributes.timestamp()
// }
impl PayloadAttributes for TaikoPayloadAttributes {
fn timestamp(&self) -> u64 {
self.payload_attributes.timestamp()
}

// fn withdrawals(&self) -> Option<&Vec<Withdrawal>> {
// self.payload_attributes.withdrawals()
// }
fn withdrawals(&self) -> Option<&Vec<Withdrawal>> {
self.payload_attributes.withdrawals()
}

// fn parent_beacon_block_root(&self) -> Option<B256> {
// self.payload_attributes.parent_beacon_block_root()
// }
// }
fn parent_beacon_block_root(&self) -> Option<B256> {
self.payload_attributes.parent_beacon_block_root()
}
}

#[cfg(feature = "op")]
impl PayloadAttributes for op_alloy_rpc_types_engine::OpPayloadAttributes {
Expand Down
4 changes: 1 addition & 3 deletions crates/payload/validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use alloy_rpc_types::engine::{
ExecutionPayload, ExecutionPayloadSidecar, MaybeCancunPayloadFields, PayloadError,
};
use alloy_rpc_types::engine::{ExecutionPayloadSidecar, MaybeCancunPayloadFields, PayloadError};
use reth_chainspec::EthereumHardforks;
use reth_primitives::{BlockExt, SealedBlock};
use reth_rpc_types_compat::engine::payload::try_into_block;
Expand Down
5 changes: 1 addition & 4 deletions crates/taiko/engine/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ workspace = true
# reth
reth-rpc-types-compat.workspace = true
reth-payload-primitives.workspace = true
reth-primitives.workspace = true
reth-chain-state.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-primitives.workspace = true
alloy-eips.workspace = true

# taiko
reth-taiko-primitives.workspace = true
reth-taiko-engine-types.workspace = true

# ethereum
reth-ethereum-engine-primitives.workspace = true

# misc
serde.workspace = true
serde_with.workspace = true
alloy-serde = "0.1.3"
alloy-rlp.workspace = true
sha2.workspace = true

Expand Down
5 changes: 1 addition & 4 deletions crates/taiko/engine/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ pub use alloy_rpc_types_engine::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
ExecutionPayloadV1, PayloadAttributes as EthPayloadAttributes,
};
pub use payload::{
TaikoExecutionPayload, TaikoExecutionPayloadEnvelopeV2, TaikoPayloadAttributes,
TaikoPayloadBuilderAttributes,
};
pub use payload::{TaikoExecutionPayloadEnvelopeV2, TaikoPayloadBuilderAttributes};
119 changes: 5 additions & 114 deletions crates/taiko/engine/primitives/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,73 +1,17 @@
//! Payload related types
use alloy_eips::eip4895::{Withdrawal, Withdrawals};
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rlp::{Encodable, RlpDecodable, RlpEncodable};
use alloy_rpc_types_engine::{ExecutionPayload, ExecutionPayloadV2, PayloadAttributes, PayloadId};
use alloy_eips::eip4895::Withdrawals;
use alloy_primitives::{Address, B256, U256};
use alloy_rlp::Encodable;
use alloy_rpc_types_engine::{ExecutionPayloadV2, PayloadId};
use reth_ethereum_engine_primitives::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_rpc_types_compat::engine::payload::block_to_payload_v2;
use reth_taiko_engine_types::{BlockMetadata, TaikoPayloadAttributes};
use reth_taiko_primitives::L1Origin;
use serde::{Deserialize, Serialize};
use serde_with::{base64::Base64, serde_as};
use std::convert::Infallible;

/// Taiko Payload Attributes
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaikoPayloadAttributes {
/// The payload attributes
#[serde(flatten)]
pub payload_attributes: PayloadAttributes,
/// EIP1559 base fee
pub base_fee_per_gas: U256,
/// Data from l1 contract
pub block_metadata: BlockMetadata,
/// l1 anchor information
pub l1_origin: L1Origin,
}

impl reth_payload_primitives::PayloadAttributes for TaikoPayloadAttributes {
fn timestamp(&self) -> u64 {
self.payload_attributes.timestamp()
}

fn withdrawals(&self) -> Option<&Vec<Withdrawal>> {
self.payload_attributes.withdrawals()
}

fn parent_beacon_block_root(&self) -> Option<B256> {
self.payload_attributes.parent_beacon_block_root()
}
}

/// This structure contains the information from l1 contract storage
#[serde_as]
#[derive(
Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, RlpDecodable, RlpEncodable,
)]
#[serde(rename_all = "camelCase")]
pub struct BlockMetadata {
/// The Keccak 256-bit hash of the parent
/// block’s header, in its entirety; formally Hp.
pub beneficiary: Address,
/// A scalar value equal to the current limit of gas expenditure per block; formally Hl.
pub gas_limit: u64,
/// Timestamp in l1
#[serde(with = "alloy_serde::quantity")]
pub timestamp: u64,
/// A 256-bit hash which, combined with the
/// nonce, proves that a sufficient amount of computation has been carried out on this block;
/// formally Hm.
pub mix_hash: B256,
/// The origin transactions data
pub tx_list: Bytes,
/// An arbitrary byte array containing data relevant to this block. This must be 32 bytes or
/// fewer; formally Hx.
#[serde_as(as = "Base64")]
pub extra_data: Vec<u8>,
}

/// Taiko Payload Builder Attributes
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TaikoPayloadBuilderAttributes {
Expand Down Expand Up @@ -191,59 +135,6 @@ impl From<EthBuiltPayload> for TaikoExecutionPayloadEnvelopeV2 {
}
}

/// An tiako execution payload
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TaikoExecutionPayload {
/// Inner V3 payload
#[serde(flatten)]
pub payload_inner: ExecutionPayload,

/// Allow passing txHash directly instead of transactions list
pub tx_hash: B256,
/// Allow passing `WithdrawalsHash` directly instead of withdrawals
pub withdrawals_hash: B256,
}

impl TaikoExecutionPayload {
/// Returns the block hash
pub const fn block_hash(&self) -> B256 {
self.payload_inner.block_hash()
}

/// Returns the block number
pub const fn block_number(&self) -> u64 {
self.payload_inner.block_number()
}

/// Returns the parent hash
pub const fn parent_hash(&self) -> B256 {
self.payload_inner.parent_hash()
}

/// Returns the withdrawals
pub const fn withdrawals(&self) -> Option<&Vec<Withdrawal>> {
self.payload_inner.withdrawals()
}

/// Returns the timestamp
pub const fn timestamp(&self) -> u64 {
self.payload_inner.timestamp()
}
}

impl From<(ExecutionPayload, B256, B256)> for TaikoExecutionPayload {
fn from((payload_inner, tx_hash, withdrawals_hash): (ExecutionPayload, B256, B256)) -> Self {
Self { payload_inner, tx_hash, withdrawals_hash }
}
}

impl From<ExecutionPayload> for TaikoExecutionPayload {
fn from(value: ExecutionPayload) -> Self {
Self { payload_inner: value, tx_hash: B256::default(), withdrawals_hash: B256::default() }
}
}

/// Generates the payload id for the configured payload from the [`PayloadAttributes`].
///
/// Returns an 8-byte identifier by hashing the payload components with sha256 hash.
Expand Down
2 changes: 1 addition & 1 deletion crates/taiko/engine/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
mod payload;

pub use payload::{
ExecutionPayloadInputV2, TaikoExecutionPayload, TaikoExecutionPayloadEnvelopeV2,
BlockMetadata, ExecutionPayloadInputV2, TaikoExecutionPayload, TaikoExecutionPayloadEnvelopeV2,
TaikoExecutionPayloadInputV2, TaikoPayloadAttributes,
};

0 comments on commit 1abccba

Please sign in to comment.