[Blockchain Watcher] (FIX) Improve vaa parser and no healthy process (#1487)

* Improve vaa parser and no healthy process

* Add undefined validation for mapper

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Pro-2.local>
This commit is contained in:
Julian 2024-06-12 14:04:08 -03:00 committed by GitHub
parent 9bf9f52adb
commit 339a2433ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 60 additions and 7 deletions

View File

@ -207,6 +207,41 @@
"__name": "MANTLE_RPCS",
"__format": "json"
}
},
"kujira": {
"network": "KUJIRA_NETWORK",
"rpcs": {
"__name": "KUJIRA_RPCS",
"__format": "json"
}
},
"injective": {
"network": "INJECTIVE_NETWORK",
"rpcs": {
"__name": "INJECTIVE_RPCS",
"__format": "json"
}
},
"evmos": {
"network": "EVMOS_NETWORK",
"rpcs": {
"__name": "EVMOS_RPCS",
"__format": "json"
}
},
"osmosis": {
"network": "OSMOSIS_NETWORK",
"rpcs": {
"__name": "OSMOSIS_RPCS",
"__format": "json"
}
},
"sei": {
"network": "SEI_NETWORK",
"rpcs": {
"__name": "SEI_RPCS",
"__format": "json"
}
}
}
}

View File

@ -175,6 +175,11 @@
],
"timeout": 10000
},
"sei": {
"network": "testnet",
"chainId": 32,
"rpcs": ["https://rpc.ankr.com/sei_testnet"]
},
"scroll": {
"name": "scroll",
"network": "testnet",

View File

@ -52,6 +52,11 @@ export abstract class RunPollingJob {
this.statRepo?.measure("job_execution_time", jobExecutionTime, { job: this.id });
this.statRepo?.count("job_items_total", { id: this.id }, items.length);
} catch (e: Error | any) {
if (e.toString().includes("No healthy providers")) {
this.statRepo?.count("job_runs_no_healthy_total", { id: this.id, status: "error" });
throw new Error(`[run] No healthy providers, job: ${this.id}`);
}
this.logger.error("[run] Error processing items", e);
this.statRepo?.count("job_runs_total", { id: this.id, status: "error" });
await setTimeout(this.interval);

View File

@ -123,6 +123,9 @@ const mappedVaaInformation = (
};
const mapVaaFromTopics: LogToVaaMapper = (log: EvmTransactionLog) => {
if (!log.topics[1] || !log.topics[2] || !log.topics[3]) {
return undefined;
}
return {
emitterChain: Number(log.topics[1]),
emitterAddress: BigInt(log.topics[2])?.toString(16)?.toUpperCase()?.padStart(64, "0"),
@ -165,14 +168,19 @@ const mapVaaFromStandardRelayerDelivery: LogToVaaMapper = (log: EvmTransactionLo
};
const mapVaaFromInput: LogToVaaMapper = (_, input: string) => {
const vaaBuffer = Buffer.from(input.substring(138), "hex");
const vaa = parseVaa(vaaBuffer);
try {
const vaaBuffer = Buffer.from(input.substring(138), "hex");
const vaa = parseVaa(vaaBuffer);
return {
emitterAddress: vaa.emitterAddress.toString("hex"),
emitterChain: vaa.emitterChain,
sequence: Number(vaa.sequence),
};
return {
emitterAddress: vaa.emitterAddress.toString("hex"),
emitterChain: vaa.emitterChain,
sequence: Number(vaa.sequence),
};
} catch (e) {
// Some time the input is not a valid parseVaa so we ignore it and then try to use other mapper
return undefined;
}
};
type VaaInformation = {