diff --git a/.ci/build-contracts.sh b/.ci/build-contracts.sh index 9ed34d3a..80d1a58b 100755 --- a/.ci/build-contracts.sh +++ b/.ci/build-contracts.sh @@ -25,6 +25,7 @@ docker run --rm --tty \ -v "$ARTIFACTS":/code/artifacts \ -v "$REGISTRY_CACHE":/usr/local/cargo/registry \ -v "$CARGO_GIT_CACHE":/usr/local/cargo/git \ +-e "RUSTUP_TOOLCHAIN=1.86.0" \ docker.io/cosmwasm/optimizer:0.17.0 # Our own custom build if different rust version is required diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73b4804c..b353b58a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: tool: just@1.40.0,nextest@0.9.99,sqlx-cli - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.86.0 + toolchain: 1.93.1 components: rustfmt, clippy - uses: Swatinem/rust-cache@v2 with: diff --git a/packages/examples/kademlia-discovery/src/lib.rs b/packages/examples/kademlia-discovery/src/lib.rs index 4ed25f47..b652e0f2 100644 --- a/packages/examples/kademlia-discovery/src/lib.rs +++ b/packages/examples/kademlia-discovery/src/lib.rs @@ -122,22 +122,6 @@ impl KolmeApp for KademliaTestApp { } } -#[derive(PartialEq, serde::Serialize, serde::Deserialize)] -struct RandomU32; - -impl KolmeDataRequest for RandomU32 { - type Response = u32; - - async fn load(self, _: &App) -> Result { - Ok(rand::random()) - } - - async fn validate(self, _: &App, _: &Self::Response) -> Result<()> { - // No validation possible - Ok(()) - } -} - pub async fn observer_node(validator_addr: &str, api_server_port: u16) -> Result<()> { let kolme = Kolme::new( KademliaTestApp::new(my_listener_key().clone(), my_approver_key().clone()), diff --git a/packages/kolme-store/src/fjall/merkle.rs b/packages/kolme-store/src/fjall/merkle.rs index b2f24d1d..fc798c41 100644 --- a/packages/kolme-store/src/fjall/merkle.rs +++ b/packages/kolme-store/src/fjall/merkle.rs @@ -115,9 +115,8 @@ fn render_children(children: &[Sha256Hash]) -> Vec { } fn parse_children(children: &[u8]) -> Result, MerkleSerialError> { - if children.len() % 32 != 0 { - return Err(MerkleSerialError::custom(std::io::Error::new( - std::io::ErrorKind::Other, + if !children.len().is_multiple_of(32) { + return Err(MerkleSerialError::custom(std::io::Error::other( "Children in fjall store not a multiple of 32 bytes", ))); } diff --git a/packages/kolme-test/src/multiple_processors.rs b/packages/kolme-test/src/multiple_processors.rs index d27c0f82..e9a48cc1 100644 --- a/packages/kolme-test/src/multiple_processors.rs +++ b/packages/kolme-test/src/multiple_processors.rs @@ -172,7 +172,7 @@ async fn client( guard.insert(txhash); let count = guard.len(); std::mem::drop(guard); - if count % 50 == 0 { + if count.is_multiple_of(50) { println!("In client, total transactions logged: {count}"); } } diff --git a/packages/merkle-map/src/impls/iter.rs b/packages/merkle-map/src/impls/iter.rs index 20147a6d..ea15677e 100644 --- a/packages/merkle-map/src/impls/iter.rs +++ b/packages/merkle-map/src/impls/iter.rs @@ -20,7 +20,7 @@ impl<'a, K, V> IntoIterator for &'a Node { } impl Node { - pub(crate) fn iter(&self) -> Iter { + pub(crate) fn iter(&self) -> Iter<'_, K, V> { self.into_iter() } } diff --git a/packages/merkle-map/src/impls/merkle_map.rs b/packages/merkle-map/src/impls/merkle_map.rs index cacf9653..3a79fb1f 100644 --- a/packages/merkle-map/src/impls/merkle_map.rs +++ b/packages/merkle-map/src/impls/merkle_map.rs @@ -132,7 +132,7 @@ where } impl MerkleMap { - pub fn iter(&self) -> crate::impls::iter::Iter { + pub fn iter(&self) -> crate::impls::iter::Iter<'_, K, V> { self.sanity_checks(); self.into_iter() } @@ -143,7 +143,7 @@ impl MerkleMap { } impl MerkleMap { - pub fn range(&self, range: R) -> impls::iter::Iter + pub fn range(&self, range: R) -> impls::iter::Iter<'_, K, V> where T: ToMerkleKey + ?Sized, K: Borrow, diff --git a/packages/merkle-map/src/impls/tree_contents.rs b/packages/merkle-map/src/impls/tree_contents.rs index 0502b948..55a3b91f 100644 --- a/packages/merkle-map/src/impls/tree_contents.rs +++ b/packages/merkle-map/src/impls/tree_contents.rs @@ -33,7 +33,7 @@ impl TreeContents { pub(crate) fn insert(&mut self, depth: u16, entry: LeafEntry) -> Option<(K, V)> { let Some(index) = entry.key_bytes.get_index_for_depth(depth) else { debug_assert!(depth == 0 || entry.key_bytes.get_index_for_depth(depth - 1).is_some()); - let v = std::mem::replace(&mut self.leaf, Some(entry)); + let v = self.leaf.replace(entry); if v.is_none() { self.len += 1; } diff --git a/packages/merkle-map/src/types/key_bytes.rs b/packages/merkle-map/src/types/key_bytes.rs index 10153934..f5318810 100644 --- a/packages/merkle-map/src/types/key_bytes.rs +++ b/packages/merkle-map/src/types/key_bytes.rs @@ -15,7 +15,7 @@ impl MerkleKey { // First get the byte in question... let byte = *self.0.get(usize::from(depth / 2))?; // Then get either the high or low bits, depending on whether our depth is even or odd - Some(if depth % 2 == 0 { + Some(if depth.is_multiple_of(2) { byte >> 4 } else { byte & 0x0F diff --git a/packages/shared/src/cryptography/real.rs b/packages/shared/src/cryptography/real.rs index dfeec5ff..66e21a72 100644 --- a/packages/shared/src/cryptography/real.rs +++ b/packages/shared/src/cryptography/real.rs @@ -105,14 +105,14 @@ impl borsh::ser::BorshSerialize for PublicKey { impl borsh::de::BorshDeserialize for PublicKey { #[inline] fn deserialize_reader(reader: &mut R) -> borsh::io::Result { - use borsh::io::{Error, ErrorKind}; + use borsh::io::Error; // We are forced to use the internal API because using the [T; N] array impl returns // a "Not all bytes read" error even though the binary representation is correct... let bytes: [u8; 33] = u8::array_from_reader(reader)?.unwrap(); // This always returns Some match Self::from_bytes(bytes) { Ok(sig) => Ok(sig), - Err(e) => Err(Error::new(ErrorKind::Other, e)), + Err(e) => Err(Error::other(e)), } } } @@ -310,14 +310,14 @@ impl borsh::ser::BorshSerialize for Signature { impl borsh::de::BorshDeserialize for Signature { #[inline] fn deserialize_reader(reader: &mut R) -> borsh::io::Result { - use borsh::io::{Error, ErrorKind}; + use borsh::io::Error; // We are forced to use the internal API because using the [T; N] array impl returns // a "Not all bytes read" error even though the binary representation is correct... let bytes: [u8; 64] = u8::array_from_reader(reader)?.unwrap(); // This always returns Some match Self::from_slice(&bytes) { Ok(sig) => Ok(sig), - Err(e) => Err(Error::new(ErrorKind::Other, e)), + Err(e) => Err(Error::other(e)), } } } @@ -394,13 +394,13 @@ impl borsh::ser::BorshSerialize for RecoveryId { impl borsh::de::BorshDeserialize for RecoveryId { #[inline] fn deserialize_reader(reader: &mut R) -> borsh::io::Result { - use borsh::io::{Error, ErrorKind}; + use borsh::io::Error; let byte = u8::deserialize_reader(reader)?; match Self::from_byte(byte) { Ok(id) => Ok(id), - Err(e) => Err(Error::new(ErrorKind::Other, e)), + Err(e) => Err(Error::other(e)), } } } diff --git a/packages/shared/src/types.rs b/packages/shared/src/types.rs index e93f4cfe..a12d0c70 100644 --- a/packages/shared/src/types.rs +++ b/packages/shared/src/types.rs @@ -83,7 +83,7 @@ mod cw_impls { type Suffix = Self; type SuperSuffix = Self; - fn key(&self) -> Vec { + fn key(&self) -> Vec> { self.0.key() } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index cf6d0f55..53551330 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.86.0" +channel = "1.93.1"