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

@ -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)
}
}
}