style: Migrate to stable-only rustfmt configuration
- Remove nightly-only features from .rustfmt.toml and vendor/ss58-registry/rustfmt.toml - Removed features: imports_granularity, wrap_comments, comment_width, reorder_impl_items, spaces_around_ranges, binop_separator, match_arm_blocks, trailing_semicolon, trailing_comma - Format all 898 affected files with stable rustfmt - Ensures long-term reliability without nightly toolchain dependency
This commit is contained in:
@@ -420,8 +420,8 @@ where
|
||||
// not a descendant of `hash`.
|
||||
let children = std::mem::take(&mut curr.children);
|
||||
for child in children {
|
||||
if child.number == *number && child.hash == *hash ||
|
||||
*number < child.number && is_descendent_of(hash, &child.hash)?
|
||||
if child.number == *number && child.hash == *hash
|
||||
|| *number < child.number && is_descendent_of(hash, &child.hash)?
|
||||
{
|
||||
curr.children.push(child);
|
||||
} else {
|
||||
@@ -544,9 +544,10 @@ where
|
||||
let is_finalized = root.hash == *hash;
|
||||
let is_descendant =
|
||||
!is_finalized && root.number > number && is_descendent_of(hash, &root.hash)?;
|
||||
let is_ancestor = !is_finalized &&
|
||||
!is_descendant && root.number < number &&
|
||||
is_descendent_of(&root.hash, hash)?;
|
||||
let is_ancestor = !is_finalized
|
||||
&& !is_descendant
|
||||
&& root.number < number
|
||||
&& is_descendent_of(&root.hash, hash)?;
|
||||
(is_finalized, is_descendant, is_ancestor)
|
||||
};
|
||||
|
||||
@@ -617,8 +618,8 @@ where
|
||||
if predicate(&node.data) && (node.hash == *hash || is_descendent_of(&node.hash, hash)?)
|
||||
{
|
||||
for child in node.children.iter() {
|
||||
if child.number <= number &&
|
||||
(child.hash == *hash || is_descendent_of(&child.hash, hash)?)
|
||||
if child.number <= number
|
||||
&& (child.hash == *hash || is_descendent_of(&child.hash, hash)?)
|
||||
{
|
||||
return Err(Error::UnfinalizedAncestor);
|
||||
}
|
||||
@@ -664,8 +665,8 @@ where
|
||||
if predicate(&root.data) && (root.hash == *hash || is_descendent_of(&root.hash, hash)?)
|
||||
{
|
||||
for child in root.children.iter() {
|
||||
if child.number <= number &&
|
||||
(child.hash == *hash || is_descendent_of(&child.hash, hash)?)
|
||||
if child.number <= number
|
||||
&& (child.hash == *hash || is_descendent_of(&child.hash, hash)?)
|
||||
{
|
||||
return Err(Error::UnfinalizedAncestor);
|
||||
}
|
||||
@@ -692,9 +693,9 @@ where
|
||||
let roots = std::mem::take(&mut self.roots);
|
||||
|
||||
for root in roots {
|
||||
let retain = root.number > number && is_descendent_of(hash, &root.hash)? ||
|
||||
root.number == number && root.hash == *hash ||
|
||||
is_descendent_of(&root.hash, hash)?;
|
||||
let retain = root.number > number && is_descendent_of(hash, &root.hash)?
|
||||
|| root.number == number && root.hash == *hash
|
||||
|| is_descendent_of(&root.hash, hash)?;
|
||||
|
||||
if retain {
|
||||
self.roots.push(root);
|
||||
@@ -1162,15 +1163,15 @@ mod test {
|
||||
// finalizing "D" will finalize a block from the tree, but it can't be applied yet
|
||||
// since it is not a root change.
|
||||
assert_eq!(
|
||||
tree.finalizes_any_with_descendent_if(&"D", 10, &is_descendent_of, |c| c.effective ==
|
||||
10),
|
||||
tree.finalizes_any_with_descendent_if(&"D", 10, &is_descendent_of, |c| c.effective
|
||||
== 10),
|
||||
Ok(Some(false)),
|
||||
);
|
||||
|
||||
// finalizing "E" is not allowed since there are not finalized ancestors.
|
||||
assert_eq!(
|
||||
tree.finalizes_any_with_descendent_if(&"E", 15, &is_descendent_of, |c| c.effective ==
|
||||
10),
|
||||
tree.finalizes_any_with_descendent_if(&"E", 15, &is_descendent_of, |c| c.effective
|
||||
== 10),
|
||||
Err(Error::UnfinalizedAncestor)
|
||||
);
|
||||
|
||||
@@ -1203,15 +1204,15 @@ mod test {
|
||||
|
||||
// finalizing "F" will fail since it would finalize past "E" without finalizing "D" first
|
||||
assert_eq!(
|
||||
tree.finalizes_any_with_descendent_if(&"F", 100, &is_descendent_of, |c| c.effective <=
|
||||
100,),
|
||||
tree.finalizes_any_with_descendent_if(&"F", 100, &is_descendent_of, |c| c.effective
|
||||
<= 100,),
|
||||
Err(Error::UnfinalizedAncestor),
|
||||
);
|
||||
|
||||
// it will work with "G" though since it is not in the same branch as "E"
|
||||
assert_eq!(
|
||||
tree.finalizes_any_with_descendent_if(&"G", 100, &is_descendent_of, |c| c.effective <=
|
||||
100),
|
||||
tree.finalizes_any_with_descendent_if(&"G", 100, &is_descendent_of, |c| c.effective
|
||||
<= 100),
|
||||
Ok(Some(true)),
|
||||
);
|
||||
|
||||
|
||||
@@ -114,8 +114,9 @@ impl ExtrinsicCmd {
|
||||
let extrinsic = self.params.extrinsic.clone().unwrap_or_default();
|
||||
let ext_builder = match ext_factory.try_get(&pezpallet, &extrinsic) {
|
||||
Some(ext_builder) => ext_builder,
|
||||
None =>
|
||||
return Err("Unknown pezpallet or extrinsic. Use --list for a complete list.".into()),
|
||||
None => {
|
||||
return Err("Unknown pezpallet or extrinsic. Use --list for a complete list.".into())
|
||||
},
|
||||
};
|
||||
|
||||
let bench =
|
||||
|
||||
@@ -150,8 +150,9 @@ impl MachineCmd {
|
||||
|
||||
let score = match metric {
|
||||
Metric::Blake2256 => benchmark_cpu(hash_limit),
|
||||
Metric::Blake2256Parallel { num_cores } =>
|
||||
benchmark_cpu_parallelism(hash_limit, *num_cores),
|
||||
Metric::Blake2256Parallel { num_cores } => {
|
||||
benchmark_cpu_parallelism(hash_limit, *num_cores)
|
||||
},
|
||||
Metric::Sr25519Verify => benchmark_sr25519_verify(verify_limit),
|
||||
Metric::MemCopy => benchmark_memory(memory_limit),
|
||||
Metric::DiskSeqWrite => benchmark_disk_sequential_writes(disk_limit, dir)?,
|
||||
|
||||
@@ -42,6 +42,7 @@ use genesis_state::WARN_SPEC_GENESIS_CTOR;
|
||||
use log::info;
|
||||
use pezcumulus_client_teyrchain_inherent::MockValidationDataInherentDataProvider;
|
||||
use pezframe_support::Deserialize;
|
||||
use pezkuwi_subxt::{client::RuntimeVersion, ext::futures, Metadata};
|
||||
use pezkuwi_teyrchain_primitives::primitives::Id as ParaId;
|
||||
use pezsc_block_builder::BlockBuilderApi;
|
||||
use pezsc_chain_spec::{ChainSpec, ChainSpecExtension, GenesisBlockBuilder};
|
||||
@@ -70,7 +71,6 @@ use std::{
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
};
|
||||
use pezkuwi_subxt::{client::RuntimeVersion, ext::futures, Metadata};
|
||||
|
||||
const DEFAULT_PARA_ID: u32 = 100;
|
||||
const LOG_TARGET: &'static str = "pezkuwi_sdk_frame::benchmark::overhead";
|
||||
@@ -273,8 +273,9 @@ impl OverheadCmd {
|
||||
chain_spec_from_api: Option<Box<dyn ChainSpec>>,
|
||||
) -> Result<(GenesisStateHandler, Option<u32>)> {
|
||||
let genesis_builder_to_source = || match self.params.genesis_builder {
|
||||
Some(GenesisBuilderPolicy::Runtime) | Some(GenesisBuilderPolicy::SpecRuntime) =>
|
||||
SpecGenesisSource::Runtime(self.params.genesis_builder_preset.clone()),
|
||||
Some(GenesisBuilderPolicy::Runtime) | Some(GenesisBuilderPolicy::SpecRuntime) => {
|
||||
SpecGenesisSource::Runtime(self.params.genesis_builder_preset.clone())
|
||||
},
|
||||
Some(GenesisBuilderPolicy::SpecGenesis) | None => {
|
||||
log::warn!(target: LOG_TARGET, "{WARN_SPEC_GENESIS_CTOR}");
|
||||
SpecGenesisSource::SpecJson
|
||||
@@ -328,9 +329,9 @@ impl OverheadCmd {
|
||||
&self,
|
||||
chain_spec: &Option<Box<dyn ChainSpec>>,
|
||||
) -> std::result::Result<(), (ErrorKind, String)> {
|
||||
if chain_spec.is_none() &&
|
||||
self.params.runtime.is_none() &&
|
||||
self.shared_params.chain.is_none()
|
||||
if chain_spec.is_none()
|
||||
&& self.params.runtime.is_none()
|
||||
&& self.shared_params.chain.is_none()
|
||||
{
|
||||
return Err((
|
||||
ErrorKind::MissingRequiredArgument,
|
||||
@@ -340,13 +341,14 @@ impl OverheadCmd {
|
||||
}
|
||||
|
||||
match self.params.genesis_builder {
|
||||
Some(GenesisBuilderPolicy::SpecGenesis | GenesisBuilderPolicy::SpecRuntime) =>
|
||||
Some(GenesisBuilderPolicy::SpecGenesis | GenesisBuilderPolicy::SpecRuntime) => {
|
||||
if chain_spec.is_none() && self.shared_params.chain.is_none() {
|
||||
return Err((
|
||||
ErrorKind::MissingRequiredArgument,
|
||||
"Provide a chain spec via `--chain`.".to_string(),
|
||||
));
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
};
|
||||
Ok(())
|
||||
@@ -414,8 +416,9 @@ impl OverheadCmd {
|
||||
// If we are dealing with a teyrchain, make sure that the para id in genesis will
|
||||
// match what we expect.
|
||||
let genesis_patcher = match chain_type {
|
||||
Teyrchain(para_id) =>
|
||||
Some(Box::new(move |value| patch_genesis(value, Some(para_id))) as Box<_>),
|
||||
Teyrchain(para_id) => {
|
||||
Some(Box::new(move |value| patch_genesis(value, Some(para_id))) as Box<_>)
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
|
||||
use crate::extrinsic::ExtrinsicBuilder;
|
||||
use codec::{Decode, Encode};
|
||||
use pezkuwi_subxt::{
|
||||
client::RuntimeVersion as SubxtRuntimeVersion,
|
||||
config::{bizinikiwi::BizinikiwiExtrinsicParamsBuilder as ParamsBuilder, HashFor},
|
||||
BizinikiwConfig, Config, OfflineClient,
|
||||
};
|
||||
use pezsc_client_api::UsageProvider;
|
||||
use pezsp_api::{ApiExt, Core, Metadata, ProvideRuntimeApi};
|
||||
use pezsp_runtime::{traits::Block as BlockT, OpaqueExtrinsic};
|
||||
use std::sync::Arc;
|
||||
use pezkuwi_subxt::{
|
||||
client::RuntimeVersion as SubxtRuntimeVersion,
|
||||
config::{bizinikiwi::BizinikiwiExtrinsicParamsBuilder as ParamsBuilder, HashFor},
|
||||
Config, OfflineClient, BizinikiwConfig,
|
||||
};
|
||||
|
||||
/// Bizinikiwi configuration
|
||||
pub type BizinikiwiConfig = BizinikiwConfig;
|
||||
|
||||
@@ -166,8 +166,9 @@ impl PalletCmd {
|
||||
chain_spec_from_api: Option<Box<dyn ChainSpec>>,
|
||||
) -> Result<GenesisStateHandler> {
|
||||
let genesis_builder_to_source = || match self.genesis_builder {
|
||||
Some(GenesisBuilderPolicy::Runtime) | Some(GenesisBuilderPolicy::SpecRuntime) =>
|
||||
SpecGenesisSource::Runtime(self.genesis_builder_preset.clone()),
|
||||
Some(GenesisBuilderPolicy::Runtime) | Some(GenesisBuilderPolicy::SpecRuntime) => {
|
||||
SpecGenesisSource::Runtime(self.genesis_builder_preset.clone())
|
||||
},
|
||||
Some(GenesisBuilderPolicy::SpecGenesis) | None => {
|
||||
log::warn!(target: LOG_TARGET, "{WARN_SPEC_GENESIS_CTOR}");
|
||||
SpecGenesisSource::SpecJson
|
||||
@@ -244,13 +245,15 @@ impl PalletCmd {
|
||||
if let Some(json_input) = &self.json_input {
|
||||
let raw_data = match std::fs::read(json_input) {
|
||||
Ok(raw_data) => raw_data,
|
||||
Err(error) =>
|
||||
return Err(format!("Failed to read {:?}: {}", json_input, error).into()),
|
||||
Err(error) => {
|
||||
return Err(format!("Failed to read {:?}: {}", json_input, error).into())
|
||||
},
|
||||
};
|
||||
let batches: Vec<BenchmarkBatchSplitResults> = match serde_json::from_slice(&raw_data) {
|
||||
Ok(batches) => batches,
|
||||
Err(error) =>
|
||||
return Err(format!("Failed to deserialize {:?}: {}", json_input, error).into()),
|
||||
Err(error) => {
|
||||
return Err(format!("Failed to deserialize {:?}: {}", json_input, error).into())
|
||||
},
|
||||
};
|
||||
return self.output_from_results(&batches);
|
||||
}
|
||||
@@ -632,10 +635,10 @@ impl PalletCmd {
|
||||
fn pezpallet_selected(&self, pezpallet: &Vec<u8>) -> bool {
|
||||
let include = self.pallets.clone();
|
||||
|
||||
let included = include.is_empty() ||
|
||||
include.iter().any(|p| p.as_bytes() == pezpallet) ||
|
||||
include.iter().any(|p| p == "*") ||
|
||||
include.iter().any(|p| p == "all");
|
||||
let included = include.is_empty()
|
||||
|| include.iter().any(|p| p.as_bytes() == pezpallet)
|
||||
|| include.iter().any(|p| p == "*")
|
||||
|| include.iter().any(|p| p == "all");
|
||||
let excluded = self.exclude_pallets.iter().any(|p| p.as_bytes() == pezpallet);
|
||||
|
||||
included && !excluded
|
||||
@@ -651,10 +654,10 @@ impl PalletCmd {
|
||||
let extrinsic_split: Vec<&str> = extrinsic_filter.split(',').collect();
|
||||
let extrinsics: Vec<_> = extrinsic_split.iter().map(|x| x.trim().as_bytes()).collect();
|
||||
|
||||
let included = extrinsic_filter.is_empty() ||
|
||||
extrinsic_filter == "*" ||
|
||||
extrinsic_filter == "all" ||
|
||||
extrinsics.contains(&&extrinsic[..]);
|
||||
let included = extrinsic_filter.is_empty()
|
||||
|| extrinsic_filter == "*"
|
||||
|| extrinsic_filter == "all"
|
||||
|| extrinsics.contains(&&extrinsic[..]);
|
||||
|
||||
let excluded = self
|
||||
.excluded_extrinsics()
|
||||
@@ -964,12 +967,13 @@ impl PalletCmd {
|
||||
.or_default()
|
||||
.entry((pov_pallet.to_string(), pov_storage.to_string()))
|
||||
{
|
||||
Entry::Occupied(_) =>
|
||||
Entry::Occupied(_) => {
|
||||
return Err(format!(
|
||||
"Cannot specify pov_mode tag twice for the same key: {}",
|
||||
pezpallet_storage
|
||||
)
|
||||
.into()),
|
||||
.into())
|
||||
},
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(mode);
|
||||
},
|
||||
@@ -1031,13 +1035,14 @@ impl PalletCmd {
|
||||
}
|
||||
|
||||
match self.genesis_builder {
|
||||
Some(GenesisBuilderPolicy::SpecGenesis | GenesisBuilderPolicy::SpecRuntime) =>
|
||||
Some(GenesisBuilderPolicy::SpecGenesis | GenesisBuilderPolicy::SpecRuntime) => {
|
||||
if chain_spec.is_none() && self.shared_params.chain.is_none() {
|
||||
return Err((
|
||||
ErrorKind::MissingRequiredArgument,
|
||||
"Provide a chain spec via `--chain`.".to_string(),
|
||||
));
|
||||
},
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
|
||||
@@ -583,8 +583,9 @@ pub(crate) fn process_storage_results(
|
||||
let mut prefix_result = result.clone();
|
||||
let key_info = storage_info_map.get(&prefix);
|
||||
let pezpallet_name = match key_info {
|
||||
Some(k) =>
|
||||
String::from_utf8(k.pezpallet_name.clone()).expect("encoded from string"),
|
||||
Some(k) => {
|
||||
String::from_utf8(k.pezpallet_name.clone()).expect("encoded from string")
|
||||
},
|
||||
None => "".to_string(),
|
||||
};
|
||||
let storage_name = match key_info {
|
||||
@@ -606,8 +607,8 @@ pub(crate) fn process_storage_results(
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
let is_all_ignored = pov_modes.get(&("ALL".to_string(), "ALL".to_string())) ==
|
||||
Some(&PovEstimationMode::Ignored);
|
||||
let is_all_ignored = pov_modes.get(&("ALL".to_string(), "ALL".to_string()))
|
||||
== Some(&PovEstimationMode::Ignored);
|
||||
if is_all_ignored && override_pov_mode != Some(&PovEstimationMode::Ignored) {
|
||||
panic!("The syntax currently does not allow to exclude single keys from a top-level `Ignored` pov-mode.");
|
||||
}
|
||||
|
||||
@@ -75,8 +75,9 @@ impl GenesisStateHandler {
|
||||
.map_err(|e| format!("{ERROR_CANNOT_BUILD_GENESIS}\nError: {e}").into()),
|
||||
SpecGenesisSource::None => Ok(Storage::default()),
|
||||
},
|
||||
GenesisStateHandler::Runtime(code_bytes, Some(preset)) =>
|
||||
genesis_from_code::<HF>(code_bytes.as_slice(), preset, json_patcher),
|
||||
GenesisStateHandler::Runtime(code_bytes, Some(preset)) => {
|
||||
genesis_from_code::<HF>(code_bytes.as_slice(), preset, json_patcher)
|
||||
},
|
||||
GenesisStateHandler::Runtime(_, None) => Ok(Storage::default()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ impl StorageCmd {
|
||||
if self.params.is_validate_block_mode() && self.params.disable_pov_recorder {
|
||||
return Err("PoV recorder must be activated to provide a storage proof for block validation at runtime. Remove `--disable-pov-recorder` from the command line.".into());
|
||||
}
|
||||
if self.params.is_validate_block_mode() &&
|
||||
self.params.batch_size > MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION
|
||||
if self.params.is_validate_block_mode()
|
||||
&& self.params.batch_size > MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION
|
||||
{
|
||||
return Err(format!("Batch size is too large. This may cause problems with runtime memory allocation. Better set `--batch-size {}` or less.", MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION).into());
|
||||
}
|
||||
@@ -158,8 +158,8 @@ impl StorageCmd {
|
||||
record.append(v.len(), start.elapsed())?;
|
||||
}
|
||||
read_in_batch += 1;
|
||||
let is_batch_full = read_in_batch >= self.params.batch_size ||
|
||||
(last_child_key == key && last_child_info == info);
|
||||
let is_batch_full = read_in_batch >= self.params.batch_size
|
||||
|| (last_child_key == key && last_child_info == info);
|
||||
|
||||
// Read child keys on block validation
|
||||
if is_batch_full && self.params.is_validate_block_mode() {
|
||||
|
||||
@@ -61,8 +61,8 @@ impl StorageCmd {
|
||||
if self.params.is_validate_block_mode() && self.params.disable_pov_recorder {
|
||||
return Err("PoV recorder must be activated to provide a storage proof for block validation at runtime. Remove `--disable-pov-recorder`.".into());
|
||||
}
|
||||
if self.params.is_validate_block_mode() &&
|
||||
self.params.batch_size > MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION
|
||||
if self.params.is_validate_block_mode()
|
||||
&& self.params.batch_size > MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION
|
||||
{
|
||||
return Err(format!("Batch size is too large. This may cause problems with runtime memory allocation. Better set `--batch-size {}` or less.", MAX_BATCH_SIZE_FOR_BLOCK_VALIDATION).into());
|
||||
}
|
||||
|
||||
@@ -1396,8 +1396,8 @@ mod remote_tests {
|
||||
|
||||
// there should be more keys in the child ext.
|
||||
assert!(
|
||||
child_ext.as_backend().backend_storage().keys().len() >
|
||||
ext.as_backend().backend_storage().keys().len()
|
||||
child_ext.as_backend().backend_storage().keys().len()
|
||||
> ext.as_backend().backend_storage().keys().len()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ fn count_migrate<'a, H: Hasher>(
|
||||
NodePlan::Leaf { value, .. } | NodePlan::NibbledBranch { value: Some(value), .. } => {
|
||||
total_nb += 1;
|
||||
if let ValuePlan::Inline(range) = value {
|
||||
if (range.end - range.start) as u32 >=
|
||||
pezsp_core::storage::TRIE_VALUE_NODE_THRESHOLD
|
||||
if (range.end - range.start) as u32
|
||||
>= pezsp_core::storage::TRIE_VALUE_NODE_THRESHOLD
|
||||
{
|
||||
nb += 1;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ pub fn proceed_storage_access<B: traits::Block>(mut params: &[u8]) {
|
||||
}
|
||||
|
||||
match payload {
|
||||
StorageAccessPayload::Read(keys) =>
|
||||
StorageAccessPayload::Read(keys) => {
|
||||
for (key, maybe_child_info) in keys {
|
||||
match maybe_child_info {
|
||||
Some(child_info) => {
|
||||
@@ -141,7 +141,8 @@ pub fn proceed_storage_access<B: traits::Block>(mut params: &[u8]) {
|
||||
.ok_or("Value unexpectedly empty");
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
StorageAccessPayload::Write((changes, maybe_child_info)) => {
|
||||
let delta = changes.iter().map(|(key, value)| (key.as_ref(), Some(value.as_ref())));
|
||||
match maybe_child_info {
|
||||
|
||||
@@ -13,21 +13,23 @@ use bizinikiwi_txtesttool::{
|
||||
runner::DefaultTxTask,
|
||||
scenario::{AccountsDescription, ChainType, ScenarioBuilder, ScenarioType},
|
||||
subxt_transaction::{
|
||||
self, generate_ecdsa_keypair, generate_sr25519_keypair, EthRuntimeConfig, EthTransaction,
|
||||
EthTransactionsSink, BizinikiwTransaction, BizinikiwTransactionsSink, SENDER_SEED,
|
||||
self, generate_ecdsa_keypair, generate_sr25519_keypair, BizinikiwTransaction,
|
||||
BizinikiwTransactionsSink, EthRuntimeConfig, EthTransaction, EthTransactionsSink,
|
||||
SENDER_SEED,
|
||||
},
|
||||
};
|
||||
use clap::Parser;
|
||||
use codec::Compact;
|
||||
use std::{fs, fs::File, io::BufReader, time::Duration};
|
||||
use pezkuwi_subxt::{ext::frame_metadata::RuntimeMetadataPrefixed, PezkuwiConfig};
|
||||
use std::{fs, fs::File, io::BufReader, time::Duration};
|
||||
use tracing::info;
|
||||
|
||||
macro_rules! populate_scenario_builder {
|
||||
($scenario_builder:expr, $scenario_type:expr) => {{
|
||||
match $scenario_type {
|
||||
ScenarioType::OneShot { account, nonce } =>
|
||||
$scenario_builder.with_account_id(account.clone()).with_nonce_from(*nonce),
|
||||
ScenarioType::OneShot { account, nonce } => {
|
||||
$scenario_builder.with_account_id(account.clone()).with_nonce_from(*nonce)
|
||||
},
|
||||
ScenarioType::FromSingleAccount { account, from, count } => $scenario_builder
|
||||
.with_account_id(account.clone())
|
||||
.with_nonce_from(*from)
|
||||
@@ -161,7 +163,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
CliCommand::Metadata { ws } => {
|
||||
// Handle metadata command
|
||||
use codec::Decode;
|
||||
let api = pezkuwi_subxt::OnlineClient::<EthRuntimeConfig>::from_insecure_url(ws).await?;
|
||||
let api =
|
||||
pezkuwi_subxt::OnlineClient::<EthRuntimeConfig>::from_insecure_url(ws).await?;
|
||||
let runtime_apis = api.runtime_api().at_latest().await?;
|
||||
let raw_bytes: Vec<u8> = runtime_apis.call_raw("Metadata_metadata", None).await?;
|
||||
let (_, meta): (Compact<u32>, RuntimeMetadataPrefixed) =
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
};
|
||||
use average::{Estimate, Max, Mean, Min, Quantile};
|
||||
use parking_lot::RwLock;
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@@ -22,7 +23,6 @@ use std::{
|
||||
},
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use tracing::{debug, info, trace};
|
||||
|
||||
pub const STAT_TARGET: &str = "stat";
|
||||
@@ -115,11 +115,11 @@ impl Counters {
|
||||
}
|
||||
|
||||
pub fn buffered(&self) -> usize {
|
||||
self.popped.load(Ordering::Relaxed) -
|
||||
(self.submit_and_watch_success.load(Ordering::Relaxed) +
|
||||
self.submit_and_watch_error.load(Ordering::Relaxed)) -
|
||||
(self.submit_success.load(Ordering::Relaxed) +
|
||||
self.submit_error.load(Ordering::Relaxed))
|
||||
self.popped.load(Ordering::Relaxed)
|
||||
- (self.submit_and_watch_success.load(Ordering::Relaxed)
|
||||
+ self.submit_and_watch_error.load(Ordering::Relaxed))
|
||||
- (self.submit_success.load(Ordering::Relaxed)
|
||||
+ self.submit_error.load(Ordering::Relaxed))
|
||||
}
|
||||
|
||||
fn count_event<H: BlockHash>(&self, event: &ExecutionEvent<H>) {
|
||||
@@ -128,10 +128,12 @@ impl Counters {
|
||||
ExecutionEvent::Sent(_) => Self::inc(&self.sent),
|
||||
ExecutionEvent::SubmitResult(_, Ok(_)) => Self::inc(&self.submit_success),
|
||||
ExecutionEvent::SubmitResult(_, Err(_)) => Self::inc(&self.submit_error),
|
||||
ExecutionEvent::SubmitAndWatchResult(_, Ok(_)) =>
|
||||
Self::inc(&self.submit_and_watch_success),
|
||||
ExecutionEvent::SubmitAndWatchResult(_, Err(_)) =>
|
||||
Self::inc(&self.submit_and_watch_error),
|
||||
ExecutionEvent::SubmitAndWatchResult(_, Ok(_)) => {
|
||||
Self::inc(&self.submit_and_watch_success)
|
||||
},
|
||||
ExecutionEvent::SubmitAndWatchResult(_, Err(_)) => {
|
||||
Self::inc(&self.submit_and_watch_error)
|
||||
},
|
||||
ExecutionEvent::FinalizedMonitor(_, _) => Self::inc(&self.finalized_monitor),
|
||||
ExecutionEvent::TxPoolEvent(_, status) => match status {
|
||||
TransactionStatus::Validated => Self::inc(&self.ts_validated),
|
||||
@@ -314,8 +316,9 @@ impl<H: BlockHash + 'static> ExecutionLog for TransactionExecutionLog<H> {
|
||||
if match event {
|
||||
// note: dedup in block events - on the stats line we want to see transactions included,
|
||||
// not events count
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::InBlock(_)) =>
|
||||
self.in_blocks().is_empty(),
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::InBlock(_)) => {
|
||||
self.in_blocks().is_empty()
|
||||
},
|
||||
_ => true,
|
||||
} {
|
||||
self.total_counters.count_event(&event);
|
||||
@@ -437,8 +440,9 @@ impl<H: BlockHash + 'static> ExecutionLog for TransactionExecutionLog<H> {
|
||||
|
||||
fn time_to_result(&self) -> Option<Duration> {
|
||||
let ets = self.events.read().iter().find_map(|e| match e {
|
||||
ExecutionEvent::SubmitAndWatchResult(i, _) | ExecutionEvent::SubmitResult(i, _) =>
|
||||
Some(*i),
|
||||
ExecutionEvent::SubmitAndWatchResult(i, _) | ExecutionEvent::SubmitResult(i, _) => {
|
||||
Some(*i)
|
||||
},
|
||||
_ => None,
|
||||
});
|
||||
Self::duration_since_timestamp(self.get_sent_time_stamp(), ets)
|
||||
@@ -449,8 +453,9 @@ impl<H: BlockHash + 'static> ExecutionLog for TransactionExecutionLog<H> {
|
||||
.read()
|
||||
.iter()
|
||||
.filter_map(|e| match e {
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Invalid(reason)) =>
|
||||
Some(reason.clone()),
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Invalid(reason)) => {
|
||||
Some(reason.clone())
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
@@ -461,8 +466,9 @@ impl<H: BlockHash + 'static> ExecutionLog for TransactionExecutionLog<H> {
|
||||
.read()
|
||||
.iter()
|
||||
.filter_map(|e| match e {
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Error(reason)) =>
|
||||
Some(reason.clone()),
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Error(reason)) => {
|
||||
Some(reason.clone())
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
@@ -473,8 +479,9 @@ impl<H: BlockHash + 'static> ExecutionLog for TransactionExecutionLog<H> {
|
||||
.read()
|
||||
.iter()
|
||||
.filter_map(|e| match e {
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Dropped(reason)) =>
|
||||
Some(reason.clone()),
|
||||
ExecutionEvent::TxPoolEvent(_, TransactionStatus::Dropped(reason)) => {
|
||||
Some(reason.clone())
|
||||
},
|
||||
_ => None,
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::{
|
||||
};
|
||||
use futures::stream::{self};
|
||||
use futures_util::StreamExt;
|
||||
use pezkuwi_subxt::ext::codec::{Decode, Encode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
any::Any,
|
||||
@@ -17,7 +18,6 @@ use std::{
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
use pezkuwi_subxt::ext::codec::{Decode, Encode};
|
||||
use tokio::task::yield_now;
|
||||
use tracing::trace;
|
||||
|
||||
@@ -319,16 +319,19 @@ impl FakeTransaction {
|
||||
trace!(target:LOG_TARGET, "submit_result: delayed: {:?}", self.hash);
|
||||
match event {
|
||||
TransactionStatus::Finalized(_) => Ok(self.hash),
|
||||
TransactionStatus::Dropped(message) =>
|
||||
Err(Error::Other(format!("submit-error:dropped:{message}").to_string())),
|
||||
TransactionStatus::Invalid(message) =>
|
||||
Err(Error::Other(format!("submit-error:invalid:{message}").to_string())),
|
||||
TransactionStatus::Error(message) =>
|
||||
Err(Error::Other(format!("submit-error:error:{message}").to_string())),
|
||||
TransactionStatus::Validated |
|
||||
TransactionStatus::NoLongerInBestBlock |
|
||||
TransactionStatus::Broadcasted |
|
||||
TransactionStatus::InBlock(_) => todo!(),
|
||||
TransactionStatus::Dropped(message) => {
|
||||
Err(Error::Other(format!("submit-error:dropped:{message}").to_string()))
|
||||
},
|
||||
TransactionStatus::Invalid(message) => {
|
||||
Err(Error::Other(format!("submit-error:invalid:{message}").to_string()))
|
||||
},
|
||||
TransactionStatus::Error(message) => {
|
||||
Err(Error::Other(format!("submit-error:error:{message}").to_string()))
|
||||
},
|
||||
TransactionStatus::Validated
|
||||
| TransactionStatus::NoLongerInBestBlock
|
||||
| TransactionStatus::Broadcasted
|
||||
| TransactionStatus::InBlock(_) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ pub fn init_logger() {
|
||||
}
|
||||
impl<S> Filter<S> for F {
|
||||
fn enabled(&self, meta: &Metadata<'_>, cx: &Context<'_, S>) -> bool {
|
||||
!self.env_filter.enabled(meta, cx.clone()) &&
|
||||
meta.target() == execution_log::STAT_TARGET
|
||||
!self.env_filter.enabled(meta, cx.clone())
|
||||
&& meta.target() == execution_log::STAT_TARGET
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ use crate::{
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use futures::{stream::FuturesUnordered, Future, StreamExt};
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use std::{
|
||||
path::Path,
|
||||
pin::Pin,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant, SystemTime},
|
||||
};
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use tokio::{
|
||||
select,
|
||||
sync::mpsc::{channel, Receiver, Sender},
|
||||
|
||||
@@ -18,12 +18,12 @@ use crate::{
|
||||
runner::{DefaultTxTask, Runner, TxTask},
|
||||
subxt_transaction::{
|
||||
eth_transfer_payload_builder, generate_ecdsa_keypair, generate_sr25519_keypair,
|
||||
remark_payload_builder, sub_transfer_payload_builder, EthPayloadBuilderFn, EthTransaction,
|
||||
EthTransactionsSink, EthTxBuildContext, SubPayloadBuilderFn, SubTxBuildContext,
|
||||
BizinikiwTransaction, BizinikiwTransactionsSink,
|
||||
remark_payload_builder, sub_transfer_payload_builder, BizinikiwTransaction,
|
||||
BizinikiwTransactionsSink, EthPayloadBuilderFn, EthTransaction, EthTransactionsSink,
|
||||
EthTxBuildContext, SubPayloadBuilderFn, SubTxBuildContext,
|
||||
},
|
||||
transaction::{
|
||||
BuildTransactionParams, EthTransactionBuilder, BizinikiwTransactionBuilder, Transaction,
|
||||
BizinikiwTransactionBuilder, BuildTransactionParams, EthTransactionBuilder, Transaction,
|
||||
TransactionBuilder, TransactionCall, TransactionRecipe, TransactionsSink,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::{error::Error, sync::Arc, time::Duration};
|
||||
use pezkuwi_subxt::OnlineClient;
|
||||
use std::{error::Error, sync::Arc, time::Duration};
|
||||
use tracing::info;
|
||||
|
||||
use crate::helpers;
|
||||
|
||||
@@ -10,12 +10,6 @@ use crate::{
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use parking_lot::RwLock;
|
||||
use std::{
|
||||
any::Any,
|
||||
collections::HashMap,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
pub use pezkuwi_subxt::dynamic;
|
||||
use pezkuwi_subxt::{
|
||||
backend::rpc::RpcClient,
|
||||
@@ -36,6 +30,12 @@ use pezkuwi_subxt_signer::{
|
||||
eth::{dev as eth_dev, Keypair as EthKeypair, Signature},
|
||||
sr25519::{dev as sr25519_dev, Keypair as SrPair},
|
||||
};
|
||||
use std::{
|
||||
any::Any,
|
||||
collections::HashMap,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tracing::{debug, error, trace};
|
||||
|
||||
const LOG_TARGET: &str = "subxt_tx";
|
||||
@@ -49,14 +49,17 @@ impl pezkuwi_subxt::Config for EthRuntimeConfig {
|
||||
type Address = AccountId20;
|
||||
type Signature = Signature;
|
||||
type Hasher = pezkuwi_subxt::config::bizinikiwi::BlakeTwo256;
|
||||
type Header =
|
||||
pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<u32, pezkuwi_subxt::config::bizinikiwi::BlakeTwo256>;
|
||||
type Header = pezkuwi_subxt::config::bizinikiwi::BizinikiwiHeader<
|
||||
u32,
|
||||
pezkuwi_subxt::config::bizinikiwi::BlakeTwo256,
|
||||
>;
|
||||
type ExtrinsicParams = pezkuwi_subxt::config::DefaultExtrinsicParams<Self>;
|
||||
type AssetId = u32;
|
||||
}
|
||||
|
||||
/// Type alias for subxt config hash (Output of Hasher).
|
||||
pub(crate) type HashOf<C> = <<C as pezkuwi_subxt::Config>::Hasher as pezkuwi_subxt::config::Hasher>::Output;
|
||||
pub(crate) type HashOf<C> =
|
||||
<<C as pezkuwi_subxt::Config>::Hasher as pezkuwi_subxt::config::Hasher>::Output;
|
||||
/// Type alias for subxt account id.
|
||||
pub(crate) type AccountIdOf<C> = <C as pezkuwi_subxt::Config>::AccountId;
|
||||
|
||||
@@ -325,9 +328,8 @@ where
|
||||
.ok_or_else(|| {
|
||||
format!("Sender account {:?} does not exist", hex::encode(account.clone()))
|
||||
})?;
|
||||
let value: pezkuwi_subxt::dynamic::Value = storage_value
|
||||
.decode()
|
||||
.map_err(|e| format!("Failed to decode storage: {e:?}"))?;
|
||||
let value: pezkuwi_subxt::dynamic::Value =
|
||||
storage_value.decode().map_err(|e| format!("Failed to decode storage: {e:?}"))?;
|
||||
|
||||
debug!(target:LOG_TARGET,"account has free balance: {:?}", value.at("data").at("free"));
|
||||
debug!(target:LOG_TARGET,"account has nonce: {:?}", value.at("nonce"));
|
||||
@@ -612,8 +614,9 @@ where
|
||||
for _ in 0..DEFAULT_RETRIES_FOR_PARTIAL_TX_CREATION {
|
||||
let params = tx_params(mortality, nonce as u64, tip);
|
||||
match sink.api().tx().create_partial(&tx_call, from_account_id, params.into()).await {
|
||||
Ok(tx) =>
|
||||
return subxt_transaction(sink, tx, from_keypair, nonce, mortality, account).await,
|
||||
Ok(tx) => {
|
||||
return subxt_transaction(sink, tx, from_keypair, nonce, mortality, account).await
|
||||
},
|
||||
Err(_) => continue,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ use crate::{
|
||||
helpers::StreamOf,
|
||||
runner::DefaultTxTask,
|
||||
subxt_transaction::{
|
||||
build_subxt_tx, EthPayloadBuilderFn, EthRuntimeConfig, EthTransaction, EthTransactionsSink,
|
||||
HashOf, SubPayloadBuilderFn, BizinikiwTransaction, BizinikiwTransactionsSink,
|
||||
build_subxt_tx, BizinikiwTransaction, BizinikiwTransactionsSink, EthPayloadBuilderFn,
|
||||
EthRuntimeConfig, EthTransaction, EthTransactionsSink, HashOf, SubPayloadBuilderFn,
|
||||
},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::any::Any;
|
||||
use pezkuwi_subxt::{tx::TxStatus, OnlineClient, PezkuwiConfig};
|
||||
use pezkuwi_subxt_core::config::Hash as BlockHash;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::any::Any;
|
||||
|
||||
/// Parameters for building a transaction.
|
||||
pub(crate) struct BuildTransactionParams<'a> {
|
||||
|
||||
@@ -303,8 +303,8 @@ impl CargoCommand {
|
||||
|
||||
/// Returns whether this version of the toolchain supports nightly features.
|
||||
fn supports_nightly_features(&self) -> bool {
|
||||
self.version.map_or(false, |version| version.is_nightly) ||
|
||||
env::var("RUSTC_BOOTSTRAP").is_ok()
|
||||
self.version.map_or(false, |version| version.is_nightly)
|
||||
|| env::var("RUSTC_BOOTSTRAP").is_ok()
|
||||
}
|
||||
|
||||
/// Check if the supplied cargo command supports our runtime environment.
|
||||
@@ -433,12 +433,13 @@ impl RuntimeTarget {
|
||||
/// Figures out the target parameter value for rustc.
|
||||
fn rustc_target(self, cargo_command: &CargoCommand) -> String {
|
||||
match self {
|
||||
RuntimeTarget::Wasm =>
|
||||
RuntimeTarget::Wasm => {
|
||||
if cargo_command.is_wasm32v1_none_target_available() {
|
||||
"wasm32v1-none".into()
|
||||
} else {
|
||||
"wasm32-unknown-unknown".into()
|
||||
},
|
||||
}
|
||||
},
|
||||
RuntimeTarget::Riscv => {
|
||||
let path = polkavm_linker::target_json_32_path().expect("riscv not found");
|
||||
path.into_os_string().into_string().unwrap()
|
||||
@@ -449,12 +450,13 @@ impl RuntimeTarget {
|
||||
/// Figures out the target directory name used by cargo.
|
||||
fn rustc_target_dir(self, cargo_command: &CargoCommand) -> &'static str {
|
||||
match self {
|
||||
RuntimeTarget::Wasm =>
|
||||
RuntimeTarget::Wasm => {
|
||||
if cargo_command.is_wasm32v1_none_target_available() {
|
||||
"wasm32v1-none".into()
|
||||
} else {
|
||||
"wasm32-unknown-unknown".into()
|
||||
},
|
||||
}
|
||||
},
|
||||
RuntimeTarget::Riscv => "riscv32emac-unknown-none-polkavm",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,8 +267,8 @@ fn check_wasm_toolchain_installed(
|
||||
}
|
||||
}
|
||||
|
||||
if cargo_command.supports_wasm32v1_none_target() &&
|
||||
!cargo_command.is_wasm32v1_none_target_installed()
|
||||
if cargo_command.supports_wasm32v1_none_target()
|
||||
&& !cargo_command.is_wasm32v1_none_target_installed()
|
||||
{
|
||||
build_helper::warning!("You are building WASM runtime using `wasm32-unknown-unknown` target, although Rust >= 1.84 supports `wasm32v1-none` target!");
|
||||
build_helper::warning!("You can install it with `rustup target add wasm32v1-none --toolchain {toolchain}` if you're using `rustup`.");
|
||||
|
||||
@@ -421,10 +421,11 @@ fn get_wasm_workspace_root() -> PathBuf {
|
||||
loop {
|
||||
match out_dir.parent() {
|
||||
Some(parent) if out_dir.ends_with("build") => return parent.to_path_buf(),
|
||||
_ =>
|
||||
_ => {
|
||||
if !out_dir.pop() {
|
||||
break;
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,18 +614,18 @@ fn project_enabled_features(
|
||||
// this heuristic anymore. However, for the transition phase between now and namespaced
|
||||
// features already being present in nightly, we need this code to make
|
||||
// runtimes compile with all the possible rustc versions.
|
||||
if v.len() == 1 &&
|
||||
v.get(0).map_or(false, |v| *v == format!("dep:{}", f)) &&
|
||||
std_enabled.as_ref().map(|e| e.iter().any(|ef| ef == *f)).unwrap_or(false)
|
||||
if v.len() == 1
|
||||
&& v.get(0).map_or(false, |v| *v == format!("dep:{}", f))
|
||||
&& std_enabled.as_ref().map(|e| e.iter().any(|ef| ef == *f)).unwrap_or(false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't want to enable the `std`/`default` feature for the wasm build and
|
||||
// we need to check if the feature is enabled by checking the env variable.
|
||||
*f != "std" &&
|
||||
*f != "default" &&
|
||||
env::var(format!("CARGO_FEATURE_{feature_env}"))
|
||||
*f != "std"
|
||||
&& *f != "default"
|
||||
&& env::var(format!("CARGO_FEATURE_{feature_env}"))
|
||||
.map(|v| v == "1")
|
||||
.unwrap_or_default()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user