diff --git a/watcher/src/watchers/AlgorandWatcher.ts b/watcher/src/watchers/AlgorandWatcher.ts index dcf26ce3..aa941392 100644 --- a/watcher/src/watchers/AlgorandWatcher.ts +++ b/watcher/src/watchers/AlgorandWatcher.ts @@ -22,7 +22,6 @@ export class AlgorandWatcher extends Watcher { if (!ALGORAND_INFO.algodServer) { throw new Error('ALGORAND_INFO.algodServer is not defined!'); } - this.algodClient = new algosdk.Algodv2( ALGORAND_INFO.algodToken, ALGORAND_INFO.algodServer, @@ -39,6 +38,7 @@ export class AlgorandWatcher extends Watcher { this.logger.info(`fetching final block for ${this.chain}`); let status = await this.algodClient.status().do(); + this.logger.info(`got final block for ${this.chain} = ${status['last-round']}`); return status['last-round']; } @@ -97,10 +97,14 @@ export class AlgorandWatcher extends Watcher { } async getMessagesForBlocks(fromBlock: number, toBlock: number): Promise { + this.logger.info('getMessagesForBlocks', fromBlock, toBlock); const txIds = await this.getApplicationLogTransactionIds(fromBlock, toBlock); + this.logger.info('txIds', txIds); const transactions = []; for (const txId of txIds) { + this.logger.info('txId', txId); const response = await this.indexerClient.searchForTransactions().txid(txId).do(); + this.logger.info('response', response); if (response?.transactions?.[0]) { transactions.push(response.transactions[0]); } @@ -116,7 +120,9 @@ export class AlgorandWatcher extends Watcher { vaasByBlock[message.blockKey].push(message.vaaKey); return vaasByBlock; }, {} as VaasByBlock); + this.logger.info('attempting to call lookupBlock...'); const toBlockInfo = await this.indexerClient.lookupBlock(toBlock).do(); + this.logger.info('toBlockInfo', toBlockInfo); const toBlockTimestamp = new Date(toBlockInfo.timestamp * 1000).toISOString(); const toBlockKey = makeBlockKey(toBlock.toString(), toBlockTimestamp); if (!vaasByBlock[toBlockKey]) { diff --git a/watcher/src/watchers/SolanaWatcher.ts b/watcher/src/watchers/SolanaWatcher.ts index 91ee35b1..eacd878f 100644 --- a/watcher/src/watchers/SolanaWatcher.ts +++ b/watcher/src/watchers/SolanaWatcher.ts @@ -42,6 +42,7 @@ export class SolanaWatcher extends Watcher { } async getMessagesForBlocks(fromSlot: number, toSlot: number): Promise { + this.logger.info('getMessagesForBlocks in'); const connection = new Connection(this.rpc, COMMITMENT); // in the rare case of maximumBatchSize skipped blocks in a row, // you might hit this error due to the recursion below @@ -53,34 +54,39 @@ export class SolanaWatcher extends Watcher { // getSignaturesForAddress walks backwards so fromSignature occurs after toSignature let toBlock: VersionedBlockResponse | null = null; try { + this.logger.info(`fetching block ${toSlot} (toSlot)`); toBlock = await connection.getBlock(toSlot, { maxSupportedTransactionVersion: 0 }); } catch (e) { if (e instanceof SolanaJSONRPCError && (e.code === -32007 || e.code === -32009)) { // failed to get confirmed block: slot was skipped or missing in long-term storage - return this.getMessagesForBlocks(fromSlot, toSlot - 1); + return await this.getMessagesForBlocks(fromSlot, toSlot - 1); } else { throw e; } } if (!toBlock || !toBlock.blockTime || toBlock.transactions.length === 0) { - return this.getMessagesForBlocks(fromSlot, toSlot - 1); + this.logger.info(`block ${toSlot} is empty, recursing...(toSlot)`); + return await this.getMessagesForBlocks(fromSlot, toSlot - 1); } const fromSignature = toBlock.transactions[toBlock.transactions.length - 1].transaction.signatures[0]; let fromBlock: VersionedBlockResponse | null = null; try { + this.logger.info(`fetching block ${fromSlot} (fromSlot)`); fromBlock = await connection.getBlock(fromSlot, { maxSupportedTransactionVersion: 0 }); } catch (e) { if (e instanceof SolanaJSONRPCError && (e.code === -32007 || e.code === -32009)) { // failed to get confirmed block: slot was skipped or missing in long-term storage - return this.getMessagesForBlocks(fromSlot + 1, toSlot); + this.logger.info(`block ${fromSlot} is empty, recursing...(fromSlot)`); + return await this.getMessagesForBlocks(fromSlot + 1, toSlot); } else { throw e; } } if (!fromBlock || !fromBlock.blockTime || fromBlock.transactions.length === 0) { - return this.getMessagesForBlocks(fromSlot + 1, toSlot); + this.logger.info(`block ${fromSlot} is empty, recursing...(fromSlot2)`); + return await this.getMessagesForBlocks(fromSlot + 1, toSlot); } const toSignature = fromBlock.transactions[0].transaction.signatures[0]; @@ -167,6 +173,7 @@ export class SolanaWatcher extends Watcher { numSignatures = signatures.length; currSignature = signatures.at(-1)?.signature; } + this.logger.info('getMessagesForBlocks out'); // add last block for storeVaasByBlock const lastBlockKey = makeBlockKey(