Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/builder/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ alloy-network.workspace = true
alloy-provider.workspace = true
alloy-serde.workspace = true
alloy-json-rpc.workspace = true
alloy-signer.workspace = true
alloy-signer-local.workspace = true
alloy-sol-types.workspace = true

Expand Down
36 changes: 18 additions & 18 deletions crates/builder/op-rbuilder/src/tests/backrun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn backrun_bundle_all_or_nothing_revert() -> eyre::Result<()> {
// 1. Build target tx first (we need Recovered<OpTxEnvelope> for bundle)
let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand All @@ -34,15 +34,15 @@ async fn backrun_bundle_all_or_nothing_revert() -> eyre::Result<()> {
// Both must have priority fee >= target's (20) to pass fee validation
let backrun_ok = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(50) // High priority - executes first
.build()
.await;
let backrun_ok_hash = backrun_ok.tx_hash();

let backrun_revert = driver
.create_transaction()
.with_signer(accounts[2])
.with_signer(&accounts[2])
.with_max_priority_fee_per_gas(25) // >= target's 20, but executes second (lower than 50)
.with_revert() // This tx will revert
.build()
Expand Down Expand Up @@ -116,7 +116,7 @@ async fn backrun_bundles_sorted_by_total_fee() -> eyre::Result<()> {
// 1. Build target tx with priority fee 20
let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand All @@ -130,15 +130,15 @@ async fn backrun_bundles_sorted_by_total_fee() -> eyre::Result<()> {
// Two txs: 60 + 50 = 110 total
let bundle_a_tx1 = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(60)
.build()
.await;
let bundle_a_tx1_hash = bundle_a_tx1.tx_hash();

let bundle_a_tx2 = driver
.create_transaction()
.with_signer(accounts[2])
.with_signer(&accounts[2])
.with_max_priority_fee_per_gas(50)
.build()
.await;
Expand All @@ -148,15 +148,15 @@ async fn backrun_bundles_sorted_by_total_fee() -> eyre::Result<()> {
// Two txs: 30 + 25 = 55 total
let bundle_b_tx1 = driver
.create_transaction()
.with_signer(accounts[3])
.with_signer(&accounts[3])
.with_max_priority_fee_per_gas(30)
.build()
.await;
let bundle_b_tx1_hash = bundle_b_tx1.tx_hash();

let bundle_b_tx2 = driver
.create_transaction()
.with_signer(accounts[4])
.with_signer(&accounts[4])
.with_max_priority_fee_per_gas(25)
.build()
.await;
Expand Down Expand Up @@ -278,7 +278,7 @@ async fn backrun_bundle_rejected_low_total_fee() -> eyre::Result<()> {
// 1. Build target tx with HIGH priority fee (100)
let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(100)
.build()
.await;
Expand All @@ -294,15 +294,15 @@ async fn backrun_bundle_rejected_low_total_fee() -> eyre::Result<()> {
// - Total: 30 + 20 = 50 < target's 100 → bundle rejected
let backrun_1 = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(30)
.build()
.await;
let backrun_1_hash = backrun_1.tx_hash();

let backrun_2 = driver
.create_transaction()
.with_signer(accounts[2])
.with_signer(&accounts[2])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand Down Expand Up @@ -375,7 +375,7 @@ async fn backrun_bundle_rejected_exceeds_gas_limit() -> eyre::Result<()> {

let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand All @@ -386,7 +386,7 @@ async fn backrun_bundle_rejected_exceeds_gas_limit() -> eyre::Result<()> {

let backrun = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(50)
.with_gas_limit(1_000_000)
.build()
Expand Down Expand Up @@ -455,7 +455,7 @@ async fn backrun_bundle_rejected_exceeds_da_limit() -> eyre::Result<()> {

let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand All @@ -467,7 +467,7 @@ async fn backrun_bundle_rejected_exceeds_da_limit() -> eyre::Result<()> {
// Create backrun with large calldata to exceed DA limit
let backrun = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(50)
.with_input(vec![0u8; 1000].into())
.build()
Expand Down Expand Up @@ -529,7 +529,7 @@ async fn backrun_bundle_invalid_tx_skipped() -> eyre::Result<()> {

let target_tx = driver
.create_transaction()
.with_signer(accounts[0])
.with_signer(&accounts[0])
.with_max_priority_fee_per_gas(20)
.build()
.await;
Expand All @@ -540,7 +540,7 @@ async fn backrun_bundle_invalid_tx_skipped() -> eyre::Result<()> {

let backrun_tx = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(50)
.with_nonce(0)
.build()
Expand All @@ -550,7 +550,7 @@ async fn backrun_bundle_invalid_tx_skipped() -> eyre::Result<()> {
// Send a conflicting tx with same nonce but higher fee - it will be included first
let conflicting_tx = driver
.create_transaction()
.with_signer(accounts[1])
.with_signer(&accounts[1])
.with_max_priority_fee_per_gas(100)
.with_nonce(0)
.send()
Expand Down
6 changes: 3 additions & 3 deletions crates/builder/op-rbuilder/src/tests/framework/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ impl<RpcProtocol: Protocol> ChainDriver<RpcProtocol> {

/// Specifies the signer used to sign transactions.
/// If not specified, a random signer will be used.
pub const fn with_signer(mut self, signer: Signer) -> Self {
self.signer = Some(signer);
pub fn with_signer(mut self, signer: &Signer) -> Self {
self.signer = Some(signer.clone());
self
}

Expand Down Expand Up @@ -141,7 +141,7 @@ impl<RpcProtocol: Protocol> ChainDriver<RpcProtocol> {
};

// Create a temporary signer for the deposit
let signer = self.signer.unwrap_or_else(Signer::random);
let signer = self.signer.clone().unwrap_or_else(Signer::random);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a light clone since the signer type is small

let signed_tx = signer.sign_tx(OpTypedTransaction::Deposit(deposit_tx))?;
signed_tx.encoded_2718().into()
};
Expand Down
4 changes: 2 additions & 2 deletions crates/builder/op-rbuilder/src/tests/framework/txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl TransactionBuilder {
self
}

pub const fn with_signer(mut self, signer: Signer) -> Self {
self.signer = Some(signer);
pub fn with_signer(mut self, signer: &Signer) -> Self {
self.signer = Some(signer.clone());
self
}

Expand Down
6 changes: 3 additions & 3 deletions crates/builder/op-rbuilder/src/tests/framework/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl TransactionBuilderExt for TransactionBuilder {
self.with_create()
.with_input(FlashblocksNumber::BYTECODE.clone())
.with_gas_limit(2_000_000) // deployment costs ~1.6 million gas
.with_signer(flashblocks_number_signer())
.with_signer(&flashblocks_number_signer())
}

fn init_flashblock_number_contract(self, register_builder: bool) -> Self {
Expand All @@ -68,13 +68,13 @@ impl TransactionBuilderExt for TransactionBuilder {
}
.abi_encode();

self.with_input(init_data.into()).with_signer(flashblocks_number_signer())
self.with_input(init_data.into()).with_signer(&flashblocks_number_signer())
}

fn add_authorized_builder(self, builder: Address) -> Self {
let calldata = FlashblocksNumber::addBuilderCall { builder }.abi_encode();

self.with_input(calldata.into()).with_signer(flashblocks_number_signer())
self.with_input(calldata.into()).with_signer(&flashblocks_number_signer())
}
}

Expand Down
10 changes: 5 additions & 5 deletions crates/builder/op-rbuilder/src/tests/gas_limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ async fn gas_limiter_blocks_excessive_usage() -> eyre::Result<()> {
// These transactions should not be throttled
let tx1 = driver
.create_transaction()
.with_signer(funded_accounts[0])
.with_signer(&funded_accounts[0])
.random_valid_transfer()
.send()
.await?;

let tx2 = driver
.create_transaction()
.with_signer(funded_accounts[1])
.with_signer(&funded_accounts[1])
.random_valid_transfer()
.send()
.await?;
Expand All @@ -55,7 +55,7 @@ async fn gas_limiter_blocks_excessive_usage() -> eyre::Result<()> {
for i in 0..5 {
let big_tx = driver
.create_transaction()
.with_signer(funded_accounts[0])
.with_signer(&funded_accounts[0])
.random_big_transaction()
.send()
.await?;
Expand All @@ -66,7 +66,7 @@ async fn gas_limiter_blocks_excessive_usage() -> eyre::Result<()> {
// Meanwhile, the other address should not be throttled
let legit_tx = driver
.create_transaction()
.with_signer(funded_accounts[1])
.with_signer(&funded_accounts[1])
.random_big_transaction()
.send()
.await?;
Expand Down Expand Up @@ -98,7 +98,7 @@ async fn gas_limiter_blocks_excessive_usage() -> eyre::Result<()> {

let tx_after_refill = driver
.create_transaction()
.with_signer(funded_accounts[0])
.with_signer(&funded_accounts[0])
.random_valid_transfer()
.send()
.await?;
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/op-rbuilder/src/tests/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn fee_priority_ordering() -> eyre::Result<()> {
let txs = join_all(accounts.iter().map(|signer| {
driver
.create_transaction()
.with_signer(*signer)
.with_signer(signer)
.with_max_priority_fee_per_gas(rand::random_range(1..50))
.send()
}))
Expand Down
4 changes: 2 additions & 2 deletions crates/builder/op-rbuilder/src/tests/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn pending_pool_limit() -> eyre::Result<()> {
let acc_with_priority = accounts.last().unwrap();

for _ in 0..50 {
let _ = driver.create_transaction().with_signer(*acc_no_priority).send().await?;
let _ = driver.create_transaction().with_signer(acc_no_priority).send().await?;
}

assert_eq!(
Expand All @@ -42,7 +42,7 @@ async fn pending_pool_limit() -> eyre::Result<()> {
for _ in 0..10 {
let tx = driver
.create_transaction()
.with_signer(*acc_with_priority)
.with_signer(acc_with_priority)
.with_max_priority_fee_per_gas(10)
.send()
.await?;
Expand Down
Loading
Loading