diff --git a/crates/synor-bridge/src/ethereum.rs b/crates/synor-bridge/src/ethereum.rs index 32773ce..82b3015 100644 --- a/crates/synor-bridge/src/ethereum.rs +++ b/crates/synor-bridge/src/ethereum.rs @@ -17,8 +17,7 @@ //! 3. Vault contract verifies proof and unlocks original tokens use crate::{ - AssetId, Bridge, BridgeAddress, BridgeError, BridgeResult, BridgeTransfer, ChainType, - TransferDirection, TransferId, TransferManager, TransferStatus, VaultManager, + AssetId, Bridge, BridgeAddress, BridgeError, BridgeResult, BridgeTransfer, ChainType, TransferId, TransferManager, TransferStatus, VaultManager, ETH_MIN_CONFIRMATIONS, }; use alloy_primitives::{Address, B256, U256}; @@ -148,13 +147,13 @@ impl EthereumEvent { pub fn hash(&self) -> B256 { let mut hasher = Keccak256::new(); hasher.update(self.tx_hash.as_slice()); - hasher.update(&self.block_number.to_le_bytes()); - hasher.update(&self.log_index.to_le_bytes()); + hasher.update(self.block_number.to_le_bytes()); + hasher.update(self.log_index.to_le_bytes()); hasher.update(self.token.as_slice()); hasher.update(self.sender.as_slice()); - hasher.update(&self.amount.to_le_bytes::<32>()); + hasher.update(self.amount.to_le_bytes::<32>()); hasher.update(&self.recipient); - hasher.update(&self.nonce.to_le_bytes()); + hasher.update(self.nonce.to_le_bytes()); let result = hasher.finalize(); B256::from_slice(&result) diff --git a/crates/synor-bridge/src/transfer.rs b/crates/synor-bridge/src/transfer.rs index ee3deee..e8ce011 100644 --- a/crates/synor-bridge/src/transfer.rs +++ b/crates/synor-bridge/src/transfer.rs @@ -35,8 +35,8 @@ impl TransferId { hasher.update(&sender.address); hasher.update(&recipient.address); hasher.update(asset.identifier.as_bytes()); - hasher.update(&amount.to_le_bytes()); - hasher.update(&nonce.to_le_bytes()); + hasher.update(amount.to_le_bytes()); + hasher.update(nonce.to_le_bytes()); Self(hex::encode(&hasher.finalize()[..16])) } } diff --git a/crates/synor-consensus/src/network.rs b/crates/synor-consensus/src/network.rs index 0695766..d3694a3 100644 --- a/crates/synor-consensus/src/network.rs +++ b/crates/synor-consensus/src/network.rs @@ -26,10 +26,12 @@ use std::time::Duration; /// Blocks per second mode. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Default)] pub enum BpsMode { /// Standard mode: 10 blocks per second (100ms block time) /// - Suitable for most network conditions /// - Requires ~100ms P95 network latency + #[default] Standard10, /// Fast mode: 32 blocks per second (~31ms block time) @@ -73,11 +75,6 @@ impl BpsMode { } } -impl Default for BpsMode { - fn default() -> Self { - BpsMode::Standard10 - } -} impl std::fmt::Display for BpsMode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/crates/synor-crypto/src/falcon.rs b/crates/synor-crypto/src/falcon.rs index edc70f0..da52ae9 100644 --- a/crates/synor-crypto/src/falcon.rs +++ b/crates/synor-crypto/src/falcon.rs @@ -60,8 +60,10 @@ use zeroize::{Zeroize, ZeroizeOnDrop}; /// FALCON variant selection. #[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Default)] pub enum FalconVariant { /// 128-bit security, ~690 byte signatures + #[default] Falcon512, /// 256-bit security, ~1,330 byte signatures Falcon1024, @@ -117,11 +119,6 @@ impl FalconVariant { } } -impl Default for FalconVariant { - fn default() -> Self { - FalconVariant::Falcon512 - } -} /// FALCON public key. #[derive(Clone)] @@ -195,6 +192,7 @@ impl std::fmt::Debug for FalconPublicKey { #[derive(Zeroize, ZeroizeOnDrop)] pub struct FalconSecretKey { #[zeroize(skip)] + #[allow(clippy::assigned_to_never_read)] // Used by variant() getter method variant: FalconVariant, bytes: Vec, } diff --git a/crates/synor-crypto/src/negotiation.rs b/crates/synor-crypto/src/negotiation.rs index 377ed8f..5e14ec8 100644 --- a/crates/synor-crypto/src/negotiation.rs +++ b/crates/synor-crypto/src/negotiation.rs @@ -452,8 +452,10 @@ impl AlgorithmNegotiator { let mutual_preference = local_top == Some(*best_algo) && remote_top == Some(*best_algo); // Create session params - let mut session_params = SessionParams::default(); - session_params.fallback = self.select_fallback(best_algo, remote_caps); + let session_params = SessionParams { + fallback: self.select_fallback(best_algo, remote_caps), + ..Default::default() + }; Ok(NegotiationResult { algorithm: *best_algo, diff --git a/crates/synor-crypto/src/sphincs.rs b/crates/synor-crypto/src/sphincs.rs index 12609fe..359c071 100644 --- a/crates/synor-crypto/src/sphincs.rs +++ b/crates/synor-crypto/src/sphincs.rs @@ -56,8 +56,10 @@ use zeroize::{Zeroize, ZeroizeOnDrop}; /// 's' variants have smaller signatures but are slower. /// 'f' variants are faster but have larger signatures. #[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Default)] pub enum SphincsVariant { /// 128-bit security, small signatures (~7.8KB) + #[default] Shake128s, /// 192-bit security, small signatures (~16KB) Shake192s, @@ -112,11 +114,6 @@ impl SphincsVariant { } } -impl Default for SphincsVariant { - fn default() -> Self { - SphincsVariant::Shake128s - } -} /// SPHINCS+ public key. #[derive(Clone)] @@ -198,6 +195,7 @@ impl std::fmt::Debug for SphincsPublicKey { #[derive(Zeroize, ZeroizeOnDrop)] pub struct SphincsSecretKey { #[zeroize(skip)] + #[allow(clippy::assigned_to_never_read)] // Used by variant() getter method variant: SphincsVariant, bytes: Vec, } diff --git a/crates/synor-dag/src/dagknight.rs b/crates/synor-dag/src/dagknight.rs index d2e6d98..c644a41 100644 --- a/crates/synor-dag/src/dagknight.rs +++ b/crates/synor-dag/src/dagknight.rs @@ -275,7 +275,7 @@ impl DagKnightManager { let data = self.ghostdag.add_block(block_id, parents)?; // Periodically update adaptive k - if self.latency_tracker.sample_count() % 50 == 0 { + if self.latency_tracker.sample_count().is_multiple_of(50) { self.update_adaptive_k(); } diff --git a/crates/synor-ibc/src/commitment.rs b/crates/synor-ibc/src/commitment.rs index 3c8501b..745c564 100644 --- a/crates/synor-ibc/src/commitment.rs +++ b/crates/synor-ibc/src/commitment.rs @@ -132,13 +132,13 @@ impl MerklePath { } /// Get full path string - pub fn to_string(&self) -> String { + pub fn path(&self) -> String { self.key_path.join("/") } /// Get path bytes for hashing pub fn to_bytes(&self) -> Vec { - self.to_string().into_bytes() + self.path().into_bytes() } } @@ -166,7 +166,7 @@ impl CommitmentProof { /// Hash a leaf value fn hash_leaf(value: &[u8]) -> Vec { let mut hasher = Sha256::new(); - hasher.update(&[0x00]); // Leaf prefix + hasher.update([0x00]); // Leaf prefix hasher.update(value); hasher.finalize().to_vec() } @@ -175,7 +175,7 @@ fn hash_leaf(value: &[u8]) -> Vec { #[allow(dead_code)] fn hash_inner(left: &[u8], right: &[u8]) -> Vec { let mut hasher = Sha256::new(); - hasher.update(&[0x01]); // Inner prefix + hasher.update([0x01]); // Inner prefix hasher.update(left); hasher.update(right); hasher.finalize().to_vec() @@ -315,7 +315,7 @@ mod tests { fn test_merkle_path() { let path = client_state_path(&ClientId::new("07-tendermint", 0)); assert_eq!( - path.to_string(), + path.path(), "clients/07-tendermint-0/clientState" ); } @@ -326,13 +326,13 @@ mod tests { let channel = ChannelId::new(0); let commit_path = packet_commitment_path(&port, &channel, 1); - assert!(commit_path.to_string().contains("commitments")); + assert!(commit_path.path().contains("commitments")); let receipt_path = packet_receipt_path(&port, &channel, 1); - assert!(receipt_path.to_string().contains("receipts")); + assert!(receipt_path.path().contains("receipts")); let ack_path = packet_acknowledgement_path(&port, &channel, 1); - assert!(ack_path.to_string().contains("acks")); + assert!(ack_path.path().contains("acks")); } #[test] diff --git a/crates/synor-ibc/src/packet.rs b/crates/synor-ibc/src/packet.rs index 378ee35..a9fae6e 100644 --- a/crates/synor-ibc/src/packet.rs +++ b/crates/synor-ibc/src/packet.rs @@ -103,13 +103,13 @@ impl Packet { /// Compute packet commitment hash pub fn commitment(&self) -> PacketCommitment { let mut hasher = Sha256::new(); - hasher.update(&self.timeout_timestamp.nanoseconds().to_be_bytes()); - hasher.update(&self.timeout_height.revision_number.to_be_bytes()); - hasher.update(&self.timeout_height.revision_height.to_be_bytes()); + hasher.update(self.timeout_timestamp.nanoseconds().to_be_bytes()); + hasher.update(self.timeout_height.revision_number.to_be_bytes()); + hasher.update(self.timeout_height.revision_height.to_be_bytes()); // Hash the data let data_hash = Sha256::digest(&self.data); - hasher.update(&data_hash); + hasher.update(data_hash); PacketCommitment(hasher.finalize().to_vec()) } @@ -194,6 +194,7 @@ impl Acknowledgement { /// Timeout information #[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Default)] pub struct Timeout { /// Timeout height pub height: Height, @@ -230,14 +231,6 @@ impl Timeout { } } -impl Default for Timeout { - fn default() -> Self { - Self { - height: Height::default(), - timestamp: Timestamp::default(), - } - } -} /// Packet receipt (for unordered channels) #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/synor-ibc/src/swap.rs b/crates/synor-ibc/src/swap.rs index 2e7a06d..b39c959 100644 --- a/crates/synor-ibc/src/swap.rs +++ b/crates/synor-ibc/src/swap.rs @@ -67,7 +67,7 @@ impl SwapId { hasher.update(initiator.as_bytes()); hasher.update(responder.as_bytes()); hasher.update(hashlock); - hasher.update(×tamp.to_le_bytes()); + hasher.update(timestamp.to_le_bytes()); Self(hex::encode(&hasher.finalize()[..16])) } } diff --git a/crates/synor-ibc/src/types.rs b/crates/synor-ibc/src/types.rs index c7a5c12..f99833b 100644 --- a/crates/synor-ibc/src/types.rs +++ b/crates/synor-ibc/src/types.rs @@ -76,6 +76,7 @@ impl fmt::Display for Height { Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize, )] +#[derive(Default)] pub struct Timestamp(pub u64); impl Timestamp { @@ -114,11 +115,6 @@ impl Timestamp { } } -impl Default for Timestamp { - fn default() -> Self { - Self(0) - } -} impl fmt::Display for Timestamp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/synor-mining/src/kheavyhash.rs b/crates/synor-mining/src/kheavyhash.rs index b3c8882..d9da83c 100644 --- a/crates/synor-mining/src/kheavyhash.rs +++ b/crates/synor-mining/src/kheavyhash.rs @@ -166,7 +166,7 @@ impl KHeavyHash { } // Report progress every 10000 hashes - if tried % 10000 == 0 && !callback(tried, nonce) { + if tried.is_multiple_of(10000) && !callback(tried, nonce) { return None; // Cancelled } } diff --git a/crates/synor-mining/src/miner.rs b/crates/synor-mining/src/miner.rs index 2f58f82..aea2bc8 100644 --- a/crates/synor-mining/src/miner.rs +++ b/crates/synor-mining/src/miner.rs @@ -282,7 +282,7 @@ impl BlockMiner { nonce = nonce.wrapping_add(1); // Update stats periodically - if hashes % 10000 == 0 { + if hashes.is_multiple_of(10000) { self.hash_counter.fetch_add(10000, Ordering::Relaxed); } } diff --git a/crates/synor-vm/src/compute.rs b/crates/synor-vm/src/compute.rs index 56fd249..b1cc966 100644 --- a/crates/synor-vm/src/compute.rs +++ b/crates/synor-vm/src/compute.rs @@ -11,8 +11,6 @@ use synor_compute::{ ComputeCluster, ComputeJob, JobId, NodeId, }; -use crate::gas::GasMeter; -use std::sync::Arc; /// Configuration for compute-accelerated VM execution. #[derive(Clone, Debug)] @@ -78,6 +76,7 @@ impl OffloadableOp { /// Result of compute offload. #[derive(Clone, Debug)] +#[derive(Default)] pub struct ComputeResult { /// Whether the operation was offloaded. pub offloaded: bool, @@ -89,16 +88,6 @@ pub struct ComputeResult { pub execution_time_us: u64, } -impl Default for ComputeResult { - fn default() -> Self { - Self { - offloaded: false, - processor_type: None, - gas_savings: 0, - execution_time_us: 0, - } - } -} /// Compute-aware execution context. #[cfg(feature = "compute")] @@ -218,7 +207,7 @@ impl ComputeContext { Self { config } } - pub fn offload(&mut self, op: OffloadableOp) -> ComputeResult { + pub fn offload(&mut self, _op: OffloadableOp) -> ComputeResult { ComputeResult::default() } diff --git a/sdk/flutter/example/example.dart b/sdk/flutter/example/example.dart index 12683e7..b73158b 100644 --- a/sdk/flutter/example/example.dart +++ b/sdk/flutter/example/example.dart @@ -66,7 +66,7 @@ Future matrixMultiplicationExample(SynorCompute client) async { final result = await client.matmul( a, b, - options: MatMulOptions( + options: const MatMulOptions( precision: Precision.fp16, processor: ProcessorType.gpu, priority: Priority.high, @@ -128,7 +128,7 @@ Future llmInferenceExample(SynorCompute client) async { final result = await client.inference( 'llama-3-70b', 'What is the capital of France? Answer in one word.', - options: InferenceOptions( + options: const InferenceOptions( maxTokens: 10, temperature: 0.1, processor: ProcessorType.lpu, // Use LPU for LLM @@ -152,7 +152,7 @@ Future streamingInferenceExample(SynorCompute client) async { await for (final token in client.inferenceStream( 'llama-3-70b', 'Write a short poem about distributed computing.', - options: InferenceOptions( + options: const InferenceOptions( maxTokens: 100, temperature: 0.7, ), @@ -245,7 +245,7 @@ Future trainingExample(SynorCompute client) async { print('Step 1: Uploading training dataset...\n'); // Example 1: JSONL format (most common for LLM fine-tuning) - final jsonlData = ''' + const jsonlData = ''' {"prompt": "What is the capital of France?", "completion": "Paris"} {"prompt": "Translate 'hello' to Spanish", "completion": "hola"} {"prompt": "What is 2 + 2?", "completion": "4"} @@ -254,7 +254,7 @@ Future trainingExample(SynorCompute client) async { final dataset = await client.uploadDataset( utf8.encode(jsonlData), - DatasetUploadOptions( + const DatasetUploadOptions( name: 'qa-training-data', description: 'Question-answering training dataset', format: DatasetFormat.jsonl, @@ -281,7 +281,7 @@ Future trainingExample(SynorCompute client) async { baseModel: 'llama-3-8b', datasetCid: dataset.cid, // Use the CID from upload outputAlias: 'my-qa-model', - options: TrainingOptions( + options: const TrainingOptions( framework: MlFramework.pytorch, epochs: 3, batchSize: 8, @@ -311,7 +311,7 @@ Future trainingExample(SynorCompute client) async { final inference = await client.inference( training.modelCid, 'What is the capital of Germany?', - options: InferenceOptions(maxTokens: 50), + options: const InferenceOptions(maxTokens: 50), ); print('Response: ${inference.result}'); } else { @@ -365,7 +365,7 @@ Future datasetUploadExamples(SynorCompute client) async { "Define ML","Machine Learning is..." '''); - final csvData = ''' + const csvData = ''' prompt,completion "What is AI?","Artificial Intelligence is the simulation of human intelligence" "Define ML","Machine Learning is a subset of AI that learns from data" @@ -373,7 +373,7 @@ prompt,completion final csvDataset = await client.uploadDataset( utf8.encode(csvData), - DatasetUploadOptions( + const DatasetUploadOptions( name: 'csv-dataset', format: DatasetFormat.csv, type: DatasetType.textCompletion, diff --git a/sdk/flutter/lib/src/job.dart b/sdk/flutter/lib/src/job.dart index 3ef0f76..5108be8 100644 --- a/sdk/flutter/lib/src/job.dart +++ b/sdk/flutter/lib/src/job.dart @@ -6,7 +6,6 @@ import 'dart:convert'; import 'package:web_socket_channel/web_socket_channel.dart'; -import 'tensor.dart'; import 'types.dart'; /// Result of a compute job diff --git a/sdk/flutter/lib/src/types.dart b/sdk/flutter/lib/src/types.dart index 3c98502..3c6e559 100644 --- a/sdk/flutter/lib/src/types.dart +++ b/sdk/flutter/lib/src/types.dart @@ -1,7 +1,6 @@ /// Type definitions for Synor Compute SDK library synor_compute.types; -import 'package:collection/collection.dart'; /// Numeric precision for compute operations enum Precision { diff --git a/sdk/flutter/test/tensor_test.dart b/sdk/flutter/test/tensor_test.dart index ea3aaca..ebbfdd3 100644 --- a/sdk/flutter/test/tensor_test.dart +++ b/sdk/flutter/test/tensor_test.dart @@ -1,4 +1,3 @@ -import 'dart:convert'; import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; diff --git a/sdk/flutter/test/types_test.dart b/sdk/flutter/test/types_test.dart index cbc3dcd..33225e1 100644 --- a/sdk/flutter/test/types_test.dart +++ b/sdk/flutter/test/types_test.dart @@ -101,7 +101,7 @@ void main() { group('SynorConfig', () { test('creates with required fields', () { - final config = SynorConfig(apiKey: 'test-key'); + const config = SynorConfig(apiKey: 'test-key'); expect(config.apiKey, equals('test-key')); expect(config.baseUrl, equals('https://compute.synor.io')); @@ -112,7 +112,7 @@ void main() { }); test('creates with custom values', () { - final config = SynorConfig( + const config = SynorConfig( apiKey: 'test-key', baseUrl: 'https://custom.api.com', timeout: const Duration(seconds: 60), @@ -127,7 +127,7 @@ void main() { }); test('copyWith updates fields', () { - final original = SynorConfig(apiKey: 'test-key'); + const original = SynorConfig(apiKey: 'test-key'); final updated = original.copyWith( timeout: const Duration(seconds: 60), defaultProcessor: ProcessorType.tpu, @@ -316,7 +316,7 @@ void main() { }); test('formats parameters correctly', () { - final model = ModelInfo( + const model = ModelInfo( id: 'test', name: 'Test', description: 'Test', diff --git a/tests/cross_crate_integration.rs b/tests/cross_crate_integration.rs index 111a76b..ad37c78 100644 --- a/tests/cross_crate_integration.rs +++ b/tests/cross_crate_integration.rs @@ -868,7 +868,7 @@ mod types_hashing_integration { let hash3 = Hash256::blake3(b"ccc"); // Hashes should be orderable - let mut hashes = vec![hash2, hash3, hash1]; + let mut hashes = [hash2, hash3, hash1]; hashes.sort(); // After sorting, should be in consistent order diff --git a/tests/phase13_integration.rs b/tests/phase13_integration.rs index 2e05d57..da44f0b 100644 --- a/tests/phase13_integration.rs +++ b/tests/phase13_integration.rs @@ -42,7 +42,7 @@ mod dagknight_tests { let tolerance_ms = 5; // Simulate block production - let blocks_per_second = 32; + let _blocks_per_second = 32; let interval = Duration::from_millis(target_interval_ms); assert!( @@ -143,7 +143,7 @@ mod quantum_crypto_tests { /// Test hybrid signature (classical + post-quantum) #[test] fn test_hybrid_signature() { - use synor_crypto::signature::{HybridSignature, SignatureScheme}; + use synor_crypto::signature::SignatureScheme; let keypair = synor_crypto::keypair::Keypair::generate(SignatureScheme::HybridPQ); let message = b"Hybrid classical + post-quantum signature";