Skip to content

Commit 183b6cb

Browse files
authored
Merge pull request #1180 from permaweb/jfrain99/ignore-local-checkpoints-cu
feat(cu): ignore local checkpoints in env
2 parents a5b0678 + d10d81d commit 183b6cb

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

servers/cu/src/bootstrap.js

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ export const createApis = async (ctx) => {
406406
CHECKPONT_VALIDATION_STEPS: ctx.CHECKPONT_VALIDATION_STEPS,
407407
CHECKPONT_VALIDATION_THRESH: ctx.CHECKPONT_VALIDATION_THRESH,
408408
CHECKPONT_VALIDATION_RETRIES: ctx.CHECKPONT_VALIDATION_RETRIES,
409+
IGNORE_LOCAL_CHECKPOINTS: ctx.IGNORE_LOCAL_CHECKPOINTS,
409410
logger
410411
}),
411412
saveLatestProcessMemory: AoProcessClient.saveLatestProcessMemoryWith({

servers/cu/src/config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ const CONFIG_ENVS = {
177177
ALLOW_OWNERS: process.env.ALLOW_OWNERS || [],
178178
CHECKPONT_VALIDATION_STEPS: process.env.CHECKPONT_VALIDATION_STEPS || 10,
179179
CHECKPONT_VALIDATION_THRESH: process.env.CHECKPONT_VALIDATION_THRESH || 0.75,
180-
CHECKPONT_VALIDATION_RETRIES: process.env.CHECKPONT_VALIDATION_RETRIES || 5
180+
CHECKPONT_VALIDATION_RETRIES: process.env.CHECKPONT_VALIDATION_RETRIES || 5,
181+
IGNORE_LOCAL_CHECKPOINTS: process.env.IGNORE_LOCAL_CHECKPOINTS === 'true'
181182
},
182183
production: {
183184
MODE,
@@ -234,7 +235,8 @@ const CONFIG_ENVS = {
234235
ALLOW_OWNERS: process.env.ALLOW_OWNERS || [],
235236
CHECKPONT_VALIDATION_STEPS: process.env.CHECKPONT_VALIDATION_STEPS || 10,
236237
CHECKPONT_VALIDATION_THRESH: process.env.CHECKPONT_VALIDATION_THRESH || 0.75,
237-
CHECKPONT_VALIDATION_RETRIES: process.env.CHECKPONT_VALIDATION_RETRIES || 5
238+
CHECKPONT_VALIDATION_RETRIES: process.env.CHECKPONT_VALIDATION_RETRIES || 5,
239+
IGNORE_LOCAL_CHECKPOINTS: process.env.IGNORE_LOCAL_CHECKPOINTS === 'true'
238240
}
239241
}
240242

servers/cu/src/domain/model.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,12 @@ export const domainConfigSchema = z.object({
241241
* How many times to jump backwards when failing to validate
242242
* a state from a checkpoint
243243
*/
244-
CHECKPONT_VALIDATION_RETRIES: positiveIntSchema
244+
CHECKPONT_VALIDATION_RETRIES: positiveIntSchema,
245+
246+
/**
247+
* Whether to ignore local checkpoints. Set to 'true' to ignore local checkpoints (file and record checkpoints).
248+
*/
249+
IGNORE_LOCAL_CHECKPOINTS: z.preprocess((val) => !!val, z.boolean())
245250
})
246251

247252
export const bufferSchema = z.any().refine(buffer => {

servers/cu/src/effects/ao-process.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ export function findLatestProcessMemoryWith ({
804804
hashWasmMemory,
805805
CHECKPONT_VALIDATION_STEPS,
806806
CHECKPONT_VALIDATION_THRESH,
807-
CHECKPONT_VALIDATION_RETRIES
807+
CHECKPONT_VALIDATION_RETRIES,
808+
IGNORE_LOCAL_CHECKPOINTS
808809
}) {
809810
const logger = _logger.child('ao-process:findLatestProcessMemory')
810811
readProcessMemoryFile = fromPromise(readProcessMemoryFile)
@@ -1129,6 +1130,12 @@ export function findLatestProcessMemoryWith ({
11291130
*/
11301131
function maybeFile (args) {
11311132
const { processId, omitMemory } = args
1133+
1134+
if (IGNORE_LOCAL_CHECKPOINTS) {
1135+
logger('Local Checkpoints are ignored for this CU. Not attempting to query file checkpoints...', processId)
1136+
return Rejected(args)
1137+
}
1138+
11321139
/**
11331140
* Attempt to find the latest checkpoint in a file
11341141
*/
@@ -1183,6 +1190,10 @@ export function findLatestProcessMemoryWith ({
11831190

11841191
function maybeRecord (args) {
11851192
const { processId, omitMemory } = args
1193+
if (IGNORE_LOCAL_CHECKPOINTS) {
1194+
logger('Local Checkpoints are ignored for this CU. Not attempting to query record checkpoints...', processId)
1195+
return Rejected(args)
1196+
}
11861197

11871198
if (PROCESS_IGNORE_ARWEAVE_CHECKPOINTS.includes(processId)) {
11881199
logger('Arweave Checkpoints are ignored for process "%s". Not attempting to query file checkpoints...', processId)

0 commit comments

Comments
 (0)