@@ -220,28 +220,31 @@ where
220220
221221 fn validate (
222222 & self ,
223- _who : & Self :: AccountId ,
224- _call : & Self :: Call ,
225- _info : & DispatchInfoOf < Self :: Call > ,
226- _len : usize ,
223+ who : & Self :: AccountId ,
224+ call : & Self :: Call ,
225+ info : & DispatchInfoOf < Self :: Call > ,
226+ len : usize ,
227227 ) -> TransactionValidity {
228+ // reject batch transactions with obsolete headers
229+ if let Some ( UtilityCall :: < R > :: batch_all { ref calls } ) = call. is_sub_type ( ) {
230+ for nested_call in calls {
231+ let reject_obsolete_transactions = BE :: default ( ) ;
232+ reject_obsolete_transactions. pre_dispatch ( who, nested_call, info, len) ?;
233+ }
234+ }
235+
228236 Ok ( ValidTransaction :: default ( ) )
229237 }
230238
231239 fn pre_dispatch (
232240 self ,
233241 who : & Self :: AccountId ,
234242 call : & Self :: Call ,
235- post_info : & DispatchInfoOf < Self :: Call > ,
243+ info : & DispatchInfoOf < Self :: Call > ,
236244 len : usize ,
237245 ) -> Result < Self :: Pre , TransactionValidityError > {
238246 // reject batch transactions with obsolete headers
239- if let Some ( UtilityCall :: < R > :: batch_all { ref calls } ) = call. is_sub_type ( ) {
240- for nested_call in calls {
241- let reject_obsolete_transactions = BE :: default ( ) ;
242- reject_obsolete_transactions. pre_dispatch ( who, nested_call, post_info, len) ?;
243- }
244- }
247+ self . validate ( who, call, info, len) . map ( drop) ?;
245248
246249 // now try to check if tx matches one of types we support
247250 let parse_call_type = || {
@@ -611,6 +614,11 @@ mod tests {
611614 sp_io:: TestExternalities :: new ( Default :: default ( ) ) . execute_with ( test)
612615 }
613616
617+ fn run_validate ( call : RuntimeCall ) -> TransactionValidity {
618+ let extension: TestExtension = RefundRelayerForMessagesFromParachain ( PhantomData ) ;
619+ extension. validate ( & relayer_account ( ) , & call, & DispatchInfo :: default ( ) , 0 )
620+ }
621+
614622 fn run_pre_dispatch (
615623 call : RuntimeCall ,
616624 ) -> Result < Option < PreDispatchData < millau_runtime:: AccountId > > , TransactionValidityError > {
@@ -654,19 +662,43 @@ mod tests {
654662 }
655663
656664 #[ test]
657- fn pre_dispatch_rejects_batch_with_obsolete_relay_chain_header ( ) {
665+ fn validate_allows_non_obsolete_transactions ( ) {
666+ run_test ( || {
667+ initialize_environment ( 100 , 100 , 100 ) ;
668+
669+ assert_eq ! ( run_validate( message_delivery_call( 200 ) ) , Ok ( ValidTransaction :: default ( ) ) , ) ;
670+
671+ assert_eq ! (
672+ run_validate( parachain_finality_and_delivery_batch_call( 200 , 200 ) ) ,
673+ Ok ( ValidTransaction :: default ( ) ) ,
674+ ) ;
675+
676+ assert_eq ! (
677+ run_validate( all_finality_and_delivery_batch_call( 200 , 200 , 200 ) ) ,
678+ Ok ( ValidTransaction :: default ( ) ) ,
679+ ) ;
680+ } ) ;
681+ }
682+
683+ #[ test]
684+ fn ext_rejects_batch_with_obsolete_relay_chain_header ( ) {
658685 run_test ( || {
659686 initialize_environment ( 100 , 100 , 100 ) ;
660687
661688 assert_eq ! (
662689 run_pre_dispatch( all_finality_and_delivery_batch_call( 100 , 200 , 200 ) ) ,
663690 Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
664691 ) ;
692+
693+ assert_eq ! (
694+ run_validate( all_finality_and_delivery_batch_call( 100 , 200 , 200 ) ) ,
695+ Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
696+ ) ;
665697 } ) ;
666698 }
667699
668700 #[ test]
669- fn pre_dispatch_rejects_batch_with_obsolete_parachain_head ( ) {
701+ fn ext_rejects_batch_with_obsolete_parachain_head ( ) {
670702 run_test ( || {
671703 initialize_environment ( 100 , 100 , 100 ) ;
672704
@@ -679,11 +711,21 @@ mod tests {
679711 run_pre_dispatch( parachain_finality_and_delivery_batch_call( 100 , 200 ) ) ,
680712 Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
681713 ) ;
714+
715+ assert_eq ! (
716+ run_validate( all_finality_and_delivery_batch_call( 101 , 100 , 200 ) ) ,
717+ Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
718+ ) ;
719+
720+ assert_eq ! (
721+ run_validate( parachain_finality_and_delivery_batch_call( 100 , 200 ) ) ,
722+ Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
723+ ) ;
682724 } ) ;
683725 }
684726
685727 #[ test]
686- fn pre_dispatch_rejects_batch_with_obsolete_messages ( ) {
728+ fn ext_rejects_batch_with_obsolete_messages ( ) {
687729 run_test ( || {
688730 initialize_environment ( 100 , 100 , 100 ) ;
689731
@@ -696,6 +738,16 @@ mod tests {
696738 run_pre_dispatch( parachain_finality_and_delivery_batch_call( 200 , 100 ) ) ,
697739 Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
698740 ) ;
741+
742+ assert_eq ! (
743+ run_validate( all_finality_and_delivery_batch_call( 200 , 200 , 100 ) ) ,
744+ Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
745+ ) ;
746+
747+ assert_eq ! (
748+ run_validate( parachain_finality_and_delivery_batch_call( 200 , 100 ) ) ,
749+ Err ( TransactionValidityError :: Invalid ( InvalidTransaction :: Stale ) ) ,
750+ ) ;
699751 } ) ;
700752 }
701753
0 commit comments