Companion for polkadot#7234 (XCM: Tools for uniquely referencing messages) (#2601)

* Fixes for new API

* Formatting

* Fixes

* Fixes

* Further fixes

* XCMP dispatch events mention message ID

* XCMP event includes ID

* Add DMP message ID functionality

* Integrate into test parachains

* Remove WithUniqueTopic usage

* Use new primitive

* Formatting

* undiener

* Revert lock

* Fixes

* Fixes

* Fixes

* Fixes

* Formatting

* message_hash becomes message_id

* Rename

* Another Rename

* Fixes

* Fix

* Bump

* Fixes

* Grumble.
This commit is contained in:
Gavin Wood
2023-05-25 16:52:38 +01:00
committed by GitHub
parent febea66397
commit ec21c0a24d
23 changed files with 431 additions and 569 deletions
+68 -67
View File
@@ -1147,6 +1147,7 @@ dependencies = [
name = "bridge-hub-test-utils" name = "bridge-hub-test-utils"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"assert_matches",
"asset-test-utils", "asset-test-utils",
"bp-bridge-hub-rococo", "bp-bridge-hub-rococo",
"bp-bridge-hub-wococo", "bp-bridge-hub-wococo",
@@ -5158,7 +5159,7 @@ checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7"
[[package]] [[package]]
name = "kusama-runtime" name = "kusama-runtime"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"frame-benchmarking", "frame-benchmarking",
@@ -5257,7 +5258,7 @@ dependencies = [
[[package]] [[package]]
name = "kusama-runtime-constants" name = "kusama-runtime-constants"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"polkadot-primitives", "polkadot-primitives",
@@ -7938,7 +7939,7 @@ dependencies = [
[[package]] [[package]]
name = "pallet-xcm" name = "pallet-xcm"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bounded-collections", "bounded-collections",
"frame-benchmarking", "frame-benchmarking",
@@ -7959,7 +7960,7 @@ dependencies = [
[[package]] [[package]]
name = "pallet-xcm-benchmarks" name = "pallet-xcm-benchmarks"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-benchmarking", "frame-benchmarking",
"frame-support", "frame-support",
@@ -8576,7 +8577,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-approval-distribution" name = "polkadot-approval-distribution"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"polkadot-node-jaeger", "polkadot-node-jaeger",
@@ -8592,7 +8593,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-availability-bitfield-distribution" name = "polkadot-availability-bitfield-distribution"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"polkadot-node-network-protocol", "polkadot-node-network-protocol",
@@ -8606,7 +8607,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-availability-distribution" name = "polkadot-availability-distribution"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"derive_more", "derive_more",
"fatality", "fatality",
@@ -8629,7 +8630,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-availability-recovery" name = "polkadot-availability-recovery"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"fatality", "fatality",
"futures", "futures",
@@ -8650,7 +8651,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-cli" name = "polkadot-cli"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"clap", "clap",
"frame-benchmarking-cli", "frame-benchmarking-cli",
@@ -8679,7 +8680,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-client" name = "polkadot-client"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"frame-benchmarking", "frame-benchmarking",
@@ -8722,7 +8723,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-collator-protocol" name = "polkadot-collator-protocol"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"always-assert", "always-assert",
"bitvec", "bitvec",
@@ -8744,7 +8745,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-core-primitives" name = "polkadot-core-primitives"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
@@ -8756,7 +8757,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-dispute-distribution" name = "polkadot-dispute-distribution"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"derive_more", "derive_more",
"fatality", "fatality",
@@ -8781,7 +8782,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-erasure-coding" name = "polkadot-erasure-coding"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"polkadot-node-primitives", "polkadot-node-primitives",
@@ -8795,7 +8796,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-gossip-support" name = "polkadot-gossip-support"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"futures-timer", "futures-timer",
@@ -8815,7 +8816,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-network-bridge" name = "polkadot-network-bridge"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"always-assert", "always-assert",
"async-trait", "async-trait",
@@ -8838,7 +8839,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-collation-generation" name = "polkadot-node-collation-generation"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"parity-scale-codec", "parity-scale-codec",
@@ -8856,7 +8857,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-approval-voting" name = "polkadot-node-core-approval-voting"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"derive_more", "derive_more",
@@ -8885,7 +8886,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-av-store" name = "polkadot-node-core-av-store"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"futures", "futures",
@@ -8906,7 +8907,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-backing" name = "polkadot-node-core-backing"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"fatality", "fatality",
@@ -8925,7 +8926,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-bitfield-signing" name = "polkadot-node-core-bitfield-signing"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"polkadot-node-subsystem", "polkadot-node-subsystem",
@@ -8940,7 +8941,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-candidate-validation" name = "polkadot-node-core-candidate-validation"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
@@ -8960,7 +8961,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-chain-api" name = "polkadot-node-core-chain-api"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"polkadot-node-metrics", "polkadot-node-metrics",
@@ -8975,7 +8976,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-chain-selection" name = "polkadot-node-core-chain-selection"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"futures-timer", "futures-timer",
@@ -8992,7 +8993,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-dispute-coordinator" name = "polkadot-node-core-dispute-coordinator"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"fatality", "fatality",
"futures", "futures",
@@ -9011,7 +9012,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-parachains-inherent" name = "polkadot-node-core-parachains-inherent"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
@@ -9028,7 +9029,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-provisioner" name = "polkadot-node-core-provisioner"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"fatality", "fatality",
@@ -9046,7 +9047,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-pvf" name = "polkadot-node-core-pvf"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"always-assert", "always-assert",
"futures", "futures",
@@ -9073,7 +9074,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-pvf-checker" name = "polkadot-node-core-pvf-checker"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"polkadot-node-primitives", "polkadot-node-primitives",
@@ -9089,7 +9090,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-pvf-worker" name = "polkadot-node-core-pvf-worker"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"assert_matches", "assert_matches",
"cpu-time", "cpu-time",
@@ -9118,7 +9119,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-core-runtime-api" name = "polkadot-node-core-runtime-api"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"futures", "futures",
"lru 0.9.0", "lru 0.9.0",
@@ -9133,7 +9134,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-jaeger" name = "polkadot-node-jaeger"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"log", "log",
@@ -9151,7 +9152,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-metrics" name = "polkadot-node-metrics"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bs58", "bs58",
"futures", "futures",
@@ -9170,7 +9171,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-network-protocol" name = "polkadot-node-network-protocol"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-channel", "async-channel",
"async-trait", "async-trait",
@@ -9193,7 +9194,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-primitives" name = "polkadot-node-primitives"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bounded-vec", "bounded-vec",
"futures", "futures",
@@ -9215,7 +9216,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-subsystem" name = "polkadot-node-subsystem"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"polkadot-node-jaeger", "polkadot-node-jaeger",
"polkadot-node-subsystem-types", "polkadot-node-subsystem-types",
@@ -9225,7 +9226,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-subsystem-test-helpers" name = "polkadot-node-subsystem-test-helpers"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
@@ -9243,7 +9244,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-subsystem-types" name = "polkadot-node-subsystem-types"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"derive_more", "derive_more",
@@ -9266,7 +9267,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-node-subsystem-util" name = "polkadot-node-subsystem-util"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"derive_more", "derive_more",
@@ -9299,7 +9300,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-overseer" name = "polkadot-overseer"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures", "futures",
@@ -9322,7 +9323,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-parachain" name = "polkadot-parachain"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bounded-collections", "bounded-collections",
"derive_more", "derive_more",
@@ -9421,7 +9422,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-performance-test" name = "polkadot-performance-test"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"env_logger 0.9.0", "env_logger 0.9.0",
"kusama-runtime", "kusama-runtime",
@@ -9439,7 +9440,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-primitives" name = "polkadot-primitives"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"hex-literal 0.4.1", "hex-literal 0.4.1",
@@ -9465,7 +9466,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-rpc" name = "polkadot-rpc"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"jsonrpsee", "jsonrpsee",
"mmr-rpc", "mmr-rpc",
@@ -9497,7 +9498,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-runtime" name = "polkadot-runtime"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"frame-benchmarking", "frame-benchmarking",
@@ -9592,7 +9593,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-runtime-common" name = "polkadot-runtime-common"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"frame-benchmarking", "frame-benchmarking",
@@ -9638,7 +9639,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-runtime-constants" name = "polkadot-runtime-constants"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"polkadot-primitives", "polkadot-primitives",
@@ -9652,7 +9653,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-runtime-metrics" name = "polkadot-runtime-metrics"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bs58", "bs58",
"parity-scale-codec", "parity-scale-codec",
@@ -9664,7 +9665,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-runtime-parachains" name = "polkadot-runtime-parachains"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"bitvec", "bitvec",
@@ -9709,7 +9710,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-service" name = "polkadot-service"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"frame-benchmarking-cli", "frame-benchmarking-cli",
@@ -9819,7 +9820,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-statement-distribution" name = "polkadot-statement-distribution"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"arrayvec 0.5.2", "arrayvec 0.5.2",
"fatality", "fatality",
@@ -9840,7 +9841,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-statement-table" name = "polkadot-statement-table"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"polkadot-primitives", "polkadot-primitives",
@@ -9850,7 +9851,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-test-client" name = "polkadot-test-client"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"parity-scale-codec", "parity-scale-codec",
"polkadot-node-subsystem", "polkadot-node-subsystem",
@@ -9875,7 +9876,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-test-runtime" name = "polkadot-test-runtime"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"frame-election-provider-support", "frame-election-provider-support",
@@ -9936,7 +9937,7 @@ dependencies = [
[[package]] [[package]]
name = "polkadot-test-service" name = "polkadot-test-service"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-benchmarking", "frame-benchmarking",
"frame-system", "frame-system",
@@ -10716,7 +10717,7 @@ dependencies = [
[[package]] [[package]]
name = "rococo-runtime" name = "rococo-runtime"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"binary-merkle-tree", "binary-merkle-tree",
"frame-benchmarking", "frame-benchmarking",
@@ -10803,7 +10804,7 @@ dependencies = [
[[package]] [[package]]
name = "rococo-runtime-constants" name = "rococo-runtime-constants"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"polkadot-primitives", "polkadot-primitives",
@@ -12647,7 +12648,7 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec"
[[package]] [[package]]
name = "slot-range-helper" name = "slot-range-helper"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"enumn", "enumn",
"parity-scale-codec", "parity-scale-codec",
@@ -14064,7 +14065,7 @@ checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
[[package]] [[package]]
name = "test-runtime-constants" name = "test-runtime-constants"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"polkadot-primitives", "polkadot-primitives",
@@ -14455,7 +14456,7 @@ dependencies = [
[[package]] [[package]]
name = "tracing-gum" name = "tracing-gum"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"polkadot-node-jaeger", "polkadot-node-jaeger",
"polkadot-primitives", "polkadot-primitives",
@@ -14466,7 +14467,7 @@ dependencies = [
[[package]] [[package]]
name = "tracing-gum-proc-macro" name = "tracing-gum-proc-macro"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"expander 2.0.0", "expander 2.0.0",
"proc-macro-crate", "proc-macro-crate",
@@ -15544,7 +15545,7 @@ dependencies = [
[[package]] [[package]]
name = "westend-runtime" name = "westend-runtime"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bitvec", "bitvec",
"frame-benchmarking", "frame-benchmarking",
@@ -15637,7 +15638,7 @@ dependencies = [
[[package]] [[package]]
name = "westend-runtime-constants" name = "westend-runtime-constants"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"polkadot-primitives", "polkadot-primitives",
@@ -16140,7 +16141,7 @@ dependencies = [
[[package]] [[package]]
name = "xcm" name = "xcm"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"bounded-collections", "bounded-collections",
"derivative", "derivative",
@@ -16156,7 +16157,7 @@ dependencies = [
[[package]] [[package]]
name = "xcm-builder" name = "xcm-builder"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"frame-support", "frame-support",
"frame-system", "frame-system",
@@ -16211,7 +16212,7 @@ dependencies = [
[[package]] [[package]]
name = "xcm-executor" name = "xcm-executor"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"environmental", "environmental",
"frame-benchmarking", "frame-benchmarking",
@@ -16231,7 +16232,7 @@ dependencies = [
[[package]] [[package]]
name = "xcm-procedural" name = "xcm-procedural"
version = "0.9.41" version = "0.9.41"
source = "git+https://github.com/paritytech/polkadot?branch=master#039d81563097c03935a519c5de6f3b0f8d8abc15" source = "git+https://github.com/paritytech/polkadot?branch=master#df3e3c7ca7a61044a5c543aa87c070688f1c11f3"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"proc-macro2", "proc-macro2",
+1
View File
@@ -71,3 +71,4 @@ opt-level = 3
inherits = "release" inherits = "release"
lto = true lto = true
codegen-units = 1 codegen-units = 1
+81 -87
View File
@@ -75,7 +75,7 @@ pub struct PageIndexData {
/// Simple type used to identify messages for the purpose of reporting events. Secure if and only /// Simple type used to identify messages for the purpose of reporting events. Secure if and only
/// if the message content is unique. /// if the message content is unique.
pub type MessageId = [u8; 32]; pub type MessageId = XcmHash;
/// Index used to identify overweight messages. /// Index used to identify overweight messages.
pub type OverweightIndex = u64; pub type OverweightIndex = u64;
@@ -174,23 +174,39 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// Downward message is invalid XCM. /// Downward message is invalid XCM.
InvalidFormat { message_id: MessageId }, InvalidFormat { message_hash: XcmHash },
/// Downward message is unsupported version of XCM. /// Downward message is unsupported version of XCM.
UnsupportedVersion { message_id: MessageId }, UnsupportedVersion { message_hash: XcmHash },
/// Downward message executed with the given outcome. /// Downward message executed with the given outcome.
ExecutedDownward { message_id: MessageId, outcome: Outcome }, ExecutedDownward { message_hash: XcmHash, message_id: XcmHash, outcome: Outcome },
/// The weight limit for handling downward messages was reached. /// The weight limit for handling downward messages was reached.
WeightExhausted { message_id: MessageId, remaining_weight: Weight, required_weight: Weight }, WeightExhausted {
message_hash: XcmHash,
message_id: XcmHash,
remaining_weight: Weight,
required_weight: Weight,
},
/// Downward message is overweight and was placed in the overweight queue. /// Downward message is overweight and was placed in the overweight queue.
OverweightEnqueued { OverweightEnqueued {
message_id: MessageId, message_hash: XcmHash,
message_id: XcmHash,
overweight_index: OverweightIndex, overweight_index: OverweightIndex,
required_weight: Weight, required_weight: Weight,
}, },
/// Downward message from the overweight queue was executed. /// Downward message from the overweight queue was executed.
OverweightServiced { overweight_index: OverweightIndex, weight_used: Weight }, OverweightServiced { overweight_index: OverweightIndex, weight_used: Weight },
/// The maximum number of downward messages was. /// The maximum number of downward messages was reached.
MaxMessagesExhausted { message_id: MessageId }, MaxMessagesExhausted { message_hash: XcmHash },
}
/// Error type when a message was failed to be serviced.
pub(crate) struct ServiceMessageError {
/// The message's hash.
message_hash: XcmHash,
/// The message's ID (which could also be its hash if nothing overrides it).
message_id: XcmHash,
/// Weight required for the message to be executed.
required_weight: Weight,
} }
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
@@ -250,8 +266,9 @@ pub mod pallet {
limit: Weight, limit: Weight,
_sent_at: RelayBlockNumber, _sent_at: RelayBlockNumber,
mut data: &[u8], mut data: &[u8],
) -> Result<Weight, (MessageId, Weight)> { ) -> Result<Weight, ServiceMessageError> {
let message_id = sp_io::hashing::blake2_256(data); let message_hash = sp_io::hashing::blake2_256(data);
let mut message_id = message_hash;
let maybe_msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit( let maybe_msg = VersionedXcm::<T::RuntimeCall>::decode_all_with_depth_limit(
MAX_XCM_DECODE_DEPTH, MAX_XCM_DECODE_DEPTH,
&mut data, &mut data,
@@ -259,21 +276,31 @@ pub mod pallet {
.map(Xcm::<T::RuntimeCall>::try_from); .map(Xcm::<T::RuntimeCall>::try_from);
match maybe_msg { match maybe_msg {
Err(_) => { Err(_) => {
Self::deposit_event(Event::InvalidFormat { message_id }); Self::deposit_event(Event::InvalidFormat { message_hash });
Ok(Weight::zero()) Ok(Weight::zero())
}, },
Ok(Err(())) => { Ok(Err(())) => {
Self::deposit_event(Event::UnsupportedVersion { message_id }); Self::deposit_event(Event::UnsupportedVersion { message_hash });
Ok(Weight::zero()) Ok(Weight::zero())
}, },
Ok(Ok(x)) => { Ok(Ok(x)) => {
let outcome = T::XcmExecutor::execute_xcm(Parent, x, message_id, limit); let outcome = T::XcmExecutor::prepare_and_execute(
Parent,
x,
&mut message_id,
limit,
Weight::zero(),
);
match outcome { match outcome {
Outcome::Error(XcmError::WeightLimitReached(required)) => Outcome::Error(XcmError::WeightLimitReached(required_weight)) =>
Err((message_id, required)), Err(ServiceMessageError { message_hash, message_id, required_weight }),
outcome => { outcome => {
let weight_used = outcome.weight_used(); let weight_used = outcome.weight_used();
Self::deposit_event(Event::ExecutedDownward { message_id, outcome }); Self::deposit_event(Event::ExecutedDownward {
message_hash,
message_id,
outcome,
});
Ok(weight_used) Ok(weight_used)
}, },
} }
@@ -314,7 +341,7 @@ pub mod pallet {
maybe_enqueue_page = Some(Vec::with_capacity(item_count_left)); maybe_enqueue_page = Some(Vec::with_capacity(item_count_left));
Self::deposit_event(Event::MaxMessagesExhausted { Self::deposit_event(Event::MaxMessagesExhausted {
message_id: sp_io::hashing::blake2_256(&data), message_hash: sp_io::hashing::blake2_256(&data),
}); });
} else { } else {
// We're not currently enqueuing - try to execute inline. // We're not currently enqueuing - try to execute inline.
@@ -322,7 +349,11 @@ pub mod pallet {
messages_processed += 1; messages_processed += 1;
match Self::try_service_message(remaining_weight, sent_at, &data[..]) { match Self::try_service_message(remaining_weight, sent_at, &data[..]) {
Ok(consumed) => used += consumed, Ok(consumed) => used += consumed,
Err((message_id, required_weight)) => Err(ServiceMessageError {
message_hash,
message_id,
required_weight,
}) =>
// Too much weight required right now. // Too much weight required right now.
{ {
let is_under_limit = let is_under_limit =
@@ -334,6 +365,7 @@ pub mod pallet {
let overweight_index = page_index.overweight_count; let overweight_index = page_index.overweight_count;
Overweight::<T>::insert(overweight_index, (sent_at, data)); Overweight::<T>::insert(overweight_index, (sent_at, data));
Self::deposit_event(Event::OverweightEnqueued { Self::deposit_event(Event::OverweightEnqueued {
message_hash,
message_id, message_id,
overweight_index, overweight_index,
required_weight, required_weight,
@@ -348,6 +380,7 @@ pub mod pallet {
let item_count_left = item_count.saturating_sub(i); let item_count_left = item_count.saturating_sub(i);
maybe_enqueue_page = Some(Vec::with_capacity(item_count_left)); maybe_enqueue_page = Some(Vec::with_capacity(item_count_left));
Self::deposit_event(Event::WeightExhausted { Self::deposit_event(Event::WeightExhausted {
message_hash,
message_id, message_id,
remaining_weight, remaining_weight,
required_weight, required_weight,
@@ -466,50 +499,36 @@ mod tests {
}) })
} }
pub enum Weightless {} pub struct MockPrepared(Xcm);
impl PreparedMessage for Weightless { impl PreparedMessage for MockPrepared {
fn weight_of(&self) -> Weight { fn weight_of(&self) -> Weight {
unreachable!() match ((self.0).0.len(), &(self.0).0.first()) {
(1, Some(Transact { require_weight_at_most, .. })) => *require_weight_at_most,
_ => Weight::from_parts(1, 1),
}
} }
} }
pub struct MockExec; pub struct MockExec;
impl ExecuteXcm<RuntimeCall> for MockExec { impl ExecuteXcm<RuntimeCall> for MockExec {
type Prepared = Weightless; type Prepared = MockPrepared;
fn prepare(_message: Xcm) -> Result<Self::Prepared, Xcm> { fn prepare(message: Xcm) -> Result<Self::Prepared, Xcm> {
unreachable!() Ok(MockPrepared(message))
} }
fn execute( fn execute(
_origin: impl Into<MultiLocation>, _origin: impl Into<MultiLocation>,
_pre: Weightless, prepared: MockPrepared,
_hash: XcmHash, _id: &mut XcmHash,
_weight_credit: Weight,
) -> Outcome {
unreachable!()
}
fn execute_xcm_in_credit(
_origin: impl Into<MultiLocation>,
message: Xcm,
_hash: XcmHash,
weight_limit: Weight,
_weight_credit: Weight, _weight_credit: Weight,
) -> Outcome { ) -> Outcome {
let message = prepared.0;
let o = match (message.0.len(), &message.0.first()) { let o = match (message.0.len(), &message.0.first()) {
(1, Some(Transact { require_weight_at_most, .. })) => { (1, Some(Transact { require_weight_at_most, .. })) =>
if require_weight_at_most.all_lte(weight_limit) { Outcome::Complete(*require_weight_at_most),
Outcome::Complete(*require_weight_at_most)
} else {
Outcome::Error(XcmError::WeightLimitReached(*require_weight_at_most))
}
},
// use 1000 to decide that it's not supported. // use 1000 to decide that it's not supported.
_ => Outcome::Incomplete( _ => Outcome::Incomplete(Weight::from_parts(1, 1), XcmError::Unimplemented),
Weight::from_parts(1000, 1000).min(weight_limit),
XcmError::Unimplemented,
),
}; };
TRACE.with(|q| q.borrow_mut().push((message, o.clone()))); TRACE.with(|q| q.borrow_mut().push((message, o.clone())));
o o
@@ -564,13 +583,6 @@ mod tests {
(msg(weight), Outcome::Complete(Weight::from_parts(weight, weight))) (msg(weight), Outcome::Complete(Weight::from_parts(weight, weight)))
} }
fn msg_limit_reached(weight: u64) -> (Xcm, Outcome) {
(
msg(weight),
Outcome::Error(XcmError::WeightLimitReached(Weight::from_parts(weight, weight))),
)
}
fn pages_queued() -> PageCounter { fn pages_queued() -> PageCounter {
PageIndex::<Test>::get().end_used - PageIndex::<Test>::get().begin_used PageIndex::<Test>::get().end_used - PageIndex::<Test>::get().begin_used
} }
@@ -613,10 +625,7 @@ mod tests {
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::from_parts(2001, 2001)); assert_eq!(weight_used, Weight::from_parts(2001, 2001));
assert_eq!( assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001),]);
take_trace(),
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
);
}); });
} }
@@ -631,18 +640,15 @@ mod tests {
PageIndexData { begin_used: 0, end_used: 1, overweight_count: 0 } PageIndexData { begin_used: 0, end_used: 1, overweight_count: 0 }
); );
assert_eq!(Pages::<Test>::get(0).len(), 3); assert_eq!(Pages::<Test>::get(0).len(), 3);
assert_eq!(take_trace(), vec![msg_limit_reached(1000)]); assert_eq!(take_trace(), vec![]);
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::from_parts(2001, 2001)); assert_eq!(weight_used, Weight::from_parts(2001, 2001));
assert_eq!( assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001)]);
take_trace(),
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
);
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::from_parts(1002, 1002)); assert_eq!(weight_used, Weight::from_parts(1002, 1002));
assert_eq!(take_trace(), vec![msg_complete(1002),]); assert_eq!(take_trace(), vec![msg_complete(1002)]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -655,7 +661,7 @@ mod tests {
assert_eq!(weight_used, Weight::from_parts(1000, 1000)); assert_eq!(weight_used, Weight::from_parts(1000, 1000));
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
assert_eq!(Pages::<Test>::get(0).len(), 2); assert_eq!(Pages::<Test>::get(0).len(), 2);
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]); assert_eq!(take_trace(), vec![msg_complete(1000)]);
let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&[], Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::from_parts(2003, 2003)); assert_eq!(weight_used, Weight::from_parts(2003, 2003));
@@ -693,13 +699,13 @@ mod tests {
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000)); let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
assert_eq!(weight_used, Weight::from_parts(1000, 1000)); assert_eq!(weight_used, Weight::from_parts(1000, 1000));
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(10001),]); assert_eq!(take_trace(), vec![msg_complete(1000)]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
// 5000 is not enough to process the 10001 blocker, so nothing happens. // 5000 is not enough to process the 10001 blocker, so nothing happens.
let weight_used = handle_messages(&[], Weight::from_parts(5000, 5000)); let weight_used = handle_messages(&[], Weight::from_parts(5000, 5000));
assert_eq!(weight_used, Weight::zero()); assert_eq!(weight_used, Weight::zero());
assert_eq!(take_trace(), vec![msg_limit_reached(10001),]); assert_eq!(take_trace(), vec![]);
// 20000 is now enough to process everything. // 20000 is now enough to process everything.
let weight_used = handle_messages(&[], Weight::from_parts(20000, 20000)); let weight_used = handle_messages(&[], Weight::from_parts(20000, 20000));
@@ -720,10 +726,7 @@ mod tests {
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000)); let weight_used = handle_messages(&incoming, Weight::from_parts(5000, 5000));
assert_eq!(weight_used, Weight::from_parts(2001, 2001)); assert_eq!(weight_used, Weight::from_parts(2001, 2001));
assert_eq!( assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001)]);
take_trace(),
vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(10002),]
);
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
// 20000 is now enough to process everything. // 20000 is now enough to process everything.
@@ -744,12 +747,7 @@ mod tests {
assert_eq!(weight_used, Weight::from_parts(3003, 3003)); assert_eq!(weight_used, Weight::from_parts(3003, 3003));
assert_eq!( assert_eq!(
take_trace(), take_trace(),
vec![ vec![msg_complete(1000), msg_complete(1001), msg_complete(1002),]
msg_complete(1000),
msg_complete(1001),
msg_complete(1002),
msg_limit_reached(10003),
]
); );
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
@@ -768,19 +766,19 @@ mod tests {
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500)); let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1000, 1000)); assert_eq!(weight_used, Weight::from_parts(1000, 1000));
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]); assert_eq!(take_trace(), vec![msg_complete(1000)]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 0); assert_eq!(PageIndex::<Test>::get().begin_used, 0);
let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500)); let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1001, 1001)); assert_eq!(weight_used, Weight::from_parts(1001, 1001));
assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]); assert_eq!(take_trace(), vec![msg_complete(1001)]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 1); assert_eq!(PageIndex::<Test>::get().begin_used, 1);
let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500)); let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500));
assert_eq!(weight_used, Weight::from_parts(1002, 1002)); assert_eq!(weight_used, Weight::from_parts(1002, 1002));
assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]); assert_eq!(take_trace(), vec![msg_complete(1002)]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 2); assert_eq!(PageIndex::<Test>::get().begin_used, 2);
}); });
@@ -798,10 +796,7 @@ mod tests {
let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::from_parts(2002, 2002)); assert_eq!(weight_used, Weight::from_parts(2002, 2002));
assert!(queue_is_empty()); assert!(queue_is_empty());
assert_eq!( assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1002),]);
take_trace(),
vec![msg_complete(1000), msg_limit_reached(10001), msg_complete(1002),]
);
assert_eq!(overweights(), vec![0]); assert_eq!(overweights(), vec![0]);
}); });
@@ -818,7 +813,7 @@ mod tests {
let incoming = vec![msg(10000)]; let incoming = vec![msg(10000)];
let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500)); let weight_used = handle_messages(&incoming, Weight::from_parts(2500, 2500));
assert_eq!(weight_used, Weight::zero()); assert_eq!(weight_used, Weight::zero());
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]); assert_eq!(take_trace(), vec![]);
assert_eq!(overweights(), vec![0]); assert_eq!(overweights(), vec![0]);
assert_noop!( assert_noop!(
@@ -845,7 +840,7 @@ mod tests {
), ),
Error::<Test>::OverLimit Error::<Test>::OverLimit
); );
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]); assert_eq!(take_trace(), vec![]);
let base_weight = let base_weight =
super::Call::<Test>::service_overweight { index: 0, weight_limit: Weight::zero() } super::Call::<Test>::service_overweight { index: 0, weight_limit: Weight::zero() }
@@ -891,7 +886,6 @@ mod tests {
msg_complete(1002), msg_complete(1002),
msg_complete(1003), msg_complete(1003),
msg_complete(1004), msg_complete(1004),
msg_limit_reached(1005),
] ]
); );
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
+24 -18
View File
@@ -282,15 +282,15 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// Some XCM was executed ok. /// Some XCM was executed ok.
Success { message_hash: Option<XcmHash>, weight: Weight }, Success { message_hash: XcmHash, message_id: XcmHash, weight: Weight },
/// Some XCM failed. /// Some XCM failed.
Fail { message_hash: Option<XcmHash>, error: XcmError, weight: Weight }, Fail { message_hash: XcmHash, message_id: XcmHash, error: XcmError, weight: Weight },
/// Bad XCM version used. /// Bad XCM version used.
BadVersion { message_hash: Option<XcmHash> }, BadVersion { message_hash: XcmHash },
/// Bad XCM format used. /// Bad XCM format used.
BadFormat { message_hash: Option<XcmHash> }, BadFormat { message_hash: XcmHash },
/// An HRMP message was sent to a sibling parachain. /// An HRMP message was sent to a sibling parachain.
XcmpMessageSent { message_hash: Option<XcmHash> }, XcmpMessageSent { message_hash: XcmHash },
/// An XCM exceeded the individual message weight budget. /// An XCM exceeded the individual message weight budget.
OverweightEnqueued { OverweightEnqueued {
sender: ParaId, sender: ParaId,
@@ -619,27 +619,33 @@ impl<T: Config> Pallet<T> {
xcm: VersionedXcm<T::RuntimeCall>, xcm: VersionedXcm<T::RuntimeCall>,
max_weight: Weight, max_weight: Weight,
) -> Result<Weight, XcmError> { ) -> Result<Weight, XcmError> {
let hash = xcm.using_encoded(sp_io::hashing::blake2_256); let message_hash = xcm.using_encoded(sp_io::hashing::blake2_256);
log::debug!("Processing XCMP-XCM: {:?}", &hash); log::debug!("Processing XCMP-XCM: {:?}", &message_hash);
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) { let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
Ok(xcm) => { Ok(xcm) => {
let location = (Parent, Parachain(sender.into())); let location = (Parent, Parachain(sender.into()));
let mut message_id = message_hash;
match T::XcmExecutor::execute_xcm(location, xcm, hash, max_weight) { match T::XcmExecutor::prepare_and_execute(
Outcome::Error(e) => ( location,
Err(e), xcm,
Event::Fail { message_hash: Some(hash), error: e, weight: Weight::zero() }, &mut message_id,
max_weight,
Weight::zero(),
) {
Outcome::Error(error) => (
Err(error),
Event::Fail { message_hash, message_id, error, weight: Weight::zero() },
), ),
Outcome::Complete(w) => Outcome::Complete(weight) =>
(Ok(w), Event::Success { message_hash: Some(hash), weight: w }), (Ok(weight), Event::Success { message_hash, message_id, weight }),
// As far as the caller is concerned, this was dispatched without error, so // As far as the caller is concerned, this was dispatched without error, so
// we just report the weight used. // we just report the weight used.
Outcome::Incomplete(w, e) => Outcome::Incomplete(weight, error) =>
(Ok(w), Event::Fail { message_hash: Some(hash), error: e, weight: w }), (Ok(weight), Event::Fail { message_hash, message_id, error, weight }),
} }
}, },
Err(()) => Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash }),
(Err(XcmError::UnhandledXcmVersion), Event::BadVersion { message_hash: Some(hash) }),
}; };
Self::deposit_event(event); Self::deposit_event(event);
result result
@@ -1183,7 +1189,7 @@ impl<T: Config> SendXcm for Pallet<T> {
match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) { match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) {
Ok(_) => { Ok(_) => {
Self::deposit_event(Event::XcmpMessageSent { message_hash: Some(hash) }); Self::deposit_event(Event::XcmpMessageSent { message_hash: hash });
Ok(hash) Ok(hash)
}, },
Err(e) => Err(SendError::Transport(<&'static str>::from(e))), Err(e) => Err(SendError::Transport(<&'static str>::from(e))),
@@ -2,10 +2,9 @@ use super::{
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
}; };
use core::{marker::PhantomData, ops::ControlFlow};
use frame_support::{ use frame_support::{
log, match_types, parameter_types, match_types, parameter_types,
traits::{ConstU32, Everything, Nothing, ProcessMessageError}, traits::{ConstU32, Everything, Nothing},
weights::Weight, weights::Weight,
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
@@ -15,12 +14,13 @@ use polkadot_runtime_common::impls::ToAuthor;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
CreateMatcher, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, MatchXcm, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin,
NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::ShouldExecute, XcmExecutor}; use xcm_executor::XcmExecutor;
parameter_types! { parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayLocation: MultiLocation = MultiLocation::parent();
@@ -90,75 +90,8 @@ match_types! {
}; };
} }
//TODO: move DenyThenTry to polkadot's xcm module. pub type Barrier = TrailingSetTopicAsId<
/// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else. DenyThenTry<
/// If it passes the Deny, and matches one of the Allow cases then it is let through.
pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
where
Deny: ShouldExecute,
Allow: ShouldExecute;
impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>
where
Deny: ShouldExecute,
Allow: ShouldExecute,
{
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ProcessMessageError> {
Deny::should_execute(origin, message, max_weight, weight_credit)?;
Allow::should_execute(origin, message, max_weight, weight_credit)
}
}
// See issue <https://github.com/paritytech/polkadot/issues/5233>
pub struct DenyReserveTransferToRelayChain;
impl ShouldExecute for DenyReserveTransferToRelayChain {
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut [Instruction<RuntimeCall>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ProcessMessageError> {
message.matcher().match_next_inst_while(
|_| true,
|inst| match inst {
InitiateReserveWithdraw {
reserve: MultiLocation { parents: 1, interior: Here },
..
} |
DepositReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} |
TransferReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} => {
Err(ProcessMessageError::Unsupported) // Deny
},
// An unexpected reserve transfer has arrived from the Relay Chain. Generally,
// `IsReserve` should not allow this, but we just log it here.
ReserveAssetDeposited { .. }
if matches!(origin, MultiLocation { parents: 1, interior: Here }) =>
{
log::warn!(
target: "xcm::barrier",
"Unexpected ReserveAssetDeposited from the Relay Chain",
);
Ok(ControlFlow::Continue(()))
},
_ => Ok(ControlFlow::Continue(())),
},
)?;
// Permit everything else
Ok(())
}
}
pub type Barrier = DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
TakeWeightCredit, TakeWeightCredit,
@@ -172,6 +105,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -208,12 +142,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
+2 -76
View File
@@ -1,86 +1,12 @@
use crate::impls::AccountIdOf; use crate::impls::AccountIdOf;
use core::{marker::PhantomData, ops::ControlFlow}; use core::marker::PhantomData;
use frame_support::{ use frame_support::{
log, log,
traits::{ traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair},
fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair, ProcessMessageError,
},
weights::Weight, weights::Weight,
}; };
use sp_runtime::traits::Get; use sp_runtime::traits::Get;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{CreateMatcher, MatchXcm};
use xcm_executor::traits::ShouldExecute;
//TODO: move DenyThenTry to polkadot's xcm module.
/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else.
/// If it passes the Deny, and matches one of the Allow cases then it is let through.
pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
where
Deny: ShouldExecute,
Allow: ShouldExecute;
impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>
where
Deny: ShouldExecute,
Allow: ShouldExecute,
{
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
weight_credit: &mut Weight,
) -> Result<(), ProcessMessageError> {
Deny::should_execute(origin, message, max_weight, weight_credit)?;
Allow::should_execute(origin, message, max_weight, weight_credit)
}
}
// See issue <https://github.com/paritytech/polkadot/issues/5233>
pub struct DenyReserveTransferToRelayChain;
impl ShouldExecute for DenyReserveTransferToRelayChain {
fn should_execute<RuntimeCall>(
origin: &MultiLocation,
message: &mut [Instruction<RuntimeCall>],
_max_weight: Weight,
_weight_credit: &mut Weight,
) -> Result<(), ProcessMessageError> {
message.matcher().match_next_inst_while(
|_| true,
|inst| match inst {
InitiateReserveWithdraw {
reserve: MultiLocation { parents: 1, interior: Here },
..
} |
DepositReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} |
TransferReserveAsset {
dest: MultiLocation { parents: 1, interior: Here }, ..
} => {
Err(ProcessMessageError::Unsupported) // Deny
},
// An unexpected reserve transfer has arrived from the Relay Chain. Generally,
// `IsReserve` should not allow this, but we just log it here.
ReserveAssetDeposited { .. }
if matches!(origin, MultiLocation { parents: 1, interior: Here }) =>
{
log::warn!(
target: "xcm::barrier",
"Unexpected ReserveAssetDeposited from the Relay Chain",
);
Ok(ControlFlow::Continue(()))
},
_ => Ok(ControlFlow::Continue(())),
},
)?;
// Permit everything else
Ok(())
}
}
/// A `ChargeFeeInFungibles` implementation that converts the output of /// A `ChargeFeeInFungibles` implementation that converts the output of
/// a given WeightToFee implementation an amount charged in /// a given WeightToFee implementation an amount charged in
@@ -32,7 +32,7 @@ fn reserve_transfer_native_asset_from_relay_to_assets() {
assert_expected_events!( assert_expected_events!(
Kusama, Kusama,
vec![ vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted(Outcome::Complete(weight))) => { RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => {
weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(754_244_000, 0), *weight), weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(754_244_000, 0), *weight),
}, },
] ]
@@ -32,7 +32,9 @@ fn teleport_native_assets_from_relay_to_assets_para() {
assert_expected_events!( assert_expected_events!(
Kusama, Kusama,
vec![ vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted(Outcome::Complete { .. })) => {}, RuntimeEvent::XcmPallet(
pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }
) => {},
] ]
); );
}); });
@@ -32,7 +32,7 @@ fn reserve_transfer_native_asset_from_relay_to_assets() {
assert_expected_events!( assert_expected_events!(
Polkadot, Polkadot,
vec![ vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted(Outcome::Complete(weight))) => { RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => {
weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(2_000_000_000, 0), *weight), weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(2_000_000_000, 0), *weight),
}, },
] ]
@@ -32,7 +32,7 @@ fn teleport_native_assets_from_relay_to_assets_para() {
assert_expected_events!( assert_expected_events!(
Polkadot, Polkadot,
vec![ vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted(Outcome::Complete { .. })) => {}, RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }) => {},
] ]
); );
}); });
@@ -27,22 +27,18 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
impls::ToStakingPot,
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry,
},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto; use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
UsingComponents, WeightInfoBounds, WithComputedOrigin, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -341,7 +337,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
TakeWeightCredit, TakeWeightCredit,
@@ -361,6 +358,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier<
@@ -429,12 +427,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -27,22 +27,18 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
impls::ToStakingPot,
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry,
},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto; use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
UsingComponents, WeightInfoBounds, WithComputedOrigin, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WeightInfoBounds, WithComputedOrigin,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -28,22 +28,18 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
impls::ToStakingPot,
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry,
},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto; use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
UsingComponents, WeightInfoBounds, WithComputedOrigin, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -342,7 +338,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
TakeWeightCredit, TakeWeightCredit,
@@ -362,6 +359,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier<
@@ -429,12 +427,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -24,19 +24,16 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
WithComputedOrigin, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -154,7 +151,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
// Allow local users to buy weight credit. // Allow local users to buy weight credit.
@@ -174,6 +172,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -217,12 +216,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -24,19 +24,16 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
WithComputedOrigin, UsingComponents, WeightInfoBounds, WithComputedOrigin,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -30,20 +30,18 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use sp_core::Get; use sp_core::Get;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom,
CurrencyAdapter, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, ParentIsPreset, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
UsingComponents, WeightInfoBounds, WithComputedOrigin, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{ use xcm_executor::{
traits::{ExportXcm, WithOriginFilter}, traits::{ExportXcm, WithOriginFilter},
@@ -197,7 +195,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
} }
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
// Allow local users to buy weight credit. // Allow local users to buy weight credit.
@@ -220,6 +219,7 @@ pub type Barrier = DenyThenTry<
// remove this and extend `AllowExplicitUnpaidExecutionFrom` with "or SystemParachains" once merged https://github.com/paritytech/polkadot/pull/7005 // remove this and extend `AllowExplicitUnpaidExecutionFrom` with "or SystemParachains" once merged https://github.com/paritytech/polkadot/pull/7005
AllowUnpaidExecutionFrom<Everything>, AllowUnpaidExecutionFrom<Everything>,
), ),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -263,12 +263,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -8,6 +8,7 @@ description = "Utils for BridgeHub testing"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
assert_matches = "1.4.0"
# Substrate # Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
@@ -16,6 +16,7 @@
//! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities. //! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities.
use assert_matches::assert_matches;
use bp_messages::{ use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch, SourceHeaderChain}, target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch, SourceHeaderChain},
LaneId, MessageKey, OutboundLaneData, Weight, LaneId, MessageKey, OutboundLaneData, Weight,
@@ -462,7 +463,7 @@ pub fn relayed_incoming_message_works<Runtime, XcmConfig, HrmpChannelOpener, GPI
let relayer_id_on_source: AccountId32 = relayer_at_source.public().into(); let relayer_id_on_source: AccountId32 = relayer_at_source.public().into();
let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42]; let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42];
let expected_dispatch = xcm::VersionedXcm::<()>::V3(xcm.clone().into()); let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone());
// generate bridged relay chain finality, parachain heads and message proofs, // generate bridged relay chain finality, parachain heads and message proofs,
// to be submitted by relayer to this chain. // to be submitted by relayer to this chain.
let ( let (
@@ -559,6 +560,9 @@ pub fn relayed_incoming_message_works<Runtime, XcmConfig, HrmpChannelOpener, GPI
sibling_parachain_id.into(), sibling_parachain_id.into(),
) )
.unwrap(); .unwrap();
let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap();
// We use `WithUniqueTopic`, so expect a trailing `SetTopic`.
assert_matches!(dispatched.0.pop(), Some(SetTopic(..)));
assert_eq!(dispatched, expected_dispatch); assert_eq!(dispatched, expected_dispatch);
}) })
} }
@@ -667,8 +671,8 @@ pub fn complex_relay_extrinsic_works<Runtime, XcmConfig, HrmpChannelOpener, GPI,
let para_header_number = 5; let para_header_number = 5;
let relay_header_number = 1; let relay_header_number = 1;
let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42]; let xcm = vec![xcm::latest::Instruction::<()>::ClearOrigin; 42];
let expected_dispatch = xcm::VersionedXcm::<()>::V3(xcm.clone().into()); let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone());
// generate bridged relay chain finality, parachain heads and message proofs, // generate bridged relay chain finality, parachain heads and message proofs,
// to be submitted by relayer to this chain. // to be submitted by relayer to this chain.
let ( let (
@@ -776,6 +780,9 @@ pub fn complex_relay_extrinsic_works<Runtime, XcmConfig, HrmpChannelOpener, GPI,
sibling_parachain_id.into(), sibling_parachain_id.into(),
) )
.unwrap(); .unwrap();
let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap();
// We use `WithUniqueTopic`, so expect a trailing `SetTopic`.
assert_matches!(dispatched.0.pop(), Some(SetTopic(..)));
assert_eq!(dispatched, expected_dispatch); assert_eq!(dispatched, expected_dispatch);
}) })
} }
@@ -24,19 +24,17 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::{ use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry},
};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
FixedWeightBounds, IsConcrete, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
UsingComponents, WithComputedOrigin, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
}; };
use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
@@ -24,16 +24,16 @@ use frame_support::{
}; };
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
UsingComponents, WithComputedOrigin, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::XcmExecutor; use xcm_executor::XcmExecutor;
@@ -118,7 +118,8 @@ match_types! {
}; };
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
TakeWeightCredit, TakeWeightCredit,
@@ -138,6 +139,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
pub struct XcmConfig; pub struct XcmConfig;
@@ -173,12 +175,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
@@ -258,7 +258,7 @@ impl<XcmConfig: xcm_executor::Config> RuntimeHelper<XcmConfig> {
&to, &to,
// We aren't able to track the XCM that initiated the fee deposit, so we create a // We aren't able to track the XCM that initiated the fee deposit, so we create a
// fake message hash here // fake message hash here
&XcmContext::with_message_hash([0; 32]), &XcmContext::with_message_id([0; 32]),
) )
} }
} }
@@ -344,7 +344,7 @@ impl<Runtime: frame_system::Config + pallet_xcm::Config> RuntimeHelper<Runtime>
.into_iter() .into_iter()
.filter_map(|e| unwrap_pallet_xcm_event(e.event.encode())) .filter_map(|e| unwrap_pallet_xcm_event(e.event.encode()))
.find_map(|e| match e { .find_map(|e| match e {
pallet_xcm::Event::Attempted(outcome) => Some(outcome), pallet_xcm::Event::Attempted { outcome } => Some(outcome),
_ => None, _ => None,
}) })
.expect("No `pallet_xcm::Event::Attempted(outcome)` event found!"); .expect("No `pallet_xcm::Event::Attempted(outcome)` event found!");
@@ -363,7 +363,8 @@ impl<Runtime: frame_system::Config + cumulus_pallet_xcmp_queue::Config> RuntimeH
.into_iter() .into_iter()
.filter_map(|e| unwrap_xcmp_queue_event(e.event.encode())) .filter_map(|e| unwrap_xcmp_queue_event(e.event.encode()))
.find_map(|e| match e { .find_map(|e| match e {
cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => message_hash, cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash } =>
Some(message_hash),
_ => None, _ => None,
}) })
} }
@@ -38,7 +38,6 @@ use frame_support::{
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_asset_tx_payment::HandleCredit; use pallet_asset_tx_payment::HandleCredit;
use pallet_xcm::XcmPassthrough; use pallet_xcm::XcmPassthrough;
use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry};
use polkadot_parachain::primitives::Sibling; use polkadot_parachain::primitives::Sibling;
use polkadot_runtime_common::impls::ToAuthor; use polkadot_runtime_common::impls::ToAuthor;
use sp_runtime::traits::Zero; use sp_runtime::traits::Zero;
@@ -46,11 +45,11 @@ use xcm::latest::prelude::*;
use xcm_builder::{ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, ConvertedConcreteId, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry,
IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
WithComputedOrigin, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
}; };
use xcm_executor::{traits::JustTry, XcmExecutor}; use xcm_executor::{traits::JustTry, XcmExecutor};
@@ -150,7 +149,8 @@ match_types! {
}; };
} }
pub type Barrier = DenyThenTry< pub type Barrier = TrailingSetTopicAsId<
DenyThenTry<
DenyReserveTransferToRelayChain, DenyReserveTransferToRelayChain,
( (
TakeWeightCredit, TakeWeightCredit,
@@ -173,6 +173,7 @@ pub type Barrier = DenyThenTry<
ConstU32<8>, ConstU32<8>,
>, >,
), ),
>,
>; >;
/// Type alias to conveniently refer to `frame_system`'s `Config::AccountId`. /// Type alias to conveniently refer to `frame_system`'s `Config::AccountId`.
@@ -299,12 +300,12 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// The means for routing XCM messages which are not for local execution into the right message /// The means for routing XCM messages which are not for local execution into the right message
/// queues. /// queues.
pub type XcmRouter = ( pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain: // Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>, cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains. // ..and XCMP to communicate with the sibling chains.
XcmpQueue, XcmpQueue,
); )>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
parameter_types! { parameter_types! {
+1 -1
View File
@@ -288,7 +288,7 @@ impl<
&(X1(AccountId32 { network: None, id: receiver.into() }).into()), &(X1(AccountId32 { network: None, id: receiver.into() }).into()),
// We aren't able to track the XCM that initiated the fee deposit, so we create a // We aren't able to track the XCM that initiated the fee deposit, so we create a
// fake message hash here // fake message hash here
&XcmContext::with_message_hash([0; 32]), &XcmContext::with_message_id([0; 32]),
) )
.is_ok(); .is_ok();