File tree 7 files changed +19
-6
lines changed
7 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ export class BeaconChain implements IBeaconChain {
184
184
{
185
185
config,
186
186
db,
187
+ dataDir,
187
188
logger,
188
189
processShutdownCallback,
189
190
clock,
@@ -196,6 +197,7 @@ export class BeaconChain implements IBeaconChain {
196
197
} : {
197
198
config : BeaconConfig ;
198
199
db : IBeaconDb ;
200
+ dataDir : string ;
199
201
logger : Logger ;
200
202
processShutdownCallback : ProcessShutdownCallback ;
201
203
/** Used for testing to supply fake clock */
@@ -284,7 +286,7 @@ export class BeaconChain implements IBeaconChain {
284
286
this . pubkey2index = cachedState . epochCtx . pubkey2index ;
285
287
this . index2pubkey = cachedState . epochCtx . index2pubkey ;
286
288
287
- const fileDataStore = opts . nHistoricalStatesFileDataStore ?? false ;
289
+ const fileDataStore = opts . nHistoricalStatesFileDataStore ?? true ;
288
290
const blockStateCache = this . opts . nHistoricalStates
289
291
? new FIFOBlockStateCache ( this . opts , { metrics} )
290
292
: new BlockStateCacheImpl ( { metrics} ) ;
@@ -301,7 +303,7 @@ export class BeaconChain implements IBeaconChain {
301
303
bufferPool : this . bufferPool ,
302
304
datastore : fileDataStore
303
305
? // debug option if we want to investigate any issues with the DB
304
- new FileCPStateDatastore ( )
306
+ new FileCPStateDatastore ( dataDir )
305
307
: // production option
306
308
new DbCPStateDatastore ( this . db ) ,
307
309
} ,
Original file line number Diff line number Diff line change @@ -117,7 +117,11 @@ export const defaultChainOptions: IChainOptions = {
117
117
// since this batch attestation work is designed to work with useWorker=true, make this the lowest value
118
118
minSameMessageSignatureSetsToBatch : 2 ,
119
119
nHistoricalStates : true ,
120
- nHistoricalStatesFileDataStore : false ,
120
+ // as of Feb 2025, this option turned out to be very useful:
121
+ // - it allows to share a persisted checkpoint state to other nodes
122
+ // - users can prune the persisted checkpoint state files manually to save disc space
123
+ // - it helps debug easier when network is unfinalized
124
+ nHistoricalStatesFileDataStore : true ,
121
125
maxBlockStates : DEFAULT_MAX_BLOCK_STATES ,
122
126
maxCPStateEpochsInMemory : DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY ,
123
127
} ;
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ const CHECKPOINT_FILE_NAME_LENGTH = 82;
13
13
export class FileCPStateDatastore implements CPStateDatastore {
14
14
private readonly folderPath : string ;
15
15
16
- constructor ( parentDir = "." ) {
17
- // by default use the beacon folder `/beacon/checkpoint_states`
18
- this . folderPath = path . join ( parentDir , CHECKPOINT_STATES_FOLDER ) ;
16
+ constructor ( dataDir : string ) {
17
+ // service deployment: `/beacon/checkpoint_states`
18
+ // docker deployment: `/data/checkpoint_states`
19
+ this . folderPath = path . join ( dataDir , CHECKPOINT_STATES_FOLDER ) ;
19
20
}
20
21
21
22
async init ( ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export type BeaconNodeInitModules = {
52
52
logger : LoggerNode ;
53
53
processShutdownCallback : ProcessShutdownCallback ;
54
54
peerId : PeerId ;
55
+ dataDir : string ;
55
56
peerStoreDir ?: string ;
56
57
anchorState : BeaconStateAllForks ;
57
58
wsCheckpoint ?: phase0 . Checkpoint ;
@@ -149,6 +150,7 @@ export class BeaconNode {
149
150
logger,
150
151
processShutdownCallback,
151
152
peerId,
153
+ dataDir,
152
154
peerStoreDir,
153
155
anchorState,
154
156
wsCheckpoint,
@@ -224,6 +226,7 @@ export class BeaconNode {
224
226
const chain = new BeaconChain ( opts . chain , {
225
227
config,
226
228
clock,
229
+ dataDir,
227
230
db,
228
231
logger : logger . child ( { module : LoggerModule . chain } ) ,
229
232
processShutdownCallback,
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ const forkChoiceTest =
111
111
{
112
112
config : createBeaconConfig ( config , state . genesisValidatorsRoot ) ,
113
113
db : getMockedBeaconDb ( ) ,
114
+ dataDir : "." ,
114
115
logger,
115
116
processShutdownCallback : ( ) => { } ,
116
117
clock,
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ export async function getDevBeaconNode(
94
94
logger,
95
95
processShutdownCallback : ( ) => { } ,
96
96
peerId,
97
+ dataDir : "." ,
97
98
peerStoreDir,
98
99
anchorState,
99
100
wsCheckpoint : opts . wsCheckpoint ,
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise<void
86
86
logger,
87
87
processShutdownCallback,
88
88
peerId,
89
+ dataDir : beaconPaths . dataDir ,
89
90
peerStoreDir : beaconPaths . peerStoreDir ,
90
91
anchorState,
91
92
wsCheckpoint,
You can’t perform that action at this time.
0 commit comments