@@ -22,7 +22,6 @@ use alloy::{
22
22
} ,
23
23
signers:: { local:: PrivateKeySigner , Signer } ,
24
24
} ;
25
- use eyre:: Context ;
26
25
use init4_bin_base:: {
27
26
deps:: tracing:: debug,
28
27
deps:: tracing_subscriber:: {
@@ -258,52 +257,6 @@ async fn test_send_valid_bundle_mainnet() {
258
257
assert ! ( resp. bundle_hash != B256 :: ZERO ) ;
259
258
}
260
259
261
- /// Asserts that a tx was included in Sepolia within `deadline` seconds.
262
- async fn assert_tx_included ( sepolia : & SepoliaProvider , tx_hash : B256 , deadline : u64 ) {
263
- let now = Instant :: now ( ) ;
264
- let deadline = now + Duration :: from_secs ( deadline) ;
265
- let mut found = false ;
266
-
267
- loop {
268
- let n = Instant :: now ( ) ;
269
- if n >= deadline {
270
- break ;
271
- }
272
-
273
- match sepolia. get_transaction_by_hash ( tx_hash) . await {
274
- Ok ( Some ( _tx) ) => {
275
- found = true ;
276
- break ;
277
- }
278
- Ok ( None ) => {
279
- // Not yet present; wait and retry
280
- dbg ! ( "transaction not yet seen" ) ;
281
- tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
282
- }
283
- Err ( err) => {
284
- // Transient error querying the provider; log and retry
285
- eprintln ! ( "warning: error querying tx: {}" , err) ;
286
- tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
287
- }
288
- }
289
- }
290
-
291
- assert ! (
292
- found,
293
- "transaction was not seen by the provider within {:?} seconds" ,
294
- deadline
295
- ) ;
296
- }
297
-
298
- /// Initializes logger for printing during testing
299
- pub fn setup_logging ( ) {
300
- // Initialize logging
301
- let filter = EnvFilter :: from_default_env ( ) ;
302
- let fmt = fmt:: layer ( ) . with_filter ( filter) ;
303
- let registry = registry ( ) . with ( fmt) ;
304
- let _ = registry. try_init ( ) ;
305
- }
306
-
307
260
#[ tokio:: test]
308
261
#[ ignore = "integration test" ]
309
262
async fn test_alloy_flashbots_sepolia ( ) {
@@ -325,7 +278,7 @@ async fn test_alloy_flashbots_sepolia() {
325
278
. value ( U256 :: from ( 0u64 ) )
326
279
. gas_limit ( 21_000 )
327
280
. max_fee_per_gas ( ( 50 * GWEI_TO_WEI ) . into ( ) )
328
- . max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
281
+ . max_priority_fee_per_gas ( ( 20 * GWEI_TO_WEI ) . into ( ) )
329
282
. from ( builder_key. address ( ) ) ;
330
283
331
284
let block = sepolia_host
@@ -345,14 +298,6 @@ async fn test_alloy_flashbots_sepolia() {
345
298
let bundle = EthSendBundle {
346
299
txs : vec ! [ tx_bytes. clone( ) . into( ) ] ,
347
300
block_number : target_block,
348
- min_timestamp : None ,
349
- max_timestamp : None ,
350
- reverting_tx_hashes : vec ! [ ] ,
351
- replacement_uuid : None ,
352
- dropping_tx_hashes : vec ! [ ] ,
353
- refund_percent : None ,
354
- refund_recipient : None ,
355
- refund_tx_hashes : vec ! [ ] ,
356
301
..Default :: default ( )
357
302
} ;
358
303
@@ -372,7 +317,7 @@ async fn test_alloy_flashbots_sepolia() {
372
317
373
318
#[ tokio:: test]
374
319
#[ ignore = "integration test" ]
375
- async fn test_mev_endpoints ( ) {
320
+ async fn test_mev_endpoints_sepolia ( ) {
376
321
setup_logging ( ) ;
377
322
378
323
let raw_key = env:: var ( "BUILDER_KEY" ) . expect ( "BUILDER_KEY must be set" ) ;
@@ -384,6 +329,7 @@ async fn test_mev_endpoints() {
384
329
. wallet ( builder_key. clone ( ) )
385
330
. connect_http ( "https://relay-sepolia.flashbots.net" . parse ( ) . unwrap ( ) ) ;
386
331
332
+ // TEMP: Keeping this around because alloy flashbots doesn't have a simulate endpoint for `mev_simBundle`.
387
333
let old_flashbots = Flashbots :: new (
388
334
"https://relay-sepolia.flashbots.net" . parse ( ) . unwrap ( ) ,
389
335
builder_key. clone ( ) ,
@@ -404,7 +350,7 @@ async fn test_mev_endpoints() {
404
350
. value ( U256 :: from ( 0u64 ) )
405
351
. gas_limit ( 21_000 )
406
352
. max_fee_per_gas ( ( 50 * GWEI_TO_WEI ) . into ( ) )
407
- . max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
353
+ . max_priority_fee_per_gas ( ( 20 * GWEI_TO_WEI ) . into ( ) )
408
354
. from ( builder_key. address ( ) ) ;
409
355
410
356
let SendableTx :: Envelope ( tx) = sepolia_host. fill ( req. clone ( ) ) . await . unwrap ( ) else {
@@ -430,15 +376,6 @@ async fn test_mev_endpoints() {
430
376
. send_mev_bundle ( bundle)
431
377
. with_auth ( builder_key. clone ( ) ) ;
432
378
dbg ! ( "send mev bundle:" , result. await . unwrap( ) ) ;
433
-
434
- let result = flashbots
435
- . send_private_transaction ( EthSendPrivateTransaction {
436
- tx : tx_bytes. into ( ) ,
437
- max_block_number : Some ( target_block + 5 ) ,
438
- preferences : PrivateTransactionPreferences :: default ( ) ,
439
- } )
440
- . with_auth ( builder_key. clone ( ) ) ;
441
- dbg ! ( "send private transaction" , result. await . unwrap( ) ) ;
442
379
}
443
380
444
381
#[ tokio:: test]
@@ -453,9 +390,11 @@ async fn test_alloy_flashbots_mainnet() {
453
390
454
391
let flashbots = ProviderBuilder :: new ( )
455
392
. wallet ( builder_key. clone ( ) )
456
- . connect_http ( "https://relay-sepolia .flashbots.net" . parse ( ) . unwrap ( ) ) ;
393
+ . connect_http ( "https://relay.flashbots.net" . parse ( ) . unwrap ( ) ) ;
457
394
458
- let sepolia_host = get_sepolia_host ( builder_key. clone ( ) ) ;
395
+ let mainnet = ProviderBuilder :: new ( )
396
+ . wallet ( builder_key. clone ( ) )
397
+ . connect_http ( "https://ethereum-rpc.publicnode.com" . parse ( ) . unwrap ( ) ) ;
459
398
460
399
let req = TransactionRequest :: default ( )
461
400
. to ( builder_key. address ( ) )
@@ -465,18 +404,14 @@ async fn test_alloy_flashbots_mainnet() {
465
404
. max_priority_fee_per_gas ( ( 2 * GWEI_TO_WEI ) . into ( ) )
466
405
. from ( builder_key. address ( ) ) ;
467
406
468
- let block = sepolia_host
469
- . get_block ( BlockId :: latest ( ) )
470
- . await
471
- . unwrap ( )
472
- . unwrap ( ) ;
407
+ let block = mainnet. get_block ( BlockId :: latest ( ) ) . await . unwrap ( ) . unwrap ( ) ;
473
408
let target_block = block. number ( ) + 1 ;
474
409
dbg ! ( "preparing bundle for" , target_block) ;
475
410
476
411
let target_block = block. number ( ) + 1 ;
477
412
dbg ! ( "preparing bundle for" , target_block) ;
478
413
479
- let SendableTx :: Envelope ( tx) = sepolia_host . fill ( req. clone ( ) ) . await . unwrap ( ) else {
414
+ let SendableTx :: Envelope ( tx) = mainnet . fill ( req. clone ( ) ) . await . unwrap ( ) else {
480
415
panic ! ( "expected filled tx" ) ;
481
416
} ;
482
417
dbg ! ( "prepared transaction request" , tx. clone( ) ) ;
@@ -538,3 +473,49 @@ pub async fn test_send_single_tx_sepolia() {
538
473
. unwrap ( ) ;
539
474
dbg ! ( pending_tx) ;
540
475
}
476
+
477
+ /// Asserts that a tx was included in Sepolia within `deadline` seconds.
478
+ async fn assert_tx_included ( sepolia : & SepoliaProvider , tx_hash : B256 , deadline : u64 ) {
479
+ let now = Instant :: now ( ) ;
480
+ let deadline = now + Duration :: from_secs ( deadline) ;
481
+ let mut found = false ;
482
+
483
+ loop {
484
+ let n = Instant :: now ( ) ;
485
+ if n >= deadline {
486
+ break ;
487
+ }
488
+
489
+ match sepolia. get_transaction_by_hash ( tx_hash) . await {
490
+ Ok ( Some ( _tx) ) => {
491
+ found = true ;
492
+ break ;
493
+ }
494
+ Ok ( None ) => {
495
+ // Not yet present; wait and retry
496
+ dbg ! ( "transaction not yet seen" ) ;
497
+ tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
498
+ }
499
+ Err ( err) => {
500
+ // Transient error querying the provider; log and retry
501
+ eprintln ! ( "warning: error querying tx: {}" , err) ;
502
+ tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
503
+ }
504
+ }
505
+ }
506
+
507
+ assert ! (
508
+ found,
509
+ "transaction was not seen by the provider within {:?} seconds" ,
510
+ deadline
511
+ ) ;
512
+ }
513
+
514
+ /// Initializes logger for printing during testing
515
+ pub fn setup_logging ( ) {
516
+ // Initialize logging
517
+ let filter = EnvFilter :: from_default_env ( ) ;
518
+ let fmt = fmt:: layer ( ) . with_filter ( filter) ;
519
+ let registry = registry ( ) . with ( fmt) ;
520
+ let _ = registry. try_init ( ) ;
521
+ }
0 commit comments