Implement WASM instance restart to handle out of memory error (#81)

* Test case for wasm out of memory error

* Restart wasm instance after N blocks

* Handle out of memory error and re instantiate WASM

* Remove old instance from map before reinstantiating WASM
This commit is contained in:
2021-12-28 16:08:05 +05:30
committed by nabarun
parent 68bc1c00db
commit 198e49e5a0
29 changed files with 181 additions and 63 deletions
+22 -7
View File
@@ -1,5 +1,5 @@
import assert from 'assert';
import { DeepPartial } from 'typeorm';
import { FindConditions, FindManyOptions } from 'typeorm';
import {
IndexerInterface,
@@ -51,19 +51,19 @@ export class Indexer implements IndexerInterface {
return '';
}
async getOrFetchBlockEvents (block: DeepPartial<BlockProgressInterface>): Promise<Array<EventInterface>> {
assert(block);
return [];
async fetchBlockEvents (block: BlockProgressInterface): Promise<BlockProgressInterface> {
return block;
}
async removeUnknownEvents (block: BlockProgressInterface): Promise<void> {
assert(block);
}
async updateBlockProgress (blockHash: string, lastProcessedEventIndex: number): Promise<void> {
assert(blockHash);
async updateBlockProgress (block: BlockProgressInterface, lastProcessedEventIndex: number): Promise<BlockProgressInterface> {
assert(block);
assert(lastProcessedEventIndex);
return block;
}
async updateSyncStatusChainHead (blockHash: string, blockNumber: number): Promise<SyncStatusInterface> {
@@ -104,6 +104,21 @@ export class Indexer implements IndexerInterface {
getEntityTypesMap (): Map<string, { [key: string]: string; }> {
return new Map();
}
async getBlockProgressEntities (where: FindConditions<BlockProgressInterface>, options: FindManyOptions<BlockProgressInterface>): Promise<BlockProgressInterface[]> {
assert(where);
assert(options);
return [];
}
async saveEventEntity (dbEvent: EventInterface): Promise<EventInterface> {
return dbEvent;
}
async processEvent (event: EventInterface): Promise<void> {
assert(event);
}
}
class SyncStatus implements SyncStatusInterface {