Skip to content

Commit

Permalink
watcher: more splitting out of testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
panoel committed Feb 1, 2024
1 parent 08ba54d commit e8fb875
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion watcher/scripts/fetchMissingVAAs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BigtableDatabase } from '../src/databases/BigtableDatabase';
import { makeSignedVAAsRowKey, parseMessageId } from '../src/databases/utils';
import { AXIOS_CONFIG_JSON, GUARDIAN_RPC_HOSTS } from '../src/consts';
import { parseVaa } from '@certusone/wormhole-sdk';
import { Environment, getEnvironment } from '@wormhole-foundation/wormhole-monitor-common';

// This script checks for messages which don't have VAAs and attempts to fetch the VAAs from the guardians
// This is useful for cases where the VAA doesn't exist in bigtable (perhaps due to an outage) but is available
Expand All @@ -22,6 +23,7 @@ const missingVaas: { [id: string]: string | undefined } = {};
if (!bt.bigtable) {
throw new Error('bigtable is undefined');
}
const environment: Environment = getEnvironment();
const now = Math.floor(Date.now() / 1000);
try {
let log = ora('Fetching messages without a signed VAA...').start();
Expand All @@ -37,7 +39,7 @@ const missingVaas: { [id: string]: string | undefined } = {};
const { chain, emitter, sequence } = parseMessageId(observedMessage.id);
const id = makeSignedVAAsRowKey(chain, emitter, sequence.toString());
let vaaBytes: string | null = null;
for (const host of GUARDIAN_RPC_HOSTS) {
for (const host of GUARDIAN_RPC_HOSTS[environment]) {
log.text = `Searching for VAA ${search}/${total} (${host})...`;
try {
const result = await axios.get(
Expand Down
16 changes: 10 additions & 6 deletions watcher/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ export const AXIOS_CONFIG_JSON: AxiosRequestConfig = {
headers: { 'Accept-Encoding': 'application/json' },
};

export const GUARDIAN_RPC_HOSTS = [
'https://api.wormholescan.io',
'https://wormhole-v2-mainnet-api.mcf.rocks',
'https://wormhole-v2-mainnet-api.chainlayer.network',
'https://wormhole-v2-mainnet-api.staking.fund',
];
export const GUARDIAN_RPC_HOSTS: { [key in Environment]: string[] } = {
['mainnet']: [
'https://api.wormholescan.io',
'https://wormhole-v2-mainnet-api.mcf.rocks',
'https://wormhole-v2-mainnet-api.chainlayer.network',
'https://wormhole-v2-mainnet-api.staking.fund',
],
['testnet']: ['https://api.testnet.wormholescan.io'],
['devnet']: [],
};

export type AlgorandInfo = {
appid: number;
Expand Down
4 changes: 3 additions & 1 deletion watcher/src/utils/getSignedVAA.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import axios from 'axios';
import { AXIOS_CONFIG_JSON, GUARDIAN_RPC_HOSTS } from '../consts';
import { Environment, getEnvironment } from '@wormhole-foundation/wormhole-monitor-common';

export const getSignedVAA = async (
chain: number,
emitter: string,
sequence: string
): Promise<Buffer | null> => {
for (const host of GUARDIAN_RPC_HOSTS) {
const environment: Environment = getEnvironment();
for (const host of GUARDIAN_RPC_HOSTS[environment]) {
try {
const result = await axios.get(
`${host}/v1/signed_vaa/${chain}/${emitter}/${sequence.toString()}`,
Expand Down

0 comments on commit e8fb875

Please sign in to comment.