@@ -2,7 +2,7 @@ use alloy_consensus::{Eip658Value, Transaction, conditional::BlockConditionalAtt
2
2
use alloy_eips:: Typed2718 ;
3
3
use alloy_evm:: Database ;
4
4
use alloy_op_evm:: block:: receipt_builder:: OpReceiptBuilder ;
5
- use alloy_primitives:: { Bytes , U256 } ;
5
+ use alloy_primitives:: { BlockHash , Bytes , U256 } ;
6
6
use alloy_rpc_types_eth:: Withdrawals ;
7
7
use core:: fmt:: Debug ;
8
8
use op_alloy_consensus:: OpDepositReceipt ;
@@ -75,41 +75,51 @@ pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
75
75
76
76
impl < ExtraCtx : Debug + Default > OpPayloadBuilderCtx < ExtraCtx > {
77
77
/// Returns the parent block the payload will be build on.
78
- pub ( super ) fn parent ( & self ) -> & SealedHeader {
78
+ pub fn parent ( & self ) -> & SealedHeader {
79
79
& self . config . parent_header
80
80
}
81
81
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
+
82
92
/// Returns the builder attributes.
83
93
pub ( super ) const fn attributes ( & self ) -> & OpPayloadBuilderAttributes < OpTransactionSigned > {
84
94
& self . config . attributes
85
95
}
86
96
87
97
/// Returns the withdrawals if shanghai is active.
88
- pub ( super ) fn withdrawals ( & self ) -> Option < & Withdrawals > {
98
+ pub fn withdrawals ( & self ) -> Option < & Withdrawals > {
89
99
self . chain_spec
90
100
. is_shanghai_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
91
101
. then ( || & self . attributes ( ) . payload_attributes . withdrawals )
92
102
}
93
103
94
104
/// Returns the block gas limit to target.
95
- pub ( super ) fn block_gas_limit ( & self ) -> u64 {
105
+ pub fn block_gas_limit ( & self ) -> u64 {
96
106
self . attributes ( )
97
107
. gas_limit
98
108
. unwrap_or ( self . evm_env . block_env . gas_limit )
99
109
}
100
110
101
111
/// Returns the block number for the block.
102
- pub ( super ) fn block_number ( & self ) -> u64 {
112
+ pub fn block_number ( & self ) -> u64 {
103
113
as_u64_saturated ! ( self . evm_env. block_env. number)
104
114
}
105
115
106
116
/// Returns the current base fee
107
- pub ( super ) fn base_fee ( & self ) -> u64 {
117
+ pub fn base_fee ( & self ) -> u64 {
108
118
self . evm_env . block_env . basefee
109
119
}
110
120
111
121
/// 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 > {
113
123
self . evm_env
114
124
. block_env
115
125
. blob_gasprice ( )
@@ -119,7 +129,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
119
129
/// Returns the blob fields for the header.
120
130
///
121
131
/// 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 > ) {
123
133
// OP doesn't support blobs/EIP-4844.
124
134
// https://specs.optimism.io/protocol/exec-engine.html#ecotone-disable-blob-transactions
125
135
// Need [Some] or [None] based on hardfork to match block hash.
@@ -133,7 +143,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
133
143
/// Returns the extra data for the block.
134
144
///
135
145
/// 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 > {
137
147
if self . is_holocene_active ( ) {
138
148
self . attributes ( )
139
149
. get_holocene_extra_data (
@@ -148,47 +158,47 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
148
158
}
149
159
150
160
/// 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 {
152
162
BestTransactionsAttributes :: new ( self . base_fee ( ) , self . get_blob_gasprice ( ) )
153
163
}
154
164
155
165
/// Returns the unique id for this payload job.
156
- pub ( super ) fn payload_id ( & self ) -> PayloadId {
166
+ pub fn payload_id ( & self ) -> PayloadId {
157
167
self . attributes ( ) . payload_id ( )
158
168
}
159
169
160
170
/// 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 {
162
172
self . chain_spec
163
173
. is_regolith_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
164
174
}
165
175
166
176
/// 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 {
168
178
self . chain_spec
169
179
. is_ecotone_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
170
180
}
171
181
172
182
/// 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 {
174
184
self . chain_spec
175
185
. is_canyon_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
176
186
}
177
187
178
188
/// 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 {
180
190
self . chain_spec
181
191
. is_holocene_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
182
192
}
183
193
184
194
/// 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 {
186
196
self . chain_spec
187
197
. is_isthmus_active_at_timestamp ( self . attributes ( ) . timestamp ( ) )
188
198
}
189
199
190
200
/// Returns the chain id
191
- pub ( super ) fn chain_id ( & self ) -> u64 {
201
+ pub fn chain_id ( & self ) -> u64 {
192
202
self . chain_spec . chain_id ( )
193
203
}
194
204
}
0 commit comments