From 98286ade0b5e8edf1521078c454404c7afaab438 Mon Sep 17 00:00:00 2001
From: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
Date: Mon, 9 Oct 2023 22:39:12 +0200
Subject: [PATCH 001/524] Fix Asset Hub collator crashing when starting from
genesis (#1788)
---
cumulus/polkadot-parachain/src/command.rs | 6 +-
cumulus/polkadot-parachain/src/service.rs | 155 +++++++++++++++++++++-
2 files changed, 154 insertions(+), 7 deletions(-)
diff --git a/cumulus/polkadot-parachain/src/command.rs b/cumulus/polkadot-parachain/src/command.rs
index 0e948d24f82..c47555a3216 100644
--- a/cumulus/polkadot-parachain/src/command.rs
+++ b/cumulus/polkadot-parachain/src/command.rs
@@ -836,21 +836,21 @@ pub fn run() -> Result<()> {
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
match config.chain_spec.runtime() {
- Runtime::AssetHubPolkadot => crate::service::start_generic_aura_node::<
+ Runtime::AssetHubPolkadot => crate::service::start_asset_hub_node::<
asset_hub_polkadot_runtime::RuntimeApi,
AssetHubPolkadotAuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
- Runtime::AssetHubKusama => crate::service::start_generic_aura_node::<
+ Runtime::AssetHubKusama => crate::service::start_asset_hub_node::<
asset_hub_kusama_runtime::RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
.await
.map(|r| r.0)
.map_err(Into::into),
- Runtime::AssetHubWestend => crate::service::start_generic_aura_node::<
+ Runtime::AssetHubWestend => crate::service::start_asset_hub_node::<
asset_hub_westend_runtime::RuntimeApi,
AuraId,
>(config, polkadot_config, collator_options, id, hwbench)
diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs
index 2f86f54f12a..fa61f534784 100644
--- a/cumulus/polkadot-parachain/src/service.rs
+++ b/cumulus/polkadot-parachain/src/service.rs
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see .
-use codec::Codec;
+use codec::{Codec, Decode};
use cumulus_client_cli::CollatorOptions;
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_aura::collators::{
@@ -44,7 +44,7 @@ use crate::rpc;
pub use parachains_common::{AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce};
use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier;
-use futures::lock::Mutex;
+use futures::{lock::Mutex, prelude::*};
use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams, ImportQueue,
@@ -54,10 +54,14 @@ use sc_network::{config::FullNetworkConfiguration, NetworkBlock};
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
-use sp_api::{ApiExt, ConstructRuntimeApi};
+use sp_api::{ApiExt, ConstructRuntimeApi, ProvideRuntimeApi};
use sp_consensus_aura::AuraApi;
+use sp_core::traits::SpawnEssentialNamed;
use sp_keystore::KeystorePtr;
-use sp_runtime::{app_crypto::AppCrypto, traits::Header as HeaderT};
+use sp_runtime::{
+ app_crypto::AppCrypto,
+ traits::{Block as BlockT, Header as HeaderT},
+};
use std::{marker::PhantomData, sync::Arc, time::Duration};
use substrate_prometheus_endpoint::Registry;
@@ -1389,6 +1393,149 @@ where
.await
}
+/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub
+/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and
+/// needs to sync and upgrade before it can run `AuraApi` functions.
+pub async fn start_asset_hub_node(
+ parachain_config: Configuration,
+ polkadot_config: Configuration,
+ collator_options: CollatorOptions,
+ para_id: ParaId,
+ hwbench: Option,
+) -> sc_service::error::Result<(TaskManager, Arc>)>
+where
+ RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static,
+ RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue
+ + sp_api::Metadata
+ + sp_session::SessionKeys
+ + sp_api::ApiExt
+ + sp_offchain::OffchainWorkerApi
+ + sp_block_builder::BlockBuilder
+ + cumulus_primitives_core::CollectCollationInfo
+ + sp_consensus_aura::AuraApi::Pair as Pair>::Public>
+ + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi
+ + frame_rpc_system::AccountNonceApi,
+ <::Pair as Pair>::Signature:
+ TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec,
+{
+ start_node_impl::(
+ parachain_config,
+ polkadot_config,
+ collator_options,
+ CollatorSybilResistance::Resistant, // Aura
+ para_id,
+ |_| Ok(RpcModule::new(())),
+ aura_build_import_queue::<_, AuraId>,
+ |client,
+ block_import,
+ prometheus_registry,
+ telemetry,
+ task_manager,
+ relay_chain_interface,
+ transaction_pool,
+ sync_oracle,
+ keystore,
+ relay_chain_slot_duration,
+ para_id,
+ collator_key,
+ overseer_handle,
+ announce_block| {
+ let relay_chain_interface2 = relay_chain_interface.clone();
+
+ let collator_service = CollatorService::new(
+ client.clone(),
+ Arc::new(task_manager.spawn_handle()),
+ announce_block,
+ client.clone(),
+ );
+
+ let spawner = task_manager.spawn_handle();
+
+ let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
+ spawner,
+ client.clone(),
+ transaction_pool,
+ prometheus_registry,
+ telemetry.clone(),
+ );
+
+ let collation_future = Box::pin(async move {
+ // Start collating with the `shell` runtime while waiting for an upgrade to an Aura
+ // compatible runtime.
+ let mut request_stream = cumulus_client_collator::relay_chain_driven::init(
+ collator_key.clone(),
+ para_id,
+ overseer_handle.clone(),
+ )
+ .await;
+ while let Some(request) = request_stream.next().await {
+ let pvd = request.persisted_validation_data().clone();
+ let last_head_hash =
+ match ::Header::decode(&mut &pvd.parent_head.0[..]) {
+ Ok(header) => header.hash(),
+ Err(e) => {
+ log::error!("Could not decode the head data: {e}");
+ request.complete(None);
+ continue
+ },
+ };
+
+ // Check if we have upgraded to an Aura compatible runtime and transition if
+ // necessary.
+ if client
+ .runtime_api()
+ .has_api::>(last_head_hash)
+ .unwrap_or(false)
+ {
+ // Respond to this request before transitioning to Aura.
+ request.complete(None);
+ break
+ }
+ }
+
+ // Move to Aura consensus.
+ let slot_duration = match cumulus_client_consensus_aura::slot_duration(&*client) {
+ Ok(d) => d,
+ Err(e) => {
+ log::error!("Could not get Aura slot duration: {e}");
+ return
+ },
+ };
+
+ let proposer = Proposer::new(proposer_factory);
+
+ let params = BasicAuraParams {
+ create_inherent_data_providers: move |_, ()| async move { Ok(()) },
+ block_import,
+ para_client: client,
+ relay_client: relay_chain_interface2,
+ sync_oracle,
+ keystore,
+ collator_key,
+ para_id,
+ overseer_handle,
+ slot_duration,
+ relay_chain_slot_duration,
+ proposer,
+ collator_service,
+ // Very limited proposal time.
+ authoring_duration: Duration::from_millis(500),
+ };
+
+ basic_aura::run::::Pair, _, _, _, _, _, _, _>(params)
+ .await
+ });
+
+ let spawner = task_manager.spawn_essential_handle();
+ spawner.spawn_essential("cumulus-asset-hub-collator", None, collation_future);
+
+ Ok(())
+ },
+ hwbench,
+ )
+ .await
+}
+
/// Start an aura powered parachain node which uses the lookahead collator to support async backing.
/// This node is basic in the sense that its runtime api doesn't include common contents such as
/// transaction payment. Used for aura glutton.
--
GitLab
From 93d9c8c24e5d470e036caaa23df08dcf0c527dd6 Mon Sep 17 00:00:00 2001
From: David Emett
Date: Tue, 10 Oct 2023 09:14:56 +0200
Subject: [PATCH 002/524] Make CheckNonce refuse transactions signed by
accounts with no providers (#1578)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
See #1453.
Co-authored-by: Bastian Köcher
---
.../node/executor/tests/submit_transaction.rs | 2 +-
.../client/service/test/src/client/mod.rs | 25 +++------
.../system/src/extensions/check_nonce.rs | 56 ++++++++++++++++++-
3 files changed, 62 insertions(+), 21 deletions(-)
diff --git a/substrate/bin/node/executor/tests/submit_transaction.rs b/substrate/bin/node/executor/tests/submit_transaction.rs
index 7678a3c6e5a..5cbb0103d47 100644
--- a/substrate/bin/node/executor/tests/submit_transaction.rs
+++ b/substrate/bin/node/executor/tests/submit_transaction.rs
@@ -239,7 +239,7 @@ fn submitted_transaction_should_be_valid() {
let author = extrinsic.signature.clone().unwrap().0;
let address = Indices::lookup(author).unwrap();
let data = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
- let account = frame_system::AccountInfo { data, ..Default::default() };
+ let account = frame_system::AccountInfo { providers: 1, data, ..Default::default() };
>::insert(&address, account);
// check validity
diff --git a/substrate/client/service/test/src/client/mod.rs b/substrate/client/service/test/src/client/mod.rs
index c40ac33da4b..f8200875587 100644
--- a/substrate/client/service/test/src/client/mod.rs
+++ b/substrate/client/service/test/src/client/mod.rs
@@ -39,7 +39,6 @@ use sp_runtime::{
};
use sp_state_machine::{backend::Backend as _, InMemoryBackend, OverlayedChanges, StateMachine};
use sp_storage::{ChildInfo, StorageKey};
-use sp_trie::{LayoutV0, TrieConfiguration};
use std::{collections::HashSet, sync::Arc};
use substrate_test_runtime::TestAPI;
use substrate_test_runtime_client::{
@@ -62,22 +61,17 @@ fn construct_block(
backend: &InMemoryBackend,
number: BlockNumber,
parent_hash: Hash,
- state_root: Hash,
txs: Vec,
-) -> (Vec, Hash) {
+) -> Vec {
let transactions = txs.into_iter().map(|tx| tx.into_unchecked_extrinsic()).collect::>();
- let iter = transactions.iter().map(Encode::encode);
- let extrinsics_root = LayoutV0::::ordered_trie_root(iter).into();
-
let mut header = Header {
parent_hash,
number,
- state_root,
- extrinsics_root,
+ state_root: Default::default(),
+ extrinsics_root: Default::default(),
digest: Digest { logs: vec![] },
};
- let hash = header.hash();
let mut overlay = OverlayedChanges::default();
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
@@ -124,19 +118,16 @@ fn construct_block(
.unwrap();
header = Header::decode(&mut &ret_data[..]).unwrap();
- (vec![].and(&Block { header, extrinsics: transactions }), hash)
+ vec![].and(&Block { header, extrinsics: transactions })
}
-fn block1(genesis_hash: Hash, backend: &InMemoryBackend) -> (Vec, Hash) {
+fn block1(genesis_hash: Hash, backend: &InMemoryBackend) -> Vec {
construct_block(
backend,
1,
genesis_hash,
- array_bytes::hex_n_into_unchecked(
- "25e5b37074063ab75c889326246640729b40d0c86932edc527bc80db0e04fe5c",
- ),
vec![Transfer {
- from: AccountKeyring::Alice.into(),
+ from: AccountKeyring::One.into(),
to: AccountKeyring::Two.into(),
amount: 69 * DOLLARS,
nonce: 0,
@@ -175,7 +166,7 @@ fn construct_genesis_should_work_with_native() {
let genesis_hash = insert_genesis_block(&mut storage);
let backend = InMemoryBackend::from((storage, StateVersion::default()));
- let (b1data, _b1hash) = block1(genesis_hash, &backend);
+ let b1data = block1(genesis_hash, &backend);
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
@@ -206,7 +197,7 @@ fn construct_genesis_should_work_with_wasm() {
let genesis_hash = insert_genesis_block(&mut storage);
let backend = InMemoryBackend::from((storage, StateVersion::default()));
- let (b1data, _b1hash) = block1(genesis_hash, &backend);
+ let b1data = block1(genesis_hash, &backend);
let backend_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&backend);
let runtime_code = backend_runtime_code.runtime_code().expect("Code is part of the backend");
diff --git a/substrate/frame/system/src/extensions/check_nonce.rs b/substrate/frame/system/src/extensions/check_nonce.rs
index 2939fd6534c..7504a814aef 100644
--- a/substrate/frame/system/src/extensions/check_nonce.rs
+++ b/substrate/frame/system/src/extensions/check_nonce.rs
@@ -20,7 +20,7 @@ use codec::{Decode, Encode};
use frame_support::dispatch::DispatchInfo;
use scale_info::TypeInfo;
use sp_runtime::{
- traits::{DispatchInfoOf, Dispatchable, One, SignedExtension},
+ traits::{DispatchInfoOf, Dispatchable, One, SignedExtension, Zero},
transaction_validity::{
InvalidTransaction, TransactionLongevity, TransactionValidity, TransactionValidityError,
ValidTransaction,
@@ -80,6 +80,10 @@ where
_len: usize,
) -> Result<(), TransactionValidityError> {
let mut account = crate::Account::::get(who);
+ if account.providers.is_zero() && account.sufficients.is_zero() {
+ // Nonce storage not paid for
+ return Err(InvalidTransaction::Payment.into())
+ }
if self.0 != account.nonce {
return Err(if self.0 < account.nonce {
InvalidTransaction::Stale
@@ -100,8 +104,11 @@ where
_info: &DispatchInfoOf,
_len: usize,
) -> TransactionValidity {
- // check index
let account = crate::Account::::get(who);
+ if account.providers.is_zero() && account.sufficients.is_zero() {
+ // Nonce storage not paid for
+ return InvalidTransaction::Payment.into()
+ }
if self.0 < account.nonce {
return InvalidTransaction::Stale.into()
}
@@ -137,7 +144,7 @@ mod tests {
crate::AccountInfo {
nonce: 1,
consumers: 0,
- providers: 0,
+ providers: 1,
sufficients: 0,
data: 0,
},
@@ -164,4 +171,47 @@ mod tests {
);
})
}
+
+ #[test]
+ fn signed_ext_check_nonce_requires_provider() {
+ new_test_ext().execute_with(|| {
+ crate::Account::::insert(
+ 2,
+ crate::AccountInfo {
+ nonce: 1,
+ consumers: 0,
+ providers: 1,
+ sufficients: 0,
+ data: 0,
+ },
+ );
+ crate::Account::::insert(
+ 3,
+ crate::AccountInfo {
+ nonce: 1,
+ consumers: 0,
+ providers: 0,
+ sufficients: 1,
+ data: 0,
+ },
+ );
+ let info = DispatchInfo::default();
+ let len = 0_usize;
+ // Both providers and sufficients zero
+ assert_noop!(
+ CheckNonce::(1).validate(&1, CALL, &info, len),
+ InvalidTransaction::Payment
+ );
+ assert_noop!(
+ CheckNonce::(1).pre_dispatch(&1, CALL, &info, len),
+ InvalidTransaction::Payment
+ );
+ // Non-zero providers
+ assert_ok!(CheckNonce::(1).validate(&2, CALL, &info, len));
+ assert_ok!(CheckNonce::(1).pre_dispatch(&2, CALL, &info, len));
+ // Non-zero sufficients
+ assert_ok!(CheckNonce::(1).validate(&3, CALL, &info, len));
+ assert_ok!(CheckNonce::(1).pre_dispatch(&3, CALL, &info, len));
+ })
+ }
}
--
GitLab
From 2b4b33d01f22b1f4037a404597357f398e21224f Mon Sep 17 00:00:00 2001
From: Rahul Subramaniyam <78006270+rahulksnv@users.noreply.github.com>
Date: Tue, 10 Oct 2023 02:46:23 -0700
Subject: [PATCH 003/524] Check for parent of first ready block being on chain
(#1812)
When retrieving the ready blocks, verify that the parent of the first
ready block is on chain. If the parent is not on chain, we are
downloading from a fork. In this case, keep downloading until we have a
parent on chain (common ancestor).
Resolves https://github.com/paritytech/polkadot-sdk/issues/493.
---------
Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com>
---
substrate/client/network/sync/src/blocks.rs | 25 ++
substrate/client/network/sync/src/lib.rs | 397 +++++++++++++++++++-
2 files changed, 421 insertions(+), 1 deletion(-)
diff --git a/substrate/client/network/sync/src/blocks.rs b/substrate/client/network/sync/src/blocks.rs
index 240c1ca1f8b..cad50fef3e3 100644
--- a/substrate/client/network/sync/src/blocks.rs
+++ b/substrate/client/network/sync/src/blocks.rs
@@ -212,6 +212,31 @@ impl BlockCollection {
ready
}
+ /// Returns the block header of the first block that is ready for importing.
+ /// `from` is the maximum block number for the start of the range that we are interested in.
+ /// The function will return None if the first block ready is higher than `from`.
+ /// The logic is structured to be consistent with ready_blocks().
+ pub fn first_ready_block_header(&self, from: NumberFor) -> Option {
+ let mut prev = from;
+ for (&start, range_data) in &self.blocks {
+ if start > prev {
+ break
+ }
+
+ match range_data {
+ BlockRangeState::Complete(blocks) => {
+ let len = (blocks.len() as u32).into();
+ prev = start + len;
+ if let Some(BlockData { block, .. }) = blocks.first() {
+ return block.header.clone()
+ }
+ },
+ _ => continue,
+ }
+ }
+ None
+ }
+
pub fn clear_queued(&mut self, hash: &B::Hash) {
if let Some((from, to)) = self.queued_blocks.remove(hash) {
let mut block_num = from;
diff --git a/substrate/client/network/sync/src/lib.rs b/substrate/client/network/sync/src/lib.rs
index 10eaa245051..a291da4a90d 100644
--- a/substrate/client/network/sync/src/lib.rs
+++ b/substrate/client/network/sync/src/lib.rs
@@ -1405,8 +1405,27 @@ where
/// Get the set of downloaded blocks that are ready to be queued for import.
fn ready_blocks(&mut self) -> Vec> {
+ let start_block = self.best_queued_number + One::one();
+
+ // Verify that the parent of the first available block is in the chain.
+ // If not, we are downloading from a fork. In this case, wait until
+ // the start block has a parent on chain.
+ let parent_on_chain =
+ self.blocks.first_ready_block_header(start_block).map_or(false, |hdr| {
+ std::matches!(
+ self.block_status(hdr.parent_hash()).unwrap_or(BlockStatus::Unknown),
+ BlockStatus::InChainWithState |
+ BlockStatus::InChainPruned |
+ BlockStatus::Queued
+ )
+ });
+
+ if !parent_on_chain {
+ return vec![]
+ }
+
self.blocks
- .ready_blocks(self.best_queued_number + One::one())
+ .ready_blocks(start_block)
.into_iter()
.map(|block_data| {
let justifications = block_data
@@ -3364,4 +3383,380 @@ mod test {
pending_responses.remove(&peers[1]);
assert_eq!(pending_responses.len(), 0);
}
+
+ #[test]
+ fn syncs_fork_with_partial_response_extends_tip() {
+ sp_tracing::try_init_simple();
+
+ // Set up: the two chains share the first 15 blocks before
+ // diverging. The other(canonical) chain fork is longer.
+ let max_blocks_per_request = 64;
+ let common_ancestor = 15;
+ let non_canonical_chain_length = common_ancestor + 3;
+ let canonical_chain_length = common_ancestor + max_blocks_per_request + 10;
+
+ let (_chain_sync_network_provider, chain_sync_network_handle) =
+ NetworkServiceProvider::new();
+ let mut client = Arc::new(TestClientBuilder::new().build());
+
+ // Blocks on the non-canonical chain.
+ let non_canonical_blocks = (0..non_canonical_chain_length)
+ .map(|_| build_block(&mut client, None, false))
+ .collect::>();
+
+ // Blocks on the canonical chain.
+ let canonical_blocks = {
+ let mut client = Arc::new(TestClientBuilder::new().build());
+ let common_blocks = non_canonical_blocks[..common_ancestor as usize]
+ .into_iter()
+ .inspect(|b| block_on(client.import(BlockOrigin::Own, (*b).clone())).unwrap())
+ .cloned()
+ .collect::>();
+
+ common_blocks
+ .into_iter()
+ .chain(
+ (0..(canonical_chain_length - common_ancestor as u32))
+ .map(|_| build_block(&mut client, None, true)),
+ )
+ .collect::>()
+ };
+
+ let mut sync = ChainSync::new(
+ SyncMode::Full,
+ client.clone(),
+ ProtocolName::from("test-block-announce-protocol"),
+ 1,
+ max_blocks_per_request,
+ None,
+ chain_sync_network_handle,
+ )
+ .unwrap();
+
+ // Connect the node we will sync from
+ let peer_id = PeerId::random();
+ let canonical_tip = canonical_blocks.last().unwrap().clone();
+ let mut request = sync
+ .new_peer(peer_id, canonical_tip.hash(), *canonical_tip.header().number())
+ .unwrap()
+ .unwrap();
+ assert_eq!(FromBlock::Number(client.info().best_number), request.from);
+ assert_eq!(Some(1), request.max);
+
+ // Do the ancestor search
+ loop {
+ let block =
+ &canonical_blocks[unwrap_from_block_number(request.from.clone()) as usize - 1];
+ let response = create_block_response(vec![block.clone()]);
+
+ let on_block_data = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ request = if let OnBlockData::Request(_peer, request) = on_block_data {
+ request
+ } else {
+ // We found the ancestor
+ break
+ };
+
+ log::trace!(target: LOG_TARGET, "Request: {request:?}");
+ }
+
+ // The response for the 64 blocks is returned in two parts:
+ // part 1: last 61 blocks [19..79], part 2: first 3 blocks [16-18].
+ // Even though the first part extends the current chain ending at 18,
+ // it should not result in an import yet.
+ let resp_1_from = common_ancestor as u64 + max_blocks_per_request as u64;
+ let resp_2_from = common_ancestor as u64 + 3;
+
+ // No import expected.
+ let request = get_block_request(
+ &mut sync,
+ FromBlock::Number(resp_1_from),
+ max_blocks_per_request as u32,
+ &peer_id,
+ );
+
+ let from = unwrap_from_block_number(request.from.clone());
+ let mut resp_blocks = canonical_blocks[18..from as usize].to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ assert!(matches!(
+ res,
+ OnBlockData::Import(ImportBlocksAction{ origin: _, blocks }) if blocks.is_empty()
+ ),);
+
+ // Gap filled, expect max_blocks_per_request being imported now.
+ let request = get_block_request(&mut sync, FromBlock::Number(resp_2_from), 3, &peer_id);
+ let mut resp_blocks = canonical_blocks[common_ancestor as usize..18].to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ let to_import: Vec<_> = match &res {
+ OnBlockData::Import(ImportBlocksAction { origin: _, blocks }) => {
+ assert_eq!(blocks.len(), sync.max_blocks_per_request as usize);
+ blocks
+ .iter()
+ .map(|b| {
+ let num = *b.header.as_ref().unwrap().number() as usize;
+ canonical_blocks[num - 1].clone()
+ })
+ .collect()
+ },
+ _ => {
+ panic!("Unexpected response: {res:?}");
+ },
+ };
+
+ let _ = sync.on_blocks_processed(
+ max_blocks_per_request as usize,
+ resp_blocks.len(),
+ resp_blocks
+ .iter()
+ .rev()
+ .map(|b| {
+ (
+ Ok(BlockImportStatus::ImportedUnknown(
+ *b.header().number(),
+ Default::default(),
+ Some(peer_id),
+ )),
+ b.hash(),
+ )
+ })
+ .collect(),
+ );
+ to_import.into_iter().for_each(|b| {
+ assert!(matches!(client.block(*b.header.parent_hash()), Ok(Some(_))));
+ block_on(client.import(BlockOrigin::Own, b)).unwrap();
+ });
+ let expected_number = common_ancestor as u32 + max_blocks_per_request as u32;
+ assert_eq!(sync.best_queued_number as u32, expected_number);
+ assert_eq!(sync.best_queued_hash, canonical_blocks[expected_number as usize - 1].hash());
+ // Sync rest of the chain.
+ let request =
+ get_block_request(&mut sync, FromBlock::Hash(canonical_tip.hash()), 10_u32, &peer_id);
+ let mut resp_blocks = canonical_blocks
+ [(canonical_chain_length - 10) as usize..canonical_chain_length as usize]
+ .to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ assert!(matches!(
+ res,
+ OnBlockData::Import(ImportBlocksAction{ origin: _, blocks }) if blocks.len() == 10 as usize
+ ),);
+ let _ = sync.on_blocks_processed(
+ max_blocks_per_request as usize,
+ resp_blocks.len(),
+ resp_blocks
+ .iter()
+ .rev()
+ .map(|b| {
+ (
+ Ok(BlockImportStatus::ImportedUnknown(
+ *b.header().number(),
+ Default::default(),
+ Some(peer_id),
+ )),
+ b.hash(),
+ )
+ })
+ .collect(),
+ );
+ resp_blocks.into_iter().rev().for_each(|b| {
+ assert!(matches!(client.block(*b.header.parent_hash()), Ok(Some(_))));
+ block_on(client.import(BlockOrigin::Own, b)).unwrap();
+ });
+ let expected_number = canonical_chain_length as u32;
+ assert_eq!(sync.best_queued_number as u32, expected_number);
+ assert_eq!(sync.best_queued_hash, canonical_blocks[expected_number as usize - 1].hash());
+ }
+
+ #[test]
+ fn syncs_fork_with_partial_response_does_not_extend_tip() {
+ sp_tracing::try_init_simple();
+
+ // Set up: the two chains share the first 15 blocks before
+ // diverging. The other(canonical) chain fork is longer.
+ let max_blocks_per_request = 64;
+ let common_ancestor = 15;
+ let non_canonical_chain_length = common_ancestor + 3;
+ let canonical_chain_length = common_ancestor + max_blocks_per_request + 10;
+
+ let (_chain_sync_network_provider, chain_sync_network_handle) =
+ NetworkServiceProvider::new();
+ let mut client = Arc::new(TestClientBuilder::new().build());
+
+ // Blocks on the non-canonical chain.
+ let non_canonical_blocks = (0..non_canonical_chain_length)
+ .map(|_| build_block(&mut client, None, false))
+ .collect::>();
+
+ // Blocks on the canonical chain.
+ let canonical_blocks = {
+ let mut client = Arc::new(TestClientBuilder::new().build());
+ let common_blocks = non_canonical_blocks[..common_ancestor as usize]
+ .into_iter()
+ .inspect(|b| block_on(client.import(BlockOrigin::Own, (*b).clone())).unwrap())
+ .cloned()
+ .collect::>();
+
+ common_blocks
+ .into_iter()
+ .chain(
+ (0..(canonical_chain_length - common_ancestor as u32))
+ .map(|_| build_block(&mut client, None, true)),
+ )
+ .collect::>()
+ };
+
+ let mut sync = ChainSync::new(
+ SyncMode::Full,
+ client.clone(),
+ ProtocolName::from("test-block-announce-protocol"),
+ 1,
+ max_blocks_per_request,
+ None,
+ chain_sync_network_handle,
+ )
+ .unwrap();
+
+ // Connect the node we will sync from
+ let peer_id = PeerId::random();
+ let canonical_tip = canonical_blocks.last().unwrap().clone();
+ let mut request = sync
+ .new_peer(peer_id, canonical_tip.hash(), *canonical_tip.header().number())
+ .unwrap()
+ .unwrap();
+ assert_eq!(FromBlock::Number(client.info().best_number), request.from);
+ assert_eq!(Some(1), request.max);
+
+ // Do the ancestor search
+ loop {
+ let block =
+ &canonical_blocks[unwrap_from_block_number(request.from.clone()) as usize - 1];
+ let response = create_block_response(vec![block.clone()]);
+
+ let on_block_data = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ request = if let OnBlockData::Request(_peer, request) = on_block_data {
+ request
+ } else {
+ // We found the ancestor
+ break
+ };
+
+ log::trace!(target: LOG_TARGET, "Request: {request:?}");
+ }
+
+ // The response for the 64 blocks is returned in two parts:
+ // part 1: last 62 blocks [18..79], part 2: first 2 blocks [16-17].
+ // Even though the first part extends the current chain ending at 18,
+ // it should not result in an import yet.
+ let resp_1_from = common_ancestor as u64 + max_blocks_per_request as u64;
+ let resp_2_from = common_ancestor as u64 + 2;
+
+ // No import expected.
+ let request = get_block_request(
+ &mut sync,
+ FromBlock::Number(resp_1_from),
+ max_blocks_per_request as u32,
+ &peer_id,
+ );
+
+ let from = unwrap_from_block_number(request.from.clone());
+ let mut resp_blocks = canonical_blocks[17..from as usize].to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ assert!(matches!(
+ res,
+ OnBlockData::Import(ImportBlocksAction{ origin: _, blocks }) if blocks.is_empty()
+ ),);
+
+ // Gap filled, expect max_blocks_per_request being imported now.
+ let request = get_block_request(&mut sync, FromBlock::Number(resp_2_from), 2, &peer_id);
+ let mut resp_blocks = canonical_blocks[common_ancestor as usize..17].to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ let to_import: Vec<_> = match &res {
+ OnBlockData::Import(ImportBlocksAction { origin: _, blocks }) => {
+ assert_eq!(blocks.len(), sync.max_blocks_per_request as usize);
+ blocks
+ .iter()
+ .map(|b| {
+ let num = *b.header.as_ref().unwrap().number() as usize;
+ canonical_blocks[num - 1].clone()
+ })
+ .collect()
+ },
+ _ => {
+ panic!("Unexpected response: {res:?}");
+ },
+ };
+
+ let _ = sync.on_blocks_processed(
+ max_blocks_per_request as usize,
+ resp_blocks.len(),
+ resp_blocks
+ .iter()
+ .rev()
+ .map(|b| {
+ (
+ Ok(BlockImportStatus::ImportedUnknown(
+ *b.header().number(),
+ Default::default(),
+ Some(peer_id),
+ )),
+ b.hash(),
+ )
+ })
+ .collect(),
+ );
+ to_import.into_iter().for_each(|b| {
+ assert!(matches!(client.block(*b.header.parent_hash()), Ok(Some(_))));
+ block_on(client.import(BlockOrigin::Own, b)).unwrap();
+ });
+ let expected_number = common_ancestor as u32 + max_blocks_per_request as u32;
+ assert_eq!(sync.best_queued_number as u32, expected_number);
+ assert_eq!(sync.best_queued_hash, canonical_blocks[expected_number as usize - 1].hash());
+ // Sync rest of the chain.
+ let request =
+ get_block_request(&mut sync, FromBlock::Hash(canonical_tip.hash()), 10_u32, &peer_id);
+ let mut resp_blocks = canonical_blocks
+ [(canonical_chain_length - 10) as usize..canonical_chain_length as usize]
+ .to_vec();
+ resp_blocks.reverse();
+ let response = create_block_response(resp_blocks.clone());
+ let res = sync.on_block_data(&peer_id, Some(request), response).unwrap();
+ assert!(matches!(
+ res,
+ OnBlockData::Import(ImportBlocksAction{ origin: _, blocks }) if blocks.len() == 10 as usize
+ ),);
+ let _ = sync.on_blocks_processed(
+ max_blocks_per_request as usize,
+ resp_blocks.len(),
+ resp_blocks
+ .iter()
+ .rev()
+ .map(|b| {
+ (
+ Ok(BlockImportStatus::ImportedUnknown(
+ *b.header().number(),
+ Default::default(),
+ Some(peer_id),
+ )),
+ b.hash(),
+ )
+ })
+ .collect(),
+ );
+ resp_blocks.into_iter().rev().for_each(|b| {
+ assert!(matches!(client.block(*b.header.parent_hash()), Ok(Some(_))));
+ block_on(client.import(BlockOrigin::Own, b)).unwrap();
+ });
+ let expected_number = canonical_chain_length as u32;
+ assert_eq!(sync.best_queued_number as u32, expected_number);
+ assert_eq!(sync.best_queued_hash, canonical_blocks[expected_number as usize - 1].hash());
+ }
}
--
GitLab
From ebf442336f14f45d0a6522b65e68f567107cfb46 Mon Sep 17 00:00:00 2001
From: Svyatoslav Nikolsky
Date: Tue, 10 Oct 2023 14:20:25 +0300
Subject: [PATCH 004/524] Update bridges subtree (#1803)
---
.../runtime-common/src/messages_call_ext.rs | 29 ++++-
.../src/refund_relayer_extension.rs | 107 +++++++++++++++++-
bridges/modules/grandpa/src/call_ext.rs | 21 +++-
bridges/modules/parachains/src/call_ext.rs | 19 +++-
4 files changed, 164 insertions(+), 12 deletions(-)
diff --git a/bridges/bin/runtime-common/src/messages_call_ext.rs b/bridges/bin/runtime-common/src/messages_call_ext.rs
index 07a99d2c0a1..5303fcb7ba0 100644
--- a/bridges/bin/runtime-common/src/messages_call_ext.rs
+++ b/bridges/bin/runtime-common/src/messages_call_ext.rs
@@ -18,6 +18,7 @@ use crate::messages::{
source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof,
};
use bp_messages::{target_chain::MessageDispatch, InboundLaneData, LaneId, MessageNonce};
+use bp_runtime::OwnedBridgeModule;
use frame_support::{
dispatch::CallableCallFor,
traits::{Get, IsSubType},
@@ -187,8 +188,22 @@ pub trait MessagesCallSubType, I: 'static>:
/// or a `ReceiveMessagesDeliveryProof` call, if the call is for the provided lane.
fn call_info_for(&self, lane_id: LaneId) -> Option;
- /// Check that a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call is trying
- /// to deliver/confirm at least some messages that are better than the ones we know of.
+ /// Ensures that a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call:
+ ///
+ /// - does not deliver already delivered messages. We require all messages in the
+ /// `ReceiveMessagesProof` call to be undelivered;
+ ///
+ /// - does not submit empty `ReceiveMessagesProof` call with zero messages, unless the lane
+ /// needs to be unblocked by providing relayer rewards proof;
+ ///
+ /// - brings no new delivery confirmations in a `ReceiveMessagesDeliveryProof` call. We require
+ /// at least one new delivery confirmation in the unrewarded relayers set;
+ ///
+ /// - does not violate some basic (easy verifiable) messages pallet rules obsolete (like
+ /// submitting a call when a pallet is halted or delivering messages when a dispatcher is
+ /// inactive).
+ ///
+ /// If one of above rules is violated, the transaction is treated as invalid.
fn check_obsolete_call(&self) -> TransactionValidity;
}
@@ -278,7 +293,17 @@ impl<
}
fn check_obsolete_call(&self) -> TransactionValidity {
+ let is_pallet_halted = Pallet::::ensure_not_halted().is_err();
match self.call_info() {
+ Some(proof_info) if is_pallet_halted => {
+ log::trace!(
+ target: pallet_bridge_messages::LOG_TARGET,
+ "Rejecting messages transaction on halted pallet: {:?}",
+ proof_info
+ );
+
+ return sp_runtime::transaction_validity::InvalidTransaction::Call.into()
+ },
Some(CallInfo::ReceiveMessagesProof(proof_info))
if proof_info.is_obsolete(T::MessageDispatch::is_active()) =>
{
diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs
index 876c069dc0f..6d8b2114808 100644
--- a/bridges/bin/runtime-common/src/refund_relayer_extension.rs
+++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs
@@ -838,21 +838,23 @@ mod tests {
mock::*,
};
use bp_messages::{
- DeliveredMessages, InboundLaneData, MessageNonce, OutboundLaneData, UnrewardedRelayer,
- UnrewardedRelayersState,
+ DeliveredMessages, InboundLaneData, MessageNonce, MessagesOperatingMode, OutboundLaneData,
+ UnrewardedRelayer, UnrewardedRelayersState,
};
use bp_parachains::{BestParaHeadHash, ParaInfo};
use bp_polkadot_core::parachains::{ParaHeadsProof, ParaId};
- use bp_runtime::HeaderId;
+ use bp_runtime::{BasicOperatingMode, HeaderId};
use bp_test_utils::{make_default_justification, test_keyring};
use frame_support::{
assert_storage_noop, parameter_types,
traits::{fungible::Mutate, ReservableCurrency},
weights::Weight,
};
- use pallet_bridge_grandpa::{Call as GrandpaCall, StoredAuthoritySet};
- use pallet_bridge_messages::Call as MessagesCall;
- use pallet_bridge_parachains::{Call as ParachainsCall, RelayBlockHash};
+ use pallet_bridge_grandpa::{Call as GrandpaCall, Pallet as GrandpaPallet, StoredAuthoritySet};
+ use pallet_bridge_messages::{Call as MessagesCall, Pallet as MessagesPallet};
+ use pallet_bridge_parachains::{
+ Call as ParachainsCall, Pallet as ParachainsPallet, RelayBlockHash,
+ };
use sp_runtime::{
traits::{ConstU64, Header as HeaderT},
transaction_validity::{InvalidTransaction, ValidTransaction},
@@ -1592,6 +1594,99 @@ mod tests {
});
}
+ #[test]
+ fn ext_rejects_batch_with_grandpa_finality_proof_when_grandpa_pallet_is_halted() {
+ run_test(|| {
+ initialize_environment(100, 100, 100);
+
+ GrandpaPallet::::set_operating_mode(
+ RuntimeOrigin::root(),
+ BasicOperatingMode::Halted,
+ )
+ .unwrap();
+
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ });
+ }
+
+ #[test]
+ fn ext_rejects_batch_with_parachain_finality_proof_when_parachains_pallet_is_halted() {
+ run_test(|| {
+ initialize_environment(100, 100, 100);
+
+ ParachainsPallet::::set_operating_mode(
+ RuntimeOrigin::root(),
+ BasicOperatingMode::Halted,
+ )
+ .unwrap();
+
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+
+ assert_eq!(
+ run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ });
+ }
+
+ #[test]
+ fn ext_rejects_transaction_when_messages_pallet_is_halted() {
+ run_test(|| {
+ initialize_environment(100, 100, 100);
+
+ MessagesPallet::::set_operating_mode(
+ RuntimeOrigin::root(),
+ MessagesOperatingMode::Basic(BasicOperatingMode::Halted),
+ )
+ .unwrap();
+
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+
+ assert_eq!(
+ run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+
+ assert_eq!(
+ run_pre_dispatch(message_delivery_call(200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ assert_eq!(
+ run_pre_dispatch(message_confirmation_call(200)),
+ Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),
+ );
+ });
+ }
+
#[test]
fn pre_dispatch_parses_batch_with_relay_chain_and_parachain_headers() {
run_test(|| {
diff --git a/bridges/modules/grandpa/src/call_ext.rs b/bridges/modules/grandpa/src/call_ext.rs
index e0648d5dd0f..f238064f92b 100644
--- a/bridges/modules/grandpa/src/call_ext.rs
+++ b/bridges/modules/grandpa/src/call_ext.rs
@@ -16,7 +16,7 @@
use crate::{weights::WeightInfo, BridgedBlockNumber, BridgedHeader, Config, Error, Pallet};
use bp_header_chain::{justification::GrandpaJustification, ChainWithGrandpa};
-use bp_runtime::BlockNumberOf;
+use bp_runtime::{BlockNumberOf, OwnedBridgeModule};
use codec::Encode;
use frame_support::{dispatch::CallableCallFor, traits::IsSubType, weights::Weight};
use sp_runtime::{
@@ -126,6 +126,10 @@ pub trait CallSubType, I: 'static>:
_ => return Ok(ValidTransaction::default()),
};
+ if Pallet::::ensure_not_halted().is_err() {
+ return InvalidTransaction::Call.into()
+ }
+
match SubmitFinalityProofHelper::::check_obsolete(finality_target.block_number) {
Ok(_) => Ok(ValidTransaction::default()),
Err(Error::::OldHeader) => InvalidTransaction::Stale.into(),
@@ -192,10 +196,10 @@ mod tests {
use crate::{
call_ext::CallSubType,
mock::{run_test, test_header, RuntimeCall, TestBridgedChain, TestNumber, TestRuntime},
- BestFinalized, Config, WeightInfo,
+ BestFinalized, Config, PalletOperatingMode, WeightInfo,
};
use bp_header_chain::ChainWithGrandpa;
- use bp_runtime::HeaderId;
+ use bp_runtime::{BasicOperatingMode, HeaderId};
use bp_test_utils::{
make_default_justification, make_justification_for_header, JustificationGeneratorParams,
};
@@ -238,6 +242,17 @@ mod tests {
});
}
+ #[test]
+ fn extension_rejects_new_header_if_pallet_is_halted() {
+ run_test(|| {
+ // when pallet is halted => tx is rejected
+ sync_to_header_10();
+ PalletOperatingMode::::put(BasicOperatingMode::Halted);
+
+ assert!(!validate_block_submit(15));
+ });
+ }
+
#[test]
fn extension_accepts_new_header() {
run_test(|| {
diff --git a/bridges/modules/parachains/src/call_ext.rs b/bridges/modules/parachains/src/call_ext.rs
index 99640dadc61..198ff11be49 100644
--- a/bridges/modules/parachains/src/call_ext.rs
+++ b/bridges/modules/parachains/src/call_ext.rs
@@ -17,6 +17,7 @@
use crate::{Config, Pallet, RelayBlockNumber};
use bp_parachains::BestParaHeadHash;
use bp_polkadot_core::parachains::{ParaHash, ParaId};
+use bp_runtime::OwnedBridgeModule;
use frame_support::{dispatch::CallableCallFor, traits::IsSubType};
use sp_runtime::{
transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction},
@@ -141,6 +142,10 @@ pub trait CallSubType, I: 'static>:
None => return Ok(ValidTransaction::default()),
};
+ if Pallet::::ensure_not_halted().is_err() {
+ return InvalidTransaction::Call.into()
+ }
+
if SubmitParachainHeadsHelper::::is_obsolete(&update) {
return InvalidTransaction::Stale.into()
}
@@ -160,10 +165,11 @@ where
mod tests {
use crate::{
mock::{run_test, RuntimeCall, TestRuntime},
- CallSubType, ParaInfo, ParasInfo, RelayBlockNumber,
+ CallSubType, PalletOperatingMode, ParaInfo, ParasInfo, RelayBlockNumber,
};
use bp_parachains::BestParaHeadHash;
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
+ use bp_runtime::BasicOperatingMode;
fn validate_submit_parachain_heads(
num: RelayBlockNumber,
@@ -221,6 +227,17 @@ mod tests {
});
}
+ #[test]
+ fn extension_rejects_header_if_pallet_is_halted() {
+ run_test(|| {
+ // when pallet is halted => tx is rejected
+ sync_to_relay_header_10();
+ PalletOperatingMode::::put(BasicOperatingMode::Halted);
+
+ assert!(!validate_submit_parachain_heads(15, vec![(ParaId(1), [2u8; 32].into())]));
+ });
+ }
+
#[test]
fn extension_accepts_new_header() {
run_test(|| {
--
GitLab
From e3c97e486010d443cb20f8bbb29d404527665a1a Mon Sep 17 00:00:00 2001
From: Branislav Kontur
Date: Tue, 10 Oct 2023 13:26:22 +0200
Subject: [PATCH 005/524] [xcm] Use `Weight::MAX` for
`reserve_asset_deposited`, `receive_teleported_asset` benchmarks (#1726)
# Description
## Summary
Previously, the `pallet_xcm::do_reserve_transfer_assets` and
`pallet_xcm::do_teleport_assets` functions relied on weight estimation
for remote chain execution, which was based on guesswork derived from
the local chain. This approach led to complications for runtimes that
did not provide or support specific [XCM
configurations](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/polkadot/xcm/xcm-executor/src/config.rs#L43-L47)
for `IsReserve` or `IsTeleporter`. Consequently, such runtimes had to
resort to implementing hard-coded weights for XCM instructions like
`reserve_asset_deposited` or `receive_teleported_asset` to support
extrinsics such as `pallet_xcm::reserve_transfer_assets` and
`pallet_xcm::teleport_assets`, which depended on remote weight
estimation.
The issue of remote weight estimation was addressed and resolved by
[Pull Request
#1645](https://github.com/paritytech/polkadot-sdk/pull/1645), which
removed the need for remote weight estimation.
## Solution
As a continuation of this improvement, the current PR proposes further
cleanup by removing unnecessary hard-coded values and rectifying
benchmark results with `Weight::MAX` that previously used
`T::BlockWeights::get().max_block` as an override for unsupported XCM
instructions like `ReserveAssetDeposited` and `ReceiveTeleportedAsset`.
## Questions
- [x] Can we remove now also `Hardcoded till the XCM pallet is fixed`
for `deposit_asset`? E.g. for AssetHubKusama
[here](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs#L129-L134)
- [x] Are comments like
[this](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/polkadot/runtime/kusama/src/weights/xcm/mod.rs#L94)
`// Kusama doesn't support ReserveAssetDeposited, so this benchmark has
a default weight` still relevant? Shouldnt be removed/changed?
## TODO
- [x] `bench bot` regenerate xcm weights for all runtimes
- [x] remove hard-coded stuff from system parachain weight files
- [ ] when merged, open `polkadot-fellow/runtimes` PR
## References
Fixes #1132
Closes #1132
Old polkadot repo [PR](https://github.com/paritytech/polkadot/pull/7546)
---------
Co-authored-by: command-bot <>
---
.../src/tests/reserve_transfer.rs | 11 +-
.../asset-hub-westend/src/tests/send.rs | 4 +-
.../asset-hub-westend/src/tests/teleport.rs | 168 +++++++++---------
.../emulated/common/src/impls.rs | 16 ++
.../asset-hub-kusama/src/weights/xcm/mod.rs | 17 +-
.../xcm/pallet_xcm_benchmarks_fungible.rs | 78 ++++----
.../asset-hub-polkadot/src/weights/xcm/mod.rs | 17 +-
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 ++++---
.../asset-hub-westend/src/weights/xcm/mod.rs | 17 +-
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 ++++---
.../bridge-hub-kusama/src/weights/xcm/mod.rs | 17 +-
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 ++++---
.../src/weights/xcm/mod.rs | 22 +--
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 ++++---
.../bridge-hub-rococo/src/weights/xcm/mod.rs | 17 +-
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 ++++---
.../runtime/rococo/src/weights/xcm/mod.rs | 1 -
.../xcm/pallet_xcm_benchmarks_fungible.rs | 64 +++----
.../runtime/westend/src/weights/xcm/mod.rs | 1 -
.../xcm/pallet_xcm_benchmarks_fungible.rs | 60 +++----
.../src/fungible/benchmarking.rs | 5 +-
21 files changed, 381 insertions(+), 454 deletions(-)
diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs
index 51fac43be12..805c8811b2d 100644
--- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs
+++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs
@@ -35,11 +35,8 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) {
);
}
-fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) {
- AssetHubWestend::assert_dmp_queue_incomplete(
- Some(Weight::from_parts(1_000_000_000, 0)),
- Some(Error::UntrustedReserveLocation),
- );
+fn system_para_dest_assertions(_t: RelayToSystemParaTest) {
+ AssetHubWestend::assert_dmp_queue_error(Error::WeightNotComputable);
}
fn system_para_to_relay_assertions(_t: SystemParaToRelayTest) {
@@ -178,7 +175,7 @@ fn limited_reserve_transfer_native_asset_from_relay_to_system_para_fails() {
let receiver_balance_before = test.receiver.balance;
test.set_assertion::(relay_origin_assertions);
- test.set_assertion::(system_para_dest_assertions_incomplete);
+ test.set_assertion::(system_para_dest_assertions);
test.set_dispatchable::(relay_limited_reserve_transfer_assets);
test.assert();
@@ -237,7 +234,7 @@ fn reserve_transfer_native_asset_from_relay_to_system_para_fails() {
let receiver_balance_before = test.receiver.balance;
test.set_assertion::(relay_origin_assertions);
- test.set_assertion::(system_para_dest_assertions_incomplete);
+ test.set_assertion::(system_para_dest_assertions);
test.set_dispatchable::(relay_reserve_transfer_assets);
test.assert();
diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs
index 424d222bef3..d0a71e88c67 100644
--- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs
+++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/send.rs
@@ -119,8 +119,8 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
type RuntimeEvent = ::RuntimeEvent;
AssetHubWestend::assert_xcmp_queue_success(Some(Weight::from_parts(
- 2_176_414_000,
- 203_593,
+ 16_290_336_000,
+ 562_893,
)));
assert_expected_events!(
diff --git a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs
index 8de73a7420c..d94fd4b97d9 100644
--- a/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs
+++ b/cumulus/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs
@@ -97,7 +97,7 @@ fn para_origin_assertions(t: SystemParaToRelayTest) {
fn para_dest_assertions(t: RelayToSystemParaTest) {
type RuntimeEvent = ::RuntimeEvent;
- AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(164_733_000, 0)));
+ AssetHubWestend::assert_dmp_queue_complete(Some(Weight::from_parts(164_793_000, 3593)));
assert_expected_events!(
AssetHubWestend,
@@ -142,16 +142,15 @@ fn system_para_limited_teleport_assets(t: SystemParaToRelayTest) -> DispatchResu
)
}
-// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged
-// fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult {
-// ::PolkadotXcm::teleport_assets(
-// t.signed_origin,
-// bx!(t.args.dest),
-// bx!(t.args.beneficiary),
-// bx!(t.args.assets),
-// t.args.fee_asset_item,
-// )
-// }
+fn system_para_teleport_assets(t: SystemParaToRelayTest) -> DispatchResult {
+ ::PolkadotXcm::teleport_assets(
+ t.signed_origin,
+ bx!(t.args.dest.into()),
+ bx!(t.args.beneficiary.into()),
+ bx!(t.args.assets.into()),
+ t.args.fee_asset_item,
+ )
+}
/// Limited Teleport of native asset from Relay Chain to the System Parachain should work
#[test]
@@ -286,78 +285,75 @@ fn teleport_native_assets_from_relay_to_system_para_works() {
assert!(receiver_balance_after > receiver_balance_before);
}
-// TODO: Uncomment when https://github.com/paritytech/polkadot/pull/7424 is merged
-
-// Right now it is failing in the Relay Chain with a
-// `messageQueue.ProcessingFailed` event `error: Unsupported`.
-// The reason is the `Weigher` in `pallet_xcm` is not properly calculating the `remote_weight`
-// and it cause an `Overweight` error in `AllowTopLevelPaidExecutionFrom` barrier
-
-// /// Teleport of native asset from System Parachains to the Relay Chain
-// /// should work when there is enough balance in Relay Chain's `CheckAccount`
-// #[test]
-// fn teleport_native_assets_back_from_system_para_to_relay_works() {
-// // Dependency - Relay Chain's `CheckAccount` should have enough balance
-// teleport_native_assets_from_relay_to_system_para_works();
-
-// // Init values for Relay Chain
-// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
-// let test_args = TestContext {
-// sender: AssetHubWestendSender::get(),
-// receiver: WestendReceiver::get(),
-// args: get_para_dispatch_args(amount_to_send),
-// };
-
-// let mut test = SystemParaToRelayTest::new(test_args);
-
-// let sender_balance_before = test.sender.balance;
-// let receiver_balance_before = test.receiver.balance;
-
-// test.set_assertion::(para_origin_assertions);
-// test.set_assertion::(relay_dest_assertions);
-// test.set_dispatchable::(system_para_teleport_assets);
-// test.assert();
-
-// let sender_balance_after = test.sender.balance;
-// let receiver_balance_after = test.receiver.balance;
-
-// // Sender's balance is reduced
-// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after);
-// // Receiver's balance is increased
-// assert!(receiver_balance_after > receiver_balance_before);
-// }
-
-// /// Teleport of native asset from System Parachain to Relay Chain
-// /// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount`
-// #[test]
-// fn teleport_native_assets_from_system_para_to_relay_fails() {
-// // Init values for Relay Chain
-// let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
-// let assets = (Parent, amount_to_send).into();
-//
-// let test_args = TestContext {
-// sender: AssetHubWestendSender::get(),
-// receiver: WestendReceiver::get(),
-// args: system_para_test_args(amount_to_send),
-// assets,
-// None
-// };
-
-// let mut test = SystemParaToRelayTest::new(test_args);
-
-// let sender_balance_before = test.sender.balance;
-// let receiver_balance_before = test.receiver.balance;
-
-// test.set_assertion::(para_origin_assertions);
-// test.set_assertion::(relay_dest_assertions);
-// test.set_dispatchable::(system_para_teleport_assets);
-// test.assert();
-
-// let sender_balance_after = test.sender.balance;
-// let receiver_balance_after = test.receiver.balance;
-
-// // Sender's balance is reduced
-// assert_eq!(sender_balance_before - amount_to_send, sender_balance_after);
-// // Receiver's balance does not change
-// assert_eq!(receiver_balance_after, receiver_balance_before);
-// }
+/// Teleport of native asset from System Parachains to the Relay Chain
+/// should work when there is enough balance in Relay Chain's `CheckAccount`
+#[test]
+fn teleport_native_assets_back_from_system_para_to_relay_works() {
+ // Dependency - Relay Chain's `CheckAccount` should have enough balance
+ teleport_native_assets_from_relay_to_system_para_works();
+
+ // Init values for Relay Chain
+ let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
+ let destination = AssetHubWestend::parent_location();
+ let beneficiary_id = WestendReceiver::get();
+ let assets = (Parent, amount_to_send).into();
+
+ let test_args = TestContext {
+ sender: AssetHubWestendSender::get(),
+ receiver: WestendReceiver::get(),
+ args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None),
+ };
+
+ let mut test = SystemParaToRelayTest::new(test_args);
+
+ let sender_balance_before = test.sender.balance;
+ let receiver_balance_before = test.receiver.balance;
+
+ test.set_assertion::(para_origin_assertions);
+ test.set_assertion::(relay_dest_assertions);
+ test.set_dispatchable::(system_para_teleport_assets);
+ test.assert();
+
+ let sender_balance_after = test.sender.balance;
+ let receiver_balance_after = test.receiver.balance;
+
+ // Sender's balance is reduced
+ assert_eq!(sender_balance_before - amount_to_send, sender_balance_after);
+ // Receiver's balance is increased
+ assert!(receiver_balance_after > receiver_balance_before);
+}
+
+/// Teleport of native asset from System Parachain to Relay Chain
+/// shouldn't work when there is not enough balance in Relay Chain's `CheckAccount`
+#[test]
+fn teleport_native_assets_from_system_para_to_relay_fails() {
+ // Init values for Relay Chain
+ let amount_to_send: Balance = ASSET_HUB_WESTEND_ED * 1000;
+ let destination = AssetHubWestend::parent_location();
+ let beneficiary_id = WestendReceiver::get();
+ let assets = (Parent, amount_to_send).into();
+
+ let test_args = TestContext {
+ sender: AssetHubWestendSender::get(),
+ receiver: WestendReceiver::get(),
+ args: system_para_test_args(destination, beneficiary_id, amount_to_send, assets, None),
+ };
+
+ let mut test = SystemParaToRelayTest::new(test_args);
+
+ let sender_balance_before = test.sender.balance;
+ let receiver_balance_before = test.receiver.balance;
+
+ test.set_assertion::(para_origin_assertions);
+ test.set_assertion::(relay_dest_assertions_fail);
+ test.set_dispatchable::(system_para_teleport_assets);
+ test.assert();
+
+ let sender_balance_after = test.sender.balance;
+ let receiver_balance_after = test.receiver.balance;
+
+ // Sender's balance is reduced
+ assert_eq!(sender_balance_before - amount_to_send, sender_balance_after);
+ // Receiver's balance does not change
+ assert_eq!(receiver_balance_after, receiver_balance_before);
+}
diff --git a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs
index 024ae65c51e..5e11922d859 100644
--- a/cumulus/parachains/integration-tests/emulated/common/src/impls.rs
+++ b/cumulus/parachains/integration-tests/emulated/common/src/impls.rs
@@ -503,6 +503,22 @@ macro_rules! impl_assert_events_helpers_for_parachain {
);
}
+ /// Asserts a XCM from Relay Chain is executed with error
+ pub fn assert_dmp_queue_error(
+ expected_error: $crate::impls::Error,
+ ) {
+ $crate::impls::assert_expected_events!(
+ Self,
+ vec![
+ [<$chain RuntimeEvent>]::DmpQueue($crate::impls::cumulus_pallet_dmp_queue::Event::ExecutedDownward {
+ outcome: $crate::impls::Outcome::Error(error), ..
+ }) => {
+ error: *error == expected_error,
+ },
+ ]
+ );
+ }
+
/// Asserts a XCM from another Parachain is completely executed
pub fn assert_xcmp_queue_success(expected_weight: Option<$crate::impls::Weight>) {
$crate::impls::assert_expected_events!(
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs
index 9aff4902d15..ce6e9206515 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs
@@ -61,16 +61,8 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset())
}
- // Currently there is no trusted reserve (`IsReserve = ()`),
- // but we need this hack for `pallet_xcm::reserve_transfer_assets`
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7424
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7546
- fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
- // TODO: if we change `IsReserve = ...` then use this line...
- // TODO: or if remote weight estimation is fixed, then remove
- // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- hardcoded_weight.min(XcmFungibleWeight::::reserve_asset_deposited())
+ fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
+ assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset())
@@ -127,10 +119,7 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight {
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
index 6e663039b0c..9b8611fd663 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-09-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// target/production/polkadot-parachain
// benchmark
// pallet
-// --template=./templates/xcm-bench-template.hbs
-// --chain=asset-hub-kusama-dev
-// --wasm-execution=compiled
-// --pallet=pallet_xcm_benchmarks::fungible
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --extrinsic=*
// --steps=50
// --repeat=20
-// --json
-// --header=./file_header.txt
-// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_benchmarks::fungible
+// --chain=asset-hub-kusama-dev
+// --header=./cumulus/file_header.txt
+// --template=./cumulus/templates/xcm-bench-template.hbs
+// --output=./cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
- // Minimum execution time: 26_104_000 picoseconds.
- Weight::from_parts(26_722_000, 3593)
+ // Minimum execution time: 25_602_000 picoseconds.
+ Weight::from_parts(26_312_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,8 +65,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
- // Minimum execution time: 52_259_000 picoseconds.
- Weight::from_parts(53_854_000, 6196)
+ // Minimum execution time: 51_173_000 picoseconds.
+ Weight::from_parts(52_221_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -88,10 +86,10 @@ impl WeightInfo {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn transfer_reserve_asset() -> Weight {
// Proof Size summary in bytes:
- // Measured: `210`
+ // Measured: `246`
// Estimated: `6196`
- // Minimum execution time: 77_248_000 picoseconds.
- Weight::from_parts(80_354_000, 6196)
+ // Minimum execution time: 74_651_000 picoseconds.
+ Weight::from_parts(76_500_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -101,8 +99,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 500_000_000_000 picoseconds.
- Weight::from_parts(500_000_000_000, 0)
+ // Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
+ Weight::from_parts(18_446_744_073_709_551_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -118,10 +116,10 @@ impl WeightInfo {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn initiate_reserve_withdraw() -> Weight {
// Proof Size summary in bytes:
- // Measured: `109`
- // Estimated: `3574`
- // Minimum execution time: 482_070_000 picoseconds.
- Weight::from_parts(490_269_000, 3574)
+ // Measured: `145`
+ // Estimated: `3610`
+ // Minimum execution time: 458_666_000 picoseconds.
+ Weight::from_parts(470_470_000, 3610)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -129,8 +127,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_970_000 picoseconds.
- Weight::from_parts(4_056_000, 0)
+ // Minimum execution time: 3_701_000 picoseconds.
+ Weight::from_parts(3_887_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,8 +136,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
- // Minimum execution time: 26_324_000 picoseconds.
- Weight::from_parts(26_985_000, 3593)
+ // Minimum execution time: 25_709_000 picoseconds.
+ Weight::from_parts(26_320_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -159,10 +157,10 @@ impl WeightInfo {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn deposit_reserve_asset() -> Weight {
// Proof Size summary in bytes:
- // Measured: `109`
- // Estimated: `3593`
- // Minimum execution time: 52_814_000 picoseconds.
- Weight::from_parts(54_666_000, 3593)
+ // Measured: `145`
+ // Estimated: `3610`
+ // Minimum execution time: 51_663_000 picoseconds.
+ Weight::from_parts(52_538_000, 3610)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -180,10 +178,10 @@ impl WeightInfo {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn initiate_teleport() -> Weight {
// Proof Size summary in bytes:
- // Measured: `109`
- // Estimated: `3574`
- // Minimum execution time: 33_044_000 picoseconds.
- Weight::from_parts(33_849_000, 3574)
+ // Measured: `145`
+ // Estimated: `3610`
+ // Minimum execution time: 31_972_000 picoseconds.
+ Weight::from_parts(32_834_000, 3610)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs
index 55fed809e2b..eb140c4bf32 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs
@@ -61,16 +61,8 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset())
}
- // Currently there is no trusted reserve (`IsReserve = ()`),
- // but we need this hack for `pallet_xcm::reserve_transfer_assets`
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7424
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7546
- fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
- // TODO: if we change `IsReserve = ...` then use this line...
- // TODO: or if remote weight estimation is fixed, then remove
- // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- hardcoded_weight.min(XcmFungibleWeight::::reserve_asset_deposited())
+ fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
+ assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset())
@@ -127,10 +119,7 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight {
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
index 4f64ea3fa1b..96d86ec423f 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-09-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// target/production/polkadot-parachain
// benchmark
// pallet
-// --template=./templates/xcm-bench-template.hbs
-// --chain=asset-hub-polkadot-dev
-// --wasm-execution=compiled
-// --pallet=pallet_xcm_benchmarks::fungible
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --extrinsic=*
// --steps=50
// --repeat=20
-// --json
-// --header=./file_header.txt
-// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_benchmarks::fungible
+// --chain=asset-hub-polkadot-dev
+// --header=./cumulus/file_header.txt
+// --template=./cumulus/templates/xcm-bench-template.hbs
+// --output=./cumulus/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
- // Minimum execution time: 26_090_000 picoseconds.
- Weight::from_parts(27_006_000, 3593)
+ // Minimum execution time: 25_903_000 picoseconds.
+ Weight::from_parts(26_768_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,8 +65,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
- // Minimum execution time: 50_699_000 picoseconds.
- Weight::from_parts(51_888_000, 6196)
+ // Minimum execution time: 51_042_000 picoseconds.
+ Weight::from_parts(51_939_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -90,8 +88,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `176`
// Estimated: `6196`
- // Minimum execution time: 72_130_000 picoseconds.
- Weight::from_parts(73_994_000, 6196)
+ // Minimum execution time: 74_626_000 picoseconds.
+ Weight::from_parts(75_963_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -101,8 +99,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 500_000_000_000 picoseconds.
- Weight::from_parts(500_000_000_000, 0)
+ // Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
+ Weight::from_parts(18_446_744_073_709_551_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -120,8 +118,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `75`
// Estimated: `3540`
- // Minimum execution time: 477_183_000 picoseconds.
- Weight::from_parts(488_156_000, 3540)
+ // Minimum execution time: 480_030_000 picoseconds.
+ Weight::from_parts(486_039_000, 3540)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -129,8 +127,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_966_000 picoseconds.
- Weight::from_parts(4_129_000, 0)
+ // Minimum execution time: 3_936_000 picoseconds.
+ Weight::from_parts(4_033_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,8 +136,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
- // Minimum execution time: 26_047_000 picoseconds.
- Weight::from_parts(26_982_000, 3593)
+ // Minimum execution time: 26_274_000 picoseconds.
+ Weight::from_parts(26_609_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -161,8 +159,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `75`
// Estimated: `3593`
- // Minimum execution time: 51_076_000 picoseconds.
- Weight::from_parts(51_826_000, 3593)
+ // Minimum execution time: 52_888_000 picoseconds.
+ Weight::from_parts(53_835_000, 3593)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -182,8 +180,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `75`
// Estimated: `3540`
- // Minimum execution time: 30_606_000 picoseconds.
- Weight::from_parts(31_168_000, 3540)
+ // Minimum execution time: 33_395_000 picoseconds.
+ Weight::from_parts(33_827_000, 3540)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs
index bb850ac72c0..3e47cf077a2 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs
@@ -61,16 +61,8 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset())
}
- // Currently there is no trusted reserve (`IsReserve = ()`),
- // but we need this hack for `pallet_xcm::reserve_transfer_assets`
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7424
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7546
- fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
- // TODO: if we change `IsReserve = ...` then use this line...
- // TODO: or if remote weight estimation is fixed, then remove
- // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- hardcoded_weight.min(XcmFungibleWeight::::reserve_asset_deposited())
+ fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
+ assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset())
@@ -127,10 +119,7 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight {
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
index d6763d2fc66..f482064e84e 100644
--- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-09-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// target/production/polkadot-parachain
// benchmark
// pallet
-// --template=./templates/xcm-bench-template.hbs
-// --chain=asset-hub-westend-dev
-// --wasm-execution=compiled
-// --pallet=pallet_xcm_benchmarks::fungible
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --extrinsic=*
// --steps=50
// --repeat=20
-// --json
-// --header=./file_header.txt
-// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_benchmarks::fungible
+// --chain=asset-hub-westend-dev
+// --header=./cumulus/file_header.txt
+// --template=./cumulus/templates/xcm-bench-template.hbs
+// --output=./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
- // Minimum execution time: 25_411_000 picoseconds.
- Weight::from_parts(25_663_000, 3593)
+ // Minimum execution time: 25_407_000 picoseconds.
+ Weight::from_parts(25_949_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,8 +65,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
- // Minimum execution time: 49_478_000 picoseconds.
- Weight::from_parts(50_417_000, 6196)
+ // Minimum execution time: 51_335_000 picoseconds.
+ Weight::from_parts(52_090_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -90,8 +88,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `246`
// Estimated: `6196`
- // Minimum execution time: 72_958_000 picoseconds.
- Weight::from_parts(74_503_000, 6196)
+ // Minimum execution time: 74_312_000 picoseconds.
+ Weight::from_parts(76_725_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -101,8 +99,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 500_000_000_000 picoseconds.
- Weight::from_parts(500_000_000_000, 0)
+ // Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
+ Weight::from_parts(18_446_744_073_709_551_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -120,8 +118,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
- // Minimum execution time: 456_993_000 picoseconds.
- Weight::from_parts(469_393_000, 3610)
+ // Minimum execution time: 446_848_000 picoseconds.
+ Weight::from_parts(466_251_000, 3610)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -129,8 +127,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_580_000 picoseconds.
- Weight::from_parts(3_717_000, 0)
+ // Minimum execution time: 3_602_000 picoseconds.
+ Weight::from_parts(3_844_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,8 +136,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
- // Minimum execution time: 25_087_000 picoseconds.
- Weight::from_parts(25_788_000, 3593)
+ // Minimum execution time: 25_480_000 picoseconds.
+ Weight::from_parts(26_142_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -161,8 +159,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
- // Minimum execution time: 50_824_000 picoseconds.
- Weight::from_parts(52_309_000, 3610)
+ // Minimum execution time: 51_540_000 picoseconds.
+ Weight::from_parts(53_744_000, 3610)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -182,8 +180,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `145`
// Estimated: `3610`
- // Minimum execution time: 31_854_000 picoseconds.
- Weight::from_parts(32_553_000, 3610)
+ // Minimum execution time: 32_279_000 picoseconds.
+ Weight::from_parts(33_176_000, 3610)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs
index 0e740922f33..ded5dc6702e 100644
--- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs
@@ -61,16 +61,8 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset())
}
- // Currently there is no trusted reserve (`IsReserve = ()`),
- // but we need this hack for `pallet_xcm::reserve_transfer_assets`
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7424
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7546
- fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
- // TODO: if we change `IsReserve = ...` then use this line...
- // TODO: or if remote weight estimation is fixed, then remove
- // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- hardcoded_weight.min(XcmFungibleWeight::::reserve_asset_deposited())
+ fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
+ assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset())
@@ -127,10 +119,7 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight {
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
index 6c8c7ab66bb..17ee5cb6a8d 100644
--- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-09-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// target/production/polkadot-parachain
// benchmark
// pallet
-// --template=./templates/xcm-bench-template.hbs
-// --chain=bridge-hub-kusama-dev
-// --wasm-execution=compiled
-// --pallet=pallet_xcm_benchmarks::fungible
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --extrinsic=*
// --steps=50
// --repeat=20
-// --json
-// --header=./file_header.txt
-// --output=./parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_benchmarks::fungible
+// --chain=bridge-hub-kusama-dev
+// --header=./cumulus/file_header.txt
+// --template=./cumulus/templates/xcm-bench-template.hbs
+// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
- // Minimum execution time: 24_064_000 picoseconds.
- Weight::from_parts(24_751_000, 3593)
+ // Minimum execution time: 25_447_000 picoseconds.
+ Weight::from_parts(25_810_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,8 +65,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `153`
// Estimated: `6196`
- // Minimum execution time: 51_097_000 picoseconds.
- Weight::from_parts(51_960_000, 6196)
+ // Minimum execution time: 53_908_000 picoseconds.
+ Weight::from_parts(54_568_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -90,8 +88,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `6196`
- // Minimum execution time: 75_319_000 picoseconds.
- Weight::from_parts(77_356_000, 6196)
+ // Minimum execution time: 79_923_000 picoseconds.
+ Weight::from_parts(80_790_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -101,8 +99,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 500_000_000_000 picoseconds.
- Weight::from_parts(500_000_000_000, 0)
+ // Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
+ Weight::from_parts(18_446_744_073_709_551_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -120,8 +118,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
- // Minimum execution time: 29_392_000 picoseconds.
- Weight::from_parts(29_943_000, 3535)
+ // Minimum execution time: 31_923_000 picoseconds.
+ Weight::from_parts(32_499_000, 3535)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -129,8 +127,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_637_000 picoseconds.
- Weight::from_parts(3_720_000, 0)
+ // Minimum execution time: 3_903_000 picoseconds.
+ Weight::from_parts(4_065_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,8 +136,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `52`
// Estimated: `3593`
- // Minimum execution time: 25_045_000 picoseconds.
- Weight::from_parts(25_546_000, 3593)
+ // Minimum execution time: 26_987_000 picoseconds.
+ Weight::from_parts(27_486_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -161,8 +159,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `122`
// Estimated: `3593`
- // Minimum execution time: 51_450_000 picoseconds.
- Weight::from_parts(52_354_000, 3593)
+ // Minimum execution time: 56_012_000 picoseconds.
+ Weight::from_parts(58_067_000, 3593)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -182,8 +180,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
- // Minimum execution time: 29_711_000 picoseconds.
- Weight::from_parts(30_759_000, 3535)
+ // Minimum execution time: 32_350_000 picoseconds.
+ Weight::from_parts(33_403_000, 3535)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs
index 4f8c2dec7a8..7e9f2184272 100644
--- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs
@@ -61,16 +61,8 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset())
}
- // Currently there is no trusted reserve (`IsReserve = ()`),
- // but we need this hack for `pallet_xcm::reserve_transfer_assets`
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7424
- // (TODO) fix https://github.com/paritytech/polkadot/pull/7546
- fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
- // TODO: if we change `IsReserve = ...` then use this line...
- // TODO: or if remote weight estimation is fixed, then remove
- // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- hardcoded_weight.min(XcmFungibleWeight::::reserve_asset_deposited())
+ fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
+ assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset())
@@ -127,10 +119,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight {
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
@@ -154,10 +143,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight {
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> Weight {
- // Hardcoded till the XCM pallet is fixed
- let hardcoded_weight = Weight::from_parts(200_000_000_u64, 0);
- let weight = assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport());
- hardcoded_weight.min(weight)
+ assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport())
}
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::::report_holding()
diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
index 7c525dca051..f45f3936365 100644
--- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-09-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
-//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024
+//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
+//! WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024
// Executed Command:
-// ./target/production/polkadot-parachain
+// target/production/polkadot-parachain
// benchmark
// pallet
-// --template=./templates/xcm-bench-template.hbs
-// --chain=bridge-hub-polkadot-dev
-// --wasm-execution=compiled
-// --pallet=pallet_xcm_benchmarks::fungible
-// --no-storage-info
-// --no-median-slopes
-// --no-min-squares
-// --extrinsic=*
// --steps=50
// --repeat=20
-// --json
-// --header=./file_header.txt
-// --output=./parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
+// --extrinsic=*
+// --wasm-execution=compiled
+// --heap-pages=4096
+// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
+// --pallet=pallet_xcm_benchmarks::fungible
+// --chain=bridge-hub-polkadot-dev
+// --header=./cumulus/file_header.txt
+// --template=./cumulus/templates/xcm-bench-template.hbs
+// --output=./cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
- // Minimum execution time: 23_862_000 picoseconds.
- Weight::from_parts(24_603_000, 3593)
+ // Minimum execution time: 24_237_000 picoseconds.
+ Weight::from_parts(24_697_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,8 +65,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `153`
// Estimated: `6196`
- // Minimum execution time: 51_101_000 picoseconds.
- Weight::from_parts(51_976_000, 6196)
+ // Minimum execution time: 52_269_000 picoseconds.
+ Weight::from_parts(53_848_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -90,8 +88,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `6196`
- // Minimum execution time: 72_983_000 picoseconds.
- Weight::from_parts(74_099_000, 6196)
+ // Minimum execution time: 77_611_000 picoseconds.
+ Weight::from_parts(82_634_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -101,8 +99,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 500_000_000_000 picoseconds.
- Weight::from_parts(500_000_000_000, 0)
+ // Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
+ Weight::from_parts(18_446_744_073_709_551_000, 0)
}
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
@@ -120,8 +118,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
- // Minimum execution time: 27_131_000 picoseconds.
- Weight::from_parts(28_062_000, 3535)
+ // Minimum execution time: 29_506_000 picoseconds.
+ Weight::from_parts(30_269_000, 3535)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -129,8 +127,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 3_564_000 picoseconds.
- Weight::from_parts(3_738_000, 0)
+ // Minimum execution time: 3_541_000 picoseconds.
+ Weight::from_parts(3_629_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,8 +136,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `52`
// Estimated: `3593`
- // Minimum execution time: 24_453_000 picoseconds.
- Weight::from_parts(25_216_000, 3593)
+ // Minimum execution time: 25_651_000 picoseconds.
+ Weight::from_parts(26_078_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -161,8 +159,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `122`
// Estimated: `3593`
- // Minimum execution time: 48_913_000 picoseconds.
- Weight::from_parts(50_202_000, 3593)
+ // Minimum execution time: 52_050_000 picoseconds.
+ Weight::from_parts(53_293_000, 3593)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -182,8 +180,8 @@ impl WeightInfo {
// Proof Size summary in bytes:
// Measured: `70`
// Estimated: `3535`
- // Minimum execution time: 27_592_000 picoseconds.
- Weight::from_parts(28_099_000, 3535)
+ // Minimum execution time: 30_009_000 picoseconds.
+ Weight::from_parts(30_540_000, 3535)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs
index 40a2036fb49..78a0eed9174 100644
--- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs
+++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs
@@ -62,16 +62,8 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight