From 3dfb8150f1fb7fba800beed3f4761c529c5dd247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Wed, 15 May 2024 21:40:46 +0200 Subject: [PATCH] fix new warnings --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/apps/src/lib/bench_utils.rs | 6 +- crates/apps/src/lib/node/ledger/shell/mod.rs | 2 +- .../apps/src/lib/node/ledger/shell/queries.rs | 1 + .../src/lib/node/ledger/shell/testing/node.rs | 3 +- crates/core/src/storage.rs | 9 ++- crates/core/src/uint.rs | 2 +- crates/merkle_tree/src/lib.rs | 4 +- crates/namada/src/ledger/mod.rs | 2 + crates/proof_of_stake/src/lib.rs | 8 -- crates/sdk/Cargo.toml | 2 + crates/sdk/src/queries/router.rs | 8 ++ crates/sdk/src/tx.rs | 5 +- crates/tests/Cargo.toml | 4 +- crates/tests/src/e2e.rs | 4 +- crates/tests/src/native_vp/pos.rs | 1 - wasm/Cargo.lock | 4 +- wasm_for_tests/Cargo.lock | 76 ++++++++++--------- 19 files changed, 76 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f967862c68..cad4ae560d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5236,7 +5236,7 @@ dependencies = [ "namada_gas", "namada_macros", "namada_migrations", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits 0.2.17", "proptest", "prost 0.12.3", diff --git a/Cargo.toml b/Cargo.toml index 255a982dda..8cf62431f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,7 +126,7 @@ masp_primitives = { git = "https://github.com/anoma/masp", rev = "16fae96bbf6c14 masp_proofs = { git = "https://github.com/anoma/masp", rev = "16fae96bbf6c14f2459ac11bf1add27b94b52572", default-features = false, features = ["local-prover"] } num256 = "0.3.5" num_cpus = "1.13.0" -num-derive = "0.3.3" +num-derive = "0.4" num-rational = "0.4.1" num-traits = "0.2.14" once_cell = "1.8.0" diff --git a/crates/apps/src/lib/bench_utils.rs b/crates/apps/src/lib/bench_utils.rs index 79fcf608f4..8947c65806 100644 --- a/crates/apps/src/lib/bench_utils.rs +++ b/crates/apps/src/lib/bench_utils.rs @@ -656,8 +656,7 @@ pub struct BenchShieldedUtils { context_dir: WrapperTempDir, } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl ShieldedUtils for BenchShieldedUtils { fn local_tx_prover(&self) -> LocalTxProver { if let Ok(params_dir) = std::env::var(masp::ENV_VAR_MASP_PARAMS_DIR) { @@ -752,8 +751,7 @@ impl ShieldedUtils for BenchShieldedUtils { } } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl Client for BenchShell { type Error = std::io::Error; diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps/src/lib/node/ledger/shell/mod.rs index 546b55061f..1d50520fee 100644 --- a/crates/apps/src/lib/node/ledger/shell/mod.rs +++ b/crates/apps/src/lib/node/ledger/shell/mod.rs @@ -1072,7 +1072,7 @@ where response.code = ResultCode::InvalidTx.into(); response.log = "The wrapper gas limit overflowed gas \ representation" - .to_owned(); + .to_string(); return response; } }; diff --git a/crates/apps/src/lib/node/ledger/shell/queries.rs b/crates/apps/src/lib/node/ledger/shell/queries.rs index 7dab7cb27e..1e4ca8db0f 100644 --- a/crates/apps/src/lib/node/ledger/shell/queries.rs +++ b/crates/apps/src/lib/node/ledger/shell/queries.rs @@ -67,6 +67,7 @@ where // NOTE: we are testing `namada::ledger::queries_ext`, // which is not possible from `namada` since we do not have // access to the `Shell` there +#[allow(clippy::cast_possible_truncation)] #[cfg(test)] mod test_queries { use namada::core::storage::Epoch; diff --git a/crates/apps/src/lib/node/ledger/shell/testing/node.rs b/crates/apps/src/lib/node/ledger/shell/testing/node.rs index dd190774c8..7c4fbdcf1d 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/node.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/node.rs @@ -675,8 +675,7 @@ impl MockNode { } } -#[cfg_attr(feature = "async-send", async_trait::async_trait)] -#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] +#[async_trait::async_trait(?Send)] impl<'a> Client for &'a MockNode { type Error = Report; diff --git a/crates/core/src/storage.rs b/crates/core/src/storage.rs index 75c6998a64..0fb8045c83 100644 --- a/crates/core/src/storage.rs +++ b/crates/core/src/storage.rs @@ -53,6 +53,8 @@ pub enum Error { {0}" )] DbColFamily(String), + #[error("{0}")] + TryFromInt(#[from] std::num::TryFromIntError), } /// Result for functions that may fail @@ -1086,14 +1088,17 @@ macro_rules! impl_int_key_seg { // get signed int from a unsigned int complemented with a min // value let complemented = <$unsigned>::parse(string)?; - let signed = (complemented as $signed) ^ <$signed>::MIN; + let signed = <$signed>::try_from(complemented)?; + let signed = signed ^ <$signed>::MIN; Ok(signed) } fn raw(&self) -> String { // signed int is converted to unsigned int that preserves the // order by complementing it with a min value - let complemented = (*self ^ <$signed>::MIN) as $unsigned; + let complemented = + <$unsigned>::try_from(*self ^ <$signed>::MIN) + .expect("Complemented signed int is zero or positive"); complemented.raw() } diff --git a/crates/core/src/uint.rs b/crates/core/src/uint.rs index b22970d68c..f4d23d5686 100644 --- a/crates/core/src/uint.rs +++ b/crates/core/src/uint.rs @@ -180,7 +180,7 @@ impl Uint { q_hat } else { // here q_hat >= q_j >= q_hat - 1 - u64::max_value() + u64::MAX }; // ex. 20: diff --git a/crates/merkle_tree/src/lib.rs b/crates/merkle_tree/src/lib.rs index a1217053a3..915c995f1b 100644 --- a/crates/merkle_tree/src/lib.rs +++ b/crates/merkle_tree/src/lib.rs @@ -1419,7 +1419,7 @@ mod test { &value, )); // for the verification of the base tree - value = sub_root.clone(); + value.clone_from(&sub_root); } // Check the base root assert_eq!(sub_root, tree.root().0); @@ -1483,7 +1483,7 @@ mod test { &value, )); // for the verification of the base tree - value = sub_root.clone(); + value.clone_from(&sub_root); } // Check the base root assert_eq!(sub_root, tree.root().0); diff --git a/crates/namada/src/ledger/mod.rs b/crates/namada/src/ledger/mod.rs index 606d2b469b..a1200d1f62 100644 --- a/crates/namada/src/ledger/mod.rs +++ b/crates/namada/src/ledger/mod.rs @@ -174,8 +174,10 @@ mod test { /// tx wasm compilation cache pub tx_wasm_cache: TxCache, /// VP wasm compilation cache directory + #[allow(dead_code)] // never read pub vp_cache_dir: TempDir, /// tx wasm compilation cache directory + #[allow(dead_code)] // never read pub tx_cache_dir: TempDir, } diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index 42da174ba5..9660b8e060 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -375,14 +375,6 @@ where total_consensus_stake_handle().set(storage, total, epoch, 0) } -/// Used below in `fn unbond_tokens` to update the bond and unbond amounts -#[derive(Eq, Hash, PartialEq)] -struct BondAndUnbondUpdates { - bond_start: Epoch, - new_bond_value: token::Change, - unbond_value: token::Change, -} - /// Unbond tokens that are bonded between a validator and a source (self or /// delegator). /// diff --git a/crates/sdk/Cargo.toml b/crates/sdk/Cargo.toml index 62f3df7dd7..d03d7f817a 100644 --- a/crates/sdk/Cargo.toml +++ b/crates/sdk/Cargo.toml @@ -17,6 +17,8 @@ version.workspace = true [features] default = ["tendermint-rpc", "download-params", "std", "rand", "migrations"] +mainnet = ["namada_core/mainnet", "namada_events/mainnet"] + multicore = ["masp_proofs/multicore"] namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"] diff --git a/crates/sdk/src/queries/router.rs b/crates/sdk/src/queries/router.rs index 5270a859f6..e9adfe622e 100644 --- a/crates/sdk/src/queries/router.rs +++ b/crates/sdk/src/queries/router.rs @@ -657,6 +657,14 @@ macro_rules! router_type { // paste the generated methods $( $methods )* } + + impl Default for $name { + fn default() -> Self { + Self { + prefix: String::new(), + } + } + } } }; diff --git a/crates/sdk/src/tx.rs b/crates/sdk/src/tx.rs index 1d5d712d15..b6aa134d86 100644 --- a/crates/sdk/src/tx.rs +++ b/crates/sdk/src/tx.rs @@ -267,10 +267,7 @@ pub async fn is_reveal_pk_needed( client: &C, address: &Address, force: bool, -) -> Result -where - C: crate::queries::Client + Sync, -{ +) -> Result { // Check if PK revealed Ok(force || !has_revealed_pk(client, address).await?) } diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index cfe510f154..67e97c2ca3 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -47,8 +47,10 @@ flate2.workspace = true hyper = {version = "0.14.20", features = ["full"]} ibc-testkit.workspace = true ics23.workspace = true +itertools.workspace = true lazy_static.workspace = true num-traits.workspace = true +proptest.workspace = true prost.workspace = true regex.workspace = true serde.workspace = true @@ -76,10 +78,8 @@ escargot = {workspace = true} # , features = ["print"]} expectrl.workspace = true eyre.workspace = true fs_extra.workspace = true -itertools.workspace = true once_cell.workspace = true pretty_assertions.workspace = true -proptest.workspace = true proptest-state-machine.workspace = true rand.workspace = true test-log.workspace = true diff --git a/crates/tests/src/e2e.rs b/crates/tests/src/e2e.rs index 10a6f69d6e..b1cfb67a9d 100644 --- a/crates/tests/src/e2e.rs +++ b/crates/tests/src/e2e.rs @@ -11,8 +11,8 @@ //! To keep the temporary files created by a test, use env var //! `NAMADA_E2E_KEEP_TEMP=true`. -#[cfg(DISABLED_UNTIL_ERC20_WHITELISTS_IMPLEMENTED)] -pub mod eth_bridge_tests; +// Disabled until erc20 whitelists implemented +// pub mod eth_bridge_tests; pub mod helpers; pub mod ibc_tests; pub mod ledger_tests; diff --git a/crates/tests/src/native_vp/pos.rs b/crates/tests/src/native_vp/pos.rs index 57f04c706d..e0d970f11a 100644 --- a/crates/tests/src/native_vp/pos.rs +++ b/crates/tests/src/native_vp/pos.rs @@ -574,7 +574,6 @@ mod tests { } /// Testing helpers -#[cfg(any(test, feature = "testing"))] pub mod testing { use std::cell::RefCell; diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 2b0c163fa3..e424bdd199 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -4190,6 +4190,7 @@ dependencies = [ "hyper", "ibc-testkit", "ics23", + "itertools 0.10.5", "lazy_static", "namada", "namada_core", @@ -4198,6 +4199,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits", + "proptest", "prost 0.12.3", "regex", "serde", @@ -4249,7 +4251,7 @@ dependencies = [ "namada_gas", "namada_macros", "namada_migrations", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits", "proptest", "prost 0.12.3", diff --git a/wasm_for_tests/Cargo.lock b/wasm_for_tests/Cargo.lock index d82d1991d2..21d3332026 100644 --- a/wasm_for_tests/Cargo.lock +++ b/wasm_for_tests/Cargo.lock @@ -242,7 +242,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -554,7 +554,7 @@ dependencies = [ "proc-macro-crate 2.0.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", "syn_derive", ] @@ -874,7 +874,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f76990911f2267d837d9d0ad060aa63aaad170af40904b29461734c339030d4d" dependencies = [ "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1262,7 +1262,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1273,7 +1273,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1387,7 +1387,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1587,7 +1587,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1771,7 +1771,7 @@ dependencies = [ "regex", "serde", "serde_json", - "syn 2.0.39", + "syn 2.0.63", "toml 0.8.2", "walkdir", ] @@ -1789,7 +1789,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -1815,7 +1815,7 @@ dependencies = [ "serde", "serde_json", "strum 0.25.0", - "syn 2.0.39", + "syn 2.0.63", "tempfile", "thiserror", "tiny-keccak", @@ -2125,7 +2125,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -3004,7 +3004,7 @@ checksum = "23d961d2194fd5229961835d2eb78091906ef8afbaaa55bce7ad41bf3ead8aa9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -4136,6 +4136,7 @@ dependencies = [ "hyper", "ibc-testkit", "ics23", + "itertools 0.10.5", "lazy_static", "namada", "namada_core", @@ -4144,6 +4145,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits", + "proptest", "prost 0.12.3", "regex", "serde", @@ -4193,7 +4195,7 @@ dependencies = [ "namada_events", "namada_gas", "namada_macros", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits", "proptest", "prost 0.12.3", @@ -4388,7 +4390,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -4488,7 +4490,7 @@ dependencies = [ "proc-macro-crate 2.0.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -4821,7 +4823,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -4886,7 +4888,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -4958,9 +4960,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -5050,7 +5052,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -5099,9 +5101,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -5835,7 +5837,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -5868,7 +5870,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6039,7 +6041,7 @@ source = "git+https://github.com/heliaxdev/smooth-operator?tag=v0.6.0#1e9e2382dd dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6155,7 +6157,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6198,9 +6200,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -6216,7 +6218,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6444,7 +6446,7 @@ checksum = "7ba277e77219e9eea169e8508942db1bf5d8a41ff2db9b20aab5a5aadc9fa25d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6464,7 +6466,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6588,7 +6590,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6708,7 +6710,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -6944,7 +6946,7 @@ checksum = "982ee4197351b5c9782847ef5ec1fdcaf50503fb19d68f9771adae314e72b492" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ] [[package]] @@ -7259,7 +7261,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -7293,7 +7295,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7961,5 +7963,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.63", ]