diff --git a/common/src/consts.ts b/common/src/consts.ts index b76e1e71..e29c6a3d 100644 --- a/common/src/consts.ts +++ b/common/src/consts.ts @@ -64,7 +64,7 @@ export const INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN: { aptos: '0', // block is 1094390 but AptosWatcher uses sequence number instead near: '72767136', xpla: '777549', - solana: '94401321', // https://explorer.solana.com/tx/KhLy688yDxbP7xbXVXK7TGpZU5DAFHbYiaoX16zZArxvVySz8i8g7N7Ss2noQYoq9XRbg6HDzrQBjUfmNcSWwhe + solana: '94396403', // https://explorer.solana.com/tx/2L8rQY94W2d44sycRkhHA1PyXdh5z6ND541ftDDk1dgBcv6RLR9a3zUgTJispPmXjkmqdqd5EDytXcnP5PC2AmEJ sui: '1485552', // https://explorer.sui.io/txblock/671SoTvVUvBZQWKXeameDvAwzHQvnr8Nj7dR9MUwm3CV?network=https%3A%2F%2Frpc.mainnet.sui.io base: '1422314', sei: '238594', diff --git a/watcher/package.json b/watcher/package.json index 6cc03783..09bae116 100644 --- a/watcher/package.json +++ b/watcher/package.json @@ -15,11 +15,13 @@ "backfill-near": "ts-node scripts/backfillNear.ts", "backfill-signed-vaas": "ts-node scripts/backfillSignedVAAs", "backfill-vaas-by-tx-hash": "ts-node scripts/backfillVAAsByTxHash.ts", + "delete-messages-by-chain": "ts-node scripts/deleteMessagesByChain.ts", "locate-message-gaps": "ts-node scripts/locateMessageGaps.ts", "fetch-missing-vaas": "ts-node scripts/fetchMissingVAAs.ts", "update-found-vaas": "ts-node scripts/updateFoundVAAs.ts", "read-bigtable": "ts-node scripts/readBigtable.ts", - "read-firestore": "ts-node scripts/readFirestore.ts" + "read-firestore": "ts-node scripts/readFirestore.ts", + "reconstruct-vaa": "ts-node scripts/reconstructVAA.ts" }, "dependencies": { "@celo-tools/celo-ethers-wrapper": "^0.3.0", diff --git a/watcher/scripts/locateMessageGaps.ts b/watcher/scripts/locateMessageGaps.ts index 76305cd1..3db395d5 100644 --- a/watcher/scripts/locateMessageGaps.ts +++ b/watcher/scripts/locateMessageGaps.ts @@ -1,7 +1,12 @@ import * as dotenv from 'dotenv'; dotenv.config(); -import { ChainId, coalesceChainName } from '@certusone/wormhole-sdk'; -import { Environment, getEnvironment, sleep } from '@wormhole-foundation/wormhole-monitor-common'; +import { ChainId, CHAIN_ID_SOLANA, coalesceChainName } from '@certusone/wormhole-sdk'; +import { + Environment, + INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN, + getEnvironment, + sleep, +} from '@wormhole-foundation/wormhole-monitor-common'; import { TIMEOUT } from '../src/consts'; import { BigtableDatabase } from '../src/databases/BigtableDatabase'; import { parseMessageId } from '../src/databases/utils'; @@ -21,10 +26,20 @@ import { Watcher } from '../src/watchers/Watcher'; const messageTable = instance.table(bt.msgTableId); try { // Find gaps in sequence numbers with the same chain and emitter + // Filter known bad emitters // Sort by ascending sequence number - const observedMessages = (await messageTable.getRows())[0].sort((a, b) => - Number(parseMessageId(a.id).sequence - parseMessageId(b.id).sequence) - ); + const observedMessages = (await messageTable.getRows())[0] + .filter((m) => { + const { chain, emitter } = parseMessageId(m.id); + if ( + chain === CHAIN_ID_SOLANA && + emitter === '6bb14509a612f01fbbc4cffeebd4bbfb492a86df717ebe92eb6df432a3f00a25' + ) { + return false; + } + return true; + }) + .sort((a, b) => Number(parseMessageId(a.id).sequence - parseMessageId(b.id).sequence)); const total = observedMessages.length; console.log(`processing ${total} messages`); const gaps = []; @@ -36,9 +51,13 @@ import { Watcher } from '../src/watchers/Watcher'; emitter: emitterAddress, sequence, } = parseMessageId(observedMessage.id); + const chainName = coalesceChainName(emitterChain as ChainId); const emitter = `${emitterChain}/${emitterAddress}`; if (!latestEmission[emitter]) { - latestEmission[emitter] = { sequence: 0n, block: 0 }; + latestEmission[emitter] = { + sequence: chainName === 'algorand' || chainName === 'near' ? 0n : -1n, + block: Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN[network][chainName] || 0), + }; } while (sequence > latestEmission[emitter].sequence + 1n) { latestEmission[emitter].sequence += 1n; @@ -71,6 +90,10 @@ import { Watcher } from '../src/watchers/Watcher'; for (const gap of gaps) { const [chain, blockRange, emitter, sequence] = gap.split('/'); const chainName = coalesceChainName(Number(chain) as ChainId); + if (chainName === 'algorand') { + console.warn('skipping algorand gaps until backfilled'); + continue; + } let watcher: Watcher; try { watcher = makeFinalizedWatcher(network, chainName); diff --git a/watcher/scripts/locateTxForMessage.ts b/watcher/scripts/locateTxForMessage.ts new file mode 100644 index 00000000..ba95d521 --- /dev/null +++ b/watcher/scripts/locateTxForMessage.ts @@ -0,0 +1,332 @@ +import * as dotenv from 'dotenv'; +import { BigtableDatabase } from '../src/databases/BigtableDatabase'; +dotenv.config(); + +// This script locates transactions for the specified messages. + +const FIND_MSGS = [ + '00002/0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585/00000000000000091543', + '00002/0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585/00000000000000091558', + '00002/0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585/00000000000000092407', + '00002/0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585/00000000000000092411', + '00002/0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585/00000000000000093808', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000213078', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000214487', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000216995', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000217841', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000219096', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000219782', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000219864', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220030', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220147', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220167', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220673', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220734', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000220759', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000221280', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000221281', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000221391', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000221724', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000221755', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000222349', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223159', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223340', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223455', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223456', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223457', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223458', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223459', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223460', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000223495', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000226714', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000226719', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000226907', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000226934', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000226982', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000227009', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000227112', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000228257', + '00004/000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7/00000000000000231520', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000078549', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000078645', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079048', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079277', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079296', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079639', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079641', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079660', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079813', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079814', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000079963', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080023', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080120', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080184', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080320', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080343', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080724', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080751', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080752', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080773', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000080917', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081572', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081848', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081855', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081856', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081857', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000081862', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082057', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082105', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082124', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082140', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082193', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082194', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082195', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082355', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082396', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082596', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082622', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082629', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082636', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082643', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082828', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082846', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000082919', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083005', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083019', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083027', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083031', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083059', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083065', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083067', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083069', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083090', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083094', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083241', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083255', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083280', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083322', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083389', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083433', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083464', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083586', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083624', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083645', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083721', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083751', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083755', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083783', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083824', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083856', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083858', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083887', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083902', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083909', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083978', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000083983', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000084174', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000084598', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000084660', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000084766', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000084791', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085047', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085093', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085109', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085110', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085173', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085333', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085334', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085392', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085398', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085424', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085430', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085436', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085445', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085446', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085447', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085448', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085449', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085450', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085451', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085452', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085453', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085496', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085513', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085600', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085622', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085644', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085766', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085774', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085775', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085802', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085804', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085805', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085898', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085948', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085996', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000085998', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086452', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086453', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086454', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086504', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086747', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086748', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086782', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086923', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086925', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086926', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086927', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086929', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086932', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086934', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086935', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086936', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086937', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000086938', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087071', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087072', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087073', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087075', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087076', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087077', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087078', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087079', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087080', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087081', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087082', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087083', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087084', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087086', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087087', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087088', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087089', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087090', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087092', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087093', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087094', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087095', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087169', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087178', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087179', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087209', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087210', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087211', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087212', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087213', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087214', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087215', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087216', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087217', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087218', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087219', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087235', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087236', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087237', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087240', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087244', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087273', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087274', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087289', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087290', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087291', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087293', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087346', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087381', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087610', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087623', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087645', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087792', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087795', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087969', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000087989', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088004', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088012', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088240', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088257', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088314', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088654', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088748', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088771', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088780', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088807', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088818', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088912', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088913', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088914', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088915', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088916', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088917', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088918', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088919', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088920', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088926', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000088952', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000089164', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000089851', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000089860', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000089862', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000089900', + '00005/0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde/00000000000000090545', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086055', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086059', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086061', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086063', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086064', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086065', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086066', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086067', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086068', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086069', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086070', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000086088', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000087492', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000087615', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000088202', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089032', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089045', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089118', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089165', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089191', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089227', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089256', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089279', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089286', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089493', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089505', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089604', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089606', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089630', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089681', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089810', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000089843', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000090273', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000090310', + '00006/0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052/00000000000000090683', +]; + +(async () => { + const bt = new BigtableDatabase(); + if (!bt.bigtable) { + throw new Error('bigtable is undefined'); + } + const instance = bt.bigtable.instance(bt.instanceId); + const messageTable = instance.table(bt.msgTableId); + try { + const observedMessages = ( + await messageTable.getRows({ prefixes: ['00002/', '00004/', '00005/', '00006/'] }) + )[0]; + console.log( + JSON.stringify( + observedMessages + .filter((m) => { + const [chain, _block, emitter, seq] = m.id.split('/'); + return FIND_MSGS.includes(`${chain}/${emitter}/${seq}`); + }) + .map((m) => `${m.id.split('/')[0]} ${m.data.info.txHash[0].value}`), + undefined, + 2 + ) + ); + } catch (e) { + console.error(e); + } +})(); diff --git a/watcher/scripts/reconstructVAA.ts b/watcher/scripts/reconstructVAA.ts new file mode 100644 index 00000000..63a2b6f2 --- /dev/null +++ b/watcher/scripts/reconstructVAA.ts @@ -0,0 +1,288 @@ +import { + ChainId, + coalesceChainName, + CONTRACTS, + encode, + hex, + isEVMChain, + Other, + Signature, + VAA, +} from '@certusone/wormhole-sdk'; +import axios from 'axios'; +import { AXIOS_CONFIG_JSON, RPCS_BY_CHAIN } from '../src/consts'; +import { LOG_MESSAGE_PUBLISHED_TOPIC, wormholeInterface } from '../src/watchers/EVMWatcher'; +import { Log } from '@ethersproject/abstract-provider'; +import { getEnvironment } from '@wormhole-foundation/wormhole-monitor-common'; + +const misses: { chain: ChainId; txHash: string }[] = [ + { chain: 11, txHash: '0x14180a4b1b056c71d473348203976f5b250e1c7342abd1947fa7de79195a91d4' }, + { chain: 11, txHash: '0x403c10df0d87dfca40783ee00aaed3c338b8e5a18643479d77ef2d9e667c5401' }, + { chain: 11, txHash: '0xa433e28d368f1478430ae195439698dacd645eb39e44a4c08efad383702c1ef6' }, + { chain: 11, txHash: '0x36707fcbd9136cda044ed178c70fea40c233855ac4d06b810bef3c0b23e2fbe8' }, + { chain: 11, txHash: '0x10daa711167a0333877bc29e53c240851f2aeb27917c9e980891766ba80d45b4' }, + { chain: 11, txHash: '0x922357276f1e116c5e9249035677ac2ec9b1a0fd31cc0cfa653563991f75fe8c' }, + { chain: 11, txHash: '0xbb1466fa50a5d2d6d9342a84800a99a74900c6942b4b4dbd22c7b8634396365a' }, + { chain: 11, txHash: '0xc06b5041d402531c991befde448d815ebf327b4ff76eaea1bf8e645fe9ffaca4' }, + { chain: 11, txHash: '0xa75a8fcbf135384420c0780a90f59edcbb3159bbb2b80dc100204a61b8f221bf' }, + { chain: 11, txHash: '0x48f532fdc933fc27afb73c580ade371e2d961dee8e56b496298f4bc4dddd19dc' }, + { chain: 11, txHash: '0xd16540dcddea5a467ecb5c100329e86495719f68d7b01d883379eaea2c2746ef' }, +]; + +type GuardianSetEntry = { pubkey: string; name: string }; + +// https://github.com/wormhole-foundation/wormhole-networks/blob/master/mainnetv2/guardianset/v3.prototxt +const gs3: GuardianSetEntry[] = [ + { + pubkey: '0x58CC3AE5C097b213cE3c81979e1B9f9570746AA5', + name: 'Certus One', + }, + { + pubkey: '0xfF6CB952589BDE862c25Ef4392132fb9D4A42157', + name: 'Staked', + }, + { + pubkey: '0x114De8460193bdf3A2fCf81f86a09765F4762fD1', + name: 'Figment', + }, + { + pubkey: '0x107A0086b32d7A0977926A205131d8731D39cbEB', + name: 'ChainodeTech', + }, + { + pubkey: '0x8C82B2fd82FaeD2711d59AF0F2499D16e726f6b2', + name: 'Inotel', + }, + { + pubkey: '0x11b39756C042441BE6D8650b69b54EbE715E2343', + name: 'HashQuark', + }, + { + pubkey: '0x54Ce5B4D348fb74B958e8966e2ec3dBd4958a7cd', + name: 'Chainlayer', + }, + { + pubkey: '0x15e7cAF07C4e3DC8e7C469f92C8Cd88FB8005a20', + name: 'xLabs', + }, + { + pubkey: '0x74a3bf913953D695260D88BC1aA25A4eeE363ef0', + name: 'Forbole', + }, + { + pubkey: '0x000aC0076727b35FBea2dAc28fEE5cCB0fEA768e', + name: 'Staking Fund', + }, + { + pubkey: '0xAF45Ced136b9D9e24903464AE889F5C8a723FC14', + name: 'MoonletWallet', + }, + { + pubkey: '0xf93124b7c738843CBB89E864c862c38cddCccF95', + name: 'P2P.ORG Validator', + }, + { + pubkey: '0xD2CC37A4dc036a8D232b48f62cDD4731412f4890', + name: '01Node', + }, + { + pubkey: '0xDA798F6896A3331F64b48c12D1D57Fd9cbe70811', + name: 'MCF', + }, + { + pubkey: '0x71AA1BE1D36CaFE3867910F99C09e347899C19C3', + name: 'Everstake', + }, + { + pubkey: '0x8192b6E7387CCd768277c17DAb1b7a5027c0b3Cf', + name: 'Chorus One', + }, + { + pubkey: '0x178e21ad2E77AE06711549CFBB1f9c7a9d8096e8', + name: 'Syncnode', + }, + { + pubkey: '0x5E1487F35515d02A92753504a8D75471b9f49EdB', + name: 'Triton', + }, + { + pubkey: '0x6FbEBc898F403E4773E95feB15E80C9A99c8348d', + name: 'Staking Facilities', + }, +]; + +function serialiseSignature(sig: Signature): string { + const body = [encode('uint8', sig.guardianSetIndex), sig.signature]; + return body.join(''); +} + +function vaaBody(vaa: VAA) { + let payload_str: string; + payload_str = vaa.payload.hex; + const body = [ + encode('uint32', vaa.timestamp), + encode('uint32', vaa.nonce), + encode('uint16', vaa.emitterChain), + encode('bytes32', hex(vaa.emitterAddress)), + encode('uint64', vaa.sequence), + encode('uint8', vaa.consistencyLevel), + payload_str, + ]; + return body.join(''); +} + +export function serializeVAA(vaa: VAA) { + const body = [ + encode('uint8', vaa.version), + encode('uint32', vaa.guardianSetIndex), + encode('uint8', vaa.signatures.length), + ...vaa.signatures.map((sig) => serialiseSignature(sig)), + vaaBody(vaa), + ]; + return body.join(''); +} + +(async () => { + const network = getEnvironment(); + for (const miss of misses) { + const rpc = RPCS_BY_CHAIN[network][coalesceChainName(miss.chain)]; + if (!isEVMChain(miss.chain)) { + console.error('unsupported chain (non EVM)', miss.chain); + continue; + } + if (!rpc) { + console.error('unsupported chain no rpc', miss.chain); + continue; + } + let receipt: any; + try { + receipt = ( + await axios.post( + rpc, + { + method: 'eth_getTransactionReceipt', + params: [miss.txHash], + id: 1, + jsonrpc: '2.0', + }, + AXIOS_CONFIG_JSON + ) + ).data.result; + } catch (e) { + console.error('failed to get tx receipt for', miss.txHash); + continue; + } + let timestamp: number; + try { + timestamp = parseInt( + ( + await axios.post( + rpc, + { + method: 'eth_getBlockByHash', + params: [receipt.blockHash, false], + id: 1, + jsonrpc: '2.0', + }, + AXIOS_CONFIG_JSON + ) + ).data.result.timestamp, + 16 + ); + } catch (e) { + console.error('failed to get timestamp for block', receipt.blockHash); + continue; + } + // for now, just take the first WH message + let emitterAddress; + let parsed; + for (const log of receipt.logs as Array) { + if ( + log.address.toLowerCase() === + CONTRACTS.MAINNET[coalesceChainName(miss.chain)].core?.toLowerCase() && + log.topics[0] === LOG_MESSAGE_PUBLISHED_TOPIC + ) { + emitterAddress = log.topics[1]; + parsed = wormholeInterface.parseLog(log); + break; + } + } + if (!emitterAddress || !parsed) { + console.error('failed to parse logs'); + continue; + } + const emitterChain = miss.chain; + const { + args: { nonce, sequence: bigSequence, payload, consistencyLevel }, + } = parsed; + const sequence = bigSequence.toBigInt(); + let observations: any[]; + try { + observations = ( + await axios.get( + `http://api.staging.wormscan.io/api/v1/observations/${emitterChain}/${emitterAddress}/${sequence.toString()}`, + AXIOS_CONFIG_JSON + ) + ).data; + } catch (e) { + console.error('failed to get observations for', emitterChain, emitterAddress, sequence); + continue; + } + + // convert sigs to hex and find their index + const hex_signatures: Signature[] = []; + + for (const observation of observations) { + let sig_64 = Buffer.from(observation.signature, 'base64'); + const signature = sig_64.toString('hex'); + const address = observation.guardianAddr; + const idx = gs3.findIndex((g) => g.pubkey.toLowerCase() === address.toLowerCase()); + if (idx === -1) { + console.warn('skipping signature from guardian not in set'); + continue; + } + + const guardianSig: Signature = { + guardianSetIndex: idx, + signature: signature, + }; + hex_signatures.push(guardianSig); + } + const signatures = hex_signatures.sort((a, b) => + a.guardianSetIndex > b.guardianSetIndex ? 1 : -1 + ); + + if (signatures.length < 13) { + console.error('not enough signatures to create a valid vaa'); + console.error(miss.txHash); + console.error(`${emitterChain}/${emitterAddress.slice(2)}/${sequence.toString()}`); + console.error(`${signatures.length} signed`); + for (let idx = 0; idx < gs3.length; idx++) { + if (!signatures.find((s) => s.guardianSetIndex === idx)) { + console.error(`missing signature for index ${idx}: ${gs3[idx].name} ${gs3[idx].pubkey}`); + } + } + continue; + } + + let vaa: VAA = { + version: 1, + guardianSetIndex: 3, + signatures, + timestamp, + nonce, + emitterChain, + emitterAddress, + sequence, + consistencyLevel, + payload: { + type: 'Other', + hex: payload.slice(2), + }, + }; + + console.log(miss.txHash); + console.log(`${emitterChain}/${emitterAddress.slice(2)}/${sequence.toString()}`); + console.log(serializeVAA(vaa)); + } +})();