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;
// Provided methods
fn reset_to_block<'life0, 'async_trait>(
&'life0 self,
_target_block_number: u64,
) -> Pin<Box<dyn Future<Output = Result<(), BlockProducerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn set_finality(
&self,
_safe: Option<B256>,
_finalized: Option<B256>,
_validated: Option<B256>,
) -> Result<(), BlockProducerError> { ... }
fn attach_validated_watcher(&self, _watcher: Arc<RwLock<B256>>) { ... }
}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
Provided Methods§
Sourcefn reset_to_block<'life0, 'async_trait>(
&'life0 self,
_target_block_number: u64,
) -> Pin<Box<dyn Future<Output = Result<(), BlockProducerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_to_block<'life0, 'async_trait>(
&'life0 self,
_target_block_number: u64,
) -> Pin<Box<dyn Future<Output = Result<(), BlockProducerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reset the canonical chain head to the given block number.
Used by nitroexecution_reorg to roll back state before replaying
divergent messages. The concrete implementation should truncate
blocks above target_block_number from the canonical chain,
making that block the new head. Receipts and transactions above
the target should be removed.
Default implementation returns an “unsupported” error. Node implementations that support reorg should override this.
Sourcefn set_finality(
&self,
_safe: Option<B256>,
_finalized: Option<B256>,
_validated: Option<B256>,
) -> Result<(), BlockProducerError>
fn set_finality( &self, _safe: Option<B256>, _finalized: Option<B256>, _validated: Option<B256>, ) -> Result<(), BlockProducerError>
Mark finality metadata (safe / finalized / validated block hashes) on the canonical chain.
Nitro’s consensus layer calls setFinalityData periodically to
propagate finality information derived from L1 confirmations.
The execution client should store these markers so that RPC
queries like eth_getBlockByNumber("finalized") return the
correct block.
Default impl is a no-op; node implementations override if they support finality tracking.
Sourcefn attach_validated_watcher(&self, _watcher: Arc<RwLock<B256>>)
fn attach_validated_watcher(&self, _watcher: Arc<RwLock<B256>>)
Attach an external validated-block watcher. The producer should
write the current validated marker into the provided shared
slot on every set_finality call so RPC handlers (which hold
the same handle) can surface the value.
No-op by default; concrete producers override.