Skip to content

Commit

Permalink
fix new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed May 21, 2024
1 parent b7b525e commit 2be8d18
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 42 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ masp_primitives = { git = "https://github.com/anoma/masp", rev = "6fc4692841a224
masp_proofs = { git = "https://github.com/anoma/masp", rev = "6fc4692841a2241633792c429cc66b42023e5bf3", default-features = false, features = ["local-prover"] }
num256 = "0.3.5"
num_cpus = "1.13.0"
num-derive = "0.3.3"
num-derive = "0.4"
num-rational = "0.4.1"
num-traits = "0.2.14"
once_cell = "1.8.0"
Expand Down
6 changes: 4 additions & 2 deletions crates/core/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,16 +1083,18 @@ macro_rules! impl_int_key_seg {

impl KeySeg for $signed {
fn parse(string: String) -> Result<Self> {
// get signed int from a unsigned int complemented with a min
// get signed int from a unsigned int complemented with a max
// value
let complemented = <$unsigned>::parse(string)?;
#[allow(clippy::cast_possible_wrap)]
let signed = (complemented as $signed) ^ <$signed>::MIN;
Ok(signed)
}

fn raw(&self) -> String {
// signed int is converted to unsigned int that preserves the
// order by complementing it with a min value
// order by complementing it with a max value
#[allow(clippy::cast_sign_loss)]
let complemented = (*self ^ <$signed>::MIN) as $unsigned;
complemented.raw()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Uint {
q_hat
} else {
// here q_hat >= q_j >= q_hat - 1
u64::max_value()
u64::MAX
};

// ex. 20:
Expand Down
4 changes: 2 additions & 2 deletions crates/merkle_tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ mod test {
&value,
));
// for the verification of the base tree
value = sub_root.clone();
value.clone_from(&sub_root);
}
// Check the base root
assert_eq!(sub_root, tree.root().0);
Expand Down Expand Up @@ -1486,7 +1486,7 @@ mod test {
&value,
));
// for the verification of the base tree
value = sub_root.clone();
value.clone_from(&sub_root);
}
// Check the base root
assert_eq!(sub_root, tree.root().0);
Expand Down
2 changes: 2 additions & 0 deletions crates/namada/src/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ mod test {
/// tx wasm compilation cache
pub tx_wasm_cache: TxCache<WasmCacheRoAccess>,
/// VP wasm compilation cache directory
#[allow(dead_code)] // never read
pub vp_cache_dir: TempDir,
/// tx wasm compilation cache directory
#[allow(dead_code)] // never read
pub tx_cache_dir: TempDir,
}

Expand Down
6 changes: 2 additions & 4 deletions crates/node/src/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,7 @@ pub struct BenchShieldedUtils {
context_dir: WrapperTempDir,
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl ShieldedUtils for BenchShieldedUtils {
fn local_tx_prover(&self) -> LocalTxProver {
if let Ok(params_dir) = std::env::var(masp::ENV_VAR_MASP_PARAMS_DIR) {
Expand Down Expand Up @@ -768,8 +767,7 @@ impl ShieldedUtils for BenchShieldedUtils {
}
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl Client for BenchShell {
type Error = std::io::Error;

Expand Down
12 changes: 3 additions & 9 deletions crates/node/src/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5436,9 +5436,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications are missing
Expand Down Expand Up @@ -5554,9 +5552,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications are missing
Expand Down Expand Up @@ -5603,9 +5599,7 @@ mod test_finalize_block {
);
// Assert that the last tx didn't run
assert!(
inner_results
.get(&batch.commitments()[2].get_hash())
.is_none()
!inner_results.contains_key(&batch.commitments()[2].get_hash())
);

// Check storage modifications
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ where
response.code = ResultCode::InvalidTx.into();
response.log = "The wrapper gas limit overflowed gas \
representation"
.to_owned();
.to_string();
return response;
}
};
Expand Down
1 change: 1 addition & 0 deletions crates/node/src/shell/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ where
// NOTE: we are testing `namada::ledger::queries_ext`,
// which is not possible from `namada` since we do not have
// access to the `Shell` there
#[allow(clippy::cast_possible_truncation)]
#[cfg(test)]
mod test_queries {
use namada::core::storage::Epoch;
Expand Down
3 changes: 1 addition & 2 deletions crates/node/src/shell/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,7 @@ impl MockNode {
}
}

#[cfg_attr(feature = "async-send", async_trait::async_trait)]
#[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))]
#[async_trait::async_trait(?Send)]
impl<'a> Client for &'a MockNode {
type Error = Report;

Expand Down
8 changes: 0 additions & 8 deletions crates/proof_of_stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,6 @@ where
total_consensus_stake_handle().set(storage, total, epoch, 0)
}

/// Used below in `fn unbond_tokens` to update the bond and unbond amounts
#[derive(Eq, Hash, PartialEq)]
struct BondAndUnbondUpdates {
bond_start: Epoch,
new_bond_value: token::Change,
unbond_value: token::Change,
}

/// Unbond tokens that are bonded between a validator and a source (self or
/// delegator).
///
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ version.workspace = true
[features]
default = ["tendermint-rpc", "download-params", "std", "rand", "migrations"]

mainnet = ["namada_core/mainnet", "namada_events/mainnet"]

multicore = ["masp_proofs/multicore"]

namada-sdk = ["tendermint-rpc", "masp_primitives/transparent-inputs"]
Expand Down
8 changes: 8 additions & 0 deletions crates/sdk/src/queries/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,14 @@ macro_rules! router_type {
// paste the generated methods
$( $methods )*
}

impl Default for $name {
fn default() -> Self {
Self {
prefix: String::new(),
}
}
}
}
};

Expand Down
5 changes: 1 addition & 4 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ pub async fn process_tx(
pub async fn is_reveal_pk_needed<C: crate::queries::Client + Sync>(
client: &C,
address: &Address,
) -> Result<bool>
where
C: crate::queries::Client + Sync,
{
) -> Result<bool> {
// Check if PK revealed
Ok(!has_revealed_pk(client, address).await?)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ flate2.workspace = true
hyper = {version = "0.14.20", features = ["full"]}
ibc-testkit.workspace = true
ics23.workspace = true
itertools.workspace = true
lazy_static.workspace = true
num-traits.workspace = true
proptest.workspace = true
prost.workspace = true
regex.workspace = true
serde.workspace = true
Expand Down Expand Up @@ -74,10 +76,8 @@ escargot = {workspace = true} # , features = ["print"]}
expectrl.workspace = true
eyre.workspace = true
fs_extra.workspace = true
itertools.workspace = true
once_cell.workspace = true
pretty_assertions.workspace = true
proptest.workspace = true
proptest-state-machine.workspace = true
rand.workspace = true
tendermint-light-client.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//! To keep the temporary files created by a test, use env var
//! `NAMADA_E2E_KEEP_TEMP=true`.

#[cfg(DISABLED_UNTIL_ERC20_WHITELISTS_IMPLEMENTED)]
pub mod eth_bridge_tests;
// Disabled until erc20 whitelists implemented
// pub mod eth_bridge_tests;
pub mod helpers;
pub mod ibc_tests;
pub mod ledger_tests;
Expand Down
1 change: 0 additions & 1 deletion crates/tests/src/native_vp/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ mod tests {
}

/// Testing helpers
#[cfg(any(test, feature = "testing"))]
pub mod testing {

use std::cell::RefCell;
Expand Down
4 changes: 3 additions & 1 deletion wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion wasm_for_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2be8d18

Please sign in to comment.