11//! `block.rs` contains the Simulator and everything that wires it into an
22//! actor that handles the simulation of a stream of bundles and transactions
33//! and turns them into valid Pecorino blocks for network submission.
4+ use super :: cfg:: PecorinoBlockEnv ;
45use crate :: {
56 config:: { BuilderConfig , RuProvider } ,
6- tasks:: bundler:: Bundle ,
7+ tasks:: { block :: cfg :: PecorinoCfg , bundler:: Bundle } ,
78} ;
89use alloy:: {
910 consensus:: TxEnvelope ,
1011 eips:: { BlockId , BlockNumberOrTag :: Latest } ,
1112 network:: Ethereum ,
12- primitives:: { Address , B256 , FixedBytes , U256 } ,
1313 providers:: Provider ,
1414} ;
1515use chrono:: { DateTime , Utc } ;
@@ -33,15 +33,9 @@ use tokio::{
3333 task:: JoinHandle ,
3434 time:: sleep,
3535} ;
36- use trevm:: {
37- Block ,
38- revm:: {
39- context:: { BlockEnv , CfgEnv } ,
40- context_interface:: block:: BlobExcessGasAndPrice ,
41- database:: { AlloyDB , WrapDatabaseAsync } ,
42- inspector:: NoOpInspector ,
43- primitives:: hardfork:: SpecId :: { self } ,
44- } ,
36+ use trevm:: revm:: {
37+ database:: { AlloyDB , WrapDatabaseAsync } ,
38+ inspector:: NoOpInspector ,
4539} ;
4640
4741/// `Simulator` is responsible for periodically building blocks and submitting them for
@@ -409,90 +403,3 @@ async fn cache_updater(
409403 }
410404 }
411405}
412-
413- /// PecorinoCfg holds network-level configuration values.
414- #[ derive( Debug , Clone , Copy ) ]
415- pub struct PecorinoCfg { }
416-
417- impl trevm:: Cfg for PecorinoCfg {
418- /// Fills the configuration environment with Pecorino-specific values.
419- ///
420- /// # Arguments
421- ///
422- /// - `cfg_env`: The configuration environment to be filled.
423- fn fill_cfg_env ( & self , cfg_env : & mut CfgEnv ) {
424- let CfgEnv { chain_id, spec, .. } = cfg_env;
425-
426- * chain_id = signet_constants:: pecorino:: RU_CHAIN_ID ;
427- * spec = SpecId :: default ( ) ;
428- }
429- }
430-
431- /// PecorinoBlockEnv holds block-level configurations for Pecorino blocks.
432- #[ derive( Debug , Clone , Copy ) ]
433- pub struct PecorinoBlockEnv {
434- /// The block number for this block.
435- pub number : u64 ,
436- /// The address the block reward should be sent to.
437- pub beneficiary : Address ,
438- /// Timestamp for the block.
439- pub timestamp : u64 ,
440- /// The gas limit for this block environment.
441- pub gas_limit : u64 ,
442- /// The basefee to use for calculating gas usage.
443- pub basefee : u64 ,
444- /// The prevrandao to use for this block.
445- pub prevrandao : Option < FixedBytes < 32 > > ,
446- }
447-
448- /// Implements [`trevm::Block`] for the Pecorino block.
449- impl Block for PecorinoBlockEnv {
450- /// Fills the block environment with the Pecorino specific values
451- fn fill_block_env ( & self , block_env : & mut trevm:: revm:: context:: BlockEnv ) {
452- // Destructure the fields off of the block_env and modify them
453- let BlockEnv {
454- number,
455- beneficiary,
456- timestamp,
457- gas_limit,
458- basefee,
459- difficulty,
460- prevrandao,
461- blob_excess_gas_and_price,
462- } = block_env;
463- * number = self . number ;
464- * beneficiary = self . beneficiary ;
465- * timestamp = self . timestamp ;
466- * gas_limit = self . gas_limit ;
467- * basefee = self . basefee ;
468- * prevrandao = self . prevrandao ;
469-
470- // NB: The following fields are set to sane defaults because they
471- // are not supported by the rollup
472- * difficulty = U256 :: ZERO ;
473- * blob_excess_gas_and_price =
474- Some ( BlobExcessGasAndPrice { excess_blob_gas : 0 , blob_gasprice : 0 } ) ;
475- }
476- }
477-
478- impl PecorinoBlockEnv {
479- /// Returns a new PecorinoBlockEnv with the specified values.
480- ///
481- /// # Arguments
482- ///
483- /// - config: The BuilderConfig for the builder.
484- /// - number: The block number of this block, usually the latest block number plus 1,
485- /// unless simulating blocks in the past.
486- /// - timestamp: The timestamp of the block, typically set to the deadline of the
487- /// block building task.
488- fn new ( config : BuilderConfig , number : u64 , timestamp : u64 , basefee : u64 ) -> Self {
489- PecorinoBlockEnv {
490- number,
491- beneficiary : config. builder_rewards_address ,
492- timestamp,
493- gas_limit : config. rollup_block_gas_limit ,
494- basefee,
495- prevrandao : Some ( B256 :: random ( ) ) ,
496- }
497- }
498- }
0 commit comments