Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): add blob support to the rollup ExEx #8028

Merged
merged 21 commits into from
May 2, 2024

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented May 1, 2024

Closes #7558

This PR adds support for rollup block submissions using either calldata or EIP-4844 blobs

// Get raw transactions either from the blobs, or directly from the block data
let raw_transactions = if matches!(tx.tx_type(), TxType::Eip4844) {
let blobs: Vec<_> = if let Some(sidecar) = pool.get_blob(tx.hash)? {
// Try to get blobs from the transaction pool
sidecar.blobs.into_iter().zip(sidecar.commitments).collect()
} else {
// If transaction is not found in the pool, try to get blobs from the Blobscan
let blobscan_client = foundry_blob_explorers::Client::holesky();
let sidecar = blobscan_client.transaction(tx.hash).await?.blob_sidecar();
sidecar
.blobs
.into_iter()
.map(|blob| (*blob).into())
.zip(sidecar.commitments.into_iter().map(|commitment| (*commitment).into()))
.collect()
};
// Decode blob hashes from block data
let blob_hashes = Vec::<B256>::decode(&mut block_data.as_ref())?;
// Filter blobs that are present in the block data
let blobs = blobs
.into_iter()
// Convert blob KZG commitments to versioned hashes
.map(|(blob, commitment)| (blob, kzg_to_versioned_hash((*commitment).into())))
// Filter only blobs that are present in the block data
.filter(|(_, hash)| blob_hashes.contains(hash))
.map(|(blob, _)| blob)
.collect::<Vec<_>>();
if blobs.len() != blob_hashes.len() {
eyre::bail!("some blobs not found")
}
// Decode blobs and concatenate them to get the raw transactions
let data = SimpleCoder::default()
.decode_all(&blobs)
.ok_or(eyre::eyre!("failed to decode blobs"))?
.concat();
data.into()
} else {
block_data
};

As well as an additional check for the blockDataHash commitment

let raw_transaction_hash = keccak256(&raw_transactions);
if raw_transaction_hash != block_data_hash {
eyre::bail!("block data hash mismatch")
}


The diff is quite large due to moving decoding- and execution-related code to a separate file.

@shekhirin shekhirin added C-enhancement New feature or request A-exex Execution Extensions C-example Examples labels May 1, 2024
@shekhirin shekhirin force-pushed the alexey/exex-rollup-blob branch 2 times, most recently from 27f73b4 to f70880f Compare May 1, 2024 21:23
@shekhirin shekhirin marked this pull request as ready for review May 2, 2024 15:08
@shekhirin shekhirin requested a review from onbjerg May 2, 2024 15:12
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise

examples/exex/rollup/src/execution.rs Outdated Show resolved Hide resolved
examples/exex/rollup/src/execution.rs Show resolved Hide resolved
examples/exex/rollup/src/main.rs Show resolved Hide resolved
examples/exex/rollup/src/main.rs Outdated Show resolved Hide resolved
examples/exex/rollup/src/execution.rs Outdated Show resolved Hide resolved
examples/exex/rollup/src/execution.rs Show resolved Hide resolved
examples/exex/rollup/src/execution.rs Show resolved Hide resolved
examples/exex/rollup/src/execution.rs Show resolved Hide resolved
@shekhirin shekhirin enabled auto-merge May 2, 2024 20:07
@shekhirin shekhirin added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit 2ac2433 May 2, 2024
30 checks passed
@shekhirin shekhirin deleted the alexey/exex-rollup-blob branch May 2, 2024 20:32
mw2000 pushed a commit to mw2000/reth that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exex Execution Extensions C-enhancement New feature or request C-example Examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP4844 blob sidecars ExEx example
4 participants