fmt: run nightly-2023-10-15 and remove semicolons (#6035)

This commit is contained in:
rakita
2024-01-12 12:38:41 +01:00
committed by GitHub
parent 49621631a6
commit ee199bb5db
27 changed files with 161 additions and 167 deletions

View File

@ -190,7 +190,7 @@ impl Command {
if in_memory_state_root == block.state_root {
info!(target: "reth::cli", state_root = ?in_memory_state_root, "Computed in-memory state root matches");
return Ok(());
return Ok(())
}
let provider_rw = factory.provider_rw()?;

View File

@ -178,7 +178,7 @@ impl Command {
Ok(senders) => senders,
Err(err) => {
warn!(target: "reth::cli", "Error sealing block with senders: {err:?}. Skipping...");
continue;
continue
}
};
provider_rw.insert_block(sealed_block, None)?;
@ -278,7 +278,7 @@ impl Command {
let clean_result = merkle_stage.execute(&provider_rw, clean_input);
assert!(clean_result.is_ok(), "Clean state root calculation failed");
if clean_result.unwrap().done {
break;
break
}
}
@ -344,7 +344,7 @@ impl Command {
clean.1.nibbles.len() > self.skip_node_depth.unwrap_or_default()
{
first_mismatched_storage = Some((incremental, clean));
break;
break
}
}
(Some(incremental), None) => {

View File

@ -1189,7 +1189,7 @@ impl<DB: Database, EF: ExecutorFactory> BlockchainTree<DB, EF> {
block_number: tip.number,
block_hash: tip.hash,
},
))));
))))
}
self.metrics.trie_updates_insert_recomputed.increment(1);
trie_updates

View File

@ -339,21 +339,21 @@ where
) -> RethResult<OnForkChoiceUpdated> {
trace!(target: "consensus::engine", ?state, "Received new forkchoice state update");
if state.head_block_hash.is_zero() {
return Ok(OnForkChoiceUpdated::invalid_state());
return Ok(OnForkChoiceUpdated::invalid_state())
}
// check if the new head hash is connected to any ancestor that we previously marked as
// invalid
let lowest_buffered_ancestor_fcu = self.lowest_buffered_ancestor_or(state.head_block_hash);
if let Some(status) = self.check_invalid_ancestor(lowest_buffered_ancestor_fcu) {
return Ok(OnForkChoiceUpdated::with_invalid(status));
return Ok(OnForkChoiceUpdated::with_invalid(status))
}
if self.sync.is_pipeline_active() {
// We can only process new forkchoice updates if the pipeline is idle, since it requires
// exclusive access to the database
trace!(target: "consensus::engine", "Pipeline is syncing, skipping forkchoice update");
return Ok(OnForkChoiceUpdated::syncing());
return Ok(OnForkChoiceUpdated::syncing())
}
if let Some(hook) = self.hooks.active_db_write_hook() {
@ -365,7 +365,7 @@ where
"Hook is in progress, skipping forkchoice update. \
This may affect the performance of your node as a validator."
);
return Ok(OnForkChoiceUpdated::syncing());
return Ok(OnForkChoiceUpdated::syncing())
}
let start = Instant::now();
@ -434,7 +434,7 @@ where
// attributes
if let Some(invalid_fcu_response) = self.ensure_consistent_state(state)? {
trace!(target: "consensus::engine", ?state, head=?state.head_block_hash, "Forkchoice state is inconsistent, returning invalid response");
return Ok(invalid_fcu_response);
return Ok(invalid_fcu_response)
}
// the CL requested to build a new payload on top of this new VALID head
@ -445,7 +445,7 @@ where
);
trace!(target: "consensus::engine", status = ?payload_response, ?state, "Returning forkchoice status");
return Ok(payload_response);
return Ok(payload_response)
}
PayloadStatus::new(PayloadStatusEnum::Valid, Some(state.head_block_hash))
@ -454,7 +454,7 @@ where
if let RethError::Canonical(ref err) = error {
if err.is_fatal() {
tracing::error!(target: "consensus::engine", ?err, "Encountered fatal error");
return Err(error);
return Err(error)
}
}
@ -466,7 +466,7 @@ where
self.ensure_consistent_state_with_status(state, &status)?
{
trace!(target: "consensus::engine", ?status, ?state, "Forkchoice state is inconsistent, returning invalid response");
return Ok(invalid_fcu_response);
return Ok(invalid_fcu_response)
}
trace!(target: "consensus::engine", ?status, ?state, "Returning forkchoice status");
@ -494,11 +494,11 @@ where
// FCU resulted in a fatal error from which we can't recover
let err = err.clone();
let _ = tx.send(Err(error));
return OnForkchoiceUpdateOutcome::Fatal(err);
return OnForkchoiceUpdateOutcome::Fatal(err)
}
}
let _ = tx.send(Err(error));
return OnForkchoiceUpdateOutcome::Processed;
return OnForkchoiceUpdateOutcome::Processed
}
};
@ -523,7 +523,7 @@ where
if self.sync.has_reached_max_block(tip_number) {
// Terminate the sync early if it's reached the maximum user
// configured block.
return OnForkchoiceUpdateOutcome::ReachedMaxBlock;
return OnForkchoiceUpdateOutcome::ReachedMaxBlock
}
}
ForkchoiceStatus::Syncing => {
@ -574,7 +574,7 @@ where
inconsistent_stage_checkpoint = stage_checkpoint,
"Pipeline sync progress is inconsistent"
);
return Ok(self.blockchain.block_hash(first_stage_checkpoint)?);
return Ok(self.blockchain.block_hash(first_stage_checkpoint)?)
}
}
@ -650,7 +650,7 @@ where
Ok(None) => {
// we don't have the block yet and the distance exceeds the allowed
// threshold
return Some(state.finalized_block_hash);
return Some(state.finalized_block_hash)
}
Ok(Some(_)) => {
// we're fully synced to the finalized block
@ -691,7 +691,7 @@ where
) -> Option<B256> {
// check pre merge block error
if insert_err.map(|err| err.is_block_pre_merge()).unwrap_or_default() {
return Some(B256::ZERO);
return Some(B256::ZERO)
}
// If this is sent from new payload then the parent hash could be in a side chain, and is
@ -706,7 +706,7 @@ where
// we need to check if the parent block is the last POW block, if so then the payload is
// the first POS. The engine API spec mandates a zero hash to be returned: <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_newpayloadv1>
if !parent_header.is_zero_difficulty() {
return Some(B256::ZERO);
return Some(B256::ZERO)
}
// parent is canonical POS block
@ -818,7 +818,7 @@ where
// we likely do not have the finalized or safe blocks, and would return an incorrect
// INVALID status instead.
if status.is_valid() {
return self.ensure_consistent_state(state);
return self.ensure_consistent_state(state)
}
Ok(None)
@ -844,7 +844,7 @@ where
if !state.finalized_block_hash.is_zero() &&
!self.blockchain.is_canonical(state.finalized_block_hash)?
{
return Ok(Some(OnForkChoiceUpdated::invalid_state()));
return Ok(Some(OnForkChoiceUpdated::invalid_state()))
}
// Finalized block is consistent, so update it in the canon chain tracker.
@ -858,7 +858,7 @@ where
if !state.safe_block_hash.is_zero() &&
!self.blockchain.is_canonical(state.safe_block_hash)?
{
return Ok(Some(OnForkChoiceUpdated::invalid_state()));
return Ok(Some(OnForkChoiceUpdated::invalid_state()))
}
// Safe block is consistent, so update it in the canon chain tracker.
@ -919,7 +919,7 @@ where
if !safe_block_hash.is_zero() {
if self.blockchain.safe_block_hash()? == Some(safe_block_hash) {
// nothing to update
return Ok(());
return Ok(())
}
let safe =
@ -939,7 +939,7 @@ where
if !finalized_block_hash.is_zero() {
if self.blockchain.finalized_block_hash()? == Some(finalized_block_hash) {
// nothing to update
return Ok(());
return Ok(())
}
let finalized = self
@ -973,7 +973,7 @@ where
if let Some(invalid_ancestor) = self.check_invalid_ancestor(state.head_block_hash) {
warn!(target: "consensus::engine", ?error, ?state, ?invalid_ancestor, head=?state.head_block_hash, "Failed to canonicalize the head hash, head is also considered invalid");
debug!(target: "consensus::engine", head=?state.head_block_hash, current_error=?error, "Head was previously marked as invalid");
return invalid_ancestor;
return invalid_ancestor
}
match &error {
@ -984,7 +984,7 @@ where
return PayloadStatus::from_status(PayloadStatusEnum::Invalid {
validation_error: error.to_string(),
})
.with_latest_valid_hash(B256::ZERO);
.with_latest_valid_hash(B256::ZERO)
}
RethError::Canonical(CanonicalError::BlockchainTree(
BlockchainTreeError::BlockHashNotFoundInChain { .. },
@ -1086,7 +1086,7 @@ where
if let Some(status) =
self.check_invalid_ancestor_with_head(lowest_buffered_ancestor, block.hash)
{
return Ok(status);
return Ok(status)
}
let res = if self.sync.is_pipeline_idle() {
@ -1192,7 +1192,7 @@ where
// begin a payload build process. In such an event, the forkchoiceState update MUST NOT
// be rolled back.
if attrs.timestamp() <= head.timestamp {
return OnForkChoiceUpdated::invalid_payload_attributes();
return OnForkChoiceUpdated::invalid_payload_attributes()
}
// 8. Client software MUST begin a payload build process building on top of
@ -1278,7 +1278,7 @@ where
if let Some(status) =
self.check_invalid_ancestor_with_head(block.parent_hash, block.hash)
{
return Ok(status);
return Ok(status)
}
// not known to be invalid, but we don't know anything else
@ -1377,7 +1377,7 @@ where
// check if the block's parent is already marked as invalid
if self.check_invalid_ancestor_with_head(block.parent_hash, block.hash).is_some() {
// can skip this invalid block
return;
return
}
match self
@ -1443,7 +1443,7 @@ where
// threshold
self.sync.set_pipeline_sync_target(target);
// we can exit early here because the pipeline will take care of syncing
return;
return
}
// continue downloading the missing parent
@ -1546,7 +1546,7 @@ where
}
EngineSyncEvent::PipelineTaskDropped => {
error!(target: "consensus::engine", "Failed to receive spawned pipeline");
return Some(Err(BeaconConsensusEngineError::PipelineChannelClosed));
return Some(Err(BeaconConsensusEngineError::PipelineChannelClosed))
}
EngineSyncEvent::PipelineFinished { result, reached_max_block } => {
return self.on_pipeline_finished(result, reached_max_block)
@ -1576,7 +1576,7 @@ where
if reached_max_block {
// Terminate the sync early if it's reached the maximum user
// configured block.
return Some(Ok(()));
return Some(Ok(()))
}
if let ControlFlow::Unwind { bad_block, .. } = ctrl {
@ -1584,7 +1584,7 @@ where
// update the `invalid_headers` cache with the new invalid headers
self.invalid_headers.insert(*bad_block);
return None;
return None
}
// update the canon chain if continuous is enabled
@ -1602,7 +1602,7 @@ where
},
Err(error) => {
error!(target: "consensus::engine", ?error, "Error getting canonical header for continuous sync");
return Some(Err(RethError::Provider(error).into()));
return Some(Err(RethError::Provider(error).into()))
}
};
self.blockchain.set_canonical_head(max_header);
@ -1614,7 +1614,7 @@ where
// This is only possible if the node was run with `debug.tip`
// argument and without CL.
warn!(target: "consensus::engine", "No fork choice state available");
return None;
return None
}
};
@ -1684,7 +1684,7 @@ where
}
Err(error) => {
error!(target: "consensus::engine", ?error, "Error restoring blockchain tree state");
return Some(Err(error.into()));
return Some(Err(error.into()))
}
};
}
@ -1718,7 +1718,7 @@ where
self.blockchain.connect_buffered_blocks_to_canonical_hashes()
{
error!(target: "consensus::engine", ?error, "Error connecting buffered blocks to canonical hashes on hook result");
return Err(error.into());
return Err(error.into())
}
}
}
@ -1772,7 +1772,7 @@ where
},
)? {
this.on_hook_result(result)?;
continue;
continue
}
// Process one incoming message from the CL. We don't drain the messages right away,
@ -1787,11 +1787,11 @@ where
OnForkchoiceUpdateOutcome::Processed => {}
OnForkchoiceUpdateOutcome::ReachedMaxBlock => {
// reached the max block, we can terminate the future
return Poll::Ready(Ok(()));
return Poll::Ready(Ok(()))
}
OnForkchoiceUpdateOutcome::Fatal(err) => {
// fatal error, we can terminate the future
return Poll::Ready(Err(RethError::Execution(err).into()));
return Poll::Ready(Err(RethError::Execution(err).into()))
}
}
}
@ -1807,23 +1807,23 @@ where
this.listeners.push_listener(tx);
}
}
continue;
continue
}
// Both running hook with db write access and engine messages are pending,
// proceed to other polls
break;
break
}
// process sync events if any
match this.sync.poll(cx) {
Poll::Ready(sync_event) => {
if let Some(res) = this.on_sync_event(sync_event) {
return Poll::Ready(res);
return Poll::Ready(res)
}
// this could have taken a while, so we start the next cycle to handle any new
// engine messages
continue 'main;
continue 'main
}
Poll::Pending => {
// no more sync events to process
@ -1851,13 +1851,13 @@ where
// ensure we're polling until pending while also checking for new engine
// messages before polling the next hook
continue 'main;
continue 'main
}
}
// incoming engine messages and sync events are drained, so we can yield back
// control
return Poll::Pending;
return Poll::Pending
}
}
}
@ -1971,7 +1971,7 @@ mod tests {
result,
Err(BeaconConsensusEngineError::Pipeline(n)) if matches!(*n.as_ref(), PipelineError::Stage(StageError::ChannelClosed))
);
break;
break
}
Err(TryRecvError::Empty) => {
let _ = env

View File

@ -90,7 +90,7 @@ impl<DB> TestEnv<DB> {
loop {
let result = self.send_new_payload(payload.clone(), cancun_fields.clone()).await?;
if !result.is_syncing() {
return Ok(result);
return Ok(result)
}
}
}
@ -111,7 +111,7 @@ impl<DB> TestEnv<DB> {
loop {
let result = self.engine_handle.fork_choice_updated(state, None).await?;
if !result.is_syncing() {
return Ok(result);
return Ok(result)
}
}
}

View File

@ -137,7 +137,7 @@ pub mod proto {
/// Decodes a `TestProtoMessage` from the given message buffer.
pub fn decode_message(buf: &mut &[u8]) -> Option<Self> {
if buf.is_empty() {
return None;
return None
}
let id = buf[0];
buf.advance(1);

View File

@ -524,7 +524,7 @@ where
if self.handle.mode().is_stake() {
// See [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675#devp2p)
warn!(target: "net", "Peer performed block propagation, but it is not supported in proof of stake (EIP-3675)");
return;
return
}
let msg = NewBlockMessage { hash, block: Arc::new(block) };
self.swarm.state_mut().announce_new_block(msg);
@ -647,7 +647,7 @@ where
// This is only possible if the channel was deliberately closed since we always
// have an instance of `NetworkHandle`
error!("Network message channel closed.");
return Poll::Ready(());
return Poll::Ready(())
}
Poll::Ready(Some(msg)) => this.on_handle_message(msg),
};
@ -918,7 +918,7 @@ where
if budget == 0 {
// make sure we're woken up again
cx.waker().wake_by_ref();
break;
break
}
}

View File

@ -192,7 +192,7 @@ where
ListenerEvent::Incoming { stream, remote_addr } => {
// Reject incoming connection if node is shutting down.
if self.is_shutting_down() {
return None;
return None
}
// ensure we can handle an incoming connection from this address
if let Err(err) =
@ -210,13 +210,13 @@ where
);
}
}
return None;
return None
}
match self.sessions.on_incoming(stream, remote_addr) {
Ok(session_id) => {
trace!(target: "net", ?remote_addr, "Incoming connection");
return Some(SwarmEvent::IncomingTcpConnection { session_id, remote_addr });
return Some(SwarmEvent::IncomingTcpConnection { session_id, remote_addr })
}
Err(err) => {
trace!(target: "net", ?err, "Incoming connection rejected, capacity already reached.");
@ -235,7 +235,7 @@ where
match event {
StateAction::Connect { remote_addr, peer_id } => {
self.dial_outbound(remote_addr, peer_id);
return Some(SwarmEvent::OutgoingTcpConnection { remote_addr, peer_id });
return Some(SwarmEvent::OutgoingTcpConnection { remote_addr, peer_id })
}
StateAction::Disconnect { peer_id, reason } => {
self.sessions.disconnect(peer_id, reason);
@ -253,7 +253,7 @@ where
StateAction::DiscoveredNode { peer_id, socket_addr, fork_id } => {
// Don't try to connect to peer if node is shutting down
if self.is_shutting_down() {
return None;
return None
}
// Insert peer only if no fork id or a valid fork id
if fork_id.map_or_else(|| true, |f| self.sessions.is_valid_fork_id(f)) {
@ -302,7 +302,7 @@ where
loop {
while let Poll::Ready(action) = this.state.poll(cx) {
if let Some(event) = this.on_state_action(action) {
return Poll::Ready(Some(event));
return Poll::Ready(Some(event))
}
}
@ -311,9 +311,9 @@ where
Poll::Pending => {}
Poll::Ready(event) => {
if let Some(event) = this.on_session_event(event) {
return Poll::Ready(Some(event));
return Poll::Ready(Some(event))
}
continue;
continue
}
}
@ -322,13 +322,13 @@ where
Poll::Pending => {}
Poll::Ready(event) => {
if let Some(event) = this.on_connection(event) {
return Poll::Ready(Some(event));
return Poll::Ready(Some(event))
}
continue;
continue
}
}
return Poll::Pending;
return Poll::Pending
}
}
}

View File

@ -114,7 +114,7 @@ mod proto {
/// Decodes a `TestProtoMessage` from the given message buffer.
pub fn decode_message(buf: &mut &[u8]) -> Option<Self> {
if buf.is_empty() {
return None;
return None
}
let id = buf[0];
buf.advance(1);
@ -238,7 +238,7 @@ impl Stream for PingPongProtoConnection {
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let this = self.get_mut();
if let Some(initial_ping) = this.initial_ping.take() {
return Poll::Ready(Some(initial_ping.encoded()));
return Poll::Ready(Some(initial_ping.encoded()))
}
loop {
@ -250,21 +250,19 @@ impl Stream for PingPongProtoConnection {
}
}
}
let Some(msg) = ready!(this.conn.poll_next_unpin(cx)) else {
return Poll::Ready(None);
};
let Some(msg) = ready!(this.conn.poll_next_unpin(cx)) else { return Poll::Ready(None) };
let Some(msg) = PingPongProtoMessage::decode_message(&mut &msg[..]) else {
return Poll::Ready(None);
return Poll::Ready(None)
};
match msg.message {
PingPongProtoMessageKind::Ping => {
return Poll::Ready(Some(PingPongProtoMessage::pong().encoded()));
return Poll::Ready(Some(PingPongProtoMessage::pong().encoded()))
}
PingPongProtoMessageKind::Pong => {}
PingPongProtoMessageKind::PingMessage(msg) => {
return Poll::Ready(Some(PingPongProtoMessage::pong_message(msg).encoded()));
return Poll::Ready(Some(PingPongProtoMessage::pong_message(msg).encoded()))
}
PingPongProtoMessageKind::PongMessage(msg) => {
if let Some(sender) = this.pending_pong.take() {
@ -274,7 +272,7 @@ impl Stream for PingPongProtoConnection {
}
}
return Poll::Pending;
return Poll::Pending
}
}
}

View File

@ -109,7 +109,7 @@ impl ExecutionPayloadValidator {
if !cancun_active && block.has_blob_transactions() {
// cancun not active but blob transactions present
return Err(PayloadError::PreCancunBlockWithBlobTransactions);
return Err(PayloadError::PreCancunBlockWithBlobTransactions)
}
// Ensure the hash included in the payload matches the block hash

View File

@ -89,7 +89,7 @@ impl Block {
let Some(senders) =
TransactionSigned::recover_signers_unchecked(&self.body, self.body.len())
else {
return Err(self);
return Err(self)
};
senders
};

View File

@ -146,7 +146,7 @@ impl Header {
/// Returns an error if the extradata size is larger than 100 KB.
pub fn ensure_extradata_valid(&self) -> Result<(), HeaderError> {
if self.extra_data.len() > 100 * 1024 {
return Err(HeaderError::LargeExtraData);
return Err(HeaderError::LargeExtraData)
}
Ok(())
}
@ -158,7 +158,7 @@ impl Header {
/// Returns an error if the block difficulty exceeds 80 bits.
pub fn ensure_difficulty_valid(&self) -> Result<(), HeaderError> {
if self.difficulty.bit_len() > 80 {
return Err(HeaderError::LargeDifficulty);
return Err(HeaderError::LargeDifficulty)
}
Ok(())
}

View File

@ -120,15 +120,13 @@ impl Receipts {
/// Retrieves gas spent by transactions as a vector of tuples (transaction index, gas used).
pub fn gas_spent_by_tx(&self) -> Result<Vec<(u64, u64)>, PruneSegmentError> {
let Some(block_r) = self.last() else {
return Ok(vec![]);
};
let Some(block_r) = self.last() else { return Ok(vec![]) };
let mut out = Vec::with_capacity(block_r.len());
for (id, tx_r) in block_r.iter().enumerate() {
if let Some(receipt) = tx_r.as_ref() {
out.push((id as u64, receipt.cumulative_gas_used));
} else {
return Err(PruneSegmentError::ReceiptsPruned);
return Err(PruneSegmentError::ReceiptsPruned)
}
}
Ok(out)

View File

@ -43,7 +43,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
block.timestamp,
) {
debug!(target: "evm", ?error, ?receipts, "receipts verification failed");
return Err(error);
return Err(error)
};
self.stats.receipt_root_duration += time.elapsed();
}
@ -60,7 +60,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
// perf: do not execute empty blocks
if block.body.is_empty() {
return Ok((Vec::new(), 0));
return Ok((Vec::new(), 0))
}
let is_regolith =
@ -91,7 +91,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
transaction_gas_limit: transaction.gas_limit(),
block_available_gas,
}
.into());
.into())
}
// Cache the depositor account prior to the state transition for the deposit nonce.

View File

@ -277,7 +277,7 @@ impl<'a> EVMProcessor<'a> {
gas: GotExpected { got: cumulative_gas_used, expected: block.gas_used },
gas_spent_by_tx: receipts.gas_spent_by_tx()?,
}
.into());
.into())
}
let time = Instant::now();
self.apply_post_execution_state_change(block, total_difficulty)?;
@ -336,7 +336,7 @@ impl<'a> EVMProcessor<'a> {
self.prune_modes.receipts.map_or(false, |mode| mode.should_prune(block_number, tip))
{
receipts.clear();
return Ok(());
return Ok(())
}
// All receipts from the last 128 blocks are required for blockchain tree, even with
@ -344,7 +344,7 @@ impl<'a> EVMProcessor<'a> {
let prunable_receipts =
PruneMode::Distance(MINIMUM_PRUNING_DISTANCE).should_prune(block_number, tip);
if !prunable_receipts {
return Ok(());
return Ok(())
}
let contract_log_pruner = self.prune_modes.receipts_log_filter.group_by_block(tip, None)?;
@ -402,7 +402,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
verify_receipt(block.header.receipts_root, block.header.logs_bloom, receipts.iter())
{
debug!(target: "evm", ?error, ?receipts, "receipts verification failed");
return Err(error);
return Err(error)
};
self.stats.receipt_root_duration += time.elapsed();
}
@ -419,7 +419,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
// perf: do not execute empty blocks
if block.body.is_empty() {
return Ok((Vec::new(), 0));
return Ok((Vec::new(), 0))
}
let mut cumulative_gas_used = 0;
@ -434,7 +434,7 @@ impl<'a> BlockExecutor for EVMProcessor<'a> {
transaction_gas_limit: transaction.gas_limit(),
block_available_gas,
}
.into());
.into())
}
// Execute transaction.
let ResultAndState { result, state } = self.transact(transaction, *sender)?;
@ -517,7 +517,7 @@ pub fn verify_receipt<'a>(
return Err(BlockValidationError::ReceiptRootDiff(
GotExpected { got: receipts_root, expected: expected_receipts_root }.into(),
)
.into());
.into())
}
// Create header log bloom.
@ -526,7 +526,7 @@ pub fn verify_receipt<'a>(
return Err(BlockValidationError::BloomLogDiff(
GotExpected { got: logs_bloom, expected: expected_logs_bloom }.into(),
)
.into());
.into())
}
Ok(())

View File

@ -106,7 +106,7 @@ impl PendingBlockEnv {
// them as invalid here which removes all dependent transactions from the iterator
// before we can continue
best_txs.mark_invalid(&pool_tx);
continue;
continue
}
// convert tx to a signed transaction

View File

@ -161,7 +161,7 @@ where
max_block = ?self.max_block,
"Terminating pipeline."
);
return Ok(());
return Ok(())
}
}
}
@ -197,7 +197,7 @@ where
ControlFlow::Continue { block_number } => self.progress.update(block_number),
ControlFlow::Unwind { target, bad_block } => {
self.unwind(target, Some(bad_block.number))?;
return Ok(ControlFlow::Unwind { target, bad_block });
return Ok(ControlFlow::Unwind { target, bad_block })
}
}
@ -240,7 +240,7 @@ where
"Unwind point too far for stage"
);
self.listeners.notify(PipelineEvent::Skipped { stage_id });
continue;
continue
}
debug!(
@ -285,7 +285,7 @@ where
}
Err(err) => {
self.listeners.notify(PipelineEvent::Error { stage_id });
return Err(PipelineError::Stage(StageError::Fatal(Box::new(err))));
return Err(PipelineError::Stage(StageError::Fatal(Box::new(err))))
}
}
}
@ -325,7 +325,7 @@ where
// We reached the maximum block, so we skip the stage
return Ok(ControlFlow::NoProgress {
block_number: prev_checkpoint.map(|progress| progress.block_number),
});
})
}
let exec_input = ExecInput { target, checkpoint: prev_checkpoint };
@ -380,7 +380,7 @@ where
ControlFlow::Continue { block_number }
} else {
ControlFlow::NoProgress { block_number: Some(block_number) }
});
})
}
}
Err(err) => {
@ -389,7 +389,7 @@ where
if let Some(ctrl) =
on_stage_error(&self.provider_factory, stage_id, prev_checkpoint, err)?
{
return Ok(ctrl);
return Ok(ctrl)
}
}
}

View File

@ -114,7 +114,7 @@ impl<EF: ExecutorFactory> ExecutionStage<EF> {
input: ExecInput,
) -> Result<ExecOutput, StageError> {
if input.target_reached() {
return Ok(ExecOutput::done(input.checkpoint()));
return Ok(ExecOutput::done(input.checkpoint()))
}
let start_block = input.next_block();
@ -183,7 +183,7 @@ impl<EF: ExecutorFactory> ExecutionStage<EF> {
bundle_size_hint,
cumulative_gas,
) {
break;
break
}
}
let time = Instant::now();
@ -360,7 +360,7 @@ impl<EF: ExecutorFactory, DB: Database> Stage<DB> for ExecutionStage<EF> {
if range.is_empty() {
return Ok(UnwindOutput {
checkpoint: input.checkpoint.with_block_number(input.unwind_to),
});
})
}
// get all batches for account change
@ -403,7 +403,7 @@ impl<EF: ExecutorFactory, DB: Database> Stage<DB> for ExecutionStage<EF> {
let mut rev_storage_changeset_walker = storage_changeset.walk_back(None)?;
while let Some((key, _)) = rev_storage_changeset_walker.next().transpose()? {
if key.block_number() < *range.start() {
break;
break
}
// delete all changesets
rev_storage_changeset_walker.delete_current()?;
@ -423,7 +423,7 @@ impl<EF: ExecutorFactory, DB: Database> Stage<DB> for ExecutionStage<EF> {
while let Some(Ok((tx_number, receipt))) = reverse_walker.next() {
if tx_number < first_tx_num {
break;
break
}
reverse_walker.delete_current()?;

View File

@ -138,7 +138,7 @@ impl<DB: Database> Stage<DB> for AccountHashingStage {
input: ExecInput,
) -> Result<ExecOutput, StageError> {
if input.target_reached() {
return Ok(ExecOutput::done(input.checkpoint()));
return Ok(ExecOutput::done(input.checkpoint()))
}
let (from_block, to_block) = input.next_block_range().into_inner();
@ -238,7 +238,7 @@ impl<DB: Database> Stage<DB> for AccountHashingStage {
},
);
return Ok(ExecOutput { checkpoint, done: false });
return Ok(ExecOutput { checkpoint, done: false })
}
} else {
// Aggregate all transition changesets and make a list of accounts that have been
@ -549,7 +549,7 @@ mod tests {
let start_block = input.next_block();
let end_block = output.checkpoint.block_number;
if start_block > end_block {
return Ok(());
return Ok(())
}
}
self.check_hashed_accounts()

View File

@ -178,9 +178,7 @@ where
where
B: bytes::BufMut + AsMut<[u8]>,
{
let Some(element) = self else {
return 0;
};
let Some(element) = self else { return 0 };
// We don't know the length of the element until we compact it.
let mut tmp = Vec::with_capacity(64);
@ -248,7 +246,7 @@ impl Compact for U256 {
#[inline]
fn from_compact(mut buf: &[u8], len: usize) -> (Self, &[u8]) {
if len == 0 {
return (U256::ZERO, buf);
return (U256::ZERO, buf)
}
let mut arr = [0; 32];
@ -358,7 +356,7 @@ fn decode_varuint(buf: &[u8]) -> (usize, &[u8]) {
let byte = buf[i];
value |= usize::from(byte & 0x7F) << (i * 7);
if byte < 0x80 {
return (value, &buf[i + 1..]);
return (value, &buf[i + 1..])
}
}

View File

@ -272,7 +272,7 @@ impl DatabaseEnv {
LogLevel::Extra => 7,
});
} else {
return Err(DatabaseError::LogLevelUnavailable(log_level));
return Err(DatabaseError::LogLevelUnavailable(log_level))
}
}

View File

@ -144,7 +144,7 @@ impl<DB: Database> ProviderFactory<DB> {
if block_number == provider.best_block_number().unwrap_or_default() &&
block_number == provider.last_block_number().unwrap_or_default()
{
return Ok(Box::new(LatestStateProvider::new(provider.into_tx())));
return Ok(Box::new(LatestStateProvider::new(provider.into_tx())))
}
// +1 as the changeset that we want is the one that was applied after this block.

View File

@ -189,7 +189,7 @@ where
while let Some((sharded_key, list)) = item {
// If the shard does not belong to the key, break.
if !shard_belongs_to_key(&sharded_key) {
break;
break
}
cursor.delete_current()?;
@ -198,12 +198,12 @@ where
let first = list.iter(0).next().expect("List can't be empty");
if first >= block_number as usize {
item = cursor.prev()?;
continue;
continue
} else if block_number <= sharded_key.as_ref().highest_block_number {
// Filter out all elements greater than block number.
return Ok(list.iter(0).take_while(|i| *i < block_number as usize).collect::<Vec<_>>());
return Ok(list.iter(0).take_while(|i| *i < block_number as usize).collect::<Vec<_>>())
} else {
return Ok(list.iter(0).collect::<Vec<_>>());
return Ok(list.iter(0).collect::<Vec<_>>())
}
}
@ -332,7 +332,7 @@ impl<TX: DbTx> DatabaseProvider<TX> {
if snapshot_upper_bound
.map_or(false, |snapshot_upper_bound| snapshot_upper_bound >= number)
{
return fetch_from_snapshot(provider);
return fetch_from_snapshot(provider)
}
}
fetch_from_database()
@ -393,7 +393,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<BundleStateWithReceipts> {
if range.is_empty() {
return Ok(BundleStateWithReceipts::default());
return Ok(BundleStateWithReceipts::default())
}
let start_block_number = *range.start();
@ -571,7 +571,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
let block_bodies = self.get_or_take::<tables::BlockBodyIndices, false>(range)?;
if block_bodies.is_empty() {
return Ok(Vec::new());
return Ok(Vec::new())
}
// Compute the first and last tx ID in the range
@ -580,7 +580,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
// If this is the case then all of the blocks in the range are empty
if last_transaction < first_transaction {
return Ok(block_bodies.into_iter().map(|(n, _)| (n, Vec::new())).collect());
return Ok(block_bodies.into_iter().map(|(n, _)| (n, Vec::new())).collect())
}
// Get transactions and senders
@ -709,7 +709,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
let block_headers = self.get_or_take::<tables::Headers, TAKE>(range.clone())?;
if block_headers.is_empty() {
return Ok(Vec::new());
return Ok(Vec::new())
}
let block_header_hashes =
@ -815,7 +815,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
while let Some(Ok((entry_key, _))) = reverse_walker.next() {
if selector(entry_key.clone()) <= key {
break;
break
}
reverse_walker.delete_current()?;
deleted += 1;
@ -862,7 +862,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
}
if deleted == limit {
break;
break
}
}
}
@ -893,7 +893,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
}
if deleted == limit {
break;
break
}
}
}
@ -913,7 +913,7 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
// delete old shard so new one can be inserted.
self.tx.delete::<T>(shard_key, None)?;
let list = list.iter(0).map(|i| i as u64).collect::<Vec<_>>();
return Ok(list);
return Ok(list)
}
Ok(Vec::new())
}
@ -1110,7 +1110,7 @@ impl<TX: DbTx> HeaderProvider for DatabaseProvider<TX> {
if let Some(td) = self.chain_spec.final_paris_total_difficulty(number) {
// if this block is higher than the final paris(merge) block, return the final paris
// difficulty
return Ok(Some(td));
return Ok(Some(td))
}
self.get_with_snapshot(
@ -1259,7 +1259,7 @@ impl<TX: DbTx> BlockReader for DatabaseProvider<TX> {
None => return Ok(None),
};
return Ok(Some(Block { header, body: transactions, ommers, withdrawals }));
return Ok(Some(Block { header, body: transactions, ommers, withdrawals }))
}
}
@ -1283,11 +1283,11 @@ impl<TX: DbTx> BlockReader for DatabaseProvider<TX> {
// If the Paris (Merge) hardfork block is known and block is after it, return empty
// ommers.
if self.chain_spec.final_paris_total_difficulty(number).is_some() {
return Ok(Some(Vec::new()));
return Ok(Some(Vec::new()))
}
let ommers = self.tx.get::<tables::BlockOmmers>(number)?.map(|o| o.ommers);
return Ok(ommers);
return Ok(ommers)
}
Ok(None)
@ -1360,7 +1360,7 @@ impl<TX: DbTx> BlockReader for DatabaseProvider<TX> {
fn block_range(&self, range: RangeInclusive<BlockNumber>) -> ProviderResult<Vec<Block>> {
if range.is_empty() {
return Ok(Vec::new());
return Ok(Vec::new())
}
let len = range.end().saturating_sub(*range.start()) as usize;
@ -1558,7 +1558,7 @@ impl<TX: DbTx> TransactionsProvider for DatabaseProvider<TX> {
excess_blob_gas: header.excess_blob_gas,
};
return Ok(Some((transaction, meta)));
return Ok(Some((transaction, meta)))
}
}
}
@ -1706,7 +1706,7 @@ impl<TX: DbTx> WithdrawalsProvider for DatabaseProvider<TX> {
.get::<tables::BlockWithdrawals>(number)
.map(|w| w.map(|w| w.withdrawals))?
.unwrap_or_default();
return Ok(Some(withdrawals));
return Ok(Some(withdrawals))
}
}
Ok(None)
@ -2098,7 +2098,7 @@ impl<TX: DbTxMut + DbTx> HashingWriter for DatabaseProvider<TX> {
root: GotExpected { got: state_root, expected: expected_state_root },
block_number: *range.end(),
block_hash: end_block_hash,
})));
})))
}
trie_updates.flush(&self.tx)?;
}
@ -2294,7 +2294,7 @@ impl<TX: DbTxMut + DbTx> BlockExecutionWriter for DatabaseProvider<TX> {
root: GotExpected { got: new_state_root, expected: parent_state_root },
block_number: parent_number,
block_hash: parent_hash,
})));
})))
}
trie_updates.flush(&self.tx)?;
}
@ -2463,7 +2463,7 @@ impl<TX: DbTxMut + DbTx> BlockWriter for DatabaseProvider<TX> {
) -> ProviderResult<()> {
if blocks.is_empty() {
debug!(target: "providers::db", "Attempted to append empty block range");
return Ok(());
return Ok(())
}
let first_number = blocks.first().unwrap().number;

View File

@ -347,7 +347,7 @@ impl SnapshotProvider {
break 'outer
}
result.push(res);
break 'inner;
break 'inner
}
None => {
provider = get_provider(number)?;

View File

@ -17,7 +17,7 @@ impl BlockExecutor for TestExecutor {
_total_difficulty: U256,
) -> Result<(), BlockExecutionError> {
if self.0.is_none() {
return Err(BlockExecutionError::UnavailableForTest);
return Err(BlockExecutionError::UnavailableForTest)
}
Ok(())
}
@ -28,7 +28,7 @@ impl BlockExecutor for TestExecutor {
_total_difficulty: U256,
) -> Result<(), BlockExecutionError> {
if self.0.is_none() {
return Err(BlockExecutionError::UnavailableForTest);
return Err(BlockExecutionError::UnavailableForTest)
}
Ok(())
}

View File

@ -491,7 +491,7 @@ impl<T: TransactionOrdering> TxPool<T> {
on_chain_nonce: u64,
) -> PoolResult<AddedTransaction<T::Transaction>> {
if self.contains(tx.hash()) {
return Err(PoolError::new(*tx.hash(), PoolErrorKind::AlreadyImported));
return Err(PoolError::new(*tx.hash(), PoolErrorKind::AlreadyImported))
}
// Update sender info with balance and nonce
@ -719,7 +719,7 @@ impl<T: TransactionOrdering> TxPool<T> {
}
id = descendant;
} else {
return;
return
}
}
}
@ -945,7 +945,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
let count = entry.get_mut();
if *count == 1 {
entry.remove();
return;
return
}
*count -= 1;
}
@ -1005,7 +1005,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
($iter:ident) => {
'this: while let Some((peek, _)) = iter.peek() {
if peek.sender != id.sender {
break 'this;
break 'this
}
iter.next();
}
@ -1024,7 +1024,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
current: tx.subpool,
destination: Destination::Discard,
});
continue 'transactions;
continue 'transactions
}
let ancestor = TransactionId::ancestor(id.nonce, info.state_nonce, id.sender);
@ -1047,7 +1047,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
// If there's a nonce gap, we can shortcircuit, because there's nothing to update yet.
if tx.state.has_nonce_gap() {
next_sender!(iter);
continue 'transactions;
continue 'transactions
}
// Since this is the first transaction of the sender, it has no parked ancestors
@ -1067,13 +1067,13 @@ impl<T: PoolTransaction> AllTransactions<T> {
while let Some((peek, ref mut tx)) = iter.peek_mut() {
if peek.sender != id.sender {
// Found the next sender
continue 'transactions;
continue 'transactions
}
// can short circuit
if tx.state.has_nonce_gap() {
next_sender!(iter);
continue 'transactions;
continue 'transactions
}
// update cumulative cost
@ -1235,7 +1235,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
fn contains_conflicting_transaction(&self, tx: &ValidPoolTransaction<T>) -> bool {
let mut iter = self.txs_iter(tx.transaction_id.sender);
if let Some((_, existing)) = iter.next() {
return tx.tx_type_conflicts_with(&existing.transaction);
return tx.tx_type_conflicts_with(&existing.transaction)
}
// no existing transaction for this sender
false
@ -1259,7 +1259,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
if current_txs >= self.max_account_slots {
return Err(InsertErr::ExceededSenderTransactionsCapacity {
transaction: Arc::new(transaction),
});
})
}
}
if transaction.gas_limit() > self.block_gas_limit {
@ -1267,12 +1267,12 @@ impl<T: PoolTransaction> AllTransactions<T> {
block_gas_limit: self.block_gas_limit,
tx_gas_limit: transaction.gas_limit(),
transaction: Arc::new(transaction),
});
})
}
if self.contains_conflicting_transaction(&transaction) {
// blob vs non blob transactions are mutually exclusive for the same sender
return Err(InsertErr::TxTypeConflict { transaction: Arc::new(transaction) });
return Err(InsertErr::TxTypeConflict { transaction: Arc::new(transaction) })
}
Ok(transaction)
@ -1292,12 +1292,12 @@ impl<T: PoolTransaction> AllTransactions<T> {
if let Some(ancestor) = ancestor {
let Some(ancestor_tx) = self.txs.get(&ancestor) else {
// ancestor tx is missing, so we can't insert the new blob
return Err(InsertErr::BlobTxHasNonceGap { transaction: Arc::new(new_blob_tx) });
return Err(InsertErr::BlobTxHasNonceGap { transaction: Arc::new(new_blob_tx) })
};
if ancestor_tx.state.has_nonce_gap() {
// the ancestor transaction already has a nonce gap, so we can't insert the new
// blob
return Err(InsertErr::BlobTxHasNonceGap { transaction: Arc::new(new_blob_tx) });
return Err(InsertErr::BlobTxHasNonceGap { transaction: Arc::new(new_blob_tx) })
}
// the max cost executing this transaction requires
@ -1306,7 +1306,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
// check if the new blob would go into overdraft
if cumulative_cost > on_chain_balance {
// the transaction would go into overdraft
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) });
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) })
}
// ensure that a replacement would not shift already propagated blob transactions into
@ -1323,14 +1323,14 @@ impl<T: PoolTransaction> AllTransactions<T> {
cumulative_cost += tx.transaction.cost();
if tx.transaction.is_eip4844() && cumulative_cost > on_chain_balance {
// the transaction would shift
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) });
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) })
}
}
}
}
} else if new_blob_tx.cost() > on_chain_balance {
// the transaction would go into overdraft
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) });
return Err(InsertErr::Overdraft { transaction: Arc::new(new_blob_tx) })
}
Ok(new_blob_tx)
@ -1350,7 +1350,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
if maybe_replacement.max_fee_per_gas() <=
existing_transaction.max_fee_per_gas() * price_bump_multiplier
{
return true;
return true
}
let existing_max_priority_fee_per_gas =
@ -1363,7 +1363,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
existing_max_priority_fee_per_gas != 0 &&
replacement_max_priority_fee_per_gas != 0
{
return true;
return true
}
// check max blob fee per gas
@ -1376,7 +1376,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
if replacement_max_blob_fee_per_gas <=
existing_max_blob_fee_per_gas * price_bump_multiplier
{
return true;
return true
}
}
@ -1468,7 +1468,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
let fee_cap = transaction.max_fee_per_gas();
if fee_cap < self.minimal_protocol_basefee as u128 {
return Err(InsertErr::FeeCapBelowMinimumProtocolFeeCap { transaction, fee_cap });
return Err(InsertErr::FeeCapBelowMinimumProtocolFeeCap { transaction, fee_cap })
}
if fee_cap >= self.pending_fees.base_fee as u128 {
state.insert(TxState::ENOUGH_FEE_CAP_BLOCK);
@ -1502,7 +1502,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
return Err(InsertErr::Underpriced {
transaction: pool_tx.transaction,
existing: *entry.get().transaction.hash(),
});
})
}
let new_hash = *pool_tx.transaction.hash();
let new_transaction = pool_tx.transaction.clone();
@ -1545,7 +1545,7 @@ impl<T: PoolTransaction> AllTransactions<T> {
// If there's a nonce gap, we can shortcircuit
if next_nonce != id.nonce {
break;
break
}
// close the nonce gap

View File

@ -59,7 +59,7 @@ impl Case for BlockchainTestCase {
fn run(&self) -> Result<(), Error> {
// If the test is marked for skipping, return a Skipped error immediately.
if self.skip {
return Err(Error::Skipped);
return Err(Error::Skipped)
}
// Iterate through test cases, filtering by the network type to exclude specific forks.