11use crate :: {
22 config:: { HostProvider , ZenithInstance } ,
3- signer:: LocalOrAws ,
4- tasks:: oauth:: SharedToken ,
3+ quincey:: Quincey ,
54 utils:: extract_signature_components,
65} ;
76use alloy:: {
@@ -11,16 +10,14 @@ use alloy::{
1110 primitives:: { FixedBytes , TxHash , U256 } ,
1211 providers:: { Provider as _, SendableTx , WalletProvider } ,
1312 rpc:: types:: eth:: TransactionRequest ,
14- signers:: Signer ,
1513 sol_types:: { SolCall , SolError } ,
1614 transports:: TransportError ,
1715} ;
18- use eyre:: { Context , bail, eyre} ;
16+ use eyre:: { bail, eyre} ;
1917use init4_bin_base:: deps:: {
2018 metrics:: { counter, histogram} ,
21- tracing:: { self , Instrument , debug, debug_span, error, info, instrument, trace , warn} ,
19+ tracing:: { self , Instrument , debug, debug_span, error, info, instrument, warn} ,
2220} ;
23- use oauth2:: TokenResponse ;
2421use signet_sim:: BuiltBlock ;
2522use signet_types:: { SignRequest , SignResponse } ;
2623use signet_zenith:: {
@@ -58,48 +55,23 @@ pub enum ControlFlow {
5855/// Submits sidecars in ethereum txns to mainnet ethereum
5956#[ derive( Debug ) ]
6057pub struct SubmitTask {
61- /// Ethereum Provider
62- pub host_provider : HostProvider ,
6358 /// Zenith
6459 pub zenith : ZenithInstance ,
65- /// Reqwest
66- pub client : reqwest :: Client ,
67- /// Sequencer Signer
68- pub sequencer_signer : Option < LocalOrAws > ,
60+
61+ /// Quincey
62+ pub quincey : Quincey ,
63+
6964 /// Config
7065 pub config : crate :: config:: BuilderConfig ,
71- /// Authenticator
72- pub token : SharedToken ,
66+
7367 /// Channel over which to send pending transactions
7468 pub outbound_tx_channel : mpsc:: UnboundedSender < TxHash > ,
7569}
7670
7771impl SubmitTask {
78- #[ instrument( skip( self ) ) ]
79- async fn sup_quincey ( & self , sig_request : & SignRequest ) -> eyre:: Result < SignResponse > {
80- info ! (
81- host_block_number = %sig_request. host_block_number,
82- ru_chain_id = %sig_request. ru_chain_id,
83- "pinging quincey for signature"
84- ) ;
85-
86- let Some ( token) = self . token . read ( ) else { bail ! ( "no token available" ) } ;
87-
88- let resp: reqwest:: Response = self
89- . client
90- . post ( self . config . quincey_url . as_ref ( ) )
91- . json ( sig_request)
92- . bearer_auth ( token. access_token ( ) . secret ( ) )
93- . send ( )
94- . await ?
95- . error_for_status ( ) ?;
96-
97- let body = resp. bytes ( ) . await ?;
98-
99- debug ! ( bytes = body. len( ) , "retrieved response body" ) ;
100- trace ! ( body = %String :: from_utf8_lossy( & body) , "response body" ) ;
101-
102- serde_json:: from_slice ( & body) . map_err ( Into :: into)
72+ /// Get the provider from the zenith instance
73+ const fn provider ( & self ) -> & HostProvider {
74+ self . zenith . provider ( )
10375 }
10476
10577 /// Constructs the signing request from the in-progress block passed to it and assigns the
@@ -140,7 +112,7 @@ impl SubmitTask {
140112
141113 /// Returns the next host block height
142114 async fn next_host_block_height ( & self ) -> eyre:: Result < u64 > {
143- let result = self . host_provider . get_block_number ( ) . await ?;
115+ let result = self . provider ( ) . get_block_number ( ) . await ?;
144116 let next = result. checked_add ( 1 ) . ok_or_else ( || eyre ! ( "next host block height overflow" ) ) ?;
145117 Ok ( next)
146118 }
@@ -164,12 +136,12 @@ impl SubmitTask {
164136 let fills = vec ! [ ] ; // NB: ignored until fills are implemented
165137 let tx = self
166138 . build_blob_tx ( fills, header, v, r, s, in_progress) ?
167- . with_from ( self . host_provider . default_signer_address ( ) )
139+ . with_from ( self . provider ( ) . default_signer_address ( ) )
168140 . with_to ( self . config . builder_helper_address )
169141 . with_gas_limit ( 1_000_000 ) ;
170142
171143 if let Err ( TransportError :: ErrorResp ( e) ) =
172- self . host_provider . call ( tx. clone ( ) ) . block ( BlockNumberOrTag :: Pending . into ( ) ) . await
144+ self . provider ( ) . call ( tx. clone ( ) ) . block ( BlockNumberOrTag :: Pending . into ( ) ) . await
173145 {
174146 error ! (
175147 code = e. code,
@@ -203,12 +175,12 @@ impl SubmitTask {
203175 "sending transaction to network"
204176 ) ;
205177
206- let SendableTx :: Envelope ( tx) = self . host_provider . fill ( tx) . await ? else {
178+ let SendableTx :: Envelope ( tx) = self . provider ( ) . fill ( tx) . await ? else {
207179 bail ! ( "failed to fill transaction" )
208180 } ;
209181
210182 // Send the tx via the primary host_provider
211- let fut = spawn_provider_send ! ( & self . host_provider , & tx) ;
183+ let fut = spawn_provider_send ! ( self . provider ( ) , & tx) ;
212184
213185 // Spawn send_tx futures for all additional broadcast host_providers
214186 for host_provider in self . config . connect_additional_broadcast ( ) {
@@ -237,26 +209,6 @@ impl SubmitTask {
237209 Ok ( ControlFlow :: Done )
238210 }
239211
240- /// Sign with a local signer if available, otherwise ask quincey
241- /// for a signature (politely).
242- #[ instrument( skip_all, fields( is_local = self . sequencer_signer. is_some( ) ) ) ]
243- async fn get_signature ( & self , req : SignRequest ) -> eyre:: Result < SignResponse > {
244- let sig = if let Some ( signer) = & self . sequencer_signer {
245- signer. sign_hash ( & req. signing_hash ( ) ) . await ?
246- } else {
247- self . sup_quincey ( & req)
248- . await
249- . wrap_err ( "failed to get signature from quincey" )
250- . inspect ( |_| {
251- counter ! ( "builder.quincey_signature_acquired" ) . increment ( 1 ) ;
252- } ) ?
253- . sig
254- } ;
255-
256- debug ! ( sig = hex:: encode( sig. as_bytes( ) ) , "acquired signature" ) ;
257- Ok ( SignResponse { req, sig } )
258- }
259-
260212 #[ instrument( skip_all) ]
261213 async fn handle_inbound ( & self , block : & BuiltBlock ) -> eyre:: Result < ControlFlow > {
262214 info ! ( txns = block. tx_count( ) , "handling inbound block" ) ;
@@ -272,7 +224,7 @@ impl SubmitTask {
272224 "constructed signature request for host block"
273225 ) ;
274226
275- let signed = self . get_signature ( sig_request) . await ?;
227+ let signed = self . quincey . get_signature ( & sig_request) . await ?;
276228
277229 self . submit_transaction ( & signed, block) . await
278230 }
0 commit comments