Skip to content

Commit 9e20852

Browse files
committed
record metrics on cancel
1 parent 11410f6 commit 9e20852

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

crates/op-rbuilder/src/monitoring.rs

+38-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use reth_node_api::{FullNodeComponents, NodeTypes};
88
use reth_optimism_primitives::{OpPrimitives, OpReceipt, OpTransactionSigned};
99
use reth_primitives::{Block, RecoveredBlock};
1010
use reth_provider::{Chain, ExecutionOutcome};
11-
use tracing::{info, warn};
11+
use tracing::{info, warn, error};
1212

1313
use crate::{metrics::OpRBuilderMetrics, tx_signer::Signer};
1414

@@ -147,19 +147,51 @@ fn decode_chain_into_builder_txs(
147147
.blocks_and_receipts()
148148
// Get all receipts
149149
.map(|(block, receipts)| {
150+
error!(
151+
block_number = block.number,
152+
tx_count = block.body().transactions.len(),
153+
"Processing block transactions"
154+
);
155+
150156
let has_builder_tx =
151157
block
152158
.body()
153159
.transactions
154160
.iter()
155161
.zip(receipts.iter())
156162
.any(move |(tx, receipt)| {
157-
receipt.status()
158-
&& tx.input().starts_with(OP_BUILDER_TX_PREFIX)
159-
&& tx.recover_signer().is_ok_and(|signer| {
160-
builder_signer.is_some_and(|bs| signer == bs.address)
161-
})
163+
let starts_with_prefix = tx.input().starts_with(OP_BUILDER_TX_PREFIX);
164+
let is_successful = receipt.status();
165+
let sender_recovery = tx.recover_signer();
166+
error!(
167+
tx_hash = ?tx.hash(),
168+
sender_recovery = ?sender_recovery,
169+
"Transaction builder check details"
170+
);
171+
let sender_matches = sender_recovery.is_ok_and(|signer| {
172+
builder_signer.is_some_and(|bs| signer == bs.address)
173+
});
174+
175+
error!(
176+
tx_hash = ?tx.hash(),
177+
starts_with_prefix,
178+
is_successful,
179+
sender_matches,
180+
expected_signer = ?builder_signer.as_ref().map(|s| s.address),
181+
"Transaction builder check details"
182+
);
183+
184+
is_successful && starts_with_prefix && sender_matches
162185
});
186+
187+
if !has_builder_tx && builder_signer.is_some() {
188+
error!(
189+
block_number = block.number,
190+
expected_signer = ?builder_signer.as_ref().map(|s| s.address),
191+
"No builder transactions found in block"
192+
);
193+
}
194+
163195
(block, has_builder_tx)
164196
})
165197
.collect()

crates/op-rbuilder/src/payload_builder.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ where
11571157

11581158
// check if the job was cancelled, if so we can exit early
11591159
if self.cancel.is_cancelled() {
1160+
self.record_tx_metrics(num_txs_considered, num_txs_simulated, num_txs_simulated_success, num_txs_simulated_fail);
11601161
return Ok(Some(()));
11611162
}
11621163

@@ -1224,20 +1225,23 @@ where
12241225
info.executed_senders.push(tx.signer());
12251226
info.executed_transactions.push(tx.into_inner());
12261227
}
1228+
self.record_tx_metrics(num_txs_considered, num_txs_simulated, num_txs_simulated_success, num_txs_simulated_fail);
1229+
Ok(None)
1230+
}
12271231

1232+
/// Record transaction metrics for payload building
1233+
fn record_tx_metrics(&self, considered: usize, simulated: usize, success: usize, fail: usize) {
12281234
self.metrics
12291235
.payload_num_tx_considered
1230-
.record(num_txs_considered as f64);
1236+
.record(considered as f64);
12311237
self.metrics
12321238
.payload_num_tx_simulated
1233-
.record(num_txs_simulated as f64);
1239+
.record(simulated as f64);
12341240
self.metrics
12351241
.payload_num_tx_simulated_success
1236-
.record(num_txs_simulated_success as f64);
1242+
.record(success as f64);
12371243
self.metrics
12381244
.payload_num_tx_simulated_fail
1239-
.record(num_txs_simulated_fail as f64);
1240-
1241-
Ok(None)
1245+
.record(fail as f64);
12421246
}
12431247
}

0 commit comments

Comments
 (0)