Skip to content

Commit c2ead9a

Browse files
committed
watcher: change miss to 30 mins
1 parent 1e79184 commit c2ead9a

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

cloud_functions/src/alarmMissingVaas.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
getEnvironment,
88
explorerBlock,
99
explorerTx,
10+
MISS_THRESHOLD_IN_MINS,
1011
} from '@wormhole-foundation/wormhole-monitor-common';
1112
import { Firestore } from 'firebase-admin/firestore';
1213

@@ -88,22 +89,22 @@ export async function alarmMissingVaas(req: any, res: any) {
8889
if (messages) {
8990
const now = new Date();
9091
const thePast = now;
91-
thePast.setHours(now.getHours() - 2);
92-
const twoHoursAgo = thePast.toISOString();
92+
thePast.setMinutes(now.getMinutes() - MISS_THRESHOLD_IN_MINS);
93+
const missThreshold = thePast.toISOString();
9394
for (const chain of Object.keys(messages)) {
9495
const chainId = chain as unknown as ChainId;
9596
const msgs = messages[chainId];
9697
if (msgs && msgs.messages) {
9798
for (let i = 0; i < msgs.messages.length; i++) {
98-
// Check the timestamp and only send messages that are older than 2 hours
99+
// Check the timestamp and only send messages that are older than MISS_THRESHOLD_IN_MINS
99100
const msg: ObservedMessage = msgs.messages[i];
100101
// If there is a reference time for this chain, use it. Otherwise, use the current time.
101-
let timeToCheck = twoHoursAgo;
102+
let timeToCheck = missThreshold;
102103
if (refTimes[chainId]) {
103104
let refTime = refTimes[chainId]?.latestTime;
104105
if (refTime) {
105106
const refDateTime = new Date(refTime);
106-
refDateTime.setHours(refDateTime.getHours() - 2);
107+
refDateTime.setMinutes(refDateTime.getMinutes() - MISS_THRESHOLD_IN_MINS);
107108
timeToCheck = refDateTime.toISOString();
108109
}
109110
}
@@ -196,7 +197,7 @@ async function getGovernedVaas(): Promise<GovernedVAAMap> {
196197
}
197198

198199
// This function gets all the VAAs in the firestore table,
199-
// checks the timestamp (keeping any that are less than 2 hours old),
200+
// checks the timestamp (keeping any that are less than MISS_THRESHOLD_IN_MINS old),
200201
// and returns a map of those VAAs.
201202
async function getAndProcessFirestore(): Promise<Map<string, FirestoreVAA>> {
202203
// Get VAAs in the firestore holding area.
@@ -207,19 +208,19 @@ async function getAndProcessFirestore(): Promise<Map<string, FirestoreVAA>> {
207208
let current = new Map<string, FirestoreVAA>();
208209
const now = new Date();
209210
const thePast = now;
210-
thePast.setHours(now.getHours() - 2);
211-
const twoHoursAgo = thePast.toISOString();
211+
thePast.setMinutes(now.getMinutes() - MISS_THRESHOLD_IN_MINS);
212+
const missThreshold = thePast.toISOString();
212213
await collection
213214
.doc('VAAs')
214215
.get()
215216
.then((doc) => {
216217
if (doc.exists) {
217218
const data = doc.data();
218219
if (data) {
219-
// if VAA < 2 hours old, leave in firestore
220+
// if VAA < MISS_THRESHOLD_IN_MINS old, leave in firestore
220221
const vaas: FirestoreVAA[] = data.VAAs;
221222
vaas.forEach((vaa) => {
222-
if (vaa.noticedTS > twoHoursAgo) {
223+
if (vaa.noticedTS > missThreshold) {
223224
// console.log('keeping VAA in firestore', vaa.vaaKey);
224225
current.set(vaa.vaaKey, vaa);
225226
}

common/src/consts.ts

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export type Network = {
4141
};
4242
export type Mode = 'vaa' | 'ntt';
4343

44+
export const MISS_THRESHOLD_IN_MINS = 30;
45+
export const MISS_THRESHOLD_LABEL = '30 minutes';
46+
4447
export const INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN: {
4548
[key in Environment]: { [key in ChainName]?: string };
4649
} = {

dashboard/src/components/Monitor.tsx

+11-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
explorerBlock,
2424
explorerTx,
2525
explorerVaa,
26+
MISS_THRESHOLD_IN_MINS,
27+
MISS_THRESHOLD_LABEL,
2628
} from '@wormhole-foundation/wormhole-monitor-common';
2729
import { Environment, useCurrentEnvironment, useNetworkContext } from '../contexts/NetworkContext';
2830
import { CloudGovernorInfo } from '../hooks/useCloudGovernorInfo';
@@ -248,16 +250,16 @@ function DetailBlocks({ chain }: { chain: string }) {
248250

249251
function ReobserveCodeContent({ misses }: { misses: MissesByChain }) {
250252
const now = new Date();
251-
now.setHours(now.getHours() - 2);
252-
const twoHoursAgo = now.toISOString();
253+
now.setMinutes(now.getMinutes() - MISS_THRESHOLD_IN_MINS);
254+
const missThreshold = now.toISOString();
253255
const { showAllMisses } = useSettings();
254256
return (
255257
<pre>
256258
{Object.entries(misses)
257259
.map(([chain, info]) => {
258260
const filteredMisses = showAllMisses
259261
? info.messages
260-
: info.messages.filter((message) => message.timestamp < twoHoursAgo);
262+
: info.messages.filter((message) => message.timestamp < missThreshold);
261263
return filteredMisses.length === 0
262264
? null
263265
: filteredMisses
@@ -323,15 +325,15 @@ function Misses({ governorInfo }: { governorInfo?: CloudGovernorInfo | null }) {
323325
};
324326
}, [currentNetwork]);
325327
const now = new Date();
326-
now.setHours(now.getHours() - 2);
327-
const twoHoursAgo = now.toISOString();
328+
now.setMinutes(now.getMinutes() - MISS_THRESHOLD_IN_MINS);
329+
const missThreshold = now.toISOString();
328330
const missesElements = misses
329331
? Object.entries(misses)
330332
.map(([chain, info]) => {
331333
const filteredMisses = showAllMisses
332334
? info.messages
333335
: info.messages
334-
.filter((message) => message.timestamp < twoHoursAgo)
336+
.filter((message) => message.timestamp < missThreshold)
335337
.filter(
336338
(message) =>
337339
!governorInfo?.enqueuedVAAs.some(
@@ -396,7 +398,9 @@ function Misses({ governorInfo }: { governorInfo?: CloudGovernorInfo | null }) {
396398
) : missesElements.length ? (
397399
missesElements
398400
) : (
399-
<Typography pl={0.5}>No misses{showAllMisses ? '' : ' > 2 Hours'}!</Typography>
401+
<Typography pl={0.5}>
402+
No misses{showAllMisses ? '' : ` > ${MISS_THRESHOLD_LABEL}`}!
403+
</Typography>
400404
)}
401405
</>
402406
);

watcher/scripts/solanaMissedMessageAccounts.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ import {
1010
isLegacyMessage,
1111
normalizeCompileInstruction,
1212
} from '@wormhole-foundation/wormhole-monitor-common/src/solana';
13+
import { MISS_THRESHOLD_IN_MINS } from '@wormhole-foundation/wormhole-monitor-common';
1314

1415
// This script finds the message accounts which correspond to solana misses
1516

1617
(async () => {
1718
const now = new Date();
18-
now.setHours(now.getHours() - 2);
19-
const twoHoursAgo = now.toISOString();
19+
now.setMinutes(now.getMinutes() - MISS_THRESHOLD_IN_MINS);
20+
const missThreshold = now.toISOString();
2021
let log = ora('Fetching Solana misses').start();
2122
try {
2223
const response = await axios.get(
2324
'https://europe-west3-wormhole-message-db-mainnet.cloudfunctions.net/missing-vaas'
2425
);
2526
const solanaTxHashes = response.data[1].messages
26-
.filter((m: any) => m.timestamp < twoHoursAgo)
27+
.filter((m: any) => m.timestamp < missThreshold)
2728
.map((m: any) => m.txHash);
2829
log.succeed();
2930
log = ora('Fetching message accounts').start();

0 commit comments

Comments
 (0)