Skip to content

Commit

Permalink
Fix: xcm notification error
Browse files Browse the repository at this point in the history
  • Loading branch information
mclyk committed Nov 13, 2023
1 parent 2614870 commit 25f7984
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 24 deletions.
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

0 comments on commit 25f7984

Please sign in to comment.