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