mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-11-03 16:17:27 +00:00
skip wrong chain timestamp (#360)
* skip wrong chain timestamp * handle timestamp overflow
This commit is contained in:
parent
74074dfa2f
commit
347cd3e4f3
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -977,6 +977,7 @@ dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
@ -6420,9 +6421,11 @@ name = "pruner"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"contract-interface",
|
||||
"ethereum-types 0.14.1",
|
||||
"ethers",
|
||||
"ethers-core",
|
||||
"miner",
|
||||
"rand 0.8.5",
|
||||
"storage",
|
||||
|
||||
@ -15,4 +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"] }
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
use anyhow::{bail, Result};
|
||||
use chrono::Utc;
|
||||
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;
|
||||
@ -117,7 +119,22 @@ impl Pruner {
|
||||
|
||||
// Check no reward chunks and prune.
|
||||
match self.reward_contract.first_rewardable_chunk().call().await {
|
||||
Ok(new_first_rewardable) => {
|
||||
Ok((new_first_rewardable, chain_timestamp)) => {
|
||||
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_ts,
|
||||
"chain timestamp is weird, skip pruning"
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if let Some(no_reward_list) = self
|
||||
.maybe_forward_first_rewardable(new_first_rewardable)
|
||||
.await?
|
||||
|
||||
@ -1 +1 @@
|
||||
1e931c7b168f9bc2b55f7b8fd96946e35b373048
|
||||
2772838c13c041dcebcf586a982c4bc8a7f09359
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -40,8 +40,8 @@
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060be8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806361ec5082146037578063da6eb36a14604b575b600080fd5b600060405190815260200160405180910390f35b605b6056366004605d565b505050565b005b600080600060608486031215607157600080fd5b50508135936020830135935060409092013591905056fea264697066735822122080db0b00f4b93cc320a2df449a74e503451a2675da518eff0fc5b7cf0ae8c90c64736f6c63430008100033",
|
||||
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c806361ec5082146037578063da6eb36a14604b575b600080fd5b600060405190815260200160405180910390f35b605b6056366004605d565b505050565b005b600080600060608486031215607157600080fd5b50508135936020830135935060409092013591905056fea264697066735822122080db0b00f4b93cc320a2df449a74e503451a2675da518eff0fc5b7cf0ae8c90c64736f6c63430008100033",
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060be8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c806361ec5082146037578063da6eb36a14604b575b600080fd5b600060405190815260200160405180910390f35b605b6056366004605d565b505050565b005b600080600060608486031215607157600080fd5b50508135936020830135935060409092013591905056fea264697066735822122046b53f2984cbf5adf3e9850bdbd978b04bf2673faae23f82bb65f6ed17a8ca6164736f6c63430008100033",
|
||||
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c806361ec5082146037578063da6eb36a14604b575b600080fd5b600060405190815260200160405180910390f35b605b6056366004605d565b505050565b005b600080600060608486031215607157600080fd5b50508135936020830135935060409092013591905056fea264697066735822122046b53f2984cbf5adf3e9850bdbd978b04bf2673faae23f82bb65f6ed17a8ca6164736f6c63430008100033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
|
||||
@ -18,6 +18,12 @@
|
||||
"name": "beneficiary",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bytes32",
|
||||
"name": "minerId",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
@ -70,8 +76,8 @@
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060f18061001f6000396000f3fe60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea2646970667358221220d2f22ec6a41724281bad8a768c241562927a5fcc8ba600f3b3784f584a68c65864736f6c63430008100033",
|
||||
"deployedBytecode": "0x60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea2646970667358221220d2f22ec6a41724281bad8a768c241562927a5fcc8ba600f3b3784f584a68c65864736f6c63430008100033",
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060f18061001f6000396000f3fe60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea264697066735822122007df1d2999303b3bd440ba3a542d4ba59318a16f2d33109615522c89b0f299dc64736f6c63430008100033",
|
||||
"deployedBytecode": "0x60806040526004361060265760003560e01c806359e9670014602b578063b7a3c04c14603c575b600080fd5b603a60363660046058565b5050565b005b348015604757600080fd5b50603a60533660046079565b505050565b60008060408385031215606a57600080fd5b50508035926020909101359150565b600080600060608486031215608d57600080fd5b8335925060208401356001600160a01b038116811460aa57600080fd5b92959294505050604091909101359056fea264697066735822122007df1d2999303b3bd440ba3a542d4ba59318a16f2d33109615522c89b0f299dc64736f6c63430008100033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user