Skip to content

Commit bddecdd

Browse files
author
Einar Rasmussen
committed
_
1 parent 1d701d2 commit bddecdd

5 files changed

Lines changed: 49 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,15 @@ alloy-hardforks = "0.4.7"
165165
alloy-op-evm = { version = "0.26.3", default-features = false }
166166
alloy-op-hardforks = "0.4.7"
167167
op-alloy-rpc-types = { version = "0.23.1", default-features = false }
168+
# here
168169
op-alloy-rpc-types-engine = { version = "0.23.1", default-features = false, features = ["serde"] }
169170
op-alloy-rpc-jsonrpsee = { version = "0.23.1", default-features = false }
170171
op-alloy-network = { version = "0.23.1", default-features = false }
171172
op-alloy-consensus = { version = "0.23.1", default-features = false }
172173
op-alloy-flz = { version = "0.13.1", default-features = false }
173174

175+
base-access-lists = { git = "https://github.com/base/base.git" }
176+
174177
async-trait = { version = "0.1.83" }
175178
clap = { version = "4.4.3", features = ["derive", "env", "string"] }
176179
clap_builder = { version = "4.5.19" }
@@ -211,3 +214,6 @@ time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
211214
vergen = "9.0.4"
212215
vergen-git2 = "9.0.4"
213216
opentelemetry = { version = "0.31", features = ["trace"] }
217+
218+
[patch.crates-io]
219+
op-alloy-rpc-types-engine = { path = "../optimism/rust/op-alloy/crates/rpc-types-engine" }

crates/op-rbuilder/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ op-alloy-flz.workspace = true
9090
revm.workspace = true
9191
op-revm.workspace = true
9292

93+
base-access-lists.workspace = true
94+
9395
tracing.workspace = true
9496
eyre.workspace = true
9597
serde_with.workspace = true

crates/op-rbuilder/src/builders/flashblocks/payload.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use alloy_consensus::{
2121
use alloy_eips::{Encodable2718, eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
2222
use alloy_evm::block::BlockExecutionResult;
2323
use alloy_primitives::{Address, B256, U256};
24+
use base_access_lists::FlashblockAccessList;
2425
use eyre::WrapErr as _;
2526
use op_alloy_rpc_types_engine::{
2627
OpFlashblockPayload, OpFlashblockPayloadBase, OpFlashblockPayloadDelta,
@@ -88,6 +89,8 @@ type NextBestFlashblocksTxs<Pool> = BestFlashblocksTxs<
8889
pub(super) struct FlashblocksExecutionInfo {
8990
/// Index of the last consumed flashblock
9091
last_flashblock_index: usize,
92+
// here
93+
pub access_list: Option<FlashblockAccessList>,
9194
}
9295

9396
#[derive(Debug, Default, Clone)]
@@ -1084,10 +1087,12 @@ where
10841087
.zip(new_receipts.iter())
10851088
.map(|(tx, receipt)| (tx.tx_hash(), convert_receipt(receipt)))
10861089
.collect::<BTreeMap<B256, op_alloy_consensus::OpReceipt>>();
1090+
// here
10871091
let metadata = OpFlashblockPayloadMetadata {
10881092
receipts: receipts_with_hash,
10891093
new_account_balances,
10901094
block_number: ctx.parent().number + 1,
1095+
access_lists: info.extra.access_list,
10911096
};
10921097

10931098
let (_, blob_gas_used) = ctx.blob_fields(info);

crates/op-rbuilder/src/builders/flashblocks/payload_handler.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ use reth_optimism_payload_builder::OpBuiltPayload;
2525
use reth_optimism_primitives::{OpReceipt, OpTransactionSigned};
2626
use reth_payload_builder::EthPayloadBuilderAttributes;
2727
use reth_primitives_traits::SealedHeader;
28-
use std::sync::Arc;
28+
use std::{
29+
cmp::{max, min},
30+
sync::Arc,
31+
};
2932
use tokio::sync::mpsc;
3033
use tracing::warn;
3134

35+
use base_access_lists::FBALBuilderDb;
36+
3237
/// Handles newly built or received flashblock payloads.
3338
///
3439
/// In the case of a payload built by this node, it is broadcast to peers and an event is sent to the payload builder.
@@ -182,6 +187,7 @@ where
182187
.state_by_block_hash(parent_hash)
183188
.wrap_err("failed to get state for parent hash")?;
184189
let db = StateProviderDatabase::new(&state_provider);
190+
// here
185191
let mut state = State::builder()
186192
.with_database(cached_reads.as_db_mut(db))
187193
.with_bundle_update()
@@ -333,9 +339,18 @@ fn execute_transactions(
333339
use reth_primitives_traits::SignedTransaction;
334340
use revm::{DatabaseCommit as _, context::result::ResultAndState};
335341

336-
let mut evm = ctx.evm_config().evm_with_env(&mut *state, evm_env);
342+
//here
343+
let mut fbal_db = FBALBuilderDb::new(state);
344+
let mut evm = ctx.evm_config().evm_with_env(&mut fbal_db, evm_env);
345+
346+
let mut min_tx_index = u64::MAX;
347+
let mut max_tx_index = u64::MIN;
348+
for (i, tx) in txs.into_iter().enumerate() {
349+
let j: u64 = i.try_into().unwrap();
350+
evm.db_mut().set_index(j);
351+
min_tx_index = min(min_tx_index, j);
352+
max_tx_index = max(max_tx_index, j);
337353

338-
for tx in txs {
339354
// Convert to recovered transaction
340355
let tx_recovered = tx
341356
.try_clone_into_recovered()
@@ -350,6 +365,7 @@ fn execute_transactions(
350365
let depositor_nonce = (ctx.is_regolith_active(timestamp) && tx_recovered.is_deposit())
351366
.then(|| {
352367
evm.db_mut()
368+
.db_mut()
353369
.load_cache_account(sender)
354370
.map(|acc| acc.account_info().unwrap_or_default().nonce)
355371
})
@@ -406,6 +422,9 @@ fn execute_transactions(
406422
});
407423
info.da_footprint_scalar = da_footprint_gas_scalar;
408424

425+
let fbal_builder = fbal_db.finish()?;
426+
info.extra.access_list = Some(fbal_builder.build(min_tx_index, max_tx_index));
427+
409428
Ok(())
410429
}
411430

0 commit comments

Comments
 (0)