pub struct SpanBatch {
pub parent_check: FixedBytes<20>,
pub l1_origin_check: FixedBytes<20>,
pub genesis_timestamp: u64,
pub chain_id: u64,
pub batches: Vec<SpanBatchElement>,
pub origin_bits: SpanBatchBits,
pub block_tx_counts: Vec<u64>,
pub txs: SpanBatchTransactions,
}
Expand description
The span batch contains the input to build a span of L2 blocks in derived form.
Fields§
§parent_check: FixedBytes<20>
First 20 bytes of the first block’s parent hash
l1_origin_check: FixedBytes<20>
First 20 bytes of the last block’s L1 origin hash
genesis_timestamp: u64
Genesis block timestamp
chain_id: u64
Chain ID
batches: Vec<SpanBatchElement>
List of block input in derived form
origin_bits: SpanBatchBits
Caching - origin bits
block_tx_counts: Vec<u64>
Caching - block tx counts
txs: SpanBatchTransactions
Caching - span batch txs
Implementations§
Source§impl SpanBatch
impl SpanBatch
Sourcepub fn starting_timestamp(&self) -> u64
pub fn starting_timestamp(&self) -> u64
Returns the starting timestamp for the first batch in the span.
§Safety
Panics if Self::batches is empty.
Sourcepub fn final_timestamp(&self) -> u64
pub fn final_timestamp(&self) -> u64
Returns the final timestamp for the last batch in the span.
§Safety
Panics if Self::batches is empty.
Sourcepub fn starting_epoch_num(&self) -> u64
pub fn starting_epoch_num(&self) -> u64
Sourcepub fn check_origin_hash(&self, hash: FixedBytes<32>) -> bool
pub fn check_origin_hash(&self, hash: FixedBytes<32>) -> bool
Checks if the first 20 bytes of the given hash match the L1 origin check.
Sourcepub fn check_parent_hash(&self, hash: FixedBytes<32>) -> bool
pub fn check_parent_hash(&self, hash: FixedBytes<32>) -> bool
Checks if the first 20 bytes of the given hash match the parent check.
Sourcepub fn to_raw_span_batch(&self) -> Result<RawSpanBatch, SpanBatchError>
pub fn to_raw_span_batch(&self) -> Result<RawSpanBatch, SpanBatchError>
Constructs a RawSpanBatch from the SpanBatch.
Sourcepub fn get_singular_batches(
&self,
l1_origins: &[BlockInfo],
l2_safe_head: L2BlockInfo,
) -> Result<Vec<SingleBatch>, SpanBatchError>
pub fn get_singular_batches( &self, l1_origins: &[BlockInfo], l2_safe_head: L2BlockInfo, ) -> Result<Vec<SingleBatch>, SpanBatchError>
Converts all SpanBatchElements after the L2 safe head to SingleBatches. The resulting SingleBatches do not contain a parent hash, as it is populated by the Batch Queue stage.
Sourcepub fn append_singular_batch(
&mut self,
singular_batch: SingleBatch,
seq_num: u64,
) -> Result<(), SpanBatchError>
pub fn append_singular_batch( &mut self, singular_batch: SingleBatch, seq_num: u64, ) -> Result<(), SpanBatchError>
Append a SingleBatch to the SpanBatch. Updates the L1 origin check if need be.
Sourcepub async fn check_batch<BV>(
&self,
cfg: &RollupConfig,
l1_blocks: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BV,
) -> BatchValiditywhere
BV: BatchValidationProvider,
pub async fn check_batch<BV>(
&self,
cfg: &RollupConfig,
l1_blocks: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BV,
) -> BatchValiditywhere
BV: BatchValidationProvider,
Checks if the span batch is valid.
Sourcepub async fn check_batch_prefix<BF>(
&self,
cfg: &RollupConfig,
l1_origins: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BF,
) -> (BatchValidity, Option<L2BlockInfo>)where
BF: BatchValidationProvider,
pub async fn check_batch_prefix<BF>(
&self,
cfg: &RollupConfig,
l1_origins: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BF,
) -> (BatchValidity, Option<L2BlockInfo>)where
BF: BatchValidationProvider,
Checks the validity of the batch’s prefix.
This function is used for post-Holocene hardfork to perform batch validation as each batch is being loaded in.