-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi chain rewind service #2673
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. It would be good to have a test/simulation of the multichain rewind
private async getRewindTimestamp(): Promise<number | undefined> { | ||
const rewindTimestampKey = generateRewindTimestampKey(this.subqueryProject.network.chainId); | ||
const record = await this.globalDataRepo.findByPk(rewindTimestampKey); | ||
if (hasValue(record)) { | ||
return record.toJSON().value as number; | ||
} | ||
} | ||
|
||
private async initChainRewindTimestamp() { | ||
if (this.historical !== 'timestamp') return; | ||
if ((await this.getRewindTimestamp()) !== undefined) return; | ||
const rewindTimestampKey = generateRewindTimestampKey(this.subqueryProject.network.chainId); | ||
await this.globalDataRepo.create({key: rewindTimestampKey, value: 0}); | ||
} | ||
|
||
async getLastProcessedBlock(): Promise<{height: number; timestamp?: number}> { | ||
const {lastProcessedBlockTimestamp: timestamp, lastProcessedHeight: height} = await this.metadataModel.findMany([ | ||
'lastProcessedHeight', | ||
'lastProcessedBlockTimestamp', | ||
]); | ||
|
||
return {height: height || 0, timestamp}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be moved to a GlobalPlainModel
|
||
// Creating a new pgClient is to avoid using the same database connection as the block scheduler, | ||
// which may prevent real-time listening to rollback events. | ||
const pgPool = new Pool(getPgPoolConfig(this.nodeConfig)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use the existing pool instead of creating a new one. The existing one can be exposed if necessary.
@@ -58,6 +58,7 @@ export interface IBlockchainService< | |||
// Unfinalized blocks | |||
getHeaderForHash(hash: string): Promise<Header>; | |||
getHeaderForHeight(height: number): Promise<Header>; | |||
getRequiredHeaderForHeight(height: number): Promise<Required<Header>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? getHeaderForHeight
should always return a timestamp but there is one substrate chain that doesn't have timestamps in blocks so that is why it is optional
poiService?: PoiService, | ||
forceCleanService?: ForceCleanService | ||
): Promise<void> { | ||
const lastUnit = storeService.historical === 'timestamp' ? lastProcessed.timestamp : lastProcessed.height; | ||
const isMultiChain = storeService.historical === 'timestamp'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the other comment, historical mode doesn't indicate that its multichain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
---|---|---|---|
🟡 | Statements | 66.81% (-3.3% 🔻) |
20828/31177 |
🟡 | Branches | 78.6% (+0.31% 🔼) |
2791/3551 |
🟡 | Functions | 69.62% (+7.12% 🔼) |
1139/1636 |
🟡 | Lines | 66.81% (-3.3% 🔻) |
20828/31177 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
---|---|---|---|---|---|
🟢 | ... / migrate.ts |
85.34% | 9.09% | 100% | 85.34% |
🟢 | ... / migrate-abis.controller.ts |
95% | 87.5% | 100% | 95% |
🟢 | ... / constants.ts |
100% | 100% | 100% | 100% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🟢 | ... / ethereum.ts |
82.28% | 83.33% | 100% | 82.28% |
🟢 | ... / migrate-manifest.controller.ts |
88% | 73.33% | 88.89% | 88% |
🟢 | ... / migrate-mapping.controller.ts |
100% | 100% | 100% | 100% |
🟢 | ... / migrate-controller.ts |
92.41% | 84.62% | 100% | 92.41% |
🟢 | ... / migrate.fixtures.ts |
100% | 100% | 100% | 100% |
🟢 | ... / migrate-schema.controller.ts |
97.23% | 79.22% | 100% | 97.23% |
🔴 | ... / types.ts |
0% | 0% | 0% | 0% |
🟢 | ... / createProject.fixtures.ts |
94.92% | 77.78% | 100% | 94.92% |
🟢 | ... / config.ts |
100% | 100% | 100% | 100% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🔴 | ... / moduleLoader.ts |
56% | 40% | 100% | 56% |
🟢 | ... / types.ts |
100% | 100% | 100% | 100% |
🔴 | ... / utils.ts |
0% | 0% | 0% | 0% |
🟢 | ... / networkFamily.ts |
92.59% | 88.89% | 100% | 92.59% |
🟡 | ... / IPFSHTTPClientLite.ts |
76.47% | 79.17% | 88.89% | 76.47% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🟢 | ... / utils.ts |
92% | 66.67% | 100% | 92% |
🟡 | ... / admin.controller.ts |
75.56% | 96% | 78.57% | 75.56% |
🟡 | ... / blockRange.ts |
74.6% | 100% | 80% | 74.6% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🟢 | ... / blockchain.service.ts |
100% | 100% | 100% | 100% |
🟢 | ... / SubqueryProject.ts |
86.21% | 83.33% | 71.43% | 86.21% |
🟡 | ... / factory.ts |
79.22% | 66.67% | 100% | 79.22% |
🟢 | ... / core.module.ts |
100% | 100% | 100% | 100% |
🟢 | ... / dictionary.fixtures.ts |
100% | 100% | 100% | 100% |
🟡 | ... / GlobalData.entity.ts |
61.54% | 100% | 0% | 61.54% |
🟡 | ... / monitor.service.ts |
70.04% | 87.21% | 94.12% | 70.04% |
🔴 | ... / multiChainRewind.service.ts |
29.04% | 80% | 36.84% | 29.04% |
🔴 | ... / sandbox.service.ts |
33.33% | 50% | 25% | 33.33% |
🟡 | ... / baseCache.service.ts |
67.57% | 90.91% | 66.67% | 67.57% |
🟡 | ... / baseStoreModel.service.ts |
64.41% | 83.33% | 83.33% | 64.41% |
🟢 | ... / cacheable.ts |
89.29% | 75% | 100% | 89.29% |
🟡 | ... / csvStore.ts |
75% | 73.68% | 85.71% | 75% |
🟡 | ... / exporter.ts |
71.67% | 71.43% | 71.43% | 71.67% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🔴 | ... / global.ts |
19.25% | 100% | 0% | 19.25% |
🔴 | ... / index.ts |
0% | 0% | 0% | 0% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🟡 | ... / cacheMetadata.ts |
66.96% | 72.09% | 86.67% | 66.96% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🔴 | ... / metadata.ts |
54.22% | 71.43% | 55.56% | 54.22% |
🟢 | ... / utils.ts |
100% | 100% | 100% | 100% |
🟢 | ... / cacheModel.ts |
88.86% | 91.01% | 90% | 88.86% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🟢 | ... / model.ts |
81.01% | 72% | 90.91% | 81.01% |
🟢 | ... / utils.ts |
100% | 100% | 100% | 100% |
🟡 | ... / cachePoi.ts |
77.89% | 89.47% | 85.71% | 77.89% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🔴 | ... / poi.ts |
41.96% | 71.43% | 44.44% | 41.96% |
🟢 | ... / setValueModel.ts |
83.97% | 77.14% | 85.71% | 83.97% |
🟡 | ... / storeCache.service.ts |
65.7% | 76.67% | 76.92% | 65.7% |
🟡 | ... / storeModel.service.ts |
64.84% | 61.54% | 71.43% | 64.84% |
🟢 | ... / types.ts |
100% | 100% | 100% | 100% |
🟢 | ... / utils.ts |
93.33% | 66.67% | 100% | 93.33% |
🟢 | ... / worker.core.module.ts |
100% | 100% | 0% | 100% |
🔴 | ... / worker.monitor.service.ts |
39.53% | 100% | 0% | 39.53% |
🔴 | ... / meta.controller.ts |
53.33% | 100% | 0% | 53.33% |
🟡 | ... / meta.module.ts |
60% | 100% | 0% | 60% |
🟡 | ... / process.ts |
61.29% | 100% | 40% | 61.29% |
🔴 | ... / foreceClean.init.ts |
47.62% | 100% | 0% | 47.62% |
🔴 | ... / reindex.init.ts |
33.33% | 100% | 0% | 33.33% |
🟢 | ... / testing.core.module.ts |
100% | 100% | 100% | 100% |
🟡 | ... / autoQueue.ts |
65.85% | 86.49% | 73.33% | 65.85% |
🟢 | ... / index.ts |
100% | 100% | 100% | 100% |
🔴 | ... / queue.ts |
47.22% | 80% | 66.67% | 47.22% |
🟡 | ... / rampQueue.ts |
78.72% | 91.3% | 87.5% | 78.72% |
🟢 | ... / string.ts |
81.4% | 83.33% | 100% | 81.4% |
🟡 | ... / blockchain.service.ts |
67.26% | 100% | 60% | 67.26% |
🔴 | ... / datasourceProcessors.ts |
0% | 0% | 0% | 0% |
🔴 | ... / index.ts |
0% | 0% | 0% | 0% |
🔴 | ... / types.ts |
0% | 0% | 0% | 0% |
🔴 | ... / networking.ts |
31.58% | 100% | 0% | 31.58% |
Show files with reduced coverage 🔻
St.❔ |
File | Statements | Branches | Functions | Lines |
---|---|---|---|---|---|
🔴 | ... / delete.ts |
48.72% (-5.57% 🔻) |
100% | 0% | 48.72% (-5.57% 🔻) |
🔴 | ... / promote.ts |
44.19% (-4.53% 🔻) |
100% | 0% | 44.19% (-4.53% 🔻) |
🟡 | ... / add.ts |
61.29% (-0.78% 🔻) |
100% | 0% | 61.29% (-0.78% 🔻) |
🟢 | ... / publish.ts |
83.72% (-5.61% 🔻) |
57.14% | 100% | 83.72% (-5.61% 🔻) |
🔴 | ... / add-chain-controller.ts |
39.85% (-0.23% 🔻) |
66.67% | 30% | 39.85% (-0.23% 🔻) |
🟢 | ... / build-controller.ts |
86.03% (-5.27% 🔻) |
57.14% | 100% | 86.03% (-5.27% 🔻) |
🟢 | ... / codegen-controller.ts |
88.77% (-0.62% 🔻) |
83.95% (+8.37% 🔼) |
100% | 88.77% (-0.62% 🔻) |
🟡 | ... / deploy-controller.ts |
64.94% (+27.48% 🔼) |
72.73% (-5.05% 🔻) |
64.29% (+39.29% 🔼) |
64.94% (+27.48% 🔼) |
🟢 | ... / generate-controller.ts |
97.75% (+0.1% 🔼) |
93.24% (-0.79% 🔻) |
100% | 97.75% (+0.1% 🔼) |
🟡 | ... / init-controller.ts |
76.7% (+6.21% 🔼) |
67.65% (-0.35% 🔻) |
61.11% (+7.78% 🔼) |
76.7% (+6.21% 🔼) |
🟢 | ... / project-controller.ts |
83.13% (-14.13% 🔻) |
42.86% (-17.14% 🔻) |
75% (-25% 🔻) |
83.13% (-14.13% 🔻) |
🟢 | ... / publish-controller.ts |
82.63% (+2.38% 🔼) |
70.27% (-0.84% 🔻) |
100% | 82.63% (+2.38% 🔼) |
🟡 | ... / load.ts |
79.41% (-8.82% 🔻) |
66.67% (-19.05% 🔻) |
100% | 79.41% (-8.82% 🔻) |
🔴 | ... / models.ts |
55.56% (-43.89% 🔻) |
94.12% (+1.81% 🔼) |
30.77% (-69.23% 🔻) |
55.56% (-43.89% 🔻) |
🟢 | ... / ProjectManifestVersioned.ts |
82.19% (-2.74% 🔻) |
88.89% (-11.11% 🔻) |
61.54% (+3.21% 🔼) |
82.19% (-2.74% 🔻) |
🟢 | ... / model.ts |
94.29% (-3.43% 🔻) |
100% | 73.33% (+1.9% 🔼) |
94.29% (-3.43% 🔻) |
🔴 | ... / models.ts |
52.94% (-47.06% 🔻) |
100% | 0% (-100% 🔻) |
52.94% (-47.06% 🔻) |
🟡 | ... / load.ts |
66.33% (+7.14% 🔼) |
47.37% (-8.19% 🔻) |
83.33% (+16.67% 🔼) |
66.33% (+7.14% 🔼) |
🟡 | ... / github-reader.ts |
67.24% (-22.04% 🔻) |
85.71% (+10.71% 🔼) |
71.43% (-11.9% 🔻) |
67.24% (-22.04% 🔻) |
🟡 | ... / ipfs-reader.ts |
63.49% (-22.22% 🔻) |
72.73% (+9.09% 🔼) |
71.43% (-11.9% 🔻) |
63.49% (-22.22% 🔻) |
🟡 | ... / local-reader.ts |
72.09% (-13.95% 🔻) |
100% (+37.5% 🔼) |
83.33% (-16.67% 🔻) |
72.09% (-13.95% 🔻) |
🟢 | ... / reader.ts |
81.58% (-7.89% 🔻) |
57.14% (-17.86% 🔻) |
100% | 81.58% (-7.89% 🔻) |
🔴 | ... / base.ts |
47.66% (-50.34% 🔻) |
87.5% (-12.5% 🔻) |
40% (-40% 🔻) |
47.66% (-50.34% 🔻) |
🔴 | ... / models.ts |
31.74% (-68.26% 🔻) |
100% | 0% (-100% 🔻) |
31.74% (-68.26% 🔻) |
🟢 | ... / NodeConfig.ts |
88.92% (+0.31% 🔼) |
80.3% (+0.67% 🔼) |
84.91% (-1.14% 🔻) |
88.92% (+0.31% 🔼) |
🟡 | ... / ProjectUpgrade.service.ts |
78.81% (-8.26% 🔻) |
78.82% (-12.53% 🔻) |
92.31% (+1% 🔼) |
78.81% (-8.26% 🔻) |
🟢 | ... / configure.module.ts |
82.67% (-1.9% 🔻) |
71.15% (+7.15% 🔼) |
100% | 82.67% (-1.9% 🔻) |
🟢 | ... / db.module.ts |
82.55% (-5.73% 🔻) |
62.5% (-20.83% 🔻) |
72.73% (-7.27% 🔻) |
82.55% (-5.73% 🔻) |
🟢 | ... / SchemaMigration.service.ts |
84.57% (-2.99% 🔻) |
81.82% (+0.57% 🔼) |
83.33% (-16.67% 🔻) |
84.57% (-2.99% 🔻) |
🟡 | ... / migration-helpers.ts |
74.54% (-1.48% 🔻) |
86.76% (+6.17% 🔼) |
90.91% | 74.54% (-1.48% 🔻) |
🟡 | ... / migration.ts |
73.39% (-8.89% 🔻) |
83.33% (+3.6% 🔼) |
85% (-5.48% 🔻) |
73.39% (-8.89% 🔻) |
🟡 | ... / sequelizeUtil.ts |
79.46% (-11.61% 🔻) |
66.67% (-3.7% 🔻) |
62.5% | 79.46% (-11.61% 🔻) |
🟡 | ... / StoreOperations.ts |
67.06% (-25.25% 🔻) |
60% (-25% 🔻) |
87.5% (-12.5% 🔻) |
67.06% (-25.25% 🔻) |
🔴 | ... / benchmark.service.ts |
44.76% (-10.49% 🔻) |
66.67% | 36.36% (-3.64% 🔻) |
44.76% (-10.49% 🔻) |
🔴 | ... / base-block-dispatcher.ts |
18.48% (-28.87% 🔻) |
100% | 4.55% (-5.45% 🔻) |
18.48% (-28.87% 🔻) |
🔴 | ... / block-dispatcher.ts |
31.02% (-9.97% 🔻) |
66.67% | 28.57% | 31.02% (-9.97% 🔻) |
🔴 | ... / worker-block-dispatcher.ts |
18.47% (-31.74% 🔻) |
100% | 0% (-27.27% 🔻) |
18.47% (-31.74% 🔻) |
🔴 | ... / coreDictionary.ts |
48.72% (-51.28% 🔻) |
87.5% (-6.94% 🔻) |
77.78% (-22.22% 🔻) |
48.72% (-51.28% 🔻) |
🟡 | ... / dictionary.service.ts |
68.97% (-16.18% 🔻) |
83.78% (-1.93% 🔻) |
83.33% (-7.58% 🔻) |
68.97% (-16.18% 🔻) |
🟢 | ... / utils.ts |
92.59% (-3.7% 🔻) |
69.23% (-24.89% 🔻) |
100% | 92.59% (-3.7% 🔻) |
🟡 | ... / dictionaryV1.ts |
75.51% (-17.72% 🔻) |
75% (-3.26% 🔻) |
91.67% (-8.33% 🔻) |
75.51% (-17.72% 🔻) |
🟡 | ... / dictionaryV2.ts |
70.62% (-11.06% 🔻) |
68% (+2.78% 🔼) |
88.89% (-11.11% 🔻) |
70.62% (-11.06% 🔻) |
🔴 | ... / ds-processor.service.ts |
39.73% (-22.36% 🔻) |
75% | 58.33% (-29.17% 🔻) |
39.73% (-22.36% 🔻) |
🟡 | ... / dynamic-ds.service.ts |
63.38% (-26.82% 🔻) |
63.64% (-3.03% 🔻) |
81.82% (-3.9% 🔻) |
63.38% (-26.82% 🔻) |
🟢 | ... / fetch.service.ts |
90.44% (-1.85% 🔻) |
88.16% (-0.57% 🔻) |
84.62% (-2.34% 🔻) |
90.44% (-1.85% 🔻) |
🟢 | ... / inMemoryCache.service.ts |
86.21% (-13.79% 🔻) |
100% | 75% (-25% 🔻) |
86.21% (-13.79% 🔻) |
🔴 | ... / indexer.manager.ts |
17.73% (-15.48% 🔻) |
100% | 10% (-2.5% 🔻) |
17.73% (-15.48% 🔻) |
🟢 | ... / PoiBlock.ts |
84.68% (-13.71% 🔻) |
96.55% | 75% (-25% 🔻) |
84.68% (-13.71% 🔻) |
🔴 | ... / poi.service.ts |
55.7% (+31.78% 🔼) |
57.69% (-42.31% 🔻) |
80% (+51.43% 🔼) |
55.7% (+31.78% 🔼) |
🔴 | ... / poiSync.service.ts |
55.88% (-31% 🔻) |
77.61% (+1.05% 🔼) |
88.89% (-3.42% 🔻) |
55.88% (-31% 🔻) |
🟡 | ... / project.service.ts |
74.34% (-5.66% 🔻) |
72.73% (+2.55% 🔼) |
85.71% (+1.71% 🔼) |
74.34% (-5.66% 🔻) |
🔴 | ... / sandbox.ts |
59.73% (-8.25% 🔻) |
53.33% (-3.81% 🔻) |
57.14% (-4.4% 🔻) |
59.73% (-8.25% 🔻) |
🔴 | ... / store.service.ts |
58.25% (-7.8% 🔻) |
73.44% (+5.02% 🔼) |
74.29% (+17.14% 🔼) |
58.25% (-7.8% 🔻) |
🔴 | ... / entity.ts |
53.57% (-7.97% 🔻) |
100% | 50% (+50% 🔼) |
53.57% (-7.97% 🔻) |
🔴 | ... / store.ts |
31.03% (-1.17% 🔻) |
62.5% (-37.5% 🔻) |
33.33% (+33.33% 🔼) |
31.03% (-1.17% 🔻) |
🟢 | ... / test.runner.ts |
95.06% (-4.27% 🔻) |
77.78% (+4.44% 🔼) |
75% (-25% 🔻) |
95.06% (-4.27% 🔻) |
🔴 | ... / testing.service.ts |
11.54% (-17.03% 🔻) |
100% | 0% | 11.54% (-17.03% 🔻) |
🔴 | ... / unfinalizedBlocks.service.ts |
58.28% (-25.71% 🔻) |
73.08% (-23.64% 🔻) |
91.3% (-0.36% 🔻) |
58.28% (-25.71% 🔻) |
🟡 | ... / worker.builder.ts |
61.97% (-17.22% 🔻) |
65.38% | 80% | 61.97% (-17.22% 🔻) |
🔴 | ... / worker.cache.service.ts |
48.78% (-9.76% 🔻) |
100% | 0% | 48.78% (-9.76% 🔻) |
🔴 | ... / worker.connectionPoolState.manager.ts |
38.21% (-22.76% 🔻) |
100% | 0% | 38.21% (-22.76% 🔻) |
🔴 | ... / worker.dynamic-ds.service.ts |
44.44% (-17.78% 🔻) |
100% | 0% | 44.44% (-17.78% 🔻) |
🔴 | ... / worker.service.ts |
21.24% (-23.4% 🔻) |
100% | 0% | 21.24% (-23.4% 🔻) |
🔴 | ... / worker.ts |
41.75% (-0.71% 🔻) |
100% | 0% | 41.75% (-0.71% 🔻) |
🔴 | ... / worker.unfinalizedBlocks.service.ts |
26.79% (-73.21% 🔻) |
100% | 0% (-100% 🔻) |
26.79% (-73.21% 🔻) |
🔴 | ... / logger.ts |
49.3% (-15.18% 🔻) |
33.33% | 40% (+20% 🔼) |
49.3% (-15.18% 🔻) |
🔴 | ... / event.listener.ts |
16.16% (-64.65% 🔻) |
100% | 0% (-25% 🔻) |
16.16% (-64.65% 🔻) |
🔴 | ... / health.controller.ts |
37.93% (-17.24% 🔻) |
100% | 0% (-50% 🔻) |
37.93% (-17.24% 🔻) |
🔴 | ... / health.service.ts |
21.05% (-36.48% 🔻) |
100% | 0% (-20% 🔻) |
21.05% (-36.48% 🔻) |
🔴 | ... / meta.service.ts |
35.19% (-34.34% 🔻) |
100% (+20% 🔼) |
0% (-40% 🔻) |
35.19% (-34.34% 🔻) |
🔴 | ... / ready.controller.ts |
34.78% (-21.74% 🔻) |
100% | 0% (-50% 🔻) |
34.78% (-21.74% 🔻) |
🔴 | ... / ready.service.ts |
37.5% (-54.17% 🔻) |
100% | 0% (-66.67% 🔻) |
37.5% (-54.17% 🔻) |
🔴 | ... / forceClean.service.ts |
21.05% (-5.26% 🔻) |
100% | 0% | 21.05% (-5.26% 🔻) |
🔴 | ... / reindex.service.ts |
19.73% (-13.61% 🔻) |
100% | 0% | 19.73% (-13.61% 🔻) |
🟡 | ... / blocks.ts |
71.21% (-28.79% 🔻) |
91.67% (+2.78% 🔼) |
75% (-25% 🔻) |
71.21% (-28.79% 🔻) |
🟡 | ... / project.ts |
73.29% (-0.09% 🔻) |
75% (+0.42% 🔼) |
77.78% | 73.29% (-0.09% 🔻) |
🟢 | ... / promise.ts |
88.14% (-3.63% 🔻) |
100% (+13.64% 🔼) |
71.43% (-14.29% 🔻) |
88.14% (-3.63% 🔻) |
🟡 | ... / reindex.ts |
78.74% (+44.7% 🔼) |
10% (-90% 🔻) |
100% (+100% 🔼) |
78.74% (+44.7% 🔼) |
🔴 | ... / yargs.ts |
44.18% (-1.3% 🔻) |
100% | 14.29% | 44.18% (-1.3% 🔻) |
🟢 | ... / api.service.ts |
87.2% (+3.69% 🔼) |
81.54% (+9.32% 🔼) |
80.77% (-5.9% 🔻) |
87.2% (+3.69% 🔼) |
🟡 | ... / apiPromise.connection.ts |
78.13% (+9.05% 🔼) |
54.55% (-25.45% 🔻) |
66.67% (+23.81% 🔼) |
78.13% (+9.05% 🔼) |
🔴 | ... / index.ts |
0% (-100% 🔻) |
0% (-100% 🔻) |
0% (-100% 🔻) |
0% (-100% 🔻) |
🟢 | ... / substrateDictionary.service.ts |
98.15% (+7.58% 🔼) |
66.67% (-6.06% 🔻) |
100% (+20% 🔼) |
98.15% (+7.58% 🔼) |
🔴 | ... / types.ts |
0% (-100% 🔻) |
0% (-100% 🔻) |
0% (-100% 🔻) |
0% (-100% 🔻) |
🟢 | ... / substrateDictionaryV1.ts |
85.43% (-0.05% 🔻) |
78.72% (+8.96% 🔼) |
84.62% (+1.28% 🔼) |
85.43% (-0.05% 🔻) |
🟡 | ... / substrateDictionaryV2.ts |
73.03% (-2.48% 🔻) |
75% | 33.33% | 73.03% (-2.48% 🔻) |
🔴 | ... / indexer.manager.ts |
47.96% (-9.58% 🔻) |
100% | 16.67% (+7.58% 🔼) |
47.96% (-9.58% 🔻) |
🟢 | ... / runtimeService.ts |
95.29% (+3.09% 🔼) |
83.33% (-5.56% 🔻) |
100% (+20% 🔼) |
95.29% (+3.09% 🔼) |
🟡 | ... / types.ts |
70.45% (-14.84% 🔻) |
100% | 0% | 70.45% (-14.84% 🔻) |
🔴 | ... / http.ts |
50.97% (-28.96% 🔻) |
50% (+10% 🔼) |
42.86% (+12.09% 🔼) |
50.97% (-28.96% 🔻) |
🟢 | ... / project.ts |
88.73% (-0.16% 🔻) |
68.18% | 87.5% | 88.73% (-0.16% 🔻) |
🟢 | ... / buffer.ts |
95.12% (-4.88% 🔻) |
95.83% (-4.17% 🔻) |
90.48% (+6.27% 🔼) |
95.12% (-4.88% 🔻) |
🟡 | ... / logger.ts |
69.19% (-0.41% 🔻) |
48.15% (-6.85% 🔻) |
78.57% (+3.57% 🔼) |
69.19% (-0.41% 🔻) |
🟢 | ... / u8aUtils.ts |
88.89% (-11.11% 🔻) |
50% (-50% 🔻) |
100% | 88.89% (-11.11% 🔻) |
Test suite run failed
Failed tests: 3/613. Failed suites: 3/107.
● sync helper test › Multi-chain notification › can handle multiple rows in one transaction
expect(jest.fn()).toHaveBeenCalledTimes(expected)
Expected number of calls: 3
Received number of calls: 0
259 | await sequelize.query(`DELETE FROM "${schema}"."_global" WHERE "key" = '${RewindLockKey}'`);
260 | await delay(1);
> 261 | expect(listener).toHaveBeenCalledTimes(3);
| ^
262 | expect(listener).toHaveBeenNthCalledWith(1, MultiChainRewindEvent.Rewind);
263 | expect(listener).toHaveBeenNthCalledWith(2, MultiChainRewindEvent.RewindTimestampDecreased);
264 | expect(listener).toHaveBeenNthCalledWith(3, MultiChainRewindEvent.RewindComplete);
at Object.<anonymous> (packages/node-core/src/db/sync-helper.test.ts:261:24)
● ProjectService › reload chainTypes when project changed, on init
Nest can't resolve dependencies of the MultiChainRewindService (NodeConfig, EventEmitter, ?, StoreService, IBlockchainService). Please make sure that the argument Sequelize at index [2] is available in the RootTestModule context.
Potential solutions:
- Is RootTestModule a valid NestJS module?
- If Sequelize is a provider, is it part of the current RootTestModule?
- If Sequelize is exported from a separate @Module, is that module imported within RootTestModule?
@Module({
imports: [ /* the Module containing Sequelize */ ]
})
129 | const p = upgradableSubqueryProject(projectUpgrade);
130 |
> 131 | const module = await Test.createTestingModule({
| ^
132 | providers: [
133 | ConnectionPoolStateManager,
134 | ConnectionPoolService,
at TestingInjector.lookupComponentInParentModules (node_modules/@nestjs/core/injector/injector.js:262:19)
at TestingInjector.resolveComponentInstance (node_modules/@nestjs/core/injector/injector.js:215:33)
at TestingInjector.resolveComponentInstance (node_modules/@nestjs/testing/testing-injector.js:19:45)
at resolveParam (node_modules/@nestjs/core/injector/injector.js:129:38)
at async Promise.all (index 2)
at TestingInjector.resolveConstructorParams (node_modules/@nestjs/core/injector/injector.js:144:27)
at TestingInjector.loadInstance (node_modules/@nestjs/core/injector/injector.js:70:13)
at TestingInjector.loadProvider (node_modules/@nestjs/core/injector/injector.js:98:9)
at node_modules/@nestjs/core/injector/instance-loader.js:56:13
at async Promise.all (index 13)
at TestingInstanceLoader.createInstancesOfProviders (node_modules/@nestjs/core/injector/instance-loader.js:55:9)
at node_modules/@nestjs/core/injector/instance-loader.js:40:13
at async Promise.all (index 1)
at TestingInstanceLoader.createInstances (node_modules/@nestjs/core/injector/instance-loader.js:39:9)
at TestingInstanceLoader.createInstancesOfDependencies (node_modules/@nestjs/core/injector/instance-loader.js:22:13)
at TestingInstanceLoader.createInstancesOfDependencies (node_modules/@nestjs/testing/testing-instance-loader.js:9:9)
at TestingModuleBuilder.createInstancesOfDependencies (node_modules/@nestjs/testing/testing-module.builder.js:118:9)
at TestingModuleBuilder.compile (node_modules/@nestjs/testing/testing-module.builder.js:74:9)
at Object.<anonymous> (packages/node/src/indexer/project.service.spec.ts:131:20)
● SchemaMigration integration tests › Should initialize correct schema based on startHeight
Request aborted
at makeAbortedError (node_modules/fetch-h2/dist/lib/fetch-common.js:188:12)
at node_modules/fetch-h2/dist/lib/fetch-http2.js:63:60
at ClientHttp2Stream.<anonymous> (node_modules/callguard/dist/index.js:38:29)
● SchemaMigration integration tests › Should initialize correct schema based on startHeight
Request aborted
at makeAbortedError (node_modules/fetch-h2/dist/lib/fetch-common.js:188:12)
at node_modules/fetch-h2/dist/lib/fetch-http2.js:63:60
at ClientHttp2Stream.<anonymous> (node_modules/callguard/dist/index.js:38:29)
● SchemaMigration integration tests › Should initialize correct schema based on startHeight
Request aborted
at makeAbortedError (node_modules/fetch-h2/dist/lib/fetch-common.js:188:12)
at node_modules/fetch-h2/dist/lib/fetch-http2.js:63:60
at ClientHttp2Stream.<anonymous> (node_modules/callguard/dist/index.js:38:29)
● SchemaMigration integration tests › Should initialize correct schema based on startHeight
Request aborted
at makeAbortedError (node_modules/fetch-h2/dist/lib/fetch-common.js:188:12)
at node_modules/fetch-h2/dist/lib/fetch-http2.js:63:60
at ClientHttp2Stream.<anonymous> (node_modules/callguard/dist/index.js:38:29)
● SchemaMigration integration tests › Should initialize correct schema based on startHeight
Request aborted
at makeAbortedError (node_modules/fetch-h2/dist/lib/fetch-common.js:188:12)
at node_modules/fetch-h2/dist/lib/fetch-http2.js:63:60
at ClientHttp2Stream.<anonymous> (node_modules/callguard/dist/index.js:38:29)
Report generated by 🧪jest coverage report action from c05acd8
@@ -58,6 +58,7 @@ export interface IBlockchainService< | |||
// Unfinalized blocks | |||
getHeaderForHash(hash: string): Promise<Header>; | |||
getHeaderForHeight(height: number): Promise<Header>; | |||
getRequiredHeaderForHeight(height: number): Promise<Header & {timestamp: Date}>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed. Lets make timestamp required on Header. There's only one chain that we cant get the timestamp and its not worth making compromises just for that
export type RewindLockInfo = { | ||
/** Timestamp to rewind to. */ | ||
timestamp: number; | ||
chainNum: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does chainNum
mean here? Should it be chainId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it means the number of other chains that need to wait for rollback. Maybe we need to rename it.
|
||
export const RewindTimestampKeyPrefix = 'rewindTimestamp'; | ||
export const RewindLockKey = 'rewindLock'; | ||
export type RewindTimestampKey = `${typeof RewindTimestampKeyPrefix}_${string}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the string portion of this a chainId? Can you comment what sort of values are expected please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
} | ||
|
||
export function generateRewindTimestampKey(chainId: string): RewindTimestampKey { | ||
return `${RewindTimestampKeyPrefix}_${blake2AsHex(chainId)})`.substring(0, 63) as RewindTimestampKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this hash and substring necessary? We use it in other places such as table or function names because of postgres limitations but in this case because its data I don't see why these steps are necessary.
logger.info( | ||
`Waiting for all chains to complete rewind, current chainId: ${this.multiChainRewindService.chainId}` | ||
); | ||
await delay(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move this to a const, otherwise its a magic number and we have no idea on how this value was determined.
poiService?: PoiService, | ||
forceCleanService?: ForceCleanService | ||
): Promise<void> { | ||
const lastUnit = storeService.historical === 'timestamp' ? lastProcessed.timestamp : lastProcessed.height; | ||
const isMultiChain = storeService.historical === 'timestamp'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still relevant
@@ -55,4 +55,10 @@ describe('BlockchainService', () => { | |||
const interval = await blockchainService.getChainInterval(); | |||
expect(interval).toEqual(5000); | |||
}); | |||
|
|||
it('can get the chain create time', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a test needed for Shiden to make sure that specific functionality works?
@@ -62,6 +63,8 @@ import { IIndexerWorker } from './worker/worker'; | |||
useClass: ProjectService, | |||
provide: 'IProjectService', | |||
}, | |||
MultiChainRewindService, | |||
/* END: Move to node core */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment can be removed
@@ -379,8 +398,11 @@ export class FetchService<DS extends BaseDataSource, B extends IBlockDispatcher< | |||
return this.latestFinalizedHeight; | |||
} | |||
|
|||
resetForIncorrectBestBlock(blockHeight: number): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be worth checking that other SDKs dont use this function. But it probably can be removed.
@OnEvent(MultiChainRewindEvent.RewindTimestampDecreased) | ||
handleMultiChainRewindEvent(payload: MultiChainRewindPayload) { | ||
logger.info(`Received rewind event, height: ${payload.height}`); | ||
this.resetForNewDs(payload.height); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this function needs to be renamed if it has other uses now.
Description
In a multi-chain project, after enabling historical mode, a rewind requires coordination with other processes for rollback. Below are the tasks we need to accomplish.
Fixes # (issue)
#2620
TODO
_global.rewind_lock
exist. If they do, perform a rollback.rewind_timestamp
exists. If it does, perform a rewind._global
contain therewind_timestamp
. If none exist, release_global.rewind_lock
.timestamp
, It may require using the binary search method.Type of change
Please delete options that are not relevant.
Checklist