mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-01 14:06:10 +00:00
handle timestamp overflow
This commit is contained in:
parent
be14ba647d
commit
7dbaeaafba
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6425,6 +6425,7 @@ dependencies = [
|
||||
"contract-interface",
|
||||
"ethereum-types 0.14.1",
|
||||
"ethers",
|
||||
"ethers-core",
|
||||
"miner",
|
||||
"rand 0.8.5",
|
||||
"storage",
|
||||
|
@ -15,5 +15,6 @@ tracing = "0.1.40"
|
||||
ethereum-types = "0.14.1"
|
||||
contract-interface = { path = "../../common/contract-interface" }
|
||||
ethers = "^2"
|
||||
ethers-core = { version = "^2" }
|
||||
zgs_spec = { path = "../../common/spec" }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
@ -4,6 +4,7 @@ use contract_interface::ChunkLinearReward;
|
||||
use ethereum_types::Address;
|
||||
use ethers::prelude::{Http, Provider};
|
||||
use ethers::providers::{HttpRateLimitRetryPolicy, RetryClient, RetryClientBuilder};
|
||||
use ethers_core::types::U256;
|
||||
use miner::MinerMessage;
|
||||
use rand::Rng;
|
||||
use std::cmp::Ordering;
|
||||
@ -119,10 +120,17 @@ impl Pruner {
|
||||
// Check no reward chunks and prune.
|
||||
match self.reward_contract.first_rewardable_chunk().call().await {
|
||||
Ok((new_first_rewardable, chain_timestamp)) => {
|
||||
if (Utc::now().timestamp() - (chain_timestamp.as_u64() as i64)).abs() > 60 * 60
|
||||
{
|
||||
if chain_timestamp > U256::from(i64::MAX as u64) {
|
||||
error!(
|
||||
chain_timestamp = chain_timestamp.to_string(),
|
||||
"chain timestamp is too large, skip pruning"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
let chain_ts = chain_timestamp.as_u64() as i64;
|
||||
if (Utc::now().timestamp() - chain_ts).abs() > 60 * 60 {
|
||||
debug!(
|
||||
chain_timestamp = chain_timestamp.as_u64(),
|
||||
chain_timestamp = chain_ts,
|
||||
"chain timestamp is weird, skip pruning"
|
||||
);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user