From adfe54cd9b21f87e40190a514530c42f647dd687 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 22 Mar 2024 00:28:20 +0100 Subject: [PATCH 1/2] Bump clippy to 1.77.0 --- .circleci/config.yml | 2 +- contracts/staking/src/contract.rs | 5 +++-- packages/std/src/testing/assertions.rs | 1 + packages/vm/src/cache.rs | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e685942e7b..dfc0187e4d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,7 +72,7 @@ workflows: matrix: parameters: # Run with MSRV and some modern stable Rust - rust-version: ["1.73.0", "1.76.0"] + rust-version: ["1.73.0", "1.77.0"] - benchmarking: requires: - package_vm diff --git a/contracts/staking/src/contract.rs b/contracts/staking/src/contract.rs index 9015006ea2..a9de13a1b4 100644 --- a/contracts/staking/src/contract.rs +++ b/contracts/staking/src/contract.rs @@ -322,13 +322,14 @@ pub fn _bond_all_tokens( // we deduct pending claims from our account balance before reinvesting. // if there is not enough funds, we just return a no-op - match update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { + let updated = update_item(deps.storage, KEY_TOTAL_SUPPLY, |mut supply: Supply| { balance.amount = balance.amount.checked_sub(supply.claims)?; // this just triggers the "no op" case if we don't have min_withdrawal left to reinvest balance.amount.checked_sub(invest.min_withdrawal)?; supply.bonded += balance.amount; Ok(supply) - }) { + }); + match updated { Ok(_) => {} // if it is below the minimum, we do a no-op (do not revert other state from withdrawal) Err(StdError::Overflow { .. }) => return Ok(Response::default()), diff --git a/packages/std/src/testing/assertions.rs b/packages/std/src/testing/assertions.rs index c87ba28b55..01d68b29cd 100644 --- a/packages/std/src/testing/assertions.rs +++ b/packages/std/src/testing/assertions.rs @@ -158,6 +158,7 @@ mod tests { )] fn assert_approx_with_custom_panic_msg() { let adjective = "extra"; + #[allow(dead_code)] #[derive(Debug)] struct Foo(u32); assert_approx_eq!( diff --git a/packages/vm/src/cache.rs b/packages/vm/src/cache.rs index 5677bbc3e3..993d8590d9 100644 --- a/packages/vm/src/cache.rs +++ b/packages/vm/src/cache.rs @@ -522,6 +522,7 @@ fn save_wasm_to_disk(dir: impl Into, wasm: &[u8]) -> VmResult let mut file = OpenOptions::new() .write(true) .create(true) + .truncate(true) .open(filepath) .map_err(|e| VmError::cache_err(format!("Error opening Wasm file for writing: {e}")))?; file.write_all(wasm) From 24cb39f055d7f100a12e8d3808d27a35522f196e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Fri, 22 Mar 2024 09:54:57 +0100 Subject: [PATCH 2/2] Disable 4294967296usize on non-64 bit platforms --- packages/vm/src/conversion.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vm/src/conversion.rs b/packages/vm/src/conversion.rs index ef9577c4af..409abd6fa4 100644 --- a/packages/vm/src/conversion.rs +++ b/packages/vm/src/conversion.rs @@ -41,7 +41,8 @@ mod tests { assert_eq!(to_u32(2147483647usize).unwrap(), 2147483647); assert_eq!(to_u32(2147483648usize).unwrap(), 2147483648); assert_eq!(to_u32(4294967295usize).unwrap(), 4294967295); - + // Gate required for Rust 1.77.0 in Linux, possibly a Rust/clippy regression bug + #[cfg(target_pointer_width = "64")] match to_u32(4294967296usize) { Err(VmError::ConversionErr { from_type, @@ -130,6 +131,8 @@ mod tests { assert_eq!(ref_to_u32(&2147483647usize).unwrap(), 2147483647); assert_eq!(ref_to_u32(&2147483648usize).unwrap(), 2147483648); assert_eq!(ref_to_u32(&4294967295usize).unwrap(), 4294967295); + // Gate required for Rust 1.77.0 in Linux, possibly a Rust/clippy regression bug + #[cfg(target_pointer_width = "64")] match ref_to_u32(&4294967296usize).unwrap_err() { VmError::ConversionErr { from_type,