@@ -273,8 +273,19 @@ impl<T: Config> Pallet<T> {
273
273
query_id,
274
274
max_weight,
275
275
} ) ;
276
- // Prepend SetAppendix(Xcm(vec![ReportError])) wont be able to pass barrier check
277
- // so we need to insert it after Withdraw, BuyExecution
276
+ // Before insertion is:
277
+ // 0: WithdrawAsset
278
+ // 1: BuyExecution
279
+ // 2: Transact
280
+ // 3: RefundSurplus
281
+ // 4: DepositAsset
282
+ // After insertion is:
283
+ // 0: WithdrawAsset
284
+ // 1: BuyExecution
285
+ // 2: Transact
286
+ // 3: ReportError
287
+ // 4: RefundSurplus
288
+ // 5: DepositAsset
278
289
message. 0 . insert ( 3 , report_error) ;
279
290
Ok ( query_id)
280
291
}
@@ -288,9 +299,25 @@ impl<T: Config> Pallet<T> {
288
299
289
300
// Since xcm v3 doesn't support utility.batch_all
290
301
// instead, here append one more transact msg
291
- //
292
- // NOTE: index here is 3,
293
- // must append before 'report_outcome_notify' that index is 2
302
+
303
+ // A new bug occurred due to XCM version incompatible,
304
+ // here is a temp solutin which is ugly:
305
+ // ***`append_transact` MUST invoke after `report_outcome_notify`***
306
+ // Before insertion is:
307
+ // 0: WithdrawAsset
308
+ // 1: BuyExecution
309
+ // 2: Transact
310
+ // 3: ReportError
311
+ // 4: RefundSurplus
312
+ // 5: DepositAsset
313
+ // After insertion is:
314
+ // 0: WithdrawAsset
315
+ // 1: BuyExecution
316
+ // 2: Transact
317
+ // 3: Transact
318
+ // 4: ReportError
319
+ // 5: RefundSurplus
320
+ // 6: DepositAsset
294
321
pub fn append_transact ( message : & mut Xcm < ( ) > , call : DoubleEncoded < ( ) > , weight : Weight ) {
295
322
message. 0 . insert (
296
323
3 ,
@@ -516,6 +543,13 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
516
543
xcm_weight_fee_misc. fee,
517
544
) ?;
518
545
546
+ let query_id = Self :: report_outcome_notify(
547
+ & mut msg,
548
+ MultiLocation :: parent( ) ,
549
+ notify,
550
+ T :: NotifyTimeout :: get( ) ,
551
+ ) ?;
552
+
519
553
let call = RelaychainCall :: <T >:: Proxy ( Box :: new( ProxyCall :: Proxy ( ProxyProxyCall {
520
554
real,
521
555
force_proxy_type: None ,
@@ -529,13 +563,6 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
529
563
} ) ) ) ;
530
564
Self :: append_transact( & mut msg, call. encode( ) . into( ) , xcm_weight_fee_misc. weight) ;
531
565
532
- let query_id = Self :: report_outcome_notify(
533
- & mut msg,
534
- MultiLocation :: parent( ) ,
535
- notify,
536
- T :: NotifyTimeout :: get( ) ,
537
- ) ?;
538
-
539
566
if let Err ( _e) = send_xcm:: <T :: XcmSender >( MultiLocation :: parent( ) , msg) {
540
567
return Err ( Error :: <T >:: SendFailure . into( ) ) ;
541
568
}
@@ -566,6 +593,14 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
566
593
Self :: refund_location( ) ,
567
594
xcm_weight_fee_misc. fee,
568
595
) ?;
596
+
597
+ let query_id = Self :: report_outcome_notify(
598
+ & mut msg,
599
+ MultiLocation :: parent( ) ,
600
+ notify,
601
+ T :: NotifyTimeout :: get( ) ,
602
+ ) ?;
603
+
569
604
let call = RelaychainCall :: <T >:: Utility ( Box :: new( UtilityCall :: AsDerivative (
570
605
UtilityAsDerivativeCall {
571
606
index,
@@ -576,16 +611,8 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
576
611
} ) ) ,
577
612
} ,
578
613
) ) ) ;
579
-
580
614
Self :: append_transact( & mut msg, call. encode( ) . into( ) , xcm_weight_fee_misc. weight) ;
581
615
582
- let query_id = Self :: report_outcome_notify(
583
- & mut msg,
584
- MultiLocation :: parent( ) ,
585
- notify,
586
- T :: NotifyTimeout :: get( ) ,
587
- ) ?;
588
-
589
616
if let Err ( _err) = send_xcm:: <T :: XcmSender >( MultiLocation :: parent( ) , msg) {
590
617
return Err ( Error :: <T >:: SendFailure . into( ) ) ;
591
618
}
@@ -616,6 +643,13 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
616
643
xcm_weight_fee_misc. fee,
617
644
) ?;
618
645
646
+ let query_id = Self :: report_outcome_notify(
647
+ & mut msg,
648
+ MultiLocation :: parent( ) ,
649
+ notify,
650
+ T :: NotifyTimeout :: get( ) ,
651
+ ) ?;
652
+
619
653
let call = RelaychainCall :: <T >:: Utility ( Box :: new( UtilityCall :: AsDerivative (
620
654
UtilityAsDerivativeCall {
621
655
index,
@@ -626,13 +660,6 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
626
660
) ) ) ;
627
661
Self :: append_transact( & mut msg, call. encode( ) . into( ) , xcm_weight_fee_misc. weight) ;
628
662
629
- let query_id = Self :: report_outcome_notify(
630
- & mut msg,
631
- MultiLocation :: parent( ) ,
632
- notify,
633
- T :: NotifyTimeout :: get( ) ,
634
- ) ?;
635
-
636
663
if let Err ( _err) = send_xcm:: <T :: XcmSender >( MultiLocation :: parent( ) , msg) {
637
664
return Err ( Error :: <T >:: SendFailure . into( ) ) ;
638
665
}
@@ -741,6 +768,13 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
741
768
xcm_weight_fee_misc. fee,
742
769
) ?;
743
770
771
+ let query_id = Self :: report_outcome_notify(
772
+ & mut msg,
773
+ MultiLocation :: parent( ) ,
774
+ notify,
775
+ T :: NotifyTimeout :: get( ) ,
776
+ ) ?;
777
+
744
778
let call = RelaychainCall :: Utility ( Box :: new( UtilityCall :: AsDerivative (
745
779
UtilityAsDerivativeCall {
746
780
index,
@@ -754,13 +788,6 @@ impl<T: Config> XcmHelper<T, BalanceOf<T>, AccountIdOf<T>> for Pallet<T> {
754
788
) ) ) ;
755
789
Self :: append_transact( & mut msg, call. encode( ) . into( ) , xcm_weight_fee_misc. weight) ;
756
790
757
- let query_id = Self :: report_outcome_notify(
758
- & mut msg,
759
- MultiLocation :: parent( ) ,
760
- notify,
761
- T :: NotifyTimeout :: get( ) ,
762
- ) ?;
763
-
764
791
if let Err ( _err) = send_xcm:: <T :: XcmSender >( MultiLocation :: parent( ) , msg) {
765
792
return Err ( Error :: <T >:: SendFailure . into( ) ) ;
766
793
}
0 commit comments