Skip to content

Commit 5e79018

Browse files
committed
fmt
1 parent 6a4e7e8 commit 5e79018

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+421
-403
lines changed

crates/anvil/core/src/eth/serde_helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod sequence {
2525
return Err(serde::de::Error::custom(format!(
2626
"expected params sequence with length 1 but got {}",
2727
seq.len()
28-
)))
28+
)));
2929
}
3030
Ok(seq.remove(0))
3131
}
@@ -44,7 +44,7 @@ pub mod empty_params {
4444
return Err(serde::de::Error::custom(format!(
4545
"expected params sequence with length 0 but got {}",
4646
seq.len()
47-
)))
47+
)));
4848
}
4949
Ok(())
5050
}

crates/anvil/core/src/eth/transaction/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl MaybeImpersonatedTransaction {
209209
/// Returns the hash of the transaction
210210
pub fn hash(&self) -> B256 {
211211
if let Some(sender) = self.impersonated_sender {
212-
return self.transaction.impersonated_hash(sender)
212+
return self.transaction.impersonated_hash(sender);
213213
}
214214
self.transaction.hash()
215215
}
@@ -1042,7 +1042,7 @@ impl Encodable2718 for TypedTransaction {
10421042
impl Decodable2718 for TypedTransaction {
10431043
fn typed_decode(ty: u8, buf: &mut &[u8]) -> Result<Self, Eip2718Error> {
10441044
if ty == 0x7E {
1045-
return Ok(Self::Deposit(DepositTransaction::decode(buf)?))
1045+
return Ok(Self::Deposit(DepositTransaction::decode(buf)?));
10461046
}
10471047
match TxEnvelope::typed_decode(ty, buf)? {
10481048
TxEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)),

crates/anvil/server/src/ipc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl tokio_util::codec::Decoder for JsonRpcCodec {
159159
return match String::from_utf8(bts.as_ref().to_vec()) {
160160
Ok(val) => Ok(Some(val)),
161161
Err(_) => Ok(None),
162-
}
162+
};
163163
}
164164
}
165165
Ok(None)

crates/anvil/server/src/pubsub.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<Handler: PubSubRpcHandler> PubSubContext<Handler> {
6868
let mut subscriptions = self.subscriptions.lock();
6969
if let Some(idx) = subscriptions.iter().position(|(i, _)| id == i) {
7070
trace!(target: "rpc", ?id, "removed subscription");
71-
return Some(subscriptions.swap_remove(idx).1)
71+
return Some(subscriptions.swap_remove(idx).1);
7272
}
7373
None
7474
}
@@ -174,7 +174,7 @@ where
174174
error!(target: "rpc", ?err, "Failed to send message");
175175
}
176176
} else {
177-
break
177+
break;
178178
}
179179
}
180180

@@ -183,7 +183,7 @@ where
183183
if let Poll::Ready(Err(err)) = pin.connection.poll_flush_unpin(cx) {
184184
trace!(target: "rpc", ?err, "websocket err");
185185
// close the connection
186-
return Poll::Ready(())
186+
return Poll::Ready(());
187187
}
188188

189189
loop {
@@ -195,25 +195,25 @@ where
195195
Err(err) => match err {
196196
RequestError::Axum(err) => {
197197
trace!(target: "rpc", ?err, "client disconnected");
198-
return Poll::Ready(())
198+
return Poll::Ready(());
199199
}
200200
RequestError::Io(err) => {
201201
trace!(target: "rpc", ?err, "client disconnected");
202-
return Poll::Ready(())
202+
return Poll::Ready(());
203203
}
204204
RequestError::Serde(err) => {
205205
pin.process_request(Err(err));
206206
}
207207
RequestError::Disconnect => {
208208
trace!(target: "rpc", "client disconnected");
209-
return Poll::Ready(())
209+
return Poll::Ready(());
210210
}
211211
},
212212
_ => {}
213213
},
214214
Poll::Ready(None) => {
215215
trace!(target: "rpc", "socket connection finished");
216-
return Poll::Ready(())
216+
return Poll::Ready(());
217217
}
218218
Poll::Pending => break,
219219
}
@@ -256,7 +256,7 @@ where
256256
}
257257

258258
if !progress {
259-
return Poll::Pending
259+
return Poll::Pending;
260260
}
261261
}
262262
}

crates/anvil/src/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn run_command(args: Anvil) -> Result<()> {
4242
&mut std::io::stdout(),
4343
),
4444
}
45-
return Ok(())
45+
return Ok(());
4646
}
4747

4848
let _ = fdlimit::raise_fd_limit();

crates/anvil/src/cmd.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ impl Future for PeriodicStateDumper {
653653
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
654654
let this = self.get_mut();
655655
if this.dump_state.is_none() {
656-
return Poll::Pending
656+
return Poll::Pending;
657657
}
658658

659659
loop {
@@ -664,7 +664,7 @@ impl Future for PeriodicStateDumper {
664664
}
665665
Poll::Pending => {
666666
this.in_progress_dump = Some(flush);
667-
return Poll::Pending
667+
return Poll::Pending;
668668
}
669669
}
670670
}
@@ -675,7 +675,7 @@ impl Future for PeriodicStateDumper {
675675
this.in_progress_dump =
676676
Some(Box::pin(Self::dump_state(api, path, this.preserve_historical_states)));
677677
} else {
678-
break
678+
break;
679679
}
680680
}
681681

@@ -705,7 +705,7 @@ impl StateFile {
705705
}
706706
let mut state = Self { path, state: None };
707707
if !state.path.exists() {
708-
return Ok(state)
708+
return Ok(state);
709709
}
710710

711711
state.state = Some(SerializableState::load(&state.path).map_err(|err| err.to_string())?);
@@ -740,14 +740,14 @@ impl FromStr for ForkUrl {
740740
fn from_str(s: &str) -> Result<Self, Self::Err> {
741741
if let Some((url, block)) = s.rsplit_once('@') {
742742
if block == "latest" {
743-
return Ok(Self { url: url.to_string(), block: None })
743+
return Ok(Self { url: url.to_string(), block: None });
744744
}
745745
// this will prevent false positives for auths `user:[email protected]`
746746
if !block.is_empty() && !block.contains(':') && !block.contains('.') {
747747
let block: u64 = block
748748
.parse()
749749
.map_err(|_| format!("Failed to parse block number: `{block}`"))?;
750-
return Ok(Self { url: url.to_string(), block: Some(block) })
750+
return Ok(Self { url: url.to_string(), block: Some(block) });
751751
}
752752
}
753753
Ok(Self { url: s.to_string(), block: None })

crates/anvil/src/eth/api.rs

+21-18
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl EthApi {
373373
if time >= U256::from(u64::MAX) {
374374
return ResponseResult::Error(RpcError::invalid_params(
375375
"The timestamp is too big",
376-
))
376+
));
377377
}
378378
let time = time.to::<u64>();
379379
self.evm_set_next_block_timestamp(time).to_rpc_result()
@@ -382,7 +382,7 @@ impl EthApi {
382382
if timestamp >= U256::from(u64::MAX) {
383383
return ResponseResult::Error(RpcError::invalid_params(
384384
"The timestamp is too big",
385-
))
385+
));
386386
}
387387
let time = timestamp.to::<u64>();
388388
self.evm_set_time(time).to_rpc_result()
@@ -491,13 +491,13 @@ impl EthApi {
491491
B256::with_last_byte(1),
492492
false,
493493
);
494-
return build_typed_transaction(request, nil_signature)
494+
return build_typed_transaction(request, nil_signature);
495495
}
496496
_ => {
497497
for signer in self.signers.iter() {
498498
if signer.accounts().contains(from) {
499499
let signature = signer.sign_transaction(request.clone(), from)?;
500-
return build_typed_transaction(request, signature)
500+
return build_typed_transaction(request, signature);
501501
}
502502
}
503503
}
@@ -688,7 +688,7 @@ impl EthApi {
688688
if let BlockRequest::Number(number) = block_request {
689689
if let Some(fork) = self.get_fork() {
690690
if fork.predates_fork(number) {
691-
return Ok(fork.get_balance(address, number).await?)
691+
return Ok(fork.get_balance(address, number).await?);
692692
}
693693
}
694694
}
@@ -711,7 +711,7 @@ impl EthApi {
711711
if let BlockRequest::Number(number) = block_request {
712712
if let Some(fork) = self.get_fork() {
713713
if fork.predates_fork(number) {
714-
return Ok(fork.get_account(address, number).await?)
714+
return Ok(fork.get_account(address, number).await?);
715715
}
716716
}
717717
}
@@ -868,7 +868,7 @@ impl EthApi {
868868
if let BlockRequest::Number(number) = block_request {
869869
if let Some(fork) = self.get_fork() {
870870
if fork.predates_fork(number) {
871-
return Ok(fork.get_code(address, number).await?)
871+
return Ok(fork.get_code(address, number).await?);
872872
}
873873
}
874874
}
@@ -893,7 +893,7 @@ impl EthApi {
893893
if let BlockRequest::Number(number) = block_request {
894894
if let Some(fork) = self.get_fork() {
895895
if fork.predates_fork_inclusive(number) {
896-
return Ok(fork.get_proof(address, keys, Some(number.into())).await?)
896+
return Ok(fork.get_proof(address, keys, Some(number.into())).await?);
897897
}
898898
}
899899
}
@@ -1079,7 +1079,7 @@ impl EthApi {
10791079
"not available on past forked blocks".to_string(),
10801080
));
10811081
}
1082-
return Ok(fork.call(&request, Some(number.into())).await?)
1082+
return Ok(fork.call(&request, Some(number.into())).await?);
10831083
}
10841084
}
10851085
}
@@ -1127,7 +1127,7 @@ impl EthApi {
11271127
if let BlockRequest::Number(number) = block_request {
11281128
if let Some(fork) = self.get_fork() {
11291129
if fork.predates_fork(number) {
1130-
return Ok(fork.create_access_list(&request, Some(number.into())).await?)
1130+
return Ok(fork.create_access_list(&request, Some(number.into())).await?);
11311131
}
11321132
}
11331133
}
@@ -1271,7 +1271,7 @@ impl EthApi {
12711271
self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?;
12721272
if let Some(fork) = self.get_fork() {
12731273
if fork.predates_fork_inclusive(number) {
1274-
return Ok(fork.uncle_by_block_hash_and_index(block_hash, idx.into()).await?)
1274+
return Ok(fork.uncle_by_block_hash_and_index(block_hash, idx.into()).await?);
12751275
}
12761276
}
12771277
// It's impossible to have uncles outside of fork mode
@@ -1290,7 +1290,7 @@ impl EthApi {
12901290
let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?;
12911291
if let Some(fork) = self.get_fork() {
12921292
if fork.predates_fork_inclusive(number) {
1293-
return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?)
1293+
return Ok(fork.uncle_by_block_number_and_index(number, idx.into()).await?);
12941294
}
12951295
}
12961296
// It's impossible to have uncles outside of fork mode
@@ -2449,7 +2449,7 @@ impl EthApi {
24492449
// Validate the request
24502450
// reject transactions that have a non-zero value to prevent draining the executor.
24512451
if request.value.is_some_and(|val| val > U256::ZERO) {
2452-
return Err(WalletError::ValueNotZero.into())
2452+
return Err(WalletError::ValueNotZero.into());
24532453
}
24542454

24552455
// reject transactions that have from set, as this will be the executor.
@@ -2623,7 +2623,7 @@ impl EthApi {
26232623
"not available on past forked blocks".to_string(),
26242624
));
26252625
}
2626-
return Ok(fork.estimate_gas(&request, Some(number.into())).await?)
2626+
return Ok(fork.estimate_gas(&request, Some(number.into())).await?);
26272627
}
26282628
}
26292629
}
@@ -2984,7 +2984,7 @@ impl EthApi {
29842984
if let BlockRequest::Number(number) = block_request {
29852985
if let Some(fork) = self.get_fork() {
29862986
if fork.predates_fork(number) {
2987-
return Ok(fork.get_nonce(address, number).await?)
2987+
return Ok(fork.get_nonce(address, number).await?);
29882988
}
29892989
}
29902990
}
@@ -3123,9 +3123,12 @@ impl TryFrom<Result<(InstructionResult, Option<Output>, u128, State)>> for GasEs
31233123
}
31243124
Err(err) => Err(err),
31253125
Ok((exit, output, gas, _)) => match exit {
3126-
InstructionResult::Continue | InstructionResult::Stop |
3127-
InstructionResult::Return | InstructionResult::SelfDestruct |
3128-
InstructionResult::ReturnContract | InstructionResult::CallOrCreate => Ok(Self::Success(gas)),
3126+
InstructionResult::Continue |
3127+
InstructionResult::Stop |
3128+
InstructionResult::Return |
3129+
InstructionResult::SelfDestruct |
3130+
InstructionResult::ReturnContract |
3131+
InstructionResult::CallOrCreate => Ok(Self::Success(gas)),
31293132

31303133
InstructionResult::Revert => Ok(Self::Revert(output.map(|o| o.into_data()))),
31313134

crates/anvil/src/eth/backend/cheats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl CheatsManager {
2727
// which does not check that list when auto impersonation is enabled.
2828
if state.impersonated_accounts.contains(&addr) {
2929
// need to check if already impersonated, so we don't overwrite the code
30-
return true
30+
return true;
3131
}
3232
state.impersonated_accounts.insert(addr)
3333
}

crates/anvil/src/eth/backend/executor.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ impl<DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'_, DB, V> {
148148
}
149149
TransactionExecutionOutcome::Exhausted(tx) => {
150150
trace!(target: "backend", tx_gas_limit = %tx.pending_transaction.transaction.gas_limit(), ?tx, "block gas limit exhausting, skipping transaction");
151-
continue
151+
continue;
152152
}
153153
TransactionExecutionOutcome::BlobGasExhausted(tx) => {
154154
trace!(target: "backend", blob_gas = %tx.pending_transaction.transaction.blob_gas().unwrap_or_default(), ?tx, "block blob gas limit exhausting, skipping transaction");
155-
continue
155+
continue;
156156
}
157157
TransactionExecutionOutcome::Invalid(tx, _) => {
158158
trace!(target: "backend", ?tx, "skipping invalid transaction");
159159
invalid.push(tx);
160-
continue
160+
continue;
161161
}
162162
TransactionExecutionOutcome::DatabaseError(_, err) => {
163163
// Note: this is only possible in forking mode, if for example a rpc request
164164
// failed
165165
trace!(target: "backend", ?err, "Failed to execute transaction due to database error");
166-
continue
166+
continue;
167167
}
168168
};
169169
if is_cancun {
@@ -281,15 +281,15 @@ impl<DB: Db + ?Sized, V: TransactionValidator> Iterator for &mut TransactionExec
281281
// check that we comply with the block's gas limit, if not disabled
282282
let max_gas = self.gas_used.saturating_add(env.tx.gas_limit);
283283
if !env.cfg.disable_block_gas_limit && max_gas > env.block.gas_limit.to::<u64>() {
284-
return Some(TransactionExecutionOutcome::Exhausted(transaction))
284+
return Some(TransactionExecutionOutcome::Exhausted(transaction));
285285
}
286286

287287
// check that we comply with the block's blob gas limit
288288
let max_blob_gas = self.blob_gas_used.saturating_add(
289289
transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0),
290290
);
291291
if max_blob_gas > alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK {
292-
return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction))
292+
return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction));
293293
}
294294

295295
// validate before executing
@@ -299,7 +299,7 @@ impl<DB: Db + ?Sized, V: TransactionValidator> Iterator for &mut TransactionExec
299299
&env,
300300
) {
301301
warn!(target: "backend", "Skipping invalid tx execution [{:?}] {}", transaction.hash(), err);
302-
return Some(TransactionExecutionOutcome::Invalid(transaction, err))
302+
return Some(TransactionExecutionOutcome::Invalid(transaction, err));
303303
}
304304

305305
let nonce = account.nonce;

0 commit comments

Comments
 (0)