Skip to content

Commit 1036364

Browse files
authored
feat(based-op-reth): save l1 block info when executing frag (#277)
tested seems to have fixed the issue
1 parent 915ecfe commit 1036364

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

based/crates/reth/src/exec.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ where
165165
let mut state_overrides = ub.get_state_overrides().unwrap_or_default();
166166

167167
let block: OpBlock = build_op_block_from_ub_and_frag(&ub, &frag)?;
168-
let mut l1_block_info = reth_optimism_evm::extract_l1_info(&block.body)?;
168+
169+
let mut l1_block_info =
170+
ub.l1_block_info.clone().map(Ok).unwrap_or_else(|| reth_optimism_evm::extract_l1_info(&block.body))?;
171+
169172
let header = block.header.clone().seal_slow();
170173

171174
let block_env_attributes = OpNextBlockEnvAttributes {
@@ -280,7 +283,6 @@ where
280283

281284
let receipt = OpReceiptBuilder::new(chain_spec.as_ref(), input, &mut l1_block_info)?.build();
282285

283-
// TODO: Is this correct?q
284286
next_log_index += receipt.inner.logs().len();
285287
ub.with_transaction_receipt(tx_hash, receipt.clone());
286288
receipts.push(receipt);
@@ -298,7 +300,8 @@ where
298300
ub = ub
299301
.with_db_cache(db.cache)
300302
.with_state_overrides(Some(state_overrides))
301-
.with_bundle_state(db.db.bundle_state);
303+
.with_bundle_state(db.db.bundle_state)
304+
.with_l1_block_info(l1_block_info);
302305

303306
ub.accept_frag_execution(frag, logs, receipts, gas_used);
304307

based/crates/reth/src/unsealed_block.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use op_alloy_consensus::{OpBlock, OpTxEnvelope};
88
use op_alloy_network::{Optimism, TransactionResponse};
99
use op_alloy_rpc_types::{OpTransactionReceipt, Transaction};
1010
use reth::revm::db::{BundleState, Cache};
11+
use reth_evm::op_revm::L1BlockInfo;
1112
use reth_optimism_primitives::OpTransactionSigned;
1213
use reth_rpc_eth_api::RpcBlock;
1314
use tokio::sync::broadcast;
@@ -37,6 +38,8 @@ pub struct UnsealedBlock {
3738
/// Cumulative blob gas used across all blob-carrying transactions in the block.
3839
pub cumulative_blob_gas_used: u64,
3940
pub is_prague: bool,
41+
// Current unsealed block l1 block info
42+
pub l1_block_info: Option<L1BlockInfo>,
4043

4144
transaction_count: HashMap<Address, U256>,
4245
transactions: Vec<Transaction>,
@@ -71,6 +74,7 @@ impl UnsealedBlock {
7174
new_block_sender,
7275
db_cache: Default::default(),
7376
bundle_state: Default::default(),
77+
l1_block_info: None,
7478
}
7579
}
7680

@@ -226,6 +230,12 @@ impl UnsealedBlock {
226230
self
227231
}
228232

233+
/// Attach/replace the l1 block info.
234+
pub fn with_l1_block_info(mut self, l1_block_info: L1BlockInfo) -> Self {
235+
self.l1_block_info = Some(l1_block_info);
236+
self
237+
}
238+
229239
/// Returns the database cache.
230240
pub fn get_db_cache(&self) -> Cache {
231241
self.db_cache.clone()
@@ -255,6 +265,7 @@ impl UnsealedBlock {
255265
new_block_sender: self.new_block_sender.clone(),
256266
transaction_receipts: self.transaction_receipts.clone(),
257267
bundle_state: self.bundle_state.clone(),
268+
l1_block_info: self.l1_block_info.clone(),
258269
}
259270
}
260271

0 commit comments

Comments
 (0)