Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct OpRbuilderArgs {
pub chain_block_time: u64,

/// max gas a transaction can use
#[arg(long = "builder.max_gas_per_txn", default_value = "25000")]
#[arg(long = "builder.max_gas_per_txn")]
pub max_gas_per_txn: Option<u64>,

/// Signals whether to log pool transaction events
Expand Down
2 changes: 1 addition & 1 deletion crates/op-rbuilder/src/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<S: Default + Clone> Default for BuilderConfig<S> {
da_config: OpDAConfig::default(),
specific: S::default(),
sampling_ratio: 100,
max_gas_per_txn: Some(25_000),
max_gas_per_txn: None,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/op-rbuilder/src/tests/framework/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ impl TransactionBuilderExt for TransactionBuilder {
}

fn random_big_transaction(self) -> Self {
self.with_create().with_input(hex!("3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006883d15f0000000000000000000000000000000000000000000000000000000000000004100504040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000056000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003090b0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000e9bacdc46b210000000000000000000000000000000000000000000000000000000da673855a3f900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c0000000000000000000000000000000000000000000000000009536c7089100000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000418fa3488d7e13f0c06ac5f8485d306b5748f4f000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc0000000000000000000000000000000000000000000000000e92596fd629000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090ec5e568dfab3242ac3f11cd497ec731e4a5cc00000000000000000000000000000000000000000000000000000000000000000c").into())
// PUSH13 0x63ffffffff60005260046000f3 PUSH1 0x00 MSTORE PUSH1 0x02 PUSH1 0x0d PUSH1 0x13 PUSH1 0x00 CREATE2
self.with_create()
.with_input(hex!("6c63ffffffff60005260046000f36000526002600d60136000f5").into())
}
}

Expand Down
73 changes: 57 additions & 16 deletions crates/op-rbuilder/src/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,42 +195,83 @@ async fn test_no_tx_pool(rbuilder: LocalInstance) -> eyre::Result<()> {
}

#[rb_test(args = OpRbuilderArgs {
max_gas_per_txn: Some(21000),
max_gas_per_txn: Some(25000),
..Default::default()
})]
async fn chain_produces_big_txs(rbuilder: LocalInstance) -> eyre::Result<()> {
async fn chain_produces_big_tx_with_gas_limit(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;

#[cfg(target_os = "linux")]
let driver = driver
.with_validation_node(crate::tests::ExternalNode::reth().await?)
.await?;

let count = rand::random_range(1..8);
let mut tx_hashes = HashSet::<TxHash>::default();
// insert txn with gas usage above limit
let _ = driver
.create_transaction()
.random_big_transaction()
.send()
.await
.expect("Failed to send transaction");

let block = driver.build_new_block_with_current_timestamp(None).await?;
let txs = block.transactions;

for _ in 0..count {
// insert txns with gas = 210_000
let tx = driver
.create_transaction()
.random_big_transaction()
.send()
.await
.expect("Failed to send transaction");
println!("{}", txs.len());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug

assert!(txs.len() == 3);

tx_hashes.insert(*tx.tx_hash());
}
Ok(())
}

// insert 1 valid txn with gas=21_000
#[rb_test(args = OpRbuilderArgs {
..Default::default()
})]
async fn chain_produces_big_tx_without_gas_limit(rbuilder: LocalInstance) -> eyre::Result<()> {
let driver = rbuilder.driver().await?;

#[cfg(target_os = "linux")]
let driver = driver
.with_validation_node(crate::tests::ExternalNode::reth().await?)
.await?;

// insert txn with gas usage but there is no limit
let _ = driver
.create_transaction()
.random_valid_transfer()
.random_big_transaction()
.send()
.await
.expect("Failed to send transaction");

let block = driver.build_new_block_with_current_timestamp(None).await?;
let txs = block.transactions;

println!("{}", txs.len());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug

assert!(txs.len() == 4);

Ok(())
}

#[rb_test(args = OpRbuilderArgs {
max_gas_per_txn: Some(25000),
..Default::default()
})]
async fn chain_produces_small_tx(rbuilder: LocalInstance) -> eyre::Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's combine this test with chain_produces_big_tx_with_gas_limit
create 2 txs (big and small one)
And the check by hash that small transaction got included

let driver = rbuilder.driver().await?;

#[cfg(target_os = "linux")]
let driver = driver
.with_validation_node(crate::tests::ExternalNode::reth().await?)
.await?;

// insert valid txn under limit
let _ = driver
.create_transaction()
.random_valid_transfer()
.send()
.await
.expect("Failed to send transaction");

let block = driver.build_new_block_with_current_timestamp(None).await?;
let txs = block.transactions;

assert!(txs.len() == 4);
Expand Down