@@ -2,13 +2,16 @@ use super::bundler::{Bundle, BundlePoller};
2
2
use super :: oauth:: Authenticator ;
3
3
use super :: tx_poller:: TxPoller ;
4
4
use crate :: config:: { BuilderConfig , WalletlessProvider } ;
5
+ use crate :: tasks:: simulator:: SimulatorFactory ;
5
6
use alloy:: {
6
7
consensus:: { SidecarBuilder , SidecarCoder , TxEnvelope } ,
7
8
eips:: eip2718:: Decodable2718 ,
8
9
primitives:: { keccak256, Bytes , B256 } ,
9
10
providers:: Provider as _,
10
11
rlp:: Buf ,
11
12
} ;
13
+ use revm:: db:: { AlloyDB , CacheDB } ;
14
+ use std:: sync:: Arc ;
12
15
use std:: time:: { SystemTime , UNIX_EPOCH } ;
13
16
use std:: { sync:: OnceLock , time:: Duration } ;
14
17
use tokio:: { sync:: mpsc, task:: JoinHandle } ;
@@ -238,13 +241,29 @@ impl BlockBuilder {
238
241
tokio:: time:: sleep ( Duration :: from_secs ( self . secs_to_next_target ( ) ) ) . await ;
239
242
info ! ( "beginning block build cycle" ) ;
240
243
241
- // Build a block
242
- let mut in_progress = InProgressBlock :: default ( ) ;
243
- self . get_transactions ( & mut in_progress) . await ;
244
- self . get_bundles ( & mut in_progress) . await ;
245
-
246
- // Filter confirmed transactions from the block
247
- self . filter_transactions ( & mut in_progress) . await ;
244
+ // Setup a simulator factory
245
+ let ru_provider = self . ru_provider . clone ( ) ;
246
+ let latest = ru_provider. get_block_number ( ) . await . unwrap ( ) ;
247
+ let db = AlloyDB :: new (
248
+ ru_provider. into ( ) ,
249
+ alloy_eips:: BlockId :: Number ( latest. into ( ) ) ,
250
+ ) ;
251
+
252
+ // Calculate the simulation deadline
253
+ let deadline = self . secs_to_next_target ( ) ;
254
+
255
+ // Create a simulator instance
256
+ if let Some ( db) = db {
257
+ let cache_db = CacheDB :: new ( Arc :: new ( db) ) ;
258
+ let sim = SimulatorFactory :: new ( cache_db, ( ) ) ;
259
+
260
+ // TODO: Plumb the
261
+ let in_progress =
262
+ sim. spawn ( inbound_tx, inbound_bundle, evaluator, deadline) . await ;
263
+ outbound. send ( in_progress) ;
264
+ } else {
265
+ todo ! ( "handle failure to get a db" )
266
+ }
248
267
249
268
// submit the block if it has transactions
250
269
if !in_progress. is_empty ( ) {
0 commit comments