Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ use alloy_consensus::{
BlockBody, EMPTY_OMMER_ROOT_HASH, Header, constants::EMPTY_WITHDRAWALS, proofs,
};
use alloy_eips::{Encodable2718, eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
use alloy_primitives::{Address, B256, U256, map::foldhash::HashMap};
use alloy_primitives::{B256, U256};
use core::time::Duration;
use eyre::WrapErr as _;
use reth::payload::PayloadBuilderAttributes;
use reth_basic_payload_builder::BuildOutcome;
use reth_chain_state::ExecutedBlock;
use reth_chainspec::EthChainSpec;
use reth_evm::{ConfigureEvm, execute::BlockBuilder};
use reth_node_api::{Block, NodePrimitives, PayloadBuilderError};
use reth_node_api::{Block, PayloadBuilderError};
use reth_optimism_consensus::{calculate_receipt_root_no_memo_optimism, isthmus};
use reth_optimism_evm::{OpEvmConfig, OpNextBlockEnvAttributes};
use reth_optimism_forks::OpHardforks;
use reth_optimism_node::{OpBuiltPayload, OpPayloadBuilderAttributes};
use reth_optimism_primitives::{OpPrimitives, OpReceipt, OpTransactionSigned};
use reth_optimism_primitives::OpTransactionSigned;
use reth_payload_util::BestPayloadTransactions;
use reth_primitives_traits::RecoveredBlock;
use reth_provider::{
Expand Down Expand Up @@ -942,8 +942,6 @@ where

#[derive(Debug, Serialize, Deserialize)]
struct FlashblocksMetadata {
receipts: HashMap<B256, <OpPrimitives as NodePrimitives>::Receipt>,
new_account_balances: HashMap<Address, U256>,
block_number: u64,
}

Expand Down Expand Up @@ -1134,23 +1132,9 @@ where
.map(|tx| tx.encoded_2718().into())
.collect::<Vec<_>>();

let new_receipts = info.receipts[info.extra.last_flashblock_index..].to_vec();
info.extra.last_flashblock_index = info.executed_transactions.len();
let receipts_with_hash = new_transactions
.iter()
.zip(new_receipts.iter())
.map(|(tx, receipt)| (tx.tx_hash(), receipt.clone()))
.collect::<HashMap<B256, OpReceipt>>();
let new_account_balances = state
.bundle_state
.state
.iter()
.filter_map(|(address, account)| account.info.as_ref().map(|info| (*address, info.balance)))
.collect::<HashMap<Address, U256>>();

let metadata: FlashblocksMetadata = FlashblocksMetadata {
receipts: receipts_with_hash,
new_account_balances,
block_number: ctx.parent().number + 1,
};

Expand Down
21 changes: 10 additions & 11 deletions crates/op-rbuilder/src/tests/framework/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,24 +448,23 @@ impl FlashblocksListener {

/// Check if any flashblock contains the given transaction hash
pub fn contains_transaction(&self, tx_hash: &B256) -> bool {
let tx_hash_str = format!("{tx_hash:#x}");
self.flashblocks.lock().iter().any(|fb| {
if let Some(receipts) = fb.metadata.get("receipts")
&& let Some(receipts_obj) = receipts.as_object()
{
return receipts_obj.contains_key(&tx_hash_str);
}
false
fb.diff
.transactions
.iter()
.any(|tx| keccak256(tx) == *tx_hash)
})
}

/// Find which flashblock index contains the given transaction hash
pub fn find_transaction_flashblock(&self, tx_hash: &B256) -> Option<u64> {
let tx_hash_str = format!("{tx_hash:#x}");
self.flashblocks.lock().iter().find_map(|fb| {
if let Some(receipts) = fb.metadata.get("receipts")
&& let Some(receipts_obj) = receipts.as_object()
&& receipts_obj.contains_key(&tx_hash_str)
if fb
.diff
.transactions
.iter()
.find(|tx| keccak256(tx) == *tx_hash)
.is_some()
{
return Some(fb.index);
}
Expand Down
Loading