Skip to content

Commit 98306f9

Browse files
committed
Add e2e test for pool
1 parent 87d82f0 commit 98306f9

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/op-rbuilder/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ min-info-logs = ["tracing/release_max_level_info"]
115115
min-debug-logs = ["tracing/release_max_level_debug"]
116116
min-trace-logs = ["tracing/release_max_level_trace"]
117117

118-
integration = []
118+
integration = [
119+
"alloy-provider/txpool-api"
120+
]
119121
flashblocks = []
120122

121123
[[bin]]

crates/op-rbuilder/src/integration/integration_test.rs

+30-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod tests {
88
use alloy_consensus::{Transaction, TxEip1559};
99
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718};
1010
use alloy_primitives::hex;
11-
use alloy_provider::{Identity, Provider, ProviderBuilder};
11+
use alloy_provider::{ext::TxPoolApi, Identity, Provider, ProviderBuilder};
1212
use alloy_rpc_types_eth::BlockTransactionsKind;
1313
use futures_util::StreamExt;
1414
use op_alloy_consensus::OpTypedTransaction;
@@ -181,8 +181,33 @@ mod tests {
181181
.send_raw_transaction(signed_tx.encoded_2718().as_slice())
182182
.await?;
183183

184+
// Create a second reverting transaction
185+
let tx_request = OpTypedTransaction::Eip1559(TxEip1559 {
186+
chain_id: 901,
187+
nonce: nonce + 2,
188+
gas_limit: 300000,
189+
max_fee_per_gas: base_fee.into(),
190+
input: hex!("60006000fd").into(), // PUSH1 0x00 PUSH1 0x00 REVERT
191+
..Default::default()
192+
});
193+
let signed_tx = known_wallet.sign_tx(tx_request)?;
194+
let reverting_tx_2 = provider
195+
.send_raw_transaction(signed_tx.encoded_2718().as_slice())
196+
.await?;
197+
198+
let pool = provider.txpool_status().await?;
199+
200+
// Before block we should have 3 txs in pool, because they all valid
201+
assert_eq!(pool.pending, 3, "all txs should be in pending pool");
202+
assert_eq!(pool.queued, 0, "queued pool should be empty");
203+
184204
let block_hash = generator.generate_block().await?;
185205

206+
// After block is produced we will remove one of the reverting txs and place another
207+
// in queue pool because we have nonce gap
208+
assert_eq!(pool.pending, 0, "pending pool should be empty");
209+
assert_eq!(pool.queued, 1, "queued pool should contain 1 tx");
210+
186211
// query the block and the transactions inside the block
187212
let block = provider
188213
.get_block_by_hash(block_hash)
@@ -198,12 +223,11 @@ mod tests {
198223
"successful transaction missing from block"
199224
);
200225

201-
// Verify reverted transaction is NOT included
226+
// Verify reverted transactions are NOT included
202227
assert!(
203-
!block
204-
.transactions
205-
.hashes()
206-
.any(|hash| hash == *reverting_tx.tx_hash()),
228+
!block.transactions.hashes().any(
229+
|hash| hash == *reverting_tx.tx_hash() || hash == *reverting_tx_2.tx_hash()
230+
),
207231
"reverted transaction unexpectedly included in block"
208232
);
209233
for hash in block.transactions.hashes() {

crates/op-rbuilder/src/payload_builder_vanilla.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ where
125125
+ 'static,
126126
<Pool as TransactionPool>::Transaction: OpPooledTx,
127127
Evm: ConfigureEvm<
128-
Primitives = PrimitivesTy<Node::Types>,
129-
NextBlockEnvCtx = OpNextBlockEnvAttributes,
130-
> + 'static,
128+
Primitives = PrimitivesTy<Node::Types>,
129+
NextBlockEnvCtx = OpNextBlockEnvAttributes,
130+
> + 'static,
131131
{
132132
type PayloadBuilder = OpPayloadBuilderVanilla<Pool, Node::Provider>;
133133

@@ -160,9 +160,9 @@ where
160160
+ 'static,
161161
<Pool as TransactionPool>::Transaction: OpPooledTx,
162162
Evm: ConfigureEvm<
163-
Primitives = PrimitivesTy<Node::Types>,
164-
NextBlockEnvCtx = OpNextBlockEnvAttributes,
165-
> + 'static,
163+
Primitives = PrimitivesTy<Node::Types>,
164+
NextBlockEnvCtx = OpNextBlockEnvAttributes,
165+
> + 'static,
166166
{
167167
async fn spawn_payload_builder_service(
168168
self,

0 commit comments

Comments
 (0)