mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-09-20 07:27:31 +00:00
do not fail on prune error
This commit is contained in:
parent
b5cb0e0d58
commit
c4816c3ecf
@ -15,7 +15,7 @@ use storage::log_store::log_manager::PORA_CHUNK_SIZE;
|
|||||||
use storage_async::Store;
|
use storage_async::Store;
|
||||||
use task_executor::TaskExecutor;
|
use task_executor::TaskExecutor;
|
||||||
use tokio::sync::{broadcast, mpsc};
|
use tokio::sync::{broadcast, mpsc};
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, error, info};
|
||||||
use zgs_spec::SECTORS_PER_PRICING;
|
use zgs_spec::SECTORS_PER_PRICING;
|
||||||
|
|
||||||
// Start pruning when the db directory size exceeds 0.9 * limit.
|
// Start pruning when the db directory size exceeds 0.9 * limit.
|
||||||
@ -58,7 +58,7 @@ pub struct Pruner {
|
|||||||
sender: mpsc::UnboundedSender<PrunerMessage>,
|
sender: mpsc::UnboundedSender<PrunerMessage>,
|
||||||
miner_sender: Option<broadcast::Sender<MinerMessage>>,
|
miner_sender: Option<broadcast::Sender<MinerMessage>>,
|
||||||
|
|
||||||
reward_contract: ChunkLinearReward<Arc<Provider<RetryClient<Http>>>>,
|
reward_contract: ChunkLinearReward<Provider<RetryClient<Http>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pruner {
|
impl Pruner {
|
||||||
@ -75,6 +75,8 @@ impl Pruner {
|
|||||||
.await?
|
.await?
|
||||||
.unwrap_or((0, 0));
|
.unwrap_or((0, 0));
|
||||||
|
|
||||||
|
info!(config.rpc_endpoint_url, "pruner config rpc");
|
||||||
|
|
||||||
let provider = Arc::new(Provider::new(
|
let provider = Arc::new(Provider::new(
|
||||||
RetryClientBuilder::default()
|
RetryClientBuilder::default()
|
||||||
.rate_limit_retries(config.rate_limit_retries)
|
.rate_limit_retries(config.rate_limit_retries)
|
||||||
@ -85,7 +87,7 @@ impl Pruner {
|
|||||||
Box::new(HttpRateLimitRetryPolicy),
|
Box::new(HttpRateLimitRetryPolicy),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
let reward_contract = ChunkLinearReward::new(config.reward_address, Arc::new(provider));
|
let reward_contract = ChunkLinearReward::new(config.reward_address, provider);
|
||||||
let (tx, rx) = mpsc::unbounded_channel();
|
let (tx, rx) = mpsc::unbounded_channel();
|
||||||
let pruner = Pruner {
|
let pruner = Pruner {
|
||||||
config,
|
config,
|
||||||
@ -116,30 +118,36 @@ impl Pruner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check no reward chunks and prune.
|
// Check no reward chunks and prune.
|
||||||
let new_first_rewardable = self.reward_contract.first_rewardable_chunk().call().await?;
|
match self.reward_contract.first_rewardable_chunk().call().await {
|
||||||
if let Some(no_reward_list) = self
|
Ok(new_first_rewardable) => {
|
||||||
.maybe_forward_first_rewardable(new_first_rewardable)
|
if let Some(no_reward_list) = self
|
||||||
.await?
|
.maybe_forward_first_rewardable(new_first_rewardable)
|
||||||
{
|
.await?
|
||||||
info!(
|
{
|
||||||
?new_first_rewardable,
|
info!(
|
||||||
"first rewardable chunk moves forward, start pruning"
|
?new_first_rewardable,
|
||||||
);
|
"first rewardable chunk moves forward, start pruning"
|
||||||
self.prune_tx(
|
);
|
||||||
self.first_rewardable_chunk * SECTORS_PER_PRICING as u64,
|
self.prune_tx(
|
||||||
new_first_rewardable * SECTORS_PER_PRICING as u64,
|
self.first_rewardable_chunk * SECTORS_PER_PRICING as u64,
|
||||||
)
|
new_first_rewardable * SECTORS_PER_PRICING as u64,
|
||||||
.await?;
|
)
|
||||||
self.prune_in_batch(no_reward_list).await?;
|
.await?;
|
||||||
|
self.prune_in_batch(no_reward_list).await?;
|
||||||
|
|
||||||
self.first_rewardable_chunk = new_first_rewardable;
|
self.first_rewardable_chunk = new_first_rewardable;
|
||||||
self.put_first_rewardable_chunk_index(
|
self.put_first_rewardable_chunk_index(
|
||||||
self.first_rewardable_chunk,
|
self.first_rewardable_chunk,
|
||||||
self.first_tx_seq,
|
self.first_tx_seq,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
tokio::time::sleep(self.config.check_time).await;
|
tokio::time::sleep(self.config.check_time).await;
|
||||||
|
}
|
||||||
|
e => {
|
||||||
|
error!("handle reward contract read fails, e={:?}", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use crate::ZgsConfig;
|
use crate::ZgsConfig;
|
||||||
use ethereum_types::{H256, U256};
|
use ethereum_types::{H256, U256};
|
||||||
use ethers::prelude::{Http, Middleware, Provider};
|
use ethers::prelude::{Http, Middleware, Provider};
|
||||||
|
use ethers::providers::{HttpRateLimitRetryPolicy, RetryClientBuilder};
|
||||||
use log_entry_sync::{CacheConfig, ContractAddress, LogSyncConfig};
|
use log_entry_sync::{CacheConfig, ContractAddress, LogSyncConfig};
|
||||||
use miner::MinerConfig;
|
use miner::MinerConfig;
|
||||||
use network::NetworkConfig;
|
use network::NetworkConfig;
|
||||||
@ -10,6 +11,7 @@ use pruner::PrunerConfig;
|
|||||||
use rpc::RPCConfig;
|
use rpc::RPCConfig;
|
||||||
use shared_types::NetworkIdentity;
|
use shared_types::NetworkIdentity;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use storage::config::ShardConfig;
|
use storage::config::ShardConfig;
|
||||||
use storage::StorageConfig;
|
use storage::StorageConfig;
|
||||||
@ -31,8 +33,16 @@ impl ZgsConfig {
|
|||||||
.log_contract_address
|
.log_contract_address
|
||||||
.parse::<ContractAddress>()
|
.parse::<ContractAddress>()
|
||||||
.map_err(|e| format!("Unable to parse log_contract_address: {:?}", e))?;
|
.map_err(|e| format!("Unable to parse log_contract_address: {:?}", e))?;
|
||||||
let provider = Provider::<Http>::try_from(&self.blockchain_rpc_endpoint)
|
let provider = Provider::new(
|
||||||
.map_err(|e| format!("Can not parse blockchain endpoint: {:?}", e))?;
|
RetryClientBuilder::default()
|
||||||
|
.rate_limit_retries(10)
|
||||||
|
.timeout_retries(10)
|
||||||
|
.initial_backoff(Duration::from_millis(1000))
|
||||||
|
.build(
|
||||||
|
Http::from_str(&self.blockchain_rpc_endpoint).unwrap(),
|
||||||
|
Box::new(HttpRateLimitRetryPolicy),
|
||||||
|
),
|
||||||
|
);
|
||||||
let chain_id = provider
|
let chain_id = provider
|
||||||
.get_chainid()
|
.get_chainid()
|
||||||
.await
|
.await
|
||||||
|
Loading…
Reference in New Issue
Block a user