@@ -214,29 +214,27 @@ where
214214 continue ;
215215 }
216216
217- let ( mut tx_event, tx_gas_meter, mut wrapper_args) =
218- match & tx_header. tx_type {
219- TxType :: Wrapper ( wrapper) => {
220- stats. increment_wrapper_txs ( ) ;
221- let tx_event = new_tx_event ( & tx, height. 0 ) ;
222- let gas_limit = match Gas :: try_from ( wrapper. gas_limit ) {
223- Ok ( value) => value,
224- Err ( _) => {
225- response. events . emit (
226- new_tx_event ( & tx, height. 0 )
227- . with ( Code ( ResultCode :: InvalidTx ) )
228- . with ( Info (
229- "The wrapper gas limit overflowed \
230- gas representation"
231- . to_owned ( ) ,
232- ) )
233- . with ( GasUsed ( 0 . into ( ) ) ) ,
234- ) ;
235- continue ;
236- }
237- } ;
238- let gas_meter = TxGasMeter :: new ( gas_limit) ;
239- for cmt in tx. commitments ( ) {
217+ let ( tx_gas_meter, mut wrapper_args) = match & tx_header. tx_type {
218+ TxType :: Wrapper ( wrapper) => {
219+ stats. increment_wrapper_txs ( ) ;
220+ let gas_limit = match Gas :: try_from ( wrapper. gas_limit ) {
221+ Ok ( value) => value,
222+ Err ( _) => {
223+ response. events . emit (
224+ new_tx_event ( & tx, height. 0 )
225+ . with ( Code ( ResultCode :: InvalidTx ) )
226+ . with ( Info (
227+ "The wrapper gas limit overflowed gas \
228+ representation"
229+ . to_owned ( ) ,
230+ ) )
231+ . with ( GasUsed ( 0 . into ( ) ) ) ,
232+ ) ;
233+ continue ;
234+ }
235+ } ;
236+ let gas_meter = TxGasMeter :: new ( gas_limit) ;
237+ for cmt in tx. commitments ( ) {
240238 if let Some ( code_sec) = tx
241239 . get_section ( cmt. code_sechash ( ) )
242240 . and_then ( |x| Section :: code_sec ( x. as_ref ( ) ) )
@@ -245,8 +243,8 @@ where
245243 code_sec. code . hash ( ) . to_string ( ) ,
246244 ) ;
247245 }
248- }
249246 }
247+
250248 (
251249 gas_meter,
252250 Some ( WrapperArgs {
@@ -544,8 +542,8 @@ where
544542 namada:: tx:: data:: TxResult < protocol:: Error > ,
545543 DispatchError ,
546544 > ,
547- tx_data: TxData ,
548- mut tx_logs: TxLogs ,
545+ tx_data : TxData < ' _ > ,
546+ mut tx_logs : TxLogs < ' _ > ,
549547 ) {
550548 // Check the commitment of the fee unshielding regardless of the
551549 // result, it could be committed even in case of errors
@@ -628,8 +626,8 @@ where
628626 & mut self ,
629627 response : & mut shim:: response:: FinalizeBlock ,
630628 tx_result : namada:: tx:: data:: TxResult < protocol:: Error > ,
631- tx_data: TxData ,
632- tx_logs: & mut TxLogs ,
629+ tx_data : TxData < ' _ > ,
630+ tx_logs : & mut TxLogs < ' _ > ,
633631 ) {
634632 let mut temp_log = TempTxLogs :: new_from_tx_logs ( tx_logs) ;
635633
@@ -646,8 +644,13 @@ where
646644 if tx_data. is_atomic_batch && is_any_tx_invalid {
647645 // Atomic batches need custom handling when even a single tx fails,
648646 // since we need to drop everything
649- let unrun_txs = tx_data. commitments_len
650- - tx_result. batch_results. 0 . len( ) as u64 ;
647+ let unrun_txs = tx_data
648+ . commitments_len
649+ . checked_sub (
650+ u64:: try_from ( tx_result. batch_results . 0 . len ( ) )
651+ . expect ( "Should be able to convert to u64" ) ,
652+ )
653+ . expect ( "Shouldn't underflow" ) ;
651654 temp_log. stats . set_failing_atomic_batch ( unrun_txs) ;
652655 temp_log. commit_stats_only ( tx_logs) ;
653656 self . state . write_log_mut ( ) . drop_batch ( ) ;
@@ -687,8 +690,8 @@ where
687690 response : & mut shim:: response:: FinalizeBlock ,
688691 msg : & Error ,
689692 tx_result : namada:: tx:: data:: TxResult < protocol:: Error > ,
690- tx_data: TxData ,
691- tx_logs: & mut TxLogs ,
693+ tx_data : TxData < ' _ > ,
694+ tx_logs : & mut TxLogs < ' _ > ,
692695 ) {
693696 let mut temp_log = TempTxLogs :: new_from_tx_logs ( tx_logs) ;
694697
@@ -702,8 +705,13 @@ where
702705 tx_data. height ,
703706 ) ;
704707
705- let unrun_txs =
706- tx_data. commitments_len - tx_result. batch_results. 0 . len( ) as u64;
708+ let unrun_txs = tx_data
709+ . commitments_len
710+ . checked_sub (
711+ u64:: try_from ( tx_result. batch_results . 0 . len ( ) )
712+ . expect ( "Should be able to convert to u64" ) ,
713+ )
714+ . expect ( "Shouldn't underflow" ) ;
707715
708716 if tx_data. is_atomic_batch {
709717 tx_logs. stats . set_failing_atomic_batch ( unrun_txs) ;
@@ -735,7 +743,7 @@ where
735743 . extend ( Batch ( & tx_result. to_result_string ( ) ) ) ;
736744 }
737745
738- fn handle_batch_error_reprot( & mut self , err: & Error , tx_data: TxData ) {
746+ fn handle_batch_error_reprot ( & mut self , err : & Error , tx_data : TxData < ' _ > ) {
739747 // If user transaction didn't fail because of out of gas nor
740748 // invalid section commitment, commit its hash to prevent
741749 // replays
@@ -801,7 +809,7 @@ struct TempTxLogs {
801809}
802810
803811impl TempTxLogs {
804- fn new_from_tx_logs( tx_logs : & TxLogs ) -> Self {
812+ fn new_from_tx_logs ( tx_logs : & TxLogs < ' _ > ) -> Self {
805813 Self {
806814 tx_event : Event :: new (
807815 tx_logs. tx_event . kind ( ) . to_owned ( ) ,
@@ -3095,7 +3103,7 @@ mod test_finalize_block {
30953103 assert_eq ! ( * event[ 0 ] . kind( ) , APPLIED_TX ) ;
30963104 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . expect ( "Test failed" ) ;
30973105 assert_eq ! ( code, ResultCode :: Ok ) ;
3098- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
3106+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
30993107 let first_tx_result = inner_tx_result
31003108 . batch_results
31013109 . 0
@@ -3246,7 +3254,7 @@ mod test_finalize_block {
32463254 assert_eq ! ( * event[ 1 ] . kind( ) , APPLIED_TX ) ;
32473255 let code = event[ 1 ] . read_attribute :: < CodeAttr > ( ) . expect ( "Test failed" ) ;
32483256 assert_eq ! ( code, ResultCode :: Ok ) ;
3249- let inner_tx_result = event[ 1 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
3257+ let inner_tx_result = event[ 1 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
32503258 let inner_result = inner_tx_result
32513259 . batch_results
32523260 . 0
@@ -3256,7 +3264,7 @@ mod test_finalize_block {
32563264 assert_eq ! ( * event[ 2 ] . kind( ) , APPLIED_TX ) ;
32573265 let code = event[ 2 ] . read_attribute :: < CodeAttr > ( ) . expect ( "Test failed" ) ;
32583266 assert_eq ! ( code, ResultCode :: Ok ) ;
3259- let inner_tx_result = event[ 2 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
3267+ let inner_tx_result = event[ 2 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
32603268 let inner_result = inner_tx_result
32613269 . batch_results
32623270 . 0
@@ -3271,7 +3279,7 @@ mod test_finalize_block {
32713279 assert_eq ! ( * event[ 3 ] . kind( ) , APPLIED_TX ) ;
32723280 let code = event[ 3 ] . read_attribute :: < CodeAttr > ( ) . expect ( "Test failed" ) ;
32733281 assert_eq ! ( code, ResultCode :: Ok ) ;
3274- let inner_tx_result = event[ 3 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
3282+ let inner_tx_result = event[ 3 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
32753283 let inner_result = inner_tx_result
32763284 . batch_results
32773285 . 0
@@ -3476,7 +3484,7 @@ mod test_finalize_block {
34763484 assert_eq ! ( * event. kind( ) , APPLIED_TX ) ;
34773485 let code = event. read_attribute :: < CodeAttr > ( ) . expect ( "Test failed" ) ;
34783486 assert_eq ! ( code, ResultCode :: Ok ) ;
3479- let inner_tx_result = event. read_attribute :: < Batch > ( ) . unwrap ( ) ;
3487+ let inner_tx_result = event. read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
34803488 let inner_result = inner_tx_result
34813489 . batch_results
34823490 . 0
@@ -5399,7 +5407,7 @@ mod test_finalize_block {
53995407
54005408 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . unwrap ( ) ;
54015409 assert_eq ! ( code, ResultCode :: Ok ) ;
5402- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
5410+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
54035411 let inner_results = inner_tx_result. batch_results . 0 ;
54045412
54055413 for cmt in batch. commitments ( ) {
@@ -5444,7 +5452,7 @@ mod test_finalize_block {
54445452
54455453 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . unwrap ( ) ;
54465454 assert_eq ! ( code, ResultCode :: WasmRuntimeError ) ;
5447- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
5455+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
54485456 let inner_results = inner_tx_result. batch_results . 0 ;
54495457
54505458 assert ! (
@@ -5494,7 +5502,7 @@ mod test_finalize_block {
54945502
54955503 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . unwrap ( ) ;
54965504 assert_eq ! ( code, ResultCode :: Ok ) ;
5497- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
5505+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
54985506 let inner_results = inner_tx_result. batch_results . 0 ;
54995507
55005508 assert ! (
@@ -5562,7 +5570,7 @@ mod test_finalize_block {
55625570
55635571 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . unwrap ( ) ;
55645572 assert_eq ! ( code, ResultCode :: WasmRuntimeError ) ;
5565- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
5573+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
55665574 let inner_results = inner_tx_result. batch_results . 0 ;
55675575
55685576 assert ! (
@@ -5611,7 +5619,7 @@ mod test_finalize_block {
56115619
56125620 let code = event[ 0 ] . read_attribute :: < CodeAttr > ( ) . unwrap ( ) ;
56135621 assert_eq ! ( code, ResultCode :: WasmRuntimeError ) ;
5614- let inner_tx_result = event[ 0 ] . read_attribute :: < Batch > ( ) . unwrap ( ) ;
5622+ let inner_tx_result = event[ 0 ] . read_attribute :: < Batch < ' _ > > ( ) . unwrap ( ) ;
56155623 let inner_results = inner_tx_result. batch_results . 0 ;
56165624
56175625 assert ! (
0 commit comments