@@ -10,11 +10,12 @@ use op_alloy_consensus::OpTxEnvelope;
1010use op_alloy_network:: Optimism ;
1111use reth_rpc_eth_types:: EthApiError ;
1212use std:: time:: { SystemTime , UNIX_EPOCH } ;
13- use tips_audit:: { BundleEvent , BundleEventPublisher } ;
13+ use tips_audit:: BundleEvent ;
1414use tips_core:: types:: ParsedBundle ;
1515use tips_core:: {
1616 AcceptedBundle , Bundle , BundleExtensions , BundleHash , CancelBundle , MeterBundleResponse ,
1717} ;
18+ use tokio:: sync:: mpsc;
1819use tokio:: time:: Instant ;
1920use tracing:: { info, warn} ;
2021
@@ -37,24 +38,24 @@ pub trait IngressApi {
3738 async fn send_raw_transaction ( & self , tx : Bytes ) -> RpcResult < B256 > ;
3839}
3940
40- pub struct IngressService < Queue , Audit > {
41+ pub struct IngressService < Queue > {
4142 provider : RootProvider < Optimism > ,
4243 simulation_provider : RootProvider < Optimism > ,
4344 dual_write_mempool : bool ,
4445 bundle_queue : Queue ,
45- audit_publisher : Audit ,
46+ audit_channel : mpsc :: UnboundedSender < BundleEvent > ,
4647 send_transaction_default_lifetime_seconds : u64 ,
4748 metrics : Metrics ,
4849 block_time_milliseconds : u64 ,
4950}
5051
51- impl < Queue , Audit > IngressService < Queue , Audit > {
52+ impl < Queue > IngressService < Queue > {
5253 pub fn new (
5354 provider : RootProvider < Optimism > ,
5455 simulation_provider : RootProvider < Optimism > ,
5556 dual_write_mempool : bool ,
5657 queue : Queue ,
57- audit_publisher : Audit ,
58+ audit_channel : mpsc :: UnboundedSender < BundleEvent > ,
5859 send_transaction_default_lifetime_seconds : u64 ,
5960 block_time_milliseconds : u64 ,
6061 ) -> Self {
@@ -63,7 +64,7 @@ impl<Queue, Audit> IngressService<Queue, Audit> {
6364 simulation_provider,
6465 dual_write_mempool,
6566 bundle_queue : queue,
66- audit_publisher ,
67+ audit_channel ,
6768 send_transaction_default_lifetime_seconds,
6869 metrics : Metrics :: default ( ) ,
6970 block_time_milliseconds,
@@ -72,10 +73,9 @@ impl<Queue, Audit> IngressService<Queue, Audit> {
7273}
7374
7475#[ async_trait]
75- impl < Queue , Audit > IngressApiServer for IngressService < Queue , Audit >
76+ impl < Queue > IngressApiServer for IngressService < Queue >
7677where
7778 Queue : QueuePublisher + Sync + Send + ' static ,
78- Audit : BundleEventPublisher + Sync + Send + ' static ,
7979{
8080 async fn send_bundle ( & self , bundle : Bundle ) -> RpcResult < BundleHash > {
8181 self . validate_bundle ( & bundle) . await ?;
@@ -104,8 +104,11 @@ where
104104 bundle_id : * accepted_bundle. uuid ( ) ,
105105 bundle : Box :: new ( accepted_bundle. clone ( ) ) ,
106106 } ;
107- if let Err ( e) = self . audit_publisher . publish ( audit_event) . await {
108- warn ! ( message = "Failed to publish audit event" , bundle_id = %accepted_bundle. uuid( ) , error = %e) ;
107+ if let Err ( e) = self . audit_channel . send ( audit_event) {
108+ warn ! ( message = "Failed to send audit event" , error = %e) ;
109+ return Err (
110+ EthApiError :: InvalidParams ( "Failed to send audit event" . into ( ) ) . into_rpc_err ( ) ,
111+ ) ;
109112 }
110113
111114 Ok ( BundleHash {
@@ -178,8 +181,11 @@ where
178181 bundle_id : * accepted_bundle. uuid ( ) ,
179182 bundle : accepted_bundle. clone ( ) . into ( ) ,
180183 } ;
181- if let Err ( e) = self . audit_publisher . publish ( audit_event) . await {
182- warn ! ( message = "Failed to publish audit event" , bundle_id = %accepted_bundle. uuid( ) , error = %e) ;
184+ if let Err ( e) = self . audit_channel . send ( audit_event) {
185+ warn ! ( message = "Failed to send audit event" , error = %e) ;
186+ return Err (
187+ EthApiError :: InvalidParams ( "Failed to send audit event" . into ( ) ) . into_rpc_err ( ) ,
188+ ) ;
183189 }
184190
185191 self . metrics
@@ -189,10 +195,9 @@ where
189195 }
190196}
191197
192- impl < Queue , Audit > IngressService < Queue , Audit >
198+ impl < Queue > IngressService < Queue >
193199where
194200 Queue : QueuePublisher + Sync + Send + ' static ,
195- Audit : BundleEventPublisher + Sync + Send + ' static ,
196201{
197202 async fn validate_tx ( & self , data : & Bytes ) -> RpcResult < Recovered < OpTxEnvelope > > {
198203 let start = Instant :: now ( ) ;
0 commit comments