Skip to content

Commit

Permalink
cloud_function: don't keep signed vaa
Browse files Browse the repository at this point in the history
  • Loading branch information
panoel committed Oct 27, 2023
1 parent 1ea7f13 commit 7dab14d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions cloud_functions/src/alarmMissingVaas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,13 @@ async function getAndProcessReobsVAAs(): Promise<Map<string, ReobserveInfo>> {
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);
}
Expand Down
4 changes: 2 additions & 2 deletions cloud_functions/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export async function formatAndSendToSlack(msg: string): Promise<any> {
}

export async function isVAASigned(vaaKey: string): Promise<boolean> {
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' \
Expand All @@ -105,7 +105,7 @@ export async function isVAASigned(vaaKey: string): Promise<boolean> {
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;
Expand Down

0 comments on commit 7dab14d

Please sign in to comment.