From 7dab14dd3471091003cd7aea98bb67aac5ce4a40 Mon Sep 17 00:00:00 2001 From: Paul Noel Date: Fri, 27 Oct 2023 09:11:11 -0500 Subject: [PATCH] cloud_function: don't keep signed vaa --- cloud_functions/src/alarmMissingVaas.ts | 9 +++++++-- cloud_functions/src/utils.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cloud_functions/src/alarmMissingVaas.ts b/cloud_functions/src/alarmMissingVaas.ts index 5c18c727..91ff0da8 100644 --- a/cloud_functions/src/alarmMissingVaas.ts +++ b/cloud_functions/src/alarmMissingVaas.ts @@ -230,8 +230,13 @@ async function getAndProcessReobsVAAs(): Promise> { const data = doc.data(); if (data) { const vaas: ReobserveInfo[] = data.VAAs; - vaas.forEach((vaa) => { - current.set(vaa.txhash, vaa); + vaas.forEach(async (vaa) => { + if (!(await isVAASigned(vaa.vaaKey))) { + console.log('keeping reobserved VAA in firestore', vaa.vaaKey); + current.set(vaa.txhash, vaa); + } else { + console.log('pruning reobserved VAA in firestore because it is signed. ', vaa.vaaKey); + } }); console.log('number of reobserved VAAs', vaas.length); } diff --git a/cloud_functions/src/utils.ts b/cloud_functions/src/utils.ts index 5814f745..eb506c6b 100644 --- a/cloud_functions/src/utils.ts +++ b/cloud_functions/src/utils.ts @@ -93,7 +93,7 @@ export async function formatAndSendToSlack(msg: string): Promise { } export async function isVAASigned(vaaKey: string): Promise { - const url: string = WormholescanRPC + 'v1/signed_vaa/1/' + vaaKey; + const url: string = WormholescanRPC + 'v1/signed_vaa/' + vaaKey; try { const response = await axios.get(url); // curl -X 'GET' \ @@ -105,7 +105,7 @@ export async function isVAASigned(vaaKey: string): Promise { return true; } } catch (e) { - console.error('Failed to query wormholescan with url', +url + "'", e); + console.error(`Failed to query wormholescan with url [${url}]`); return false; } return false;