mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Fix Clippy (#2522)
* Import Clippy config from Polkadot Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Auto clippy fix Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * No tabs in comments Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Prefer matches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Dont drop references Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Trivial Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Refactor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * add clippy to ci * Clippy reborrow Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update client/pov-recovery/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/pov-recovery/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Partially revert 'Prefer matches' Using matches! instead of match does give less compiler checks as per review from @chevdor. Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update .cargo/config.toml Co-authored-by: Chevdor <chevdor@users.noreply.github.com> * Revert revert 💩 Should be fine to use matches! macro since it is an explicit whitelist, not wildcard matching. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: alvicsam <alvicsam@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Chevdor <chevdor@users.noreply.github.com> Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
b72ae577a0
commit
299d25ba4b
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# An auto defined `clippy` feature was introduced,
|
||||
# but it was found to clash with user defined features,
|
||||
# so was renamed to `cargo-clippy`.
|
||||
#
|
||||
# If you want standard clippy run:
|
||||
# RUSTFLAGS= cargo clippy
|
||||
[target.'cfg(feature = "cargo-clippy")']
|
||||
rustflags = [
|
||||
"-Aclippy::all",
|
||||
"-Dclippy::correctness",
|
||||
"-Aclippy::if-same-then-else",
|
||||
"-Aclippy::clone-double-ref",
|
||||
"-Dclippy::complexity",
|
||||
"-Aclippy::zero-prefixed-literal", # 00_1000_000
|
||||
"-Aclippy::type_complexity", # raison d'etre
|
||||
"-Aclippy::nonminimal-bool", # maybe
|
||||
"-Aclippy::borrowed-box", # Reasonable to fix this one
|
||||
"-Aclippy::too-many-arguments", # (Turning this on would lead to)
|
||||
"-Aclippy::unnecessary_cast", # Types may change
|
||||
"-Aclippy::identity-op", # One case where we do 0 +
|
||||
"-Aclippy::useless_conversion", # Types may change
|
||||
"-Aclippy::unit_arg", # styalistic.
|
||||
"-Aclippy::option-map-unit-fn", # styalistic
|
||||
"-Aclippy::bind_instead_of_map", # styalistic
|
||||
"-Aclippy::erasing_op", # E.g. 0 * DOLLARS
|
||||
"-Aclippy::eq_op", # In tests we test equality.
|
||||
"-Aclippy::while_immutable_condition", # false positives
|
||||
"-Aclippy::needless_option_as_deref", # false positives
|
||||
"-Aclippy::derivable_impls", # false positives
|
||||
"-Aclippy::stable_sort_primitive", # prefer stable sort
|
||||
]
|
||||
@@ -182,11 +182,7 @@ where
|
||||
// update runtime storage
|
||||
let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::<R, FI>(state_root);
|
||||
|
||||
FromBridgedChainMessagesDeliveryProof {
|
||||
bridged_header_hash: bridged_header_hash.into(),
|
||||
storage_proof,
|
||||
lane,
|
||||
}
|
||||
FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane }
|
||||
}
|
||||
|
||||
/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call.
|
||||
@@ -211,11 +207,7 @@ where
|
||||
let (_, bridged_header_hash) =
|
||||
insert_header_to_parachains_pallet::<R, PI, UnderlyingChainOf<BridgedChain<B>>>(state_root);
|
||||
|
||||
FromBridgedChainMessagesDeliveryProof {
|
||||
bridged_header_hash: bridged_header_hash.into(),
|
||||
storage_proof,
|
||||
lane,
|
||||
}
|
||||
FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane }
|
||||
}
|
||||
|
||||
/// Prepare in-memory message delivery proof, without inserting anything to the runtime storage.
|
||||
|
||||
@@ -60,7 +60,7 @@ where
|
||||
TrieDBMutBuilderV1::<RelayBlockHasher>::new(&mut mdb, &mut state_root).build();
|
||||
|
||||
// insert parachain heads
|
||||
for (i, parachain) in parachains.into_iter().enumerate() {
|
||||
for (i, parachain) in parachains.iter().enumerate() {
|
||||
let storage_key =
|
||||
parachain_head_storage_key_at_source(R::ParasPalletName::get(), *parachain);
|
||||
let leaf_data = if i == 0 {
|
||||
|
||||
@@ -139,7 +139,7 @@ benchmarks_instance_pallet! {
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||
verify {
|
||||
assert_eq!(
|
||||
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||
crate::InboundLanes::<T, I>::get(T::bench_lane_id()).last_delivered_nonce(),
|
||||
21,
|
||||
);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ benchmarks_instance_pallet! {
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight)
|
||||
verify {
|
||||
assert_eq!(
|
||||
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||
crate::InboundLanes::<T, I>::get(T::bench_lane_id()).last_delivered_nonce(),
|
||||
22,
|
||||
);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ benchmarks_instance_pallet! {
|
||||
});
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||
verify {
|
||||
let lane_state = crate::InboundLanes::<T, I>::get(&T::bench_lane_id());
|
||||
let lane_state = crate::InboundLanes::<T, I>::get(T::bench_lane_id());
|
||||
assert_eq!(lane_state.last_delivered_nonce(), 21);
|
||||
assert_eq!(lane_state.last_confirmed_nonce, 20);
|
||||
}
|
||||
@@ -240,7 +240,7 @@ benchmarks_instance_pallet! {
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||
verify {
|
||||
assert_eq!(
|
||||
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||
crate::InboundLanes::<T, I>::get(T::bench_lane_id()).last_delivered_nonce(),
|
||||
21,
|
||||
);
|
||||
}
|
||||
@@ -274,7 +274,7 @@ benchmarks_instance_pallet! {
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||
verify {
|
||||
assert_eq!(
|
||||
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||
crate::InboundLanes::<T, I>::get(T::bench_lane_id()).last_delivered_nonce(),
|
||||
21,
|
||||
);
|
||||
}
|
||||
@@ -432,7 +432,7 @@ benchmarks_instance_pallet! {
|
||||
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
|
||||
verify {
|
||||
assert_eq!(
|
||||
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
|
||||
crate::InboundLanes::<T, I>::get(T::bench_lane_id()).last_delivered_nonce(),
|
||||
21,
|
||||
);
|
||||
assert!(T::is_message_successfully_dispatched(21));
|
||||
|
||||
@@ -185,7 +185,7 @@ impl crate::benchmarking::Config<()> for TestRuntime {
|
||||
// in mock run we only care about benchmarks correctness, not the benchmark results
|
||||
// => ignore size related arguments
|
||||
let (messages, total_dispatch_weight) =
|
||||
params.message_nonces.into_iter().map(|n| message(n, REGULAR_PAYLOAD)).fold(
|
||||
params.message_nonces.map(|n| message(n, REGULAR_PAYLOAD)).fold(
|
||||
(Vec::new(), Weight::zero()),
|
||||
|(mut messages, total_dispatch_weight), message| {
|
||||
let weight = REGULAR_PAYLOAD.declared_weight;
|
||||
|
||||
@@ -104,7 +104,7 @@ benchmarks! {
|
||||
// create slash destination account
|
||||
let lane = LaneId([0, 0, 0, 0]);
|
||||
let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain);
|
||||
T::prepare_rewards_account(slash_destination.clone(), Zero::zero());
|
||||
T::prepare_rewards_account(slash_destination, Zero::zero());
|
||||
}: {
|
||||
crate::Pallet::<T>::slash_and_deregister(&relayer, slash_destination)
|
||||
}
|
||||
@@ -121,10 +121,10 @@ benchmarks! {
|
||||
let account_params =
|
||||
RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain);
|
||||
}: {
|
||||
crate::Pallet::<T>::register_relayer_reward(account_params.clone(), &relayer, One::one());
|
||||
crate::Pallet::<T>::register_relayer_reward(account_params, &relayer, One::one());
|
||||
}
|
||||
verify {
|
||||
assert_eq!(RelayerRewards::<T>::get(relayer, &account_params), Some(One::one()));
|
||||
assert_eq!(RelayerRewards::<T>::get(relayer, account_params), Some(One::one()));
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime)
|
||||
|
||||
@@ -93,7 +93,7 @@ impl PurgeChainCmd {
|
||||
io::stdin().read_line(&mut input)?;
|
||||
let input = input.trim();
|
||||
|
||||
match input.chars().nth(0) {
|
||||
match input.chars().next() {
|
||||
Some('y') | Some('Y') => {},
|
||||
_ => {
|
||||
println!("Aborted");
|
||||
@@ -103,7 +103,7 @@ impl PurgeChainCmd {
|
||||
}
|
||||
|
||||
for db_path in &db_paths {
|
||||
match fs::remove_dir_all(&db_path) {
|
||||
match fs::remove_dir_all(db_path) {
|
||||
Ok(_) => {
|
||||
println!("{:?} removed.", &db_path);
|
||||
},
|
||||
|
||||
@@ -270,16 +270,14 @@ where
|
||||
|
||||
let (header, extrinsics) = candidate.block.deconstruct();
|
||||
|
||||
let compact_proof = match candidate
|
||||
.proof
|
||||
.into_compact_proof::<HashFor<Block>>(last_head.state_root().clone())
|
||||
{
|
||||
Ok(proof) => proof,
|
||||
Err(e) => {
|
||||
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
|
||||
return None
|
||||
},
|
||||
};
|
||||
let compact_proof =
|
||||
match candidate.proof.into_compact_proof::<HashFor<Block>>(*last_head.state_root()) {
|
||||
Ok(proof) => proof,
|
||||
Err(e) => {
|
||||
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
|
||||
return None
|
||||
},
|
||||
};
|
||||
|
||||
// Create the parachain block data for the validators.
|
||||
let b = ParachainBlockData::<Block>::new(header, extrinsics, compact_proof);
|
||||
@@ -451,7 +449,7 @@ mod tests {
|
||||
.build()
|
||||
.expect("Builds overseer");
|
||||
|
||||
spawner.spawn("overseer", None, overseer.run().then(|_| async { () }).boxed());
|
||||
spawner.spawn("overseer", None, overseer.run().then(|_| async {}).boxed());
|
||||
|
||||
let collator_start = start_collator(StartCollatorParams {
|
||||
runtime_api: client.clone(),
|
||||
@@ -461,7 +459,7 @@ mod tests {
|
||||
spawner,
|
||||
para_id,
|
||||
key: CollatorPair::generate().0,
|
||||
parachain_consensus: Box::new(DummyParachainConsensus { client: client.clone() }),
|
||||
parachain_consensus: Box::new(DummyParachainConsensus { client }),
|
||||
});
|
||||
block_on(collator_start);
|
||||
|
||||
@@ -469,12 +467,10 @@ mod tests {
|
||||
.0
|
||||
.expect("message should be send by `start_collator` above.");
|
||||
|
||||
let config = match msg {
|
||||
CollationGenerationMessage::Initialize(config) => config,
|
||||
};
|
||||
let CollationGenerationMessage::Initialize(config) = msg;
|
||||
|
||||
let mut validation_data = PersistedValidationData::default();
|
||||
validation_data.parent_head = header.encode().into();
|
||||
let validation_data =
|
||||
PersistedValidationData { parent_head: header.encode().into(), ..Default::default() };
|
||||
let relay_parent = Default::default();
|
||||
|
||||
let collation = block_on((config.collator)(relay_parent, &validation_data))
|
||||
|
||||
@@ -51,7 +51,7 @@ pub struct ImportQueueParams<'a, I, C, CIDP, S> {
|
||||
}
|
||||
|
||||
/// Start an import queue for the Aura consensus algorithm.
|
||||
pub fn import_queue<'a, P, Block, I, C, S, CIDP>(
|
||||
pub fn import_queue<P, Block, I, C, S, CIDP>(
|
||||
ImportQueueParams {
|
||||
block_import,
|
||||
client,
|
||||
@@ -59,7 +59,7 @@ pub fn import_queue<'a, P, Block, I, C, S, CIDP>(
|
||||
spawner,
|
||||
registry,
|
||||
telemetry,
|
||||
}: ImportQueueParams<'a, I, C, CIDP, S>,
|
||||
}: ImportQueueParams<'_, I, C, CIDP, S>,
|
||||
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
|
||||
where
|
||||
Block: BlockT,
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
const LOG_TARGET: &'static str = "level-monitor";
|
||||
const LOG_TARGET: &str = "level-monitor";
|
||||
|
||||
/// Value good enough to be used with parachains using the current backend implementation
|
||||
/// that ships with Substrate. This value may change in the future.
|
||||
|
||||
@@ -325,7 +325,6 @@ async fn handle_new_block_imported<Block, P>(
|
||||
|
||||
match parachain.block_status(unset_hash) {
|
||||
Ok(BlockStatus::InChainWithState) => {
|
||||
drop(unset_best_header);
|
||||
let unset_best_header = unset_best_header_opt
|
||||
.take()
|
||||
.expect("We checked above that the value is set; qed");
|
||||
@@ -433,8 +432,11 @@ async fn handle_new_best_parachain_head<Block, P>(
|
||||
}
|
||||
}
|
||||
|
||||
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
|
||||
where
|
||||
async fn import_block_as_new_best<Block, P>(
|
||||
hash: Block::Hash,
|
||||
header: Block::Header,
|
||||
mut parachain: &P,
|
||||
) where
|
||||
Block: BlockT,
|
||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||
for<'a> &'a P: BlockImport<Block>,
|
||||
@@ -456,7 +458,7 @@ where
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
|
||||
block_import_params.import_existing = true;
|
||||
|
||||
if let Err(err) = (&*parachain).import_block(block_import_params).await {
|
||||
if let Err(err) = parachain.import_block(block_import_params).await {
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?hash,
|
||||
|
||||
@@ -337,7 +337,7 @@ fn follow_new_best_with_dummy_recovery_works() {
|
||||
Some(recovery_chan_tx),
|
||||
);
|
||||
|
||||
let block = build_block(&*client.clone(), None, None);
|
||||
let block = build_block(&*client, None, None);
|
||||
let block_clone = block.clone();
|
||||
let client_clone = client.clone();
|
||||
|
||||
@@ -547,7 +547,6 @@ fn do_not_set_best_block_to_older_block() {
|
||||
let client = Arc::new(TestClientBuilder::with_backend(backend).build());
|
||||
|
||||
let blocks = (0..NUM_BLOCKS)
|
||||
.into_iter()
|
||||
.map(|_| build_and_import_block(client.clone(), true))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -559,7 +558,6 @@ fn do_not_set_best_block_to_older_block() {
|
||||
let consensus =
|
||||
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}), None);
|
||||
|
||||
let client2 = client.clone();
|
||||
let work = async move {
|
||||
new_best_heads_sender
|
||||
.unbounded_send(blocks[NUM_BLOCKS - 2].header().clone())
|
||||
@@ -579,7 +577,7 @@ fn do_not_set_best_block_to_older_block() {
|
||||
});
|
||||
|
||||
// Build and import a new best block.
|
||||
build_and_import_block(client2.clone(), true);
|
||||
build_and_import_block(client, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -607,7 +605,6 @@ fn prune_blocks_on_level_overflow() {
|
||||
let id0 = block0.header.hash();
|
||||
|
||||
let blocks1 = (0..LEVEL_LIMIT)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -622,7 +619,6 @@ fn prune_blocks_on_level_overflow() {
|
||||
let id10 = blocks1[0].header.hash();
|
||||
|
||||
let blocks2 = (0..2)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -720,7 +716,6 @@ fn restore_limit_monitor() {
|
||||
let id00 = block00.header.hash();
|
||||
|
||||
let blocks1 = (0..LEVEL_LIMIT + 1)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -735,7 +730,6 @@ fn restore_limit_monitor() {
|
||||
let id10 = blocks1[0].header.hash();
|
||||
|
||||
let _ = (0..LEVEL_LIMIT)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
|
||||
@@ -161,7 +161,7 @@ where
|
||||
relay_parent: PHash,
|
||||
validation_data: &PersistedValidationData,
|
||||
) -> Option<ParachainCandidate<B>> {
|
||||
let proposer_future = self.proposer_factory.lock().init(&parent);
|
||||
let proposer_future = self.proposer_factory.lock().init(parent);
|
||||
|
||||
let proposer = proposer_future
|
||||
.await
|
||||
@@ -171,7 +171,7 @@ where
|
||||
.ok()?;
|
||||
|
||||
let inherent_data =
|
||||
self.inherent_data(parent.hash(), &validation_data, relay_parent).await?;
|
||||
self.inherent_data(parent.hash(), validation_data, relay_parent).await?;
|
||||
|
||||
let Proposal { block, storage_changes, proof } = proposer
|
||||
.propose(
|
||||
|
||||
@@ -129,7 +129,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
|
||||
para_id: 0u32.into(),
|
||||
relay_parent: PHash::random(),
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
@@ -293,7 +293,7 @@ async fn make_gossip_message_and_header(
|
||||
para_id: 0u32.into(),
|
||||
relay_parent,
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
@@ -484,7 +484,7 @@ async fn check_statement_seconded() {
|
||||
para_id: 0u32.into(),
|
||||
relay_parent: PHash::random(),
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//! 4a. After it is recovered, we restore the block and import it.
|
||||
//!
|
||||
//! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the block
|
||||
//! PoV is not yet available, we retry.
|
||||
//! PoV is not yet available, we retry.
|
||||
//!
|
||||
//! If we need to recover multiple PoV blocks (which should hopefully not happen in real life), we
|
||||
//! make sure that the blocks are imported in the correct order.
|
||||
@@ -190,7 +190,7 @@ impl<Block: BlockT> RecoveryQueue<Block> {
|
||||
/// Get the next hash for block recovery.
|
||||
pub async fn next_recovery(&mut self) -> Block::Hash {
|
||||
loop {
|
||||
if let Some(_) = self.signaling_queue.next().await {
|
||||
if self.signaling_queue.next().await.is_some() {
|
||||
if let Some(hash) = self.recovery_queue.pop_front() {
|
||||
return hash
|
||||
} else {
|
||||
@@ -309,10 +309,10 @@ where
|
||||
|
||||
/// Block is no longer waiting for recovery
|
||||
fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) {
|
||||
self.candidates.get_mut(block_hash).map(|candidate| {
|
||||
if let Some(candidate) = self.candidates.get_mut(block_hash) {
|
||||
// Prevents triggering an already enqueued recovery request
|
||||
candidate.waiting_recovery = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle a finalized block with the given `block_number`.
|
||||
|
||||
@@ -241,7 +241,7 @@ where
|
||||
self.full_client
|
||||
.import_notification_stream()
|
||||
.filter_map(|notification| async move {
|
||||
notification.is_new_best.then(|| notification.header)
|
||||
notification.is_new_best.then_some(notification.header)
|
||||
});
|
||||
Ok(Box::pin(notifications_stream))
|
||||
}
|
||||
@@ -428,7 +428,7 @@ mod tests {
|
||||
(
|
||||
client.clone(),
|
||||
block,
|
||||
RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle),
|
||||
RelayChainInProcessInterface::new(client, backend, dummy_network, mock_handle),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ mod tests {
|
||||
let hash = block.hash();
|
||||
|
||||
let ext = construct_transfer_extrinsic(
|
||||
&*client,
|
||||
&client,
|
||||
sp_keyring::Sr25519Keyring::Alice,
|
||||
sp_keyring::Sr25519Keyring::Bob,
|
||||
1000,
|
||||
|
||||
@@ -76,7 +76,7 @@ pub(crate) struct CollatorOverseerGenArgs<'a> {
|
||||
pub peer_set_protocol_names: PeerSetProtocolNames,
|
||||
}
|
||||
|
||||
fn build_overseer<'a>(
|
||||
fn build_overseer(
|
||||
connector: OverseerConnector,
|
||||
CollatorOverseerGenArgs {
|
||||
runtime_client,
|
||||
@@ -90,7 +90,7 @@ fn build_overseer<'a>(
|
||||
collator_pair,
|
||||
req_protocol_names,
|
||||
peer_set_protocol_names,
|
||||
}: CollatorOverseerGenArgs<'a>,
|
||||
}: CollatorOverseerGenArgs<'_>,
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<sc_service::SpawnTaskHandle>, Arc<BlockChainRpcClient>>, OverseerHandle),
|
||||
RelayChainError,
|
||||
|
||||
@@ -441,7 +441,7 @@ where
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("{e:?}"))?
|
||||
.ok_or_else(|| "Could not find parachain head in relay chain")?;
|
||||
.ok_or("Could not find parachain head in relay chain")?;
|
||||
|
||||
let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..])
|
||||
.map_err(|e| format!("Failed to decode parachain head: {e}"))?;
|
||||
|
||||
@@ -129,7 +129,7 @@ benchmarks! {
|
||||
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
}: {
|
||||
assert_ok!(
|
||||
<CollatorSelection<T>>::set_desired_candidates(origin, max.clone())
|
||||
<CollatorSelection<T>>::set_desired_candidates(origin, max)
|
||||
);
|
||||
}
|
||||
verify {
|
||||
@@ -142,7 +142,7 @@ benchmarks! {
|
||||
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
}: {
|
||||
assert_ok!(
|
||||
<CollatorSelection<T>>::set_candidacy_bond(origin, bond_amount.clone())
|
||||
<CollatorSelection<T>>::set_candidacy_bond(origin, bond_amount)
|
||||
);
|
||||
}
|
||||
verify {
|
||||
@@ -162,7 +162,7 @@ benchmarks! {
|
||||
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let bond: BalanceOf<T> = T::Currency::minimum_balance() * 2u32.into();
|
||||
T::Currency::make_free_balance_be(&caller, bond.clone());
|
||||
T::Currency::make_free_balance_be(&caller, bond);
|
||||
|
||||
<session::Pallet<T>>::set_keys(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
|
||||
@@ -238,8 +238,8 @@ pub mod pallet {
|
||||
"genesis desired_candidates are more than T::MaxCandidates",
|
||||
);
|
||||
|
||||
<DesiredCandidates<T>>::put(&self.desired_candidates);
|
||||
<CandidacyBond<T>>::put(&self.candidacy_bond);
|
||||
<DesiredCandidates<T>>::put(self.desired_candidates);
|
||||
<CandidacyBond<T>>::put(self.candidacy_bond);
|
||||
<Invulnerables<T>>::put(bounded_invulnerables);
|
||||
}
|
||||
}
|
||||
@@ -326,7 +326,7 @@ pub mod pallet {
|
||||
if max > T::MaxCandidates::get() {
|
||||
log::warn!("max > T::MaxCandidates; you might need to run benchmarks again");
|
||||
}
|
||||
<DesiredCandidates<T>>::put(&max);
|
||||
<DesiredCandidates<T>>::put(max);
|
||||
Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max });
|
||||
Ok(().into())
|
||||
}
|
||||
@@ -339,7 +339,7 @@ pub mod pallet {
|
||||
bond: BalanceOf<T>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::UpdateOrigin::ensure_origin(origin)?;
|
||||
<CandidacyBond<T>>::put(&bond);
|
||||
<CandidacyBond<T>>::put(bond);
|
||||
Self::deposit_event(Event::NewCandidacyBond { bond_amount: bond });
|
||||
Ok(().into())
|
||||
}
|
||||
|
||||
@@ -152,12 +152,12 @@ pub struct TestSessionHandler;
|
||||
impl pallet_session::SessionHandler<u64> for TestSessionHandler {
|
||||
const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID];
|
||||
fn on_genesis_session<Ks: OpaqueKeys>(keys: &[(u64, Ks)]) {
|
||||
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
|
||||
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
|
||||
}
|
||||
fn on_new_session<Ks: OpaqueKeys>(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) {
|
||||
SessionChangeBlock::set(System::block_number());
|
||||
dbg!(keys.len());
|
||||
SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::<Vec<_>>())
|
||||
SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::<Vec<_>>())
|
||||
}
|
||||
fn on_before_session_ending() {}
|
||||
fn on_disabled(_: u32) {}
|
||||
@@ -195,11 +195,7 @@ parameter_types! {
|
||||
pub struct IsRegistered;
|
||||
impl ValidatorRegistration<u64> for IsRegistered {
|
||||
fn is_registered(id: &u64) -> bool {
|
||||
if *id == 7u64 {
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
*id != 7u64
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ fn it_should_set_invulnerables() {
|
||||
|
||||
// cannot set with non-root.
|
||||
assert_noop!(
|
||||
CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set.clone()),
|
||||
CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set),
|
||||
BadOrigin
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ fn it_should_set_invulnerables() {
|
||||
assert_noop!(
|
||||
CollatorSelection::set_invulnerables(
|
||||
RuntimeOrigin::signed(RootAccount::get()),
|
||||
invulnerables.clone()
|
||||
invulnerables
|
||||
),
|
||||
Error::<Test>::ValidatorNotRegistered
|
||||
);
|
||||
@@ -184,8 +184,8 @@ fn cannot_register_dupe_candidate() {
|
||||
#[test]
|
||||
fn cannot_register_as_candidate_if_poor() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(Balances::free_balance(&3), 100);
|
||||
assert_eq!(Balances::free_balance(&33), 0);
|
||||
assert_eq!(Balances::free_balance(3), 100);
|
||||
assert_eq!(Balances::free_balance(33), 0);
|
||||
|
||||
// works
|
||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||
@@ -208,14 +208,14 @@ fn register_as_candidate_works() {
|
||||
assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);
|
||||
|
||||
// take two endowed, non-invulnerables accounts.
|
||||
assert_eq!(Balances::free_balance(&3), 100);
|
||||
assert_eq!(Balances::free_balance(&4), 100);
|
||||
assert_eq!(Balances::free_balance(3), 100);
|
||||
assert_eq!(Balances::free_balance(4), 100);
|
||||
|
||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3)));
|
||||
assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4)));
|
||||
|
||||
assert_eq!(Balances::free_balance(&3), 90);
|
||||
assert_eq!(Balances::free_balance(&4), 90);
|
||||
assert_eq!(Balances::free_balance(3), 90);
|
||||
assert_eq!(Balances::free_balance(4), 90);
|
||||
|
||||
assert_eq!(CollatorSelection::candidates().len(), 2);
|
||||
});
|
||||
|
||||
@@ -39,93 +39,91 @@ pub trait WeightInfo {
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
fn set_invulnerables(b: u32) -> Weight {
|
||||
Weight::from_parts(18_563_000 as u64, 0)
|
||||
Weight::from_parts(18_563_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
.saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn set_desired_candidates() -> Weight {
|
||||
Weight::from_parts(16_363_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(16_363_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn set_candidacy_bond() -> Weight {
|
||||
Weight::from_parts(16_840_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(16_840_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn register_as_candidate(c: u32) -> Weight {
|
||||
Weight::from_parts(71_196_000 as u64, 0)
|
||||
Weight::from_parts(71_196_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(4 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
.saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
fn leave_intent(c: u32) -> Weight {
|
||||
Weight::from_parts(55_336_000 as u64, 0)
|
||||
Weight::from_parts(55_336_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
.saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
fn note_author() -> Weight {
|
||||
Weight::from_parts(71_461_000 as u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as u64))
|
||||
Weight::from_parts(71_461_000_u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(4_u64))
|
||||
}
|
||||
fn new_session(r: u32, c: u32) -> Weight {
|
||||
Weight::from_parts(0 as u64, 0)
|
||||
Weight::from_parts(0_u64, 0)
|
||||
// Standard Error: 1_010_000
|
||||
.saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64))
|
||||
.saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64))
|
||||
// Standard Error: 1_010_000
|
||||
.saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64)))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
|
||||
.saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(r as u64)))
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64.saturating_mul(c as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(r as u64)))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(c as u64)))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn set_invulnerables(b: u32) -> Weight {
|
||||
Weight::from_parts(18_563_000 as u64, 0)
|
||||
Weight::from_parts(18_563_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
.saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn set_desired_candidates() -> Weight {
|
||||
Weight::from_parts(16_363_000 as u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(16_363_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn set_candidacy_bond() -> Weight {
|
||||
Weight::from_parts(16_840_000 as u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(16_840_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
fn register_as_candidate(c: u32) -> Weight {
|
||||
Weight::from_parts(71_196_000 as u64, 0)
|
||||
Weight::from_parts(71_196_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
.saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
fn leave_intent(c: u32) -> Weight {
|
||||
Weight::from_parts(55_336_000 as u64, 0)
|
||||
Weight::from_parts(55_336_000_u64, 0)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
.saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
fn note_author() -> Weight {
|
||||
Weight::from_parts(71_461_000 as u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as u64))
|
||||
Weight::from_parts(71_461_000_u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(4_u64))
|
||||
}
|
||||
fn new_session(r: u32, c: u32) -> Weight {
|
||||
Weight::from_parts(0 as u64, 0)
|
||||
Weight::from_parts(0_u64, 0)
|
||||
// Standard Error: 1_010_000
|
||||
.saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64))
|
||||
.saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64))
|
||||
// Standard Error: 1_010_000
|
||||
.saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64)))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64)))
|
||||
.saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(r as u64)))
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64.saturating_mul(c as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(r as u64)))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(c as u64)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -766,19 +766,19 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
let enqueued = vec![msg(1000), msg(1001)];
|
||||
enqueue(&enqueued);
|
||||
let weight_used = handle_messages(&vec![msg(1002)], Weight::from_parts(1500, 1500));
|
||||
let weight_used = handle_messages(&[msg(1002)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1000, 1000));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
assert_eq!(PageIndex::<Test>::get().begin_used, 0);
|
||||
|
||||
let weight_used = handle_messages(&vec![msg(1003)], Weight::from_parts(1500, 1500));
|
||||
let weight_used = handle_messages(&[msg(1003)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1001, 1001));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
assert_eq!(PageIndex::<Test>::get().begin_used, 1);
|
||||
|
||||
let weight_used = handle_messages(&vec![msg(1004)], Weight::from_parts(1500, 1500));
|
||||
let weight_used = handle_messages(&[msg(1004)], Weight::from_parts(1500, 1500));
|
||||
assert_eq!(weight_used, Weight::from_parts(1002, 1002));
|
||||
assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]);
|
||||
assert_eq!(pages_queued(), 2);
|
||||
@@ -877,9 +877,9 @@ mod tests {
|
||||
#[test]
|
||||
fn on_idle_should_service_queue() {
|
||||
new_test_ext().execute_with(|| {
|
||||
enqueue(&vec![msg(1000), msg(1001)]);
|
||||
enqueue(&vec![msg(1002), msg(1003)]);
|
||||
enqueue(&vec![msg(1004), msg(1005)]);
|
||||
enqueue(&[msg(1000), msg(1001)]);
|
||||
enqueue(&[msg(1002), msg(1003)]);
|
||||
enqueue(&[msg(1004), msg(1005)]);
|
||||
|
||||
let weight_used = DmpQueue::on_idle(1, Weight::from_parts(6000, 6000));
|
||||
assert_eq!(weight_used, Weight::from_parts(5010, 5010));
|
||||
@@ -901,20 +901,17 @@ mod tests {
|
||||
#[test]
|
||||
fn handle_max_messages_per_block() {
|
||||
new_test_ext().execute_with(|| {
|
||||
enqueue(&vec![msg(1000), msg(1001)]);
|
||||
enqueue(&vec![msg(1002), msg(1003)]);
|
||||
enqueue(&vec![msg(1004), msg(1005)]);
|
||||
enqueue(&[msg(1000), msg(1001)]);
|
||||
enqueue(&[msg(1002), msg(1003)]);
|
||||
enqueue(&[msg(1004), msg(1005)]);
|
||||
|
||||
let incoming = (0..MAX_MESSAGES_PER_BLOCK)
|
||||
.into_iter()
|
||||
.map(|i| msg(1006 + i as u64))
|
||||
.collect::<Vec<_>>();
|
||||
let incoming =
|
||||
(0..MAX_MESSAGES_PER_BLOCK).map(|i| msg(1006 + i as u64)).collect::<Vec<_>>();
|
||||
handle_messages(&incoming, Weight::from_parts(25000, 25000));
|
||||
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
(0..MAX_MESSAGES_PER_BLOCK)
|
||||
.into_iter()
|
||||
.map(|i| msg_complete(1000 + i as u64))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
@@ -924,7 +921,6 @@ mod tests {
|
||||
assert_eq!(
|
||||
take_trace(),
|
||||
(MAX_MESSAGES_PER_BLOCK..MAX_MESSAGES_PER_BLOCK + 6)
|
||||
.into_iter()
|
||||
.map(|i| msg_complete(1000 + i as u64))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
@@ -74,7 +74,7 @@ pub fn migrate_to_v1<T: Config>() -> Weight {
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(_) = Configuration::<T>::translate(|pre| pre.map(translate)) {
|
||||
if Configuration::<T>::translate(|pre| pre.map(translate)).is_err() {
|
||||
log::error!(
|
||||
target: "dmp_queue",
|
||||
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
|
||||
|
||||
@@ -473,10 +473,7 @@ pub mod pallet {
|
||||
check_version: bool,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
AuthorizedUpgrade::<T>::put(CodeUpgradeAuthorization {
|
||||
code_hash: code_hash.clone(),
|
||||
check_version,
|
||||
});
|
||||
AuthorizedUpgrade::<T>::put(CodeUpgradeAuthorization { code_hash, check_version });
|
||||
|
||||
Self::deposit_event(Event::UpgradeAuthorized { code_hash });
|
||||
Ok(())
|
||||
@@ -753,7 +750,7 @@ impl<T: Config> Pallet<T> {
|
||||
let authorization = AuthorizedUpgrade::<T>::get().ok_or(Error::<T>::NothingAuthorized)?;
|
||||
|
||||
// ensure that the actual hash matches the authorized hash
|
||||
let actual_hash = T::Hashing::hash(&code[..]);
|
||||
let actual_hash = T::Hashing::hash(code);
|
||||
ensure!(actual_hash == authorization.code_hash, Error::<T>::Unauthorized);
|
||||
|
||||
// check versions if required as part of the authorization
|
||||
@@ -941,10 +938,10 @@ impl<T: Config> Pallet<T> {
|
||||
// `running_mqc_heads`. Otherwise, in a block where no messages were sent in a channel
|
||||
// it won't get into next block's `last_mqc_heads` and thus will be all zeros, which
|
||||
// would corrupt the message queue chain.
|
||||
for &(ref sender, ref channel) in ingress_channels {
|
||||
for (sender, channel) in ingress_channels {
|
||||
let cur_head = running_mqc_heads
|
||||
.entry(sender)
|
||||
.or_insert_with(|| last_mqc_heads.get(&sender).cloned().unwrap_or_default())
|
||||
.or_insert_with(|| last_mqc_heads.get(sender).cloned().unwrap_or_default())
|
||||
.head();
|
||||
let target_head = channel.mqc_head.unwrap_or_default();
|
||||
|
||||
@@ -1090,22 +1087,20 @@ impl<T: Config> Pallet<T> {
|
||||
// may change so that the message is no longer valid.
|
||||
//
|
||||
// However, changing this setting is expected to be rare.
|
||||
match Self::host_configuration() {
|
||||
Some(cfg) =>
|
||||
if message.len() > cfg.max_upward_message_size as usize {
|
||||
return Err(MessageSendError::TooBig)
|
||||
},
|
||||
None => {
|
||||
// This storage field should carry over from the previous block. So if it's None
|
||||
// then it must be that this is an edge-case where a message is attempted to be
|
||||
// sent at the first block.
|
||||
//
|
||||
// Let's pass this message through. I think it's not unreasonable to expect that
|
||||
// the message is not huge and it comes through, but if it doesn't it can be
|
||||
// returned back to the sender.
|
||||
//
|
||||
// Thus fall through here.
|
||||
},
|
||||
if let Some(cfg) = Self::host_configuration() {
|
||||
if message.len() > cfg.max_upward_message_size as usize {
|
||||
return Err(MessageSendError::TooBig)
|
||||
}
|
||||
} else {
|
||||
// This storage field should carry over from the previous block. So if it's None
|
||||
// then it must be that this is an edge-case where a message is attempted to be
|
||||
// sent at the first block.
|
||||
//
|
||||
// Let's pass this message through. I think it's not unreasonable to expect that
|
||||
// the message is not huge and it comes through, but if it doesn't it can be
|
||||
// returned back to the sender.
|
||||
//
|
||||
// Thus fall through here.
|
||||
};
|
||||
<PendingUpwardMessages<T>>::append(message.clone());
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ impl BlockTests {
|
||||
|
||||
// begin initialization
|
||||
System::reset_events();
|
||||
System::initialize(&n, &Default::default(), &Default::default());
|
||||
System::initialize(n, &Default::default(), &Default::default());
|
||||
|
||||
// now mess with the storage the way validate_block does
|
||||
let mut sproof_builder = RelayStateSproofBuilder::default();
|
||||
@@ -357,10 +357,8 @@ impl BlockTests {
|
||||
ParachainSystem::on_finalize(*n);
|
||||
|
||||
// did block execution set new validation code?
|
||||
if NewValidationCode::<Test>::exists() {
|
||||
if self.pending_upgrade.is_some() {
|
||||
panic!("attempted to set validation code while upgrade was pending");
|
||||
}
|
||||
if NewValidationCode::<Test>::exists() && self.pending_upgrade.is_some() {
|
||||
panic!("attempted to set validation code while upgrade was pending");
|
||||
}
|
||||
|
||||
// clean up
|
||||
@@ -404,7 +402,7 @@ fn events() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored.into())
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored)
|
||||
);
|
||||
},
|
||||
)
|
||||
@@ -415,10 +413,9 @@ fn events() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
RuntimeEvent::ParachainSystem(
|
||||
crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 }
|
||||
.into()
|
||||
)
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionApplied {
|
||||
relay_chain_block_num: 1234
|
||||
})
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -491,7 +488,7 @@ fn aborted_upgrade() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into())
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded)
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -41,7 +41,7 @@ fn call_validate_block_encoded_header(
|
||||
relay_parent_number: 1,
|
||||
relay_parent_storage_root,
|
||||
},
|
||||
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
|
||||
WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
|
||||
)
|
||||
.map(|v| v.head_data.0)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ fn validate_block_invalid_parent_hash() {
|
||||
.unwrap_err();
|
||||
} else {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&["validate_block_invalid_parent_hash", "--", "--nocapture"])
|
||||
.args(["validate_block_invalid_parent_hash", "--", "--nocapture"])
|
||||
.env("RUN_TEST", "1")
|
||||
.output()
|
||||
.expect("Runs the test");
|
||||
@@ -213,7 +213,7 @@ fn validate_block_fails_on_invalid_validation_data() {
|
||||
call_validate_block(parent_head, block, Hash::random()).unwrap_err();
|
||||
} else {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"])
|
||||
.args(["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"])
|
||||
.env("RUN_TEST", "1")
|
||||
.output()
|
||||
.expect("Runs the test");
|
||||
@@ -242,7 +242,7 @@ fn check_inherent_fails_on_validate_block_as_expected() {
|
||||
.unwrap_err();
|
||||
} else {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"])
|
||||
.args(["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"])
|
||||
.env("RUN_TEST", "1")
|
||||
.output()
|
||||
.expect("Runs the test");
|
||||
@@ -276,7 +276,7 @@ fn check_inherents_are_unsigned_and_before_all_other_extrinsics() {
|
||||
.unwrap_err();
|
||||
} else {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&[
|
||||
.args([
|
||||
"check_inherents_are_unsigned_and_before_all_other_extrinsics",
|
||||
"--",
|
||||
"--nocapture",
|
||||
|
||||
@@ -538,7 +538,7 @@ impl<T: Config> Pallet<T> {
|
||||
return false
|
||||
}
|
||||
s.extend_from_slice(&data[..]);
|
||||
return true
|
||||
true
|
||||
});
|
||||
if appended {
|
||||
Ok((details.last_index - details.first_index - 1) as u32)
|
||||
|
||||
@@ -94,7 +94,7 @@ pub fn migrate_to_v2<T: Config>() -> Weight {
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(_) = QueueConfig::<T>::translate(|pre| pre.map(translate)) {
|
||||
if QueueConfig::<T>::translate(|pre| pre.map(translate)).is_err() {
|
||||
log::error!(
|
||||
target: super::LOG_TARGET,
|
||||
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
|
||||
|
||||
@@ -120,7 +120,7 @@ impl cumulus_pallet_parachain_system::Config for Test {
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayChain: MultiLocation = MultiLocation::parent();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into();
|
||||
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32));
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
|
||||
@@ -23,7 +23,7 @@ use sp_runtime::traits::BadOrigin;
|
||||
fn one_message_does_not_panic() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
||||
let messages = vec![(Default::default(), 1u32.into(), message_format.as_slice())];
|
||||
let messages = vec![(Default::default(), 1u32, message_format.as_slice())];
|
||||
|
||||
// This shouldn't cause a panic
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
@@ -128,7 +128,7 @@ fn suspend_xcm_execution_works() {
|
||||
.encode();
|
||||
let mut message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
|
||||
message_format.extend(xcm.clone());
|
||||
let messages = vec![(ParaId::from(999), 1u32.into(), message_format.as_slice())];
|
||||
let messages = vec![(ParaId::from(999), 1u32, message_format.as_slice())];
|
||||
|
||||
// This should have executed the incoming XCM, because it came from a system parachain
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
@@ -136,7 +136,7 @@ fn suspend_xcm_execution_works() {
|
||||
let queued_xcm = InboundXcmpMessages::<Test>::get(ParaId::from(999), 1u32);
|
||||
assert!(queued_xcm.is_empty());
|
||||
|
||||
let messages = vec![(ParaId::from(2000), 1u32.into(), message_format.as_slice())];
|
||||
let messages = vec![(ParaId::from(2000), 1u32, message_format.as_slice())];
|
||||
|
||||
// This shouldn't have executed the incoming XCM
|
||||
XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::MAX);
|
||||
@@ -294,7 +294,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
|
||||
|
||||
// XcmpQueue - check dest is really not applicable
|
||||
let dest = (Parent, Parent, Parent);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut dest_wrapper = Some(dest.into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert_eq!(
|
||||
Err(SendError::NotApplicable),
|
||||
@@ -302,7 +302,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
|
||||
);
|
||||
|
||||
// check wrapper were not consumed
|
||||
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
|
||||
assert_eq!(Some(dest.into()), dest_wrapper.take());
|
||||
assert_eq!(Some(message.clone()), msg_wrapper.take());
|
||||
|
||||
// another try with router chain with asserting sender
|
||||
@@ -322,7 +322,7 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
|
||||
|
||||
// XcmpQueue - check dest/msg is valid
|
||||
let dest = (Parent, X1(Parachain(5555)));
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut dest_wrapper = Some(dest.into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert!(<XcmpQueue as SendXcm>::validate(&mut dest_wrapper, &mut msg_wrapper).is_ok());
|
||||
|
||||
|
||||
@@ -18,31 +18,31 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_u32() -> Weight {
|
||||
Weight::from_parts(2_717_000 as u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(2_717_000_u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_weight() -> Weight {
|
||||
Weight::from_parts(2_717_000 as u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(2_717_000_u64, 0)
|
||||
.saturating_add(T::DbWeight::get().reads(1_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
impl WeightInfo for () {
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_u32() -> Weight {
|
||||
Weight::from_parts(2_717_000 as u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(2_717_000_u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
|
||||
// Storage: XcmpQueue QueueConfig (r:1 w:1)
|
||||
fn set_config_with_weight() -> Weight {
|
||||
Weight::from_parts(2_717_000 as u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
Weight::from_parts(2_717_000_u64, 0)
|
||||
.saturating_add(RocksDbWeight::get().reads(1_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,13 +268,13 @@ pub fn run() -> Result<()> {
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
let hwbench = (!cli.no_hardware_benchmarks).then_some(
|
||||
config.database.path().map(|database_path| {
|
||||
let _ = std::fs::create_dir_all(&database_path);
|
||||
let _ = std::fs::create_dir_all(database_path);
|
||||
sc_sysinfo::gather_hwbench(Some(database_path))
|
||||
})).flatten();
|
||||
|
||||
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
|
||||
.map(|e| e.para_id)
|
||||
.ok_or_else(|| "Could not find parachain ID in chain-spec.")?;
|
||||
.ok_or("Could not find parachain ID in chain-spec.")?;
|
||||
|
||||
let polkadot_cli = RelayChainCli::new(
|
||||
&config,
|
||||
@@ -301,7 +301,7 @@ pub fn run() -> Result<()> {
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relay_chain_args.len() > 0 {
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() {
|
||||
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
|
||||
}
|
||||
|
||||
|
||||
@@ -686,13 +686,13 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig
|
||||
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch};
|
||||
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
|
||||
@@ -278,7 +278,6 @@ mod tests {
|
||||
}
|
||||
|
||||
let asset_location = SomeSiblingParachain::get()
|
||||
.clone()
|
||||
.pushed_with_interior(GeneralIndex(42))
|
||||
.expect("multilocation will only have 2 junctions; qed");
|
||||
let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000u128.into() };
|
||||
|
||||
@@ -53,7 +53,7 @@ pub mod pallet {
|
||||
#[pallet::genesis_build]
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig {
|
||||
fn build(&self) {
|
||||
<ParachainId<T>>::put(&self.parachain_id);
|
||||
<ParachainId<T>>::put(self.parachain_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ where
|
||||
asset_location: &MultiLocation,
|
||||
) -> sp_std::result::Result<Self::Success, RuntimeOrigin> {
|
||||
let origin_location = EnsureXcm::<Everything>::try_origin(origin.clone())?;
|
||||
if !IsForeign::contains(&asset_location, &origin_location) {
|
||||
if !IsForeign::contains(asset_location, &origin_location) {
|
||||
return Err(origin)
|
||||
}
|
||||
AccountOf::convert(origin_location).map_err(|_| origin)
|
||||
@@ -51,6 +51,6 @@ where
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn try_successful_origin(a: &MultiLocation) -> Result<RuntimeOrigin, ()> {
|
||||
Ok(pallet_xcm::Origin::Xcm(a.clone()).into())
|
||||
Ok(pallet_xcm::Origin::Xcm(*a).into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,7 @@ impl<Network: Get<NetworkId>> Contains<MultiLocation>
|
||||
for StartsWithExplicitGlobalConsensus<Network>
|
||||
{
|
||||
fn contains(t: &MultiLocation) -> bool {
|
||||
match t.interior.global_consensus() {
|
||||
Ok(requested_network) if requested_network.eq(&Network::get()) => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(t.interior.global_consensus(), Ok(requested_network) if requested_network.eq(&Network::get()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +58,7 @@ impl<IsForeign: ContainsPair<MultiLocation, MultiLocation>> ContainsPair<MultiAs
|
||||
{
|
||||
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
|
||||
log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin);
|
||||
matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, &origin))
|
||||
matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, origin))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,18 +70,14 @@ impl<SelfParaId: Get<ParaId>> ContainsPair<MultiLocation, MultiLocation>
|
||||
{
|
||||
fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool {
|
||||
// `a` needs to be from `b` at least
|
||||
if !a.starts_with(&b) {
|
||||
if !a.starts_with(b) {
|
||||
return false
|
||||
}
|
||||
|
||||
// here we check if sibling
|
||||
match a {
|
||||
MultiLocation { parents: 1, interior } => match interior.first() {
|
||||
Some(Parachain(sibling_para_id))
|
||||
if sibling_para_id.ne(&u32::from(SelfParaId::get())) =>
|
||||
true,
|
||||
_ => false,
|
||||
},
|
||||
MultiLocation { parents: 1, interior } =>
|
||||
matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -1026,7 +1026,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -1062,7 +1062,6 @@ impl_runtime_apis! {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: Fungible(fungibles_amount * i as u128),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
@@ -1082,7 +1081,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
KsmLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
|
||||
@@ -1097,7 +1096,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(KsmLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1201,7 +1200,7 @@ cumulus_pallet_parachain_system::register_validate_block! {
|
||||
#[cfg(feature = "state-trie-version-1")]
|
||||
parameter_types! {
|
||||
// The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high)
|
||||
pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
|
||||
pub const MigrationSignedDepositPerItem: Balance = CENTS;
|
||||
pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS;
|
||||
pub const MigrationMaxKeyLen: u32 = 512;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -123,7 +122,7 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
@@ -197,151 +197,146 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::ForeignAssets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::ForeignAssets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::set_metadata { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Nfts(
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::set_metadata { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::Nfts(
|
||||
pallet_nfts::Call::create { .. } |
|
||||
pallet_nfts::Call::force_create { .. } |
|
||||
pallet_nfts::Call::destroy { .. } |
|
||||
pallet_nfts::Call::mint { .. } |
|
||||
pallet_nfts::Call::force_mint { .. } |
|
||||
pallet_nfts::Call::burn { .. } |
|
||||
pallet_nfts::Call::transfer { .. } |
|
||||
pallet_nfts::Call::lock_item_transfer { .. } |
|
||||
pallet_nfts::Call::unlock_item_transfer { .. } |
|
||||
pallet_nfts::Call::lock_collection { .. } |
|
||||
pallet_nfts::Call::transfer_ownership { .. } |
|
||||
pallet_nfts::Call::set_team { .. } |
|
||||
pallet_nfts::Call::force_collection_owner { .. } |
|
||||
pallet_nfts::Call::force_collection_config { .. } |
|
||||
pallet_nfts::Call::approve_transfer { .. } |
|
||||
pallet_nfts::Call::cancel_approval { .. } |
|
||||
pallet_nfts::Call::clear_all_transfer_approvals { .. } |
|
||||
pallet_nfts::Call::lock_item_properties { .. } |
|
||||
pallet_nfts::Call::set_attribute { .. } |
|
||||
pallet_nfts::Call::force_set_attribute { .. } |
|
||||
pallet_nfts::Call::clear_attribute { .. } |
|
||||
pallet_nfts::Call::approve_item_attributes { .. } |
|
||||
pallet_nfts::Call::cancel_item_attributes_approval { .. } |
|
||||
pallet_nfts::Call::set_metadata { .. } |
|
||||
pallet_nfts::Call::clear_metadata { .. } |
|
||||
pallet_nfts::Call::set_collection_metadata { .. } |
|
||||
pallet_nfts::Call::clear_collection_metadata { .. } |
|
||||
pallet_nfts::Call::set_accept_ownership { .. } |
|
||||
pallet_nfts::Call::set_collection_max_supply { .. } |
|
||||
pallet_nfts::Call::update_mint_settings { .. } |
|
||||
pallet_nfts::Call::set_price { .. } |
|
||||
pallet_nfts::Call::buy_item { .. } |
|
||||
pallet_nfts::Call::pay_tips { .. } |
|
||||
pallet_nfts::Call::create_swap { .. } |
|
||||
pallet_nfts::Call::cancel_swap { .. } |
|
||||
pallet_nfts::Call::claim_swap { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
pallet_nfts::Call::force_create { .. } |
|
||||
pallet_nfts::Call::destroy { .. } |
|
||||
pallet_nfts::Call::mint { .. } |
|
||||
pallet_nfts::Call::force_mint { .. } |
|
||||
pallet_nfts::Call::burn { .. } |
|
||||
pallet_nfts::Call::transfer { .. } |
|
||||
pallet_nfts::Call::lock_item_transfer { .. } |
|
||||
pallet_nfts::Call::unlock_item_transfer { .. } |
|
||||
pallet_nfts::Call::lock_collection { .. } |
|
||||
pallet_nfts::Call::transfer_ownership { .. } |
|
||||
pallet_nfts::Call::set_team { .. } |
|
||||
pallet_nfts::Call::force_collection_owner { .. } |
|
||||
pallet_nfts::Call::force_collection_config { .. } |
|
||||
pallet_nfts::Call::approve_transfer { .. } |
|
||||
pallet_nfts::Call::cancel_approval { .. } |
|
||||
pallet_nfts::Call::clear_all_transfer_approvals { .. } |
|
||||
pallet_nfts::Call::lock_item_properties { .. } |
|
||||
pallet_nfts::Call::set_attribute { .. } |
|
||||
pallet_nfts::Call::force_set_attribute { .. } |
|
||||
pallet_nfts::Call::clear_attribute { .. } |
|
||||
pallet_nfts::Call::approve_item_attributes { .. } |
|
||||
pallet_nfts::Call::cancel_item_attributes_approval { .. } |
|
||||
pallet_nfts::Call::set_metadata { .. } |
|
||||
pallet_nfts::Call::clear_metadata { .. } |
|
||||
pallet_nfts::Call::set_collection_metadata { .. } |
|
||||
pallet_nfts::Call::clear_collection_metadata { .. } |
|
||||
pallet_nfts::Call::set_accept_ownership { .. } |
|
||||
pallet_nfts::Call::set_collection_max_supply { .. } |
|
||||
pallet_nfts::Call::update_mint_settings { .. } |
|
||||
pallet_nfts::Call::set_price { .. } |
|
||||
pallet_nfts::Call::buy_item { .. } |
|
||||
pallet_nfts::Call::pay_tips { .. } |
|
||||
pallet_nfts::Call::create_swap { .. } |
|
||||
pallet_nfts::Call::cancel_swap { .. } |
|
||||
pallet_nfts::Call::claim_swap { .. },
|
||||
) | RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. }
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,19 +77,16 @@ fn test_asset_xcm_trader() {
|
||||
// Lets pay with: asset_amount_needed + asset_amount_extra
|
||||
let asset_amount_extra = 100_u128;
|
||||
let asset: MultiAsset =
|
||||
(asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into();
|
||||
(asset_multilocation, asset_amount_needed + asset_amount_extra).into();
|
||||
|
||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||
|
||||
// Lets buy_weight and make sure buy_weight does not return an error
|
||||
match trader.buy_weight(bought, asset.into()) {
|
||||
Ok(unused_assets) => {
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(unused_assets
|
||||
.ensure_contains(&(asset_multilocation, asset_amount_extra).into()));
|
||||
},
|
||||
Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e),
|
||||
}
|
||||
let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok");
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(
|
||||
unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())
|
||||
);
|
||||
|
||||
// Drop trader
|
||||
drop(trader);
|
||||
@@ -150,7 +147,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Make sure buy_weight does not return an error
|
||||
assert_ok!(trader.buy_weight(bought, asset.clone().into()));
|
||||
@@ -224,7 +221,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
"we are testing what happens when the amount does not exceed ED"
|
||||
);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Buy weight should return an error
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
@@ -277,11 +274,11 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
|
||||
// We know we will have to buy at least ED, so lets make sure first it will
|
||||
// fail with a payment of less than ED
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
|
||||
// Now lets buy ED at least
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into();
|
||||
let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into();
|
||||
|
||||
// Buy weight should work
|
||||
assert_ok!(trader.buy_weight(bought, asset.into()));
|
||||
@@ -416,7 +413,7 @@ fn test_assets_balances_api_works() {
|
||||
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
||||
assert_ok!(ForeignAssets::force_create(
|
||||
RuntimeHelper::<Runtime>::root_origin(),
|
||||
foreign_asset_id_multilocation.clone().into(),
|
||||
foreign_asset_id_multilocation,
|
||||
AccountId::from(SOME_ASSET_ADMIN).into(),
|
||||
false,
|
||||
foreign_asset_minimum_asset_balance
|
||||
@@ -425,7 +422,7 @@ fn test_assets_balances_api_works() {
|
||||
// We first mint enough asset for the account to exist for assets
|
||||
assert_ok!(ForeignAssets::mint(
|
||||
RuntimeHelper::<Runtime>::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
||||
foreign_asset_id_multilocation.clone().into(),
|
||||
foreign_asset_id_multilocation,
|
||||
AccountId::from(ALICE).into(),
|
||||
6 * foreign_asset_minimum_asset_balance
|
||||
));
|
||||
|
||||
@@ -223,7 +223,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -925,7 +925,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -960,7 +960,6 @@ impl_runtime_apis! {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: Fungible(fungibles_amount * i as u128),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
@@ -980,7 +979,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
DotLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(DotLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
@@ -994,7 +993,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(DotLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -123,7 +122,7 @@ impl<Call> XcmWeightInfo<Call> for StatemintXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
@@ -166,85 +166,82 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. } |
|
||||
pallet_collator_selection::Call::set_invulnerables { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. } |
|
||||
pallet_collator_selection::Call::set_invulnerables { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,19 +80,16 @@ fn test_asset_xcm_trader() {
|
||||
// Lets pay with: asset_amount_needed + asset_amount_extra
|
||||
let asset_amount_extra = 100_u128;
|
||||
let asset: MultiAsset =
|
||||
(asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into();
|
||||
(asset_multilocation, asset_amount_needed + asset_amount_extra).into();
|
||||
|
||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||
|
||||
// Lets buy_weight and make sure buy_weight does not return an error
|
||||
match trader.buy_weight(bought, asset.into()) {
|
||||
Ok(unused_assets) => {
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(unused_assets
|
||||
.ensure_contains(&(asset_multilocation, asset_amount_extra).into()));
|
||||
},
|
||||
Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e),
|
||||
}
|
||||
let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok");
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(
|
||||
unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())
|
||||
);
|
||||
|
||||
// Drop trader
|
||||
drop(trader);
|
||||
@@ -156,7 +153,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Make sure buy_weight does not return an error
|
||||
assert_ok!(trader.buy_weight(bought, asset.clone().into()));
|
||||
@@ -233,7 +230,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
"we are testing what happens when the amount does not exceed ED"
|
||||
);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Buy weight should return an error
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
@@ -286,11 +283,11 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
|
||||
// We know we will have to buy at least ED, so lets make sure first it will
|
||||
// fail with a payment of less than ED
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
|
||||
// Now lets buy ED at least
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into();
|
||||
let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into();
|
||||
|
||||
// Buy weight should work
|
||||
assert_ok!(trader.buy_weight(bought, asset.into()));
|
||||
|
||||
@@ -134,12 +134,12 @@ impl<
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pallet_balances::GenesisConfig::<Runtime> { balances: self.balances.into() }
|
||||
pallet_balances::GenesisConfig::<Runtime> { balances: self.balances }
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
|
||||
pallet_collator_selection::GenesisConfig::<Runtime> {
|
||||
invulnerables: self.collators.clone().into(),
|
||||
invulnerables: self.collators.clone(),
|
||||
candidacy_bond: Default::default(),
|
||||
desired_candidates: Default::default(),
|
||||
}
|
||||
@@ -303,11 +303,10 @@ impl<Runtime: frame_system::Config + pallet_xcm::Config> RuntimeHelper<Runtime>
|
||||
.find_map(|e| match e {
|
||||
pallet_xcm::Event::Attempted(outcome) => Some(outcome),
|
||||
_ => None,
|
||||
});
|
||||
match outcome {
|
||||
Some(outcome) => assert_outcome(outcome),
|
||||
None => assert!(false, "No `pallet_xcm::Event::Attempted(outcome)` event found!"),
|
||||
}
|
||||
})
|
||||
.expect("No `pallet_xcm::Event::Attempted(outcome)` event found!");
|
||||
|
||||
assert_outcome(outcome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,8 +361,11 @@ pub fn mock_open_hrmp_channel<
|
||||
recipient: ParaId,
|
||||
) {
|
||||
let n = 1_u32;
|
||||
let mut sproof_builder = RelayStateSproofBuilder::default();
|
||||
sproof_builder.para_id = sender;
|
||||
let mut sproof_builder = RelayStateSproofBuilder {
|
||||
para_id: sender,
|
||||
hrmp_egress_channel_index: Some(vec![recipient]),
|
||||
..Default::default()
|
||||
};
|
||||
sproof_builder.hrmp_channels.insert(
|
||||
HrmpChannelId { sender, recipient },
|
||||
AbridgedHrmpChannel {
|
||||
@@ -375,7 +377,6 @@ pub fn mock_open_hrmp_channel<
|
||||
mqc_head: None,
|
||||
},
|
||||
);
|
||||
sproof_builder.hrmp_egress_channel_index = Some(vec![recipient]);
|
||||
|
||||
let (relay_parent_storage_root, relay_chain_state) = sproof_builder.into_state_root_and_proof();
|
||||
let vfp = PersistedValidationData {
|
||||
@@ -388,7 +389,7 @@ pub fn mock_open_hrmp_channel<
|
||||
let inherent_data = {
|
||||
let mut inherent_data = InherentData::default();
|
||||
let system_inherent_data = ParachainInherentData {
|
||||
validation_data: vfp.clone(),
|
||||
validation_data: vfp,
|
||||
relay_chain_state,
|
||||
downward_messages: Default::default(),
|
||||
horizontal_messages: Default::default(),
|
||||
|
||||
@@ -134,7 +134,7 @@ pub fn teleports_for_native_asset_works<
|
||||
BuyExecution {
|
||||
fees: MultiAsset {
|
||||
id: Concrete(native_asset_id),
|
||||
fun: Fungible(buy_execution_fee_amount_eta.into()),
|
||||
fun: Fungible(buy_execution_fee_amount_eta),
|
||||
},
|
||||
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
|
||||
},
|
||||
@@ -190,7 +190,7 @@ pub fn teleports_for_native_asset_works<
|
||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||
dest,
|
||||
dest_beneficiary,
|
||||
(native_asset_id, native_asset_to_teleport_away.clone().into()),
|
||||
(native_asset_id, native_asset_to_teleport_away.into()),
|
||||
None,
|
||||
));
|
||||
// check balances
|
||||
@@ -235,7 +235,7 @@ pub fn teleports_for_native_asset_works<
|
||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||
dest,
|
||||
dest_beneficiary,
|
||||
(native_asset_id, native_asset_to_teleport_away.clone().into()),
|
||||
(native_asset_id, native_asset_to_teleport_away.into()),
|
||||
Some((runtime_para_id, other_para_id)),
|
||||
));
|
||||
|
||||
@@ -366,7 +366,7 @@ pub fn teleports_for_foreign_assets_works<
|
||||
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
|
||||
let buy_execution_fee = MultiAsset {
|
||||
id: Concrete(MultiLocation::parent()),
|
||||
fun: Fungible(buy_execution_fee_amount.into()),
|
||||
fun: Fungible(buy_execution_fee_amount),
|
||||
};
|
||||
|
||||
let teleported_foreign_asset_amount = 10000000000000;
|
||||
@@ -376,7 +376,7 @@ pub fn teleports_for_foreign_assets_works<
|
||||
.with_session_keys(collator_session_keys.session_keys())
|
||||
.with_balances(vec![
|
||||
(
|
||||
foreign_creator_as_account_id.clone(),
|
||||
foreign_creator_as_account_id,
|
||||
existential_deposit + (buy_execution_fee_amount * 2).into(),
|
||||
),
|
||||
(target_account.clone(), existential_deposit),
|
||||
@@ -441,7 +441,7 @@ pub fn teleports_for_foreign_assets_works<
|
||||
BuyExecution {
|
||||
fees: MultiAsset {
|
||||
id: Concrete(MultiLocation::parent()),
|
||||
fun: Fungible(buy_execution_fee_amount.into()),
|
||||
fun: Fungible(buy_execution_fee_amount),
|
||||
},
|
||||
weight_limit: Limited(Weight::from_parts(403531000, 65536)),
|
||||
},
|
||||
@@ -536,7 +536,7 @@ pub fn teleports_for_foreign_assets_works<
|
||||
RuntimeHelper::<Runtime>::origin_of(target_account.clone()),
|
||||
dest,
|
||||
dest_beneficiary,
|
||||
(foreign_asset_id_multilocation, asset_to_teleport_away.clone().into()),
|
||||
(foreign_asset_id_multilocation, asset_to_teleport_away),
|
||||
Some((runtime_para_id, foreign_para_id)),
|
||||
));
|
||||
|
||||
@@ -788,7 +788,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
||||
.execute_with(|| {
|
||||
// create some asset class
|
||||
let asset_minimum_asset_balance = 3333333_u128;
|
||||
let asset_id_as_multilocation = AssetIdConverter::reverse_ref(&asset_id).unwrap();
|
||||
let asset_id_as_multilocation = AssetIdConverter::reverse_ref(asset_id).unwrap();
|
||||
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::force_create(
|
||||
RuntimeHelper::<Runtime>::root_origin(),
|
||||
asset_id.into(),
|
||||
@@ -869,7 +869,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
||||
id: charlie_account.clone().into()
|
||||
}),
|
||||
},
|
||||
(asset_id_as_multilocation, 1 * asset_minimum_asset_balance),
|
||||
(asset_id_as_multilocation, asset_minimum_asset_balance),
|
||||
),
|
||||
XcmError::FailedToTransactAsset(Into::<&str>::into(
|
||||
sp_runtime::TokenError::CannotCreate
|
||||
@@ -890,7 +890,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
||||
parents: 0,
|
||||
interior: X1(AccountId32 { network: None, id: bob_account.clone().into() }),
|
||||
},
|
||||
(asset_id_as_multilocation, 1 * asset_minimum_asset_balance),
|
||||
(asset_id_as_multilocation, asset_minimum_asset_balance),
|
||||
),
|
||||
Ok(_)
|
||||
));
|
||||
@@ -908,7 +908,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
|
||||
asset_id.into(),
|
||||
&bob_account
|
||||
),
|
||||
(1 * asset_minimum_asset_balance).into()
|
||||
asset_minimum_asset_balance.into()
|
||||
);
|
||||
assert_eq!(
|
||||
<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::balance(
|
||||
@@ -1130,7 +1130,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
||||
// lets simulate this was triggered by relay chain from local consensus sibling parachain
|
||||
let xcm = Xcm(vec![
|
||||
WithdrawAsset(buy_execution_fee.clone().into()),
|
||||
BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited },
|
||||
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
|
||||
Transact {
|
||||
origin_kind: OriginKind::Xcm,
|
||||
require_weight_at_most: Weight::from_parts(40_000_000_000, 8000),
|
||||
@@ -1247,7 +1247,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
|
||||
});
|
||||
let xcm = Xcm(vec![
|
||||
WithdrawAsset(buy_execution_fee.clone().into()),
|
||||
BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited },
|
||||
BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited },
|
||||
Transact {
|
||||
origin_kind: OriginKind::Xcm,
|
||||
require_weight_at_most: Weight::from_parts(20_000_000_000, 8000),
|
||||
|
||||
@@ -199,7 +199,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -1038,7 +1038,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -1073,7 +1073,6 @@ impl_runtime_apis! {
|
||||
id: Concrete(GeneralIndex(i as u128).into()),
|
||||
fun: Fungible(fungibles_amount * i as u128),
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
|
||||
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
|
||||
@@ -1093,7 +1092,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
WestendLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WestendLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(WestendLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
|
||||
@@ -1108,7 +1107,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(WestendLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -123,7 +122,7 @@ impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
@@ -191,155 +191,149 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(
|
||||
pallet_utility::Call::as_derivative { .. } |
|
||||
pallet_utility::Call::batch { .. } |
|
||||
pallet_utility::Call::batch_all { .. },
|
||||
) |
|
||||
RuntimeCall::Assets(
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(
|
||||
pallet_utility::Call::as_derivative { .. } |
|
||||
pallet_utility::Call::batch { .. } |
|
||||
pallet_utility::Call::batch_all { .. },
|
||||
) | RuntimeCall::Assets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::ForeignAssets(
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::ForeignAssets(
|
||||
pallet_assets::Call::create { .. } |
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::set_metadata { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) |
|
||||
RuntimeCall::Nfts(
|
||||
pallet_assets::Call::force_create { .. } |
|
||||
pallet_assets::Call::start_destroy { .. } |
|
||||
pallet_assets::Call::destroy_accounts { .. } |
|
||||
pallet_assets::Call::destroy_approvals { .. } |
|
||||
pallet_assets::Call::finish_destroy { .. } |
|
||||
pallet_assets::Call::mint { .. } |
|
||||
pallet_assets::Call::burn { .. } |
|
||||
pallet_assets::Call::transfer { .. } |
|
||||
pallet_assets::Call::transfer_keep_alive { .. } |
|
||||
pallet_assets::Call::force_transfer { .. } |
|
||||
pallet_assets::Call::freeze { .. } |
|
||||
pallet_assets::Call::thaw { .. } |
|
||||
pallet_assets::Call::freeze_asset { .. } |
|
||||
pallet_assets::Call::thaw_asset { .. } |
|
||||
pallet_assets::Call::transfer_ownership { .. } |
|
||||
pallet_assets::Call::set_team { .. } |
|
||||
pallet_assets::Call::set_metadata { .. } |
|
||||
pallet_assets::Call::clear_metadata { .. } |
|
||||
pallet_assets::Call::force_clear_metadata { .. } |
|
||||
pallet_assets::Call::force_asset_status { .. } |
|
||||
pallet_assets::Call::approve_transfer { .. } |
|
||||
pallet_assets::Call::cancel_approval { .. } |
|
||||
pallet_assets::Call::force_cancel_approval { .. } |
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::Nfts(
|
||||
pallet_nfts::Call::create { .. } |
|
||||
pallet_nfts::Call::force_create { .. } |
|
||||
pallet_nfts::Call::destroy { .. } |
|
||||
pallet_nfts::Call::mint { .. } |
|
||||
pallet_nfts::Call::force_mint { .. } |
|
||||
pallet_nfts::Call::burn { .. } |
|
||||
pallet_nfts::Call::transfer { .. } |
|
||||
pallet_nfts::Call::lock_item_transfer { .. } |
|
||||
pallet_nfts::Call::unlock_item_transfer { .. } |
|
||||
pallet_nfts::Call::lock_collection { .. } |
|
||||
pallet_nfts::Call::transfer_ownership { .. } |
|
||||
pallet_nfts::Call::set_team { .. } |
|
||||
pallet_nfts::Call::force_collection_owner { .. } |
|
||||
pallet_nfts::Call::force_collection_config { .. } |
|
||||
pallet_nfts::Call::approve_transfer { .. } |
|
||||
pallet_nfts::Call::cancel_approval { .. } |
|
||||
pallet_nfts::Call::clear_all_transfer_approvals { .. } |
|
||||
pallet_nfts::Call::lock_item_properties { .. } |
|
||||
pallet_nfts::Call::set_attribute { .. } |
|
||||
pallet_nfts::Call::force_set_attribute { .. } |
|
||||
pallet_nfts::Call::clear_attribute { .. } |
|
||||
pallet_nfts::Call::approve_item_attributes { .. } |
|
||||
pallet_nfts::Call::cancel_item_attributes_approval { .. } |
|
||||
pallet_nfts::Call::set_metadata { .. } |
|
||||
pallet_nfts::Call::clear_metadata { .. } |
|
||||
pallet_nfts::Call::set_collection_metadata { .. } |
|
||||
pallet_nfts::Call::clear_collection_metadata { .. } |
|
||||
pallet_nfts::Call::set_accept_ownership { .. } |
|
||||
pallet_nfts::Call::set_collection_max_supply { .. } |
|
||||
pallet_nfts::Call::update_mint_settings { .. } |
|
||||
pallet_nfts::Call::set_price { .. } |
|
||||
pallet_nfts::Call::buy_item { .. } |
|
||||
pallet_nfts::Call::pay_tips { .. } |
|
||||
pallet_nfts::Call::create_swap { .. } |
|
||||
pallet_nfts::Call::cancel_swap { .. } |
|
||||
pallet_nfts::Call::claim_swap { .. },
|
||||
) |
|
||||
RuntimeCall::Uniques(
|
||||
pallet_nfts::Call::force_create { .. } |
|
||||
pallet_nfts::Call::destroy { .. } |
|
||||
pallet_nfts::Call::mint { .. } |
|
||||
pallet_nfts::Call::force_mint { .. } |
|
||||
pallet_nfts::Call::burn { .. } |
|
||||
pallet_nfts::Call::transfer { .. } |
|
||||
pallet_nfts::Call::lock_item_transfer { .. } |
|
||||
pallet_nfts::Call::unlock_item_transfer { .. } |
|
||||
pallet_nfts::Call::lock_collection { .. } |
|
||||
pallet_nfts::Call::transfer_ownership { .. } |
|
||||
pallet_nfts::Call::set_team { .. } |
|
||||
pallet_nfts::Call::force_collection_owner { .. } |
|
||||
pallet_nfts::Call::force_collection_config { .. } |
|
||||
pallet_nfts::Call::approve_transfer { .. } |
|
||||
pallet_nfts::Call::cancel_approval { .. } |
|
||||
pallet_nfts::Call::clear_all_transfer_approvals { .. } |
|
||||
pallet_nfts::Call::lock_item_properties { .. } |
|
||||
pallet_nfts::Call::set_attribute { .. } |
|
||||
pallet_nfts::Call::force_set_attribute { .. } |
|
||||
pallet_nfts::Call::clear_attribute { .. } |
|
||||
pallet_nfts::Call::approve_item_attributes { .. } |
|
||||
pallet_nfts::Call::cancel_item_attributes_approval { .. } |
|
||||
pallet_nfts::Call::set_metadata { .. } |
|
||||
pallet_nfts::Call::clear_metadata { .. } |
|
||||
pallet_nfts::Call::set_collection_metadata { .. } |
|
||||
pallet_nfts::Call::clear_collection_metadata { .. } |
|
||||
pallet_nfts::Call::set_accept_ownership { .. } |
|
||||
pallet_nfts::Call::set_collection_max_supply { .. } |
|
||||
pallet_nfts::Call::update_mint_settings { .. } |
|
||||
pallet_nfts::Call::set_price { .. } |
|
||||
pallet_nfts::Call::buy_item { .. } |
|
||||
pallet_nfts::Call::pay_tips { .. } |
|
||||
pallet_nfts::Call::create_swap { .. } |
|
||||
pallet_nfts::Call::cancel_swap { .. } |
|
||||
pallet_nfts::Call::claim_swap { .. },
|
||||
) | RuntimeCall::Uniques(
|
||||
pallet_uniques::Call::create { .. } |
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
pallet_uniques::Call::force_create { .. } |
|
||||
pallet_uniques::Call::destroy { .. } |
|
||||
pallet_uniques::Call::mint { .. } |
|
||||
pallet_uniques::Call::burn { .. } |
|
||||
pallet_uniques::Call::transfer { .. } |
|
||||
pallet_uniques::Call::freeze { .. } |
|
||||
pallet_uniques::Call::thaw { .. } |
|
||||
pallet_uniques::Call::freeze_collection { .. } |
|
||||
pallet_uniques::Call::thaw_collection { .. } |
|
||||
pallet_uniques::Call::transfer_ownership { .. } |
|
||||
pallet_uniques::Call::set_team { .. } |
|
||||
pallet_uniques::Call::approve_transfer { .. } |
|
||||
pallet_uniques::Call::cancel_approval { .. } |
|
||||
pallet_uniques::Call::force_item_status { .. } |
|
||||
pallet_uniques::Call::set_attribute { .. } |
|
||||
pallet_uniques::Call::clear_attribute { .. } |
|
||||
pallet_uniques::Call::set_metadata { .. } |
|
||||
pallet_uniques::Call::clear_metadata { .. } |
|
||||
pallet_uniques::Call::set_collection_metadata { .. } |
|
||||
pallet_uniques::Call::clear_collection_metadata { .. } |
|
||||
pallet_uniques::Call::set_accept_ownership { .. } |
|
||||
pallet_uniques::Call::set_collection_max_supply { .. } |
|
||||
pallet_uniques::Call::set_price { .. } |
|
||||
pallet_uniques::Call::buy_item { .. },
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,19 +84,16 @@ fn test_asset_xcm_trader() {
|
||||
// Lets pay with: asset_amount_needed + asset_amount_extra
|
||||
let asset_amount_extra = 100_u128;
|
||||
let asset: MultiAsset =
|
||||
(asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into();
|
||||
(asset_multilocation, asset_amount_needed + asset_amount_extra).into();
|
||||
|
||||
let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
|
||||
|
||||
// Lets buy_weight and make sure buy_weight does not return an error
|
||||
match trader.buy_weight(bought, asset.into()) {
|
||||
Ok(unused_assets) => {
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(unused_assets
|
||||
.ensure_contains(&(asset_multilocation, asset_amount_extra).into()));
|
||||
},
|
||||
Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e),
|
||||
}
|
||||
let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok");
|
||||
// Check whether a correct amount of unused assets is returned
|
||||
assert_ok!(
|
||||
unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into())
|
||||
);
|
||||
|
||||
// Drop trader
|
||||
drop(trader);
|
||||
@@ -156,7 +153,7 @@ fn test_asset_xcm_trader_with_refund() {
|
||||
// lets calculate amount needed
|
||||
let amount_bought = WeightToFee::weight_to_fee(&bought);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Make sure buy_weight does not return an error
|
||||
assert_ok!(trader.buy_weight(bought, asset.clone().into()));
|
||||
@@ -230,7 +227,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
|
||||
"we are testing what happens when the amount does not exceed ED"
|
||||
);
|
||||
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
|
||||
// Buy weight should return an error
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
@@ -282,11 +279,11 @@ fn test_that_buying_ed_refund_does_not_refund() {
|
||||
|
||||
// We know we will have to buy at least ED, so lets make sure first it will
|
||||
// fail with a payment of less than ED
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
|
||||
let asset: MultiAsset = (asset_multilocation, amount_bought).into();
|
||||
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
|
||||
|
||||
// Now lets buy ED at least
|
||||
let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into();
|
||||
let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into();
|
||||
|
||||
// Buy weight should work
|
||||
assert_ok!(trader.buy_weight(bought, asset.into()));
|
||||
@@ -421,7 +418,7 @@ fn test_assets_balances_api_works() {
|
||||
let foreign_asset_minimum_asset_balance = 3333333_u128;
|
||||
assert_ok!(ForeignAssets::force_create(
|
||||
RuntimeHelper::<Runtime>::root_origin(),
|
||||
foreign_asset_id_multilocation.clone().into(),
|
||||
foreign_asset_id_multilocation,
|
||||
AccountId::from(SOME_ASSET_ADMIN).into(),
|
||||
false,
|
||||
foreign_asset_minimum_asset_balance
|
||||
@@ -430,7 +427,7 @@ fn test_assets_balances_api_works() {
|
||||
// We first mint enough asset for the account to exist for assets
|
||||
assert_ok!(ForeignAssets::mint(
|
||||
RuntimeHelper::<Runtime>::origin_of(AccountId::from(SOME_ASSET_ADMIN)),
|
||||
foreign_asset_id_multilocation.clone().into(),
|
||||
foreign_asset_id_multilocation,
|
||||
AccountId::from(ALICE).into(),
|
||||
6 * foreign_asset_minimum_asset_balance
|
||||
));
|
||||
|
||||
@@ -254,7 +254,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -615,7 +615,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -653,7 +653,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
KsmRelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmRelayLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmRelayLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(KsmRelayLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -123,7 +122,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubKusamaXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
@@ -129,29 +129,27 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -615,7 +615,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -653,7 +653,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
DotRelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotRelayLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(DotRelayLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(DotRelayLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubPolkadotXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -123,7 +122,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubPolkadotXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
@@ -150,7 +149,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubPolkadotXcmWeight<Call> {
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
// Hardcoded till the XCM pallet is fixed
|
||||
let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(200_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
@@ -132,29 +132,27 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -888,7 +888,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -926,7 +926,7 @@ impl_runtime_apis! {
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
RelayLocation::get(),
|
||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RelayLocation::get()) },
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(RelayLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
}
|
||||
@@ -940,7 +940,7 @@ impl_runtime_apis! {
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(RelayLocation::get()),
|
||||
fun: Fungible(1 * UNITS),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ const MAX_ASSETS: u64 = 100;
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) =>
|
||||
weight.saturating_mul(assets.inner().into_iter().count() as u64),
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
All => weight.saturating_mul(MAX_ASSETS),
|
||||
AllOf { fun, .. } => match fun {
|
||||
@@ -54,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().into_iter().count() as u64)
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +65,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
// Currently there is no trusted reserve
|
||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
||||
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
|
||||
Weight::from_parts(1_000_000_000 as u64, 0)
|
||||
Weight::from_parts(1_000_000_000_u64, 0)
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
@@ -124,7 +123,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
|
||||
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 as u64, 0);
|
||||
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
|
||||
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
|
||||
hardcoded_weight.min(weight)
|
||||
}
|
||||
|
||||
+3
-3
@@ -347,11 +347,11 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
||||
// Storage: BridgeWococoMessages OutboundMessages (r:0 w:1)
|
||||
// Proof: BridgeWococoMessages OutboundMessages (max_values: None, max_size: Some(2621472), added: 2623947, mode: MaxEncodedLen)
|
||||
pub(crate) fn export_message(x: u32, ) -> Weight {
|
||||
Weight::from_parts(31_677_716 as u64, 0)
|
||||
Weight::from_parts(31_677_716_u64, 0)
|
||||
// Standard Error: 4_158
|
||||
.saturating_add(Weight::from_parts(123_901, 0).saturating_mul(x as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
pub fn unpaid_execution() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
|
||||
@@ -152,41 +152,35 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
|
||||
Runtime,
|
||||
BridgeGrandpaRococoInstance,
|
||||
>::initialize {
|
||||
..
|
||||
}) |
|
||||
RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::<
|
||||
Runtime,
|
||||
BridgeGrandpaWococoInstance,
|
||||
>::initialize {
|
||||
..
|
||||
}) => true,
|
||||
_ => false,
|
||||
}
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::<
|
||||
Runtime,
|
||||
BridgeGrandpaRococoInstance,
|
||||
>::initialize { .. }) |
|
||||
RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::<
|
||||
Runtime,
|
||||
BridgeGrandpaWococoInstance,
|
||||
>::initialize { .. })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
||||
// check queue before
|
||||
assert_eq!(
|
||||
pallet_bridge_messages::OutboundLanes::<Runtime, MessagesPalletInstance>::try_get(
|
||||
&expected_lane_id
|
||||
expected_lane_id
|
||||
),
|
||||
Err(())
|
||||
);
|
||||
@@ -190,7 +190,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works<
|
||||
// check queue after
|
||||
assert_eq!(
|
||||
pallet_bridge_messages::OutboundLanes::<Runtime, MessagesPalletInstance>::try_get(
|
||||
&expected_lane_id
|
||||
expected_lane_id
|
||||
),
|
||||
Ok(OutboundLaneData {
|
||||
oldest_unpruned_nonce: 1,
|
||||
@@ -243,8 +243,8 @@ macro_rules! include_handle_export_message_from_system_parachain_to_outbound_que
|
||||
/// Test-case makes sure that Runtime can route XCM messages received in inbound queue,
|
||||
/// We just test here `MessageDispatch` configuration.
|
||||
/// We expect that runtime can route messages:
|
||||
/// 1. to Parent (relay chain)
|
||||
/// 2. to Sibling parachain
|
||||
/// 1. to Parent (relay chain)
|
||||
/// 2. to Sibling parachain
|
||||
pub fn message_dispatch_routing_works<
|
||||
Runtime,
|
||||
XcmConfig,
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ pub(crate) mod import_kusama_fellowship {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
const TARGET: &'static str = "runtime::migration::import_fellowship";
|
||||
const TARGET: &str = "runtime::migration::import_fellowship";
|
||||
|
||||
parameter_types! {
|
||||
// The Fellowship addresses from Kusama state.
|
||||
@@ -250,7 +250,7 @@ pub mod tests {
|
||||
assert!(IdToIndex::<Runtime, Fellowship>::get(0, &who).is_some());
|
||||
assert!(IdToIndex::<Runtime, Fellowship>::get(rank + 1, &who).is_none());
|
||||
let index = IdToIndex::<Runtime, Fellowship>::get(rank, &who).unwrap();
|
||||
assert_eq!(IndexToId::<Runtime, Fellowship>::get(rank, &index).unwrap(), who);
|
||||
assert_eq!(IndexToId::<Runtime, Fellowship>::get(rank, index).unwrap(), who);
|
||||
assert_eq!(
|
||||
Members::<Runtime, Fellowship>::get(&who).unwrap(),
|
||||
MemberRecord::new(rank)
|
||||
|
||||
+15
-15
@@ -54,7 +54,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -76,7 +76,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -98,7 +98,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -120,7 +120,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -142,7 +142,7 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -160,11 +160,11 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "experts",
|
||||
max_deciding: 10,
|
||||
decision_deposit: 1 * DOLLARS,
|
||||
decision_deposit: DOLLARS,
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -182,11 +182,11 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "senior experts",
|
||||
max_deciding: 10,
|
||||
decision_deposit: 1 * DOLLARS,
|
||||
decision_deposit: DOLLARS,
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -204,11 +204,11 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "masters",
|
||||
max_deciding: 10,
|
||||
decision_deposit: 1 * DOLLARS,
|
||||
decision_deposit: DOLLARS,
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -226,11 +226,11 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "senior masters",
|
||||
max_deciding: 10,
|
||||
decision_deposit: 1 * DOLLARS,
|
||||
decision_deposit: DOLLARS,
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
@@ -248,11 +248,11 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
|
||||
pallet_referenda::TrackInfo {
|
||||
name: "grand masters",
|
||||
max_deciding: 10,
|
||||
decision_deposit: 1 * DOLLARS,
|
||||
decision_deposit: DOLLARS,
|
||||
prepare_period: 30 * MINUTES,
|
||||
decision_period: 7 * DAYS,
|
||||
confirm_period: 30 * MINUTES,
|
||||
min_enactment_period: 1 * MINUTES,
|
||||
min_enactment_period: MINUTES,
|
||||
min_approval: pallet_referenda::Curve::LinearDecreasing {
|
||||
length: Perbill::from_percent(100),
|
||||
floor: Perbill::from_percent(50),
|
||||
|
||||
@@ -59,7 +59,7 @@ where
|
||||
let pallet_acc: AccountIdOf<T> = PalletAccount::get();
|
||||
let treasury_acc: AccountIdOf<T> = TreasuryAccount::get();
|
||||
|
||||
<pallet_balances::Pallet<T>>::resolve_creating(&pallet_acc.clone(), amount);
|
||||
<pallet_balances::Pallet<T>>::resolve_creating(&pallet_acc, amount);
|
||||
|
||||
let result = <pallet_xcm::Pallet<T>>::teleport_assets(
|
||||
<<T as frame_system::Config>::RuntimeOrigin>::signed(pallet_acc.into()),
|
||||
@@ -73,10 +73,9 @@ where
|
||||
0,
|
||||
);
|
||||
|
||||
match result {
|
||||
Err(err) => log::warn!("Failed to teleport slashed assets: {:?}", err),
|
||||
_ => (),
|
||||
};
|
||||
if let Err(err) = result {
|
||||
log::warn!("Failed to teleport slashed assets: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ impl pallet_balances::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
/// Relay Chain `TransactionByteFee` / 10
|
||||
pub const TransactionByteFee: Balance = 1 * MILLICENTS;
|
||||
pub const TransactionByteFee: Balance = MILLICENTS;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
@@ -843,7 +843,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
@@ -899,7 +899,7 @@ impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
|
||||
.create_inherent_data()
|
||||
.expect("Could not create the timestamp inherent data");
|
||||
|
||||
inherent_data.check_extrinsics(&block)
|
||||
inherent_data.check_extrinsics(block)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,58 +137,54 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
}
|
||||
}
|
||||
|
||||
match call {
|
||||
matches!(
|
||||
call,
|
||||
RuntimeCall::System(
|
||||
frame_system::Call::set_heap_pages { .. } |
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) |
|
||||
RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) |
|
||||
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Alliance(
|
||||
// `init_members` accepts unbounded vecs as arguments,
|
||||
// but the call can be initiated only by root origin.
|
||||
pallet_alliance::Call::init_members { .. } |
|
||||
pallet_alliance::Call::vote { .. } |
|
||||
pallet_alliance::Call::disband { .. } |
|
||||
pallet_alliance::Call::set_rule { .. } |
|
||||
pallet_alliance::Call::announce { .. } |
|
||||
pallet_alliance::Call::remove_announcement { .. } |
|
||||
pallet_alliance::Call::join_alliance { .. } |
|
||||
pallet_alliance::Call::nominate_ally { .. } |
|
||||
pallet_alliance::Call::elevate_ally { .. } |
|
||||
pallet_alliance::Call::give_retirement_notice { .. } |
|
||||
pallet_alliance::Call::retire { .. } |
|
||||
pallet_alliance::Call::kick_member { .. } |
|
||||
pallet_alliance::Call::close { .. } |
|
||||
pallet_alliance::Call::abdicate_fellow_status { .. },
|
||||
) |
|
||||
RuntimeCall::AllianceMotion(
|
||||
frame_system::Call::set_code { .. } |
|
||||
frame_system::Call::set_code_without_checks { .. } |
|
||||
frame_system::Call::kill_prefix { .. },
|
||||
) | RuntimeCall::ParachainSystem(..) |
|
||||
RuntimeCall::Timestamp(..) |
|
||||
RuntimeCall::Balances(..) |
|
||||
RuntimeCall::CollatorSelection(
|
||||
pallet_collator_selection::Call::set_desired_candidates { .. } |
|
||||
pallet_collator_selection::Call::set_candidacy_bond { .. } |
|
||||
pallet_collator_selection::Call::register_as_candidate { .. } |
|
||||
pallet_collator_selection::Call::leave_intent { .. },
|
||||
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
|
||||
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
|
||||
RuntimeCall::XcmpQueue(..) |
|
||||
RuntimeCall::DmpQueue(..) |
|
||||
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
|
||||
RuntimeCall::Alliance(
|
||||
// `init_members` accepts unbounded vecs as arguments,
|
||||
// but the call can be initiated only by root origin.
|
||||
pallet_alliance::Call::init_members { .. } |
|
||||
pallet_alliance::Call::vote { .. } |
|
||||
pallet_alliance::Call::disband { .. } |
|
||||
pallet_alliance::Call::set_rule { .. } |
|
||||
pallet_alliance::Call::announce { .. } |
|
||||
pallet_alliance::Call::remove_announcement { .. } |
|
||||
pallet_alliance::Call::join_alliance { .. } |
|
||||
pallet_alliance::Call::nominate_ally { .. } |
|
||||
pallet_alliance::Call::elevate_ally { .. } |
|
||||
pallet_alliance::Call::give_retirement_notice { .. } |
|
||||
pallet_alliance::Call::retire { .. } |
|
||||
pallet_alliance::Call::kick_member { .. } |
|
||||
pallet_alliance::Call::close { .. } |
|
||||
pallet_alliance::Call::abdicate_fellow_status { .. },
|
||||
) | RuntimeCall::AllianceMotion(
|
||||
pallet_collective::Call::vote { .. } |
|
||||
pallet_collective::Call::disapprove_proposal { .. } |
|
||||
pallet_collective::Call::close { .. },
|
||||
) |
|
||||
RuntimeCall::FellowshipCollective(
|
||||
pallet_collective::Call::disapprove_proposal { .. } |
|
||||
pallet_collective::Call::close { .. },
|
||||
) | RuntimeCall::FellowshipCollective(
|
||||
pallet_ranked_collective::Call::add_member { .. } |
|
||||
pallet_ranked_collective::Call::promote_member { .. } |
|
||||
pallet_ranked_collective::Call::demote_member { .. } |
|
||||
pallet_ranked_collective::Call::remove_member { .. },
|
||||
) => true,
|
||||
_ => false,
|
||||
}
|
||||
pallet_ranked_collective::Call::promote_member { .. } |
|
||||
pallet_ranked_collective::Call::demote_member { .. } |
|
||||
pallet_ranked_collective::Call::remove_member { .. },
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -639,7 +639,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
|
||||
@@ -222,7 +222,7 @@ impl sp_runtime::traits::SignedExtension for DisallowSigned {
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
}
|
||||
fn validate(
|
||||
&self,
|
||||
|
||||
@@ -783,7 +783,7 @@ impl_runtime_apis! {
|
||||
list_benchmarks!(list, extra);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
return (list, storage_info)
|
||||
(list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
|
||||
@@ -225,12 +225,12 @@ pub trait Reserve {
|
||||
// Takes the chain part of a MultiAsset
|
||||
impl Reserve for MultiAsset {
|
||||
fn reserve(&self) -> Option<MultiLocation> {
|
||||
if let AssetId::Concrete(location) = self.id.clone() {
|
||||
if let AssetId::Concrete(location) = self.id {
|
||||
let first_interior = location.first_interior();
|
||||
let parents = location.parent_count();
|
||||
match (parents, first_interior.clone()) {
|
||||
(0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(id.clone())))),
|
||||
(1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(id.clone())))),
|
||||
match (parents, first_interior) {
|
||||
(0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(*id)))),
|
||||
(1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(*id)))),
|
||||
(1, _) => Some(MultiLocation::parent()),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
@@ -219,10 +219,10 @@ impl pallet_timestamp::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u128 = 1 * MILLIROC;
|
||||
pub const TransferFee: u128 = 1 * MILLIROC;
|
||||
pub const CreationFee: u128 = 1 * MILLIROC;
|
||||
pub const TransactionByteFee: u128 = 1 * MICROROC;
|
||||
pub const ExistentialDeposit: u128 = MILLIROC;
|
||||
pub const TransferFee: u128 = MILLIROC;
|
||||
pub const CreationFee: u128 = MILLIROC;
|
||||
pub const TransactionByteFee: u128 = MICROROC;
|
||||
}
|
||||
|
||||
impl pallet_balances::Config for Runtime {
|
||||
@@ -505,11 +505,11 @@ impl cumulus_ping::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AssetDeposit: Balance = 1 * ROC;
|
||||
pub const AssetAccountDeposit: Balance = 1 * ROC;
|
||||
pub const AssetDeposit: Balance = ROC;
|
||||
pub const AssetAccountDeposit: Balance = ROC;
|
||||
pub const ApprovalDeposit: Balance = 100 * MILLIROC;
|
||||
pub const AssetsStringLimit: u32 = 50;
|
||||
pub const MetadataDepositBase: Balance = 1 * ROC;
|
||||
pub const MetadataDepositBase: Balance = ROC;
|
||||
pub const MetadataDepositPerByte: Balance = 10 * MILLIROC;
|
||||
pub const UnitBody: BodyId = BodyId::Unit;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ pub mod rococo {
|
||||
para_id,
|
||||
bridges_pallet_owner_seed
|
||||
.as_ref()
|
||||
.map(|seed| get_account_id_from_seed::<sr25519::Public>(&seed)),
|
||||
.map(|seed| get_account_id_from_seed::<sr25519::Public>(seed)),
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
|
||||
@@ -85,7 +85,7 @@ impl RuntimeResolver for PathBuf {
|
||||
}
|
||||
|
||||
fn runtime(id: &str) -> Runtime {
|
||||
let id = id.replace("_", "-");
|
||||
let id = id.replace('_', "-");
|
||||
let (_, id, para_id) = extract_parachain_id(&id);
|
||||
|
||||
if id.starts_with("shell") {
|
||||
@@ -240,7 +240,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
Runtime::ContractsRococo =>
|
||||
Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?),
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) =>
|
||||
bridge_hub_runtime_type.chain_spec_from_json_file(path.into())?,
|
||||
bridge_hub_runtime_type.chain_spec_from_json_file(path)?,
|
||||
Runtime::Penpal(_para_id) =>
|
||||
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
|
||||
Runtime::Default => Box::new(
|
||||
@@ -258,12 +258,10 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option<ParaId>) {
|
||||
const KUSAMA_TEST_PARA_PREFIX: &str = "penpal-kusama-";
|
||||
const POLKADOT_TEST_PARA_PREFIX: &str = "penpal-polkadot-";
|
||||
|
||||
let (norm_id, orig_id, para) = if id.starts_with(KUSAMA_TEST_PARA_PREFIX) {
|
||||
let suffix = &id[KUSAMA_TEST_PARA_PREFIX.len()..];
|
||||
let (norm_id, orig_id, para) = if let Some(suffix) = id.strip_prefix(KUSAMA_TEST_PARA_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..KUSAMA_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else if id.starts_with(POLKADOT_TEST_PARA_PREFIX) {
|
||||
let suffix = &id[POLKADOT_TEST_PARA_PREFIX.len()..];
|
||||
} else if let Some(suffix) = id.strip_prefix(POLKADOT_TEST_PARA_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..POLKADOT_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else {
|
||||
@@ -813,13 +811,13 @@ pub fn run() -> Result<()> {
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
let hwbench = (!cli.no_hardware_benchmarks).then_some(
|
||||
config.database.path().map(|database_path| {
|
||||
let _ = std::fs::create_dir_all(&database_path);
|
||||
let _ = std::fs::create_dir_all(database_path);
|
||||
sc_sysinfo::gather_hwbench(Some(database_path))
|
||||
})).flatten();
|
||||
|
||||
let para_id = chain_spec::Extensions::try_get(&*config.chain_spec)
|
||||
.map(|e| e.para_id)
|
||||
.ok_or_else(|| "Could not find parachain extension in chain-spec.")?;
|
||||
.ok_or("Could not find parachain extension in chain-spec.")?;
|
||||
|
||||
let polkadot_cli = RelayChainCli::new(
|
||||
&config,
|
||||
@@ -848,7 +846,7 @@ pub fn run() -> Result<()> {
|
||||
info!("Parachain genesis state: {}", genesis_state);
|
||||
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
|
||||
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relaychain_args.len() > 0 {
|
||||
if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relaychain_args.is_empty() {
|
||||
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ where
|
||||
|
||||
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
||||
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
|
||||
module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?;
|
||||
module.merge(StateMigration::new(client, backend, deny_unsafe).into_rpc())?;
|
||||
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
@@ -858,7 +858,7 @@ where
|
||||
sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
|
||||
{
|
||||
cumulus_client_consensus_relay_chain::import_queue(
|
||||
client.clone(),
|
||||
client,
|
||||
block_import,
|
||||
|_, _| async { Ok(()) },
|
||||
&task_manager.spawn_essential_handle(),
|
||||
@@ -1103,7 +1103,7 @@ where
|
||||
Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>;
|
||||
|
||||
let verifier = Verifier {
|
||||
client: client.clone(),
|
||||
client,
|
||||
relay_chain_verifier,
|
||||
aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))),
|
||||
_phantom: PhantomData,
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
use tempfile::tempdir;
|
||||
|
||||
/// The runtimes that this command supports.
|
||||
static RUNTIMES: [&'static str; 3] = ["westmint", "statemine", "statemint"];
|
||||
static RUNTIMES: [&str; 3] = ["westmint", "statemine", "statemint"];
|
||||
|
||||
/// The `benchmark storage` command works for the dev runtimes.
|
||||
#[test]
|
||||
@@ -31,7 +31,7 @@ fn benchmark_storage_works() {
|
||||
/// Invoke the `benchmark storage` sub-command for the given database and runtime.
|
||||
fn benchmark_storage(db: &str, runtime: &str, base_path: &Path) -> ExitStatus {
|
||||
Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["benchmark", "storage", "--chain", runtime])
|
||||
.args(["benchmark", "storage", "--chain", runtime])
|
||||
.arg("--db")
|
||||
.arg(db)
|
||||
.arg("--weight-path")
|
||||
|
||||
@@ -117,12 +117,12 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) {
|
||||
line.expect("failed to obtain next line from stdout for WS address discovery");
|
||||
|
||||
data.push_str(&line);
|
||||
data.push_str("\n");
|
||||
data.push('\n');
|
||||
|
||||
// does the line contain our port (we expect this specific output from substrate).
|
||||
let sock_addr = match line.split_once("Running JSON-RPC server: addr=") {
|
||||
None => return None,
|
||||
Some((_, after)) => after.split_once(",").unwrap().0,
|
||||
Some((_, after)) => after.split_once(',').unwrap().0,
|
||||
};
|
||||
|
||||
Some(format!("ws://{}", sock_addr))
|
||||
|
||||
@@ -38,7 +38,7 @@ async fn purge_chain_works() {
|
||||
assert!(base_dir.path().join("polkadot/chains/dev/db/full").exists());
|
||||
|
||||
let status = Command::new(cargo_bin("polkadot-parachain"))
|
||||
.args(&["purge-chain", "-d"])
|
||||
.args(["purge-chain", "-d"])
|
||||
.arg(base_dir.path())
|
||||
.arg("-y")
|
||||
.status()
|
||||
|
||||
@@ -92,18 +92,19 @@ async fn collect_relay_storage_proof(
|
||||
.ok()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut relevant_keys = Vec::new();
|
||||
relevant_keys.push(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec());
|
||||
relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::relay_dispatch_queue_size(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::upgrade_go_ahead_signal(para_id));
|
||||
relevant_keys.push(relay_well_known_keys::upgrade_restriction_signal(para_id));
|
||||
let mut relevant_keys = vec![
|
||||
relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec(),
|
||||
relay_well_known_keys::CURRENT_SLOT.to_vec(),
|
||||
relay_well_known_keys::ACTIVE_CONFIG.to_vec(),
|
||||
relay_well_known_keys::dmq_mqc_head(para_id),
|
||||
relay_well_known_keys::relay_dispatch_queue_size(para_id),
|
||||
relay_well_known_keys::hrmp_ingress_channel_index(para_id),
|
||||
relay_well_known_keys::hrmp_egress_channel_index(para_id),
|
||||
relay_well_known_keys::upgrade_go_ahead_signal(para_id),
|
||||
relay_well_known_keys::upgrade_restriction_signal(para_id),
|
||||
];
|
||||
relevant_keys.extend(ingress_channels.into_iter().map(|sender| {
|
||||
relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id })
|
||||
}));
|
||||
|
||||
@@ -160,8 +160,8 @@ impl<R: Send + Sync + GenerateRandomness<u64>> InherentDataProvider
|
||||
self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block;
|
||||
|
||||
// Use the "sproof" (spoof proof) builder to build valid mock state root and proof.
|
||||
let mut sproof_builder = RelayStateSproofBuilder::default();
|
||||
sproof_builder.para_id = self.xcm_config.para_id;
|
||||
let mut sproof_builder =
|
||||
RelayStateSproofBuilder { para_id: self.xcm_config.para_id, ..Default::default() };
|
||||
|
||||
// Process the downward messages and set up the correct head
|
||||
let mut downward_messages = Vec::new();
|
||||
|
||||
@@ -99,7 +99,7 @@ mod tests {
|
||||
relay_parent_number: 1,
|
||||
relay_parent_storage_root,
|
||||
},
|
||||
&WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
|
||||
WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"),
|
||||
)
|
||||
.map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`."))
|
||||
}
|
||||
@@ -175,7 +175,7 @@ mod tests {
|
||||
(slot_timestamp * 10, false),
|
||||
] {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&["check_timestamp_inherent_works", "--", "--nocapture"])
|
||||
.args(["check_timestamp_inherent_works", "--", "--nocapture"])
|
||||
.env("RUN_TEST", "1")
|
||||
.env("TIMESTAMP", timestamp.to_string())
|
||||
.output()
|
||||
|
||||
@@ -163,7 +163,7 @@ impl<
|
||||
|
||||
// Get the local asset id in which we can pay for fees
|
||||
let (local_asset_id, _) =
|
||||
Matcher::matches_fungibles(&first).map_err(|_| XcmError::AssetNotFound)?;
|
||||
Matcher::matches_fungibles(first).map_err(|_| XcmError::AssetNotFound)?;
|
||||
|
||||
// Calculate how much we should charge in the asset_id for such amount of weight
|
||||
// Require at least a payment of minimum_balance
|
||||
@@ -181,7 +181,7 @@ impl<
|
||||
.map_err(|_| XcmError::Overflow)?;
|
||||
|
||||
// Convert to the same kind of multiasset, with the required fungible balance
|
||||
let required = first.id.clone().into_multiasset(asset_balance.into());
|
||||
let required = first.id.into_multiasset(asset_balance.into());
|
||||
|
||||
// Substract payment
|
||||
let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?;
|
||||
@@ -204,7 +204,7 @@ impl<
|
||||
{
|
||||
// Get the local asset id in which we can refund fees
|
||||
let (local_asset_id, outstanding_balance) =
|
||||
Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?;
|
||||
Matcher::matches_fungibles(&(id, fun).into()).ok()?;
|
||||
|
||||
let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id);
|
||||
|
||||
@@ -233,8 +233,7 @@ impl<
|
||||
let asset_balance: u128 = asset_balance.saturated_into();
|
||||
|
||||
// Construct outstanding_concrete_asset with the same location id and substracted balance
|
||||
let outstanding_concrete_asset: MultiAsset =
|
||||
(id.clone(), outstanding_minus_substracted).into();
|
||||
let outstanding_concrete_asset: MultiAsset = (id, outstanding_minus_substracted).into();
|
||||
|
||||
// Substract from existing weight and balance
|
||||
weight_outstanding = weight_outstanding.saturating_sub(weight);
|
||||
@@ -365,7 +364,7 @@ mod tests {
|
||||
|
||||
// ParentAsUmp - check dest is really not applicable
|
||||
let dest = (Parent, Parent, Parent);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut dest_wrapper = Some(dest.into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert_eq!(
|
||||
Err(SendError::NotApplicable),
|
||||
@@ -373,7 +372,7 @@ mod tests {
|
||||
);
|
||||
|
||||
// check wrapper were not consumed
|
||||
assert_eq!(Some(dest.clone().into()), dest_wrapper.take());
|
||||
assert_eq!(Some(dest.into()), dest_wrapper.take());
|
||||
assert_eq!(Some(message.clone()), msg_wrapper.take());
|
||||
|
||||
// another try with router chain with asserting sender
|
||||
@@ -393,7 +392,7 @@ mod tests {
|
||||
|
||||
// ParentAsUmp - check dest/msg is valid
|
||||
let dest = (Parent, Here);
|
||||
let mut dest_wrapper = Some(dest.clone().into());
|
||||
let mut dest_wrapper = Some(dest.into());
|
||||
let mut msg_wrapper = Some(message.clone());
|
||||
assert!(<ParentAsUmp<(), (), ()> as SendXcm>::validate(
|
||||
&mut dest_wrapper,
|
||||
@@ -529,16 +528,13 @@ mod tests {
|
||||
|
||||
// prepare test data
|
||||
let asset: MultiAsset = (Here, AMOUNT).into();
|
||||
let payment = Assets::from(asset.clone());
|
||||
let payment = Assets::from(asset);
|
||||
let weight_to_buy = Weight::from_parts(1_000, 1_000);
|
||||
|
||||
// lets do first call (success)
|
||||
assert_ok!(trader.buy_weight(weight_to_buy, payment.clone()));
|
||||
|
||||
// lets do second call (error)
|
||||
assert_eq!(
|
||||
trader.buy_weight(weight_to_buy, payment.clone()),
|
||||
Err(XcmError::NotWithdrawable)
|
||||
);
|
||||
assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +97,11 @@ cargo-check-benches:
|
||||
artifacts: false
|
||||
script:
|
||||
- time cargo check --all --benches
|
||||
|
||||
cargo-clippy:
|
||||
stage: test
|
||||
extends:
|
||||
- .docker-env
|
||||
- .common-refs
|
||||
script:
|
||||
- SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --locked --all-targets
|
||||
|
||||
@@ -64,13 +64,13 @@ pub trait InitBlockBuilder {
|
||||
) -> sc_block_builder::BlockBuilder<Block, Client, Backend>;
|
||||
}
|
||||
|
||||
fn init_block_builder<'a>(
|
||||
client: &'a Client,
|
||||
fn init_block_builder(
|
||||
client: &Client,
|
||||
at: Hash,
|
||||
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
|
||||
relay_sproof_builder: RelayStateSproofBuilder,
|
||||
timestamp: u64,
|
||||
) -> BlockBuilder<'a, Block, Client, Backend> {
|
||||
) -> BlockBuilder<'_, Block, Client, Backend> {
|
||||
let mut block_builder = client
|
||||
.new_block_at(at, Default::default(), true)
|
||||
.expect("Creates new block builder for test runtime");
|
||||
|
||||
@@ -199,5 +199,4 @@ pub fn validate_block(
|
||||
&validation_params.encode(),
|
||||
)
|
||||
.map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`."))
|
||||
.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ impl RelayStateSproofBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
let root = backend.root().clone();
|
||||
let root = *backend.root();
|
||||
let proof = sp_state_machine::prove_read(backend, relevant_keys).expect("prove read");
|
||||
(root, proof)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec
|
||||
accounts
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, a)| {
|
||||
.flat_map(|(i, a)| {
|
||||
vec![
|
||||
// Reset the nonce by removing any funds
|
||||
construct_extrinsic(
|
||||
@@ -54,7 +54,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec
|
||||
SudoCall::sudo {
|
||||
call: Box::new(
|
||||
BalancesCall::force_set_balance {
|
||||
who: AccountId::from(a.public()).into(),
|
||||
who: AccountId::from(a.public()),
|
||||
new_free: 0,
|
||||
}
|
||||
.into(),
|
||||
@@ -69,7 +69,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec
|
||||
SudoCall::sudo {
|
||||
call: Box::new(
|
||||
BalancesCall::force_set_balance {
|
||||
who: AccountId::from(a.public()).into(),
|
||||
who: AccountId::from(a.public()),
|
||||
new_free: 1_000_000_000_000 * ExistentialDeposit::get(),
|
||||
}
|
||||
.into(),
|
||||
@@ -80,7 +80,6 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec
|
||||
),
|
||||
]
|
||||
})
|
||||
.flatten()
|
||||
.map(OpaqueExtrinsic::from)
|
||||
.collect()
|
||||
}
|
||||
@@ -92,20 +91,19 @@ fn create_benchmark_extrinsics(
|
||||
) -> Vec<OpaqueExtrinsic> {
|
||||
accounts
|
||||
.iter()
|
||||
.map(|account| {
|
||||
.flat_map(|account| {
|
||||
(0..extrinsics_per_account).map(move |nonce| {
|
||||
construct_extrinsic(
|
||||
client,
|
||||
BalancesCall::transfer_allow_death {
|
||||
dest: Bob.to_account_id().into(),
|
||||
value: 1 * ExistentialDeposit::get(),
|
||||
dest: Bob.to_account_id(),
|
||||
value: ExistentialDeposit::get(),
|
||||
},
|
||||
account.clone(),
|
||||
Some(nonce as u32),
|
||||
)
|
||||
})
|
||||
})
|
||||
.flatten()
|
||||
.map(OpaqueExtrinsic::from)
|
||||
.collect()
|
||||
}
|
||||
@@ -208,27 +206,27 @@ fn transaction_throughput_benchmarks(c: &mut Criterion) {
|
||||
|b| {
|
||||
b.iter_batched(
|
||||
|| {
|
||||
let prepare_extrinsics = create_account_extrinsics(&*dave.client, &accounts);
|
||||
let prepare_extrinsics = create_account_extrinsics(&dave.client, &accounts);
|
||||
|
||||
benchmark_handle.block_on(future::join_all(
|
||||
prepare_extrinsics.into_iter().map(|tx| {
|
||||
submit_tx_and_wait_for_inclusion(
|
||||
&dave.transaction_pool,
|
||||
tx,
|
||||
&*dave.client,
|
||||
&dave.client,
|
||||
true,
|
||||
)
|
||||
}),
|
||||
));
|
||||
|
||||
create_benchmark_extrinsics(&*dave.client, &accounts, extrinsics_per_account)
|
||||
create_benchmark_extrinsics(&dave.client, &accounts, extrinsics_per_account)
|
||||
},
|
||||
|extrinsics| {
|
||||
benchmark_handle.block_on(future::join_all(extrinsics.into_iter().map(|tx| {
|
||||
submit_tx_and_wait_for_inclusion(
|
||||
&dave.transaction_pool,
|
||||
tx,
|
||||
&*dave.client,
|
||||
&dave.client,
|
||||
false,
|
||||
)
|
||||
})));
|
||||
|
||||
@@ -39,7 +39,7 @@ pub struct GenesisExt {
|
||||
impl sp_runtime::BuildStorage for GenesisExt {
|
||||
fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> {
|
||||
sp_state_machine::BasicExternalities::execute_with_storage(storage, || {
|
||||
sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &vec![1, 2, 3, 4]);
|
||||
sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &[1, 2, 3, 4]);
|
||||
cumulus_test_runtime::ParachainId::set(&self.para_id);
|
||||
});
|
||||
|
||||
@@ -125,7 +125,6 @@ fn testnet_genesis(
|
||||
code: cumulus_test_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
..Default::default()
|
||||
},
|
||||
parachain_system: Default::default(),
|
||||
balances: cumulus_test_runtime::BalancesConfig {
|
||||
|
||||
@@ -630,7 +630,7 @@ impl TestNodeBuilder {
|
||||
let parachain_config = node_config(
|
||||
self.storage_update_func_parachain.unwrap_or_else(|| Box::new(|| ())),
|
||||
self.tokio_handle.clone(),
|
||||
self.key.clone(),
|
||||
self.key,
|
||||
self.parachain_nodes,
|
||||
self.parachain_nodes_exclusive,
|
||||
self.para_id,
|
||||
@@ -667,7 +667,7 @@ impl TestNodeBuilder {
|
||||
.await
|
||||
.expect("could not create Cumulus test service");
|
||||
|
||||
let peer_id = network.local_peer_id().clone();
|
||||
let peer_id = network.local_peer_id();
|
||||
let addr = MultiaddrWithPeerId { multiaddr, peer_id };
|
||||
|
||||
TestNode { task_manager, client, network, addr, rpc_handlers, transaction_pool }
|
||||
@@ -690,7 +690,7 @@ pub fn node_config(
|
||||
is_collator: bool,
|
||||
) -> Result<Configuration, ServiceError> {
|
||||
let base_path = BasePath::new_temp_dir()?;
|
||||
let root = base_path.path().join(format!("cumulus_test_service_{}", key.to_string()));
|
||||
let root = base_path.path().join(format!("cumulus_test_service_{}", key));
|
||||
let role = if is_collator { Role::Authority } else { Role::Full };
|
||||
let key_seed = key.to_seed();
|
||||
let mut spec = Box::new(chain_spec::get_chain_spec(para_id));
|
||||
@@ -786,7 +786,7 @@ impl TestNode {
|
||||
function: impl Into<runtime::RuntimeCall>,
|
||||
caller: Sr25519Keyring,
|
||||
) -> Result<RpcTransactionOutput, RpcTransactionError> {
|
||||
let extrinsic = construct_extrinsic(&*self.client, function, caller.pair(), Some(0));
|
||||
let extrinsic = construct_extrinsic(&self.client, function, caller.pair(), Some(0));
|
||||
|
||||
self.rpc_handlers.send_transaction(extrinsic.into()).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user