BlockProducer

Trait BlockProducer 

Source
pub trait BlockProducer:
    Send
    + Sync
    + 'static {
    // Required methods
    fn cache_init_message(
        &self,
        l2_msg: &[u8],
    ) -> Result<(), BlockProducerError>;
    fn produce_block<'life0, 'async_trait>(
        &'life0 self,
        msg_idx: u64,
        input: BlockProductionInput,
    ) -> Pin<Box<dyn Future<Output = Result<ProducedBlock, BlockProducerError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for producing blocks from L1 messages.

Implemented by the node infrastructure where full database and EVM access is available.

Required Methods§

Source

fn cache_init_message(&self, l2_msg: &[u8]) -> Result<(), BlockProducerError>

Cache the Init message params for later use during block 1 execution.

The Init message (Kind=11) does NOT produce a block. Its params are applied during the first real block’s pre-execution so that the state root for block 1 includes both Init and execution changes.

Source

fn produce_block<'life0, 'async_trait>( &'life0 self, msg_idx: u64, input: BlockProductionInput, ) -> Pin<Box<dyn Future<Output = Result<ProducedBlock, BlockProducerError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produce a block from the given L1 incoming message.

The implementation should:

  1. Parse the L1 message into transactions
  2. Open the state at the current head
  3. Execute transactions using the ArbOS pipeline
  4. Compute the state root
  5. Persist the block and state changes
  6. Return the block hash and send root

Implementors§