Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
payload::{OpBuiltPayload, OpPayloadBuilderAttributes},
OpPayloadPrimitives,
};
use alloy_consensus::{Transaction, Typed2718};
use alloy_consensus::{BlockHeader, Transaction, Typed2718};
use alloy_primitives::{Bytes, B256, U256};
use alloy_rpc_types_debug::ExecutionWitness;
use alloy_rpc_types_engine::PayloadId;
Expand Down Expand Up @@ -175,7 +175,7 @@ where
/// Computes the witness for the payload.
pub fn payload_witness(
&self,
parent: SealedHeader,
parent: SealedHeader<N::BlockHeader>,
attributes: OpPayloadAttributes,
) -> Result<ExecutionWitness, PayloadBuilderError> {
let attributes = OpPayloadBuilderAttributes::try_new(parent.hash(), attributes, 3)
Expand Down Expand Up @@ -231,7 +231,7 @@ where
// system txs, hence on_missing_payload we return [MissingPayloadBehaviour::AwaitInProgress].
fn build_empty_payload(
&self,
config: PayloadConfig<Self::Attributes>,
config: PayloadConfig<Self::Attributes, N::BlockHeader>,
) -> Result<Self::BuiltPayload, PayloadBuilderError> {
let args = BuildArguments {
config,
Expand Down Expand Up @@ -290,7 +290,7 @@ impl<Txs> OpBuilder<'_, Txs> {
PayloadTransactions<Transaction: PoolTransaction<Consensus = N::SignedTx> + OpPooledTx>,
{
let Self { best } = self;
debug!(target: "payload_builder", id=%ctx.payload_id(), parent_header = ?ctx.parent().hash(), parent_number = ctx.parent().number, "building new payload");
debug!(target: "payload_builder", id=%ctx.payload_id(), parent_header = ?ctx.parent().hash(), parent_number = ctx.parent().number(), "building new payload");

let mut db = State::builder().with_database(db).with_bundle_update().build();

Expand Down Expand Up @@ -328,7 +328,7 @@ impl<Txs> OpBuilder<'_, Txs> {
let execution_outcome = ExecutionOutcome::new(
db.take_bundle(),
vec![execution_result.receipts],
block.number,
block.number(),
Vec::new(),
);

Expand Down Expand Up @@ -486,7 +486,10 @@ pub struct OpPayloadBuilderCtx<Evm: ConfigureEvm, ChainSpec> {
/// The chainspec
pub chain_spec: Arc<ChainSpec>,
/// How to build the payload.
pub config: PayloadConfig<OpPayloadBuilderAttributes<TxTy<Evm::Primitives>>>,
pub config: PayloadConfig<
OpPayloadBuilderAttributes<TxTy<Evm::Primitives>>,
<Evm::Primitives as NodePrimitives>::BlockHeader,
>,
/// Marker to check whether the job has been cancelled.
pub cancel: CancelOnDrop,
/// The currently best payload.
Expand All @@ -499,8 +502,8 @@ where
ChainSpec: EthChainSpec + OpHardforks,
{
/// Returns the parent block the payload will be build on.
pub fn parent(&self) -> &SealedHeader {
&self.config.parent_header
pub fn parent(&self) -> &SealedHeader<<Evm::Primitives as NodePrimitives>::BlockHeader> {
self.config.parent_header.as_ref()
}

/// Returns the builder attributes.
Expand Down Expand Up @@ -561,7 +564,10 @@ where
timestamp: self.attributes().timestamp(),
suggested_fee_recipient: self.attributes().suggested_fee_recipient(),
prev_randao: self.attributes().prev_randao(),
gas_limit: self.attributes().gas_limit.unwrap_or(self.parent().gas_limit),
gas_limit: self
.attributes()
.gas_limit
.unwrap_or_else(|| self.parent().gas_limit()),
parent_beacon_block_root: self.attributes().parent_beacon_block_root(),
extra_data: self.extra_data()?,
},
Expand Down
16 changes: 3 additions & 13 deletions crates/optimism/payload/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use alloy_consensus::{BlockBody, Header};
use alloy_consensus::BlockBody;
use reth_optimism_primitives::{transaction::OpTransaction, DepositReceipt};
use reth_primitives_traits::{NodePrimitives, SignedTransaction};

/// Helper trait to encapsulate common bounds on [`NodePrimitives`] for OP payload builder.
pub trait OpPayloadPrimitives:
NodePrimitives<
Receipt: DepositReceipt,
SignedTx = Self::_TX,
BlockHeader = Header,
BlockBody = BlockBody<Self::_TX>,
>
NodePrimitives<Receipt: DepositReceipt, SignedTx = Self::_TX, BlockBody = BlockBody<Self::_TX>>
{
/// Helper AT to bound [`NodePrimitives::Block`] type without causing bound cycle.
type _TX: SignedTransaction + OpTransaction;
Expand All @@ -18,12 +13,7 @@ pub trait OpPayloadPrimitives:
impl<Tx, T> OpPayloadPrimitives for T
where
Tx: SignedTransaction + OpTransaction,
T: NodePrimitives<
SignedTx = Tx,
Receipt: DepositReceipt,
BlockHeader = Header,
BlockBody = BlockBody<Tx>,
>,
T: NodePrimitives<SignedTx = Tx, Receipt: DepositReceipt, BlockBody = BlockBody<Tx>>,
{
type _TX = Tx;
}
19 changes: 13 additions & 6 deletions crates/optimism/rpc/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use reth_rpc_api::DebugExecutionWitnessApiServer;
use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
use reth_storage_api::{
errors::{ProviderError, ProviderResult},
BlockReaderIdExt, NodePrimitivesProvider, StateProviderFactory,
BlockReaderIdExt, HeaderProvider, NodePrimitivesProvider, StateProviderFactory,
};
use reth_tasks::TaskSpawner;
use reth_transaction_pool::TransactionPool;
Expand Down Expand Up @@ -44,10 +44,15 @@ impl<Pool, Provider, EvmConfig> OpDebugWitnessApi<Pool, Provider, EvmConfig> {
impl<Pool, Provider, EvmConfig> OpDebugWitnessApi<Pool, Provider, EvmConfig>
where
EvmConfig: ConfigureEvm,
Provider: NodePrimitivesProvider + BlockReaderIdExt<Header = alloy_consensus::Header>,
Provider: NodePrimitivesProvider<
Primitives: NodePrimitives<BlockHeader = <Provider as HeaderProvider>::Header>,
> + BlockReaderIdExt,
{
/// Fetches the parent header by hash.
fn parent_header(&self, parent_block_hash: B256) -> ProviderResult<SealedHeader> {
fn parent_header(
&self,
parent_block_hash: B256,
) -> ProviderResult<SealedHeader<<Provider as HeaderProvider>::Header>> {
self.inner
.provider
.sealed_header_by_hash(parent_block_hash)?
Expand All @@ -62,9 +67,11 @@ where
Pool: TransactionPool<
Transaction: OpPooledTx<Consensus = <Provider::Primitives as NodePrimitives>::SignedTx>,
> + 'static,
Provider: BlockReaderIdExt<Header = alloy_consensus::Header>
+ NodePrimitivesProvider<Primitives: OpPayloadPrimitives>
+ StateProviderFactory
Provider: BlockReaderIdExt
+ NodePrimitivesProvider<
Primitives: OpPayloadPrimitives
+ NodePrimitives<BlockHeader = <Provider as HeaderProvider>::Header>,
> + StateProviderFactory
+ ChainSpecProvider<ChainSpec = OpChainSpec>
+ Clone
+ 'static,
Expand Down
Loading