Skip to content
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

Catch error with dictionary validation #2101

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/node-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Fixed
- Dictionary validation error causing application exit (#2101)
- Auto queue flush getting the queue into a bad state (#2103)


### Fixed
- Fix getCache could not been cleared after reindex, and could have been re-used and lead to error, such as syncPoi

## [6.0.2] - 2023-10-12
Expand Down
31 changes: 18 additions & 13 deletions packages/node-core/src/indexer/dictionary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,22 +427,27 @@ export class DictionaryService {

private dictionaryValidation(metaData?: MetaData, startBlockHeight?: number): boolean {
const validate = (): boolean => {
if (!metaData) {
return false;
}
// Some dictionaries rely on chain others rely on genesisHash
if (!this.validateChainMeta(metaData)) {
logger.error(
'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary'
);
return false;
}
try {
if (!metaData) {
return false;
}
// Some dictionaries rely on chain others rely on genesisHash
if (!this.validateChainMeta(metaData)) {
logger.error(
'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary'
);
return false;
}

if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) {
logger.warn(`Dictionary indexed block is behind current indexing block height`);
if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) {
logger.warn(`Dictionary indexed block is behind current indexing block height`);
return false;
}
return true;
} catch (e: any) {
logger.error(e, 'Unable to validate dictionary metadata');
return false;
}
return true;
};

const valid = validate();
Expand Down