1
- use alloy_primitives:: { BlockHash , U256 } ;
1
+ use alloy_primitives:: { Address , BlockHash , U256 } ;
2
2
use exponential_backoff:: Backoff ;
3
- use jsonrpsee:: {
4
- core:: { client:: ClientT , traits:: ToRpcParams } ,
5
- http_client:: { HttpClient , HttpClientBuilder } ,
6
- } ;
3
+ use jsonrpsee:: core:: { client:: ClientT , traits:: ToRpcParams } ;
7
4
use rbuilder:: {
8
5
building:: BuiltBlockTrace ,
9
6
live_builder:: {
@@ -14,7 +11,7 @@ use rbuilder::{
14
11
use rbuilder_primitives:: {
15
12
mev_boost:: SubmitBlockRequest ,
16
13
serialize:: { RawBundle , RawShareBundle } ,
17
- Bundle , Order ,
14
+ Bundle , Order , OrderId ,
18
15
} ;
19
16
use reth_primitives:: SealedBlock ;
20
17
use serde:: { Deserialize , Serialize } ;
@@ -23,12 +20,12 @@ use serde_with::{serde_as, DisplayFromStr};
23
20
use std:: { sync:: Arc , time:: Duration } ;
24
21
use time:: format_description:: well_known;
25
22
use tracing:: { error, warn, Span } ;
23
+ use uuid:: Uuid ;
26
24
27
25
use crate :: metrics:: inc_submit_block_errors;
28
26
29
27
const BLOCK_PROCESSOR_ERROR_CATEGORY : & str = "block_processor" ;
30
- const DEFAULT_BLOCK_CONSUME_BUILT_BLOCK_METHOD : & str = "block_consumeBuiltBlockV2" ;
31
- pub const SIGNED_BLOCK_CONSUME_BUILT_BLOCK_METHOD : & str = "flashbots_consumeBuiltBlockV2" ;
28
+ pub const SIGNED_BLOCK_CONSUME_BUILT_BLOCK_METHOD : & str = "flashbots_consumeBuiltBlockV3" ;
32
29
33
30
#[ derive( Debug , Serialize , Deserialize ) ]
34
31
#[ serde( rename_all = "camelCase" ) ]
@@ -67,6 +64,14 @@ struct BlocksProcessorHeader {
67
64
pub number : Option < U256 > ,
68
65
}
69
66
67
+ #[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize , Hash ) ]
68
+ #[ serde( rename_all = "camelCase" ) ]
69
+ pub struct BlockProcessorDelayedPayments {
70
+ pub source : Uuid ,
71
+ pub value : U256 ,
72
+ pub address : Address ,
73
+ }
74
+
70
75
type ConsumeBuiltBlockRequest = (
71
76
BlocksProcessorHeader ,
72
77
String ,
@@ -78,6 +83,7 @@ type ConsumeBuiltBlockRequest = (
78
83
String ,
79
84
U256 ,
80
85
U256 ,
86
+ Vec < BlockProcessorDelayedPayments > ,
81
87
) ;
82
88
83
89
/// Struct to avoid copying ConsumeBuiltBlockRequest since HttpClient::request eats the parameter.
@@ -113,22 +119,6 @@ pub struct BlocksProcessorClient<HttpClientType> {
113
119
consume_built_block_method : & ' static str ,
114
120
}
115
121
116
- impl BlocksProcessorClient < HttpClient > {
117
- pub fn try_from (
118
- url : & str ,
119
- max_request_size : u32 ,
120
- max_concurrent_requests : usize ,
121
- ) -> eyre:: Result < Self > {
122
- Ok ( Self {
123
- client : HttpClientBuilder :: default ( )
124
- . max_request_size ( max_request_size)
125
- . max_concurrent_requests ( max_concurrent_requests)
126
- . build ( url) ?,
127
- consume_built_block_method : DEFAULT_BLOCK_CONSUME_BUILT_BLOCK_METHOD ,
128
- } )
129
- }
130
- }
131
-
132
122
/// RawBundle::encode_no_blobs but more compatible.
133
123
fn encode_bundle_for_blocks_processor ( mut bundle : Bundle ) -> RawBundle {
134
124
// set to 0 when none
@@ -187,6 +177,36 @@ impl<HttpClientType: ClientT> BlocksProcessorClient<HttpClientType> {
187
177
188
178
let used_share_bundles = Self :: get_used_sbundles ( built_block_trace) ;
189
179
180
+ let delayed_payments = built_block_trace
181
+ . included_orders
182
+ . iter ( )
183
+ . filter_map ( |res| {
184
+ let delayed_kickback = if let Some ( k) = & res. delayed_kickback {
185
+ k
186
+ } else {
187
+ return None ;
188
+ } ;
189
+
190
+ if delayed_kickback. should_pay_in_block {
191
+ return None ;
192
+ }
193
+
194
+ let bundle_uuid = match res. order . id ( ) {
195
+ OrderId :: Bundle ( uuid) => uuid,
196
+ _ => {
197
+ error ! ( order = ?res. order. id( ) , "Delayed kickback is found for non-bundle" ) ;
198
+ return None ;
199
+ }
200
+ } ;
201
+
202
+ Some ( BlockProcessorDelayedPayments {
203
+ source : bundle_uuid,
204
+ value : delayed_kickback. payout_value ,
205
+ address : delayed_kickback. recipient ,
206
+ } )
207
+ } )
208
+ . collect ( ) ;
209
+
190
210
let params: ConsumeBuiltBlockRequest = (
191
211
header,
192
212
closed_at,
@@ -198,6 +218,7 @@ impl<HttpClientType: ClientT> BlocksProcessorClient<HttpClientType> {
198
218
builder_name,
199
219
built_block_trace. true_bid_value ,
200
220
best_bid_value,
221
+ delayed_payments,
201
222
) ;
202
223
let request = ConsumeBuiltBlockRequestArc :: new ( params) ;
203
224
let backoff = backoff ( ) ;
@@ -375,4 +396,19 @@ mod tests {
375
396
dbg ! ( total_sleep_time) ;
376
397
assert ! ( total_sleep_time > 40 && total_sleep_time < 90 ) ;
377
398
}
399
+
400
+ #[ test]
401
+ fn test_delayed_payment_serialize ( ) {
402
+ let value = BlockProcessorDelayedPayments {
403
+ address : alloy_primitives:: address!( "93Ea7cB31f76B982601321b2A0d93Ec9A948236D" ) ,
404
+ value : U256 :: from ( 16 ) ,
405
+ source : Uuid :: try_parse ( "ff7b2232-b30d-4889-9258-c3632ba4bfc0" ) . unwrap ( ) ,
406
+ } ;
407
+
408
+ let value_str = serde_json:: to_string ( & value) . unwrap ( ) ;
409
+
410
+ let expected_str = r#"{"source":"ff7b2232-b30d-4889-9258-c3632ba4bfc0","value":"0x10","address":"0x93ea7cb31f76b982601321b2a0d93ec9a948236d"}"# ;
411
+
412
+ assert_eq ! ( value_str, expected_str) ;
413
+ }
378
414
}
0 commit comments