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 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: BatchValidationProvider>(
&self,
cfg: &RollupConfig,
l1_blocks: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BV,
) -> BatchValidity
pub async fn check_batch<BV: BatchValidationProvider>( &self, cfg: &RollupConfig, l1_blocks: &[BlockInfo], l2_safe_head: L2BlockInfo, inclusion_block: &BlockInfo, fetcher: &mut BV, ) -> BatchValidity
Checks if the span batch is valid.
Sourcepub async fn check_batch_prefix<BF: BatchValidationProvider>(
&self,
cfg: &RollupConfig,
l1_origins: &[BlockInfo],
l2_safe_head: L2BlockInfo,
inclusion_block: &BlockInfo,
fetcher: &mut BF,
) -> (BatchValidity, Option<L2BlockInfo>)
pub async fn check_batch_prefix<BF: BatchValidationProvider>( &self, cfg: &RollupConfig, l1_origins: &[BlockInfo], l2_safe_head: L2BlockInfo, inclusion_block: &BlockInfo, fetcher: &mut BF, ) -> (BatchValidity, Option<L2BlockInfo>)
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.
Trait Implementations§
Source§impl TryFrom<SpanBatch> for RawSpanBatch
impl TryFrom<SpanBatch> for RawSpanBatch
impl Eq for SpanBatch
impl StructuralPartialEq for SpanBatch
Auto Trait Implementations§
impl Freeze for SpanBatch
impl RefUnwindSafe for SpanBatch
impl Send for SpanBatch
impl Sync for SpanBatch
impl Unpin for SpanBatch
impl UnwindSafe for SpanBatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)