Skip to content

chore: apply rust edition 2024 fmt #10803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions crates/anvil/core/src/eth/block.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::transaction::{TransactionInfo, TypedReceipt};
use alloy_consensus::{proofs::calculate_transaction_root, Header, EMPTY_OMMER_ROOT_HASH};
use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256};
use alloy_consensus::{EMPTY_OMMER_ROOT_HASH, Header, proofs::calculate_transaction_root};
use alloy_primitives::{Address, B64, B256, Bloom, Bytes, U256};
use alloy_rlp::{RlpDecodable, RlpEncodable};

// Type alias to optionally support impersonated transactions
Expand Down
16 changes: 4 additions & 12 deletions crates/anvil/core/src/eth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{eth::subscription::SubscriptionId, types::ReorgOptions};
use alloy_primitives::{Address, Bytes, TxHash, B256, B64, U256};
use alloy_primitives::{Address, B64, B256, Bytes, TxHash, U256};
use alloy_rpc_types::{
BlockId, BlockNumberOrTag as BlockNumber, BlockOverrides, Filter, Index,
anvil::{Forking, MineOptions},
pubsub::{Params as SubscriptionParams, SubscriptionKind},
request::TransactionRequest,
Expand All @@ -10,7 +11,6 @@ use alloy_rpc_types::{
filter::TraceFilter,
geth::{GethDebugTracingCallOptions, GethDebugTracingOptions},
},
BlockId, BlockNumberOrTag as BlockNumber, BlockOverrides, Filter, Index,
};
use alloy_serde::WithOtherFields;
use foundry_common::serde_helpers::{
Expand Down Expand Up @@ -325,23 +325,15 @@ pub enum EthRequest {
SetAutomine(bool),

/// Sets the mining behavior to interval with the given interval (seconds)
#[serde(
rename = "anvil_setIntervalMining",
alias = "evm_setIntervalMining",
with = "sequence"
)]
#[serde(rename = "anvil_setIntervalMining", alias = "evm_setIntervalMining", with = "sequence")]
SetIntervalMining(u64),

/// Gets the current mining behavior
#[serde(rename = "anvil_getIntervalMining", with = "empty_params")]
GetIntervalMining(()),

/// Removes transactions from the pool
#[serde(
rename = "anvil_dropTransaction",
alias = "hardhat_dropTransaction",
with = "sequence"
)]
#[serde(rename = "anvil_dropTransaction", alias = "hardhat_dropTransaction", with = "sequence")]
DropTransaction(B256),

/// Removes transactions from the pool
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/core/src/eth/serde_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub mod sequence {
use serde::{
de::DeserializeOwned, ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer,
Deserialize, Deserializer, Serialize, Serializer, de::DeserializeOwned, ser::SerializeSeq,
};

pub fn serialize<S, T>(val: &T, s: S) -> Result<S::Ok, S::Error>
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/core/src/eth/subscription.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Subscription types
use alloy_primitives::hex;
use rand::{distr::Alphanumeric, rng, Rng};
use rand::{Rng, distr::Alphanumeric, rng};
use std::fmt;

/// Unique subscription id
Expand Down
20 changes: 10 additions & 10 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! Transaction related types
use alloy_consensus::{
Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930,
TxEnvelope, TxLegacy, TxReceipt, Typed2718,
transaction::{
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
Recovered, TxEip7702,
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
},
Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930,
TxEnvelope, TxLegacy, TxReceipt, Typed2718,
};
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
use alloy_network::{AnyReceiptEnvelope, AnyRpcTransaction, AnyTransactionReceipt, AnyTxEnvelope};
use alloy_primitives::{Address, Bloom, Bytes, Log, Signature, TxHash, TxKind, B256, U256, U64};
use alloy_rlp::{length_of_length, Decodable, Encodable, Header};
use alloy_primitives::{Address, B256, Bloom, Bytes, Log, Signature, TxHash, TxKind, U64, U256};
use alloy_rlp::{Decodable, Encodable, Header, length_of_length};
use alloy_rpc_types::{
request::TransactionRequest, trace::otterscan::OtsReceipt, AccessList, ConversionError,
Transaction as RpcTransaction, TransactionReceipt,
AccessList, ConversionError, Transaction as RpcTransaction, TransactionReceipt,
request::TransactionRequest, trace::otterscan::OtsReceipt,
};
use alloy_serde::{OtherFields, WithOtherFields};
use bytes::BufMut;
use foundry_evm::traces::CallTraceNode;
use op_alloy_consensus::{TxDeposit, DEPOSIT_TX_TYPE_ID};
use op_revm::{transaction::deposit::DepositTransactionParts, OpTransaction};
use op_alloy_consensus::{DEPOSIT_TX_TYPE_ID, TxDeposit};
use op_revm::{OpTransaction, transaction::deposit::DepositTransactionParts};
use revm::{context::TxEnv, interpreter::InstructionResult};
use serde::{Deserialize, Serialize};
use std::ops::{Deref, Mul};
Expand Down Expand Up @@ -1461,7 +1461,7 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option<Receip

#[cfg(test)]
mod tests {
use alloy_primitives::{b256, hex, LogData};
use alloy_primitives::{LogData, b256, hex};
use std::str::FromStr;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/core/src/eth/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_primitives::{map::HashMap, Address, ChainId, U64};
use alloy_primitives::{Address, ChainId, U64, map::HashMap};
use serde::{Deserialize, Serialize};

/// The capability to perform [EIP-7702][eip-7702] delegations, sponsored by the sequencer.
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/server/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use anvil_rpc::{
response::{Response, RpcResponse},
};
use axum::{
extract::{rejection::JsonRejection, State},
Json,
extract::{State, rejection::JsonRejection},
};
use futures::{future, FutureExt};
use futures::{FutureExt, future};

/// Handles incoming JSON-RPC Request.
// NOTE: `handler` must come first because the `request` extractor consumes the request body.
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/server/src/ipc.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! IPC handling

use crate::{error::RequestError, pubsub::PubSubConnection, PubSubRpcHandler};
use crate::{PubSubRpcHandler, error::RequestError, pubsub::PubSubConnection};
use anvil_rpc::request::Request;
use bytes::{BufMut, BytesMut};
use futures::{ready, Sink, Stream, StreamExt};
use futures::{Sink, Stream, StreamExt, ready};
use interprocess::local_socket::{self as ls, tokio::prelude::*};
use std::{
io,
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use anvil_rpc::{
response::{ResponseResult, RpcResponse},
};
use axum::{
extract::DefaultBodyLimit,
http::{header, HeaderValue, Method},
routing::{post, MethodRouter},
Router,
extract::DefaultBodyLimit,
http::{HeaderValue, Method, header},
routing::{MethodRouter, post},
};
use serde::de::DeserializeOwned;
use std::fmt;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/server/src/pubsub.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{error::RequestError, handler::handle_request, RpcHandler};
use crate::{RpcHandler, error::RequestError, handler::handle_request};
use anvil_rpc::{
error::RpcError,
request::Request,
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/server/src/ws.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{error::RequestError, pubsub::PubSubConnection, PubSubRpcHandler};
use crate::{PubSubRpcHandler, error::RequestError, pubsub::PubSubConnection};
use anvil_rpc::request::Request;
use axum::{
extract::{
ws::{Message, WebSocket},
State, WebSocketUpgrade,
ws::{Message, WebSocket},
},
response::Response,
};
use futures::{ready, Sink, Stream};
use futures::{Sink, Stream, ready};
use std::{
pin::Pin,
task::{Context, Poll},
Expand Down
20 changes: 12 additions & 8 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
use crate::{
config::{ForkChoice, DEFAULT_MNEMONIC},
eth::{backend::db::SerializableState, pool::transactions::TransactionOrder, EthApi},
AccountGenerator, EthereumHardfork, NodeConfig, CHAIN_ID,
AccountGenerator, CHAIN_ID, EthereumHardfork, NodeConfig,
config::{DEFAULT_MNEMONIC, ForkChoice},
eth::{EthApi, backend::db::SerializableState, pool::transactions::TransactionOrder},
};
use alloy_genesis::Genesis;
use alloy_op_hardforks::OpHardfork;
use alloy_primitives::{utils::Unit, B256, U256};
use alloy_primitives::{B256, U256, utils::Unit};
use alloy_signer_local::coins_bip39::{English, Mnemonic};
use anvil_server::ServerConfig;
use clap::Parser;
use core::fmt;
use foundry_common::shell;
use foundry_config::{Chain, Config, FigmentProviders};
use futures::FutureExt;
use rand_08::{rngs::StdRng, SeedableRng};
use rand_08::{SeedableRng, rngs::StdRng};
use std::{
net::IpAddr,
path::{Path, PathBuf},
pin::Pin,
str::FromStr,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
},
task::{Context, Poll},
time::Duration,
Expand Down Expand Up @@ -919,11 +919,15 @@ mod tests {
["::1", "1.1.1.1", "2.2.2.2"].map(|ip| ip.parse::<IpAddr>().unwrap()).to_vec()
);

unsafe { env::set_var("ANVIL_IP_ADDR", "1.1.1.1"); }
unsafe {
env::set_var("ANVIL_IP_ADDR", "1.1.1.1");
}
let args = NodeArgs::parse_from(["anvil"]);
assert_eq!(args.host, vec!["1.1.1.1".parse::<IpAddr>().unwrap()]);

unsafe { env::set_var("ANVIL_IP_ADDR", "::1,1.1.1.1,2.2.2.2"); }
unsafe {
env::set_var("ANVIL_IP_ADDR", "::1,1.1.1.1,2.2.2.2");
}
let args = NodeArgs::parse_from(["anvil"]);
assert_eq!(
args.host,
Expand Down
18 changes: 10 additions & 8 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
EthereumHardfork, FeeManager, PrecompileFactory,
eth::{
backend::{
db::{Db, SerializableState},
Expand All @@ -11,28 +12,27 @@ use crate::{
fees::{INITIAL_BASE_FEE, INITIAL_GAS_PRICE},
pool::transactions::{PoolTransaction, TransactionOrder},
},
hardfork::{ethereum_hardfork_from_block_tag, spec_id_from_ethereum_hardfork, ChainHardfork},
hardfork::{ChainHardfork, ethereum_hardfork_from_block_tag, spec_id_from_ethereum_hardfork},
mem::{self, in_memory_db::MemDb},
EthereumHardfork, FeeManager, PrecompileFactory,
};
use alloy_consensus::BlockHeader;
use alloy_genesis::Genesis;
use alloy_network::{AnyNetwork, TransactionResponse};
use alloy_op_hardforks::OpHardfork;
use alloy_primitives::{hex, map::HashMap, utils::Unit, BlockNumber, TxHash, U256};
use alloy_primitives::{BlockNumber, TxHash, U256, hex, map::HashMap, utils::Unit};
use alloy_provider::Provider;
use alloy_rpc_types::{Block, BlockNumberOrTag};
use alloy_signer::Signer;
use alloy_signer_local::{
coins_bip39::{English, Mnemonic},
MnemonicBuilder, PrivateKeySigner,
coins_bip39::{English, Mnemonic},
};
use alloy_transport::TransportError;
use anvil_server::ServerConfig;
use eyre::{Context, Result};
use foundry_common::{
provider::{ProviderBuilder, RetryProvider},
ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT,
provider::{ProviderBuilder, RetryProvider},
};
use foundry_config::Config;
use foundry_evm::{
Expand All @@ -50,7 +50,7 @@ use revm::{
context_interface::block::BlobExcessGasAndPrice,
primitives::hardfork::SpecId,
};
use serde_json::{json, Value};
use serde_json::{Value, json};
use std::{
fmt::Write as FmtWrite,
fs::File,
Expand Down Expand Up @@ -429,8 +429,10 @@ impl NodeConfig {
impl Default for NodeConfig {
fn default() -> Self {
// generate some random wallets
let genesis_accounts =
AccountGenerator::new(10).phrase(DEFAULT_MNEMONIC).generate().expect("Invalid mnemonic.");
let genesis_accounts = AccountGenerator::new(10)
.phrase(DEFAULT_MNEMONIC)
.generate()
.expect("Invalid mnemonic.");
Self {
chain_id: None,
gas_limit: None,
Expand Down
Loading
Loading