@certik/skynet 0.10.44 → 0.10.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/app.d.ts +8 -0
- package/app.js +13 -0
- package/const.js +11 -10
- package/deploy.js +20 -5
- package/examples/indexer +1 -0
- package/indexer.js +85 -79
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/app.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type Serve = {
|
|
|
16
16
|
prefix: string;
|
|
17
17
|
port: number;
|
|
18
18
|
apiKey: string;
|
|
19
|
+
killTimeout: string;
|
|
19
20
|
cpu: number;
|
|
20
21
|
mem: number;
|
|
21
22
|
instances: number;
|
|
@@ -29,6 +30,7 @@ export type Consume = {
|
|
|
29
30
|
}) => Promise<void>;
|
|
30
31
|
topic: ({ protocol }: { protocol: string }) => string;
|
|
31
32
|
maxRetry: number;
|
|
33
|
+
killTimeout: string;
|
|
32
34
|
cpu: number;
|
|
33
35
|
mem: number;
|
|
34
36
|
}
|
|
@@ -52,6 +54,7 @@ export type Produce = {
|
|
|
52
54
|
deadLetterTopic: ({ protocol }) => string;
|
|
53
55
|
batchSize: number;
|
|
54
56
|
maxRetry: number;
|
|
57
|
+
killTimeout: string;
|
|
55
58
|
cpu: number;
|
|
56
59
|
mem: number;
|
|
57
60
|
}
|
|
@@ -61,6 +64,9 @@ export type Check = {
|
|
|
61
64
|
=> ({ type: string, message: string });
|
|
62
65
|
schedule: string;
|
|
63
66
|
slackChannel: string;
|
|
67
|
+
killTimeout: string;
|
|
68
|
+
cpu: number;
|
|
69
|
+
mem: number;
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export type Build = {
|
|
@@ -68,6 +74,7 @@ export type Build = {
|
|
|
68
74
|
=> void;
|
|
69
75
|
batchSize: number;
|
|
70
76
|
schedule: string;
|
|
77
|
+
killTimeout: string;
|
|
71
78
|
cpu: number;
|
|
72
79
|
mem: number;
|
|
73
80
|
}
|
|
@@ -84,6 +91,7 @@ export type Validate = {
|
|
|
84
91
|
=> void;
|
|
85
92
|
batchSize: number;
|
|
86
93
|
schedule: string;
|
|
94
|
+
killTimeout: string;
|
|
87
95
|
cpu: number;
|
|
88
96
|
mem: number;
|
|
89
97
|
}
|
package/app.js
CHANGED
|
@@ -205,11 +205,13 @@ function indexer({ name, selector, build, check, env = {}, region = "us-east-1"
|
|
|
205
205
|
env,
|
|
206
206
|
schedule: build.schedule,
|
|
207
207
|
restart: build.restart,
|
|
208
|
+
killTimeout: build.killTimeout,
|
|
208
209
|
cpu: build.cpu,
|
|
209
210
|
mem: build.mem,
|
|
210
211
|
check: check && {
|
|
211
212
|
bin: `${bin} check`,
|
|
212
213
|
schedule: check.schedule,
|
|
214
|
+
killTimeout: check.killTimeout,
|
|
213
215
|
cpu: check.cpu || 100,
|
|
214
216
|
mem: check.mem || 100,
|
|
215
217
|
},
|
|
@@ -313,18 +315,23 @@ function modeIndexer({ name, selector, state, build, validate, check, env = {},
|
|
|
313
315
|
env,
|
|
314
316
|
|
|
315
317
|
deltaSchedule: build.schedule,
|
|
318
|
+
deltaKillTimeout: build.killTimeout,
|
|
316
319
|
deltaCpu: build.cpu,
|
|
317
320
|
deltaMem: build.mem,
|
|
321
|
+
|
|
322
|
+
rebuildKillTimeout: build.killTimeout,
|
|
318
323
|
rebuildCpu: build.cpu,
|
|
319
324
|
rebuildMem: build.mem,
|
|
320
325
|
|
|
321
326
|
validateSchedule: validate && validate.schedule,
|
|
327
|
+
validateKillTimeout: validate && validate.killTimeout,
|
|
322
328
|
validateCpu: validate && validate.cpu,
|
|
323
329
|
validateMem: validate && validate.mem,
|
|
324
330
|
|
|
325
331
|
check: check && {
|
|
326
332
|
bin: `${bin} check`,
|
|
327
333
|
schedule: check.schedule,
|
|
334
|
+
killTimeout: check.killTimeout,
|
|
328
335
|
cpu: check.cpu || 100,
|
|
329
336
|
mem: check.mem || 100,
|
|
330
337
|
},
|
|
@@ -430,11 +437,13 @@ function producer({ name, selector, produce, check, state, env = {}, region = "u
|
|
|
430
437
|
region,
|
|
431
438
|
env: envWithDefaultValues,
|
|
432
439
|
schedule: "@minutely",
|
|
440
|
+
killTimeout: produce.killTimeout,
|
|
433
441
|
cpu: produce.cpu,
|
|
434
442
|
mem: produce.mem,
|
|
435
443
|
check: check && {
|
|
436
444
|
bin: `${bin} check`,
|
|
437
445
|
schedule: check.schedule,
|
|
446
|
+
killTimeout: check.killTimeout,
|
|
438
447
|
cpu: check.cpu || 100,
|
|
439
448
|
mem: check.mem || 100,
|
|
440
449
|
},
|
|
@@ -528,11 +537,13 @@ function consumer({ name, selector, consume, check, env = {}, region = "us-east-
|
|
|
528
537
|
region,
|
|
529
538
|
env: envWithDefaultValues,
|
|
530
539
|
schedule: "@minutely",
|
|
540
|
+
killTimeout: consume.killTimeout,
|
|
531
541
|
cpu: consume.cpu,
|
|
532
542
|
mem: consume.mem,
|
|
533
543
|
check: check && {
|
|
534
544
|
bin: `${bin} check`,
|
|
535
545
|
schedule: check.schedule,
|
|
546
|
+
killTimeout: check.killTimeout,
|
|
536
547
|
cpu: check.cpu || 100,
|
|
537
548
|
mem: check.mem || 100,
|
|
538
549
|
},
|
|
@@ -682,6 +693,7 @@ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1"
|
|
|
682
693
|
interval: "30m",
|
|
683
694
|
},
|
|
684
695
|
count: serve.instances,
|
|
696
|
+
killTimeout: serve.killTimeout,
|
|
685
697
|
cpu: serve.cpu,
|
|
686
698
|
mem: serve.mem,
|
|
687
699
|
service: {
|
|
@@ -691,6 +703,7 @@ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1"
|
|
|
691
703
|
check: check && {
|
|
692
704
|
bin: `${bin} check`,
|
|
693
705
|
schedule: check.schedule,
|
|
706
|
+
killTimeout: check.killTimeout,
|
|
694
707
|
cpu: check.cpu || 100,
|
|
695
708
|
mem: check.mem || 100,
|
|
696
709
|
},
|
package/const.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
const {
|
|
2
|
-
getGetBlockApiKey,
|
|
3
|
-
getAlchemyApiKey,
|
|
4
|
-
getNodeRealApiKey,
|
|
5
|
-
ensureAndGet,
|
|
6
|
-
} = require("./env");
|
|
1
|
+
const { getGetBlockApiKey, getAlchemyApiKey, getNodeRealApiKey, ensureAndGet } = require("./env");
|
|
7
2
|
|
|
8
3
|
const SKYNET_API_PREFIX = "https://api.certik-skynet.com";
|
|
9
4
|
|
|
@@ -25,6 +20,7 @@ const PROTOCOLS = {
|
|
|
25
20
|
},
|
|
26
21
|
multiCallProvider: "0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80",
|
|
27
22
|
scanUrl: "https://etherscan.io/",
|
|
23
|
+
chainId: 1,
|
|
28
24
|
},
|
|
29
25
|
bsc: {
|
|
30
26
|
nativeTokenName: "Binance Coin",
|
|
@@ -43,6 +39,7 @@ const PROTOCOLS = {
|
|
|
43
39
|
},
|
|
44
40
|
multiCallProvider: "0xe7144e57d832c9005D252f415d205b4b8D78228e",
|
|
45
41
|
scanUrl: "https://bscscan.com/",
|
|
42
|
+
chainId: 56,
|
|
46
43
|
},
|
|
47
44
|
polygon: {
|
|
48
45
|
nativeTokenName: "Polygon",
|
|
@@ -62,6 +59,7 @@ const PROTOCOLS = {
|
|
|
62
59
|
},
|
|
63
60
|
multiCallProvider: "0x8eC86392e0aDB57d00fDffbA39b8870e107c0757",
|
|
64
61
|
scanUrl: "https://polygonscan.com/",
|
|
62
|
+
chainId: 137,
|
|
65
63
|
},
|
|
66
64
|
heco: {
|
|
67
65
|
nativeTokenName: "Heco",
|
|
@@ -71,7 +69,8 @@ const PROTOCOLS = {
|
|
|
71
69
|
endpoint: `https://http-mainnet.hecochain.com`, // use heco public RPC node
|
|
72
70
|
tokenStandard: "HRC20",
|
|
73
71
|
multiCallProvider: "0xe7144e57d832c9005d252f415d205b4b8d78228e",
|
|
74
|
-
scanUrl: "https://hecoinfo.com/"
|
|
72
|
+
scanUrl: "https://hecoinfo.com/",
|
|
73
|
+
chainId: 128,
|
|
75
74
|
},
|
|
76
75
|
avax: {
|
|
77
76
|
nativeTokenName: "Avalanche",
|
|
@@ -87,7 +86,8 @@ const PROTOCOLS = {
|
|
|
87
86
|
endpoint: "https://api.snowtrace.io/api",
|
|
88
87
|
key: ensureAndGet("SKYNET_AVASCAN_API_KEY"),
|
|
89
88
|
},
|
|
90
|
-
scanUrl: "https://snowtrace.io/"
|
|
89
|
+
scanUrl: "https://snowtrace.io/",
|
|
90
|
+
chainId: 43114,
|
|
91
91
|
},
|
|
92
92
|
ftm: {
|
|
93
93
|
nativeTokenName: "Fantom",
|
|
@@ -103,7 +103,8 @@ const PROTOCOLS = {
|
|
|
103
103
|
endpoint: "https://api.ftmscan.com/api",
|
|
104
104
|
key: ensureAndGet("SKYNET_FTMSCAN_API_KEY"),
|
|
105
105
|
},
|
|
106
|
-
scanUrl: "https://ftmscan.com/"
|
|
106
|
+
scanUrl: "https://ftmscan.com/",
|
|
107
|
+
chainId: 250,
|
|
107
108
|
},
|
|
108
109
|
algo: {
|
|
109
110
|
nativeTokenName: "Algorand",
|
|
@@ -115,7 +116,7 @@ const PROTOCOLS = {
|
|
|
115
116
|
nativeTokenCmcId: 4030,
|
|
116
117
|
endpoint: "https://algo-node.certik-skynet.com/",
|
|
117
118
|
tokenStandard: "ASA",
|
|
118
|
-
}
|
|
119
|
+
},
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
const TIME = {
|
package/deploy.js
CHANGED
|
@@ -48,6 +48,7 @@ const genConfig = ({
|
|
|
48
48
|
cron,
|
|
49
49
|
count,
|
|
50
50
|
restart,
|
|
51
|
+
killTimeout,
|
|
51
52
|
cpu,
|
|
52
53
|
mem,
|
|
53
54
|
service,
|
|
@@ -185,6 +186,8 @@ EOH
|
|
|
185
186
|
SKYNET_ENVIRONMENT="${isProduction ? "prd" : "dev"}"
|
|
186
187
|
}
|
|
187
188
|
|
|
189
|
+
kill_timeout = "${killTimeout || "60s"}"
|
|
190
|
+
|
|
188
191
|
# Specify the maximum resources required to run the task,
|
|
189
192
|
# include CPU and memory.
|
|
190
193
|
resources {
|
|
@@ -319,10 +322,13 @@ function createModeDeploy({
|
|
|
319
322
|
check,
|
|
320
323
|
deltaSchedule,
|
|
321
324
|
validateSchedule,
|
|
325
|
+
deltaKillTimeout,
|
|
322
326
|
deltaCpu,
|
|
323
327
|
deltaMem,
|
|
328
|
+
rebuildKillTimeout,
|
|
324
329
|
rebuildCpu,
|
|
325
330
|
rebuildMem,
|
|
331
|
+
validateKillTimeout,
|
|
326
332
|
validateCpu,
|
|
327
333
|
validateMem,
|
|
328
334
|
}) {
|
|
@@ -368,10 +374,14 @@ function createModeDeploy({
|
|
|
368
374
|
}
|
|
369
375
|
|
|
370
376
|
const modeResouces = {
|
|
371
|
-
rebuild: { cpu: rebuildCpu, mem: rebuildMem },
|
|
372
|
-
"resume-rebuild": { cpu: rebuildCpu, mem: rebuildMem },
|
|
373
|
-
validate: {
|
|
374
|
-
|
|
377
|
+
rebuild: { cpu: rebuildCpu, mem: rebuildMem, killTimeout: rebuildKillTimeout },
|
|
378
|
+
"resume-rebuild": { cpu: rebuildCpu, mem: rebuildMem, killTimeout: rebuildKillTimeout },
|
|
379
|
+
validate: {
|
|
380
|
+
cpu: validateCpu || rebuildCpu,
|
|
381
|
+
mem: validateMem || rebuildMem,
|
|
382
|
+
killTimeout: validateKillTimeout || rebuildKillTimeout,
|
|
383
|
+
},
|
|
384
|
+
delta: { cpu: deltaCpu, mem: deltaMem, killTimeout: deltaKillTimeout },
|
|
375
385
|
};
|
|
376
386
|
|
|
377
387
|
// added an always changing env var
|
|
@@ -382,7 +392,7 @@ function createModeDeploy({
|
|
|
382
392
|
};
|
|
383
393
|
|
|
384
394
|
// by default use delta cpu/mem settings
|
|
385
|
-
const { cpu, mem } = modeResouces[mode] || modeResouces.delta;
|
|
395
|
+
const { cpu, mem, killTimeout } = modeResouces[mode] || modeResouces.delta;
|
|
386
396
|
|
|
387
397
|
let deltaCron = typeof deltaSchedule === "function" ? deltaSchedule(jobName) : deltaSchedule;
|
|
388
398
|
|
|
@@ -408,6 +418,7 @@ function createModeDeploy({
|
|
|
408
418
|
additionalEnv: env,
|
|
409
419
|
region,
|
|
410
420
|
cmd: `${bin} ${args} ${rangeArgs}`,
|
|
421
|
+
killTimeout,
|
|
411
422
|
cpu,
|
|
412
423
|
mem,
|
|
413
424
|
isProduction: production,
|
|
@@ -436,6 +447,7 @@ function createModeDeploy({
|
|
|
436
447
|
},
|
|
437
448
|
region,
|
|
438
449
|
cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
|
|
450
|
+
killTimeout: check.killTimeout || "10s",
|
|
439
451
|
cpu: check.cpu || 100,
|
|
440
452
|
mem: check.mem || 100,
|
|
441
453
|
isProduction: production,
|
|
@@ -537,6 +549,7 @@ function createDeploy({
|
|
|
537
549
|
check,
|
|
538
550
|
schedule,
|
|
539
551
|
restart,
|
|
552
|
+
killTimeout,
|
|
540
553
|
cpu,
|
|
541
554
|
mem,
|
|
542
555
|
service,
|
|
@@ -578,6 +591,7 @@ function createDeploy({
|
|
|
578
591
|
region,
|
|
579
592
|
type,
|
|
580
593
|
cmd: `${bin} ${args}`,
|
|
594
|
+
killTimeout,
|
|
581
595
|
cpu,
|
|
582
596
|
mem,
|
|
583
597
|
service,
|
|
@@ -607,6 +621,7 @@ function createDeploy({
|
|
|
607
621
|
},
|
|
608
622
|
region,
|
|
609
623
|
cmd: `${check.bin} ${args} ${production ? "--production" : ""}`,
|
|
624
|
+
killTimeout: check.killTimeout || "10s",
|
|
610
625
|
cpu: check.cpu || 100,
|
|
611
626
|
mem: check.mem || 100,
|
|
612
627
|
isProduction: production,
|
package/examples/indexer
CHANGED
package/indexer.js
CHANGED
|
@@ -126,53 +126,71 @@ function createModeIndexerApp({
|
|
|
126
126
|
process.exit(0);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
from = await finalState.getMinId(selectorFlags);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
inline.log(
|
|
134
|
-
`[MODE INDEXER] mode=${mode}, from=${from}, to=${
|
|
135
|
-
to ? to : "undefined"
|
|
136
|
-
}, env=${getEnvironment()}, ${toSelectorString(selectorFlags, ", ")}`
|
|
137
|
-
);
|
|
129
|
+
inline.log(`[MODE INDEXER] mode=${mode}, env=${getEnvironment()}, ${toSelectorString(selectorFlags, ", ")}`);
|
|
138
130
|
|
|
139
131
|
if (mode === "reset") {
|
|
140
132
|
await runReset(selectorFlags);
|
|
141
133
|
} else if (mode === "rebuild") {
|
|
134
|
+
const rebuildFrom = from || (await finalState.getMinId(selectorFlags));
|
|
135
|
+
const rebuildTo = to || (await finalState.getMaxId(selectorFlags));
|
|
136
|
+
|
|
142
137
|
await runReset(selectorFlags);
|
|
143
|
-
await runRebuild(selectorFlags,
|
|
138
|
+
await runRebuild(selectorFlags, rebuildFrom, rebuildTo, verbose);
|
|
144
139
|
} else if (mode === "resume-rebuild") {
|
|
145
140
|
const previousRebuildEnds = await getIndexerLatestId(name, selectorFlags);
|
|
146
141
|
|
|
147
|
-
|
|
148
|
-
selectorFlags
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
142
|
+
const rebuildFrom =
|
|
143
|
+
from || increaseId(finalState.type, previousRebuildEnds, 1) || (await finalState.getMinId(selectorFlags));
|
|
144
|
+
const rebuildTo = to || (await finalState.getMaxId(selectorFlags));
|
|
145
|
+
|
|
146
|
+
await runRebuild(selectorFlags, rebuildFrom, rebuildTo, verbose);
|
|
153
147
|
} else if (mode === "validate" || mode === "validation") {
|
|
154
148
|
const previousRebuildEnds = await getIndexerLatestId(name, selectorFlags);
|
|
155
149
|
|
|
150
|
+
if (!previousRebuildEnds) {
|
|
151
|
+
inline.log(`[MODE INDEXER] cannot validate without a successful rebuild`);
|
|
152
|
+
process.exit(0);
|
|
153
|
+
}
|
|
154
|
+
|
|
156
155
|
const previousValidatedTo = await getIndexerValidatedId(name, selectorFlags);
|
|
157
156
|
|
|
158
|
-
const
|
|
157
|
+
const validateFrom = from || previousValidatedTo || (await finalState.getMinId(selectorFlags));
|
|
158
|
+
const validateTo = to || previousRebuildEnds;
|
|
159
|
+
const shouldSaveState = !to; // should not save state for manual validations, those are for testing
|
|
159
160
|
|
|
160
|
-
await runValidate(
|
|
161
|
-
selectorFlags,
|
|
162
|
-
from ? from : previousValidatedTo,
|
|
163
|
-
to ? to : previousRebuildEnds,
|
|
164
|
-
shouldSaveState,
|
|
165
|
-
verbose
|
|
166
|
-
);
|
|
161
|
+
await runValidate(selectorFlags, validateFrom, validateTo, shouldSaveState, verbose);
|
|
167
162
|
} else if (mode === "one") {
|
|
168
163
|
if (to) {
|
|
169
164
|
inline.log("[MODE INDEXER] one mode ignores --to option. you may want to use range mode instead");
|
|
170
165
|
}
|
|
166
|
+
if (!from) {
|
|
167
|
+
inline.log(`[MODE INDEXER] must provide --from option for one mode`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
171
|
await runRange(selectorFlags, from, from, verbose);
|
|
172
172
|
} else if (mode === "range") {
|
|
173
|
+
if (!from || !to) {
|
|
174
|
+
inline.log(`[MODE INDEXER] must provide --from and --to option for range mode`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
|
|
173
178
|
await runRange(selectorFlags, from, to, verbose);
|
|
174
179
|
} else {
|
|
175
|
-
await
|
|
180
|
+
const stateItem = await getRecordByKey(STATE_TABLE_NAME, {
|
|
181
|
+
name: `${name}RebuildState(${toSelectorString(selectorFlags)})`,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// only build when rebuild succeed
|
|
185
|
+
if (!stateItem || stateItem.value !== "succeed") {
|
|
186
|
+
inline.log("[MODE INDEXER] skip because rebuild hasn't done yet");
|
|
187
|
+
process.exit(0);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const deltaFrom = increaseId(finalState.type, await getIndexerLatestId(name, selectorFlags), 1);
|
|
191
|
+
const deltaTo = await state.getMaxId(selectorFlags);
|
|
192
|
+
|
|
193
|
+
await runDelta(selectorFlags, deltaFrom, deltaTo, verbose);
|
|
176
194
|
}
|
|
177
195
|
}
|
|
178
196
|
|
|
@@ -385,74 +403,62 @@ function createModeIndexerApp({
|
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
|
|
388
|
-
async function runDelta(selectorFlags, verbose) {
|
|
389
|
-
const
|
|
390
|
-
name: `${name}RebuildState(${toSelectorString(selectorFlags)})`,
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
// only build when rebuild succeed
|
|
394
|
-
if (stateItem && stateItem.value === "succeed") {
|
|
395
|
-
const from = increaseId(finalState.type, await getIndexerLatestId(name, selectorFlags), 1);
|
|
396
|
-
|
|
397
|
-
const startTime = Date.now();
|
|
398
|
-
const to = await state.getMaxId(selectorFlags);
|
|
399
|
-
|
|
400
|
-
if (to <= from) {
|
|
401
|
-
inline.log(
|
|
402
|
-
`[MODE INDEXER] skip delta because there're no items need to be processed, ${toSelectorString(
|
|
403
|
-
selectorFlags,
|
|
404
|
-
", "
|
|
405
|
-
)}`
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
406
|
+
async function runDelta(selectorFlags, from, to, verbose) {
|
|
407
|
+
const startTime = Date.now();
|
|
410
408
|
|
|
409
|
+
if (to < from) {
|
|
411
410
|
inline.log(
|
|
412
|
-
`[MODE INDEXER]
|
|
411
|
+
`[MODE INDEXER] skip delta, there're no more items need to be processed, from=${from}, to=${to}, ${toSelectorString(
|
|
413
412
|
selectorFlags,
|
|
414
413
|
", "
|
|
415
|
-
)}
|
|
414
|
+
)}`
|
|
416
415
|
);
|
|
417
416
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
if (failedIds.length > 0) {
|
|
422
|
-
inline.log("[MODE INDEXER] built with some failed txs", failedIds);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
423
419
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
420
|
+
inline.log(
|
|
421
|
+
`[MODE INDEXER] starting delta, from=${from}, to=${to}, ${toSelectorString(
|
|
422
|
+
selectorFlags,
|
|
423
|
+
", "
|
|
424
|
+
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}`
|
|
425
|
+
);
|
|
428
426
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
value: Math.min(to, failedIds[0]),
|
|
432
|
-
});
|
|
427
|
+
try {
|
|
428
|
+
const failedIds = await execBuild(selectorFlags, from, to, verbose, true);
|
|
433
429
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
await createRecord(STATE_TABLE_NAME, {
|
|
437
|
-
name: `${name}DeltaState(${toSelectorString(selectorFlags)})`,
|
|
438
|
-
value: "succeed",
|
|
439
|
-
});
|
|
430
|
+
if (failedIds.length > 0) {
|
|
431
|
+
inline.log("[MODE INDEXER] built with some failed txs", failedIds);
|
|
440
432
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
433
|
+
await createRecord(STATE_TABLE_NAME, {
|
|
434
|
+
name: `${name}DeltaState(${toSelectorString(selectorFlags)})`,
|
|
435
|
+
value: "failed",
|
|
436
|
+
});
|
|
445
437
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
inline.error("[MODE INDEXER] delta build failed", from, to, err);
|
|
438
|
+
await createRecord(STATE_TABLE_NAME, {
|
|
439
|
+
name: `${name}Since(${toSelectorString(selectorFlags)})`,
|
|
440
|
+
value: Math.min(to, failedIds[0]),
|
|
441
|
+
});
|
|
451
442
|
|
|
452
443
|
process.exit(1);
|
|
444
|
+
} else {
|
|
445
|
+
await createRecord(STATE_TABLE_NAME, {
|
|
446
|
+
name: `${name}DeltaState(${toSelectorString(selectorFlags)})`,
|
|
447
|
+
value: "succeed",
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
await createRecord(STATE_TABLE_NAME, {
|
|
451
|
+
name: `${name}Since(${toSelectorString(selectorFlags)})`,
|
|
452
|
+
value: to,
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
inline.log(`[MODE INDEXER] built successfully in ${Date.now() - startTime}ms`);
|
|
456
|
+
process.exit(0);
|
|
453
457
|
}
|
|
454
|
-
}
|
|
455
|
-
inline.
|
|
458
|
+
} catch (err) {
|
|
459
|
+
inline.error("[MODE INDEXER] delta build failed", from, to, err);
|
|
460
|
+
|
|
461
|
+
process.exit(1);
|
|
456
462
|
}
|
|
457
463
|
}
|
|
458
464
|
|