From 74d6519d7a98a019db5e46d5c188c7479fb51430 Mon Sep 17 00:00:00 2001 From: Facundo Date: Thu, 16 May 2024 15:29:06 +0100 Subject: [PATCH] chore: change some error messages for avm switch (#6447) --- .../reference/common_errors/sandbox-errors.md | 2 +- .../end-to-end/src/e2e_block_building.test.ts | 4 +--- .../src/e2e_cross_chain_messaging.test.ts | 15 ++------------ .../contract_class_registration.test.ts | 6 ++++-- .../deposits.test.ts | 20 +++---------------- .../end-to-end/src/fixtures/fixtures.ts | 6 ++++-- 6 files changed, 15 insertions(+), 38 deletions(-) diff --git a/docs/docs/reference/reference/common_errors/sandbox-errors.md b/docs/docs/reference/reference/common_errors/sandbox-errors.md index 5fb33c69955..873b5de2db2 100644 --- a/docs/docs/reference/reference/common_errors/sandbox-errors.md +++ b/docs/docs/reference/reference/common_errors/sandbox-errors.md @@ -178,7 +178,7 @@ Users may create a proof against a historical state in Aztec. The rollup circuit ## Archiver Errors -- "No non-nullified L1 to L2 message found for message hash \$\{messageHash.toString()\}" - happens when the L1 to L2 message doesn't exist or is "pending", when the user has sent a message on L1 via the Inbox contract but it has yet to be included in an L2 block by the sequencer - the user has to wait for enough blocks to progress and for the archiver to sync the respective L2 block. You can get the sequencer to pick it up by doing 2 arbitrary transactions on L2 (eg. send DAI to yourself 2 times). This would give the sequencer a transaction to process and as a side effect it would consume 2 subtrees of new messages from the Inbox contract. 2 subtrees need to be consumed and not just 1 because there is a 1 block lag to prevent the subtree from changing when the sequencer is proving. +- "No non-nullified L1 to L2 message found for message hash \$\{messageHash.toString()\}"/"Tried to consume nonexistent L1-to-L2 message" - happens when the L1 to L2 message doesn't exist or is "pending", when the user has sent a message on L1 via the Inbox contract but it has yet to be included in an L2 block by the sequencer - the user has to wait for enough blocks to progress and for the archiver to sync the respective L2 block. You can get the sequencer to pick it up by doing 2 arbitrary transactions on L2 (eg. send DAI to yourself 2 times). This would give the sequencer a transaction to process and as a side effect it would consume 2 subtrees of new messages from the Inbox contract. 2 subtrees need to be consumed and not just 1 because there is a 1 block lag to prevent the subtree from changing when the sequencer is proving. - "Block number mismatch: expected \$\{l2BlockNum\} but got \$\{block.number\}" - The archiver keeps track of the next expected L2 block number. It throws this error if it got a different one when trying to sync with the rollup contract's events on L1. diff --git a/yarn-project/end-to-end/src/e2e_block_building.test.ts b/yarn-project/end-to-end/src/e2e_block_building.test.ts index f23dfb99b48..cbafb01600a 100644 --- a/yarn-project/end-to-end/src/e2e_block_building.test.ts +++ b/yarn-project/end-to-end/src/e2e_block_building.test.ts @@ -18,6 +18,7 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token'; import 'jest-extended'; import { TaggedNote } from '../../circuit-types/src/logs/l1_note_payload/tagged_note.js'; +import { DUPLICATE_NULLIFIER_ERROR } from './fixtures/fixtures.js'; import { setup } from './fixtures/utils.js'; describe('e2e_block_building', () => { @@ -114,9 +115,6 @@ describe('e2e_block_building', () => { describe('double-spends', () => { let contract: TestContract; let teardown: () => Promise; - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): clean up - // Under current public, we expect 'dropped', under the AVM, we expect 'reverted'. - const DUPLICATE_NULLIFIER_ERROR = /dropped|reverted/; beforeAll(async () => { ({ teardown, pxe, logger, wallet: owner } = await setup(1)); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index ce136e9113c..4ba3f4990f0 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -15,6 +15,7 @@ import { type TokenBridgeContract, type TokenContract } from '@aztec/noir-contra import { toFunctionSelector } from 'viem/utils'; +import { NO_L1_TO_L2_MSG_ERROR } from './fixtures/fixtures.js'; import { setup } from './fixtures/utils.js'; import { CrossChainTestHarness } from './shared/cross_chain_test_harness.js'; @@ -233,18 +234,6 @@ describe('e2e_cross_chain_messaging', () => { // Wait for the message to be available for consumption await crossChainTestHarness.makeMessageConsumable(msgHash); - const content = sha256ToField([ - Buffer.from(toFunctionSelector('mint_public(bytes32,uint256)').substring(2), 'hex'), - ownerAddress, - new Fr(bridgeAmount), - ]); - const wrongMessage = new L1ToL2Message( - new L1Actor(crossChainTestHarness.tokenPortalAddress, crossChainTestHarness.publicClient.chain.id), - new L2Actor(l2Bridge.address, 1), - content, - secretHashForL2MessageConsumption, - ); - // get message leaf index, needed for claiming in public const maybeIndexAndPath = await aztecNode.getL1ToL2MessageMembershipWitness('latest', msgHash, 0n); expect(maybeIndexAndPath).toBeDefined(); @@ -256,6 +245,6 @@ describe('e2e_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_public(ownerAddress, bridgeAmount, secretForL2MessageConsumption, messageLeafIndex) .prove(), - ).rejects.toThrow(`No non-nullified L1 to L2 message found for message hash ${wrongMessage.hash().toString()}`); + ).rejects.toThrow(NO_L1_TO_L2_MSG_ERROR); }); }); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts index aa92b4d2b56..3b55d703fd5 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts @@ -24,6 +24,7 @@ import { writeTestData } from '@aztec/foundation/testing'; import { StatefulTestContract } from '@aztec/noir-contracts.js'; import { TestContract } from '@aztec/noir-contracts.js/Test'; +import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js'; import { DeployTest, type StatefulContractCtorArgs } from './deploy_test.js'; describe('e2e_deploy_contract contract class registration', () => { @@ -189,7 +190,8 @@ describe('e2e_deploy_contract contract class registration', () => { .constructor(...initArgs) .send({ skipPublicSimulation: true }) .wait(), - ).rejects.toThrow(/dropped/i); + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): Make these a fixed error after transition. + ).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); }); @@ -225,7 +227,7 @@ describe('e2e_deploy_contract contract class registration', () => { .public_constructor(...initArgs) .send({ skipPublicSimulation: true }) .wait(), - ).rejects.toThrow(/dropped/i); + ).rejects.toThrow(DUPLICATE_NULLIFIER_ERROR); }); }); }); diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging/deposits.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging/deposits.test.ts index 72c5c4c0aad..306e9e7bb06 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging/deposits.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging/deposits.test.ts @@ -1,8 +1,6 @@ -import { Fr, L1Actor, L1ToL2Message, L2Actor, computeAuthWitMessageHash } from '@aztec/aztec.js'; -import { sha256ToField } from '@aztec/foundation/crypto'; - -import { toFunctionSelector } from 'viem'; +import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js'; +import { NO_L1_TO_L2_MSG_ERROR } from '../fixtures/fixtures.js'; import { PublicCrossChainMessagingContractTest } from './public_cross_chain_messaging_contract_test.js'; describe('e2e_public_cross_chain_messaging deposits', () => { @@ -122,18 +120,6 @@ describe('e2e_public_cross_chain_messaging deposits', () => { await crossChainTestHarness.makeMessageConsumable(msgHash); - const content = sha256ToField([ - Buffer.from(toFunctionSelector('mint_public(bytes32,uint256)').substring(2), 'hex'), - user2Wallet.getAddress(), - new Fr(bridgeAmount), - ]); - const wrongMessage = new L1ToL2Message( - new L1Actor(crossChainTestHarness.tokenPortalAddress, crossChainTestHarness.publicClient.chain.id), - new L2Actor(l2Bridge.address, 1), - content, - secretHash, - ); - // get message leaf index, needed for claiming in public const maybeIndexAndPath = await aztecNode.getL1ToL2MessageMembershipWitness('latest', msgHash, 0n); expect(maybeIndexAndPath).toBeDefined(); @@ -145,7 +131,7 @@ describe('e2e_public_cross_chain_messaging deposits', () => { .withWallet(user2Wallet) .methods.claim_public(user2Wallet.getAddress(), bridgeAmount, secret, messageLeafIndex) .prove(), - ).rejects.toThrow(`No non-nullified L1 to L2 message found for message hash ${wrongMessage.hash().toString()}`); + ).rejects.toThrow(NO_L1_TO_L2_MSG_ERROR); // user2 consumes owner's L1-> L2 message on bridge contract and mints public tokens on L2 logger.info("user2 consumes owner's message on L2 Publicly"); diff --git a/yarn-project/end-to-end/src/fixtures/fixtures.ts b/yarn-project/end-to-end/src/fixtures/fixtures.ts index 23e0b482f27..ec11d1ae340 100644 --- a/yarn-project/end-to-end/src/fixtures/fixtures.ts +++ b/yarn-project/end-to-end/src/fixtures/fixtures.ts @@ -6,5 +6,7 @@ export const privateKey2 = Buffer.from('59c6995e998f97a5a0044966f0945389dc9e86da export const U128_UNDERFLOW_ERROR = "Assertion failed: attempt to subtract with underflow 'hi == high'"; export const U128_OVERFLOW_ERROR = "Assertion failed: attempt to add with overflow 'hi == high'"; export const BITSIZE_TOO_BIG_ERROR = "'self.__assert_max_bit_size(bit_size)'"; -// TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): Make this a fixed error after transition. -export const DUPLICATE_NULLIFIER_ERROR = /Transaction .*|.*duplicate nullifier.*/; +// TODO(https://github.com/AztecProtocol/aztec-packages/issues/5818): Make these a fixed error after transition. +export const DUPLICATE_NULLIFIER_ERROR = /dropped|duplicate nullifier|reverted/; +export const NO_L1_TO_L2_MSG_ERROR = + /No non-nullified L1 to L2 message found for message hash|Tried to consume nonexistent L1-to-L2 message/;