From adfa0a562e23809027a8c3c121fc8855466a8e2e Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Thu, 9 Apr 2026 09:06:47 +0800 Subject: [PATCH 1/2] fix: use smaller skip length for `tipset_by_height` cache --- src/chain/store/index.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/chain/store/index.rs b/src/chain/store/index.rs index 1d08857834b3..0cbbbcecb5b3 100644 --- a/src/chain/store/index.rs +++ b/src/chain/store/index.rs @@ -51,8 +51,8 @@ impl ChainIndex { let ts_height_cache: SizeTrackingLruCache = SizeTrackingLruCache::new_with_metrics( "tipset_by_height".into(), - // 20480 * 900 = 18432000 which is sufficient for mainnet - nonzero!(20480_usize), + // 1048576 * 20 = 20971520 which is sufficient for mainnet + nonzero!(1048576_usize), ); Self { ts_cache, @@ -152,8 +152,9 @@ impl ChainIndex { ) -> Result { use crate::shim::policy::policy_constants::CHAIN_FINALITY; - // use `CHAIN_FINALITY` as checkpoint interval - const CHECKPOINT_INTERVAL: ChainEpoch = CHAIN_FINALITY; + // use `20` as checkpoint interval to match Lotus: + // + const CHECKPOINT_INTERVAL: ChainEpoch = 20; fn next_checkpoint(epoch: ChainEpoch) -> ChainEpoch { epoch - epoch.mod_floor(&CHECKPOINT_INTERVAL) + CHECKPOINT_INTERVAL } From 74bbc5cc94715fe07fbdb26c4021f92234514b0d Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Thu, 9 Apr 2026 18:47:58 +0800 Subject: [PATCH 2/2] resolve comments --- src/chain/store/index.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chain/store/index.rs b/src/chain/store/index.rs index 0cbbbcecb5b3..aa4cb1f95d5c 100644 --- a/src/chain/store/index.rs +++ b/src/chain/store/index.rs @@ -52,6 +52,7 @@ impl ChainIndex { SizeTrackingLruCache::new_with_metrics( "tipset_by_height".into(), // 1048576 * 20 = 20971520 which is sufficient for mainnet + // Maximum ~32MiB RAM usage nonzero!(1048576_usize), ); Self { @@ -153,7 +154,7 @@ impl ChainIndex { use crate::shim::policy::policy_constants::CHAIN_FINALITY; // use `20` as checkpoint interval to match Lotus: - // + // const CHECKPOINT_INTERVAL: ChainEpoch = 20; fn next_checkpoint(epoch: ChainEpoch) -> ChainEpoch { epoch - epoch.mod_floor(&CHECKPOINT_INTERVAL) + CHECKPOINT_INTERVAL