Skip to content

Commit

Permalink
Catch error with dictionary validation (#2101)
Browse files Browse the repository at this point in the history
* Catch error with dictionary validation, this can happen if the dictionary returns invalid metadata

* Update changelog
  • Loading branch information
stwiname authored Oct 17, 2023
1 parent 1ad5b12 commit 6312ce1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
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

0 comments on commit 6312ce1

Please sign in to comment.