mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-12-26 08:15:17 +00:00
Merge branch 'main' into prune_no_reward
This commit is contained in:
commit
0350ea7be5
@ -26,7 +26,7 @@ const CHUNKS_PER_PRICING: u64 = (SECTORS_PER_PRICING / PORA_CHUNK_SIZE) as u64;
|
|||||||
pub struct PrunerConfig {
|
pub struct PrunerConfig {
|
||||||
pub shard_config: ShardConfig,
|
pub shard_config: ShardConfig,
|
||||||
pub db_path: PathBuf,
|
pub db_path: PathBuf,
|
||||||
pub max_num_chunks: usize,
|
pub max_num_sectors: usize,
|
||||||
pub check_time: Duration,
|
pub check_time: Duration,
|
||||||
pub batch_size: usize,
|
pub batch_size: usize,
|
||||||
pub batch_wait_time: Duration,
|
pub batch_wait_time: Duration,
|
||||||
@ -37,7 +37,7 @@ pub struct PrunerConfig {
|
|||||||
|
|
||||||
impl PrunerConfig {
|
impl PrunerConfig {
|
||||||
fn start_prune_size(&self) -> u64 {
|
fn start_prune_size(&self) -> u64 {
|
||||||
(self.max_num_chunks as f32 * PRUNE_THRESHOLD) as u64
|
(self.max_num_sectors as f32 * PRUNE_THRESHOLD) as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_provider(&self) -> Result<Provider<Http>> {
|
fn make_provider(&self) -> Result<Provider<Http>> {
|
||||||
|
@ -201,7 +201,7 @@ impl ZgsConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn pruner_config(&self) -> Result<Option<PrunerConfig>, String> {
|
pub fn pruner_config(&self) -> Result<Option<PrunerConfig>, String> {
|
||||||
if let Some(max_num_chunks) = self.db_max_num_chunks {
|
if let Some(max_num_sectors) = self.db_max_num_sectors {
|
||||||
let shard_config = self.shard_config()?;
|
let shard_config = self.shard_config()?;
|
||||||
let reward_address = self
|
let reward_address = self
|
||||||
.reward_contract_address
|
.reward_contract_address
|
||||||
@ -210,7 +210,7 @@ impl ZgsConfig {
|
|||||||
Ok(Some(PrunerConfig {
|
Ok(Some(PrunerConfig {
|
||||||
shard_config,
|
shard_config,
|
||||||
db_path: self.db_dir.clone().into(),
|
db_path: self.db_dir.clone().into(),
|
||||||
max_num_chunks,
|
max_num_sectors,
|
||||||
check_time: Duration::from_secs(self.prune_check_time_s),
|
check_time: Duration::from_secs(self.prune_check_time_s),
|
||||||
batch_size: self.prune_batch_size,
|
batch_size: self.prune_batch_size,
|
||||||
batch_wait_time: Duration::from_millis(self.prune_batch_wait_time_ms),
|
batch_wait_time: Duration::from_millis(self.prune_batch_wait_time_ms),
|
||||||
|
@ -63,7 +63,7 @@ build_config! {
|
|||||||
|
|
||||||
// db
|
// db
|
||||||
(db_dir, (String), "db".to_string())
|
(db_dir, (String), "db".to_string())
|
||||||
(db_max_num_chunks, (Option<usize>), None)
|
(db_max_num_sectors, (Option<usize>), None)
|
||||||
(prune_check_time_s, (u64), 60)
|
(prune_check_time_s, (u64), 60)
|
||||||
(prune_batch_size, (usize), 16 * 1024)
|
(prune_batch_size, (usize), 16 * 1024)
|
||||||
(prune_batch_wait_time_ms, (u64), 1000)
|
(prune_batch_wait_time_ms, (u64), 1000)
|
||||||
|
@ -194,11 +194,11 @@ mine_contract_address = "0x85F6722319538A805ED5733c5F4882d96F1C7384"
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# The max number of chunk entries to store in db.
|
# The max number of chunk entries to store in db.
|
||||||
# Each entry is 256B, so the db size is roughly limited to
|
# Each entry is 256B, so the db size is roughly limited to
|
||||||
# `256 * db_max_num_chunks` Bytes.
|
# `256 * db_max_num_sectors` Bytes.
|
||||||
# If this limit is reached, the node will update its `shard_position`
|
# If this limit is reached, the node will update its `shard_position`
|
||||||
# and store only half data.
|
# and store only half data.
|
||||||
#
|
#
|
||||||
# db_max_num_chunks = 1000000000
|
# db_max_num_sectors = 1000000000
|
||||||
|
|
||||||
# The format is <shard_id>/<shard_number>, where the shard number is 2^n.
|
# The format is <shard_id>/<shard_number>, where the shard number is 2^n.
|
||||||
# This only applies if there is no stored shard config in db.
|
# This only applies if there is no stored shard config in db.
|
||||||
|
@ -194,11 +194,11 @@
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# The max number of chunk entries to store in db.
|
# The max number of chunk entries to store in db.
|
||||||
# Each entry is 256B, so the db size is roughly limited to
|
# Each entry is 256B, so the db size is roughly limited to
|
||||||
# `256 * db_max_num_chunks` Bytes.
|
# `256 * db_max_num_sectors` Bytes.
|
||||||
# If this limit is reached, the node will update its `shard_position`
|
# If this limit is reached, the node will update its `shard_position`
|
||||||
# and store only half data.
|
# and store only half data.
|
||||||
#
|
#
|
||||||
# db_max_num_chunks = 1000000000
|
# db_max_num_sectors = 1000000000
|
||||||
|
|
||||||
# The format is <shard_id>/<shard_number>, where the shard number is 2^n.
|
# The format is <shard_id>/<shard_number>, where the shard number is 2^n.
|
||||||
# This only applies if there is no stored shard config in db.
|
# This only applies if there is no stored shard config in db.
|
||||||
|
@ -16,7 +16,7 @@ class MineTest(TestFramework):
|
|||||||
self.num_blockchain_nodes = 1
|
self.num_blockchain_nodes = 1
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.zgs_node_configs[0] = {
|
self.zgs_node_configs[0] = {
|
||||||
"db_max_num_chunks": 2**30,
|
"db_max_num_sectors": 2**30,
|
||||||
"miner_key": GENESIS_PRIV_KEY,
|
"miner_key": GENESIS_PRIV_KEY,
|
||||||
"shard_position": "3 / 8",
|
"shard_position": "3 / 8",
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class PrunerTest(TestFramework):
|
|||||||
self.num_blockchain_nodes = 1
|
self.num_blockchain_nodes = 1
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.zgs_node_configs[0] = {
|
self.zgs_node_configs[0] = {
|
||||||
"db_max_num_chunks": 32 * 1024 * 1024,
|
"db_max_num_sectors": 32 * 1024 * 1024,
|
||||||
# "miner_key": GENESIS_PRIV_KEY,
|
# "miner_key": GENESIS_PRIV_KEY,
|
||||||
"prune_check_time_s": 1,
|
"prune_check_time_s": 1,
|
||||||
"prune_batch_wait_time_ms": 1,
|
"prune_batch_wait_time_ms": 1,
|
||||||
|
@ -12,15 +12,15 @@ class PrunerTest(TestFramework):
|
|||||||
self.num_blockchain_nodes = 1
|
self.num_blockchain_nodes = 1
|
||||||
self.num_nodes = 4
|
self.num_nodes = 4
|
||||||
self.zgs_node_configs[0] = {
|
self.zgs_node_configs[0] = {
|
||||||
"db_max_num_chunks": 2 ** 30,
|
"db_max_num_sectors": 2 ** 30,
|
||||||
"shard_position": "0/2"
|
"shard_position": "0/2"
|
||||||
}
|
}
|
||||||
self.zgs_node_configs[1] = {
|
self.zgs_node_configs[1] = {
|
||||||
"db_max_num_chunks": 2 ** 30,
|
"db_max_num_sectors": 2 ** 30,
|
||||||
"shard_position": "1/2"
|
"shard_position": "1/2"
|
||||||
}
|
}
|
||||||
self.zgs_node_configs[3] = {
|
self.zgs_node_configs[3] = {
|
||||||
"db_max_num_chunks": 2 ** 30,
|
"db_max_num_sectors": 2 ** 30,
|
||||||
"shard_position": "1/4"
|
"shard_position": "1/4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user