Explorar el Código

chore: Clippy lints

x hace 4 meses
padre
commit
fe95bc2258

+ 2 - 2
Cargo.lock

@@ -4890,7 +4890,7 @@ dependencies = [
  "getifaddrs",
  "quick-xml",
  "smol",
- "thiserror 2.0.17",
+ "thiserror 2.0.18",
  "tracing",
  "url",
 ]
@@ -5529,7 +5529,7 @@ dependencies = [
  "derive-deftly",
  "libc",
  "paste",
- "thiserror 2.0.17",
+ "thiserror 1.0.69",
 ]
 
 [[package]]

+ 16 - 15
Makefile

@@ -13,9 +13,10 @@ RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
 # If building natively, this might give you more speed
 #RUSTFLAGS = -C target_cpu=native
 
-# List of zkas circuits to compile, used for tests
+# List of zkas circuits to compile
 PROOFS_SRC = \
-	$(shell find proof -type f -name '*.zk')
+	$(shell find proof -type f -name '*.zk') \
+	$(shell find src/event_graph/proof -type f -name '*.zk')
 
 PROOFS_BIN = $(PROOFS_SRC:=.bin)
 
@@ -34,7 +35,7 @@ BINS = \
 	fud \
 	fu
 
-all: $(BINS)
+all: $(PROOFS_BIN) $(BINS)
 
 zkas:
 	$(MAKE) -C bin/$@ \
@@ -65,21 +66,21 @@ drk: contracts
 		RUST_TARGET="$(RUST_TARGET)" \
 		RUSTFLAGS="$(RUSTFLAGS)"
 
-darkirc: zkas
+darkirc: $(PROOFS_BIN) zkas
 	$(MAKE) -C bin/$@ \
 		PREFIX="$(PREFIX)" \
 		CARGO="$(CARGO)" \
 		RUST_TARGET="$(RUST_TARGET)" \
 		RUSTFLAGS="$(RUSTFLAGS)"
 
-genev:
+genev: $(PROOFS_BIN)
 	$(MAKE) -C bin/genev/genev-cli \
 		PREFIX="$(PREFIX)" \
 		CARGO="$(CARGO)" \
 		RUST_TARGET="$(RUST_TARGET)" \
 		RUSTFLAGS="$(RUSTFLAGS)"
 
-genevd:
+genevd: $(PROOFS_BIN)
 	$(MAKE) -C bin/genev/genevd \
 		PREFIX="$(PREFIX)" \
 		CARGO="$(CARGO)" \
@@ -93,7 +94,7 @@ lilith:
 		RUST_TARGET="$(RUST_TARGET)" \
 		RUSTFLAGS="$(RUSTFLAGS)"
 
-taud:
+taud: $(PROOFS_BIN)
 	$(MAKE) -C bin/tau/$@ \
 		PREFIX="$(PREFIX)" \
 		CARGO="$(CARGO)" \
@@ -134,39 +135,39 @@ fmt:
 	$(CARGO) +nightly fmt --all
 
 # cargo install cargo-hack
-check: contracts $(PROOFS_BIN)
+check: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) hack check --target=$(RUST_TARGET) \
 		--release --feature-powerset --workspace
 
-clippy: contracts $(PROOFS_BIN)
+clippy: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
 		--release --all-features --workspace --tests
 
-fix: contracts $(PROOFS_BIN)
+fix: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
 		--release --all-features --workspace --tests --fix --allow-dirty
 
-rustdoc: contracts $(PROOFS_BIN)
+rustdoc: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) doc --target=$(RUST_TARGET) \
 		--release --all-features --workspace --document-private-items --no-deps
 
-test: contracts $(PROOFS_BIN)
+test: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
 		--release --all-features --workspace
 
-bench-zk-from-json: contracts $(PROOFS_BIN)
+bench-zk-from-json: $(PROOFS_BIN) contracts
 	rm -f src/contract/test-harness/*.bin
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) bench --target=$(RUST_TARGET) \
 		--bench zk_from_json --all-features --workspace \
 		-- --save-baseline master
 
-bench: contracts $(PROOFS_BIN)
+bench: $(PROOFS_BIN) contracts
 	rm -f src/contract/test-harness/*.bin
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) bench --target=$(RUST_TARGET) \
 		--all-features --workspace \
 		-- --save-baseline master
 
-coverage: contracts $(PROOFS_BIN)
+coverage: $(PROOFS_BIN) contracts
 	RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) llvm-cov --target=$(RUST_TARGET) \
 		--release --all-features --workspace --html
 

+ 1 - 1
bin/darkirc/src/crypto/rln.rs

@@ -101,7 +101,7 @@ impl RlnIdentity {
         let register_zkbin = ZkBinary::decode(RLN2_REGISTER_ZKBIN, false)?;
         let register_circuit = ZkCircuit::new(witnesses, &register_zkbin);
 
-        let proof = Proof::create(&register_pk, &[register_circuit], &public_inputs, &mut OsRng)?;
+        let proof = Proof::create(register_pk, &[register_circuit], &public_inputs, &mut OsRng)?;
 
         let leaf = vec![commitment];
         let leaf: Vec<_> = leaf.into_iter().map(|l| (l, l)).collect();

+ 1 - 1
bin/darkirc/src/irc/client.rs

@@ -227,7 +227,7 @@ impl Client {
 
                                             rln_identity.message_id += 1;
 
-                                            let (proof, y, internal_nullifier, user_msg_limit) = match self.create_rln_signal_proof(&rln_identity, &event).await {
+                                            let (proof, y, internal_nullifier, user_msg_limit) = match self.create_rln_signal_proof(rln_identity, &event).await {
                                                 Ok(v) => v,
                                                 Err(e) => {
                                                     // TODO: Send a message to the IRC client telling that sending went wrong

+ 2 - 2
bin/darkirc/src/irc/services/nickserv.rs

@@ -175,7 +175,7 @@ impl NickServ {
                     return Ok(vec![ReplyType::Notice((
                         "NickServ".to_string(),
                         nick.to_string(),
-                        format!("Invalid identity_nullifier"),
+                        "Invalid identity_nullifier".to_string(),
                     ))])
                 }
             };
@@ -188,7 +188,7 @@ impl NickServ {
                     return Ok(vec![ReplyType::Notice((
                         "NickServ".to_string(),
                         nick.to_string(),
-                        format!("Invalid identity_trapdoor"),
+                        "Invalid identity_trapdoor".to_string(),
                     ))])
                 }
             };

+ 1 - 0
bin/tau/taud/src/task_info.rs

@@ -327,6 +327,7 @@ impl From<JsonValue> for TaskInfo {
 }
 
 impl TaskInfo {
+    #[allow(clippy::too_many_arguments)]
     pub fn new(
         workspace: String,
         title: &str,

+ 10 - 12
src/event_graph/mod.rs

@@ -71,7 +71,7 @@ pub mod proto;
 use proto::{EventRep, EventReq, HeaderRep, HeaderReq, TipRep, TipReq};
 
 pub mod rln;
-use rln::{build_register_vk, build_signal_vk, build_slash_pk, build_slash_vk};
+//use rln::{build_register_vk, build_signal_vk, build_slash_pk, build_slash_vk};
 
 /// Utility functions
 pub mod util;
@@ -316,9 +316,8 @@ impl DAGStore {
         event_id: &blake3::Hash,
         dag: &sled::Tree,
     ) -> Result<Option<Event>> {
-        let Some(bytes) = dag.get(event_id.as_bytes())? else {
-            return Ok(None);
-        };
+        let Some(bytes) = dag.get(event_id.as_bytes())? else { return Ok(None) };
+
         let event: Event = deserialize_async(&bytes).await?;
 
         Ok(Some(event))
@@ -398,10 +397,12 @@ impl EventGraph {
         hours_rotation: u64,
         ex: Arc<Executor<'_>>,
     ) -> Result<EventGraphPtr> {
+        /*
         let _register_vk = build_register_vk(&sled_db)?;
         let _signal_vk = build_signal_vk(&sled_db)?;
         let _slash_pk = build_slash_pk(&sled_db)?;
         let _slash_vk = build_slash_vk(&sled_db)?;
+        */
 
         let hasher = PoseidonFp::new();
         // let store = AccountStorage::new(&sled_db, "name".to_owned());
@@ -673,7 +674,7 @@ impl EventGraph {
 
                 // We don't have any channels we can assign to or wait to get response from
                 if free_channels.is_empty() && busy_channels == 0 {
-                    return Err(Error::DagSyncFailed);
+                    return Err(Error::DagSyncFailed)
                 }
 
                 // We will distribute the remaining chunks to each channel
@@ -729,9 +730,7 @@ impl EventGraph {
         for dag in dags_to_sync {
             match self.dag_sync(dag, fast_mode).await {
                 Ok(()) => continue,
-                Err(e) => {
-                    return Err(e);
-                }
+                Err(e) => return Err(e),
             }
         }
 
@@ -1380,12 +1379,11 @@ impl EventGraph {
     }
 
     pub async fn static_fetch(&self, event_id: &Hash) -> Result<Option<Event>> {
-        let Some(bytes) = self.static_dag.get(event_id.as_bytes())? else {
-            return Ok(None);
-        };
+        let Some(bytes) = self.static_dag.get(event_id.as_bytes())? else { return Ok(None) };
+
         let event: Event = deserialize_async(&bytes).await?;
 
-        return Ok(Some(event))
+        Ok(Some(event))
     }
 
     pub async fn static_fetch_all(&self) -> Result<Vec<Event>> {

+ 3 - 4
src/event_graph/proto.rs

@@ -31,8 +31,7 @@ use darkfi_sdk::{
     pasta::pallas,
 };
 use darkfi_serial::{
-    async_trait, deserialize_async, deserialize_async_partial, serialize_async, SerialDecodable,
-    SerialEncodable,
+    async_trait, deserialize_async_partial, serialize_async, SerialDecodable, SerialEncodable,
 };
 use smol::Executor;
 use tracing::{debug, error, info, trace, warn};
@@ -40,7 +39,7 @@ use tracing::{debug, error, info, trace, warn};
 use super::{
     event::Header,
     rln::{closest_epoch, create_slash_proof, hash_event, sss_recover, MessageMetadata, RLNNode},
-    Event, EventGraphPtr, LayerUTips, NULL_ID, NULL_PARENTS,
+    Event, EventGraphPtr, LayerUTips, NULL_ID,
 };
 use crate::{
     event_graph::rln::{read_register_vk, read_signal_vk, read_slash_pk, read_slash_vk, Blob},
@@ -696,7 +695,7 @@ impl ProtocolEventGraph {
                 continue
             }
 
-            let rln_account: RLNNode = match deserialize_async_partial(&event.content()).await {
+            let rln_account: RLNNode = match deserialize_async_partial(event.content()).await {
                 Ok((v, _)) => v,
                 Err(e) => {
                     error!(target: "event_graph::protocol::handle_static_put()","[RLN] Failed deserializing event ephemeral data: {}", e);

+ 2 - 2
src/event_graph/rln.rs

@@ -148,7 +148,7 @@ impl MessageMetadata {
         x: pallas::Base,
         y: pallas::Base,
     ) -> Result<()> {
-        let inner_map = self.data.entry(external_nullifier).or_insert_with(BTreeMap::new);
+        let inner_map = self.data.entry(external_nullifier).or_default();
         let share_data = inner_map.entry(internal_nullifier).or_insert_with(ShareData::new);
 
         share_data.x_shares.push(x);
@@ -256,7 +256,7 @@ pub fn create_slash_proof(
     let slash_zkbin = ZkBinary::decode(RLN2_SLASH_ZKBIN, false)?;
     let slash_circuit = ZkCircuit::new(witnesses, &slash_zkbin);
 
-    let proof = Proof::create(&slash_pk, &[slash_circuit], &public_inputs, &mut OsRng).unwrap();
+    let proof = Proof::create(slash_pk, &[slash_circuit], &public_inputs, &mut OsRng).unwrap();
 
     Ok((proof, identity_root))
 }