@@ -3,20 +3,22 @@ use crate::generator::BuildArguments;
3
3
use crate :: {
4
4
generator:: { BlockCell , PayloadBuilder } ,
5
5
metrics:: OpRBuilderMetrics ,
6
- primitives:: { ExecutedPayload , ExecutionInfo , PayloadBuilderService } ,
6
+ primitives:: {
7
+ estimate_gas_for_builder_tx, signed_builder_tx, ExecutedPayload , ExecutionInfo ,
8
+ PayloadBuilderService ,
9
+ } ,
7
10
tx_signer:: Signer ,
8
11
} ;
9
12
use alloy_consensus:: constants:: EMPTY_WITHDRAWALS ;
10
- use alloy_consensus:: transaction:: Recovered ;
11
13
use alloy_consensus:: {
12
- Eip658Value , Header , Transaction , TxEip1559 , Typed2718 , EMPTY_OMMER_ROOT_HASH ,
14
+ Eip658Value , Header , Transaction , Typed2718 , EMPTY_OMMER_ROOT_HASH ,
13
15
} ;
14
16
use alloy_eips:: merge:: BEACON_NONCE ;
15
17
use alloy_primitives:: private:: alloy_rlp:: Encodable ;
16
- use alloy_primitives:: { Address , Bytes , TxKind , U256 } ;
18
+ use alloy_primitives:: { Bytes , U256 } ;
17
19
use alloy_rpc_types_engine:: PayloadId ;
18
20
use alloy_rpc_types_eth:: Withdrawals ;
19
- use op_alloy_consensus:: { OpDepositReceipt , OpTypedTransaction } ;
21
+ use op_alloy_consensus:: OpDepositReceipt ;
20
22
use reth:: builder:: { components:: PayloadServiceBuilder , node:: FullNodeTypes , BuilderContext } ;
21
23
use reth:: core:: primitives:: InMemorySize ;
22
24
use reth:: payload:: PayloadBuilderHandle ;
@@ -1232,58 +1234,3 @@ where
1232
1234
} )
1233
1235
}
1234
1236
}
1235
-
1236
- /// Creates signed builder tx to Address::ZERO and specified message as input
1237
- pub fn signed_builder_tx < DB > (
1238
- db : & mut State < DB > ,
1239
- builder_tx_gas : u64 ,
1240
- message : Vec < u8 > ,
1241
- signer : Signer ,
1242
- base_fee : u64 ,
1243
- chain_id : u64 ,
1244
- ) -> Result < Recovered < OpTransactionSigned > , PayloadBuilderError >
1245
- where
1246
- DB : Database < Error = ProviderError > ,
1247
- {
1248
- // Create message with block number for the builder to sign
1249
- let nonce = db
1250
- . load_cache_account ( signer. address )
1251
- . map ( |acc| acc. account_info ( ) . unwrap_or_default ( ) . nonce )
1252
- . map_err ( |_| {
1253
- PayloadBuilderError :: other ( OpPayloadBuilderError :: AccountLoadFailed ( signer. address ) )
1254
- } ) ?;
1255
-
1256
- // Create the EIP-1559 transaction
1257
- let tx = OpTypedTransaction :: Eip1559 ( TxEip1559 {
1258
- chain_id,
1259
- nonce,
1260
- gas_limit : builder_tx_gas,
1261
- max_fee_per_gas : base_fee. into ( ) ,
1262
- max_priority_fee_per_gas : 0 ,
1263
- to : TxKind :: Call ( Address :: ZERO ) ,
1264
- // Include the message as part of the transaction data
1265
- input : message. into ( ) ,
1266
- ..Default :: default ( )
1267
- } ) ;
1268
- // Sign the transaction
1269
- let builder_tx = signer. sign_tx ( tx) . map_err ( PayloadBuilderError :: other) ?;
1270
-
1271
- Ok ( builder_tx)
1272
- }
1273
-
1274
- fn estimate_gas_for_builder_tx ( input : Vec < u8 > ) -> u64 {
1275
- // Count zero and non-zero bytes
1276
- let ( zero_bytes, nonzero_bytes) = input. iter ( ) . fold ( ( 0 , 0 ) , |( zeros, nonzeros) , & byte| {
1277
- if byte == 0 {
1278
- ( zeros + 1 , nonzeros)
1279
- } else {
1280
- ( zeros, nonzeros + 1 )
1281
- }
1282
- } ) ;
1283
-
1284
- // Calculate gas cost (4 gas per zero byte, 16 gas per non-zero byte)
1285
- let zero_cost = zero_bytes * 4 ;
1286
- let nonzero_cost = nonzero_bytes * 16 ;
1287
-
1288
- zero_cost + nonzero_cost + 21_000
1289
- }
0 commit comments