From f5b6ef69bd1b56e67d5cd60c2c718bad121c12f4 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 13:18:56 +0200 Subject: [PATCH 1/6] fixed indexing for holesky wrong app --- src/LidoDAO.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 9ab399d..42d3705 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -22,12 +22,21 @@ export function handleSetApp(event: SetAppEvent): void { // updating only in case of a new contract address if (entity.impl != event.params.app) { const repo = AppRepo.bind(Address.fromString(repoAddr)) - const latest = repo.getLatestForContractAddress(event.params.app) - const semVer = latest.getSemanticVersion() + // fix indexing, for wrong app set for Holesky + try { + const latest = repo.getLatestForContractAddress(event.params.app) + const semVer = latest.getSemanticVersion() - entity.major = semVer[0] - entity.minor = semVer[1] - entity.patch = semVer[2] + entity.major = semVer[0] + entity.minor = semVer[1] + entity.patch = semVer[2] + } catch (e) { + if (e.includes('REPO_INEXISTENT_VERSION')) { + entity.major = 0; + entity.minor = 0; + entity.patch = 0; + } + } entity.impl = event.params.app entity.block = event.block.number From 257b5045d7f951820c9627a087f5ba1932379666 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 13:31:50 +0200 Subject: [PATCH 2/6] fixed indexing for holesky wrong app --- src/LidoDAO.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 42d3705..95cf2dd 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -30,8 +30,8 @@ export function handleSetApp(event: SetAppEvent): void { entity.major = semVer[0] entity.minor = semVer[1] entity.patch = semVer[2] - } catch (e) { - if (e.includes('REPO_INEXISTENT_VERSION')) { + } catch (e: Error) { + if (e.message.includes('REPO_INEXISTENT_VERSION')) { entity.major = 0; entity.minor = 0; entity.patch = 0; From ac4ac381c72c600d297d564ec4b740c9a32a9dc4 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 13:37:24 +0200 Subject: [PATCH 3/6] fixed indexing for holesky wrong app --- src/LidoDAO.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 95cf2dd..6378677 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -30,7 +30,7 @@ export function handleSetApp(event: SetAppEvent): void { entity.major = semVer[0] entity.minor = semVer[1] entity.patch = semVer[2] - } catch (e: Error) { + } catch (e) { if (e.message.includes('REPO_INEXISTENT_VERSION')) { entity.major = 0; entity.minor = 0; From dbe930b390b0ef7b22a6b7f9fe11d2526d99edb3 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 14:18:59 +0200 Subject: [PATCH 4/6] fix try catch wasm --- src/LidoDAO.ts | 17 ++++++++--------- src/constants.ts | 5 +++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 6378677..887e600 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -5,7 +5,7 @@ import { AppVersion } from '../generated/schema' import { KERNEL_APP_BASES_NAMESPACE, APP_REPOS, - ZERO_ADDRESS, + ZERO_ADDRESS, HOLESKY_BROKEN_APP_ADDRESSES, } from './constants' export function handleSetApp(event: SetAppEvent): void { @@ -22,21 +22,20 @@ export function handleSetApp(event: SetAppEvent): void { // updating only in case of a new contract address if (entity.impl != event.params.app) { const repo = AppRepo.bind(Address.fromString(repoAddr)) - // fix indexing, for wrong app set for Holesky - try { + // fix failing indexing, for wrong app set for Holesky + if (HOLESKY_BROKEN_APP_ADDRESSES.includes(event.params.app.toHexString())) { + entity.major = 0; + entity.minor = 0; + entity.patch = 0; + } else { const latest = repo.getLatestForContractAddress(event.params.app) const semVer = latest.getSemanticVersion() entity.major = semVer[0] entity.minor = semVer[1] entity.patch = semVer[2] - } catch (e) { - if (e.message.includes('REPO_INEXISTENT_VERSION')) { - entity.major = 0; - entity.minor = 0; - entity.patch = 0; - } } + entity.impl = event.params.app entity.block = event.block.number diff --git a/src/constants.ts b/src/constants.ts index 5747b70..9634d20 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -283,3 +283,8 @@ PROTOCOL_UPG_APP_VERS.set(ORACLE_APP_ID_HOLESKY, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_MAINNET, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_GOERLI, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_HOLESKY, []) + + +// these addresses on Holesky returns error for method getLatestForContractAddress +// this can happen with Holesky when someone add incorrect app address we have to exclude them +export const HOLESKY_BROKEN_APP_ADDRESSES = ['0x87BF3bB78ee5a326c49EF73b9715A5109cc58922'] From cfa469d20bc0e9adc883c59ab4a17915992417bd Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 14:59:52 +0200 Subject: [PATCH 5/6] added try_getLatestForContractAddress --- src/LidoDAO.ts | 17 +++++++++++------ src/constants.ts | 5 ----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index 887e600..da963c1 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -1,11 +1,12 @@ -import { Address, Bytes } from '@graphprotocol/graph-ts' +import { Address } from '@graphprotocol/graph-ts' import { SetApp as SetAppEvent } from '../generated/LidoDAO/LidoDAO' import { AppRepo } from '../generated/LidoDAO/AppRepo' import { AppVersion } from '../generated/schema' import { KERNEL_APP_BASES_NAMESPACE, APP_REPOS, - ZERO_ADDRESS, HOLESKY_BROKEN_APP_ADDRESSES, + ZERO_ADDRESS, + network, } from './constants' export function handleSetApp(event: SetAppEvent): void { @@ -22,14 +23,18 @@ export function handleSetApp(event: SetAppEvent): void { // updating only in case of a new contract address if (entity.impl != event.params.app) { const repo = AppRepo.bind(Address.fromString(repoAddr)) - // fix failing indexing, for wrong app set for Holesky - if (HOLESKY_BROKEN_APP_ADDRESSES.includes(event.params.app.toHexString())) { + + const triedLatest = repo.try_getLatestForContractAddress(event.params.app) + if (triedLatest.reverted) { + if (network !== 'holesky') { + throw new Error('indexing error - getLatestForContractAddress method is reverted') + } + entity.major = 0; entity.minor = 0; entity.patch = 0; } else { - const latest = repo.getLatestForContractAddress(event.params.app) - const semVer = latest.getSemanticVersion() + const semVer = triedLatest.value.getSemanticVersion() entity.major = semVer[0] entity.minor = semVer[1] diff --git a/src/constants.ts b/src/constants.ts index 9634d20..5747b70 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -283,8 +283,3 @@ PROTOCOL_UPG_APP_VERS.set(ORACLE_APP_ID_HOLESKY, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_MAINNET, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_GOERLI, []) PROTOCOL_UPG_APP_VERS.set(VOTING_APP_ID_HOLESKY, []) - - -// these addresses on Holesky returns error for method getLatestForContractAddress -// this can happen with Holesky when someone add incorrect app address we have to exclude them -export const HOLESKY_BROKEN_APP_ADDRESSES = ['0x87BF3bB78ee5a326c49EF73b9715A5109cc58922'] From 66f5bcc1bbf14f859c7421216471e10feeebcf21 Mon Sep 17 00:00:00 2001 From: Taras Alekhin Date: Mon, 15 Jul 2024 15:32:58 +0200 Subject: [PATCH 6/6] change to mainnet only throw error --- src/LidoDAO.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LidoDAO.ts b/src/LidoDAO.ts index da963c1..76dca0f 100644 --- a/src/LidoDAO.ts +++ b/src/LidoDAO.ts @@ -26,7 +26,7 @@ export function handleSetApp(event: SetAppEvent): void { const triedLatest = repo.try_getLatestForContractAddress(event.params.app) if (triedLatest.reverted) { - if (network !== 'holesky') { + if (network === 'mainnet') { throw new Error('indexing error - getLatestForContractAddress method is reverted') }