You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The "in memory" checkpoint states are similar to the old implementation: we have both Previous Root Checkpoint State and Current Root Checkpoint State per epoch.
90
-
* However in the "persisted to db or fs" part, we usually only persist 1 checkpoint state per epoch, the one that could potentially be justified/finalized later
91
-
* based on the view of blocks.
90
+
* However in the "persisted to db or fs" part
91
+
* - if there is no reorg, we only store 1 checkpoint state per epoch, the one that could potentially be justified/finalized later based on the view of the state
92
+
* - if there is reorg, we may store >=2 checkpoint states per epoch, including any checkpoints with unknown roots to the processed state
93
+
* - the goal is to make sure we can regen any states later if needed, and we have the checkpoint state that could be justified/finalized later
@@ -476,9 +479,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
476
479
* - 1 then we'll persist {root: b1, epoch n-1} checkpoint state to disk. Note that at epoch n there is both {root: b0, epoch: n} and {root: c0, epoch: n} checkpoint states in memory
477
480
* - 2 then we'll persist {root: b2, epoch n-2} checkpoint state to disk, there are also 2 checkpoint states in memory at epoch n, same to the above (maxEpochsInMemory=1)
478
481
*
479
-
* As of Jan 2024, it takes 1.2s to persist a holesky state on fast server. TODO:
480
-
* - improve state serialization time
481
-
* - or research how to only store diff against the finalized state
482
+
* As of Mar 2024, it takes <=350ms to persist a holesky state on fast server
// for each epoch, usually there are 2 rootHexes respective to the 2 checkpoint states: Previous Root Checkpoint State and Current Root Checkpoint State
655
+
constcpRootHexes=this.epochIndex.get(epoch)??[];
656
+
constpersistedRootHexes=newSet<RootHex>();
657
+
658
+
// 1) if there is no CRCS, persist PRCS (block 0 of epoch is skipped). In this case prevEpochRoot === epochBoundaryHex
659
+
// 2) if there are PRCS and CRCS, persist CRCS => persist CRCS
660
+
// => this is simplified to always persist epochBoundaryHex
661
+
persistedRootHexes.add(epochBoundaryHex);
662
+
663
+
// 3) persist any states with unknown roots to this state
0 commit comments