From 738b23fe95a4d46e89170f880d1f92f1fb5e5322 Mon Sep 17 00:00:00 2001 From: MrPai <1164934857@qq.com> Date: Thu, 21 Mar 2024 11:02:38 +0800 Subject: [PATCH 1/3] Update lib.rs --- pallets/xcm-helper/src/lib.rs | 50 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/pallets/xcm-helper/src/lib.rs b/pallets/xcm-helper/src/lib.rs index 906f26bf5..85fff16ce 100644 --- a/pallets/xcm-helper/src/lib.rs +++ b/pallets/xcm-helper/src/lib.rs @@ -273,8 +273,19 @@ impl Pallet { query_id, max_weight, }); - // Prepend SetAppendix(Xcm(vec![ReportError])) wont be able to pass barrier check - // so we need to insert it after Withdraw, BuyExecution + // Before insertion is: + // 0: WithdrawAsset + // 1: BuyExecution + // 2: Transact + // 3: RefundSurplus + // 4: DepositAsset + // After insertion is: + // 0: WithdrawAsset + // 1: BuyExecution + // 2: Transact + // 3: ReportError + // 4: RefundSurplus + // 5: DepositAsset message.0.insert(3, report_error); Ok(query_id) } @@ -288,9 +299,25 @@ impl Pallet { // Since xcm v3 doesn't support utility.batch_all // instead, here append one more transact msg - // - // NOTE: index here is 3, - // must append before 'report_outcome_notify' that index is 2 + + // A new bug occured due to XCM version incompatiable, + // here is a temp solutin which is ugly: + // ***`append_transact` MUST invoke after `report_outcome_notify`*** + // Before insertion is: + // 0: WithdrawAsset + // 1: BuyExecution + // 2: Transact + // 3: ReportError + // 4: RefundSurplus + // 5: DepositAsset + // After insertion is: + // 0: WithdrawAsset + // 1: BuyExecution + // 2: Transact + // 3: Transact + // 4: ReportError + // 5: RefundSurplus + // 6: DepositAsset pub fn append_transact(message: &mut Xcm<()>, call: DoubleEncoded<()>, weight: Weight) { message.0.insert( 3, @@ -527,7 +554,6 @@ impl XcmHelper, AccountIdOf> for Pallet { }, )), }))); - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); let query_id = Self::report_outcome_notify( &mut msg, @@ -536,6 +562,8 @@ impl XcmHelper, AccountIdOf> for Pallet { T::NotifyTimeout::get(), )?; + Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); + if let Err(_e) = send_xcm::(MultiLocation::parent(), msg) { return Err(Error::::SendFailure.into()); } @@ -577,8 +605,6 @@ impl XcmHelper, AccountIdOf> for Pallet { }, ))); - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); - let query_id = Self::report_outcome_notify( &mut msg, MultiLocation::parent(), @@ -586,6 +612,8 @@ impl XcmHelper, AccountIdOf> for Pallet { T::NotifyTimeout::get(), )?; + Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); + if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { return Err(Error::::SendFailure.into()); } @@ -624,7 +652,6 @@ impl XcmHelper, AccountIdOf> for Pallet { )), }, ))); - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); let query_id = Self::report_outcome_notify( &mut msg, @@ -633,6 +660,8 @@ impl XcmHelper, AccountIdOf> for Pallet { T::NotifyTimeout::get(), )?; + Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); + if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { return Err(Error::::SendFailure.into()); } @@ -752,7 +781,6 @@ impl XcmHelper, AccountIdOf> for Pallet { )), }, ))); - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); let query_id = Self::report_outcome_notify( &mut msg, @@ -761,6 +789,8 @@ impl XcmHelper, AccountIdOf> for Pallet { T::NotifyTimeout::get(), )?; + Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); + if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { return Err(Error::::SendFailure.into()); } From 2482b8fac12b1990b1e2f286f77c750494620afe Mon Sep 17 00:00:00 2001 From: MrPai <1164934857@qq.com> Date: Thu, 21 Mar 2024 11:11:36 +0800 Subject: [PATCH 2/3] Update lib.rs --- pallets/xcm-helper/src/lib.rs | 61 +++++++++++++++++------------------ 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/pallets/xcm-helper/src/lib.rs b/pallets/xcm-helper/src/lib.rs index 85fff16ce..5ca4bab83 100644 --- a/pallets/xcm-helper/src/lib.rs +++ b/pallets/xcm-helper/src/lib.rs @@ -543,6 +543,13 @@ impl XcmHelper, AccountIdOf> for Pallet { xcm_weight_fee_misc.fee, )?; + let query_id = Self::report_outcome_notify( + &mut msg, + MultiLocation::parent(), + notify, + T::NotifyTimeout::get(), + )?; + let call = RelaychainCall::::Proxy(Box::new(ProxyCall::Proxy(ProxyProxyCall { real, force_proxy_type: None, @@ -554,14 +561,6 @@ impl XcmHelper, AccountIdOf> for Pallet { }, )), }))); - - let query_id = Self::report_outcome_notify( - &mut msg, - MultiLocation::parent(), - notify, - T::NotifyTimeout::get(), - )?; - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); if let Err(_e) = send_xcm::(MultiLocation::parent(), msg) { @@ -594,6 +593,14 @@ impl XcmHelper, AccountIdOf> for Pallet { Self::refund_location(), xcm_weight_fee_misc.fee, )?; + + let query_id = Self::report_outcome_notify( + &mut msg, + MultiLocation::parent(), + notify, + T::NotifyTimeout::get(), + )?; + let call = RelaychainCall::::Utility(Box::new(UtilityCall::AsDerivative( UtilityAsDerivativeCall { index, @@ -604,14 +611,6 @@ impl XcmHelper, AccountIdOf> for Pallet { })), }, ))); - - let query_id = Self::report_outcome_notify( - &mut msg, - MultiLocation::parent(), - notify, - T::NotifyTimeout::get(), - )?; - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { @@ -644,6 +643,13 @@ impl XcmHelper, AccountIdOf> for Pallet { xcm_weight_fee_misc.fee, )?; + let query_id = Self::report_outcome_notify( + &mut msg, + MultiLocation::parent(), + notify, + T::NotifyTimeout::get(), + )?; + let call = RelaychainCall::::Utility(Box::new(UtilityCall::AsDerivative( UtilityAsDerivativeCall { index, @@ -652,14 +658,6 @@ impl XcmHelper, AccountIdOf> for Pallet { )), }, ))); - - let query_id = Self::report_outcome_notify( - &mut msg, - MultiLocation::parent(), - notify, - T::NotifyTimeout::get(), - )?; - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { @@ -770,6 +768,13 @@ impl XcmHelper, AccountIdOf> for Pallet { xcm_weight_fee_misc.fee, )?; + let query_id = Self::report_outcome_notify( + &mut msg, + MultiLocation::parent(), + notify, + T::NotifyTimeout::get(), + )?; + let call = RelaychainCall::Utility(Box::new(UtilityCall::AsDerivative( UtilityAsDerivativeCall { index, @@ -781,14 +786,6 @@ impl XcmHelper, AccountIdOf> for Pallet { )), }, ))); - - let query_id = Self::report_outcome_notify( - &mut msg, - MultiLocation::parent(), - notify, - T::NotifyTimeout::get(), - )?; - Self::append_transact(&mut msg, call.encode().into(), xcm_weight_fee_misc.weight); if let Err(_err) = send_xcm::(MultiLocation::parent(), msg) { From e60ddc97ca3e1526720957858c942255fc5ad4e6 Mon Sep 17 00:00:00 2001 From: MrPai <1164934857@qq.com> Date: Thu, 21 Mar 2024 11:23:55 +0800 Subject: [PATCH 3/3] fix ci --- pallets/xcm-helper/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/xcm-helper/src/lib.rs b/pallets/xcm-helper/src/lib.rs index 5ca4bab83..bcd2e4190 100644 --- a/pallets/xcm-helper/src/lib.rs +++ b/pallets/xcm-helper/src/lib.rs @@ -300,7 +300,7 @@ impl Pallet { // Since xcm v3 doesn't support utility.batch_all // instead, here append one more transact msg - // A new bug occured due to XCM version incompatiable, + // A new bug occurred due to XCM version incompatible, // here is a temp solutin which is ugly: // ***`append_transact` MUST invoke after `report_outcome_notify`*** // Before insertion is: