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 ,
@@ -14,7 +15,7 @@ use op_alloy_rpc_types_engine::{
14
15
} ;
15
16
use reth_rpc_layer:: AuthClientService ;
16
17
use std:: sync:: Arc ;
17
- use tracing:: { error, info} ;
18
+ use tracing:: { debug , error, info} ;
18
19
19
20
#[ rpc( server, client, namespace = "engine" ) ]
20
21
pub trait EngineApi {
@@ -40,6 +41,12 @@ pub trait EngineApi {
40
41
) -> RpcResult < PayloadStatus > ;
41
42
}
42
43
44
+ #[ rpc( server, client, namespace = "eth" ) ]
45
+ pub trait EthApi {
46
+ #[ method( name = "sendRawTransaction" ) ]
47
+ async fn send_raw_transaction ( & self , bytes : Bytes ) -> RpcResult < B256 > ;
48
+ }
49
+
43
50
pub struct EthEngineApi < S = AuthClientService < HttpBackend > > {
44
51
l2_client : Arc < HttpClient < S > > ,
45
52
builder_client : Arc < HttpClient < S > > ,
@@ -60,6 +67,36 @@ impl<S> EthEngineApi<S> {
60
67
}
61
68
}
62
69
70
+ #[ async_trait]
71
+ impl EthApiServer for EthEngineApi {
72
+ async fn send_raw_transaction ( & self , bytes : Bytes ) -> RpcResult < B256 > {
73
+ debug ! (
74
+ message = "received send_raw_transaction" ,
75
+ "bytes_len" = bytes. len( )
76
+ ) ;
77
+ let builder = self . builder_client . clone ( ) ;
78
+ let tx_bytes = bytes. clone ( ) ;
79
+ tokio:: spawn ( async move {
80
+ builder. send_raw_transaction ( tx_bytes) . await . map_err ( |e| {
81
+ error ! ( message = "error calling send_raw_transaction for builder" , "error" = %e) ;
82
+ } )
83
+ } ) ;
84
+ self . l2_client
85
+ . send_raw_transaction ( bytes)
86
+ . await
87
+ . map_err ( |e| match e {
88
+ ClientError :: Call ( err) => err, // Already an ErrorObjectOwned, so just return it
89
+ other_error => {
90
+ error ! (
91
+ message = "error calling send_raw_transaction for l2 client" ,
92
+ "error" = %other_error,
93
+ ) ;
94
+ ErrorCode :: InternalError . into ( )
95
+ }
96
+ } )
97
+ }
98
+ }
99
+
63
100
#[ async_trait]
64
101
impl EngineApiServer for EthEngineApi {
65
102
async fn fork_choice_updated_v3 (
0 commit comments