Skip to content

Commit eb0e675

Browse files
committed
Increment DA usage for non-deposit sequencer transactions (e.g. via CL sync)
1 parent effdf8e commit eb0e675

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

crates/op-rbuilder/src/builders/context.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use alloy_consensus::{Eip658Value, Transaction, conditional::BlockConditionalAttributes};
2-
use alloy_eips::Typed2718;
2+
use alloy_eips::{Encodable2718, Typed2718};
33
use alloy_evm::Database;
44
use alloy_op_evm::block::receipt_builder::OpReceiptBuilder;
55
use alloy_primitives::{BlockHash, Bytes, U256};
@@ -338,6 +338,12 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
338338
let gas_used = result.gas_used();
339339
info.cumulative_gas_used += gas_used;
340340

341+
if !sequencer_tx.is_deposit() {
342+
info.cumulative_da_bytes_used += op_alloy_flz::tx_estimated_size_fjord_bytes(
343+
sequencer_tx.encoded_2718().as_slice(),
344+
);
345+
}
346+
341347
let ctx = ReceiptBuilderCtx {
342348
tx: sequencer_tx.inner(),
343349
evm: &evm,

crates/op-rbuilder/src/tests/forks.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::tests::{BlockTransactionsExt, LocalInstance};
2-
use alloy_eips::{BlockNumberOrTag::Latest, eip1559::MIN_PROTOCOL_BASE_FEE};
2+
use alloy_eips::{BlockNumberOrTag::Latest, Encodable2718, eip1559::MIN_PROTOCOL_BASE_FEE};
33
use alloy_primitives::bytes;
44
use macros::{if_flashblocks, if_standard, rb_test};
55
use std::time::Duration;
@@ -40,6 +40,51 @@ async fn jovian_block_parameters_set(rbuilder: LocalInstance) -> eyre::Result<()
4040
Ok(())
4141
}
4242

43+
#[rb_test]
44+
async fn jovian_no_tx_pool_sync(rbuilder: LocalInstance) -> eyre::Result<()> {
45+
let driver = rbuilder.driver().await?;
46+
let block = driver
47+
.build_new_block_with_txs_timestamp(vec![], Some(true), None, None, Some(0))
48+
.await?;
49+
50+
// Deposit transaction + user transaction
51+
if_flashblocks! {
52+
assert_eq!(block.transactions.len(), 1);
53+
assert_eq!(block.header.blob_gas_used, Some(0));
54+
}
55+
56+
// Standard includes a builder transaction when no-tx-pool is set
57+
if_standard! {
58+
assert_eq!(block.transactions.len(), 2);
59+
assert_eq!(block.header.blob_gas_used, Some(40_000));
60+
}
61+
62+
let tx = driver.create_transaction().build().await;
63+
let block = driver
64+
.build_new_block_with_txs_timestamp(
65+
vec![tx.encoded_2718().into()],
66+
Some(true),
67+
None,
68+
None,
69+
Some(0),
70+
)
71+
.await?;
72+
73+
// Deposit transaction + user transaction
74+
if_flashblocks! {
75+
assert_eq!(block.transactions.len(), 2);
76+
assert_eq!(block.header.blob_gas_used, Some(40_000));
77+
}
78+
79+
// Standard includes a builder transaction when no-tx-pool is set
80+
if_standard! {
81+
assert_eq!(block.transactions.len(), 3);
82+
assert_eq!(block.header.blob_gas_used, Some(80_000));
83+
}
84+
85+
Ok(())
86+
}
87+
4388
#[rb_test]
4489
async fn jovian_minimum_base_fee(rbuilder: LocalInstance) -> eyre::Result<()> {
4590
let driver = rbuilder.driver().await?;

0 commit comments

Comments
 (0)