From 339a2433ae00346556c20fd308087ab831695111 Mon Sep 17 00:00:00 2001 From: Julian <52217955+julianmerlo95@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:04:08 -0300 Subject: [PATCH] [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 --- .../config/custom-environment-variables.json | 35 +++++++++++++++++++ blockchain-watcher/config/default.json | 5 +++ .../src/domain/actions/RunPollingJob.ts | 5 +++ .../evm/evmRedeemedTransactionFoundMapper.ts | 22 ++++++++---- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/blockchain-watcher/config/custom-environment-variables.json b/blockchain-watcher/config/custom-environment-variables.json index c42bde70..bf83ffb4 100644 --- a/blockchain-watcher/config/custom-environment-variables.json +++ b/blockchain-watcher/config/custom-environment-variables.json @@ -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" + } } } } diff --git a/blockchain-watcher/config/default.json b/blockchain-watcher/config/default.json index 4848c94c..42dd1235 100644 --- a/blockchain-watcher/config/default.json +++ b/blockchain-watcher/config/default.json @@ -175,6 +175,11 @@ ], "timeout": 10000 }, + "sei": { + "network": "testnet", + "chainId": 32, + "rpcs": ["https://rpc.ankr.com/sei_testnet"] + }, "scroll": { "name": "scroll", "network": "testnet", diff --git a/blockchain-watcher/src/domain/actions/RunPollingJob.ts b/blockchain-watcher/src/domain/actions/RunPollingJob.ts index 868af0ac..9818ef93 100644 --- a/blockchain-watcher/src/domain/actions/RunPollingJob.ts +++ b/blockchain-watcher/src/domain/actions/RunPollingJob.ts @@ -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); diff --git a/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts b/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts index 296fd5d2..9d76573f 100644 --- a/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts +++ b/blockchain-watcher/src/infrastructure/mappers/evm/evmRedeemedTransactionFoundMapper.ts @@ -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 = {