mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-02 22:45:41 +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",
|
"contract-interface",
|
||||||
"ethereum-types 0.14.1",
|
"ethereum-types 0.14.1",
|
||||||
"ethers",
|
"ethers",
|
||||||
|
"ethers-core",
|
||||||
"miner",
|
"miner",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"storage",
|
"storage",
|
||||||
|
@ -15,5 +15,6 @@ tracing = "0.1.40"
|
|||||||
ethereum-types = "0.14.1"
|
ethereum-types = "0.14.1"
|
||||||
contract-interface = { path = "../../common/contract-interface" }
|
contract-interface = { path = "../../common/contract-interface" }
|
||||||
ethers = "^2"
|
ethers = "^2"
|
||||||
|
ethers-core = { version = "^2" }
|
||||||
zgs_spec = { path = "../../common/spec" }
|
zgs_spec = { path = "../../common/spec" }
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
@ -4,6 +4,7 @@ use contract_interface::ChunkLinearReward;
|
|||||||
use ethereum_types::Address;
|
use ethereum_types::Address;
|
||||||
use ethers::prelude::{Http, Provider};
|
use ethers::prelude::{Http, Provider};
|
||||||
use ethers::providers::{HttpRateLimitRetryPolicy, RetryClient, RetryClientBuilder};
|
use ethers::providers::{HttpRateLimitRetryPolicy, RetryClient, RetryClientBuilder};
|
||||||
|
use ethers_core::types::U256;
|
||||||
use miner::MinerMessage;
|
use miner::MinerMessage;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
@ -119,10 +120,17 @@ impl Pruner {
|
|||||||
// Check no reward chunks and prune.
|
// Check no reward chunks and prune.
|
||||||
match self.reward_contract.first_rewardable_chunk().call().await {
|
match self.reward_contract.first_rewardable_chunk().call().await {
|
||||||
Ok((new_first_rewardable, chain_timestamp)) => {
|
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!(
|
debug!(
|
||||||
chain_timestamp = chain_timestamp.as_u64(),
|
chain_timestamp = chain_ts,
|
||||||
"chain timestamp is weird, skip pruning"
|
"chain timestamp is weird, skip pruning"
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user