-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ethereum-optimism/refcell/from-l2
fix(opdn): Implement from-l2 subcommand with generated fixture
- Loading branch information
Showing
24 changed files
with
276,852 additions
and
462 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# `opd8n` | ||
# `opdn` | ||
|
||
A CLI-tool for creating derivation test fixtures. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! Logic for building the derivation fixture blocks. | ||
|
||
use crate::cmd::blobs; | ||
use alloy_eips::eip2718::Encodable2718; | ||
use alloy_primitives::Address; | ||
use color_eyre::eyre::{eyre, Result}; | ||
use kona_derive::online::{ | ||
AlloyChainProvider, OnlineBeaconClient, OnlineBlobProviderWithFallback, SimpleSlotDerivation, | ||
}; | ||
use kona_derive::traits::ChainProvider; | ||
use op_test_vectors::derivation::FixtureBlock; | ||
|
||
/// Constructs [FixtureBlock]s for the given L1 blocks. | ||
pub async fn build_fixture_blocks( | ||
batcher_address: Address, | ||
signer: Address, | ||
blocks: &[u64], | ||
l1_provider: &mut AlloyChainProvider, | ||
blob_provider: &mut OnlineBlobProviderWithFallback< | ||
OnlineBeaconClient, | ||
OnlineBeaconClient, | ||
SimpleSlotDerivation, | ||
>, | ||
) -> Result<Vec<FixtureBlock>> { | ||
let mut fixtures = Vec::with_capacity(blocks.len()); | ||
for b in blocks { | ||
let block_info = l1_provider | ||
.block_info_by_number(*b) | ||
.await | ||
.map_err(|e| eyre!(e))?; | ||
let block_header = l1_provider | ||
.header_by_hash(block_info.hash) | ||
.await | ||
.map_err(|e| eyre!(e))?; | ||
let (_, txs) = l1_provider | ||
.block_info_and_transactions_by_hash(block_info.hash) | ||
.await | ||
.map_err(|e| eyre!(e))?; | ||
let mut transactions = Vec::with_capacity(txs.len()); | ||
for tx in txs.as_slice() { | ||
let mut out = Vec::new(); | ||
tx.encode_2718(&mut out); | ||
transactions.push(out.into()); | ||
} | ||
let receipts = l1_provider | ||
.receipts_by_hash(block_info.hash) | ||
.await | ||
.map_err(|e| eyre!(e))?; | ||
|
||
let blobs = blobs::load( | ||
&block_info, | ||
txs.as_slice(), | ||
batcher_address, | ||
signer, | ||
blob_provider, | ||
) | ||
.await?; | ||
|
||
let fixture = FixtureBlock { | ||
header: block_header, | ||
transactions, | ||
blobs, | ||
receipts, | ||
}; | ||
fixtures.push(fixture); | ||
} | ||
Ok(fixtures) | ||
} |
Oops, something went wrong.