diff --git a/rust-toolchain.toml b/rust-toolchain.toml index bf76c6a78..50c144b52 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "stable-2023-08-03" +channel = "nightly-2023-08-03" components = ["rustfmt", "clippy"] profile = "minimal" diff --git a/src/storage/mod.rs b/src/storage/mod.rs index d33b963cf..6ffb5dce2 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -16,20 +16,19 @@ pub trait DBObject: Serialize + for<'de> Deserialize<'de> + Copy { fn db_key(suffix: Vec) -> Vec; /// Asynchronous methods for getting and setting the object in storage - async fn get(storage: &S, suffix: &Vec) -> Option + async fn get(storage: &S, suffix: &[u8]) -> Option where Self: Sized, { - let key = Self::db_key(suffix.clone()); - if let Some(data) = storage.get_value(key).await { - Some(from_slice(&data).expect("Failed to deserialize data")) - } else { - None - } + let key = Self::db_key(suffix.to_vec()); + storage + .get_value(key) + .await + .map(|data| from_slice(&data).expect("Failed to deserialize data")) } - async fn set(&self, storage: &S, suffix: &Vec) { - let key = Self::db_key(suffix.clone()); + async fn set(&self, storage: &S, suffix: &[u8]) { + let key = Self::db_key(suffix.to_vec()); let data = to_vec(self).expect("Failed to serialize data"); storage.set_value(key, data).await; } @@ -39,7 +38,7 @@ pub trait DBObject: Serialize + for<'de> Deserialize<'de> + Copy { pub struct FactCheckingContext { storage: S, hash_func: HashFunctionType, - n_workers: Option, + _n_workers: Option, } pub trait Fact: DBObject { diff --git a/src/storage/starknet.rs b/src/storage/starknet.rs index 8059fe818..9997a5570 100644 --- a/src/storage/starknet.rs +++ b/src/storage/starknet.rs @@ -70,7 +70,7 @@ impl CommitmentInfo { let actual_updated_tree = previous_tree .update(ffc, modifications, Some(&mut commitment_facts)) .await; - let actual_updated_root: FieldElement = actual_updated_tree.root.into(); + let actual_updated_root: FieldElement = actual_updated_tree.root; if actual_updated_root != expected_updated_root { return Err(CommitmentInfoError::InconsistentTreeRoots( diff --git a/src/utils/commitment_tree/binary_fact_tree.rs b/src/utils/commitment_tree/binary_fact_tree.rs index ec02c532a..81ca3514d 100644 --- a/src/utils/commitment_tree/binary_fact_tree.rs +++ b/src/utils/commitment_tree/binary_fact_tree.rs @@ -45,7 +45,7 @@ where index: FieldElement, ) -> Result { let leaves = self.get_leaves(ffc, vec![index], None).await; - if leaves.keys().ne(vec![index].iter()) { + if leaves.keys().ne([index].iter()) { return Err(FactTreeError::UnexpectedResult(index)); } diff --git a/src/utils/commitment_tree/patricia_tree.rs b/src/utils/commitment_tree/patricia_tree.rs index 0ba872679..d0e211256 100644 --- a/src/utils/commitment_tree/patricia_tree.rs +++ b/src/utils/commitment_tree/patricia_tree.rs @@ -18,41 +18,41 @@ pub struct PatriciaTree { } impl BinaryFactTree for PatriciaTree { - async fn empty_tree(&self, ffc: FactCheckingContext, height: usize, leaft_fact: L) { + async fn empty_tree(&self, _ffc: FactCheckingContext, _height: usize, _leaft_fact: L) { todo!() } async fn get_leaves( &self, - ffc: FactCheckingContext, - indices: Vec, - facts: Option, + _ffc: FactCheckingContext, + _indices: Vec, + _facts: Option, ) -> HashMap { todo!() } async fn _get_leaves( &self, - ffc: FactCheckingContext, - indices: Vec, - facts: Option, + _ffc: FactCheckingContext, + _indices: Vec, + _facts: Option, ) -> HashMap { todo!() } async fn update( &self, - ffc: FactCheckingContext, - modifications: HashMap, - facts: Option<&mut BinaryFactDict>, + _ffc: FactCheckingContext, + _modifications: HashMap, + _facts: Option<&mut BinaryFactDict>, ) -> Self { todo!() } async fn get_leaf( &self, - ffc: FactCheckingContext, - index: FieldElement, + _ffc: FactCheckingContext, + _index: FieldElement, ) -> Result { todo!() }