Skip to content

Commit

Permalink
chore: change some error messages for avm switch (AztecProtocol#6447)
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro authored May 16, 2024
1 parent bee85a9 commit 74d6519
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 1 addition & 3 deletions yarn-project/end-to-end/src/e2e_block_building.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -114,9 +115,6 @@ describe('e2e_block_building', () => {
describe('double-spends', () => {
let contract: TestContract;
let teardown: () => Promise<void>;
// 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));
Expand Down
15 changes: 2 additions & 13 deletions yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand All @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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();
Expand All @@ -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");
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/end-to-end/src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/;

0 comments on commit 74d6519

Please sign in to comment.