Skip to content
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

chore(node-core): log errors in debug when ETA fails to calculate #6971

Merged
merged 2 commits into from
Mar 5, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/reth/src/sigsegv_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern "C" fn print_stack_trace(_: libc::c_int) {
// Collect return addresses
let depth = libc::backtrace(STACK_TRACE.as_mut_ptr(), MAX_FRAMES as i32);
if depth == 0 {
return;
return
}
&STACK_TRACE.as_slice()[0..(depth as _)]
};
Expand Down
20 changes: 10 additions & 10 deletions crates/ethereum-forks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ impl Hardfork {
/// Retrieves the activation block for the specified hardfork on the given chain.
pub fn activation_block(&self, chain: Chain) -> Option<u64> {
if chain == Chain::mainnet() {
return self.mainnet_activation_block();
return self.mainnet_activation_block()
}
if chain == Chain::sepolia() {
return self.sepolia_activation_block();
return self.sepolia_activation_block()
}
if chain == Chain::holesky() {
return self.holesky_activation_block();
return self.holesky_activation_block()
}

#[cfg(feature = "optimism")]
{
if chain == Chain::base_sepolia() {
return self.base_sepolia_activation_block();
return self.base_sepolia_activation_block()
}
if chain == Chain::base_mainnet() {
return self.base_mainnet_activation_block();
return self.base_mainnet_activation_block()
}
}

Expand Down Expand Up @@ -252,21 +252,21 @@ impl Hardfork {
/// Retrieves the activation timestamp for the specified hardfork on the given chain.
pub fn activation_timestamp(&self, chain: Chain) -> Option<u64> {
if chain == Chain::mainnet() {
return self.mainnet_activation_timestamp();
return self.mainnet_activation_timestamp()
}
if chain == Chain::sepolia() {
return self.sepolia_activation_timestamp();
return self.sepolia_activation_timestamp()
}
if chain == Chain::holesky() {
return self.holesky_activation_timestamp();
return self.holesky_activation_timestamp()
}
#[cfg(feature = "optimism")]
{
if chain == Chain::base_sepolia() {
return self.base_sepolia_activation_timestamp();
return self.base_sepolia_activation_timestamp()
}
if chain == Chain::base_mainnet() {
return self.base_mainnet_activation_timestamp();
return self.base_mainnet_activation_timestamp()
}
}

Expand Down
21 changes: 15 additions & 6 deletions crates/node-core/src/events/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::{
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
use tokio::time::Interval;
use tracing::{info, warn};
use tracing::{debug, info, warn};

/// Interval of reporting node state.
const INFO_MESSAGE_INTERVAL: Duration = Duration::from_secs(25);
Expand Down Expand Up @@ -483,14 +483,23 @@ impl Eta {
let Some(current) = checkpoint.entities() else { return };

if let Some(last_checkpoint_time) = &self.last_checkpoint_time {
let processed_since_last = current.processed - self.last_checkpoint.processed;
let Some(processed_since_last) =
current.processed.checked_sub(self.last_checkpoint.processed)
else {
self.eta = None;
debug!(target: "reth::cli", ?current, ?self.last_checkpoint, "Failed to calculate the ETA: processed entities is less than the last checkpoint");
return
};
let elapsed = last_checkpoint_time.elapsed();
let per_second = processed_since_last as f64 / elapsed.as_secs_f64();

self.eta = Duration::try_from_secs_f64(
((current.total - current.processed) as f64) / per_second,
)
.ok();
let Some(remaining) = current.total.checked_sub(current.processed) else {
self.eta = None;
debug!(target: "reth::cli", ?current, "Failed to calculate the ETA: total entities is less than processed entities");
return
};
Comment on lines +486 to +500
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add stage_id arg to Eta::update and log it as well to identify the source


self.eta = Duration::try_from_secs_f64(remaining as f64 / per_second).ok();
}

self.last_checkpoint = current;
Expand Down
4 changes: 2 additions & 2 deletions crates/transaction-pool/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl PoolTransaction for MockTransaction {

// If the maximum fee per gas is less than the base fee, return None
if max_fee_per_gas < base_fee {
return None;
return None
}

// Calculate the fee by subtracting the base fee from the maximum fee per gas
Expand All @@ -651,7 +651,7 @@ impl PoolTransaction for MockTransaction {
// If the maximum priority fee per gas is available, return the minimum of fee and priority
// fee
if let Some(priority_fee) = self.max_priority_fee_per_gas() {
return Some(fee.min(priority_fee));
return Some(fee.min(priority_fee))
}

// Otherwise, return the calculated fee
Expand Down
4 changes: 1 addition & 3 deletions examples/custom-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl PayloadAttributes for CustomPayloadAttributes {

// custom validation logic - ensure that the custom field is not zero
if self.custom == 0 {
return Err(AttributesValidationError::invalid_params(
CustomError::CustomFieldIsNotZero,
));
return Err(AttributesValidationError::invalid_params(CustomError::CustomFieldIsNotZero))
}

Ok(())
Expand Down
Loading