reth_optimism_payload_builder/
traits.rs

1use alloy_consensus::BlockBody;
2use reth_optimism_primitives::{transaction::OpTransaction, DepositReceipt};
3use reth_payload_primitives::PayloadBuilderAttributes;
4use reth_primitives_traits::{FullBlockHeader, NodePrimitives, SignedTransaction, WithEncoded};
5
6use crate::OpPayloadBuilderAttributes;
7
8/// Helper trait to encapsulate common bounds on [`NodePrimitives`] for OP payload builder.
9pub trait OpPayloadPrimitives:
10    NodePrimitives<
11    Receipt: DepositReceipt,
12    SignedTx = Self::_TX,
13    BlockBody = BlockBody<Self::_TX, Self::_Header>,
14    BlockHeader = Self::_Header,
15>
16{
17    /// Helper AT to bound [`NodePrimitives::Block`] type without causing bound cycle.
18    type _TX: SignedTransaction + OpTransaction;
19    /// Helper AT to bound [`NodePrimitives::Block`] type without causing bound cycle.
20    type _Header: FullBlockHeader;
21}
22
23impl<Tx, T, Header> OpPayloadPrimitives for T
24where
25    Tx: SignedTransaction + OpTransaction,
26    T: NodePrimitives<
27        SignedTx = Tx,
28        Receipt: DepositReceipt,
29        BlockBody = BlockBody<Tx, Header>,
30        BlockHeader = Header,
31    >,
32    Header: FullBlockHeader,
33{
34    type _TX = Tx;
35    type _Header = Header;
36}
37
38/// Attributes for the OP payload builder.
39pub trait OpAttributes: PayloadBuilderAttributes {
40    /// Primitive transaction type.
41    type Transaction: SignedTransaction;
42
43    /// Whether to use the transaction pool for the payload.
44    fn no_tx_pool(&self) -> bool;
45
46    /// Sequencer transactions to include in the payload.
47    fn sequencer_transactions(&self) -> &[WithEncoded<Self::Transaction>];
48}
49
50impl<T: SignedTransaction> OpAttributes for OpPayloadBuilderAttributes<T> {
51    type Transaction = T;
52
53    fn no_tx_pool(&self) -> bool {
54        self.no_tx_pool
55    }
56
57    fn sequencer_transactions(&self) -> &[WithEncoded<Self::Transaction>] {
58        &self.transactions
59    }
60}