Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 699dd98

Browse files
committed
Merge branch 'master' into rk-availabilty-recovery-v2
* master: Fix Try-Runtime (#3725) XCM v2: Scripting, Query responses, Exception handling and Error reporting (#3629) Bump async-trait from 0.1.50 to 0.1.51 (#3721) allow some overhead in MERKLE_NODE_MAX_SIZE (#3724)
2 parents c82673e + 732348c commit 699dd98

File tree

52 files changed

+3096
-986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3096
-986
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/command.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,10 @@ pub fn run() -> Result<()> {
420420
if chain_spec.is_kusama() {
421421
return runner.async_run(|config| {
422422
Ok((
423-
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutor>(config)
424-
.map_err(Error::SubstrateCli),
423+
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutorDispatch>(
424+
config,
425+
)
426+
.map_err(Error::SubstrateCli),
425427
task_manager,
426428
))
427429
})
@@ -431,7 +433,7 @@ pub fn run() -> Result<()> {
431433
if chain_spec.is_westend() {
432434
return runner.async_run(|config| {
433435
Ok((
434-
cmd.run::<service::westend_runtime::Block, service::WestendExecutor>(
436+
cmd.run::<service::westend_runtime::Block, service::WestendExecutorDispatch>(
435437
config,
436438
)
437439
.map_err(Error::SubstrateCli),
@@ -442,8 +444,10 @@ pub fn run() -> Result<()> {
442444
// else we assume it is polkadot.
443445
runner.async_run(|config| {
444446
Ok((
445-
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutor>(config)
446-
.map_err(Error::SubstrateCli),
447+
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutorDispatch>(
448+
config,
449+
)
450+
.map_err(Error::SubstrateCli),
447451
task_manager,
448452
))
449453
})

node/core/candidate-validation/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
async-trait = "0.1.42"
8+
async-trait = "0.1.51"
99
futures = "0.3.15"
1010
tracing = "0.1.26"
1111

node/core/parachains-inherent/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ futures = "0.3.15"
99
futures-timer = "3.0.2"
1010
tracing = "0.1.26"
1111
thiserror = "1.0.26"
12-
async-trait = "0.1.47"
12+
async-trait = "0.1.51"
1313
polkadot-node-subsystem = { path = "../../subsystem" }
1414
polkadot-primitives = { path = "../../../primitives" }
1515
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }

node/malus/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ parity-util-mem = { version = "0.10.0", default-features = false, features = ["j
2626
color-eyre = { version = "0.5.11", default-features = false }
2727
assert_matches = "1.5"
2828
structopt = "0.3.21"
29-
async-trait = "0.1.50"
29+
async-trait = "0.1.51"

node/metrics/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
description = "Subsystem traits and message definitions"
77

88
[dependencies]
9-
async-trait = "0.1.42"
9+
async-trait = "0.1.51"
1010
futures = "0.3.15"
1111
futures-timer = "3.0.2"
1212

node/network/bridge/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
async-trait = "0.1.42"
8+
async-trait = "0.1.51"
99
futures = "0.3.15"
1010
tracing = "0.1.26"
1111
polkadot-primitives = { path = "../../../primitives" }

node/network/dispute-distribution/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ rand = "0.8.3"
2525
lru = "0.6.6"
2626

2727
[dev-dependencies]
28-
async-trait = "0.1.42"
28+
async-trait = "0.1.51"
2929
polkadot-subsystem-testhelpers = { package = "polkadot-node-subsystem-test-helpers", path = "../../subsystem-test-helpers" }
3030
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["std"] }
3131
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }

node/network/protocol/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
description = "Primitives types for the Node-side"
77

88
[dependencies]
9-
async-trait = "0.1.42"
9+
async-trait = "0.1.51"
1010
polkadot-primitives = { path = "../../../primitives" }
1111
polkadot-node-primitives = { path = "../../primitives" }
1212
polkadot-node-jaeger = { path = "../../jaeger" }

node/overseer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
async-trait = "0.1.42"
8+
async-trait = "0.1.51"
99
client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "master" }
1010
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
1111
futures = "0.3.15"

node/primitives/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ pub use disputes::{
5252
SignedDisputeStatement, UncheckedDisputeMessage, ValidDisputeVote,
5353
};
5454

55-
// For a 16-ary Merkle Prefix Trie, we can expect at most 16 32-byte hashes per node.
56-
const MERKLE_NODE_MAX_SIZE: usize = 512;
55+
// For a 16-ary Merkle Prefix Trie, we can expect at most 16 32-byte hashes per node
56+
// plus some overhead:
57+
// header 1 + bitmap 2 + max partial_key 8 + children 16 * (32 + len 1) + value 32 + value len 1
58+
const MERKLE_NODE_MAX_SIZE: usize = 512 + 100;
5759
// 16-ary Merkle Prefix Trie for 32-bit ValidatorIndex has depth at most 8.
5860
const MERKLE_PROOF_MAX_DEPTH: usize = 8;
5961

node/service/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ serde = { version = "1.0.123", features = ["derive"] }
6767
thiserror = "1.0.26"
6868
kvdb = "0.10.0"
6969
kvdb-rocksdb = { version = "0.14.0", optional = true }
70-
async-trait = "0.1.42"
70+
async-trait = "0.1.51"
7171

7272
# Polkadot
7373
polkadot-node-core-parachains-inherent = { path = "../core/parachains-inherent" }

node/subsystem-test-helpers/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
description = "Subsystem traits and message definitions"
77

88
[dependencies]
9-
async-trait = "0.1.42"
9+
async-trait = "0.1.51"
1010
futures = "0.3.15"
1111
futures-timer = "3.0.2"
1212
tracing = "0.1.26"

node/subsystem-types/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description = "Subsystem traits and message definitions"
77

88
[dependencies]
99
async-std = "1.8.0"
10-
async-trait = "0.1.42"
10+
async-trait = "0.1.51"
1111
derive_more = "0.99.11"
1212
futures = "0.3.12"
1313
futures-timer = "3.0.2"
@@ -32,6 +32,6 @@ log = "0.4.13"
3232

3333
[dev-dependencies]
3434
assert_matches = "1.4.0"
35-
async-trait = "0.1.42"
35+
async-trait = "0.1.51"
3636
futures = { version = "0.3.12", features = ["thread-pool"] }
3737
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }

node/subsystem-util/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66
description = "Subsystem traits and message definitions"
77

88
[dependencies]
9-
async-trait = "0.1.42"
9+
async-trait = "0.1.51"
1010
futures = "0.3.15"
1111
futures-timer = "3.0.2"
1212
itertools = "0.10"
@@ -36,7 +36,7 @@ substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate
3636

3737
[dev-dependencies]
3838
assert_matches = "1.4.0"
39-
async-trait = "0.1.42"
39+
async-trait = "0.1.51"
4040
env_logger = "0.9.0"
4141
futures = { version = "0.3.15", features = ["thread-pool"] }
4242
log = "0.4.13"

node/test/service/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl PolkadotTestNode {
276276
function: impl Into<polkadot_test_runtime::Call>,
277277
caller: Sr25519Keyring,
278278
) -> Result<RpcTransactionOutput, RpcTransactionError> {
279-
let extrinsic = construct_extrinsic(&*self.client, function, caller);
279+
let extrinsic = construct_extrinsic(&*self.client, function, caller, 0);
280280

281281
self.rpc_handlers.send_transaction(extrinsic.into()).await
282282
}
@@ -332,12 +332,12 @@ pub fn construct_extrinsic(
332332
client: &Client,
333333
function: impl Into<polkadot_test_runtime::Call>,
334334
caller: Sr25519Keyring,
335+
nonce: u32,
335336
) -> UncheckedExtrinsic {
336337
let function = function.into();
337338
let current_block_hash = client.info().best_hash;
338339
let current_block = client.info().best_number.saturated_into();
339340
let genesis_block = client.hash(0).unwrap().unwrap();
340-
let nonce = 0;
341341
let period =
342342
BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
343343
let tip = 0;
@@ -384,5 +384,5 @@ pub fn construct_transfer_extrinsic(
384384
value,
385385
));
386386

387-
construct_extrinsic(client, function, origin)
387+
construct_extrinsic(client, function, origin, 0)
388388
}

runtime/common/src/xcm_sender.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@
1919
use parity_scale_codec::Encode;
2020
use runtime_parachains::{configuration, dmp};
2121
use sp_std::marker::PhantomData;
22-
use xcm::opaque::latest::*;
22+
use xcm::latest::prelude::*;
2323

2424
/// XCM sender for relay chain. It only sends downward message.
2525
pub struct ChildParachainRouter<T, W>(PhantomData<(T, W)>);
2626

2727
impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion> SendXcm
2828
for ChildParachainRouter<T, W>
2929
{
30-
fn send_xcm(dest: MultiLocation, msg: Xcm) -> Result {
30+
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> SendResult {
3131
match dest {
32-
MultiLocation { parents: 0, interior: Junctions::X1(Junction::Parachain(id)) } => {
32+
MultiLocation { parents: 0, interior: X1(Parachain(id)) } => {
3333
// Downward message passing.
3434
let versioned_xcm =
35-
W::wrap_version(&dest, msg).map_err(|()| Error::DestinationUnsupported)?;
35+
W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
3636
let config = <configuration::Pallet<T>>::config();
3737
<dmp::Pallet<T>>::queue_downward_message(
3838
&config,
3939
id.into(),
4040
versioned_xcm.encode(),
4141
)
42-
.map_err(Into::<Error>::into)?;
42+
.map_err(Into::<SendError>::into)?;
4343
Ok(())
4444
},
45-
dest => Err(Error::CannotReachDestination(dest, msg)),
45+
dest => Err(SendError::CannotReachDestination(dest, msg)),
4646
}
4747
}
4848
}

runtime/kusama/src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,9 @@ type LocalOriginConverter = (
12551255
parameter_types! {
12561256
/// The amount of weight an XCM operation takes. This is a safe overestimate.
12571257
pub const BaseXcmWeight: Weight = 1_000_000_000;
1258+
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
1259+
/// calculations getting too crazy.
1260+
pub const MaxInstructions: u32 = 100;
12581261
}
12591262

12601263
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
@@ -1290,7 +1293,7 @@ impl xcm_executor::Config for XcmConfig {
12901293
type IsTeleporter = TrustedTeleporters;
12911294
type LocationInverter = LocationInverter<Ancestry>;
12921295
type Barrier = Barrier;
1293-
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
1296+
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
12941297
// The weight trader piggybacks on the existing transaction-fee conversion logic.
12951298
type Trader = UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToAuthor<Runtime>>;
12961299
type ResponseHandler = ();
@@ -1325,8 +1328,10 @@ impl pallet_xcm::Config for Runtime {
13251328
type XcmExecutor = XcmExecutor<XcmConfig>;
13261329
type XcmTeleportFilter = Everything;
13271330
type XcmReserveTransferFilter = Everything;
1328-
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
1331+
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
13291332
type LocationInverter = LocationInverter<Ancestry>;
1333+
type Origin = Origin;
1334+
type Call = Call;
13301335
}
13311336

13321337
parameter_types! {

runtime/parachains/src/dmp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use frame_support::pallet_prelude::*;
2222
use primitives::v1::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage};
2323
use sp_runtime::traits::{BlakeTwo256, Hash as HashT, SaturatedConversion};
2424
use sp_std::{fmt, prelude::*};
25-
use xcm::latest::Error as XcmError;
25+
use xcm::latest::SendError;
2626

2727
pub use pallet::*;
2828

@@ -33,10 +33,10 @@ pub enum QueueDownwardMessageError {
3333
ExceedsMaxMessageSize,
3434
}
3535

36-
impl From<QueueDownwardMessageError> for XcmError {
36+
impl From<QueueDownwardMessageError> for SendError {
3737
fn from(err: QueueDownwardMessageError) -> Self {
3838
match err {
39-
QueueDownwardMessageError::ExceedsMaxMessageSize => XcmError::ExceedsMaxMessageSize,
39+
QueueDownwardMessageError::ExceedsMaxMessageSize => SendError::ExceedsMaxMessageSize,
4040
}
4141
}
4242
}

runtime/parachains/src/hrmp.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1007,13 +1007,13 @@ impl<T: Config> Pallet<T> {
10071007

10081008
let notification_bytes = {
10091009
use parity_scale_codec::Encode as _;
1010-
use xcm::opaque::{v1::Xcm, VersionedXcm};
1010+
use xcm::opaque::{latest::prelude::*, VersionedXcm};
10111011

1012-
VersionedXcm::from(Xcm::HrmpNewChannelOpenRequest {
1012+
VersionedXcm::from(Xcm(vec![HrmpNewChannelOpenRequest {
10131013
sender: u32::from(origin),
10141014
max_capacity: proposed_max_capacity,
10151015
max_message_size: proposed_max_message_size,
1016-
})
1016+
}]))
10171017
.encode()
10181018
};
10191019
if let Err(dmp::QueueDownwardMessageError::ExceedsMaxMessageSize) =
@@ -1066,9 +1066,9 @@ impl<T: Config> Pallet<T> {
10661066

10671067
let notification_bytes = {
10681068
use parity_scale_codec::Encode as _;
1069-
use xcm::opaque::{v1::Xcm, VersionedXcm};
1070-
1071-
VersionedXcm::from(Xcm::HrmpChannelAccepted { recipient: u32::from(origin) }).encode()
1069+
use xcm::opaque::{latest::prelude::*, VersionedXcm};
1070+
let xcm = Xcm(vec![HrmpChannelAccepted { recipient: u32::from(origin) }]);
1071+
VersionedXcm::from(xcm).encode()
10721072
};
10731073
if let Err(dmp::QueueDownwardMessageError::ExceedsMaxMessageSize) =
10741074
<dmp::Pallet<T>>::queue_downward_message(&config, sender, notification_bytes)
@@ -1106,13 +1106,13 @@ impl<T: Config> Pallet<T> {
11061106
let config = <configuration::Pallet<T>>::config();
11071107
let notification_bytes = {
11081108
use parity_scale_codec::Encode as _;
1109-
use xcm::opaque::{v1::Xcm, VersionedXcm};
1109+
use xcm::opaque::{latest::prelude::*, VersionedXcm};
11101110

1111-
VersionedXcm::from(Xcm::HrmpChannelClosing {
1111+
VersionedXcm::from(Xcm(vec![HrmpChannelClosing {
11121112
initiator: u32::from(origin),
11131113
sender: u32::from(channel_id.sender),
11141114
recipient: u32::from(channel_id.recipient),
1115-
})
1115+
}]))
11161116
.encode()
11171117
};
11181118
let opposite_party =

runtime/rococo/src/lib.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ parameter_types! {
631631
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into());
632632
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into());
633633
pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1001).into());
634+
pub const MaxInstructions: u32 = 100;
634635
}
635636
pub type TrustedTeleporters = (
636637
xcm_builder::Case<RococoForTick>,
@@ -666,7 +667,7 @@ impl xcm_executor::Config for XcmConfig {
666667
type IsTeleporter = TrustedTeleporters;
667668
type LocationInverter = LocationInverter<Ancestry>;
668669
type Barrier = Barrier;
669-
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
670+
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
670671
type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
671672
type ResponseHandler = ();
672673
}
@@ -696,8 +697,10 @@ impl pallet_xcm::Config for Runtime {
696697
type XcmExecutor = XcmExecutor<XcmConfig>;
697698
type XcmTeleportFilter = Everything;
698699
type XcmReserveTransferFilter = Everything;
699-
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
700+
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
700701
type LocationInverter = LocationInverter<Ancestry>;
702+
type Origin = Origin;
703+
type Call = Call;
701704
}
702705

703706
impl parachains_session_info::Config for Runtime {}

0 commit comments

Comments
 (0)