@@ -7,7 +7,10 @@ use crate::{
7
7
} ,
8
8
BundleReplacementData , BundleReplacementKey , MempoolTx , Order , OrderId ,
9
9
} ,
10
- telemetry:: { add_rpc_processing_time, mark_command_received, scope_meter:: ScopeMeter } ,
10
+ telemetry:: {
11
+ add_rpc_processing_time, inc_order_input_rpc_errors, mark_command_received,
12
+ scope_meter:: ScopeMeter ,
13
+ } ,
11
14
} ;
12
15
use alloy_primitives:: { Address , Bytes } ;
13
16
use jsonrpsee:: {
@@ -31,6 +34,11 @@ use tokio_util::sync::CancellationToken;
31
34
use tracing:: { info, trace, warn} ;
32
35
use uuid:: Uuid ;
33
36
37
+ const ETH_SEND_BUNDLE : & str = "eth_sendBundle" ;
38
+ const MEV_SEND_BUNDLE : & str = "mev_sendBundle" ;
39
+ const ETH_CANCEL_BUNDLE : & str = "eth_cancelBundle" ;
40
+ const ETH_SEND_RAW_TRANSACTION : & str = "eth_sendRawTransaction" ;
41
+
34
42
/// Adds metrics to the callback and registers via module.register_async_method.
35
43
pub fn register_metered_async_method < ' a , R , Fun , Fut > (
36
44
module : & ' a mut RpcModule < ( ) > ,
@@ -74,22 +82,22 @@ pub async fn start_server_accepting_bundles(
74
82
let mut module = RpcModule :: new ( ( ) ) ;
75
83
76
84
let results_clone = results. clone ( ) ;
77
- register_metered_async_method ( & mut module, "eth_sendBundle" , move |params, _| {
85
+ register_metered_async_method ( & mut module, ETH_SEND_BUNDLE , move |params, _| {
78
86
handle_eth_send_bundle ( results_clone. clone ( ) , timeout, params)
79
87
} ) ?;
80
88
81
89
let results_clone = results. clone ( ) ;
82
- register_metered_async_method ( & mut module, "mev_sendBundle" , move |params, _| {
90
+ register_metered_async_method ( & mut module, MEV_SEND_BUNDLE , move |params, _| {
83
91
handle_mev_send_bundle ( results_clone. clone ( ) , timeout, params)
84
92
} ) ?;
85
93
86
94
let results_clone = results. clone ( ) ;
87
- register_metered_async_method ( & mut module, "eth_cancelBundle" , move |params, _| {
95
+ register_metered_async_method ( & mut module, ETH_CANCEL_BUNDLE , move |params, _| {
88
96
handle_cancel_bundle ( results_clone. clone ( ) , timeout, params)
89
97
} ) ?;
90
98
91
99
let results_clone = results. clone ( ) ;
92
- register_metered_async_method ( & mut module, "eth_sendRawTransaction" , move |params, _| {
100
+ register_metered_async_method ( & mut module, ETH_SEND_RAW_TRANSACTION , move |params, _| {
93
101
let results = results_clone. clone ( ) ;
94
102
async move {
95
103
let received_at = OffsetDateTime :: now_utc ( ) ;
@@ -98,7 +106,7 @@ pub async fn start_server_accepting_bundles(
98
106
Ok ( raw_tx) => raw_tx,
99
107
Err ( err) => {
100
108
warn ! ( ?err, "Failed to parse raw transaction" ) ;
101
- // @Metric
109
+ inc_order_input_rpc_errors ( ETH_SEND_RAW_TRANSACTION ) ;
102
110
return Err ( err) ;
103
111
}
104
112
} ;
@@ -108,7 +116,7 @@ pub async fn start_server_accepting_bundles(
108
116
Ok ( tx) => tx,
109
117
Err ( err) => {
110
118
warn ! ( ?err, "Failed to decode raw transaction" ) ;
111
- // @Metric
119
+ inc_order_input_rpc_errors ( ETH_SEND_RAW_TRANSACTION ) ;
112
120
return Err ( ErrorObject :: owned (
113
121
-32602 ,
114
122
"failed to verify transaction" ,
@@ -157,7 +165,7 @@ async fn handle_eth_send_bundle(
157
165
Ok ( raw_bundle) => raw_bundle,
158
166
Err ( err) => {
159
167
warn ! ( ?err, "Failed to parse raw bundle" ) ;
160
- // @Metric
168
+ inc_order_input_rpc_errors ( ETH_SEND_BUNDLE ) ;
161
169
return ;
162
170
}
163
171
} ;
@@ -170,7 +178,7 @@ async fn handle_eth_send_bundle(
170
178
Ok ( bundle_res) => bundle_res,
171
179
Err ( err) => {
172
180
warn ! ( ?err, "Failed to decode raw bundle" ) ;
173
- // @Metric
181
+ inc_order_input_rpc_errors ( ETH_SEND_BUNDLE ) ;
174
182
return ;
175
183
}
176
184
} ;
@@ -185,6 +193,7 @@ async fn handle_eth_send_bundle(
185
193
max_timestamp = bundle. max_timestamp,
186
194
"Bundle has timestamp 0"
187
195
) ;
196
+ inc_order_input_rpc_errors ( ETH_SEND_BUNDLE ) ;
188
197
}
189
198
let order = Order :: Bundle ( bundle) ;
190
199
let parse_duration = start. elapsed ( ) ;
@@ -218,15 +227,15 @@ async fn handle_mev_send_bundle(
218
227
Ok ( raw_bundle) => raw_bundle,
219
228
Err ( err) => {
220
229
warn ! ( ?err, "Failed to parse raw share bundle" ) ;
221
- // @Metric
230
+ inc_order_input_rpc_errors ( MEV_SEND_BUNDLE ) ;
222
231
return ;
223
232
}
224
233
} ;
225
234
let decode_res = match raw_bundle. decode ( TxEncoding :: WithBlobData ) {
226
235
Ok ( res) => res,
227
236
Err ( err) => {
228
237
warn ! ( ?err, "Failed to decode raw share bundle" ) ;
229
- // @Metric
238
+ inc_order_input_rpc_errors ( MEV_SEND_BUNDLE ) ;
230
239
return ;
231
240
}
232
241
} ;
@@ -282,6 +291,7 @@ async fn send_command(
282
291
Ok ( ( ) ) => { }
283
292
Err ( SendTimeoutError :: Timeout ( _) ) => {
284
293
warn ! ( "Failed to sent order, timeout" ) ;
294
+ inc_order_input_rpc_errors ( "other" ) ;
285
295
}
286
296
Err ( SendTimeoutError :: Closed ( _) ) => { }
287
297
} ;
@@ -306,7 +316,7 @@ async fn handle_cancel_bundle(
306
316
Ok ( cancel_bundle) => cancel_bundle,
307
317
Err ( err) => {
308
318
warn ! ( ?err, "Failed to parse cancel bundle" ) ;
309
- // @Metric
319
+ inc_order_input_rpc_errors ( ETH_CANCEL_BUNDLE ) ;
310
320
return ;
311
321
}
312
322
} ;
0 commit comments