mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(node-core): log errors in debug when ETA fails to calculate (#6971)
This commit is contained in:
@ -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 _)]
|
||||
};
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
@ -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
|
||||
};
|
||||
|
||||
self.eta = Duration::try_from_secs_f64(remaining as f64 / per_second).ok();
|
||||
}
|
||||
|
||||
self.last_checkpoint = current;
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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(())
|
||||
|
||||
Reference in New Issue
Block a user