@@ -7,12 +7,7 @@ use pretty_assertions::assert_eq;
77use rstest:: { fixture, rstest} ;
88use starknet_api:: block:: GasPrice ;
99use starknet_api:: core:: ContractAddress ;
10- use starknet_api:: executable_transaction:: AccountTransaction ;
11- use starknet_api:: rpc_transaction:: {
12- RpcDeployAccountTransaction ,
13- RpcInvokeTransaction ,
14- RpcTransaction ,
15- } ;
10+ use starknet_api:: rpc_transaction:: InternalRpcTransaction ;
1611use starknet_api:: { contract_address, nonce} ;
1712use starknet_mempool_p2p_types:: communication:: MockMempoolP2pPropagatorClient ;
1813use starknet_mempool_types:: communication:: AddTransactionArgsWrapper ;
@@ -88,7 +83,7 @@ impl MempoolContentBuilder {
8883
8984 fn with_pool < P > ( mut self , pool_txs : P ) -> Self
9085 where
91- P : IntoIterator < Item = AccountTransaction > ,
86+ P : IntoIterator < Item = InternalRpcTransaction > ,
9287 {
9388 self . tx_pool = Some ( pool_txs. into_iter ( ) . collect ( ) ) ;
9489 self
@@ -140,8 +135,8 @@ impl MempoolContentBuilder {
140135 }
141136}
142137
143- impl FromIterator < AccountTransaction > for TransactionPool {
144- fn from_iter < T : IntoIterator < Item = AccountTransaction > > ( txs : T ) -> Self {
138+ impl FromIterator < InternalRpcTransaction > for TransactionPool {
139+ fn from_iter < T : IntoIterator < Item = InternalRpcTransaction > > ( txs : T ) -> Self {
145140 let mut pool = Self :: default ( ) ;
146141 for tx in txs {
147142 pool. insert ( tx) . unwrap ( ) ;
@@ -154,7 +149,7 @@ impl FromIterator<AccountTransaction> for TransactionPool {
154149fn builder_with_queue (
155150 in_priority_queue : bool ,
156151 in_pending_queue : bool ,
157- tx : & AccountTransaction ,
152+ tx : & InternalRpcTransaction ,
158153) -> MempoolContentBuilder {
159154 assert ! (
160155 !( in_priority_queue && in_pending_queue) ,
@@ -164,11 +159,11 @@ fn builder_with_queue(
164159 let mut builder = MempoolContentBuilder :: new ( ) ;
165160
166161 if in_priority_queue {
167- builder = builder. with_priority_queue ( [ TransactionReference :: deprecated_new ( tx) ] ) ;
162+ builder = builder. with_priority_queue ( [ TransactionReference :: new ( tx) ] ) ;
168163 }
169164
170165 if in_pending_queue {
171- builder = builder. with_pending_queue ( [ TransactionReference :: deprecated_new ( tx) ] ) ;
166+ builder = builder. with_pending_queue ( [ TransactionReference :: new ( tx) ] ) ;
172167 }
173168
174169 builder
@@ -209,7 +204,7 @@ fn add_tx_and_verify_replacement_in_pool(
209204#[ track_caller]
210205fn add_txs_and_verify_no_replacement (
211206 mut mempool : Mempool ,
212- existing_tx : AccountTransaction ,
207+ existing_tx : InternalRpcTransaction ,
213208 invalid_replacement_inputs : impl IntoIterator < Item = AddTransactionArgs > ,
214209 in_priority_queue : bool ,
215210 in_pending_queue : bool ,
@@ -235,7 +230,7 @@ fn add_txs_and_verify_no_replacement(
235230#[ track_caller]
236231fn add_txs_and_verify_no_replacement_in_pool (
237232 mempool : Mempool ,
238- existing_tx : AccountTransaction ,
233+ existing_tx : InternalRpcTransaction ,
239234 invalid_replacement_inputs : impl IntoIterator < Item = AddTransactionArgs > ,
240235) {
241236 let in_priority_queue = false ;
@@ -276,7 +271,7 @@ fn test_get_txs_returns_by_priority(#[case] n_requested_txs: usize) {
276271 let tx_tip_30 = tx ! ( tx_hash: 2 , address: "0x1" , tip: 30 ) ;
277272 let tx_tip_10 = tx ! ( tx_hash: 3 , address: "0x2" , tip: 10 ) ;
278273
279- let queue_txs = [ & tx_tip_20, & tx_tip_30, & tx_tip_10] . map ( TransactionReference :: deprecated_new ) ;
274+ let queue_txs = [ & tx_tip_20, & tx_tip_30, & tx_tip_10] . map ( TransactionReference :: new ) ;
280275 let pool_txs = [ & tx_tip_20, & tx_tip_30, & tx_tip_10] . map ( |tx| tx. clone ( ) ) ;
281276 let mut mempool = MempoolContentBuilder :: new ( )
282277 . with_pool ( pool_txs)
@@ -292,7 +287,7 @@ fn test_get_txs_returns_by_priority(#[case] n_requested_txs: usize) {
292287 assert_eq ! ( fetched_txs, expected_fetched_txs) ;
293288
294289 // Assert: non-returned transactions are still in the mempool.
295- let remaining_tx_references = remaining_txs. iter ( ) . map ( TransactionReference :: deprecated_new ) ;
290+ let remaining_tx_references = remaining_txs. iter ( ) . map ( TransactionReference :: new ) ;
296291 let expected_mempool_content =
297292 MempoolContentBuilder :: new ( ) . with_priority_queue ( remaining_tx_references) . build ( ) ;
298293 expected_mempool_content. assert_eq ( & mempool) ;
@@ -306,9 +301,7 @@ fn test_get_txs_returns_by_secondary_priority_on_tie() {
306301
307302 let mut mempool = MempoolContentBuilder :: new ( )
308303 . with_pool ( [ & tx_tip_10_hash_9, & tx_tip_10_hash_15] . map ( |tx| tx. clone ( ) ) )
309- . with_priority_queue (
310- [ & tx_tip_10_hash_9, & tx_tip_10_hash_15] . map ( TransactionReference :: deprecated_new) ,
311- )
304+ . with_priority_queue ( [ & tx_tip_10_hash_9, & tx_tip_10_hash_15] . map ( TransactionReference :: new) )
312305 . build_into_mempool ( ) ;
313306
314307 // Test and assert.
@@ -321,7 +314,7 @@ fn test_get_txs_does_not_return_pending_txs() {
321314 let tx = tx ! ( ) ;
322315
323316 let mut mempool = MempoolContentBuilder :: new ( )
324- . with_pending_queue ( [ TransactionReference :: deprecated_new ( & tx) ] )
317+ . with_pending_queue ( [ TransactionReference :: new ( & tx) ] )
325318 . with_pool ( [ tx] )
326319 . build_into_mempool ( ) ;
327320
@@ -334,7 +327,7 @@ fn test_get_txs_does_not_remove_returned_txs_from_pool() {
334327 // Setup.
335328 let tx = tx ! ( ) ;
336329
337- let queue_txs = [ TransactionReference :: deprecated_new ( & tx) ] ;
330+ let queue_txs = [ TransactionReference :: new ( & tx) ] ;
338331 let pool_txs = [ tx] ;
339332 let mut mempool = MempoolContentBuilder :: new ( )
340333 . with_pool ( pool_txs. clone ( ) )
@@ -355,8 +348,7 @@ fn test_get_txs_replenishes_queue_only_between_chunks() {
355348 let tx_address_0_nonce_1 = tx ! ( tx_hash: 2 , address: "0x0" , tx_nonce: 1 , tip: 20 ) ;
356349 let tx_address_1_nonce_0 = tx ! ( tx_hash: 3 , address: "0x1" , tx_nonce: 0 , tip: 10 ) ;
357350
358- let queue_txs =
359- [ & tx_address_0_nonce_0, & tx_address_1_nonce_0] . map ( TransactionReference :: deprecated_new) ;
351+ let queue_txs = [ & tx_address_0_nonce_0, & tx_address_1_nonce_0] . map ( TransactionReference :: new) ;
360352 let pool_txs =
361353 [ & tx_address_0_nonce_0, & tx_address_0_nonce_1, & tx_address_1_nonce_0] . map ( |tx| tx. clone ( ) ) ;
362354 let mut mempool = MempoolContentBuilder :: new ( )
@@ -382,7 +374,7 @@ fn test_get_txs_with_nonce_gap() {
382374 let tx_address_0_nonce_1 = tx ! ( tx_hash: 2 , address: "0x0" , tx_nonce: 1 ) ;
383375 let tx_address_1_nonce_0 = tx ! ( tx_hash: 3 , address: "0x1" , tx_nonce: 0 ) ;
384376
385- let queue_txs = [ TransactionReference :: deprecated_new ( & tx_address_1_nonce_0) ] ;
377+ let queue_txs = [ TransactionReference :: new ( & tx_address_1_nonce_0) ] ;
386378 let pool_txs = [ tx_address_0_nonce_1, tx_address_1_nonce_0. clone ( ) ] ;
387379 let mut mempool = MempoolContentBuilder :: new ( )
388380 . with_pool ( pool_txs)
@@ -415,8 +407,8 @@ fn test_add_tx_insertion_sorted_by_priority(mut mempool: Mempool) {
415407 }
416408
417409 // Assert: transactions are ordered by priority.
418- let expected_queue_txs = [ & input_tip_100 . tx , & input_tip_80 . tx , & input_tip_50 . tx ]
419- . map ( TransactionReference :: deprecated_new ) ;
410+ let expected_queue_txs =
411+ [ & input_tip_100 . tx , & input_tip_80 . tx , & input_tip_50 . tx ] . map ( TransactionReference :: new ) ;
420412 let expected_mempool_content =
421413 MempoolContentBuilder :: new ( ) . with_priority_queue ( expected_queue_txs) . build ( ) ;
422414 expected_mempool_content. assert_eq ( & mempool) ;
@@ -438,8 +430,8 @@ fn test_add_tx_correctly_places_txs_in_queue_and_pool(mut mempool: Mempool) {
438430 }
439431
440432 // Assert: only the eligible transactions appear in the queue.
441- let expected_queue_txs = [ & input_address_1_nonce_0 . tx , & input_address_0_nonce_0 . tx ]
442- . map ( TransactionReference :: deprecated_new ) ;
433+ let expected_queue_txs =
434+ [ & input_address_1_nonce_0 . tx , & input_address_0_nonce_0 . tx ] . map ( TransactionReference :: new ) ;
443435 let expected_pool_txs =
444436 [ input_address_0_nonce_0. tx , input_address_1_nonce_0. tx , input_address_0_nonce_1. tx ] ;
445437 let expected_mempool_content = MempoolContentBuilder :: new ( )
@@ -504,7 +496,7 @@ fn test_add_tx_with_identical_tip_succeeds(mut mempool: Mempool) {
504496 }
505497
506498 // Assert: both transactions are in the mempool.
507- let expected_queue_txs = [ & input1. tx , & input2. tx ] . map ( TransactionReference :: deprecated_new ) ;
499+ let expected_queue_txs = [ & input1. tx , & input2. tx ] . map ( TransactionReference :: new ) ;
508500 let expected_pool_txs = [ input1. tx , input2. tx ] ;
509501 let expected_mempool_content = MempoolContentBuilder :: new ( )
510502 . with_pool ( expected_pool_txs)
@@ -535,7 +527,7 @@ fn test_add_tx_fills_nonce_gap(mut mempool: Mempool) {
535527 add_tx ( & mut mempool, & input_nonce_0) ;
536528
537529 // Assert: only the eligible transaction appears in the queue.
538- let expected_queue_txs = [ TransactionReference :: deprecated_new ( & input_nonce_0. tx ) ] ;
530+ let expected_queue_txs = [ TransactionReference :: new ( & input_nonce_0. tx ) ] ;
539531 let expected_pool_txs = [ input_nonce_1. tx , input_nonce_0. tx ] ;
540532 let expected_mempool_content = MempoolContentBuilder :: new ( )
541533 . with_pool ( expected_pool_txs)
@@ -576,7 +568,7 @@ fn test_commit_block_includes_all_proposed_txs() {
576568 let tx_address_2_nonce_1 = tx ! ( tx_hash: 6 , address: "0x2" , tx_nonce: 1 ) ;
577569
578570 let queue_txs = [ & tx_address_2_nonce_1, & tx_address_1_nonce_3, & tx_address_0_nonce_4]
579- . map ( TransactionReference :: deprecated_new ) ;
571+ . map ( TransactionReference :: new ) ;
580572 let pool_txs = [
581573 tx_address_0_nonce_3,
582574 tx_address_0_nonce_4. clone ( ) ,
@@ -762,7 +754,7 @@ fn test_update_gas_price_threshold_increases_threshold() {
762754 & tx ! ( tx_hash: 0 , address: "0x0" , max_l2_gas_price: 100 ) ,
763755 & tx ! ( tx_hash: 1 , address: "0x1" , max_l2_gas_price: 101 ) ,
764756 ]
765- . map ( TransactionReference :: deprecated_new ) ;
757+ . map ( TransactionReference :: new ) ;
766758
767759 let mut mempool: Mempool = MempoolContentBuilder :: new ( )
768760 . with_priority_queue ( [ tx_low_gas, tx_high_gas] )
@@ -788,7 +780,7 @@ fn test_update_gas_price_threshold_decreases_threshold() {
788780 & tx ! ( tx_hash: 0 , address: "0x0" , max_l2_gas_price: 89 ) ,
789781 & tx ! ( tx_hash: 1 , address: "0x1" , max_l2_gas_price: 90 ) ,
790782 ]
791- . map ( TransactionReference :: deprecated_new ) ;
783+ . map ( TransactionReference :: new ) ;
792784
793785 let mut mempool: Mempool = MempoolContentBuilder :: new ( )
794786 . with_pending_queue ( [ tx_low_gas, tx_high_gas] )
@@ -814,26 +806,11 @@ async fn test_new_tx_sent_to_p2p(mempool: Mempool) {
814806 let tx_args = add_tx_input ! ( tx_hash: 1 , address: "0x0" , tx_nonce: 2 , account_nonce: 2 ) ;
815807 let propagateor_args =
816808 AddTransactionArgsWrapper { args : tx_args. clone ( ) , p2p_message_metadata : None } ;
817- // TODO: use regular conversion once we have a compiler component
818- let rpc_tx = match tx_args. tx {
819- AccountTransaction :: Declare ( _declare_tx) => {
820- panic ! ( "No implementation for converting DeclareTransaction to an RpcTransaction" )
821- }
822- AccountTransaction :: DeployAccount ( deploy_account_transaction) => {
823- RpcTransaction :: DeployAccount ( RpcDeployAccountTransaction :: V3 (
824- deploy_account_transaction. clone ( ) . into ( ) ,
825- ) )
826- }
827- AccountTransaction :: Invoke ( invoke_transaction) => {
828- RpcTransaction :: Invoke ( RpcInvokeTransaction :: V3 ( invoke_transaction. clone ( ) . into ( ) ) )
829- }
830- } ;
831-
832809 let mut mock_mempool_p2p_propagator_client = MockMempoolP2pPropagatorClient :: new ( ) ;
833810 mock_mempool_p2p_propagator_client
834811 . expect_add_transaction ( )
835812 . times ( 1 )
836- . with ( predicate:: eq ( rpc_tx ) )
813+ . with ( predicate:: eq ( tx_args . tx ) )
837814 . returning ( |_| Ok ( ( ) ) ) ;
838815 let mut mempool_wrapper =
839816 MempoolCommunicationWrapper :: new ( mempool, Arc :: new ( mock_mempool_p2p_propagator_client) ) ;
0 commit comments