@@ -25,6 +25,7 @@ use apollo_network_types::network_types::BroadcastedMessageMetadata;
25
25
use apollo_proc_macros:: sequencer_latency_histogram;
26
26
use apollo_state_sync_types:: communication:: SharedStateSyncClient ;
27
27
use axum:: async_trait;
28
+ use starknet_api:: core:: Nonce ;
28
29
use starknet_api:: executable_transaction:: AccountTransaction ;
29
30
use starknet_api:: rpc_transaction:: {
30
31
InternalRpcTransaction ,
@@ -149,19 +150,15 @@ impl Gateway {
149
150
transaction_converter_err_to_deprecated_gw_err ( & tx_signature, e)
150
151
} ) ?;
151
152
152
- let blocking_task = ProcessTxBlockingTask :: new (
153
- self ,
154
- internal_tx,
155
- executable_tx,
156
- tokio:: runtime:: Handle :: current ( ) ,
157
- ) ;
153
+ let blocking_task =
154
+ ProcessTxBlockingTask :: new ( self , executable_tx, tokio:: runtime:: Handle :: current ( ) ) ;
158
155
// Run the blocking task in the current span.
159
156
let curr_span = Span :: current ( ) ;
160
157
let handle =
161
158
tokio:: task:: spawn_blocking ( move || curr_span. in_scope ( || blocking_task. process_tx ( ) ) ) ;
162
159
let handle_result = handle. await ;
163
- let add_tx_args = match handle_result {
164
- Ok ( Ok ( add_tx_args ) ) => add_tx_args ,
160
+ let nonce = match handle_result {
161
+ Ok ( Ok ( nonce ) ) => nonce ,
165
162
Ok ( Err ( starknet_err) ) => {
166
163
info ! (
167
164
"Gateway validation failed for tx with signature: {:?} with error: {}" ,
@@ -182,9 +179,12 @@ impl Gateway {
182
179
}
183
180
} ;
184
181
185
- let gateway_output = create_gateway_output ( & add_tx_args . tx ) ;
182
+ let gateway_output = create_gateway_output ( & internal_tx ) ;
186
183
187
- let add_tx_args = AddTransactionArgsWrapper { args : add_tx_args, p2p_message_metadata } ;
184
+ let add_tx_args = AddTransactionArgsWrapper {
185
+ args : AddTransactionArgs :: new ( internal_tx, nonce) ,
186
+ p2p_message_metadata,
187
+ } ;
188
188
match mempool_client_result_to_deprecated_gw_result (
189
189
tx. signature ( ) ,
190
190
self . mempool_client . add_tx ( add_tx_args) . await ,
@@ -236,29 +236,26 @@ struct ProcessTxBlockingTask {
236
236
stateful_tx_validator_factory : Arc < dyn StatefulTransactionValidatorFactoryTrait > ,
237
237
state_reader_factory : Arc < dyn StateReaderFactory > ,
238
238
mempool_client : SharedMempoolClient ,
239
- internal_tx : InternalRpcTransaction ,
240
239
executable_tx : AccountTransaction ,
241
240
runtime : tokio:: runtime:: Handle ,
242
241
}
243
242
244
243
impl ProcessTxBlockingTask {
245
244
pub fn new (
246
245
gateway : & Gateway ,
247
- internal_tx : InternalRpcTransaction ,
248
246
executable_tx : AccountTransaction ,
249
247
runtime : tokio:: runtime:: Handle ,
250
248
) -> Self {
251
249
Self {
252
250
stateful_tx_validator_factory : gateway. stateful_tx_validator_factory . clone ( ) ,
253
251
state_reader_factory : gateway. state_reader_factory . clone ( ) ,
254
252
mempool_client : gateway. mempool_client . clone ( ) ,
255
- internal_tx,
256
253
executable_tx,
257
254
runtime,
258
255
}
259
256
}
260
257
261
- fn process_tx ( self ) -> GatewayResult < AddTransactionArgs > {
258
+ fn process_tx ( self ) -> GatewayResult < Nonce > {
262
259
let mut stateful_transaction_validator = self
263
260
. stateful_tx_validator_factory
264
261
. instantiate_validator ( self . state_reader_factory . as_ref ( ) ) ?;
@@ -269,7 +266,7 @@ impl ProcessTxBlockingTask {
269
266
self . runtime ,
270
267
) ?;
271
268
272
- Ok ( AddTransactionArgs :: new ( self . internal_tx , nonce) )
269
+ Ok ( nonce)
273
270
}
274
271
}
275
272
0 commit comments