From 1ffd22a6abe3b6c7fc91efdf4f6868c1c4ade587 Mon Sep 17 00:00:00 2001 From: satan Date: Wed, 21 Feb 2024 17:23:30 +0100 Subject: [PATCH 1/4] [feat]: Bumping the toolchain version --- Cargo.lock | 8 +- crates/account/src/storage.rs | 3 - crates/apps/src/lib/cli.rs | 3 +- crates/apps/src/lib/cli/context.rs | 2 +- crates/apps/src/lib/cli/utils.rs | 1 + crates/apps/src/lib/client/rpc.rs | 7 +- crates/apps/src/lib/config/genesis.rs | 5 +- crates/apps/src/lib/config/genesis/chain.rs | 1 - crates/apps/src/lib/node/ledger/abortable.rs | 4 +- .../lib/node/ledger/ethereum_oracle/events.rs | 2 + .../node/ledger/shell/block_alloc/states.rs | 15 ++- .../lib/node/ledger/shell/finalize_block.rs | 33 +++---- .../src/lib/node/ledger/shell/governance.rs | 6 +- .../src/lib/node/ledger/shell/init_chain.rs | 91 ++++++++++--------- crates/apps/src/lib/node/ledger/shell/mod.rs | 46 +++------- .../lib/node/ledger/shell/prepare_proposal.rs | 8 +- .../lib/node/ledger/shell/process_proposal.rs | 25 +---- .../apps/src/lib/node/ledger/shell/queries.rs | 7 +- .../src/lib/node/ledger/shell/testing/node.rs | 4 +- .../lib/node/ledger/shell/vote_extensions.rs | 4 +- .../shell/vote_extensions/bridge_pool_vext.rs | 5 +- .../shell/vote_extensions/eth_events.rs | 8 +- .../shell/vote_extensions/val_set_update.rs | 38 +++----- .../src/lib/node/ledger/shims/abcipp_shim.rs | 1 - .../node/ledger/shims/abcipp_shim_types.rs | 2 - .../src/lib/node/ledger/storage/rocksdb.rs | 6 +- .../src/lib/node/ledger/tendermint_node.rs | 2 +- crates/apps/src/lib/wallet/mod.rs | 1 - crates/benches/vps.rs | 2 +- crates/core/src/types/address.rs | 4 +- crates/core/src/types/dec.rs | 1 - crates/core/src/types/eth_abi.rs | 3 +- crates/core/src/types/ethereum_events.rs | 5 +- crates/core/src/types/ibc.rs | 2 +- crates/core/src/types/keccak.rs | 1 - crates/core/src/types/key/common.rs | 3 - crates/core/src/types/key/ed25519.rs | 4 +- crates/core/src/types/key/mod.rs | 2 - crates/core/src/types/key/secp256k1.rs | 13 ++- crates/core/src/types/storage.rs | 3 +- crates/core/src/types/string_encoding.rs | 2 +- crates/core/src/types/time.rs | 1 - crates/core/src/types/token.rs | 28 +++--- crates/core/src/types/uint.rs | 20 ++-- crates/encoding_spec/src/main.rs | 7 +- .../transactions/bridge_pool_roots.rs | 4 +- .../transactions/ethereum_events/events.rs | 3 +- .../transactions/ethereum_events/mod.rs | 9 +- .../src/protocol/transactions/update.rs | 5 +- .../src/protocol/transactions/utils.rs | 2 - .../transactions/validator_set_update/mod.rs | 4 +- .../src/protocol/transactions/votes.rs | 11 +-- .../src/storage/eth_bridge_queries.rs | 8 +- crates/ethereum_bridge/src/storage/mod.rs | 2 +- .../ethereum_bridge/src/storage/parameters.rs | 2 - .../src/storage/vote_tallies.rs | 6 +- .../src/storage/wrapped_erc20s.rs | 4 +- crates/ibc/src/context/common.rs | 5 +- .../light_sdk/src/reading/asynchronous/pos.rs | 1 - crates/macros/src/lib.rs | 4 +- crates/merkle_tree/src/lib.rs | 7 +- crates/namada/src/ledger/mod.rs | 2 +- .../ethereum_bridge/bridge_pool_vp.rs | 3 +- .../ledger/native_vp/ethereum_bridge/vp.rs | 3 - crates/namada/src/ledger/native_vp/ibc/mod.rs | 16 ++-- crates/namada/src/ledger/native_vp/mod.rs | 2 - .../namada/src/ledger/native_vp/multitoken.rs | 11 +-- crates/namada/src/ledger/pos/mod.rs | 2 - crates/namada/src/ledger/pos/vp.rs | 2 +- crates/namada/src/ledger/protocol/mod.rs | 8 +- crates/namada/src/vm/host_env.rs | 5 - crates/namada/src/vm/types.rs | 8 +- crates/namada/src/vm/wasm/memory.rs | 4 +- crates/namada/src/vm/wasm/run.rs | 4 +- crates/parameters/src/lib.rs | 2 +- crates/proof_of_stake/src/epoched.rs | 1 - crates/proof_of_stake/src/lib.rs | 7 +- crates/proof_of_stake/src/parameters.rs | 1 - crates/proof_of_stake/src/pos_queries.rs | 4 +- crates/proof_of_stake/src/queries.rs | 2 +- crates/proof_of_stake/src/slashing.rs | 13 ++- crates/proof_of_stake/src/storage_key.rs | 2 +- .../src/tests/state_machine_v2.rs | 2 +- crates/proof_of_stake/src/types/mod.rs | 1 - crates/sdk/src/eth_bridge/bridge_pool.rs | 10 +- crates/sdk/src/eth_bridge/mod.rs | 5 +- crates/sdk/src/eth_bridge/validator_set.rs | 43 +++++---- crates/sdk/src/events/log.rs | 3 - crates/sdk/src/events/mod.rs | 1 - crates/sdk/src/lib.rs | 10 +- crates/sdk/src/masp.rs | 24 +++-- crates/sdk/src/queries/mod.rs | 2 - crates/sdk/src/queries/shell.rs | 2 +- crates/sdk/src/queries/shell/eth_bridge.rs | 17 +--- crates/sdk/src/queries/vp/pos.rs | 2 +- crates/sdk/src/rpc.rs | 2 +- crates/sdk/src/signing.rs | 4 +- crates/sdk/src/wallet/alias.rs | 2 +- crates/sdk/src/wallet/derivation_path.rs | 4 +- crates/sdk/src/wallet/keys.rs | 5 +- crates/sdk/src/wallet/store.rs | 12 +-- crates/shielded_token/src/conversion.rs | 2 +- crates/state/src/lib.rs | 13 +-- crates/state/src/write_log.rs | 3 +- crates/tests/src/e2e/eth_bridge_tests.rs | 7 +- crates/tests/src/e2e/ibc_tests.rs | 1 - crates/tests/src/e2e/ledger_tests.rs | 25 +++-- crates/tests/src/e2e/setup.rs | 3 +- crates/tests/src/integration/masp.rs | 2 +- crates/tests/src/native_vp/pos.rs | 7 +- .../src/storage_api/collections/lazy_map.rs | 5 +- .../src/storage_api/collections/lazy_set.rs | 5 +- .../src/storage_api/collections/lazy_vec.rs | 5 +- .../collections/nested_lazy_map.rs | 17 +--- crates/tests/src/vm_host_env/mod.rs | 2 +- crates/tests/src/vm_host_env/tx.rs | 4 +- crates/tests/src/vm_host_env/vp.rs | 4 +- crates/tx/src/types.rs | 5 +- crates/tx_prelude/src/proof_of_stake.rs | 1 - crates/vote_ext/src/ethereum_events.rs | 6 +- crates/vote_ext/src/lib.rs | 16 ++-- crates/vote_ext/src/validator_set_update.rs | 3 +- crates/vp_prelude/src/lib.rs | 2 - rust-nightly-version | 2 +- rust-toolchain.toml | 2 +- rustfmt.toml | 2 +- wasm/Cargo.lock | 16 +++- wasm/wasm_source/src/tx_bond.rs | 2 - .../src/tx_change_validator_commission.rs | 2 - wasm/wasm_source/src/tx_redelegate.rs | 2 - wasm/wasm_source/src/tx_unbond.rs | 2 - wasm/wasm_source/src/tx_withdraw.rs | 2 - wasm_for_tests/wasm_source/Cargo.lock | 16 +++- 133 files changed, 378 insertions(+), 577 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0ab8f6a289..f96b3af04d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.11", "once_cell", @@ -1427,9 +1427,9 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ "cfg-if 1.0.0", "cpufeatures", diff --git a/crates/account/src/storage.rs b/crates/account/src/storage.rs index 50b56e7808..a30a7f2e96 100644 --- a/crates/account/src/storage.rs +++ b/crates/account/src/storage.rs @@ -1,7 +1,4 @@ //! Cryptographic signature keys storage API - -use namada_core::types::address::Address; -use namada_core::types::key::common; use namada_core::types::storage; use namada_storage::{Result, StorageRead, StorageWrite}; diff --git a/crates/apps/src/lib/cli.rs b/crates/apps/src/lib/cli.rs index 38ad2cb14a..5deef4f7e8 100644 --- a/crates/apps/src/lib/cli.rs +++ b/crates/apps/src/lib/cli.rs @@ -2926,7 +2926,6 @@ pub mod cmds { pub mod args { use std::collections::HashMap; - use std::convert::TryFrom; use std::env; use std::net::SocketAddr; use std::path::PathBuf; @@ -6336,7 +6335,7 @@ pub mod args { let find_viewing_key = |w: &mut Wallet| { w.find_viewing_key(&self.viewing_key.raw) - .map(Clone::clone) + .copied() .unwrap_or_else(|_| { eprintln!( "Unknown viewing key {}", diff --git a/crates/apps/src/lib/cli/context.rs b/crates/apps/src/lib/cli/context.rs index 9380d7057b..2edce8d629 100644 --- a/crates/apps/src/lib/cli/context.rs +++ b/crates/apps/src/lib/cli/context.rs @@ -549,7 +549,7 @@ impl ArgFromMutContext for ExtendedViewingKey { // Or it is a stored alias of one ctx.wallet .find_viewing_key(raw) - .map(Clone::clone) + .copied() .map_err(|_find_err| format!("Unknown viewing key {}", raw)) }) } diff --git a/crates/apps/src/lib/cli/utils.rs b/crates/apps/src/lib/cli/utils.rs index 0f50a0926a..5faee0318c 100644 --- a/crates/apps/src/lib/cli/utils.rs +++ b/crates/apps/src/lib/cli/utils.rs @@ -380,6 +380,7 @@ pub trait AppExt { /// Extensions for finding matching commands and arguments. /// The functions match commands and arguments defined in [`AppExt`]. pub trait ArgMatchesExt { + #[allow(dead_code)] fn args_parse(&self) -> T; } diff --git a/crates/apps/src/lib/client/rpc.rs b/crates/apps/src/lib/client/rpc.rs index a39cfc8252..82a19bc486 100644 --- a/crates/apps/src/lib/client/rpc.rs +++ b/crates/apps/src/lib/client/rpc.rs @@ -4,7 +4,6 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fs::{self, read_dir}; use std::io; -use std::iter::Iterator; use std::str::FromStr; use borsh::BorshDeserialize; @@ -1330,8 +1329,8 @@ pub async fn query_proposal_result( false, ); - if proposal.is_ok() { - proposal.unwrap() + if let Ok(proposal) = proposal { + proposal } else { edisplay_line!( context.io(), @@ -1946,7 +1945,6 @@ pub async fn query_bonded_stake( match args.validator { Some(validator) => { - let validator = validator; // Find bonded stake for the given validator let stake = get_validator_stake(context.client(), epoch, &validator).await; @@ -2248,7 +2246,6 @@ pub async fn query_and_print_metadata( pub async fn query_slashes(context: &N, args: args::QuerySlashes) { match args.validator { Some(validator) => { - let validator = validator; // Find slashes for the given validator let slashes: Vec = unwrap_client_response::( RPC.vp() diff --git a/crates/apps/src/lib/config/genesis.rs b/crates/apps/src/lib/config/genesis.rs index 82e5f7cdab..057be9e9b7 100644 --- a/crates/apps/src/lib/config/genesis.rs +++ b/crates/apps/src/lib/config/genesis.rs @@ -1,3 +1,4 @@ +#![allow(clippy::non_canonical_partial_ord_impl)] //! The parameters used for the chain's genesis pub mod chain; @@ -400,7 +401,7 @@ pub fn make_dev_genesis( .validator_account .as_ref() .unwrap() - .get(0) + .first() .unwrap(); let genesis_addr = GenesisAddress::EstablishedAddress(tx.tx.data.address.raw.clone()); @@ -408,7 +409,7 @@ pub fn make_dev_genesis( let balance = *nam_balances.0.get(&genesis_addr).unwrap(); let bonded = { let bond = - genesis.transactions.bond.as_mut().unwrap().get(0).unwrap(); + genesis.transactions.bond.as_mut().unwrap().first().unwrap(); bond.amount }; diff --git a/crates/apps/src/lib/config/genesis/chain.rs b/crates/apps/src/lib/config/genesis/chain.rs index 88a95ec9f5..072be1788d 100644 --- a/crates/apps/src/lib/config/genesis/chain.rs +++ b/crates/apps/src/lib/config/genesis/chain.rs @@ -810,7 +810,6 @@ pub struct Metadata { #[cfg(test)] mod test { use std::path::PathBuf; - use std::str::FromStr; use super::*; diff --git a/crates/apps/src/lib/node/ledger/abortable.rs b/crates/apps/src/lib/node/ledger/abortable.rs index ceb4a4c892..58c3c26002 100644 --- a/crates/apps/src/lib/node/ledger/abortable.rs +++ b/crates/apps/src/lib/node/ledger/abortable.rs @@ -77,8 +77,8 @@ impl AbortableSpawner { /// This future will resolve when: /// /// 1. A user sends a shutdown signal (e.g. SIGINT), or... - /// 2. One of the child processes of the ledger terminates, - /// which generates a notification upon dropping an [`Aborter`]. + /// 2. One of the child processes of the ledger terminates, which + /// generates a notification upon dropping an [`Aborter`]. /// /// These two scenarios are represented by the [`AborterStatus`] enum. pub async fn wait_for_abort(mut self) -> AborterStatus { diff --git a/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs b/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs index a750ffbc15..042bb298dd 100644 --- a/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs +++ b/crates/apps/src/lib/node/ledger/ethereum_oracle/events.rs @@ -1,4 +1,5 @@ pub mod eth_events { + #![allow(dead_code)] use std::fmt::Debug; use std::str::FromStr; @@ -119,6 +120,7 @@ pub mod eth_events { } } + #[allow(unused_macros)] macro_rules! parse_method { ($name:ident -> $type:ty) => { fn $name(self) -> Result<$type> { diff --git a/crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs b/crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs index c5e0343ccf..7163cdf877 100644 --- a/crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs +++ b/crates/apps/src/lib/node/ledger/shell/block_alloc/states.rs @@ -6,18 +6,17 @@ //! //! The state machine moves through the following state DAG: //! -//! 1. [`BuildingEncryptedTxBatch`] - the initial state. In -//! this state, we populate a block with DKG encrypted txs. -//! This state supports two modes of operation, which you can -//! think of as two sub-states: +//! 1. [`BuildingEncryptedTxBatch`] - the initial state. In this state, we +//! populate a block with DKG encrypted txs. This state supports two modes of +//! operation, which you can think of as two sub-states: //! * [`WithoutEncryptedTxs`] - When this mode is active, no encrypted txs are //! included in a block proposal. //! * [`WithEncryptedTxs`] - When this mode is active, we are able to include //! encrypted txs in a block proposal. -//! 2. [`BuildingDecryptedTxBatch`] - the second state. In -//! this state, we populate a block with DKG decrypted txs. -//! 3. [`BuildingProtocolTxBatch`] - the third state. In -//! this state, we populate a block with protocol txs. +//! 2. [`BuildingDecryptedTxBatch`] - the second state. In this state, we +//! populate a block with DKG decrypted txs. +//! 3. [`BuildingProtocolTxBatch`] - the third state. In this state, we populate +//! a block with protocol txs. mod decrypted_txs; mod encrypted_txs; diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs index b72539c89e..63bb3d3d6a 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -5,28 +5,24 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use namada::governance::pgf::inflation as pgf_inflation; use namada::ledger::events::EventType; -use namada::ledger::gas::{GasMetering, TxGasMeter}; +use namada::ledger::gas::GasMetering; use namada::ledger::pos::namada_proof_of_stake; -use namada::ledger::protocol::{self, WrapperArgs}; +use namada::ledger::protocol::WrapperArgs; use namada::proof_of_stake::storage::{ find_validator_by_raw_hash, read_last_block_proposer_address, write_last_block_proposer_address, }; -use namada::state::wl_storage::WriteLogAndStorage; use namada::state::write_log::StorageModification; -use namada::state::{ - ResultExt, StorageRead, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY, -}; +use namada::state::{ResultExt, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY}; use namada::token::conversion::update_allowed_conversions; use namada::tx::data::protocol::ProtocolTxType; -use namada::types::key::tm_raw_hash_to_string; use namada::types::storage::{BlockHash, BlockResults, Epoch, Header}; use namada::vote_ext::ethereum_events::MultiSignedEthEvent; use namada::vote_ext::ethereum_tx_data_variants; use super::governance::execute_governance_proposals; use super::*; -use crate::facade::tendermint::abci::types::{Misbehavior, VoteInfo}; +use crate::facade::tendermint::abci::types::VoteInfo; use crate::node::ledger::shell::stats::InternalStats; impl Shell @@ -835,9 +831,7 @@ fn pos_votes_from_abci( ); // Try to convert voting power to u64 - let validator_vp = u64::try_from(*power).expect( - "Must be able to convert voting power from i64 to u64", - ); + let validator_vp = u64::from(*power); Some(namada_proof_of_stake::types::VoteInfo { validator_address, @@ -862,7 +856,6 @@ mod test_finalize_block { use std::num::NonZeroU64; use std::str::FromStr; - use data_encoding::HEXUPPER; use namada::core::ledger::replay_protection; use namada::eth_bridge::storage::bridge_pool::{ self, get_key_from_hash, get_nonce_key, get_signed_root_key, @@ -890,20 +883,18 @@ mod test_finalize_block { BondId, SlashType, ValidatorState, WeightedValidator, }; use namada::proof_of_stake::{unjail_validator, ADDRESS as pos_address}; - use namada::state::StorageWrite; use namada::token::{Amount, DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; - use namada::tx::data::{Fee, WrapperTx}; - use namada::tx::{Code, Data, Section, Signature}; + use namada::tx::data::Fee; + use namada::tx::{Code, Data, Signature}; use namada::types::dec::{Dec, POS_DECIMAL_PRECISION}; use namada::types::ethereum_events::{EthAddress, Uint as ethUint}; use namada::types::hash::Hash; use namada::types::keccak::KeccakHash; use namada::types::key::testing::common_sk_from_simple_seed; - use namada::types::key::tm_consensus_key_raw_hash; - use namada::types::storage::{Epoch, KeySeg}; - use namada::types::time::{DateTimeUtc, DurationSecs}; + use namada::types::storage::KeySeg; + use namada::types::time::DurationSecs; use namada::types::uint::Uint; - use namada::vote_ext::{ethereum_events, EthereumTxData}; + use namada::vote_ext::ethereum_events; use namada_sdk::eth_bridge::MinimumConfirmations; use namada_sdk::governance::ProposalVote; use namada_sdk::proof_of_stake::storage::{ @@ -915,9 +906,7 @@ mod test_finalize_block { use test_log::test; use super::*; - use crate::facade::tendermint::abci::types::{ - Misbehavior, Validator, VoteInfo, - }; + use crate::facade::tendermint::abci::types::Validator; use crate::node::ledger::oracle::control::Command; use crate::node::ledger::shell::test_utils::*; use crate::node::ledger::shims::abcipp_shim_types::shim::request::{ diff --git a/crates/apps/src/lib/node/ledger/shell/governance.rs b/crates/apps/src/lib/node/ledger/shell/governance.rs index 119bc789b2..0e2617cf1a 100644 --- a/crates/apps/src/lib/node/ledger/shell/governance.rs +++ b/crates/apps/src/lib/node/ledger/shell/governance.rs @@ -12,18 +12,16 @@ use namada::governance::utils::{ VotePower, }; use namada::governance::{storage as gov_api, ADDRESS as gov_address}; +use namada::ibc; use namada::ledger::governance::utils::ProposalEvent; use namada::ledger::pos::BondId; -use namada::ledger::protocol; use namada::proof_of_stake::bond_amount; use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::storage::read_total_stake; -use namada::state::{DBIter, StorageHasher, StorageWrite, DB}; +use namada::state::StorageWrite; use namada::tx::{Code, Data}; -use namada::types::address::Address; use namada::types::encode; use namada::types::storage::Epoch; -use namada::{ibc, token}; use namada_sdk::proof_of_stake::storage::read_validator_stake; use super::utils::force_read; diff --git a/crates/apps/src/lib/node/ledger/shell/init_chain.rs b/crates/apps/src/lib/node/ledger/shell/init_chain.rs index a881171b51..fda5ba863e 100644 --- a/crates/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/crates/apps/src/lib/node/ledger/shell/init_chain.rs @@ -6,14 +6,13 @@ use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; use masp_proofs::bls12_381; use namada::account::protocol_pk_key; +use namada::ledger::ibc; use namada::ledger::parameters::Parameters; -use namada::ledger::{ibc, pos}; use namada::proof_of_stake::BecomeValidator; -use namada::state::{DBIter, StorageHasher, StorageWrite, DB}; +use namada::state::StorageWrite; use namada::token::{credit_tokens, write_denom}; -use namada::types::address::Address; use namada::types::hash::Hash as CodeHash; -use namada::types::time::{DateTimeUtc, TimeZone, Utc}; +use namada::types::time::{TimeZone, Utc}; use namada::vm::validate_untrusted_wasm; use namada_sdk::eth_bridge::EthBridgeStatus; use namada_sdk::proof_of_stake::PosParams; @@ -27,7 +26,6 @@ use crate::config::genesis::templates::{TokenBalances, TokenConfig}; use crate::config::genesis::transactions::{ BondTx, EstablishedAccountTx, Signed as SignedTx, ValidatorAccountTx, }; -use crate::facade::tendermint::v0_37::abci::{request, response}; use crate::facade::tendermint_proto::google::protobuf; use crate::wasm_loader; @@ -188,10 +186,7 @@ where #[cfg(any(test, feature = "testing"))] _num_validators: u64, ) -> ControlFlow<()> { let ts: protobuf::Timestamp = init.time.into(); - let initial_height = init - .initial_height - .try_into() - .expect("Unexpected block height"); + let initial_height = init.initial_height.into(); // TODO hacky conversion, depends on https://github.com/informalsystems/tendermint-rs/issues/870 let genesis_time: DateTimeUtc = (Utc .timestamp_opt(ts.seconds, ts.nanos as u32)) @@ -282,8 +277,8 @@ where vp_cache: &mut HashMap>, ) -> ControlFlow<(), Vec> { use std::collections::hash_map::Entry; - let Some(vp_filename) = - self.validate( + let Some(vp_filename) = self + .validate( genesis .vps .wasm @@ -291,8 +286,10 @@ where .map(|conf| conf.filename.clone()) .ok_or_else(|| { Panic::MissingVpWasmConfig(name.to_string()) - })) - .or_placeholder(None)? else { + }), + ) + .or_placeholder(None)? + else { return self.proceed_with(vec![]); }; let code = match vp_cache.entry(vp_filename.clone()) { @@ -322,10 +319,13 @@ where } = params; let mut is_implicit_vp_stored = false; - let Some(checksums) = self.validate( - wasm_loader::Checksums::read_checksums(&self.wasm_dir) - .map_err(|_| Panic::ChecksumsFile) - ).or_placeholder(None)? else { + let Some(checksums) = self + .validate( + wasm_loader::Checksums::read_checksums(&self.wasm_dir) + .map_err(|_| Panic::ChecksumsFile), + ) + .or_placeholder(None)? + else { return self.proceed_with(()); }; @@ -459,15 +459,20 @@ where for (token_alias, TokenBalances(balances)) in &genesis.balances.token { tracing::debug!("Initializing token balances {token_alias}"); - let Some(token_address) = self.validate(genesis - .tokens - .token - .get(token_alias) - .ok_or_else(|| Panic::MissingTokenConfig(token_alias.to_string())) - .map(|conf| &conf.address) - ) - .or_placeholder(None)? else { - continue + let Some(token_address) = self + .validate( + genesis + .tokens + .token + .get(token_alias) + .ok_or_else(|| { + Panic::MissingTokenConfig(token_alias.to_string()) + }) + .map(|conf| &conf.address), + ) + .or_placeholder(None)? + else { + continue; }; let mut total_token_balance = token::Amount::zero(); @@ -939,13 +944,12 @@ mod test { use std::collections::BTreeMap; use std::str::FromStr; - use namada::state::DBIter; use namada::types::string_encoding::StringEncoded; use namada_sdk::wallet::alias::Alias; use super::*; use crate::config::genesis::{transactions, GenesisAddress}; - use crate::node::ledger::shell::test_utils::{self, TestShell}; + use crate::node::ledger::shell::test_utils::TestShell; use crate::wallet::defaults; /// Test that the init-chain handler never commits changes directly to the @@ -998,10 +1002,9 @@ mod test { *vp_cache.get("vp_user.wasm").expect("Test failed"), Vec::::new() ); - let [Panic::ReadingWasm(_, _)]: [Panic; 1] = initializer.panics - .clone() - .try_into() - .expect("Test failed") else { + let [Panic::ReadingWasm(_, _)]: [Panic; 1] = + initializer.panics.clone().try_into().expect("Test failed") + else { panic!("Test failed") }; @@ -1009,10 +1012,9 @@ mod test { genesis.vps.wasm.remove("vp_user").expect("Test failed"); let code = initializer.lookup_vp("vp_user", &genesis, &mut vp_cache); assert_eq!(code, ControlFlow::Continue(vec![])); - let [Panic::MissingVpWasmConfig(_)]: [Panic; 1] = initializer.panics - .clone() - .try_into() - .expect("Test failed") else { + let [Panic::MissingVpWasmConfig(_)]: [Panic; 1] = + initializer.panics.clone().try_into().expect("Test failed") + else { panic!("Test failed") }; } @@ -1053,10 +1055,9 @@ mod test { .store_wasms(&genesis.get_chain_parameters(test_dir.path())); assert_eq!(res, ControlFlow::Continue(())); let errors = initializer.errors.iter().collect::>(); - let [ - Error::ReadingWasm(_), - Error::LoadingWasm(_), - ]: [&Error; 2] = errors.try_into().expect("Test failed") else { + let [Error::ReadingWasm(_), Error::LoadingWasm(_)]: [&Error; 2] = + errors.try_into().expect("Test failed") + else { panic!("Test failed"); }; let expected_panics = vec![ @@ -1083,7 +1084,8 @@ mod test { Error::ReadingWasm(_), Error::LoadingWasm(_), Error::LoadingWasm(_), - ]: [&Error; 3] = errors.try_into().expect("Test failed") else { + ]: [&Error; 3] = errors.try_into().expect("Test failed") + else { panic!("Test failed"); }; let expected_panics = vec![Panic::MissingImplicitVP("None".into())]; @@ -1107,10 +1109,9 @@ mod test { .expect("Test failed"); let res = initializer.init_token_balances(&genesis); assert_eq!(res, ControlFlow::Continue(())); - let [Panic::MissingTokenConfig(_)]: [Panic; 1] = initializer.panics - .clone() - .try_into() - .expect("Test failed") else { + let [Panic::MissingTokenConfig(_)]: [Panic; 1] = + initializer.panics.clone().try_into().expect("Test failed") + else { panic!("Test failed") }; } diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps/src/lib/node/ledger/shell/mod.rs index d922969e9f..311db6b733 100644 --- a/crates/apps/src/lib/node/ledger/shell/mod.rs +++ b/crates/apps/src/lib/node/ledger/shell/mod.rs @@ -631,16 +631,7 @@ where for evidence in byzantine_validators { // dbg!(&evidence); tracing::info!("Processing evidence {evidence:?}."); - let evidence_height = match u64::try_from(evidence.height) { - Ok(height) => height, - Err(err) => { - tracing::error!( - "Unexpected evidence block height {}", - err - ); - continue; - } - }; + let evidence_height = u64::from(evidence.height); let evidence_epoch = match self .wl_storage .storage @@ -928,8 +919,12 @@ where ); return; } - let Some(config) = EthereumOracleConfig::read(&self.wl_storage) else { - tracing::info!("Not starting oracle as the Ethereum bridge config couldn't be found in storage"); + let Some(config) = EthereumOracleConfig::read(&self.wl_storage) + else { + tracing::info!( + "Not starting oracle as the Ethereum bridge config \ + couldn't be found in storage" + ); return; }; let active = @@ -1541,35 +1536,28 @@ where #[cfg(test)] mod test_utils { use std::ops::{Deref, DerefMut}; - use std::path::PathBuf; use data_encoding::HEXUPPER; use namada::ledger::parameters::{EpochDuration, Parameters}; use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::storage::validator_consensus_key_handle; use namada::state::mockdb::MockDB; - use namada::state::{ - LastBlock, Sha256Hasher, StorageWrite, EPOCH_SWITCH_BLOCKS_DELAY, - }; + use namada::state::{LastBlock, StorageWrite}; use namada::tendermint::abci::types::VoteInfo; use namada::token::conversion::update_allowed_conversions; - use namada::tx::data::{Fee, TxType, WrapperTx}; + use namada::tx::data::Fee; use namada::tx::{Code, Data}; - use namada::types::address; - use namada::types::chain::ChainId; use namada::types::ethereum_events::Uint; use namada::types::hash::Hash; use namada::types::keccak::KeccakHash; use namada::types::key::*; use namada::types::storage::{BlockHash, Epoch, Header}; - use namada::types::time::{DateTimeUtc, DurationSecs}; + use namada::types::time::DurationSecs; use tempfile::tempdir; use tokio::sync::mpsc::{Sender, UnboundedReceiver}; use super::*; use crate::config::ethereum_bridge::ledger::ORACLE_CHANNEL_BUFFER_SIZE; - use crate::facade::tendermint; - use crate::facade::tendermint::abci::types::Misbehavior; use crate::facade::tendermint_proto::google::protobuf::Timestamp; use crate::facade::tendermint_proto::v0_37::abci::{ RequestPrepareProposal, RequestProcessProposal, @@ -1805,7 +1793,7 @@ mod test_utils { }); let results = tx_results .into_iter() - .zip(req.txs.into_iter()) + .zip(req.txs) .map(|(res, tx_bytes)| ProcessedTx { result: res, tx: tx_bytes.into(), @@ -2221,20 +2209,14 @@ mod shell_tests { use namada::core::ledger::replay_protection; use namada::token::read_denom; use namada::tx::data::protocol::{ProtocolTx, ProtocolTxType}; - use namada::tx::data::{Fee, WrapperTx}; - use namada::tx::{ - Code, Data, Section, SignableEthMessage, Signature, Signed, Tx, - }; - use namada::types::ethereum_events::EthereumEvent; - use namada::types::key::RefTo; - use namada::types::storage::{BlockHeight, Epoch}; + use namada::tx::data::Fee; + use namada::tx::{Code, Data, Signature, Signed}; + use namada::types::storage::Epoch; use namada::vote_ext::{ bridge_pool_roots, ethereum_events, ethereum_tx_data_variants, }; - use namada::{parameters, token}; use super::*; - use crate::node::ledger::shell::test_utils; use crate::node::ledger::shell::token::DenominatedAmount; use crate::wallet; diff --git a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs index cd3b55cf30..45354bc8f5 100644 --- a/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -11,7 +11,6 @@ use namada::tx::data::{DecryptedTx, TxType, WrapperTx}; use namada::tx::Tx; use namada::types::address::Address; use namada::types::key::tm_raw_hash_to_string; -use namada::types::time::DateTimeUtc; use namada::vm::wasm::{TxCache, VpCache}; use namada::vm::WasmCacheAccess; @@ -443,16 +442,15 @@ mod test_prepare_proposal { use namada::state::collections::lazy_map::{NestedSubKey, SubKey}; use namada::token; use namada::token::{read_denom, Amount, DenominatedAmount}; - use namada::tx::data::{Fee, TxType, WrapperTx}; + use namada::tx::data::Fee; use namada::tx::{Code, Data, Header, Section, Signature, Signed}; - use namada::types::address::{self, Address}; + use namada::types::address; use namada::types::ethereum_events::EthereumEvent; use namada::types::key::RefTo; use namada::types::storage::{BlockHeight, InnerEthEventsQueue}; use namada::vote_ext::{ethereum_events, ethereum_tx_data_variants}; use super::*; - use crate::config::ValidatorLocalConfig; use crate::node::ledger::shell::test_utils::{ self, gen_keypair, get_pkh_from_address, TestShell, }; @@ -842,7 +840,7 @@ mod test_prepare_proposal { // fail the test let expected_txs: Vec
= expected_wrapper .into_iter() - .chain(expected_decrypted.into_iter()) + .chain(expected_decrypted) .map(|tx| tx.header) .collect(); let received: Vec
= shell diff --git a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs b/crates/apps/src/lib/node/ledger/shell/process_proposal.rs index db3cdb926c..1c36372ddb 100644 --- a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -2,16 +2,8 @@ //! and [`RevertProposal`] ABCI++ methods for the Shell use data_encoding::HEXUPPER; -use namada::core::hints; -use namada::ethereum_bridge::protocol::validation::bridge_pool_roots::validate_bp_roots_vext; -use namada::ethereum_bridge::protocol::validation::ethereum_events::validate_eth_events_vext; -use namada::ethereum_bridge::protocol::validation::validator_set_update::validate_valset_upd_vext; use namada::ledger::pos::PosQueries; -use namada::ledger::protocol::get_fee_unshielding_transaction; -use namada::ledger::storage::tx_queue::TxInQueue; -use namada::parameters::validate_tx_bytes; use namada::proof_of_stake::storage::find_validator_by_raw_hash; -use namada::state::{TempWlStorage, WlStorage}; use namada::tx::data::protocol::ProtocolTxType; use namada::vote_ext::ethereum_tx_data_variants; @@ -669,24 +661,17 @@ where mod test_process_proposal { use namada::ledger::replay_protection; use namada::state::StorageWrite; - use namada::token; use namada::token::{read_denom, Amount, DenominatedAmount}; - use namada::tx::data::{Fee, WrapperTx}; - use namada::tx::{ - Code, Data, Section, SignableEthMessage, Signature, Signed, - }; - use namada::types::ethereum_events::EthereumEvent; + use namada::tx::data::Fee; + use namada::tx::{Code, Data, Signature, Signed}; use namada::types::key::*; use namada::types::storage::Epoch; - use namada::types::time::DateTimeUtc; - use namada::vote_ext::{ - bridge_pool_roots, ethereum_events, EthereumTxData, - }; + use namada::vote_ext::{bridge_pool_roots, ethereum_events}; use super::*; use crate::node::ledger::shell::test_utils::{ - self, deactivate_bridge, gen_keypair, get_bp_bytes_to_sign, - ProcessProposal, TestError, TestShell, + deactivate_bridge, gen_keypair, get_bp_bytes_to_sign, ProcessProposal, + TestError, TestShell, }; use crate::node::ledger::shims::abcipp_shim_types::shim::request::ProcessedTx; use crate::wallet; diff --git a/crates/apps/src/lib/node/ledger/shell/queries.rs b/crates/apps/src/lib/node/ledger/shell/queries.rs index 721fd14621..3595a5f8d3 100644 --- a/crates/apps/src/lib/node/ledger/shell/queries.rs +++ b/crates/apps/src/lib/node/ledger/shell/queries.rs @@ -2,11 +2,8 @@ use namada::ledger::dry_run_tx; use namada::ledger::queries::{RequestCtx, ResponseQuery}; -use namada::token; -use namada::types::address::Address; use super::*; -use crate::node::ledger::response; impl Shell where @@ -69,13 +66,11 @@ mod test_queries { use namada::ledger::pos::PosQueries; use namada::proof_of_stake::storage::read_consensus_validator_set_addresses_with_stake; use namada::proof_of_stake::types::WeightedValidator; - use namada::state::EPOCH_SWITCH_BLOCKS_DELAY; use namada::tendermint::abci::types::VoteInfo; use namada::types::storage::{BlockHash, Epoch}; - use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; + use namada_sdk::eth_bridge::SendValsetUpd; use super::*; - use crate::node::ledger::shell::test_utils; use crate::node::ledger::shell::test_utils::get_pkh_from_address; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; 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 ceb4fe1637..1482303791 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/node.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/node.rs @@ -571,7 +571,7 @@ impl MockNode { txs: txs .clone() .into_iter() - .zip(tx_results.into_iter()) + .zip(tx_results) .map(|(tx, result)| ProcessedTx { tx: tx.into(), result, @@ -835,7 +835,7 @@ impl<'a> Client for &'a MockNode { block: 0, app: 0, }), - chain_id: "Namada".try_into().unwrap(), + chain_id: "Namada".into(), height: encoded_event.0 as i64, time: None, last_block_id: None, diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions.rs index 2f0454bbb4..7bf22a6d42 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions.rs @@ -10,10 +10,8 @@ use namada::ethereum_bridge::protocol::transactions::validator_set_update::sign_ pub use namada::ethereum_bridge::protocol::validation::VoteExtensionError; use namada::tx::Signed; use namada::vote_ext::{ - bridge_pool_roots, ethereum_events, validator_set_update, EthereumTxData, - VoteExtension, + bridge_pool_roots, ethereum_events, validator_set_update, VoteExtension, }; -use namada_sdk::eth_bridge::EthBridgeQueries; use super::*; use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs index f6f9f10308..887eee36fe 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs @@ -1,11 +1,8 @@ //! Extend Tendermint votes with signatures of the Ethereum //! bridge pool root and nonce seen by a quorum of validators. use itertools::Itertools; -use namada::state::{DBIter, StorageHasher, DB}; -use namada::tx::Signed; use super::*; -use crate::node::ledger::shell::Shell; impl Shell where @@ -70,7 +67,7 @@ mod test_bp_vote_extensions { use namada::proof_of_stake::{become_validator, BecomeValidator, Epoch}; use namada::state::StorageWrite; use namada::tendermint::abci::types::VoteInfo; - use namada::tx::{SignableEthMessage, Signed}; + use namada::tx::Signed; use namada::types::ethereum_events::Uint; use namada::types::keccak::{keccak_hash, KeccakHash}; use namada::types::key::*; diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs index 8ef538bbcb..3630a47c00 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs @@ -2,14 +2,9 @@ use std::collections::{BTreeMap, HashMap}; -use namada::state::{DBIter, StorageHasher, DB}; -use namada::tx::Signed; -use namada::types::ethereum_events::EthereumEvent; -use namada::vote_ext::ethereum_events::{self, MultiSignedEthEvent}; -use namada_sdk::eth_bridge::EthBridgeQueries; +use namada::vote_ext::ethereum_events::MultiSignedEthEvent; use super::*; -use crate::node::ledger::shell::{Shell, ShellMode}; impl Shell where @@ -140,7 +135,6 @@ where #[cfg(test)] mod test_vote_extensions { - use std::convert::TryInto; use borsh_ext::BorshSerializeExt; use namada::eth_bridge::storage::bridge_pool; diff --git a/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs b/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs index 67eb2a0a88..fdd53239d5 100644 --- a/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs +++ b/crates/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs @@ -3,11 +3,7 @@ use std::collections::HashMap; -use namada::state::{DBIter, StorageHasher, DB}; -use namada::vote_ext::validator_set_update; - use super::*; -use crate::node::ledger::shell::Shell; impl Shell where @@ -157,19 +153,17 @@ mod test_vote_extensions { .collect() }; #[allow(clippy::redundant_clone)] - let validator_set_update = Some( - validator_set_update::Vext { - voting_powers, - validator_addr: validator_addr.clone(), - // invalid epoch - signing_epoch: next_epoch, - } - .sign(eth_bridge_key), - ); + let validator_set_update = validator_set_update::Vext { + voting_powers, + validator_addr: validator_addr.clone(), + // invalid epoch + signing_epoch: next_epoch, + } + .sign(eth_bridge_key); assert!( validate_valset_upd_vext( &shell.wl_storage, - &validator_set_update.unwrap(), + &validator_set_update, signing_epoch, ) .is_err() @@ -200,18 +194,16 @@ mod test_vote_extensions { .collect() }; #[allow(clippy::redundant_clone)] - let validator_set_update = Some( - validator_set_update::Vext { - voting_powers, - signing_epoch, - validator_addr: validator_addr.clone(), - } - .sign(ð_bridge_key), - ); + let validator_set_update = validator_set_update::Vext { + voting_powers, + signing_epoch, + validator_addr: validator_addr.clone(), + } + .sign(ð_bridge_key); assert!( validate_valset_upd_vext( &shell.wl_storage, - &validator_set_update.unwrap(), + &validator_set_update, signing_epoch, ) .is_err() diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 1b8b7343fd..31fcaecb80 100644 --- a/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/crates/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::future::Future; use std::path::PathBuf; use std::pin::Pin; diff --git a/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index 5b0a553f55..5de3994eb8 100644 --- a/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/crates/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -1,7 +1,6 @@ use crate::facade::tendermint::v0_37::abci::{Request, Response}; pub mod shim { - use std::convert::TryFrom; use thiserror::Error; @@ -151,7 +150,6 @@ pub mod shim { /// Custom types for request payloads pub mod request { - use std::convert::TryFrom; use namada::types::hash::Hash; use namada::types::storage::{BlockHash, Header}; diff --git a/crates/apps/src/lib/node/ledger/storage/rocksdb.rs b/crates/apps/src/lib/node/ledger/storage/rocksdb.rs index c708605ad7..6e417f4453 100644 --- a/crates/apps/src/lib/node/ledger/storage/rocksdb.rs +++ b/crates/apps/src/lib/node/ledger/storage/rocksdb.rs @@ -1765,8 +1765,6 @@ fn set_max_open_files(cf_opts: &mut rocksdb::Options) { #[cfg(unix)] mod imp { - use std::convert::TryInto; - use rlimit::{Resource, Rlim}; const DEFAULT_NOFILE_LIMIT: Rlim = Rlim::from_raw(16384); @@ -1818,7 +1816,7 @@ mod test { use namada::types::address::{ gen_established_address, EstablishedAddressGen, }; - use namada::types::storage::{BlockHash, Epoch, Epochs}; + use namada::types::storage::{BlockHash, Epochs}; use tempfile::tempdir; use test_log::test; @@ -1979,7 +1977,7 @@ mod test { let keys_0 = vec![key_0_a, key_0_b, key_0_c]; let keys_1 = vec![key_1_a, key_1_b, key_1_c]; let keys_01 = vec![key_01_a]; - let all_keys = vec![keys_0.clone(), keys_01, keys_1.clone()].concat(); + let all_keys = [keys_0.clone(), keys_01, keys_1.clone()].concat(); // Write the keys let mut batch = RocksDB::batch(); diff --git a/crates/apps/src/lib/node/ledger/tendermint_node.rs b/crates/apps/src/lib/node/ledger/tendermint_node.rs index 9efd96de5e..3eb0f5af6a 100644 --- a/crates/apps/src/lib/node/ledger/tendermint_node.rs +++ b/crates/apps/src/lib/node/ledger/tendermint_node.rs @@ -461,7 +461,7 @@ async fn write_tm_genesis( // gas is metered app-side, so we disable it // at the Tendermint level max_gas: -1, - /// This parameter has no value anymore in Tendermint-core + // This parameter has no value anymore in Tendermint-core time_iota_ms: block::Size::default_time_iota_ms(), }; genesis.consensus_params.block = size; diff --git a/crates/apps/src/lib/wallet/mod.rs b/crates/apps/src/lib/wallet/mod.rs index 3ed2969742..6f2d6b3892 100644 --- a/crates/apps/src/lib/wallet/mod.rs +++ b/crates/apps/src/lib/wallet/mod.rs @@ -288,7 +288,6 @@ pub fn read_and_confirm_encryption_password( mod tests { use namada::bip39::MnemonicType; use namada_sdk::wallet::WalletIo; - use rand_core; use super::CliWalletUtils; diff --git a/crates/benches/vps.rs b/crates/benches/vps.rs index 35dc7ca219..7c5038c0cc 100644 --- a/crates/benches/vps.rs +++ b/crates/benches/vps.rs @@ -215,7 +215,7 @@ fn vp_implicit(c: &mut Criterion) { let reveal_pk = shell.generate_tx( TX_REVEAL_PK_WASM, - &implicit_account.to_public(), + implicit_account.to_public(), None, None, vec![], diff --git a/crates/core/src/types/address.rs b/crates/core/src/types/address.rs index 7626d3c0b6..baea060b21 100644 --- a/crates/core/src/types/address.rs +++ b/crates/core/src/types/address.rs @@ -229,7 +229,7 @@ impl<'addr> From<&'addr Address> for raw::Address<'addr, raw::Validated> { // the order. impl PartialOrd for Address { fn partial_cmp(&self, other: &Self) -> Option { - self.encode().partial_cmp(&other.encode()) + Some(self.cmp(other)) } } @@ -725,7 +725,7 @@ pub fn gen_established_address(seed: impl AsRef) -> Address { let mut key_gen = EstablishedAddressGen::new(seed); let mut rng: ThreadRng = thread_rng(); - let mut rng_bytes = vec![0u8; 32]; + let mut rng_bytes = [0u8; 32]; rng.fill_bytes(&mut rng_bytes[..]); let rng_source = rng_bytes .iter() diff --git a/crates/core/src/types/dec.rs b/crates/core/src/types/dec.rs index 5b32b484e5..b7c04f5f7d 100644 --- a/crates/core/src/types/dec.rs +++ b/crates/core/src/types/dec.rs @@ -549,7 +549,6 @@ pub mod testing { #[cfg(test)] mod test_dec { use super::*; - use crate::types::token::{Amount, Change}; #[derive(Debug, Serialize, Deserialize)] struct SerializerTest { diff --git a/crates/core/src/types/eth_abi.rs b/crates/core/src/types/eth_abi.rs index 886b5b9c46..937f140d1c 100644 --- a/crates/core/src/types/eth_abi.rs +++ b/crates/core/src/types/eth_abi.rs @@ -40,7 +40,7 @@ impl ::std::cmp::PartialEq for EncodeCell { impl ::std::cmp::PartialOrd for EncodeCell { fn partial_cmp(&self, other: &Self) -> Option<::std::cmp::Ordering> { - self.encoded_data.partial_cmp(&other.encoded_data) + Some(self.cmp(other)) } } @@ -121,7 +121,6 @@ impl Encode for AbiEncode { // TODO: test signatures here once we merge secp keys #[cfg(test)] mod tests { - use std::convert::TryInto; use std::str::FromStr; use data_encoding::HEXLOWER; diff --git a/crates/core/src/types/ethereum_events.rs b/crates/core/src/types/ethereum_events.rs index 8569b118e4..0463efd71c 100644 --- a/crates/core/src/types/ethereum_events.rs +++ b/crates/core/src/types/ethereum_events.rs @@ -40,7 +40,7 @@ pub struct Uint(pub [u64; 4]); impl PartialOrd for Uint { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - ethUint(self.0).partial_cmp(ðUint(other.0)) + Some(self.cmp(other)) } } @@ -390,7 +390,6 @@ impl From for TransferToEthereum { #[cfg(test)] pub mod tests { - use std::str::FromStr; use super::*; @@ -450,7 +449,7 @@ pub mod testing { use proptest::prop_compose; use super::*; - use crate::types::token::{self, Amount}; + use crate::types::token; pub const DAI_ERC20_ETH_ADDRESS_CHECKSUMMED: &str = "0x6B175474E89094C44Da98b954EedeAC495271d0F"; diff --git a/crates/core/src/types/ibc.rs b/crates/core/src/types/ibc.rs index f517c84363..69d3eccc60 100644 --- a/crates/core/src/types/ibc.rs +++ b/crates/core/src/types/ibc.rs @@ -82,7 +82,7 @@ pub struct IbcEvent { impl std::cmp::PartialOrd for IbcEvent { fn partial_cmp(&self, other: &Self) -> Option { - self.event_type.partial_cmp(&other.event_type) + Some(self.cmp(other)) } } diff --git a/crates/core/src/types/keccak.rs b/crates/core/src/types/keccak.rs index f6fc15724d..98d755a4a7 100644 --- a/crates/core/src/types/keccak.rs +++ b/crates/core/src/types/keccak.rs @@ -1,7 +1,6 @@ //! This module is for hashing Namada types using the keccak256 //! hash function in a way that is compatible with smart contracts //! on Ethereum. -use std::convert::{TryFrom, TryInto}; use std::fmt; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; diff --git a/crates/core/src/types/key/common.rs b/crates/core/src/types/key/common.rs index 7db4641879..efb71ff2ef 100644 --- a/crates/core/src/types/key/common.rs +++ b/crates/core/src/types/key/common.rs @@ -1,6 +1,4 @@ //! Cryptographic keys - -use std::convert::TryFrom; use std::fmt::Display; use std::str::FromStr; @@ -456,7 +454,6 @@ impl super::SigScheme for SigScheme { #[cfg(test)] mod tests { use super::*; - use crate::types::key::ed25519; /// Run `cargo test gen_ed25519_keypair -- --nocapture` to generate a /// new ed25519 keypair wrapped in `common` key types. diff --git a/crates/core/src/types/key/ed25519.rs b/crates/core/src/types/key/ed25519.rs index 2e118fe90e..7485894460 100644 --- a/crates/core/src/types/key/ed25519.rs +++ b/crates/core/src/types/key/ed25519.rs @@ -105,7 +105,7 @@ impl Hash for PublicKey { impl PartialOrd for PublicKey { fn partial_cmp(&self, other: &Self) -> Option { - self.0.to_bytes().partial_cmp(&other.0.to_bytes()) + Some(self.cmp(other)) } } @@ -316,7 +316,7 @@ impl Hash for Signature { impl PartialOrd for Signature { fn partial_cmp(&self, other: &Self) -> Option { - self.0.to_bytes().partial_cmp(&other.0.to_bytes()) + Some(self.cmp(other)) } } diff --git a/crates/core/src/types/key/mod.rs b/crates/core/src/types/key/mod.rs index b07efc0ba4..45676b39f0 100644 --- a/crates/core/src/types/key/mod.rs +++ b/crates/core/src/types/key/mod.rs @@ -485,12 +485,10 @@ impl SignableBytes for &crate::types::keccak::KeccakHash { /// Helpers for testing with keys. #[cfg(any(test, feature = "testing"))] pub mod testing { - use borsh::BorshDeserialize; use proptest::prelude::*; use rand::prelude::{StdRng, ThreadRng}; use rand::{thread_rng, SeedableRng}; - use super::SigScheme; use crate::types::key::*; /// Generate an arbitrary public key diff --git a/crates/core/src/types/key/secp256k1.rs b/crates/core/src/types/key/secp256k1.rs index 06ae2c4216..620f5d0178 100644 --- a/crates/core/src/types/key/secp256k1.rs +++ b/crates/core/src/types/key/secp256k1.rs @@ -118,7 +118,7 @@ impl Hash for PublicKey { impl PartialOrd for PublicKey { fn partial_cmp(&self, other: &Self) -> Option { - self.0.to_sec1_bytes().partial_cmp(&other.0.to_sec1_bytes()) + Some(self.cmp(other)) } } @@ -490,16 +490,16 @@ impl Hash for Signature { impl PartialOrd for Signature { fn partial_cmp(&self, other: &Self) -> Option { - match self.0.to_bytes().partial_cmp(&other.0.to_bytes()) { - Some(Ordering::Equal) => self.1.partial_cmp(&other.1), - res => res, - } + Some(self.cmp(other)) } } impl Ord for Signature { fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other).unwrap() + match self.0.to_bytes().partial_cmp(&other.0.to_bytes()) { + Some(Ordering::Equal) => self.1.cmp(&other.1), + res => res.unwrap(), + } } } @@ -601,7 +601,6 @@ impl super::SigScheme for SigScheme { #[cfg(test)] mod test { - use k256::elliptic_curve::sec1::ToEncodedPoint; use super::*; diff --git a/crates/core/src/types/storage.rs b/crates/core/src/types/storage.rs index da1ed2920e..3f52901393 100644 --- a/crates/core/src/types/storage.rs +++ b/crates/core/src/types/storage.rs @@ -1,10 +1,9 @@ //! Storage types use std::collections::VecDeque; -use std::convert::{TryFrom, TryInto}; use std::fmt::Display; use std::io::{Read, Write}; use std::num::ParseIntError; -use std::ops::{Add, AddAssign, Deref, Div, Drop, Mul, Rem, Sub}; +use std::ops::{Add, AddAssign, Deref, Div, Mul, Rem, Sub}; use std::str::FromStr; use arse_merkle_tree::InternalKey; diff --git a/crates/core/src/types/string_encoding.rs b/crates/core/src/types/string_encoding.rs index 47db158d85..a1e0361c52 100644 --- a/crates/core/src/types/string_encoding.rs +++ b/crates/core/src/types/string_encoding.rs @@ -11,7 +11,7 @@ use std::fmt::Display; use std::ops::Deref; use std::str::FromStr; -use bech32::{self, FromBase32, ToBase32, Variant}; +use bech32::{FromBase32, ToBase32, Variant}; use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/core/src/types/time.rs b/crates/core/src/types/time.rs index 150096c691..3a5e1d617f 100644 --- a/crates/core/src/types/time.rs +++ b/crates/core/src/types/time.rs @@ -1,7 +1,6 @@ //! Types for dealing with time and durations. use std::collections::BTreeMap; -use std::convert::{TryFrom, TryInto}; use std::fmt::Display; use std::io::Read; use std::ops::{Add, Sub}; diff --git a/crates/core/src/types/token.rs b/crates/core/src/types/token.rs index 02370b9854..212b0e5cdf 100644 --- a/crates/core/src/types/token.rs +++ b/crates/core/src/types/token.rs @@ -572,6 +572,12 @@ impl FromStr for DenominatedAmount { impl PartialOrd for DenominatedAmount { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for DenominatedAmount { + fn cmp(&self, other: &Self) -> Ordering { if self.denom < other.denom { let diff = other.denom.0 - self.denom.0; let (div, rem) = @@ -581,12 +587,12 @@ impl PartialOrd for DenominatedAmount { } else { div + Uint::one() }; - let ord = self.amount.raw.partial_cmp(&div_ceil); - if let Some(Ordering::Equal) = ord { + let ord = self.amount.raw.cmp(&div_ceil); + if let Ordering::Equal = ord { if rem.is_zero() { - Some(Ordering::Equal) + Ordering::Equal } else { - Some(Ordering::Greater) + Ordering::Greater } } else { ord @@ -600,12 +606,12 @@ impl PartialOrd for DenominatedAmount { } else { div + Uint::one() }; - let ord = div_ceil.partial_cmp(&other.amount.raw); - if let Some(Ordering::Equal) = ord { + let ord = div_ceil.cmp(&other.amount.raw); + if let Ordering::Equal = ord { if rem.is_zero() { - Some(Ordering::Equal) + Ordering::Equal } else { - Some(Ordering::Less) + Ordering::Less } } else { ord @@ -614,12 +620,6 @@ impl PartialOrd for DenominatedAmount { } } -impl Ord for DenominatedAmount { - fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other).unwrap() - } -} - impl serde::Serialize for Amount { fn serialize( &self, diff --git a/crates/core/src/types/uint.rs b/crates/core/src/types/uint.rs index e13cb9ce1b..148c814474 100644 --- a/crates/core/src/types/uint.rs +++ b/crates/core/src/types/uint.rs @@ -636,29 +636,29 @@ impl Neg for I256 { impl PartialOrd for I256 { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for I256 { + fn cmp(&self, other: &Self) -> Ordering { match (self.non_negative(), other.non_negative()) { - (true, false) => Some(Ordering::Greater), - (false, true) => Some(Ordering::Less), + (true, false) => Ordering::Greater, + (false, true) => Ordering::Less, (true, true) => { let this = self.abs(); let that = other.abs(); - this.partial_cmp(&that) + this.cmp(&that) } (false, false) => { let this = self.abs(); let that = other.abs(); - that.partial_cmp(&this) + that.cmp(&this) } } } } -impl Ord for I256 { - fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other).unwrap() - } -} - impl Add for I256 { type Output = Self; diff --git a/crates/encoding_spec/src/main.rs b/crates/encoding_spec/src/main.rs index d6bb9df06c..d6838c7cde 100644 --- a/crates/encoding_spec/src/main.rs +++ b/crates/encoding_spec/src/main.rs @@ -17,7 +17,6 @@ use std::collections::{BTreeMap, HashSet}; use std::io::Write; -use std::iter::Extend; use borsh::schema::{BorshSchemaContainer, Declaration, Definition}; use borsh::{schema, schema_container_of}; @@ -288,10 +287,10 @@ fn definition_to_table(name: &Declaration, def: schema::Definition) -> Table { (desc, rows) } schema::Definition::Sequence { - length_width, + length_width: 0, length_range, elements, - } if length_width == 0 => { + } => { let rows = None; let desc = format!( "Fixed-size array with {} elements of {}", @@ -330,7 +329,7 @@ fn definition_to_table(name: &Declaration, def: schema::Definition) -> Table { } => { let mut rows = madato::types::Table::default(); // build rows for: Variant, Name, Type - for (_, (variant, name, type_name)) in variants.iter().enumerate() { + for (variant, name, type_name) in variants.iter() { rows.push(TableRow::from_iter([ ("Prefix byte".into(), variant.to_string()), ("Name".into(), name.clone()), diff --git a/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs b/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs index afd307fb87..cb986e5032 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/bridge_pool_roots.rs @@ -261,14 +261,12 @@ mod test_apply_bp_roots_to_storage { use borsh::BorshDeserialize; use namada_core::types::address; use namada_core::types::ethereum_events::Uint; - use namada_core::types::keccak::{keccak_hash, KeccakHash}; + use namada_core::types::keccak::KeccakHash; use namada_core::types::storage::Key; use namada_core::types::voting_power::FractionalVotingPower; use namada_proof_of_stake::parameters::OwnedPosParams; use namada_proof_of_stake::storage::write_pos_params; use namada_state::testing::TestWlStorage; - use namada_storage::StorageRead; - use namada_vote_ext::bridge_pool_roots; use super::*; use crate::protocol::transactions::votes::{ diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs index 1cd2144eec..92c0102689 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/events.rs @@ -585,7 +585,6 @@ mod tests { use std::collections::HashMap; use assert_matches::assert_matches; - use eyre::Result; use namada_core::borsh::BorshSerializeExt; use namada_core::types::address::testing::gen_implicit_address; use namada_core::types::address::{gen_established_address, nam, wnam}; @@ -923,7 +922,7 @@ mod tests { let receiver_balance_key = balance_key(&wdai, &receiver); let wdai_supply_key = minted_balance_key(&wdai); - for key in vec![receiver_balance_key, wdai_supply_key] { + for key in [receiver_balance_key, wdai_supply_key] { let value: Option = wl_storage.read(&key).unwrap(); if expected_amount.is_zero() { diff --git a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs index b9b2fe2731..44ab44a51e 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/ethereum_events/mod.rs @@ -31,7 +31,7 @@ impl utils::GetVoters for &HashSet { #[inline] fn get_voters(self) -> HashSet<(Address, BlockHeight)> { self.iter().fold(HashSet::new(), |mut voters, update| { - voters.extend(update.seen_by.clone().into_iter()); + voters.extend(update.seen_by.clone()); voters }) } @@ -334,17 +334,12 @@ where #[cfg(test)] mod tests { - use std::collections::{BTreeSet, HashMap, HashSet}; - - use borsh::BorshDeserialize; use namada_core::types::address; use namada_core::types::ethereum_events::testing::{ arbitrary_amount, arbitrary_eth_address, arbitrary_nonce, arbitrary_single_transfer, DAI_ERC20_ETH_ADDRESS, }; - use namada_core::types::ethereum_events::{ - EthereumEvent, TransferToNamada, - }; + use namada_core::types::ethereum_events::TransferToNamada; use namada_core::types::voting_power::FractionalVotingPower; use namada_state::testing::TestWlStorage; use namada_storage::mockdb::MockDBWriteBatch; diff --git a/crates/ethereum_bridge/src/protocol/transactions/update.rs b/crates/ethereum_bridge/src/protocol/transactions/update.rs index ee258774a2..f721b01d21 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/update.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/update.rs @@ -42,10 +42,9 @@ where #[cfg(test)] mod tests { - use eyre::{eyre, Result}; - use namada_core::types::storage; + use eyre::eyre; use namada_state::testing::TestWlStorage; - use namada_storage::{StorageRead, StorageWrite}; + use namada_storage::StorageRead; use super::*; diff --git a/crates/ethereum_bridge/src/protocol/transactions/utils.rs b/crates/ethereum_bridge/src/protocol/transactions/utils.rs index 63eaf8530e..a836ed3b9f 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/utils.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/utils.rs @@ -120,8 +120,6 @@ pub(super) fn get_voting_powers_for_selected( #[cfg(test)] mod tests { - use std::collections::HashSet; - use assert_matches::assert_matches; use namada_core::types::address; use namada_core::types::ethereum_events::testing::arbitrary_bonded_stake; diff --git a/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs b/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs index 1adcf3d09b..cc1580600b 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/validator_set_update/mod.rs @@ -134,7 +134,9 @@ where }; let valset_upd_keys = vote_tallies::Keys::from(&next_epoch); let maybe_proof = 'check_storage: { - let Some(seen) = votes::storage::maybe_read_seen(wl_storage, &valset_upd_keys)? else { + let Some(seen) = + votes::storage::maybe_read_seen(wl_storage, &valset_upd_keys)? + else { break 'check_storage None; }; if seen { diff --git a/crates/ethereum_bridge/src/protocol/transactions/votes.rs b/crates/ethereum_bridge/src/protocol/transactions/votes.rs index 7accb41f66..dde0f0905d 100644 --- a/crates/ethereum_bridge/src/protocol/transactions/votes.rs +++ b/crates/ethereum_bridge/src/protocol/transactions/votes.rs @@ -57,7 +57,8 @@ pub trait EpochedVotingPowerExt { D: 'static + DB + for<'iter> DBIter<'iter> + Sync, H: 'static + StorageHasher + Sync, { - let Some(max_voting_power) = self.epoch_max_voting_power(wl_storage) else { + let Some(max_voting_power) = self.epoch_max_voting_power(wl_storage) + else { return FractionalVotingPower::NULL; }; FractionalVotingPower::new( @@ -75,7 +76,8 @@ pub trait EpochedVotingPowerExt { D: 'static + DB + for<'iter> DBIter<'iter> + Sync, H: 'static + StorageHasher + Sync, { - let Some(max_voting_power) = self.epoch_max_voting_power(wl_storage) else { + let Some(max_voting_power) = self.epoch_max_voting_power(wl_storage) + else { return false; }; // NB: Preserve the safety property of the Tendermint protocol across @@ -185,10 +187,7 @@ pub fn dedupe(signers: BTreeSet<(Address, BlockHeight)>) -> Votes { #[cfg(test)] mod tests { - use std::collections::BTreeSet; - - use namada_core::types::storage::BlockHeight; - use namada_core::types::{address, token}; + use namada_core::types::address; use namada_proof_of_stake::parameters::OwnedPosParams; use namada_proof_of_stake::storage::write_pos_params; diff --git a/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs b/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs index 44b38a751a..d50d16b668 100644 --- a/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs +++ b/crates/ethereum_bridge/src/storage/eth_bridge_queries.rs @@ -110,9 +110,7 @@ pub struct EthBridgeQueriesHook<'db, DB> { impl<'db, DB> Clone for EthBridgeQueriesHook<'db, DB> { fn clone(&self) -> Self { - Self { - wl_storage: self.wl_storage, - } + *self } } @@ -481,8 +479,8 @@ where /// NUTs are minted when: /// /// 1. `token` is not whitelisted. - /// 2. `token` has exceeded the configured token caps, - /// after minting `amount_to_mint`. + /// 2. `token` has exceeded the configured token caps, after minting + /// `amount_to_mint`. pub fn get_eth_assets_to_mint( self, token: &EthAddress, diff --git a/crates/ethereum_bridge/src/storage/mod.rs b/crates/ethereum_bridge/src/storage/mod.rs index 96c2b8dd84..d0f6ce200d 100644 --- a/crates/ethereum_bridge/src/storage/mod.rs +++ b/crates/ethereum_bridge/src/storage/mod.rs @@ -45,7 +45,7 @@ pub fn has_eth_addr_segment(key: &Key) -> bool { /// Returns whether a key belongs to this account or not pub fn is_eth_bridge_key(nam_addr: &Address, key: &Key) -> bool { key == &escrow_key(nam_addr) - || matches!(key.segments.get(0), Some(first_segment) if first_segment == &ADDRESS.to_db_key()) + || matches!(key.segments.first(), Some(first_segment) if first_segment == &ADDRESS.to_db_key()) || wrapped_erc20s::has_erc20_segment(key) } diff --git a/crates/ethereum_bridge/src/storage/parameters.rs b/crates/ethereum_bridge/src/storage/parameters.rs index ead8b612f4..2af633d77a 100644 --- a/crates/ethereum_bridge/src/storage/parameters.rs +++ b/crates/ethereum_bridge/src/storage/parameters.rs @@ -363,8 +363,6 @@ where #[cfg(test)] mod tests { - use eyre::Result; - use namada_core::types::ethereum_events::EthAddress; use namada_state::testing::TestWlStorage; use super::*; diff --git a/crates/ethereum_bridge/src/storage/vote_tallies.rs b/crates/ethereum_bridge/src/storage/vote_tallies.rs index 354edb9958..5bfde6003f 100644 --- a/crates/ethereum_bridge/src/storage/vote_tallies.rs +++ b/crates/ethereum_bridge/src/storage/vote_tallies.rs @@ -284,7 +284,7 @@ mod test { fn test_ethereum_event_keys_all_keys() { let (event, hash) = helpers::arbitrary_event_with_hash(); let keys: Keys = (&event).into(); - let prefix = vec![ + let prefix = [ DbKeySeg::AddressSeg(ADDRESS), DbKeySeg::StringSeg(ETH_MSGS_PREFIX_KEY_SEGMENT.to_owned()), DbKeySeg::StringSeg(hash), @@ -339,7 +339,7 @@ mod test { fn test_ethereum_event_keys_from_ethereum_event() { let (event, hash) = helpers::arbitrary_event_with_hash(); let keys: Keys = (&event).into(); - let expected = vec![ + let expected = [ DbKeySeg::AddressSeg(ADDRESS), DbKeySeg::StringSeg(ETH_MSGS_PREFIX_KEY_SEGMENT.to_owned()), DbKeySeg::StringSeg(hash), @@ -351,7 +351,7 @@ mod test { fn test_ethereum_event_keys_from_hash() { let (event, hash) = helpers::arbitrary_event_with_hash(); let keys: Keys = (&event.hash().unwrap()).into(); - let expected = vec![ + let expected = [ DbKeySeg::AddressSeg(ADDRESS), DbKeySeg::StringSeg(ETH_MSGS_PREFIX_KEY_SEGMENT.to_owned()), DbKeySeg::StringSeg(hash), diff --git a/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs b/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs index 4976caea8f..7feaae5eee 100644 --- a/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs +++ b/crates/ethereum_bridge/src/storage/wrapped_erc20s.rs @@ -106,13 +106,11 @@ impl TryFrom<(&Address, &storage::Key)> for Key { #[cfg(test)] mod test { - use std::result::Result; use std::str::FromStr; use assert_matches::assert_matches; - use namada_core::types::address::{nam, Address}; + use namada_core::types::address::nam; use namada_core::types::ethereum_events::testing::DAI_ERC20_ETH_ADDRESS; - use namada_core::types::storage::DbKeySeg; use super::*; use crate::token::storage_key::BALANCE_STORAGE_KEY; diff --git a/crates/ibc/src/context/common.rs b/crates/ibc/src/context/common.rs index b5b761bd86..ac322392f9 100644 --- a/crates/ibc/src/context/common.rs +++ b/crates/ibc/src/context/common.rs @@ -288,10 +288,7 @@ pub trait IbcCommonContext: IbcStorageContext { .time .try_into() .expect("The time should be converted"); - let next_validators_hash = header - .next_validators_hash - .try_into() - .expect("The hash should be converted"); + let next_validators_hash = header.next_validators_hash.into(); let consensus_state: TmConsensusState = TmConsensusStateType::new( commitment_root, time, diff --git a/crates/light_sdk/src/reading/asynchronous/pos.rs b/crates/light_sdk/src/reading/asynchronous/pos.rs index 9c28beb957..cf83c627bc 100644 --- a/crates/light_sdk/src/reading/asynchronous/pos.rs +++ b/crates/light_sdk/src/reading/asynchronous/pos.rs @@ -5,7 +5,6 @@ use namada_sdk::proof_of_stake::types::{ }; use namada_sdk::proof_of_stake::PosParams; use namada_sdk::queries::vp::pos::EnrichedBondsAndUnbondsDetails; -use namada_sdk::types::address::Address; use namada_sdk::types::key::common; use namada_sdk::types::storage::{BlockHeight, Epoch}; diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index c3af2fd82f..b41d5240e0 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -300,7 +300,7 @@ fn derive_storage_keys_inner(struct_def: TokenStream2) -> TokenStream2 { quote! { impl #struct_def_ident { /// A list of all storage keys - pub const ALL: &[&'static str] = { + pub const ALL: &'static [&'static str] = { let #struct_def_ident { #ident_list } = Self::VALUES; @@ -520,7 +520,7 @@ mod test_proc_macros { let expected_impl = quote! { impl Keys { /// A list of all storage keys - pub const ALL: &[&'static str] = { + pub const ALL: &'static [&'static str] = { let Keys { param1, param2 } = Self::VALUES; &[param1, param2] }; diff --git a/crates/merkle_tree/src/lib.rs b/crates/merkle_tree/src/lib.rs index eb55878a82..cc4e43e47c 100644 --- a/crates/merkle_tree/src/lib.rs +++ b/crates/merkle_tree/src/lib.rs @@ -257,7 +257,7 @@ impl StoreType { if key.is_empty() { return Err(Error::EmptyKey("the key is empty".to_owned())); } - match key.segments.get(0) { + match key.segments.first() { Some(DbKeySeg::AddressSeg(Address::Internal(internal))) => { match internal { InternalAddress::PoS | InternalAddress::PosSlashPool => { @@ -1005,7 +1005,6 @@ impl<'a> SubTreeWrite for &'a mut BridgePoolTree { mod test { use ics23::HostFunctionsManager; use namada_core::types::hash::Sha256Hasher; - use namada_core::types::storage::KeySeg; use super::*; use crate::ics23_specs::{ibc_proof_specs, proof_specs}; @@ -1150,7 +1149,7 @@ mod test { }; let proof = tree.get_sub_tree_proof(&ibc_key, proof).unwrap(); let (store_type, sub_key) = StoreType::sub_key(&ibc_key).unwrap(); - let paths = vec![sub_key.to_string(), store_type.to_string()]; + let paths = [sub_key.to_string(), store_type.to_string()]; let mut sub_root = ibc_val.clone(); let mut value = ibc_val; // First, the sub proof is verified. Next the base proof is verified @@ -1214,7 +1213,7 @@ mod test { let proof = tree.get_sub_tree_proof(&pos_key, proof).unwrap(); let (store_type, sub_key) = StoreType::sub_key(&pos_key).unwrap(); - let paths = vec![sub_key.to_string(), store_type.to_string()]; + let paths = [sub_key.to_string(), store_type.to_string()]; let mut sub_root = pos_val.clone(); let mut value = pos_val; // First, the sub proof is verified. Next the base proof is verified diff --git a/crates/namada/src/ledger/mod.rs b/crates/namada/src/ledger/mod.rs index 5f54de80f2..a5bc9f7271 100644 --- a/crates/namada/src/ledger/mod.rs +++ b/crates/namada/src/ledger/mod.rs @@ -141,7 +141,7 @@ mod test { use namada_sdk::queries::{ EncodedResponseQuery, RequestCtx, RequestQuery, Router, RPC, }; - use namada_sdk::tendermint_rpc::{self, Error as RpcError, Response}; + use namada_sdk::tendermint_rpc::{Error as RpcError, Response}; use namada_state::testing::TestWlStorage; use namada_state::StorageWrite; use namada_test_utils::TestWasms; diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs index 19e99a7475..43856f2d76 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/bridge_pool_vp.rs @@ -641,7 +641,6 @@ where mod test_bridge_pool_vp { use std::env::temp_dir; - use borsh::BorshDeserialize; use namada_core::borsh::BorshSerializeExt; use namada_core::types::address; use namada_ethereum_bridge::storage::bridge_pool::get_signed_root_key; @@ -658,7 +657,7 @@ mod test_bridge_pool_vp { use crate::state::mockdb::MockDB; use crate::state::write_log::WriteLog; use crate::state::{Sha256Hasher, State, WlStorage}; - use crate::types::address::{nam, wnam, InternalAddress}; + use crate::types::address::{nam, wnam}; use crate::types::chain::ChainId; use crate::types::eth_bridge_pool::{GasFee, TransferToEthereum}; use crate::types::hash::Hash; diff --git a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs index b72fe7d13f..c92236742d 100644 --- a/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs +++ b/crates/namada/src/ledger/native_vp/ethereum_bridge/vp.rs @@ -5,7 +5,6 @@ use eyre::{eyre, Result}; use namada_core::types::address::Address; use namada_core::types::hash::StorageHasher; use namada_core::types::storage::Key; -use namada_ethereum_bridge; use namada_ethereum_bridge::storage; use namada_ethereum_bridge::storage::escrow_key; use namada_tx::Tx; @@ -165,14 +164,12 @@ fn validate_changed_keys( #[cfg(test)] mod tests { - use std::default::Default; use std::env::temp_dir; use namada_core::borsh::BorshSerializeExt; use namada_gas::TxGasMeter; use namada_state::StorageWrite; use namada_tx::data::TxType; - use namada_tx::Tx; use rand::Rng; use super::*; diff --git a/crates/namada/src/ledger/native_vp/ibc/mod.rs b/crates/namada/src/ledger/native_vp/ibc/mod.rs index 7774c41cf1..572597d6df 100644 --- a/crates/namada/src/ledger/native_vp/ibc/mod.rs +++ b/crates/namada/src/ledger/native_vp/ibc/mod.rs @@ -306,8 +306,6 @@ pub fn get_dummy_genesis_validator() #[cfg(test)] mod tests { - use core::time::Duration; - use std::convert::TryFrom; use std::str::FromStr; use borsh::BorshDeserialize; @@ -322,7 +320,7 @@ mod tests { use namada_state::testing::TestWlStorage; use namada_state::StorageRead; use namada_tx::data::TxType; - use namada_tx::{Code, Data, Section, Signature, Tx}; + use namada_tx::{Code, Data, Section, Signature}; use prost::Message; use sha2::Digest; @@ -391,12 +389,12 @@ mod tests { use crate::ibc::primitives::proto::{Any, Protobuf}; use crate::ibc::primitives::{Msg, Timestamp}; use crate::ibc::storage::{ - ack_key, calc_hash, channel_counter_key, channel_key, - client_connections_key, client_counter_key, client_state_key, - client_update_height_key, client_update_timestamp_key, commitment_key, - connection_counter_key, connection_key, consensus_state_key, - ibc_denom_key, next_sequence_ack_key, next_sequence_recv_key, - next_sequence_send_key, receipt_key, + ack_key, channel_counter_key, channel_key, client_connections_key, + client_counter_key, client_state_key, client_update_height_key, + client_update_timestamp_key, commitment_key, connection_counter_key, + connection_key, consensus_state_key, ibc_denom_key, + next_sequence_ack_key, next_sequence_recv_key, next_sequence_send_key, + receipt_key, }; use crate::ledger::gas::VpGasMeter; use crate::ledger::parameters::storage::{ diff --git a/crates/namada/src/ledger/native_vp/mod.rs b/crates/namada/src/ledger/native_vp/mod.rs index 6692a514b8..e9e4ad60ea 100644 --- a/crates/namada/src/ledger/native_vp/mod.rs +++ b/crates/namada/src/ledger/native_vp/mod.rs @@ -694,8 +694,6 @@ where pub(super) mod testing { use std::collections::HashMap; - use borsh::BorshDeserialize; - use super::*; #[derive(Debug, Default)] diff --git a/crates/namada/src/ledger/native_vp/multitoken.rs b/crates/namada/src/ledger/native_vp/multitoken.rs index 8999855ece..13e8beacd0 100644 --- a/crates/namada/src/ledger/native_vp/multitoken.rs +++ b/crates/namada/src/ledger/native_vp/multitoken.rs @@ -128,7 +128,7 @@ where } } else if is_any_token_parameter_key(key).is_some() { return self.is_valid_parameter(tx_data); - } else if key.segments.get(0) + } else if key.segments.first() == Some( &Address::Internal(InternalAddress::Multitoken).to_db_key(), ) @@ -214,13 +214,12 @@ where #[cfg(test)] mod tests { - use std::collections::BTreeSet; use borsh_ext::BorshSerializeExt; use namada_gas::TxGasMeter; use namada_state::testing::TestWlStorage; use namada_tx::data::TxType; - use namada_tx::{Code, Data, Section, Signature, Tx}; + use namada_tx::{Code, Data, Section, Signature}; use super::*; use crate::core::types::address::nam; @@ -229,11 +228,7 @@ mod tests { }; use crate::ledger::gas::VpGasMeter; use crate::ledger::ibc::storage::ibc_token; - use crate::token::storage_key::{ - balance_key, minted_balance_key, minter_key, - }; - use crate::token::Amount; - use crate::types::address::{Address, InternalAddress}; + use crate::token::storage_key::{balance_key, minted_balance_key}; use crate::types::key::testing::keypair_1; use crate::types::storage::TxIndex; use crate::vm::wasm::compilation_cache::common::testing::cache as wasm_cache; diff --git a/crates/namada/src/ledger/pos/mod.rs b/crates/namada/src/ledger/pos/mod.rs index a7e8fa0d22..ccdb66fef3 100644 --- a/crates/namada/src/ledger/pos/mod.rs +++ b/crates/namada/src/ledger/pos/mod.rs @@ -2,8 +2,6 @@ pub mod vp; -use std::convert::TryFrom; - use namada_core::types::address; pub use namada_core::types::dec::Dec; pub use namada_core::types::key::common; diff --git a/crates/namada/src/ledger/pos/vp.rs b/crates/namada/src/ledger/pos/vp.rs index 69ec002654..0cd5359691 100644 --- a/crates/namada/src/ledger/pos/vp.rs +++ b/crates/namada/src/ledger/pos/vp.rs @@ -95,7 +95,7 @@ where { return Ok(false); } - } else if key.segments.get(0) == Some(&addr.to_db_key()) { + } else if key.segments.first() == Some(&addr.to_db_key()) { // Unknown changes to this address space are disallowed // tracing::info!("PoS unrecognized key change {} rejected", // key); diff --git a/crates/namada/src/ledger/protocol/mod.rs b/crates/namada/src/ledger/protocol/mod.rs index 9ffa91b6c9..0148c992f2 100644 --- a/crates/namada/src/ledger/protocol/mod.rs +++ b/crates/namada/src/ledger/protocol/mod.rs @@ -683,9 +683,9 @@ where use namada_vote_ext::{ethereum_events, validator_set_update}; let Some(data) = data else { - return Err(Error::ProtocolTxError( - eyre!("Protocol tx data must be present")), - ); + return Err(Error::ProtocolTxError(eyre!( + "Protocol tx data must be present" + ))); }; let ethereum_tx_data = EthereumTxData::deserialize(&tx, &data) .wrap_err_with(|| { @@ -1167,8 +1167,6 @@ mod tests { use namada_ethereum_bridge::storage::proof::EthereumProof; use namada_ethereum_bridge::storage::{vote_tallies, vp}; use namada_ethereum_bridge::test_utils; - use namada_state::StorageRead; - use namada_token::Amount; use namada_tx::{SignableEthMessage, Signed}; use namada_vote_ext::bridge_pool_roots::BridgePoolRootVext; use namada_vote_ext::ethereum_events::EthereumEventsVext; diff --git a/crates/namada/src/vm/host_env.rs b/crates/namada/src/vm/host_env.rs index 21cc2885e8..735166a72e 100644 --- a/crates/namada/src/vm/host_env.rs +++ b/crates/namada/src/vm/host_env.rs @@ -1,7 +1,6 @@ //! Virtual machine's host environment exposes functions that may be called from //! within a virtual machine. use std::collections::BTreeSet; -use std::convert::TryInto; use std::num::TryFromIntError; use borsh::BorshDeserialize; @@ -2733,10 +2732,6 @@ where /// A helper module for testing #[cfg(feature = "testing")] pub mod testing { - use std::collections::BTreeSet; - - use namada_state::StorageHasher; - use super::*; use crate::vm::memory::testing::NativeMemory; use crate::vm::wasm::memory::WasmMemory; diff --git a/crates/namada/src/vm/types.rs b/crates/namada/src/vm/types.rs index 54cc170371..28d3232f5d 100644 --- a/crates/namada/src/vm/types.rs +++ b/crates/namada/src/vm/types.rs @@ -2,12 +2,10 @@ //! memory. //! //! These are either: -//! 1. Module call types -//! The module call inputs are passed host-to-guest. +//! 1. Module call types The module call inputs are passed host-to-guest. //! -//! 2. Execution environment types -//! The environment inputs are passed guest-to-host and outputs back from -//! host-to-guest. +//! 2. Execution environment types The environment inputs are passed +//! guest-to-host and outputs back from host-to-guest. use std::collections::BTreeSet; diff --git a/crates/namada/src/vm/wasm/memory.rs b/crates/namada/src/vm/wasm/memory.rs index 35923e512b..671af064d3 100644 --- a/crates/namada/src/vm/wasm/memory.rs +++ b/crates/namada/src/vm/wasm/memory.rs @@ -453,9 +453,7 @@ impl Tunables for Limit { #[cfg(test)] pub mod tests { - use wasmer::{ - wat2wasm, BaseTunables, Cranelift, Instance, Module, Store, Target, - }; + use wasmer::{wat2wasm, Cranelift, Instance, Module, Store}; use super::*; diff --git a/crates/namada/src/vm/wasm/run.rs b/crates/namada/src/vm/wasm/run.rs index 8d84185135..986da55c81 100644 --- a/crates/namada/src/vm/wasm/run.rs +++ b/crates/namada/src/vm/wasm/run.rs @@ -643,7 +643,6 @@ mod tests { use super::*; use crate::state::testing::TestStorage; use crate::tx::data::eval_vp::EvalVp; - use crate::types::hash::Hash; use crate::vm::host_env::TxRuntimeError; use crate::vm::wasm; @@ -698,7 +697,8 @@ mod tests { let downcasted_tx_rt_err: &TxRuntimeError = source_err .downcast_ref() .unwrap_or_else(|| panic!("{assert_msg}: {source_err}")); - let TxRuntimeError::MemoryError(tx_mem_err) = downcasted_tx_rt_err else { + let TxRuntimeError::MemoryError(tx_mem_err) = downcasted_tx_rt_err + else { panic!("{assert_msg}: {downcasted_tx_rt_err}"); }; tx_mem_err diff --git a/crates/parameters/src/lib.rs b/crates/parameters/src/lib.rs index 8fd77ad58f..2f56acb9ee 100644 --- a/crates/parameters/src/lib.rs +++ b/crates/parameters/src/lib.rs @@ -11,7 +11,7 @@ pub use namada_core::types::parameters::*; use namada_core::types::storage::Key; use namada_core::types::time::DurationSecs; use namada_core::types::token; -use namada_storage::{self, ResultExt, StorageRead, StorageWrite}; +use namada_storage::{ResultExt, StorageRead, StorageWrite}; pub use storage::get_max_block_gas; use thiserror::Error; pub use wasm_allowlist::{is_tx_allowed, is_vp_allowed}; diff --git a/crates/proof_of_stake/src/epoched.rs b/crates/proof_of_stake/src/epoched.rs index 5db83af399..2838472b5d 100644 --- a/crates/proof_of_stake/src/epoched.rs +++ b/crates/proof_of_stake/src/epoched.rs @@ -8,7 +8,6 @@ use std::{cmp, ops}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use namada_core::types::storage::{self, Epoch}; -use namada_storage; use namada_storage::collections::lazy_map::{LazyMap, NestedMap}; use namada_storage::collections::{self, LazyCollection}; use namada_storage::{StorageRead, StorageWrite}; diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index 6fb618db4f..aa09217878 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -312,8 +312,7 @@ where consensus_validator_set_handle() .at(&epoch) .iter(storage)? - .fold(Ok(token::Amount::zero()), |acc, entry| { - let acc = acc?; + .try_fold(token::Amount::zero(), |acc, entry| { let ( lazy_map::NestedSubKey::Data { key: amount, @@ -2484,13 +2483,9 @@ where #[cfg(any(test, feature = "testing"))] /// PoS related utility functions to help set up tests. pub mod test_utils { - use namada_storage; - use namada_storage::{StorageRead, StorageWrite}; use namada_trans_token::credit_tokens; use super::*; - use crate::parameters::PosParams; - use crate::storage::read_non_pos_owned_params; use crate::types::GenesisValidator; /// Helper function to initialize storage with PoS data diff --git a/crates/proof_of_stake/src/parameters.rs b/crates/proof_of_stake/src/parameters.rs index 6062f11a5b..e466c4b7fc 100644 --- a/crates/proof_of_stake/src/parameters.rs +++ b/crates/proof_of_stake/src/parameters.rs @@ -297,7 +297,6 @@ mod tests { /// Testing helpers #[cfg(any(test, feature = "testing"))] pub mod testing { - use namada_core::types::dec::Dec; use proptest::prelude::*; use super::*; diff --git a/crates/proof_of_stake/src/pos_queries.rs b/crates/proof_of_stake/src/pos_queries.rs index f76d4c6ed8..76f942f22f 100644 --- a/crates/proof_of_stake/src/pos_queries.rs +++ b/crates/proof_of_stake/src/pos_queries.rs @@ -82,9 +82,7 @@ pub struct PosQueriesHook<'db, S> { impl<'db, S> Clone for PosQueriesHook<'db, S> { fn clone(&self) -> Self { - Self { - storage: self.storage, - } + *self } } diff --git a/crates/proof_of_stake/src/queries.rs b/crates/proof_of_stake/src/queries.rs index 0b98810cba..8982d4fcf3 100644 --- a/crates/proof_of_stake/src/queries.rs +++ b/crates/proof_of_stake/src/queries.rs @@ -9,7 +9,7 @@ use namada_core::types::dec::Dec; use namada_core::types::storage::Epoch; use namada_core::types::token; use namada_storage::collections::lazy_map::{NestedSubKey, SubKey}; -use namada_storage::{self, StorageRead}; +use namada_storage::StorageRead; use crate::slashing::{find_validator_slashes, get_slashed_amount}; use crate::storage::{bond_handle, read_pos_params, unbond_handle}; diff --git a/crates/proof_of_stake/src/slashing.rs b/crates/proof_of_stake/src/slashing.rs index 3d7361c3cf..278674d13e 100644 --- a/crates/proof_of_stake/src/slashing.rs +++ b/crates/proof_of_stake/src/slashing.rs @@ -1101,10 +1101,8 @@ where ); let processing_epoch = epoch + params.slash_processing_epoch_offset(); let slashes = enqueued_slashes_handle().at(&processing_epoch); - let infracting_stake = slashes.iter(storage)?.fold( - Ok(Dec::zero()), - |acc: namada_storage::Result, res| { - let acc = acc?; + let infracting_stake = + slashes.iter(storage)?.try_fold(Dec::zero(), |acc, res| { let ( NestedSubKey::Data { key: validator, @@ -1118,9 +1116,10 @@ where // tracing::debug!("Val {} stake: {}", &validator, // validator_stake); - Ok(acc + Dec::from(validator_stake)) - }, - )?; + Ok::( + acc + Dec::from(validator_stake), + ) + })?; sum_vp_fraction += infracting_stake / consensus_stake; } let cubic_rate = diff --git a/crates/proof_of_stake/src/storage_key.rs b/crates/proof_of_stake/src/storage_key.rs index 6135468a95..0579ed016d 100644 --- a/crates/proof_of_stake/src/storage_key.rs +++ b/crates/proof_of_stake/src/storage_key.rs @@ -61,7 +61,7 @@ const LIVENESS_MISSED_VOTES_SUM: &str = "sum_missed_votes"; /// Is the given key a PoS storage key? pub fn is_pos_key(key: &Key) -> bool { - match &key.segments.get(0) { + match &key.segments.first() { Some(DbKeySeg::AddressSeg(addr)) => addr == &ADDRESS, _ => false, } diff --git a/crates/proof_of_stake/src/tests/state_machine_v2.rs b/crates/proof_of_stake/src/tests/state_machine_v2.rs index 872625f9d5..40ae3e0712 100644 --- a/crates/proof_of_stake/src/tests/state_machine_v2.rs +++ b/crates/proof_of_stake/src/tests/state_machine_v2.rs @@ -529,7 +529,7 @@ impl AbstractPosState { !is_withdrawable }) } - records.withdrawn.extend(to_store.into_iter()); + records.withdrawn.extend(to_store); } /// Get or insert default mutable records diff --git a/crates/proof_of_stake/src/types/mod.rs b/crates/proof_of_stake/src/types/mod.rs index b2a0d176ad..00551e16e3 100644 --- a/crates/proof_of_stake/src/types/mod.rs +++ b/crates/proof_of_stake/src/types/mod.rs @@ -4,7 +4,6 @@ mod rev_order; use core::fmt::Debug; use std::collections::{BTreeMap, HashMap}; -use std::convert::TryFrom; use std::fmt::Display; use std::hash::Hash; use std::ops::Sub; diff --git a/crates/sdk/src/eth_bridge/bridge_pool.rs b/crates/sdk/src/eth_bridge/bridge_pool.rs index c8aeb0bb92..f32ba85298 100644 --- a/crates/sdk/src/eth_bridge/bridge_pool.rs +++ b/crates/sdk/src/eth_bridge/bridge_pool.rs @@ -747,6 +747,7 @@ mod recommendations { use namada_core::types::ethereum_events::Uint as EthUint; use namada_core::types::storage::BlockHeight; use namada_core::types::uint::{self, Uint, I256}; + use namada_ethereum_bridge::storage::proof::BridgePoolRootProof; use namada_vote_ext::validator_set_update::{ EthAddrBook, VotingPowersMap, VotingPowersMapExt, }; @@ -756,8 +757,6 @@ mod recommendations { use crate::eth_bridge::storage::bridge_pool::{ get_nonce_key, get_signed_root_key, }; - use crate::eth_bridge::storage::proof::BridgePoolRootProof; - use crate::io::Io; const fn unsigned_transfer_fee() -> Uint { Uint::from_u64(37_500_u64) @@ -1220,7 +1219,6 @@ mod recommendations { #[cfg(test)] mod test_recommendations { - use namada_core::types::address::Address; use super::*; use crate::io::StdIo; @@ -1347,8 +1345,7 @@ mod recommendations { ctx.expected_eligible.push(EligibleRecommendation { transfer_hash: ctx.pending.keccak256().to_string(), cost: transfer_fee() - - I256::try_from(ctx.pending.gas_fee.amount) - .expect("Test failed"), + - I256::from(ctx.pending.gas_fee.amount), pending_transfer: ctx.pending.clone(), }); }); @@ -1591,8 +1588,7 @@ mod recommendations { transfer_hash: pending.keccak256().to_string(), cost: transfer_fee() - I256::from((1e9 / rate).floor() as u64) - * I256::try_from(pending.gas_fee.amount) - .expect("Test failed"), + * I256::from(pending.gas_fee.amount), pending_transfer: pending, }); } diff --git a/crates/sdk/src/eth_bridge/mod.rs b/crates/sdk/src/eth_bridge/mod.rs index 9107798938..0ff13a97a7 100644 --- a/crates/sdk/src/eth_bridge/mod.rs +++ b/crates/sdk/src/eth_bridge/mod.rs @@ -74,10 +74,7 @@ where .timeout(deadline, || async { let fut_syncing = client.syncing(); let fut_block_num = client.get_block_number(); - let Ok(status) = futures::try_join!( - fut_syncing, - fut_block_num, - ) else { + let Ok(status) = futures::try_join!(fut_syncing, fut_block_num,) else { return ControlFlow::Continue(()); }; ControlFlow::Break(match status { diff --git a/crates/sdk/src/eth_bridge/validator_set.rs b/crates/sdk/src/eth_bridge/validator_set.rs index c11b9b62c6..0c95600a46 100644 --- a/crates/sdk/src/eth_bridge/validator_set.rs +++ b/crates/sdk/src/eth_bridge/validator_set.rs @@ -598,25 +598,30 @@ where // update epoch in the contract args.epoch = Some(new_epoch); - let result = relay_validator_set_update_once::( - &args, - Arc::clone(ð_client), - client, - |transf_result| { - let Some(receipt) = transf_result else { - tracing::warn!("No transfer receipt received from the Ethereum node"); - last_call_succeeded = false; - return; - }; - last_call_succeeded = receipt.is_successful(); - if last_call_succeeded { - tracing::info!(?receipt, "Ethereum transfer succeeded"); - tracing::info!(?new_epoch, "Updated the validator set"); - } else { - tracing::error!(?receipt, "Ethereum transfer failed"); - } - }, - ).await; + let result = + relay_validator_set_update_once::( + &args, + Arc::clone(ð_client), + client, + |transf_result| { + let Some(receipt) = transf_result else { + tracing::warn!( + "No transfer receipt received from the Ethereum \ + node" + ); + last_call_succeeded = false; + return; + }; + last_call_succeeded = receipt.is_successful(); + if last_call_succeeded { + tracing::info!(?receipt, "Ethereum transfer succeeded"); + tracing::info!(?new_epoch, "Updated the validator set"); + } else { + tracing::error!(?receipt, "Ethereum transfer failed"); + } + }, + ) + .await; if let Err(err) = result { // only print errors, do not exit diff --git a/crates/sdk/src/events/log.rs b/crates/sdk/src/events/log.rs index 596c23bdc9..f77ec73e40 100644 --- a/crates/sdk/src/events/log.rs +++ b/crates/sdk/src/events/log.rs @@ -3,9 +3,6 @@ //! The log can only hold `N` events at a time, where `N` is a configurable //! parameter. If the log is holding `N` events, and a new event is logged, //! old events are pruned. - -use std::default::Default; - use circular_queue::CircularQueue; use crate::events::Event; diff --git a/crates/sdk/src/events/mod.rs b/crates/sdk/src/events/mod.rs index 646fd1b8d3..769c43317f 100644 --- a/crates/sdk/src/events/mod.rs +++ b/crates/sdk/src/events/mod.rs @@ -2,7 +2,6 @@ pub mod log; use std::collections::HashMap; -use std::convert::TryFrom; use std::fmt::{self, Display}; use std::ops::{Index, IndexMut}; use std::str::FromStr; diff --git a/crates/sdk/src/lib.rs b/crates/sdk/src/lib.rs index 9c49ffb0af..ce1d4b9281 100644 --- a/crates/sdk/src/lib.rs +++ b/crates/sdk/src/lib.rs @@ -231,15 +231,15 @@ pub trait Namada: Sized + MaybeSync + MaybeSend { ) -> args::Redelegate { args::Redelegate { tx: self.tx_builder(), - /// Source validator address + // Source validator address src_validator, - /// Destination validator address + // Destination validator address dest_validator, - /// Owner of the bonds that are being redelegated + // Owner of the bonds that are being redelegated owner: source, - /// The amount of tokens to redelegate + // The amount of tokens to redelegate amount, - /// Path to the TX WASM code file + // Path to the TX WASM code file tx_code_path: PathBuf::from(TX_REDELEGATE_WASM), } } diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index 1f6d284705..8054e8b65e 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -1325,7 +1325,7 @@ impl ShieldedContext { let Some(denom) = query_denom(client, token).await else { return Err(Error::Query(QueryError::General(format!( "denomination for token {token}" - )))) + )))); }; for position in MaspDigitPos::iter() { let asset_type = @@ -1392,7 +1392,10 @@ impl ShieldedContext { { // Query for the ID of the last accepted transaction let Some((token, denom, position, ep, conv, path)) = - query_conversion(client, asset_type).await else { return }; + query_conversion(client, asset_type).await + else { + return; + }; self.asset_types.insert( asset_type, AssetData { @@ -2051,9 +2054,9 @@ impl ShieldedContext { // Convert transaction amount into MASP types let Some(denom) = query_denom(context.client(), token).await else { - return Err(TransferErr::General(Error::from(QueryError::General(format!( - "denomination for token {token}" - ))))) + return Err(TransferErr::General(Error::from( + QueryError::General(format!("denomination for token {token}")), + ))); }; let (asset_types, masp_amount) = { let mut shielded = context.shielded_mut().await; @@ -2985,18 +2988,13 @@ pub mod testing { use std::ops::AddAssign; use std::sync::Mutex; - use masp_primitives::asset_type::AssetType; use masp_primitives::consensus::testing::arb_height; use masp_primitives::constants::SPENDING_KEY_GENERATOR; - use masp_primitives::convert::AllowedConversion; use masp_primitives::ff::Field; - use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::prover::TxProver; - use masp_primitives::sapling::redjubjub::{PublicKey, Signature}; - use masp_primitives::sapling::{ - Diversifier, Node, PaymentAddress, ProofGenerationKey, Rseed, - }; - use masp_primitives::transaction::components::{I128Sum, GROTH_PROOF_SIZE}; + use masp_primitives::sapling::redjubjub::Signature; + use masp_primitives::sapling::{PaymentAddress, ProofGenerationKey, Rseed}; + use masp_primitives::transaction::components::GROTH_PROOF_SIZE; use proptest::collection::SizeRange; use proptest::prelude::*; use proptest::test_runner::TestRng; diff --git a/crates/sdk/src/queries/mod.rs b/crates/sdk/src/queries/mod.rs index bf30131170..b9c1ed9847 100644 --- a/crates/sdk/src/queries/mod.rs +++ b/crates/sdk/src/queries/mod.rs @@ -96,8 +96,6 @@ pub fn require_no_data(request: &RequestQuery) -> namada_storage::Result<()> { /// Queries testing helpers #[cfg(any(test, feature = "testing"))] mod testing { - - use namada_core::types::storage::BlockHeight; use namada_state::testing::TestWlStorage; use tendermint_rpc::Response; diff --git a/crates/sdk/src/queries/shell.rs b/crates/sdk/src/queries/shell.rs index ea885ee4a6..22fc23abf4 100644 --- a/crates/sdk/src/queries/shell.rs +++ b/crates/sdk/src/queries/shell.rs @@ -18,7 +18,7 @@ use namada_core::types::storage::{ use namada_core::types::token::{Denomination, MaspDigitPos}; use namada_core::types::uint::Uint; use namada_state::{DBIter, LastBlock, StorageHasher, DB}; -use namada_storage::{self, ResultExt, StorageRead}; +use namada_storage::{ResultExt, StorageRead}; #[cfg(any(test, feature = "async-client"))] use namada_tx::data::TxResult; diff --git a/crates/sdk/src/queries/shell/eth_bridge.rs b/crates/sdk/src/queries/shell/eth_bridge.rs index 92ee5f3ca8..d25ad6d329 100644 --- a/crates/sdk/src/queries/shell/eth_bridge.rs +++ b/crates/sdk/src/queries/shell/eth_bridge.rs @@ -34,7 +34,7 @@ use namada_ethereum_bridge::storage::{ use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::MembershipProof::BridgePool; use namada_state::{DBIter, StorageHasher, StoreRef, StoreType, DB}; -use namada_storage::{self, CustomError, ResultExt, StorageRead}; +use namada_storage::{CustomError, ResultExt, StorageRead}; use namada_vote_ext::validator_set_update::{ ValidatorSetArgs, VotingPowersMap, }; @@ -368,8 +368,8 @@ where { let Some(contract) = StorageRead::read(ctx.wl_storage, key)? else { return Err(namada_storage::Error::SimpleMessage( - "Failed to read contract: The Ethereum bridge \ - storage is not initialized", + "Failed to read contract: The Ethereum bridge storage is not \ + initialized", )); }; Ok(contract) @@ -839,22 +839,16 @@ mod test_ethbridge_router { use assert_matches::assert_matches; use namada_core::types::address::nam; use namada_core::types::address::testing::established_address_1; - use namada_core::types::eth_abi::Encode; use namada_core::types::eth_bridge_pool::{ - GasFee, PendingTransfer, TransferToEthereum, TransferToEthereumKind, - }; - use namada_core::types::ethereum_events::EthAddress; - use namada_core::types::storage::BlockHeight; - use namada_core::types::voting_power::{ - EthBridgeVotingPower, FractionalVotingPower, + GasFee, TransferToEthereum, TransferToEthereumKind, }; + use namada_core::types::voting_power::EthBridgeVotingPower; use namada_ethereum_bridge::protocol::transactions::validator_set_update::aggregate_votes; use namada_ethereum_bridge::storage::bridge_pool::{ get_pending_key, get_signed_root_key, BridgePoolTree, }; use namada_ethereum_bridge::storage::proof::BridgePoolRootProof; use namada_ethereum_bridge::storage::whitelist; - use namada_proof_of_stake::pos_queries::PosQueries; use namada_state::mockdb::MockDBWriteBatch; use namada_storage::StorageWrite; use namada_vote_ext::validator_set_update; @@ -1792,7 +1786,6 @@ mod test_ethbridge_router { #[allow(dead_code)] mod test_utils { use namada_core::types::address::Address; - pub use namada_ethereum_bridge::test_utils::*; /// An established user address for testing & development pub fn bertha_address() -> Address { diff --git a/crates/sdk/src/queries/vp/pos.rs b/crates/sdk/src/queries/vp/pos.rs index 47a7f33cf9..8b6cf15bab 100644 --- a/crates/sdk/src/queries/vp/pos.rs +++ b/crates/sdk/src/queries/vp/pos.rs @@ -29,7 +29,7 @@ use namada_proof_of_stake::types::{ BondId, BondsAndUnbondsDetail, BondsAndUnbondsDetails, CommissionPair, Slash, ValidatorMetaData, ValidatorState, WeightedValidator, }; -use namada_proof_of_stake::{self, bond_amount, query_reward_tokens}; +use namada_proof_of_stake::{bond_amount, query_reward_tokens}; use namada_state::{DBIter, StorageHasher, DB}; use namada_storage::collections::lazy_map; use namada_storage::OptionExt; diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index b0d2b9994d..bb6bace950 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -685,7 +685,7 @@ pub async fn query_tx_response( // Get the block results corresponding to a block to which // the specified transaction belongs let block = &blocks - .get(0) + .first() .ok_or_else(|| { TError::server( "Unable to find a block applying the given transaction" diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index 7bc127c68d..0a0e553408 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -349,7 +349,7 @@ pub async fn aux_signing_data( match &args.wrapper_fee_payer { Some(keypair) => keypair.clone(), None => public_keys - .get(0) + .first() .ok_or(TxSubmitError::InvalidFeePayer)? .clone(), } @@ -389,7 +389,7 @@ pub async fn init_validator_signing_data( match &args.wrapper_fee_payer { Some(keypair) => keypair.clone(), None => public_keys - .get(0) + .first() .ok_or(TxSubmitError::InvalidFeePayer)? .clone(), } diff --git a/crates/sdk/src/wallet/alias.rs b/crates/sdk/src/wallet/alias.rs index 48ab4a9fa0..e03daa6f10 100644 --- a/crates/sdk/src/wallet/alias.rs +++ b/crates/sdk/src/wallet/alias.rs @@ -87,7 +87,7 @@ impl PartialEq for Alias { impl PartialOrd for Alias { fn partial_cmp(&self, other: &Self) -> Option { - self.normalize().partial_cmp(&other.normalize()) + Some(self.cmp(other)) } } diff --git a/crates/sdk/src/wallet/derivation_path.rs b/crates/sdk/src/wallet/derivation_path.rs index 3210450d26..0f547a18cc 100644 --- a/crates/sdk/src/wallet/derivation_path.rs +++ b/crates/sdk/src/wallet/derivation_path.rs @@ -64,7 +64,7 @@ impl DerivationPath { pub fn is_bip44_conform(&self, strict: bool) -> bool { // check the path conforms the structure: // m / purpose' / coin_type' / account' / change / address_index - let purpose = self.0.as_ref().get(0); + let purpose = self.0.as_ref().first(); let coin_type = self.0.as_ref().get(1); let account = self.0.as_ref().get(2); let change = self.0.as_ref().get(3); @@ -108,7 +108,7 @@ impl DerivationPath { // check the path conforms one of the structure: // m / purpose' / coin_type' / account' // m / purpose' / coin_type' / account' / address_index - let purpose = self.0.as_ref().get(0); + let purpose = self.0.as_ref().first(); let coin_type = self.0.as_ref().get(1); let account = self.0.as_ref().get(2); let address = self.0.as_ref().get(3); diff --git a/crates/sdk/src/wallet/keys.rs b/crates/sdk/src/wallet/keys.rs index 64a052dd41..7c94df49d6 100644 --- a/crates/sdk/src/wallet/keys.rs +++ b/crates/sdk/src/wallet/keys.rs @@ -97,8 +97,9 @@ where }) .map_err(D::Error::custom) } else { - Err(DeserializeStoredKeypairError::MissingPrefix) - .map_err(D::Error::custom) + Err(D::Error::custom( + DeserializeStoredKeypairError::MissingPrefix, + )) } } } diff --git a/crates/sdk/src/wallet/store.rs b/crates/sdk/src/wallet/store.rs index 37d2dc1e44..ea32737643 100644 --- a/crates/sdk/src/wallet/store.rs +++ b/crates/sdk/src/wallet/store.rs @@ -13,7 +13,6 @@ use namada_core::types::masp::{ ExtendedSpendingKey, ExtendedViewingKey, PaymentAddress, }; use serde::{Deserialize, Serialize}; -use slip10_ed25519; use zeroize::Zeroizing; use super::alias::{self, Alias}; @@ -633,7 +632,7 @@ impl Store { other.store.tendermint_node_key, ), ]; - self.secret_keys.extend(keys.into_iter()); + self.secret_keys.extend(keys); let consensus_pk = other.consensus_key.ref_to(); let tendermint_node_pk = other.tendermint_node_key.ref_to(); @@ -644,15 +643,15 @@ impl Store { tendermint_node_pk.clone(), ), ]; - self.public_keys.extend(public_keys.clone().into_iter()); + self.public_keys.extend(public_keys.clone()); self.addresses - .extend(public_keys.into_iter().map(|(k, v)| (k, (&v).into()))); + .extend(public_keys.map(|(k, v)| (k, (&v).into()))); let pkhs = [ ((&consensus_pk).into(), consensus_key_alias), ((&tendermint_node_pk).into(), tendermint_node_key_alias), ]; - self.pkhs.extend(pkhs.into_iter()); + self.pkhs.extend(pkhs); self.validator_data = Some(ValidatorData { address: validator_address, @@ -789,11 +788,10 @@ impl<'de> Deserialize<'de> for AddressVpType { #[cfg(test)] mod test_wallet { - use base58::{self, FromBase58}; + use base58::FromBase58; use bip39::{Language, Mnemonic, Seed}; use data_encoding::HEXLOWER; - use super::super::derivation_path::DerivationPath; use super::*; #[test] diff --git a/crates/shielded_token/src/conversion.rs b/crates/shielded_token/src/conversion.rs index 23db438d42..4d520bca6d 100644 --- a/crates/shielded_token/src/conversion.rs +++ b/crates/shielded_token/src/conversion.rs @@ -527,7 +527,7 @@ mod tests { use namada_core::types::token::testing::arb_amount; use namada_parameters::{EpochDuration, Parameters}; use namada_state::testing::TestWlStorage; - use namada_trans_token::{write_denom, Denomination, MaspParams}; + use namada_trans_token::{write_denom, MaspParams}; use proptest::prelude::*; use proptest::test_runner::Config; use test_log::test; diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 8274277158..163cdb2fe8 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -33,7 +33,7 @@ pub use namada_merkle_tree::{ MerkleTreeStoresRead, MerkleTreeStoresWrite, StoreRef, StoreType, }; use namada_merkle_tree::{Error as MerkleTreeError, MerkleRoot}; -use namada_parameters::{self, EpochDuration, Parameters}; +use namada_parameters::{EpochDuration, Parameters}; pub use namada_storage::{Error as StorageError, Result as StorageResult, *}; use thiserror::Error; use tx_queue::{ExpiredTxsQueue, TxQueue}; @@ -570,14 +570,11 @@ where height }; - let epoch = self - .block - .pred_epochs - .get_epoch(height) - .unwrap_or(Epoch::default()); + let epoch = + self.block.pred_epochs.get_epoch(height).unwrap_or_default(); let epoch_start_height = match self.block.pred_epochs.get_start_height_of_epoch(epoch) { - Some(height) if height == BlockHeight(0) => BlockHeight(1), + Some(BlockHeight(0)) => BlockHeight(1), Some(height) => height, None => BlockHeight(1), }; @@ -1103,7 +1100,6 @@ impl From for Error { #[cfg(any(test, feature = "testing"))] pub mod testing { use namada_core::types::address; - use namada_core::types::hash::Sha256Hasher; use super::mockdb::MockDB; use super::*; @@ -1175,7 +1171,6 @@ mod tests { use namada_core::types::dec::Dec; use namada_core::types::time::{self, Duration}; use namada_core::types::token; - use namada_parameters::Parameters; use proptest::prelude::*; use proptest::test_runner::Config; diff --git a/crates/state/src/write_log.rs b/crates/state/src/write_log.rs index 17de478659..a6740b8221 100644 --- a/crates/state/src/write_log.rs +++ b/crates/state/src/write_log.rs @@ -731,8 +731,7 @@ impl WriteLog { #[cfg(test)] mod tests { use assert_matches::assert_matches; - use namada_core::types::hash::Hash; - use namada_core::types::{address, storage}; + use namada_core::types::address; use pretty_assertions::assert_eq; use proptest::prelude::*; diff --git a/crates/tests/src/e2e/eth_bridge_tests.rs b/crates/tests/src/e2e/eth_bridge_tests.rs index b1ea2636f5..3486c3aafa 100644 --- a/crates/tests/src/e2e/eth_bridge_tests.rs +++ b/crates/tests/src/e2e/eth_bridge_tests.rs @@ -279,10 +279,9 @@ async fn test_roundtrip_eth_transfer() -> Result<()> { /// In this test, we check the following: /// 1. We can successfully add transfers to the bridge pool. /// 2. We can query the bridge pool and it is non-empty. -/// 3. We request a proof of inclusion of the transfer into the -/// bridge pool. -/// 4. We submit an Ethereum event indicating that the transfer -/// has been relayed. +/// 3. We request a proof of inclusion of the transfer into the bridge pool. +/// 4. We submit an Ethereum event indicating that the transfer has been +/// relayed. /// 5. We check that the event is removed from the bridge pool. #[tokio::test] async fn test_bridge_pool_e2e() { diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index 40968383a0..3f4bc189ed 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -9,7 +9,6 @@ //! To keep the temporary files created by a test, use env var //! `NAMADA_E2E_KEEP_TEMP=true`. -use core::convert::TryFrom; use core::str::FromStr; use core::time::Duration; use std::collections::{BTreeSet, HashMap}; diff --git a/crates/tests/src/e2e/ledger_tests.rs b/crates/tests/src/e2e/ledger_tests.rs index 7f93e0f50c..6c4e0c80bb 100644 --- a/crates/tests/src/e2e/ledger_tests.rs +++ b/crates/tests/src/e2e/ledger_tests.rs @@ -346,8 +346,8 @@ fn run_ledger_load_state_and_reset() -> Result<()> { } /// In this test we -/// 1. Run the ledger node until a pre-configured height, -/// at which point it should suspend. +/// 1. Run the ledger node until a pre-configured height, at which point it +/// should suspend. /// 2. Check that we can still query the ledger. /// 3. Check that we can shutdown the ledger normally afterwards. #[test] @@ -576,7 +576,7 @@ fn ledger_txs_and_queries() -> Result<()> { let tx_args = if dry_run && tx_args[0] == "tx" { continue; } else if dry_run { - vec![tx_args.clone(), vec!["--dry-run"]].concat() + [tx_args.clone(), vec!["--dry-run"]].concat() } else { tx_args.clone() }; @@ -1611,8 +1611,8 @@ fn pos_init_validator() -> Result<()> { client.exp_string(TX_APPLIED_SUCCESS)?; client.assert_success(); - // 3. Submit a delegation to the new validator - // First, transfer some tokens to the validator's key for fees: + // 3. Submit a delegation to the new validator First, transfer some tokens + // to the validator's key for fees: let tx_args = vec![ "transfer", "--source", @@ -2630,7 +2630,7 @@ fn proposal_offline() -> Result<()> { ); let valid_proposal_json_path = test.test_dir.path().join("valid_proposal.json"); - write_json_file(valid_proposal_json_path.as_path(), &valid_proposal_json); + write_json_file(valid_proposal_json_path.as_path(), valid_proposal_json); let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap(); while epoch.0 <= 3 { @@ -3031,13 +3031,12 @@ fn double_signing_gets_slashed() -> Result<()> { /// In this test we: /// 1. Run the ledger node -/// 2. For some transactions that need signature authorization: -/// 2a. Generate a new key for an implicit account. -/// 2b. Send some funds to the implicit account. -/// 2c. Submit the tx with the implicit account as the source, that -/// requires that the account has revealed its PK. This should be done -/// by the client automatically. -/// 2d. Submit same tx again, this time the client shouldn't reveal again. +/// 2. For some transactions that need signature authorization: 2a. Generate a +/// new key for an implicit account. 2b. Send some funds to the implicit +/// account. 2c. Submit the tx with the implicit account as the source, that +/// requires that the account has revealed its PK. This should be done by the +/// client automatically. 2d. Submit same tx again, this time the client +/// shouldn't reveal again. #[test] fn implicit_account_reveal_pk() -> Result<()> { let test = setup::single_node_net()?; diff --git a/crates/tests/src/e2e/setup.rs b/crates/tests/src/e2e/setup.rs index 34517848c3..7ce0431841 100644 --- a/crates/tests/src/e2e/setup.rs +++ b/crates/tests/src/e2e/setup.rs @@ -36,7 +36,6 @@ use namada_tx_prelude::token; use once_cell::sync::Lazy; use rand::rngs::OsRng; use rand::Rng; -use serde_json; use tempfile::{tempdir, tempdir_in, TempDir}; use crate::e2e::helpers::{generate_bin_command, make_hermes_config}; @@ -370,7 +369,7 @@ pub fn network( { let base_dir = test_dir.path(); let src_path = - wallet::wallet_file(&templates_dir.join("src").join("pre-genesis")); + wallet::wallet_file(templates_dir.join("src").join("pre-genesis")); let dest_dir = base_dir.join("pre-genesis"); let dest_path = wallet::wallet_file(&dest_dir); println!( diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 040857603d..1025f18e77 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -1376,7 +1376,7 @@ fn masp_txs_and_queries() -> Result<()> { vec!["shielded-sync", "--node", validator_one_rpc], )?; let tx_args = if dry_run && tx_args[0] == "transfer" { - vec![tx_args.clone(), vec!["--dry-run"]].concat() + [tx_args.clone(), vec!["--dry-run"]].concat() } else { tx_args.clone() }; diff --git a/crates/tests/src/native_vp/pos.rs b/crates/tests/src/native_vp/pos.rs index f4a3c6bc5e..c7360645dd 100644 --- a/crates/tests/src/native_vp/pos.rs +++ b/crates/tests/src/native_vp/pos.rs @@ -147,11 +147,10 @@ pub fn init_pos( #[cfg(test)] mod tests { - use namada::ledger::pos::{PosParams, PosVP}; + use namada::ledger::pos::PosVP; use namada::token; use namada::types::address; use namada::types::key::common::PublicKey; - use namada::types::storage::Epoch; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; use namada_tx_prelude::Address; use proptest::prelude::*; @@ -167,7 +166,6 @@ mod tests { }; use super::*; use crate::native_vp::TestNativeVpEnv; - use crate::tx::tx_host_env; prop_state_machine! { #![proptest_config(Config { @@ -465,8 +463,7 @@ mod tests { if self.invalid_pos_changes.is_empty() && self.invalid_arbitrary_changes.is_empty() { - self.committed_valid_actions - .extend(valid_actions_to_commit.into_iter()); + self.committed_valid_actions.extend(valid_actions_to_commit); } self.invalid_pos_changes = vec![]; self.invalid_arbitrary_changes = vec![]; diff --git a/crates/tests/src/storage_api/collections/lazy_map.rs b/crates/tests/src/storage_api/collections/lazy_map.rs index 0e9309df49..3ece0c16e2 100644 --- a/crates/tests/src/storage_api/collections/lazy_map.rs +++ b/crates/tests/src/storage_api/collections/lazy_map.rs @@ -1,7 +1,6 @@ #[cfg(test)] mod tests { use std::collections::BTreeMap; - use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; use namada::types::address::{self, Address}; @@ -154,9 +153,7 @@ mod tests { Transition::CommitTx | Transition::CommitTxAndBlock => { let valid_actions_to_commit = std::mem::take(&mut state.valid_transitions); - state - .committed_transitions - .extend(valid_actions_to_commit.into_iter()); + state.committed_transitions.extend(valid_actions_to_commit); } _ => state.valid_transitions.push(transition.clone()), } diff --git a/crates/tests/src/storage_api/collections/lazy_set.rs b/crates/tests/src/storage_api/collections/lazy_set.rs index 2fa04a3e40..4f04fac2a4 100644 --- a/crates/tests/src/storage_api/collections/lazy_set.rs +++ b/crates/tests/src/storage_api/collections/lazy_set.rs @@ -1,7 +1,6 @@ #[cfg(test)] mod tests { use std::collections::BTreeSet; - use std::convert::TryInto; use namada::types::address::{self, Address}; use namada::types::storage; @@ -139,9 +138,7 @@ mod tests { Transition::CommitTx | Transition::CommitTxAndBlock => { let valid_actions_to_commit = std::mem::take(&mut state.valid_transitions); - state - .committed_transitions - .extend(valid_actions_to_commit.into_iter()); + state.committed_transitions.extend(valid_actions_to_commit); } _ => state.valid_transitions.push(transition.clone()), } diff --git a/crates/tests/src/storage_api/collections/lazy_vec.rs b/crates/tests/src/storage_api/collections/lazy_vec.rs index 7a3c3f0b14..a114b7fe2d 100644 --- a/crates/tests/src/storage_api/collections/lazy_vec.rs +++ b/crates/tests/src/storage_api/collections/lazy_vec.rs @@ -1,6 +1,5 @@ #[cfg(test)] mod tests { - use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; use namada::types::address::{self, Address}; @@ -158,9 +157,7 @@ mod tests { Transition::CommitTx => { let valid_actions_to_commit = std::mem::take(&mut state.valid_transitions); - state - .committed_transitions - .extend(valid_actions_to_commit.into_iter()); + state.committed_transitions.extend(valid_actions_to_commit); } _ => state.valid_transitions.push(transition.clone()), } diff --git a/crates/tests/src/storage_api/collections/nested_lazy_map.rs b/crates/tests/src/storage_api/collections/nested_lazy_map.rs index 9a4d487886..f8d11f14e9 100644 --- a/crates/tests/src/storage_api/collections/nested_lazy_map.rs +++ b/crates/tests/src/storage_api/collections/nested_lazy_map.rs @@ -1,7 +1,6 @@ #[cfg(test)] mod tests { use std::collections::BTreeMap; - use std::convert::TryInto; use borsh::{BorshDeserialize, BorshSerialize}; use namada::types::address::{self, Address}; @@ -167,9 +166,7 @@ mod tests { Transition::CommitTx | Transition::CommitTxAndBlock => { let valid_actions_to_commit = std::mem::take(&mut state.valid_transitions); - state - .committed_transitions - .extend(valid_actions_to_commit.into_iter()); + state.committed_transitions.extend(valid_actions_to_commit); } _ => state.valid_transitions.push(transition.clone()), } @@ -633,17 +630,13 @@ mod tests { Transition::CommitTx | Transition::CommitTxAndBlock => {} Transition::Insert((key_outer, key_middle, key_inner), value) | Transition::Update((key_outer, key_middle, key_inner), value) => { - let middle = - map.entry(*key_outer).or_insert_with(Default::default); - let inner = - middle.entry(*key_middle).or_insert_with(Default::default); + let middle = map.entry(*key_outer).or_default(); + let inner = middle.entry(*key_middle).or_default(); inner.insert(*key_inner, value.clone()); } Transition::Remove((key_outer, key_middle, key_inner)) => { - let middle = - map.entry(*key_outer).or_insert_with(Default::default); - let inner = - middle.entry(*key_middle).or_insert_with(Default::default); + let middle = map.entry(*key_outer).or_default(); + let inner = middle.entry(*key_middle).or_default(); let _popped = inner.remove(key_inner); } } diff --git a/crates/tests/src/vm_host_env/mod.rs b/crates/tests/src/vm_host_env/mod.rs index 2269acf1a8..e9b7182ce8 100644 --- a/crates/tests/src/vm_host_env/mod.rs +++ b/crates/tests/src/vm_host_env/mod.rs @@ -564,7 +564,7 @@ mod tests { let expiration = Some(DateTimeUtc::now()); for data in &[ // Tx with some arbitrary data - vec![1, 2, 3, 4].repeat(10), + [1, 2, 3, 4].repeat(10), // Tx without any data vec![], ] { diff --git a/crates/tests/src/vm_host_env/tx.rs b/crates/tests/src/vm_host_env/tx.rs index c91807589a..c167a8ee11 100644 --- a/crates/tests/src/vm_host_env/tx.rs +++ b/crates/tests/src/vm_host_env/tx.rs @@ -29,6 +29,7 @@ use crate::vp::TestVpEnv; static mut CTX: Ctx = unsafe { Ctx::new() }; /// Tx execution context provides access to host env functions +#[allow(static_mut_refs)] pub fn ctx() -> &'static mut Ctx { unsafe { &mut CTX } } @@ -257,7 +258,7 @@ mod native_tx_host_env { /// A [`TestTxEnv`] that can be used for tx host env functions calls /// that implements the WASM host environment in native environment. pub static ENV: RefCell>>> = - RefCell::new(None); + const { RefCell::new(None) }; } /// Initialize the tx host environment in [`ENV`]. This will be used in the @@ -524,7 +525,6 @@ mod native_tx_host_env { #[cfg(test)] mod tests { - use namada::ledger::storage::mockdb::MockDB; use namada::types::storage; use namada::vm::host_env::{self, TxVmEnv}; use namada::vm::memory::VmMemory; diff --git a/crates/tests/src/vm_host_env/vp.rs b/crates/tests/src/vm_host_env/vp.rs index a1963fe4ce..921ff5059c 100644 --- a/crates/tests/src/vm_host_env/vp.rs +++ b/crates/tests/src/vm_host_env/vp.rs @@ -116,9 +116,7 @@ mod native_vp_host_env { // TODO replace with `std::concat_idents` once stabilized (https://github.com/rust-lang/rust/issues/29599) use concat_idents::concat_idents; - use namada::state::Sha256Hasher; use namada::vm::host_env::*; - use namada::vm::WasmCacheRwAccess; use super::*; @@ -135,7 +133,7 @@ mod native_vp_host_env { /// A [`TestVpEnv`] that can be used for VP host env functions calls /// that implements the WASM host environment in native environment. pub static ENV: RefCell>>> = - RefCell::new(None); + const {RefCell::new(None) }; } /// Initialize the VP environment in [`ENV`]. This will be used in the diff --git a/crates/tx/src/types.rs b/crates/tx/src/types.rs index 432e217e29..1dcec2a9d6 100644 --- a/crates/tx/src/types.rs +++ b/crates/tx/src/types.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use std::cmp::Ordering; use std::collections::{BTreeMap, HashMap, HashSet}; -use std::convert::TryFrom; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; @@ -1256,7 +1255,7 @@ impl Tx { ) -> Result<&Signature, VerifySigError> { self.verify_signatures( hashes, - AccountPublicKeysMap::from_iter([public_key.clone()].into_iter()), + AccountPublicKeysMap::from_iter([public_key.clone()]), &None, 1, None, @@ -1515,7 +1514,7 @@ impl Tx { let secret_keys = if signer.is_some() { account_public_keys_map.index_secret_keys(keypairs) } else { - (0..).zip(keypairs.into_iter()).collect() + (0..).zip(keypairs).collect() }; self.add_section(Section::Signature(Signature::new( diff --git a/crates/tx_prelude/src/proof_of_stake.rs b/crates/tx_prelude/src/proof_of_stake.rs index 50ad3daf73..6a0aadb5c8 100644 --- a/crates/tx_prelude/src/proof_of_stake.rs +++ b/crates/tx_prelude/src/proof_of_stake.rs @@ -1,7 +1,6 @@ //! Proof of Stake system integration with functions for transactions use namada_core::types::dec::Dec; -use namada_core::types::key::common; use namada_core::types::{key, token}; pub use namada_proof_of_stake::parameters::PosParams; use namada_proof_of_stake::storage::read_pos_params; diff --git a/crates/vote_ext/src/ethereum_events.rs b/crates/vote_ext/src/ethereum_events.rs index 35733dcdc9..b5df5f6c28 100644 --- a/crates/vote_ext/src/ethereum_events.rs +++ b/crates/vote_ext/src/ethereum_events.rs @@ -153,11 +153,9 @@ impl VextDigest { #[cfg(test)] mod tests { - use namada_core::types::address::{self, Address}; - use namada_core::types::ethereum_events::{EthereumEvent, Uint}; + use namada_core::types::ethereum_events::Uint; use namada_core::types::hash::Hash; - use namada_core::types::key; - use namada_tx::Signed; + use namada_core::types::{address, key}; use super::*; diff --git a/crates/vote_ext/src/lib.rs b/crates/vote_ext/src/lib.rs index ca49e96801..bb895b640e 100644 --- a/crates/vote_ext/src/lib.rs +++ b/crates/vote_ext/src/lib.rs @@ -113,15 +113,15 @@ impl TryFrom<&Tx> for EthereumTxData { fn try_from(tx: &Tx) -> Result { let TxType::Protocol(protocol_tx) = tx.header().tx_type else { - return Err(TxError::Deserialization( - "Expected protocol tx type".into(), - )); - }; + return Err(TxError::Deserialization( + "Expected protocol tx type".into(), + )); + }; let Some(tx_data) = tx.data() else { - return Err(TxError::Deserialization( - "Expected protocol tx type associated data".into(), - )); - }; + return Err(TxError::Deserialization( + "Expected protocol tx type associated data".into(), + )); + }; Self::deserialize(&protocol_tx.tx, &tx_data) } } diff --git a/crates/vote_ext/src/validator_set_update.rs b/crates/vote_ext/src/validator_set_update.rs index 6e4a181319..c6fbf5533f 100644 --- a/crates/vote_ext/src/validator_set_update.rs +++ b/crates/vote_ext/src/validator_set_update.rs @@ -357,7 +357,7 @@ impl From for ethereum_structs::ValidatorSetArgs { ethereum_structs::ValidatorSetArgs { validator_set: validators .into_iter() - .zip(voting_powers.into_iter()) + .zip(voting_powers) .map(|(addr, power)| encode_validator_data(addr, power)) .collect(), nonce: epoch.0.into(), @@ -428,7 +428,6 @@ mod tests { use std::str::FromStr; use data_encoding::HEXLOWER; - use namada_core::types::ethereum_events::EthAddress; use super::*; diff --git a/crates/vp_prelude/src/lib.rs b/crates/vp_prelude/src/lib.rs index 0f57f495c4..a61b685439 100644 --- a/crates/vp_prelude/src/lib.rs +++ b/crates/vp_prelude/src/lib.rs @@ -12,10 +12,8 @@ pub mod ibc { } // used in the VP input -use core::convert::AsRef; use core::slice; pub use std::collections::{BTreeSet, HashSet}; -use std::convert::TryFrom; use std::marker::PhantomData; pub use namada_core::borsh::{ diff --git a/rust-nightly-version b/rust-nightly-version index df18b6ae37..99d5905d98 100644 --- a/rust-nightly-version +++ b/rust-nightly-version @@ -1 +1 @@ -nightly-2023-06-01 +nightly-2024-02-20 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 196d6c41ec..f537877896 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "1.76.0" components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-src", "rust-analysis"] targets = ['wasm32-unknown-unknown'] \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml index 6a1590b990..943b8da0f2 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -45,7 +45,7 @@ remove_nested_parens = true reorder_impl_items = true reorder_imports = true reorder_modules = true -required_version = "1.5.2" +required_version = "1.7.0" skip_children = false space_after_colon = true space_before_colon = false diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 3d945aa042..64170ce543 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.11", "once_cell", @@ -2951,6 +2951,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -5552,11 +5561,12 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=515687fe7884cb365067ac86c66ac3613de176bb#515687fe7884cb365067ac86c66ac3613de176bb" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=bab8cb96872db22cc9a139b2d3dfc4e00521d097#bab8cb96872db22cc9a139b2d3dfc4e00521d097" dependencies = [ "borsh", "cfg-if 1.0.0", "ics23", + "itertools 0.12.1", "sha2 0.9.9", ] diff --git a/wasm/wasm_source/src/tx_bond.rs b/wasm/wasm_source/src/tx_bond.rs index 94c2339d49..923c08d1bb 100644 --- a/wasm/wasm_source/src/tx_bond.rs +++ b/wasm/wasm_source/src/tx_bond.rs @@ -27,7 +27,6 @@ mod tests { }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; @@ -40,7 +39,6 @@ mod tests { use namada_tx_prelude::key::testing::arb_common_keypair; use namada_tx_prelude::key::RefTo; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; - use namada_tx_prelude::{token, BorshSerializeExt}; use proptest::prelude::*; use super::*; diff --git a/wasm/wasm_source/src/tx_change_validator_commission.rs b/wasm/wasm_source/src/tx_change_validator_commission.rs index ce95c6d780..fd7786baa2 100644 --- a/wasm/wasm_source/src/tx_change_validator_commission.rs +++ b/wasm/wasm_source/src/tx_change_validator_commission.rs @@ -26,7 +26,6 @@ mod tests { use namada::proof_of_stake::storage::validator_commission_rate_handle; use namada::proof_of_stake::types::GenesisValidator; use namada::types::dec::{Dec, POS_DECIMAL_PRECISION}; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; @@ -36,7 +35,6 @@ mod tests { use namada_tx_prelude::key::testing::arb_common_keypair; use namada_tx_prelude::key::RefTo; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; - use namada_tx_prelude::{token, BorshSerializeExt}; use proptest::prelude::*; use super::*; diff --git a/wasm/wasm_source/src/tx_redelegate.rs b/wasm/wasm_source/src/tx_redelegate.rs index c4f9e240bb..e7668f2382 100644 --- a/wasm/wasm_source/src/tx_redelegate.rs +++ b/wasm/wasm_source/src/tx_redelegate.rs @@ -31,7 +31,6 @@ mod tests { }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; @@ -41,7 +40,6 @@ mod tests { use namada_tx_prelude::key::testing::arb_common_keypair; use namada_tx_prelude::key::RefTo; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; - use namada_tx_prelude::{token, BorshSerializeExt}; use proptest::prelude::*; use super::*; diff --git a/wasm/wasm_source/src/tx_unbond.rs b/wasm/wasm_source/src/tx_unbond.rs index 5d982c11bb..17ead030ec 100644 --- a/wasm/wasm_source/src/tx_unbond.rs +++ b/wasm/wasm_source/src/tx_unbond.rs @@ -34,7 +34,6 @@ mod tests { }; use namada::proof_of_stake::types::{GenesisValidator, WeightedValidator}; use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; @@ -44,7 +43,6 @@ mod tests { use namada_tx_prelude::key::testing::arb_common_keypair; use namada_tx_prelude::key::RefTo; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; - use namada_tx_prelude::{token, BorshSerializeExt}; use proptest::prelude::*; use super::*; diff --git a/wasm/wasm_source/src/tx_withdraw.rs b/wasm/wasm_source/src/tx_withdraw.rs index 260da26c11..9abf295605 100644 --- a/wasm/wasm_source/src/tx_withdraw.rs +++ b/wasm/wasm_source/src/tx_withdraw.rs @@ -27,7 +27,6 @@ mod tests { use namada::proof_of_stake::storage::unbond_handle; use namada::proof_of_stake::types::GenesisValidator; use namada::types::dec::Dec; - use namada::types::storage::Epoch; use namada_tests::log::test; use namada_tests::native_vp::pos::init_pos; use namada_tests::native_vp::TestNativeVpEnv; @@ -40,7 +39,6 @@ mod tests { use namada_tx_prelude::key::testing::arb_common_keypair; use namada_tx_prelude::key::RefTo; use namada_tx_prelude::proof_of_stake::parameters::testing::arb_pos_params; - use namada_tx_prelude::BorshSerializeExt; use proptest::prelude::*; use super::*; diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 249cd097f2..68b5ba431f 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -50,9 +50,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom 0.2.11", "once_cell", @@ -2951,6 +2951,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -5546,11 +5555,12 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=515687fe7884cb365067ac86c66ac3613de176bb#515687fe7884cb365067ac86c66ac3613de176bb" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=bab8cb96872db22cc9a139b2d3dfc4e00521d097#bab8cb96872db22cc9a139b2d3dfc4e00521d097" dependencies = [ "borsh", "cfg-if 1.0.0", "ics23", + "itertools 0.12.1", "sha2 0.9.9", ] From 1ab1b484677962a51c3a30f0e6fbec91ed332a85 Mon Sep 17 00:00:00 2001 From: satan Date: Thu, 22 Feb 2024 10:56:01 +0100 Subject: [PATCH 2/4] Fixed unit tests. Added changelog. Updated toolchain for wasm --- .../unreleased/improvements/2687-toolchain-update.md | 1 + crates/apps/src/lib/bench_utils.rs | 1 - .../apps/src/lib/node/ledger/shell/finalize_block.rs | 2 +- crates/apps/src/lib/node/ledger/shell/mod.rs | 1 - .../apps/src/lib/node/ledger/shell/testing/node.rs | 4 ++-- crates/macros/src/lib.rs | 2 +- crates/sdk/src/masp.rs | 2 +- crates/sdk/src/queries/shell/eth_bridge.rs | 2 ++ wasm/Cargo.lock | 12 +----------- wasm/rust-toolchain.toml | 2 +- wasm_for_tests/wasm_source/Cargo.lock | 12 +----------- 11 files changed, 11 insertions(+), 30 deletions(-) create mode 100644 .changelog/unreleased/improvements/2687-toolchain-update.md diff --git a/.changelog/unreleased/improvements/2687-toolchain-update.md b/.changelog/unreleased/improvements/2687-toolchain-update.md new file mode 100644 index 0000000000..1e63e434e7 --- /dev/null +++ b/.changelog/unreleased/improvements/2687-toolchain-update.md @@ -0,0 +1 @@ +- Moving to rust version 1.76.0 ([#2687](https://github.com/anoma/anoma/pull/2687)) \ No newline at end of file diff --git a/crates/apps/src/lib/bench_utils.rs b/crates/apps/src/lib/bench_utils.rs index 9cff3d0368..8b31dee989 100644 --- a/crates/apps/src/lib/bench_utils.rs +++ b/crates/apps/src/lib/bench_utils.rs @@ -58,7 +58,6 @@ use namada::ledger::queries::{ Client, EncodedResponseQuery, RequestCtx, RequestQuery, Router, RPC, }; use namada::state::StorageRead; -use namada::tendermint_rpc::{self}; use namada::tx::data::pos::Bond; use namada::tx::data::{TxResult, VpsResult}; use namada::tx::{Code, Data, Section, Signature, Tx}; diff --git a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs index 63bb3d3d6a..c6cf8edc46 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -852,7 +852,7 @@ fn pos_votes_from_abci( /// are covered by the e2e tests. #[cfg(test)] mod test_finalize_block { - use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; + use std::collections::{BTreeMap, HashMap, HashSet}; use std::num::NonZeroU64; use std::str::FromStr; diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps/src/lib/node/ledger/shell/mod.rs index 311db6b733..443fcda30b 100644 --- a/crates/apps/src/lib/node/ledger/shell/mod.rs +++ b/crates/apps/src/lib/node/ledger/shell/mod.rs @@ -22,7 +22,6 @@ pub mod utils; mod vote_extensions; use std::collections::BTreeSet; -use std::convert::{TryFrom, TryInto}; use std::mem; use std::path::{Path, PathBuf}; #[allow(unused_imports)] 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 1482303791..025e7fa553 100644 --- a/crates/apps/src/lib/node/ledger/shell/testing/node.rs +++ b/crates/apps/src/lib/node/ledger/shell/testing/node.rs @@ -25,7 +25,6 @@ use namada::proof_of_stake::types::WeightedValidator; use namada::state::{LastBlock, Sha256Hasher, EPOCH_SWITCH_BLOCKS_DELAY}; use namada::tendermint::abci::response::Info; use namada::tendermint::abci::types::VoteInfo; -use namada::tendermint_rpc::SimpleRequest; use namada::types::control_flow::time::Duration; use namada::types::ethereum_events::EthereumEvent; use namada::types::ethereum_structs; @@ -38,13 +37,14 @@ use namada_sdk::tendermint_proto::google::protobuf::Timestamp; use namada_sdk::tx::data::ResultCode; use regex::Regex; use tendermint_rpc::endpoint::block; +use tendermint_rpc::SimpleRequest; use tokio::sync::mpsc; +use crate::facade::tendermint; use crate::facade::tendermint_proto::v0_37::abci::{ RequestPrepareProposal, RequestProcessProposal, }; use crate::facade::tendermint_rpc::error::Error as RpcError; -use crate::facade::{tendermint, tendermint_rpc}; use crate::node::ledger::ethereum_oracle::test_tools::mock_web3_client::{ TestOracle, Web3Client, Web3Controller, }; diff --git a/crates/macros/src/lib.rs b/crates/macros/src/lib.rs index b41d5240e0..71743b8abb 100644 --- a/crates/macros/src/lib.rs +++ b/crates/macros/src/lib.rs @@ -389,7 +389,7 @@ mod test_proc_macros { let expected_impl = quote! { impl Keys { /// A list of all storage keys - pub const ALL: &[&'static str] = { + pub const ALL: &'static [&'static str] = { let Keys { bird, is, the, word } = Self::VALUES; &[bird, is, the, word] }; diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index 8054e8b65e..293d7d4279 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -552,7 +552,7 @@ impl Unscanned { where I: IntoIterator, { - self.txs.extend(items.into_iter()); + self.txs.extend(items); } fn contains_height(&self, height: u64) -> bool { diff --git a/crates/sdk/src/queries/shell/eth_bridge.rs b/crates/sdk/src/queries/shell/eth_bridge.rs index d25ad6d329..dcfa1c99b9 100644 --- a/crates/sdk/src/queries/shell/eth_bridge.rs +++ b/crates/sdk/src/queries/shell/eth_bridge.rs @@ -1786,6 +1786,8 @@ mod test_ethbridge_router { #[allow(dead_code)] mod test_utils { use namada_core::types::address::Address; + #[allow(unused_imports)] + pub use namada_ethereum_bridge::test_utils::*; /// An established user address for testing & development pub fn bertha_address() -> Address { diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 64170ce543..73cefa5f24 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -2951,15 +2951,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.9" @@ -5561,12 +5552,11 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=bab8cb96872db22cc9a139b2d3dfc4e00521d097#bab8cb96872db22cc9a139b2d3dfc4e00521d097" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=515687fe7884cb365067ac86c66ac3613de176bb#515687fe7884cb365067ac86c66ac3613de176bb" dependencies = [ "borsh", "cfg-if 1.0.0", "ics23", - "itertools 0.12.1", "sha2 0.9.9", ] diff --git a/wasm/rust-toolchain.toml b/wasm/rust-toolchain.toml index 2658985cb0..16235b717f 100644 --- a/wasm/rust-toolchain.toml +++ b/wasm/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.70.0" +channel = "1.76.0" components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-analysis"] diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 68b5ba431f..dc4be17b5c 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -2951,15 +2951,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.9" @@ -5555,12 +5546,11 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=bab8cb96872db22cc9a139b2d3dfc4e00521d097#bab8cb96872db22cc9a139b2d3dfc4e00521d097" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=515687fe7884cb365067ac86c66ac3613de176bb#515687fe7884cb365067ac86c66ac3613de176bb" dependencies = [ "borsh", "cfg-if 1.0.0", "ics23", - "itertools 0.12.1", "sha2 0.9.9", ] From 47beaf1abe65c23b893a6d47c1ebe975107226ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Thu, 22 Feb 2024 12:39:02 +0000 Subject: [PATCH 3/4] ci+docker: update toolchain versions --- .github/workflows/build-and-test.yml | 12 ++++++------ .github/workflows/checks.yml | 2 +- .github/workflows/cron.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/triggerable_sync.yml | 2 +- docker/namada-wasm/Dockerfile | 4 ++-- docker/namada/Dockerfile | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 70d1ecddb4..79b4229fc0 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -101,7 +101,7 @@ jobs: matrix: os: [ubuntu-latest] wasm_cache_version: ["v2"] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] steps: @@ -164,7 +164,7 @@ jobs: matrix: os: [ubuntu-latest] wasm_cache_version: ["v2"] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] steps: @@ -194,7 +194,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] make: - name: ABCI @@ -291,7 +291,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] make: - name: ABCI @@ -380,7 +380,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] make: - name: ABCI @@ -568,7 +568,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] comet_bft: [0.37.2] hermes: [1.7.4-namada-beta7] diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7c5f589e08..889f60ccc3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -36,7 +36,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] make: - name: Clippy command: clippy diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 96fa86a8ed..a64cddee73 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -22,7 +22,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] make: - name: Audit command: audit diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9cf28fecb3..dc013b2399 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -36,7 +36,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mdbook_version: [rust-lang/mdbook@v0.4.18] mdbook_mermaid: [badboy/mdbook-mermaid@v0.11.1] mdbook_linkcheck: [Michael-F-Bryan/mdbook-linkcheck@v0.7.6] diff --git a/.github/workflows/triggerable_sync.yml b/.github/workflows/triggerable_sync.yml index bf1f01d6f1..54886c49e7 100644 --- a/.github/workflows/triggerable_sync.yml +++ b/.github/workflows/triggerable_sync.yml @@ -41,7 +41,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - nightly_version: [nightly-2023-06-01] + nightly_version: [nightly-2024-02-20] mold_version: [2.4.0] comet_bft: [0.37.2] name: ["Run chain sync test"] diff --git a/docker/namada-wasm/Dockerfile b/docker/namada-wasm/Dockerfile index b6422340bd..1749c1f85b 100644 --- a/docker/namada-wasm/Dockerfile +++ b/docker/namada-wasm/Dockerfile @@ -1,12 +1,12 @@ # This docker is used for deterministic wasm builds # The version should be matching the version set in wasm/rust-toolchain.toml -FROM rust:1.70.0-bullseye +FROM rust:1.76.0-bullseye WORKDIR /__w/namada/namada # The version should be matching the version set above -RUN rustup toolchain install 1.70.0 --profile minimal +RUN rustup toolchain install 1.76.0 --profile minimal RUN rustup target add wasm32-unknown-unknown RUN apt-get update && apt-get install -y \ diff --git a/docker/namada/Dockerfile b/docker/namada/Dockerfile index 6563de29e8..10846a4501 100644 --- a/docker/namada/Dockerfile +++ b/docker/namada/Dockerfile @@ -1,4 +1,4 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1.70.0 AS chef +FROM lukemathwalker/cargo-chef:latest-rust-1.76.0 AS chef WORKDIR /app FROM chef AS planner From 92fc1f6732a102dbf1f8189144181a923f9779b7 Mon Sep 17 00:00:00 2001 From: Jacob Turner Date: Thu, 22 Feb 2024 14:40:40 +0100 Subject: [PATCH 4/4] Update crates/core/src/types/key/secp256k1.rs --- crates/core/src/types/key/secp256k1.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/core/src/types/key/secp256k1.rs b/crates/core/src/types/key/secp256k1.rs index 620f5d0178..e1baf17b6c 100644 --- a/crates/core/src/types/key/secp256k1.rs +++ b/crates/core/src/types/key/secp256k1.rs @@ -496,9 +496,9 @@ impl PartialOrd for Signature { impl Ord for Signature { fn cmp(&self, other: &Self) -> Ordering { - match self.0.to_bytes().partial_cmp(&other.0.to_bytes()) { - Some(Ordering::Equal) => self.1.cmp(&other.1), - res => res.unwrap(), + match self.0.to_bytes().cmp(&other.0.to_bytes()) { + Ordering::Equal => self.1.cmp(&other.1), + res => res, } } }