1
1
use crate :: {
2
2
config:: { HostProvider , ZenithInstance } ,
3
- signer:: LocalOrAws ,
4
- tasks:: oauth:: SharedToken ,
3
+ quincey:: Quincey ,
5
4
utils:: extract_signature_components,
6
5
} ;
7
6
use alloy:: {
@@ -11,16 +10,14 @@ use alloy::{
11
10
primitives:: { FixedBytes , TxHash , U256 } ,
12
11
providers:: { Provider as _, SendableTx , WalletProvider } ,
13
12
rpc:: types:: eth:: TransactionRequest ,
14
- signers:: Signer ,
15
13
sol_types:: { SolCall , SolError } ,
16
14
transports:: TransportError ,
17
15
} ;
18
- use eyre:: { Context , bail, eyre} ;
16
+ use eyre:: { bail, eyre} ;
19
17
use init4_bin_base:: deps:: {
20
18
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} ,
22
20
} ;
23
- use oauth2:: TokenResponse ;
24
21
use signet_sim:: BuiltBlock ;
25
22
use signet_types:: { SignRequest , SignResponse } ;
26
23
use signet_zenith:: {
@@ -58,48 +55,23 @@ pub enum ControlFlow {
58
55
/// Submits sidecars in ethereum txns to mainnet ethereum
59
56
#[ derive( Debug ) ]
60
57
pub struct SubmitTask {
61
- /// Ethereum Provider
62
- pub host_provider : HostProvider ,
63
58
/// Zenith
64
59
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
+
69
64
/// Config
70
65
pub config : crate :: config:: BuilderConfig ,
71
- /// Authenticator
72
- pub token : SharedToken ,
66
+
73
67
/// Channel over which to send pending transactions
74
68
pub outbound_tx_channel : mpsc:: UnboundedSender < TxHash > ,
75
69
}
76
70
77
71
impl 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 ( )
103
75
}
104
76
105
77
/// Constructs the signing request from the in-progress block passed to it and assigns the
@@ -140,7 +112,7 @@ impl SubmitTask {
140
112
141
113
/// Returns the next host block height
142
114
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 ?;
144
116
let next = result. checked_add ( 1 ) . ok_or_else ( || eyre ! ( "next host block height overflow" ) ) ?;
145
117
Ok ( next)
146
118
}
@@ -164,12 +136,12 @@ impl SubmitTask {
164
136
let fills = vec ! [ ] ; // NB: ignored until fills are implemented
165
137
let tx = self
166
138
. 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 ( ) )
168
140
. with_to ( self . config . builder_helper_address )
169
141
. with_gas_limit ( 1_000_000 ) ;
170
142
171
143
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
173
145
{
174
146
error ! (
175
147
code = e. code,
@@ -203,12 +175,12 @@ impl SubmitTask {
203
175
"sending transaction to network"
204
176
) ;
205
177
206
- let SendableTx :: Envelope ( tx) = self . host_provider . fill ( tx) . await ? else {
178
+ let SendableTx :: Envelope ( tx) = self . provider ( ) . fill ( tx) . await ? else {
207
179
bail ! ( "failed to fill transaction" )
208
180
} ;
209
181
210
182
// 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) ;
212
184
213
185
// Spawn send_tx futures for all additional broadcast host_providers
214
186
for host_provider in self . config . connect_additional_broadcast ( ) {
@@ -237,26 +209,6 @@ impl SubmitTask {
237
209
Ok ( ControlFlow :: Done )
238
210
}
239
211
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
-
260
212
#[ instrument( skip_all) ]
261
213
async fn handle_inbound ( & self , block : & BuiltBlock ) -> eyre:: Result < ControlFlow > {
262
214
info ! ( txns = block. tx_count( ) , "handling inbound block" ) ;
@@ -272,7 +224,7 @@ impl SubmitTask {
272
224
"constructed signature request for host block"
273
225
) ;
274
226
275
- let signed = self . get_signature ( sig_request) . await ?;
227
+ let signed = self . quincey . get_signature ( & sig_request) . await ?;
276
228
277
229
self . submit_transaction ( & signed, block) . await
278
230
}
0 commit comments