Skip to content

Commit

Permalink
fix(en): Minor node fixes (#1978)
Browse files Browse the repository at this point in the history
## What ❔

Fixes minor issues with the EN:

- Transient error detection for RPC clients is suboptimal, leading to
what really is a transient error crashing consistency checker.
- Since refactoring signal handling, `ManagedTasks::wait_single()` on EN
may inappropriately log task termination errors even after a signal is
being received.
- Since recent refactoring (?), block fetcher doesn't tag its L2 client.
- Block fetcher may produce many rate limiting logs, which currently
have WARN level.
- Initializing L2 client multiple times (e.g., in a load test) produces
many WARN logs.

## Why ❔

Improves EN UX.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `zk spellcheck`.
  • Loading branch information
slowli authored and aon committed May 17, 2024
1 parent 7ecfb27 commit 55ed274
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 5 additions & 2 deletions core/bin/external_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,9 +1019,12 @@ async fn run_node(

let mut tasks = ManagedTasks::new(task_handles);
tokio::select! {
() = tasks.wait_single() => {},
// We don't want to log unnecessary warnings in `tasks.wait_single()` if we have received a stop signal.
biased;

_ = stop_receiver.changed() => {},
};
() = tasks.wait_single() => {},
}

// Reaching this point means that either some actor exited unexpectedly or we received a stop signal.
// Broadcast the stop signal (in case it wasn't broadcast previously) to all actors and exit.
Expand Down
2 changes: 1 addition & 1 deletion core/lib/web3_decl/src/client/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl L2ClientMetrics {
};
let info = &self.info[&network];
if let Err(err) = info.set(config_labels) {
tracing::warn!(
tracing::debug!(
"Error setting configuration info {:?} for L2 client; already set to {:?}",
err.into_inner(),
info.get()
Expand Down
2 changes: 1 addition & 1 deletion core/lib/web3_decl/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<Net: Network, C: ClientBase> Client<Net, C> {
origin,
&stats,
);
tracing::warn!(
tracing::debug!(
network = network_label,
component = self.component_name,
%origin,
Expand Down
15 changes: 10 additions & 5 deletions core/lib/web3_decl/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
task::{Context, Poll},
};

use jsonrpsee::core::ClientError;
use jsonrpsee::{core::ClientError, types::error::ErrorCode};
use pin_project_lite::pin_project;
use thiserror::Error;
use zksync_types::{api::SerializationTransactionError, L1BatchNumber, L2BlockNumber};
Expand Down Expand Up @@ -87,10 +87,15 @@ impl EnrichedClientError {

/// Whether the error should be considered transient.
pub fn is_transient(&self) -> bool {
matches!(
self.as_ref(),
ClientError::Transport(_) | ClientError::RequestTimeout
)
match self.as_ref() {
ClientError::Transport(_) | ClientError::RequestTimeout => true,
ClientError::Call(err) => {
// At least some RPC providers use "internal error" in case of the server being overloaded
err.code() == ErrorCode::ServerIsBusy.code()
|| err.code() == ErrorCode::InternalError.code()
}
_ => false,
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/node/consensus/src/era.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn run_en(
let en = en::EN {
pool: ConnectionPool(pool),
sync_state: sync_state.clone(),
client: main_node_client,
client: main_node_client.for_component("block_fetcher"),
};
let res = match cfg {
Some((cfg, secrets)) => en.run(ctx, actions, cfg, secrets).await,
Expand Down

0 comments on commit 55ed274

Please sign in to comment.