Skip to content

Commit 84ecc91

Browse files
committed
Add max data availability transaction and block size configuration
- Introduced `max_da_tx_size` and `max_da_block_size` fields in `TestHarnessBuilder` and `OpRbuilderConfig`. - Added builder methods `with_max_da_tx_size` and `with_max_da_block_size` for setting these values. - Implemented a new test to ensure transaction size limits are respected in data availability scenarios. - Updated test module to include the new data availability test.
1 parent 2b013ad commit 84ecc91

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

crates/op-rbuilder/src/tests/framework/harness.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub struct TestHarnessBuilder {
2525
flashblocks_ws_url: Option<String>,
2626
chain_block_time: Option<u64>,
2727
flashbots_block_time: Option<u64>,
28+
max_da_tx_size: Option<u64>,
29+
max_da_block_size: Option<u64>,
2830
}
2931

3032
impl TestHarnessBuilder {
@@ -35,6 +37,8 @@ impl TestHarnessBuilder {
3537
flashblocks_ws_url: None,
3638
chain_block_time: None,
3739
flashbots_block_time: None,
40+
max_da_tx_size: None,
41+
max_da_block_size: None,
3842
}
3943
}
4044

@@ -58,6 +62,16 @@ impl TestHarnessBuilder {
5862
self
5963
}
6064

65+
pub fn with_max_da_tx_size(mut self, max_da_tx_size: u64) -> Self {
66+
self.max_da_tx_size = Some(max_da_tx_size);
67+
self
68+
}
69+
70+
pub fn with_max_da_block_size(mut self, max_da_block_size: u64) -> Self {
71+
self.max_da_block_size = Some(max_da_block_size);
72+
self
73+
}
74+
6175
pub async fn build(self) -> eyre::Result<TestHarness> {
6276
let mut framework = IntegrationFramework::new(&self.name).unwrap();
6377

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub struct OpRbuilderConfig {
2727
chain_block_time: Option<u64>,
2828
flashbots_block_time: Option<u64>,
2929
with_revert_protection: Option<bool>,
30+
max_da_tx_size: Option<u64>,
31+
max_da_block_size: Option<u64>,
3032
}
3133

3234
impl OpRbuilderConfig {
@@ -83,6 +85,16 @@ impl OpRbuilderConfig {
8385
self.flashbots_block_time = Some(time);
8486
self
8587
}
88+
89+
pub fn with_max_da_tx_size(mut self, size: u64) -> Self {
90+
self.max_da_tx_size = Some(size);
91+
self
92+
}
93+
94+
pub fn with_max_da_block_size(mut self, size: u64) -> Self {
95+
self.max_da_block_size = Some(size);
96+
self
97+
}
8698
}
8799

88100
impl Service for OpRbuilderConfig {
@@ -155,6 +167,16 @@ impl Service for OpRbuilderConfig {
155167
.arg(flashbots_block_time.to_string());
156168
}
157169

170+
if let Some(max_da_tx_size) = self.max_da_tx_size {
171+
cmd.arg("--rollup.max-da-tx-size")
172+
.arg(max_da_tx_size.to_string());
173+
}
174+
175+
if let Some(max_da_block_size) = self.max_da_block_size {
176+
cmd.arg("--rollup.max-da-block-size")
177+
.arg(max_da_block_size.to_string());
178+
}
179+
158180
cmd
159181
}
160182

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::tests::framework::{TestHarnessBuilder};
2+
3+
/// This test ensures that the transaction size limit is respected.
4+
/// We will set limit to 1 byte and see that the builder will not include any transactions.
5+
#[tokio::test]
6+
async fn data_availability_tx_size_limit() -> eyre::Result<()> {
7+
let harness = TestHarnessBuilder::new("integration_test_data_availability")
8+
.with_max_da_tx_size(1)
9+
.build()
10+
.await?;
11+
12+
let mut generator = harness.block_generator().await?;
13+
14+
// generate regualr tx
15+
let invalid_tx = harness.send_valid_transaction().await?;
16+
17+
let block = generator.generate_block().await?;
18+
19+
// tx should not be included because we set the tx_size_limit to 1
20+
assert!(block.not_includes(*invalid_tx.tx_hash()), "transaction should not be included in the block");
21+
22+
Ok(())
23+
}

crates/op-rbuilder/src/tests/vanilla/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
mod ordering;
44
mod revert;
55
mod smoke;
6+
mod data_availability;
67

78
use super::*;

0 commit comments

Comments
 (0)