MCPcopy Create free account
hub / github.com/base/base / refresh_same_block_header

Method refresh_same_block_header

crates/execution/flashblocks/src/block_assembler.rs:138–165  ·  view source on GitHub ↗

Refreshes a same-block pending header without rebuilding the full block body.

(
        previous_header: &Sealed<Header>,
        flashblocks: &[Flashblock],
    )

Source from the content-addressed store, hash-verified

136
137 /// Refreshes a same-block pending header without rebuilding the full block body.
138 pub fn refresh_same_block_header(
139 previous_header: &Sealed<Header>,
140 flashblocks: &[Flashblock],
141 ) -> Result<Sealed<Header>> {
142 let latest_flashblock = flashblocks.last().ok_or(ProtocolError::EmptyFlashblocks)?;
143 let transactions_root = proofs::ordered_trie_root_with_encoder(
144 &flashblocks
145 .iter()
146 .flat_map(|flashblock| flashblock.diff.transactions.iter())
147 .collect::<Vec<_>>(),
148 |transaction, buf| buf.put_slice(transaction.as_ref()),
149 );
150
151 let mut header = previous_header.inner().clone();
152 header.transactions_root = transactions_root;
153 header.state_root = latest_flashblock.diff.state_root;
154 header.receipts_root = latest_flashblock.diff.receipts_root;
155 header.logs_bloom = latest_flashblock.diff.logs_bloom;
156 header.gas_used = latest_flashblock.diff.gas_used;
157 if header.withdrawals_root.is_some() {
158 header.withdrawals_root = Some(latest_flashblock.diff.withdrawals_root);
159 }
160 if previous_header.inner().blob_gas_used.is_some() {
161 header.blob_gas_used = Some(latest_flashblock.diff.blob_gas_used.unwrap_or_default());
162 }
163
164 Ok(header.seal(B256::ZERO))
165 }
166}
167
168#[cfg(test)]

Callers

nothing calls this directly

Calls 5

is_someMethod · 0.80
iterMethod · 0.45
as_refMethod · 0.45
cloneMethod · 0.45
innerMethod · 0.45

Tested by

no test coverage detected