@@ -2,7 +2,7 @@ use alloy_consensus::{Eip658Value, Transaction, conditional::BlockConditionalAtt
22use alloy_eips:: Typed2718 ;
33use alloy_evm:: Database ;
44use alloy_op_evm:: block:: receipt_builder:: OpReceiptBuilder ;
5- use alloy_primitives:: { Bytes , U256 } ;
5+ use alloy_primitives:: { BlockHash , Bytes , U256 } ;
66use alloy_rpc_types_eth:: Withdrawals ;
77use core:: fmt:: Debug ;
88use op_alloy_consensus:: OpDepositReceipt ;
@@ -75,41 +75,51 @@ pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
7575
7676impl < ExtraCtx : Debug + Default > OpPayloadBuilderCtx < ExtraCtx > {
7777 /// Returns the parent block the payload will be build on.
78- pub ( super ) fn parent ( & self ) -> & SealedHeader {
78+ pub fn parent ( & self ) -> & SealedHeader {
7979 & self . config . parent_header
8080 }
8181
82+ /// Returns the parent hash
83+ pub fn parent_hash ( & self ) -> BlockHash {
84+ self . parent ( ) . hash ( )
85+ }
86+
87+ /// Returns the timestamp
88+ pub fn timestamp ( & self ) -> u64 {
89+ self . attributes ( ) . timestamp ( )
90+ }
91+
8292 /// Returns the builder attributes.
8393 pub ( super ) const fn attributes ( & self ) -> & OpPayloadBuilderAttributes < OpTransactionSigned > {
8494 & self . config . attributes
8595 }
8696
8797 /// Returns the withdrawals if shanghai is active.
88- pub ( super ) fn withdrawals ( & self ) -> Option < & Withdrawals > {
98+ pub fn withdrawals ( & self ) -> Option < & Withdrawals > {
8999 self . chain_spec
90100 . is_shanghai_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
91101 . then ( || & self . attributes ( ) . payload_attributes . withdrawals )
92102 }
93103
94104 /// Returns the block gas limit to target.
95- pub ( super ) fn block_gas_limit ( & self ) -> u64 {
105+ pub fn block_gas_limit ( & self ) -> u64 {
96106 self . attributes ( )
97107 . gas_limit
98108 . unwrap_or ( self . evm_env . block_env . gas_limit )
99109 }
100110
101111 /// Returns the block number for the block.
102- pub ( super ) fn block_number ( & self ) -> u64 {
112+ pub fn block_number ( & self ) -> u64 {
103113 as_u64_saturated ! ( self . evm_env. block_env. number)
104114 }
105115
106116 /// Returns the current base fee
107- pub ( super ) fn base_fee ( & self ) -> u64 {
117+ pub fn base_fee ( & self ) -> u64 {
108118 self . evm_env . block_env . basefee
109119 }
110120
111121 /// Returns the current blob gas price.
112- pub ( super ) fn get_blob_gasprice ( & self ) -> Option < u64 > {
122+ pub fn get_blob_gasprice ( & self ) -> Option < u64 > {
113123 self . evm_env
114124 . block_env
115125 . blob_gasprice ( )
@@ -119,7 +129,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
119129 /// Returns the blob fields for the header.
120130 ///
121131 /// This will always return `Some(0)` after ecotone.
122- pub ( super ) fn blob_fields ( & self ) -> ( Option < u64 > , Option < u64 > ) {
132+ pub fn blob_fields ( & self ) -> ( Option < u64 > , Option < u64 > ) {
123133 // OP doesn't support blobs/EIP-4844.
124134 // https://specs.optimism.io/protocol/exec-engine.html#ecotone-disable-blob-transactions
125135 // Need [Some] or [None] based on hardfork to match block hash.
@@ -133,7 +143,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
133143 /// Returns the extra data for the block.
134144 ///
135145 /// After holocene this extracts the extradata from the paylpad
136- pub ( super ) fn extra_data ( & self ) -> Result < Bytes , PayloadBuilderError > {
146+ pub fn extra_data ( & self ) -> Result < Bytes , PayloadBuilderError > {
137147 if self . is_holocene_active ( ) {
138148 self . attributes ( )
139149 . get_holocene_extra_data (
@@ -148,47 +158,47 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
148158 }
149159
150160 /// Returns the current fee settings for transactions from the mempool
151- pub ( super ) fn best_transaction_attributes ( & self ) -> BestTransactionsAttributes {
161+ pub fn best_transaction_attributes ( & self ) -> BestTransactionsAttributes {
152162 BestTransactionsAttributes :: new ( self . base_fee ( ) , self . get_blob_gasprice ( ) )
153163 }
154164
155165 /// Returns the unique id for this payload job.
156- pub ( super ) fn payload_id ( & self ) -> PayloadId {
166+ pub fn payload_id ( & self ) -> PayloadId {
157167 self . attributes ( ) . payload_id ( )
158168 }
159169
160170 /// Returns true if regolith is active for the payload.
161- pub ( super ) fn is_regolith_active ( & self ) -> bool {
171+ pub fn is_regolith_active ( & self ) -> bool {
162172 self . chain_spec
163173 . is_regolith_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
164174 }
165175
166176 /// Returns true if ecotone is active for the payload.
167- pub ( super ) fn is_ecotone_active ( & self ) -> bool {
177+ pub fn is_ecotone_active ( & self ) -> bool {
168178 self . chain_spec
169179 . is_ecotone_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
170180 }
171181
172182 /// Returns true if canyon is active for the payload.
173- pub ( super ) fn is_canyon_active ( & self ) -> bool {
183+ pub fn is_canyon_active ( & self ) -> bool {
174184 self . chain_spec
175185 . is_canyon_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
176186 }
177187
178188 /// Returns true if holocene is active for the payload.
179- pub ( super ) fn is_holocene_active ( & self ) -> bool {
189+ pub fn is_holocene_active ( & self ) -> bool {
180190 self . chain_spec
181191 . is_holocene_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
182192 }
183193
184194 /// Returns true if isthmus is active for the payload.
185- pub ( super ) fn is_isthmus_active ( & self ) -> bool {
195+ pub fn is_isthmus_active ( & self ) -> bool {
186196 self . chain_spec
187197 . is_isthmus_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
188198 }
189199
190200 /// Returns the chain id
191- pub ( super ) fn chain_id ( & self ) -> u64 {
201+ pub fn chain_id ( & self ) -> u64 {
192202 self . chain_spec . chain_id ( )
193203 }
194204}
0 commit comments