From dbd865fded49e51251c2ce0b6ed34eaf84e14df7 Mon Sep 17 00:00:00 2001 From: peilun-conflux <48905552+peilun-conflux@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:31:19 +0800 Subject: [PATCH] Change db_max_num_chunks to db_max_num_sectors. (#137) * Change db_max_num_chunks to db_max_num_sectors. * Update tests and config files. * Revert contract change. --- node/pruner/src/lib.rs | 4 ++-- node/src/config/convert.rs | 4 ++-- node/src/config/mod.rs | 2 +- run/config-testnet.toml | 4 ++-- run/config.toml | 4 ++-- tests/mine_with_market_test.py | 2 +- tests/pruner_test.py | 2 +- tests/shard_sync_test.py | 6 +++--- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/node/pruner/src/lib.rs b/node/pruner/src/lib.rs index 4ceab42..fa4e5a9 100644 --- a/node/pruner/src/lib.rs +++ b/node/pruner/src/lib.rs @@ -17,7 +17,7 @@ const PRUNE_THRESHOLD: f32 = 0.9; pub struct PrunerConfig { pub shard_config: ShardConfig, pub db_path: PathBuf, - pub max_num_chunks: usize, + pub max_num_sectors: usize, pub check_time: Duration, pub batch_size: usize, pub batch_wait_time: Duration, @@ -25,7 +25,7 @@ pub struct PrunerConfig { impl PrunerConfig { 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 } } diff --git a/node/src/config/convert.rs b/node/src/config/convert.rs index 3f9cb36..f33fdb5 100644 --- a/node/src/config/convert.rs +++ b/node/src/config/convert.rs @@ -201,12 +201,12 @@ impl ZgsConfig { } pub fn pruner_config(&self) -> Result, 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()?; Ok(Some(PrunerConfig { shard_config, db_path: self.db_dir.clone().into(), - max_num_chunks, + max_num_sectors, check_time: Duration::from_secs(self.prune_check_time_s), batch_size: self.prune_batch_size, batch_wait_time: Duration::from_millis(self.prune_batch_wait_time_ms), diff --git a/node/src/config/mod.rs b/node/src/config/mod.rs index 5f66515..42ce4f1 100644 --- a/node/src/config/mod.rs +++ b/node/src/config/mod.rs @@ -63,7 +63,7 @@ build_config! { // db (db_dir, (String), "db".to_string()) - (db_max_num_chunks, (Option), None) + (db_max_num_sectors, (Option), None) (prune_check_time_s, (u64), 60) (prune_batch_size, (usize), 1024) (prune_batch_wait_time_ms, (u64), 1000) diff --git a/run/config-testnet.toml b/run/config-testnet.toml index 012de07..6dbf85b 100644 --- a/run/config-testnet.toml +++ b/run/config-testnet.toml @@ -194,11 +194,11 @@ mine_contract_address = "0x85F6722319538A805ED5733c5F4882d96F1C7384" ####################################################################### # The max number of chunk entries to store in db. # 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` # and store only half data. # -# db_max_num_chunks = 1000000000 +# db_max_num_sectors = 1000000000 # The format is /, where the shard number is 2^n. # This only applies if there is no stored shard config in db. diff --git a/run/config.toml b/run/config.toml index f7f7132..540e47e 100644 --- a/run/config.toml +++ b/run/config.toml @@ -194,11 +194,11 @@ ####################################################################### # The max number of chunk entries to store in db. # 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` # and store only half data. # -# db_max_num_chunks = 1000000000 +# db_max_num_sectors = 1000000000 # The format is /, where the shard number is 2^n. # This only applies if there is no stored shard config in db. diff --git a/tests/mine_with_market_test.py b/tests/mine_with_market_test.py index db2702a..4f99cba 100755 --- a/tests/mine_with_market_test.py +++ b/tests/mine_with_market_test.py @@ -16,7 +16,7 @@ class MineTest(TestFramework): self.num_blockchain_nodes = 1 self.num_nodes = 1 self.zgs_node_configs[0] = { - "db_max_num_chunks": 2**30, + "db_max_num_sectors": 2**30, "miner_key": GENESIS_PRIV_KEY, "shard_position": "3 / 8", } diff --git a/tests/pruner_test.py b/tests/pruner_test.py index 81ee1e0..395fc81 100755 --- a/tests/pruner_test.py +++ b/tests/pruner_test.py @@ -12,7 +12,7 @@ class PrunerTest(TestFramework): self.num_blockchain_nodes = 1 self.num_nodes = 1 self.zgs_node_configs[0] = { - "db_max_num_chunks": 16 * 1024, + "db_max_num_sectors": 16 * 1024, "prune_check_time_s": 1, "prune_batch_wait_time_ms": 10, } diff --git a/tests/shard_sync_test.py b/tests/shard_sync_test.py index 1a38658..d838fb5 100755 --- a/tests/shard_sync_test.py +++ b/tests/shard_sync_test.py @@ -12,15 +12,15 @@ class PrunerTest(TestFramework): self.num_blockchain_nodes = 1 self.num_nodes = 4 self.zgs_node_configs[0] = { - "db_max_num_chunks": 2 ** 30, + "db_max_num_sectors": 2 ** 30, "shard_position": "0/2" } self.zgs_node_configs[1] = { - "db_max_num_chunks": 2 ** 30, + "db_max_num_sectors": 2 ** 30, "shard_position": "1/2" } self.zgs_node_configs[3] = { - "db_max_num_chunks": 2 ** 30, + "db_max_num_sectors": 2 ** 30, "shard_position": "1/4" }