From 8335acb776ca68458c7358d03ebd516163bf34f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Zemanovi=C4=8D?= Date: Tue, 27 Feb 2024 11:08:02 +0000 Subject: [PATCH] fixup! Merge branch 'bat/toochain-1.76.0' (#2687) --- .../lib/node/ledger/shell/finalize_block.rs | 18 ++++++------------ .../src/lib/node/ledger/shell/governance.rs | 4 +--- .../src/lib/node/ledger/shell/init_chain.rs | 1 + crates/apps/src/lib/node/ledger/shell/mod.rs | 5 ++--- .../lib/node/ledger/shell/process_proposal.rs | 4 +--- .../apps/src/lib/node/ledger/shell/queries.rs | 1 - crates/merkle_tree/src/lib.rs | 2 +- .../namada/src/ledger/native_vp/multitoken.rs | 1 - crates/namada/src/vm/wasm/run.rs | 1 - crates/proof_of_stake/src/lib.rs | 8 +------- crates/sdk/src/eth_bridge/bridge_pool.rs | 2 ++ crates/sdk/src/masp.rs | 3 ++- crates/sdk/src/queries/shell/eth_bridge.rs | 4 +--- crates/state/src/lib.rs | 2 +- crates/state/src/wl_state.rs | 4 ++-- crates/storage/src/mockdb.rs | 2 +- crates/tests/src/vm_host_env/tx.rs | 2 -- crates/tests/src/vm_host_env/vp.rs | 2 -- crates/vote_ext/src/ethereum_events.rs | 2 +- 19 files changed, 23 insertions(+), 45 deletions(-) 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 e584a13b449..81c2d96a7e5 100644 --- a/crates/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/crates/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -1,11 +1,8 @@ //! Implementation of the `FinalizeBlock` ABCI++ method for the Shell -use std::cell::RefCell; - use data_encoding::HEXUPPER; use masp_primitives::merkle_tree::CommitmentTree; use masp_primitives::sapling::Node; -use namada::core::key::tm_raw_hash_to_string; use namada::core::storage::{BlockHash, BlockResults, Epoch, Header}; use namada::governance::pgf::inflation as pgf_inflation; use namada::ledger::events::EventType; @@ -745,15 +742,13 @@ mod test_finalize_block { use std::num::NonZeroU64; use std::str::FromStr; - use data_encoding::HEXUPPER; use namada::core::dec::{Dec, POS_DECIMAL_PRECISION}; use namada::core::ethereum_events::{EthAddress, Uint as ethUint}; use namada::core::hash::Hash; use namada::core::keccak::KeccakHash; use namada::core::key::testing::common_sk_from_simple_seed; - use namada::core::key::tm_consensus_key_raw_hash; - use namada::core::storage::{Epoch, KeySeg}; - use namada::core::time::{DateTimeUtc, DurationSecs}; + use namada::core::storage::KeySeg; + use namada::core::time::DurationSecs; use namada::core::uint::Uint; use namada::eth_bridge::storage::bridge_pool::{ self, get_key_from_hash, get_nonce_key, get_signed_root_key, @@ -782,18 +777,17 @@ mod test_finalize_block { }; use namada::proof_of_stake::{unjail_validator, ADDRESS as pos_address}; use namada::replay_protection; - use namada::state::StorageWrite; + use namada::tendermint::abci::types::{Misbehavior, MisbehaviorKind}; use namada::token::{Amount, DenominatedAmount, NATIVE_MAX_DECIMAL_PLACES}; - use namada::tx::data::{Fee, WrapperTx}; - use namada::tx::{Code, Data, Section, Signature}; - use namada::vote_ext::{ethereum_events, EthereumTxData}; + use namada::tx::data::Fee; + use namada::tx::{Code, Data, Signature}; + use namada::vote_ext::ethereum_events; use namada_sdk::eth_bridge::MinimumConfirmations; use namada_sdk::governance::ProposalVote; use namada_sdk::proof_of_stake::storage::{ liveness_missed_votes_handle, liveness_sum_missed_votes_handle, read_consensus_validator_set_addresses, }; - use namada_sdk::tendermint::abci::types::MisbehaviorKind; use namada_sdk::validity_predicate::VpSentinel; use namada_test_utils::tx_data::TxWriteData; use namada_test_utils::TestWasms; diff --git a/crates/apps/src/lib/node/ledger/shell/governance.rs b/crates/apps/src/lib/node/ledger/shell/governance.rs index 2b5f096120a..e568f5e2123 100644 --- a/crates/apps/src/lib/node/ledger/shell/governance.rs +++ b/crates/apps/src/lib/node/ledger/shell/governance.rs @@ -1,7 +1,5 @@ -use std::cell::RefCell; use std::collections::HashMap; -use namada::core::address::Address; use namada::core::encode; use namada::core::event::EmitEvents; use namada::core::storage::Epoch; @@ -17,6 +15,7 @@ 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::proof_of_stake::bond_amount; @@ -24,7 +23,6 @@ use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::storage::read_total_stake; use namada::state::StorageWrite; use namada::tx::{Code, Data}; -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 950927d0873..8982367b788 100644 --- a/crates/apps/src/lib/node/ledger/shell/init_chain.rs +++ b/crates/apps/src/lib/node/ledger/shell/init_chain.rs @@ -9,6 +9,7 @@ use namada::account::protocol_pk_key; use namada::core::hash::Hash as CodeHash; use namada::core::time::{TimeZone, Utc}; use namada::ledger::parameters::Parameters; +use namada::ledger::{ibc, pos}; use namada::proof_of_stake::BecomeValidator; use namada::state::StorageWrite; use namada::token::{credit_tokens, write_denom}; diff --git a/crates/apps/src/lib/node/ledger/shell/mod.rs b/crates/apps/src/lib/node/ledger/shell/mod.rs index db0003d2fa3..e144794e2c2 100644 --- a/crates/apps/src/lib/node/ledger/shell/mod.rs +++ b/crates/apps/src/lib/node/ledger/shell/mod.rs @@ -1422,6 +1422,7 @@ mod test_utils { use super::*; use crate::config::ethereum_bridge::ledger::ORACLE_CHANNEL_BUFFER_SIZE; + 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, @@ -2066,9 +2067,7 @@ mod test_utils { #[cfg(test)] mod shell_tests { - use namada::core::ethereum_events::EthereumEvent; - use namada::core::key::RefTo; - use namada::core::storage::{BlockHeight, Epoch}; + use namada::core::storage::Epoch; use namada::replay_protection; use namada::token::read_denom; use namada::tx::data::protocol::{ProtocolTx, ProtocolTxType}; 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 08b70dd89a0..73648c7207a 100644 --- a/crates/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/crates/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -654,16 +654,14 @@ where /// are covered by the e2e tests. #[cfg(test)] mod test_process_proposal { - use namada::core::ethereum_events::EthereumEvent; use namada::core::key::*; use namada::core::storage::Epoch; - use namada::core::time::DateTimeUtc; + use namada::replay_protection; use namada::state::StorageWrite; use namada::token::{read_denom, Amount, DenominatedAmount}; use namada::tx::data::Fee; use namada::tx::{Code, Data, Signature, Signed}; use namada::vote_ext::{bridge_pool_roots, ethereum_events}; - use namada::{replay_protection, token}; use super::*; use crate::node::ledger::shell::test_utils::{ diff --git a/crates/apps/src/lib/node/ledger/shell/queries.rs b/crates/apps/src/lib/node/ledger/shell/queries.rs index 71508ccbfd8..fd1ad1f2216 100644 --- a/crates/apps/src/lib/node/ledger/shell/queries.rs +++ b/crates/apps/src/lib/node/ledger/shell/queries.rs @@ -2,7 +2,6 @@ use namada::ledger::dry_run_tx; use namada::ledger::queries::{RequestCtx, ResponseQuery}; -use namada::token; use super::*; diff --git a/crates/merkle_tree/src/lib.rs b/crates/merkle_tree/src/lib.rs index 5e2318f52e0..45fd45653ce 100644 --- a/crates/merkle_tree/src/lib.rs +++ b/crates/merkle_tree/src/lib.rs @@ -25,7 +25,7 @@ use namada_core::storage::{ self, BlockHeight, DbKeySeg, Epoch, Error as StorageError, Key, KeySeg, StringKey, TreeBytes, TreeKeyError, IBC_KEY_LIMIT, }; -use namada_core::{self, decode, DecodeError}; +use namada_core::{decode, DecodeError}; use thiserror::Error; /// Trait for reading from a merkle tree that is a sub-tree diff --git a/crates/namada/src/ledger/native_vp/multitoken.rs b/crates/namada/src/ledger/native_vp/multitoken.rs index de1b7d82b78..1286fa1a67e 100644 --- a/crates/namada/src/ledger/native_vp/multitoken.rs +++ b/crates/namada/src/ledger/native_vp/multitoken.rs @@ -222,7 +222,6 @@ mod tests { use namada_tx::{Code, Data, Section, Signature}; use super::*; - use crate::address::{Address, InternalAddress}; use crate::core::address::testing::{ established_address_1, established_address_2, nam, }; diff --git a/crates/namada/src/vm/wasm/run.rs b/crates/namada/src/vm/wasm/run.rs index 87831bbb178..817e5c6432b 100644 --- a/crates/namada/src/vm/wasm/run.rs +++ b/crates/namada/src/vm/wasm/run.rs @@ -630,7 +630,6 @@ mod tests { use wasmer_vm::TrapCode; use super::*; - use crate::hash::Hash; use crate::state::testing::TestState; use crate::tx::data::eval_vp::EvalVp; use crate::vm::host_env::TxRuntimeError; diff --git a/crates/proof_of_stake/src/lib.rs b/crates/proof_of_stake/src/lib.rs index 21e63c905d8..06edfc0b1f8 100644 --- a/crates/proof_of_stake/src/lib.rs +++ b/crates/proof_of_stake/src/lib.rs @@ -2928,13 +2928,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 pred_epochs.get_epoch(BlockHeight(evidence_height)) { Some(epoch) => epoch, diff --git a/crates/sdk/src/eth_bridge/bridge_pool.rs b/crates/sdk/src/eth_bridge/bridge_pool.rs index 13ecfe62dc3..81fe057eb00 100644 --- a/crates/sdk/src/eth_bridge/bridge_pool.rs +++ b/crates/sdk/src/eth_bridge/bridge_pool.rs @@ -1219,6 +1219,8 @@ mod recommendations { #[cfg(test)] mod test_recommendations { + use namada_core::address; + use super::*; use crate::io::StdIo; diff --git a/crates/sdk/src/masp.rs b/crates/sdk/src/masp.rs index 4570d72d09f..54442510e5a 100644 --- a/crates/sdk/src/masp.rs +++ b/crates/sdk/src/masp.rs @@ -2856,10 +2856,11 @@ pub mod testing { use masp_primitives::ff::Field; use masp_primitives::sapling::prover::TxProver; use masp_primitives::sapling::redjubjub::Signature; - use masp_primitives::sapling::{PaymentAddress, ProofGenerationKey, Rseed}; + use masp_primitives::sapling::{ProofGenerationKey, Rseed}; use masp_primitives::transaction::components::GROTH_PROOF_SIZE; use masp_proofs::bellman::groth16::Proof; use proptest::prelude::*; + use proptest::sample::SizeRange; use proptest::test_runner::TestRng; use proptest::{collection, option, prop_compose}; diff --git a/crates/sdk/src/queries/shell/eth_bridge.rs b/crates/sdk/src/queries/shell/eth_bridge.rs index 2a75469b761..766d1914278 100644 --- a/crates/sdk/src/queries/shell/eth_bridge.rs +++ b/crates/sdk/src/queries/shell/eth_bridge.rs @@ -831,9 +831,7 @@ mod test_ethbridge_router { use namada_core::eth_bridge_pool::{ GasFee, TransferToEthereum, TransferToEthereumKind, }; - use namada_core::voting_power::{ - EthBridgeVotingPower, FractionalVotingPower, - }; + use namada_core::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, diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 6012a490ae8..afe728c4fa9 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -654,7 +654,7 @@ mod tests { use namada_core::storage::DbKeySeg; use namada_core::time::{self, DateTimeUtc, Duration}; use namada_core::token; - use namada_parameters::EpochDuration; + use namada_parameters::{EpochDuration, Parameters}; use proptest::prelude::*; use proptest::test_runner::Config; // Use `RUST_LOG=info` (or another tracing level) and `--nocapture` to diff --git a/crates/state/src/wl_state.rs b/crates/state/src/wl_state.rs index c07edb34684..c90403ea3c4 100644 --- a/crates/state/src/wl_state.rs +++ b/crates/state/src/wl_state.rs @@ -849,14 +849,14 @@ where .block .pred_epochs .get_epoch(height) - .unwrap_or(Epoch::default()); + .unwrap_or_default(); let epoch_start_height = match self .in_mem .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), }; diff --git a/crates/storage/src/mockdb.rs b/crates/storage/src/mockdb.rs index 43eb0915dbb..4128321e547 100644 --- a/crates/storage/src/mockdb.rs +++ b/crates/storage/src/mockdb.rs @@ -18,7 +18,7 @@ use namada_core::{decode, encode, ethereum_events, ethereum_structs}; use namada_merkle_tree::{ base_tree_key_prefix, subtree_key_prefix, MerkleTreeStoresRead, StoreType, }; -use {namada_core, namada_replay_protection as replay_protection}; +use namada_replay_protection as replay_protection; use crate::conversion_state::ConversionState; use crate::db::{ diff --git a/crates/tests/src/vm_host_env/tx.rs b/crates/tests/src/vm_host_env/tx.rs index 78d1b44f31a..3f67644fb24 100644 --- a/crates/tests/src/vm_host_env/tx.rs +++ b/crates/tests/src/vm_host_env/tx.rs @@ -238,8 +238,6 @@ impl TestTxEnv { /// invoked host environment functions and so it must be initialized /// before the test. mod native_tx_host_env { - - use std::cell::RefCell; use std::pin::Pin; // TODO replace with `std::concat_idents` once stabilized (https://github.com/rust-lang/rust/issues/29599) diff --git a/crates/tests/src/vm_host_env/vp.rs b/crates/tests/src/vm_host_env/vp.rs index e79eb8f2dfb..d36e73dce90 100644 --- a/crates/tests/src/vm_host_env/vp.rs +++ b/crates/tests/src/vm_host_env/vp.rs @@ -106,8 +106,6 @@ impl TestVpEnv { /// invoked host environment functions and so it must be initialized /// before the test. mod native_vp_host_env { - - use std::cell::RefCell; use std::pin::Pin; // TODO replace with `std::concat_idents` once stabilized (https://github.com/rust-lang/rust/issues/29599) diff --git a/crates/vote_ext/src/ethereum_events.rs b/crates/vote_ext/src/ethereum_events.rs index 03675aa4446..2d74964acc8 100644 --- a/crates/vote_ext/src/ethereum_events.rs +++ b/crates/vote_ext/src/ethereum_events.rs @@ -147,7 +147,7 @@ impl VextDigest { #[cfg(test)] mod tests { - use namada_core::ethereum_events::{EthereumEvent, Uint}; + use namada_core::ethereum_events::Uint; use namada_core::hash::Hash; use namada_core::{address, key};