From bf7dbdf419ab7f6c8016f6069e7a202c93826a0a Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 21 Nov 2023 10:39:46 +0000 Subject: [PATCH 1/4] debug logs --- yarn-project/aztec.js/src/contract/sent_tx.ts | 18 ++++++++++++++++++ yarn-project/end-to-end/src/e2e_2_pxes.test.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index 66a0dbfb489..d93c50f6e49 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -4,6 +4,8 @@ import { ExtendedNote, GetUnencryptedLogsResponse, PXE, TxHash, TxReceipt, TxSta import every from 'lodash.every'; +import { createDebugLogger } from '../index.js'; + /** Options related to waiting for a tx. */ export type WaitOpts = { /** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */ @@ -66,6 +68,22 @@ export class SentTx { } const receipt = await this.waitForReceipt(opts); if (receipt.status !== TxStatus.MINED) { + { + // A few logs placed here temporarily to help me (@benesjan) debug an issue with intermittent failure of + // 2 pixies test. + // https://github.com/AztecProtocol/aztec-packages/issues/3357 + // For whatever reason (according to logs) the tx which appears here as dropped seems to be correctly included + // in a block and the block built and submitted on-chain. I will try to fetch the latest block here and see + // which txs it contains to check if the block source used here has the relevant block. If it doesn't then + // the test is probably misconfigured and an incorrect block source is used (pxe pointing to a different aztec + // node or smt like that) or there is some bigger issue with block sync somewhere. + const blockNum = await this.pxe.getBlockNumber(); + const block = await this.pxe.getBlock(blockNum); + const txs = block?.getTxs(); + const txHashes = txs?.map(tx => tx.txHash.toString()); + const log = createDebugLogger('aztec:sent-tx'); + log(`Tx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`); + } throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`); } if (opts?.debug) { diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index 6af6d29dab0..9543b801fdf 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -119,7 +119,7 @@ describe('e2e_2_pxes', () => { ); }; - it('transfers fund from user A to B via PXE A followed by transfer from B to A via PXE B', async () => { + it('transfers funds from user A to B via PXE A followed by transfer from B to A via PXE B', async () => { const initialBalance = 987n; const transferAmount1 = 654n; const transferAmount2 = 323n; From 3d9055590d5c53b2d4c7bc39ab9f4e6d58b4ac46 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 21 Nov 2023 12:35:04 +0000 Subject: [PATCH 2/4] fix --- yarn-project/aztec.js/src/contract/sent_tx.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index d93c50f6e49..6d386ea8f63 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -1,4 +1,4 @@ -import { FieldsOf } from '@aztec/circuits.js'; +import { FieldsOf, MAX_NEW_NULLIFIERS_PER_TX } from '@aztec/circuits.js'; import { retryUntil } from '@aztec/foundation/retry'; import { ExtendedNote, GetUnencryptedLogsResponse, PXE, TxHash, TxReceipt, TxStatus } from '@aztec/types'; @@ -79,8 +79,11 @@ export class SentTx { // node or smt like that) or there is some bigger issue with block sync somewhere. const blockNum = await this.pxe.getBlockNumber(); const block = await this.pxe.getBlock(blockNum); - const txs = block?.getTxs(); - const txHashes = txs?.map(tx => tx.txHash.toString()); + const txHashes = []; + for (let txIndex = 0; txIndex < block!.numberOfTxs; txIndex++) { + const txHash = block!.newNullifiers[MAX_NEW_NULLIFIERS_PER_TX * txIndex]; + txHashes.push(txHash.toString()); + } const log = createDebugLogger('aztec:sent-tx'); log(`Tx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`); } From 857d904b6b182bd9feabcb31000d090d73dba643 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 21 Nov 2023 12:57:24 +0000 Subject: [PATCH 3/4] fix --- yarn-project/aztec.js/src/contract/sent_tx.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index 6d386ea8f63..fa0f7d3a33b 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -4,8 +4,6 @@ import { ExtendedNote, GetUnencryptedLogsResponse, PXE, TxHash, TxReceipt, TxSta import every from 'lodash.every'; -import { createDebugLogger } from '../index.js'; - /** Options related to waiting for a tx. */ export type WaitOpts = { /** The maximum time (in seconds) to wait for the transaction to be mined. Defaults to 60. */ @@ -68,26 +66,30 @@ export class SentTx { } const receipt = await this.waitForReceipt(opts); if (receipt.status !== TxStatus.MINED) { - { - // A few logs placed here temporarily to help me (@benesjan) debug an issue with intermittent failure of - // 2 pixies test. - // https://github.com/AztecProtocol/aztec-packages/issues/3357 - // For whatever reason (according to logs) the tx which appears here as dropped seems to be correctly included - // in a block and the block built and submitted on-chain. I will try to fetch the latest block here and see - // which txs it contains to check if the block source used here has the relevant block. If it doesn't then - // the test is probably misconfigured and an incorrect block source is used (pxe pointing to a different aztec - // node or smt like that) or there is some bigger issue with block sync somewhere. - const blockNum = await this.pxe.getBlockNumber(); - const block = await this.pxe.getBlock(blockNum); - const txHashes = []; - for (let txIndex = 0; txIndex < block!.numberOfTxs; txIndex++) { - const txHash = block!.newNullifiers[MAX_NEW_NULLIFIERS_PER_TX * txIndex]; - txHashes.push(txHash.toString()); - } - const log = createDebugLogger('aztec:sent-tx'); - log(`Tx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`); + // ############## Temporary code start ############## + // A few logs placed here temporarily to help me (@benesjan) debug an issue with intermittent failure of + // 2 pixies test. + // https://github.com/AztecProtocol/aztec-packages/issues/3357 + // For whatever reason (according to logs) the tx which appears here as dropped seems to be correctly included + // in a block and the block built and submitted on-chain. I will try to fetch the latest block here and see + // which txs it contains to check if the block source used here has the relevant block. If it doesn't then + // the test is probably misconfigured and an incorrect block source is used (pxe pointing to a different aztec + // node or smt like that) or there is some bigger issue with block sync somewhere. + const blockNum = await this.pxe.getBlockNumber(); + const block = await this.pxe.getBlock(blockNum); + const txHashes = []; + for (let txIndex = 0; txIndex < block!.numberOfTxs; txIndex++) { + const txHash = block!.newNullifiers[MAX_NEW_NULLIFIERS_PER_TX * txIndex]; + txHashes.push(txHash.toString()); } - throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`); + throw new Error( + `Transaction ${await this.getTxHash()} was ${ + receipt.status + }.\nTx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`, + ); + // ############## Temporary code end ############## + + // throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`); } if (opts?.debug) { const txHash = await this.getTxHash(); From 9e2610bbd6cab5f9bb6de68bc33ac1e50d37a997 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 21 Nov 2023 13:36:23 +0000 Subject: [PATCH 4/4] fix --- yarn-project/aztec.js/src/contract/sent_tx.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/yarn-project/aztec.js/src/contract/sent_tx.ts b/yarn-project/aztec.js/src/contract/sent_tx.ts index fa0f7d3a33b..33af8912162 100644 --- a/yarn-project/aztec.js/src/contract/sent_tx.ts +++ b/yarn-project/aztec.js/src/contract/sent_tx.ts @@ -77,16 +77,20 @@ export class SentTx { // node or smt like that) or there is some bigger issue with block sync somewhere. const blockNum = await this.pxe.getBlockNumber(); const block = await this.pxe.getBlock(blockNum); - const txHashes = []; - for (let txIndex = 0; txIndex < block!.numberOfTxs; txIndex++) { - const txHash = block!.newNullifiers[MAX_NEW_NULLIFIERS_PER_TX * txIndex]; - txHashes.push(txHash.toString()); + if (block) { + const txHashes = []; + for (let txIndex = 0; txIndex < block!.numberOfTxs; txIndex++) { + const txHash = block!.newNullifiers[MAX_NEW_NULLIFIERS_PER_TX * txIndex]; + txHashes.push(txHash.toString()); + } + throw new Error( + `Transaction ${await this.getTxHash()} was ${ + receipt.status + }.\nTx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`, + ); + } else { + throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}. Block ${blockNum} not found.`); } - throw new Error( - `Transaction ${await this.getTxHash()} was ${ - receipt.status - }.\nTx hashes of txs included in the last synced block ${block?.number} are: ${txHashes}`, - ); // ############## Temporary code end ############## // throw new Error(`Transaction ${await this.getTxHash()} was ${receipt.status}`);