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§
Sourcefn cache_init_message(&self, l2_msg: &[u8]) -> Result<(), BlockProducerError>
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.
Sourcefn 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,
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:
- Parse the L1 message into transactions
- Open the state at the current head
- Execute transactions using the ArbOS pipeline
- Compute the state root
- Persist the block and state changes
- Return the block hash and send root