Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: xcm notification error #1950

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pallet-timestamp = { workspace = true }

# Polkadot dependencies
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-executor = { workspace = true }

# Frontier dependencies
fp-rpc = { workspace = true }
Expand Down
37 changes: 37 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,40 @@ pub use fp_rpc;
pub use fp_self_contained;
pub use pallet_evm_precompile_assets_erc20::AddressToAssetId;
pub use pallet_evm_precompile_balances_erc20::Erc20Metadata;

use frame_support::log;
use sp_std::{marker::PhantomData, result::Result};
use xcm::latest::{
Instruction::{self, *},
MultiLocation, Weight,
};
use xcm_executor::traits::{OnResponse, ShouldExecute};

/// TODO: Belowing code can be removed once upgrade to polkadot-v1.0.0
/// Copy from polkadot-v0.9.38
/// Polakdot-v1.0.0 have made changes of ShouldExecute
pub struct AllowKnownQueryResponses<ResponseHandler>(PhantomData<ResponseHandler>);
impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<ResponseHandler> {
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
instructions: &mut [Instruction<RuntimeCall>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ()> {
log::trace!(
target: "xcm::barriers",
"Parallel AllowKnownQueryResponses origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}",
origin, instructions, _max_weight, _weight_credit,
);
// ignore other instructions
// ensure!(instructions.len() == 1, ());
match instructions.first() {
Some(QueryResponse {
query_id, querier, ..
}) if ResponseHandler::expecting_response(origin, *query_id, querier.as_ref()) => {
Ok(())
}
_ => Err(()),
}
}
}
12 changes: 6 additions & 6 deletions runtime/heiko/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
AccountId32Aliases, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{traits::JustTry, Config, XcmExecutor};

Expand Down Expand Up @@ -116,7 +116,7 @@ use runtime_common::{
constants::{currency, fee, time},
fp_rpc, fp_self_contained,
precompiles::{ParallelPrecompiles, ASSET_PRECOMPILE_ADDRESS_PREFIX},
AddressToAssetId, Erc20Metadata,
AddressToAssetId, AllowKnownQueryResponses, Erc20Metadata,
};

use currency::*;
Expand Down
12 changes: 6 additions & 6 deletions runtime/kerria/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
AccountId32Aliases, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{traits::JustTry, Config, XcmExecutor};

Expand Down Expand Up @@ -116,7 +116,7 @@ use runtime_common::{
constants::{currency, fee, time},
fp_rpc, fp_self_contained,
precompiles::{ParallelPrecompiles, ASSET_PRECOMPILE_ADDRESS_PREFIX},
AddressToAssetId, Erc20Metadata,
AddressToAssetId, AllowKnownQueryResponses, Erc20Metadata,
};

use currency::*;
Expand Down
12 changes: 6 additions & 6 deletions runtime/parallel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
AccountId32Aliases, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{traits::JustTry, Config, XcmExecutor};

Expand Down Expand Up @@ -116,7 +116,7 @@ use runtime_common::{
constants::{currency, fee, time},
fp_rpc, fp_self_contained,
precompiles::{ParallelPrecompiles, ASSET_PRECOMPILE_ADDRESS_PREFIX},
AddressToAssetId, Erc20Metadata,
AddressToAssetId, AllowKnownQueryResponses, Erc20Metadata,
};

use currency::*;
Expand Down
12 changes: 6 additions & 6 deletions runtime/vanilla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds,
FungiblesAdapter, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
AccountId32Aliases, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit,
};
use xcm_executor::{traits::JustTry, Config, XcmExecutor};

Expand Down Expand Up @@ -116,7 +116,7 @@ use runtime_common::{
constants::{currency, fee, time},
fp_rpc, fp_self_contained,
precompiles::{ParallelPrecompiles, ASSET_PRECOMPILE_ADDRESS_PREFIX},
AddressToAssetId, Erc20Metadata,
AddressToAssetId, AllowKnownQueryResponses, Erc20Metadata,
};

use currency::*;
Expand Down