Skip to content

Commit

Permalink
chore: use is_zero fn
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jan 15, 2024
1 parent c5fd67b commit 8ebf34c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ impl EthApi {
node_info!("anvil_mine");
let interval = interval.map(|i| i.to::<u64>());
let blocks = num_blocks.unwrap_or(U256::from(1));
if blocks == U256::ZERO {
if blocks.is_zero() {
return Ok(());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ impl Backend {

let mut env = self.env.read().clone();

if env.block.basefee == revm::primitives::U256::ZERO {
if env.block.basefee.is_zero() {
// this is an edge case because the evm fails if `tx.effective_gas_price < base_fee`
// 0 is only possible if it's manually set
env.cfg.disable_base_fee = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl FeeManager {
// It's naturally impossible for base fee to be 0;
// It means it was set by the user deliberately and therefore we treat it as a constant.
// Therefore, we skip the base fee calculation altogether and we return 0.
if self.base_fee() == U256::ZERO {
if self.base_fee().is_zero() {
return 0
}
calculate_next_block_base_fee(
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/core/src/fork/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl MemDb {
acc_storage.clear();
}
for (index, value) in acc.storage {
if value.present_value() == U256::from(0) {
if value.present_value().is_zero() {
acc_storage.remove(&index);
} else {
acc_storage.insert(index, value.present_value());
Expand Down
4 changes: 2 additions & 2 deletions crates/evm/traces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#[macro_use]
extern crate tracing;

use alloy_primitives::{LogData, U256};
use alloy_primitives::LogData;
use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact};
use foundry_evm_core::constants::CHEATCODE_ADDRESS;
use futures::{future::BoxFuture, FutureExt};
Expand Down Expand Up @@ -200,7 +200,7 @@ pub async fn render_trace(
"{addr}::{func_name}{opt_value}({inputs}){action}",
addr = color.paint(decoded.label.as_deref().unwrap_or(&address)),
func_name = color.paint(func_name),
opt_value = if trace.value == U256::ZERO {
opt_value = if trace.value.is_zero() {
String::new()
} else {
format!("{{value: {}}}", trace.value)
Expand Down

0 comments on commit 8ebf34c

Please sign in to comment.