diff --git a/crates/core-primitives/src/testing.rs b/crates/core-primitives/src/testing.rs index f5834e7..df08cf8 100644 --- a/crates/core-primitives/src/testing.rs +++ b/crates/core-primitives/src/testing.rs @@ -81,7 +81,7 @@ impl HeaderCommitList for CommitListTestWithData { impl CommitListTestWithData { /// Converts the static `TEST_COMMITMENTS` into bytes. pub fn commit_bytes() -> Vec { - TEST_COMMITMENTS.iter().map(|c| c.to_bytes()).flatten().collect() + TEST_COMMITMENTS.iter().flat_map(|c| c.to_bytes()).collect() } /// Creates a `HeaderExtension` with the bytes representation of `TEST_COMMITMENTS`. diff --git a/crates/core-primitives/src/traits.rs b/crates/core-primitives/src/traits.rs index c1dc348..f20fcb9 100644 --- a/crates/core-primitives/src/traits.rs +++ b/crates/core-primitives/src/traits.rs @@ -63,6 +63,7 @@ pub trait HeaderCommitList { sp_api::decl_runtime_apis! { /// Extracts the `data` field from some types of extrinsics. + #[allow(clippy::ptr_arg, clippy::type_complexity)] pub trait Extractor { fn extract( extrinsic: &Vec, diff --git a/crates/das-network/src/dht_work.rs b/crates/das-network/src/dht_work.rs index 8c4cf63..e3fda7f 100644 --- a/crates/das-network/src/dht_work.rs +++ b/crates/das-network/src/dht_work.rs @@ -118,36 +118,33 @@ where for (key, value) in values { let maybe_sidecar = Sidecar::from_local_outside::(key.as_ref(), &mut self.offchain_db); - match maybe_sidecar { - Some(sidecar) => { - if sidecar.status.is_none() { - let data_hash = Sidecar::calculate_id(&value); - let mut new_sidecar = sidecar.clone(); - if data_hash != sidecar.metadata.blobs_hash.as_bytes() { - new_sidecar.status = Some(SidecarStatus::ProofError); + if let Some(sidecar) = maybe_sidecar { + if sidecar.status.is_none() { + let data_hash = Sidecar::calculate_id(&value); + let mut new_sidecar = sidecar.clone(); + if data_hash != sidecar.metadata.blobs_hash.as_bytes() { + new_sidecar.status = Some(SidecarStatus::ProofError); + } else { + let kzg = KZG::default_embedded(); + // TODO bytes to blobs + let blobs = bytes_vec_to_blobs(&[value.clone()], 1).unwrap(); + let encoding_valid = Blob::verify_batch( + &blobs, + &sidecar.metadata.commitments, + &sidecar.metadata.proofs, + &kzg, + FIELD_ELEMENTS_PER_BLOB, + ) + .unwrap(); + if encoding_valid { + new_sidecar.blobs = Some(value.clone()); + new_sidecar.status = Some(SidecarStatus::Success); } else { - let kzg = KZG::default_embedded(); - // TODO bytes to blobs - let blobs = bytes_vec_to_blobs(&[value.clone()], 1).unwrap(); - let encoding_valid = Blob::verify_batch( - &blobs, - &sidecar.metadata.commitments, - &sidecar.metadata.proofs, - &kzg, - FIELD_ELEMENTS_PER_BLOB, - ) - .unwrap(); - if encoding_valid { - new_sidecar.blobs = Some(value.clone()); - new_sidecar.status = Some(SidecarStatus::Success); - } else { - new_sidecar.status = Some(SidecarStatus::ProofError); - } + new_sidecar.status = Some(SidecarStatus::ProofError); } - new_sidecar.save_to_local_outside::(&mut self.offchain_db) } - }, - None => {}, + new_sidecar.save_to_local_outside::(&mut self.offchain_db) + } } } } @@ -156,15 +153,12 @@ where fn handle_dht_value_not_found_event(&mut self, key: KademliaKey) { let maybe_sidecar = Sidecar::from_local_outside::(key.as_ref(), &mut self.offchain_db); - match maybe_sidecar { - Some(sidecar) => { - if sidecar.status.is_none() { - let mut new_sidecar = sidecar.clone(); - new_sidecar.status = Some(SidecarStatus::NotFound); - new_sidecar.save_to_local_outside::(&mut self.offchain_db) - } - }, - None => {}, + if let Some(sidecar) = maybe_sidecar { + if sidecar.status.is_none() { + let mut new_sidecar = sidecar.clone(); + new_sidecar.status = Some(SidecarStatus::NotFound); + new_sidecar.save_to_local_outside::(&mut self.offchain_db) + } } } @@ -172,7 +166,10 @@ where fn process_message_from_service(&self, msg: ServicetoWorkerMsg) { match msg { ServicetoWorkerMsg::PutValueToDht(key, value, sender) => { - let _ = sender.send(Some(self.network.put_value(key, value))); + let _ = sender.send({ + self.network.put_value(key, value); + Some(()) + }); }, } } diff --git a/crates/das-network/src/lib.rs b/crates/das-network/src/lib.rs index 5708d3d..55f8c39 100644 --- a/crates/das-network/src/lib.rs +++ b/crates/das-network/src/lib.rs @@ -72,6 +72,7 @@ pub fn new_service(to_worker: mpsc::Sender) -> Service { } /// Conveniently creates both a Worker and Service with the given parameters. +#[allow(clippy::type_complexity)] pub fn new_worker_and_service( client: Arc, network: Arc, diff --git a/crates/das-rpc/src/lib.rs b/crates/das-rpc/src/lib.rs index 91333aa..89cc637 100644 --- a/crates/das-rpc/src/lib.rs +++ b/crates/das-rpc/src/lib.rs @@ -136,7 +136,7 @@ where let tx_hash = self.pool.submit_one(&at, TX_SOURCE, xt).await.map_err(|e| { e.into_pool_error() .map(|e| Error::TransactionPushFailed(Box::new(e))) - .unwrap_or_else(|e| Error::TransactionPushFailed(Box::new(e)).into()) + .unwrap_or_else(|e| Error::TransactionPushFailed(Box::new(e))) })?; let metadata = SidecarMetadata { data_len, blobs_hash: data_hash, commitments, proofs }; diff --git a/crates/meloxt/src/run_examples.rs b/crates/meloxt/src/run_examples.rs index c66f54e..69e5fe2 100644 --- a/crates/meloxt/src/run_examples.rs +++ b/crates/meloxt/src/run_examples.rs @@ -44,7 +44,7 @@ async fn main() -> Result<()> { async fn run_example(example: &str) -> Result<()> { // Execute the example using cargo. It assumes that the example can be run using the cargo command. let status = TokioCommand::new("cargo") - .args(&["run", "--release", "--example", example]) + .args(["run", "--release", "--example", example]) .status() .await?; @@ -63,7 +63,7 @@ async fn fetch_all_examples() -> Result> { // Use tokio's spawn_blocking to run a blocking operation in the context of an asynchronous function. let output = tokio::task::spawn_blocking(move || { std::process::Command::new("cargo") - .args(&["run", "--release", "--example"]) + .args(["run", "--release", "--example"]) .stderr(Stdio::piped()) .output() }) diff --git a/crates/pallet-melo-store/src/lib.rs b/crates/pallet-melo-store/src/lib.rs index d4d39a1..f0e2a60 100644 --- a/crates/pallet-melo-store/src/lib.rs +++ b/crates/pallet-melo-store/src/lib.rs @@ -416,7 +416,7 @@ pub mod pallet { let app_id = AppId::::get() + 1; AppId::::put(app_id); Self::deposit_event(Event::AppIdRegistered { app_id, from: who }); - Ok(().into()) + Ok(()) } } @@ -468,7 +468,7 @@ pub mod pallet { let keys = Keys::::get(); let authority_id = - match keys.get(unavailable_data_report.authority_index.clone() as usize) { + match keys.get(unavailable_data_report.authority_index as usize) { Some(id) => id, None => return InvalidTransaction::Stale.into(), }; @@ -535,8 +535,7 @@ impl Pallet { pub fn get_commitment_list(at_block: BlockNumberFor) -> Vec { Metadata::::get(at_block) .iter() - .map(|metadata| metadata.commitments.clone()) - .flatten() + .flat_map(|metadata| metadata.commitments.clone()) .collect::>() } @@ -548,7 +547,6 @@ impl Pallet { now: BlockNumberFor, ) -> OffchainResult>> { let reports = (0..DELAY_CHECK_THRESHOLD) - .into_iter() .filter_map(move |gap| { if T::BlockNumber::from(gap) > now { return None; @@ -569,7 +567,7 @@ impl Pallet { None } }) - .flat_map(|it| it); + .flatten(); Ok(reports) } diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 27e44bc..6e9f9e9 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -84,7 +84,6 @@ pub fn testnet_genesis( let nominations = initial_authorities .as_slice() .choose_multiple(&mut rng, count) - .into_iter() .map(|choice| choice.0.clone()) .collect::>(); (x.clone(), x.clone(), STASH, StakerStatus::Nominator(nominations)) @@ -155,7 +154,7 @@ pub fn testnet_genesis( }, nomination_pools: NominationPoolsConfig { min_create_bond: 10 * DOLLARS, - min_join_bond: 1 * DOLLARS, + min_join_bond: DOLLARS, ..Default::default() }, } diff --git a/node/src/service.rs b/node/src/service.rs index a014322..8f0e212 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -52,6 +52,7 @@ pub type TransactionPool = sc_transaction_pool::FullPool; type FullGrandpaBlockImport = grandpa::GrandpaBlockImport; +#[allow(clippy::type_complexity)] pub fn new_partial( config: &Configuration, ) -> Result< diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index eccfe02..94daf9d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -725,9 +725,9 @@ where parameter_types! { pub const PreimageMaxSize: u32 = 4096 * 1024; - pub const PreimageBaseDeposit: Balance = 1 * DOLLARS; + pub const PreimageBaseDeposit: Balance = DOLLARS; // One cent: $10,000 / MB - pub const PreimageByteDeposit: Balance = 1 * CENTS; + pub const PreimageByteDeposit: Balance = CENTS; } #[auto_config(include_currency)] @@ -779,10 +779,10 @@ impl pallet_elections_phragmen::Config for Runtime { parameter_types! { pub const AssetDeposit: Balance = 100 * DOLLARS; - pub const ApprovalDeposit: Balance = 1 * DOLLARS; + pub const ApprovalDeposit: Balance = DOLLARS; pub const StringLimit: u32 = 50; pub const MetadataDepositBase: Balance = 10 * DOLLARS; - pub const MetadataDepositPerByte: Balance = 1 * DOLLARS; + pub const MetadataDepositPerByte: Balance = DOLLARS; } impl pallet_assets::Config for Runtime { @@ -809,7 +809,7 @@ impl pallet_assets::Config for Runtime { } parameter_types! { - pub const IndexDeposit: Balance = 1 * DOLLARS; + pub const IndexDeposit: Balance = DOLLARS; } // #[auto_config()]