1
1
use alloy:: primitives:: B256 ;
2
+ use alloy_primitives:: Bytes ;
2
3
use alloy_rpc_types_engine:: {
3
4
ExecutionPayload , ExecutionPayloadV3 , ForkchoiceState , ForkchoiceUpdated , PayloadId ,
4
5
PayloadStatus ,
@@ -15,7 +16,7 @@ use op_alloy_rpc_types_engine::{
15
16
} ;
16
17
use reth_rpc_layer:: AuthClientService ;
17
18
use std:: sync:: Arc ;
18
- use tracing:: { error, info} ;
19
+ use tracing:: { debug , error, info} ;
19
20
20
21
use crate :: selector:: { DefaultPayloadSelector , PayloadSelector } ;
21
22
@@ -43,6 +44,12 @@ pub trait EngineApi {
43
44
) -> RpcResult < PayloadStatus > ;
44
45
}
45
46
47
+ #[ rpc( server, client, namespace = "eth" ) ]
48
+ pub trait EthApi {
49
+ #[ method( name = "sendRawTransaction" ) ]
50
+ async fn send_raw_transaction ( & self , bytes : Bytes ) -> RpcResult < B256 > ;
51
+ }
52
+
46
53
pub struct EthEngineApi < S = AuthClientService < HttpBackend > > {
47
54
l2_client : Arc < HttpClient < S > > ,
48
55
builder_clients : Vec < Arc < HttpClient < S > > > ,
@@ -65,6 +72,36 @@ impl<S> EthEngineApi<S> {
65
72
}
66
73
}
67
74
75
+ #[ async_trait]
76
+ impl EthApiServer for EthEngineApi {
77
+ async fn send_raw_transaction ( & self , bytes : Bytes ) -> RpcResult < B256 > {
78
+ debug ! (
79
+ message = "received send_raw_transaction" ,
80
+ "bytes_len" = bytes. len( )
81
+ ) ;
82
+ let builder = self . builder_client . clone ( ) ;
83
+ let tx_bytes = bytes. clone ( ) ;
84
+ tokio:: spawn ( async move {
85
+ builder. send_raw_transaction ( tx_bytes) . await . map_err ( |e| {
86
+ error ! ( message = "error calling send_raw_transaction for builder" , "error" = %e) ;
87
+ } )
88
+ } ) ;
89
+ self . l2_client
90
+ . send_raw_transaction ( bytes)
91
+ . await
92
+ . map_err ( |e| match e {
93
+ ClientError :: Call ( err) => err, // Already an ErrorObjectOwned, so just return it
94
+ other_error => {
95
+ error ! (
96
+ message = "error calling send_raw_transaction for l2 client" ,
97
+ "error" = %other_error,
98
+ ) ;
99
+ ErrorCode :: InternalError . into ( )
100
+ }
101
+ } )
102
+ }
103
+ }
104
+
68
105
#[ async_trait]
69
106
impl EngineApiServer for EthEngineApi {
70
107
async fn fork_choice_updated_v3 (
0 commit comments