Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions yarn-project/end-to-end/src/e2e_event_logs.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AztecAddress, type AztecNode, Fr, type Wallet, getDecodedPublicEvents } from '@aztec/aztec.js';
import { AztecAddress, type AztecNode, Fr, type Logger, type Wallet, getDecodedPublicEvents } from '@aztec/aztec.js';
import { makeTuple } from '@aztec/foundation/array';
import { timesParallel } from '@aztec/foundation/collection';
import type { Tuple } from '@aztec/foundation/serialize';
Expand All @@ -20,6 +20,7 @@ describe('Logs', () => {
let account1Address: AztecAddress;
let account2Address: AztecAddress;

let log: Logger;
let teardown: () => Promise<void>;

beforeAll(async () => {
Expand All @@ -28,10 +29,13 @@ describe('Logs', () => {
wallet,
accounts: [account1Address, account2Address],
aztecNode,
logger: log,
} = await setup(2));

await ensureAccountContractsPublished(wallet, [account1Address, account1Address]);
log.warn(`Setup complete, checking account contracts published`);
await ensureAccountContractsPublished(wallet, [account1Address, account2Address]);

log.warn(`Deploying test contract`);
testLogContract = await TestLogContract.deploy(wallet).send({ from: account1Address }).deployed();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Fr } from '@aztec/foundation/fields';
import { mockTx, mockTxForRollup } from '@aztec/stdlib/testing';
import { type AnyTx, TX_ERROR_DUPLICATE_NULLIFIER_IN_TX, TX_ERROR_EXISTING_NULLIFIER } from '@aztec/stdlib/tx';

Expand Down Expand Up @@ -27,8 +28,8 @@ describe('DoubleSpendTxValidator', () => {
numberOfNonRevertiblePublicCallRequests: 1,
numberOfRevertiblePublicCallRequests: 0,
});
badTx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers[1] =
badTx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers[0];
const nullifiers = badTx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers;
nullifiers[1] = new Fr(nullifiers[0].toBigInt());
await expectInvalid(badTx, TX_ERROR_DUPLICATE_NULLIFIER_IN_TX);
});

Expand All @@ -38,8 +39,8 @@ describe('DoubleSpendTxValidator', () => {
numberOfRevertiblePublicCallRequests: 1,
numberOfRevertibleNullifiers: 1,
});
badTx.data.forPublic!.revertibleAccumulatedData.nullifiers[1] =
badTx.data.forPublic!.revertibleAccumulatedData.nullifiers[0];
const nullifiers = badTx.data.forPublic!.revertibleAccumulatedData.nullifiers;
nullifiers[1] = new Fr(nullifiers[0].toBigInt());
await expectInvalid(badTx, TX_ERROR_DUPLICATE_NULLIFIER_IN_TX);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
const nullifiers = tx instanceof Tx ? tx.data.getNonEmptyNullifiers() : tx.txEffect.nullifiers;

// Ditch this tx if it has repeated nullifiers
const uniqueNullifiers = new Set(nullifiers);
const uniqueNullifiers = new Set(nullifiers.map(n => n.toBigInt()));
if (uniqueNullifiers.size !== nullifiers.length) {
this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for emitting duplicate nullifiers`);
return { result: 'invalid', reason: [TX_ERROR_DUPLICATE_NULLIFIER_IN_TX] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
StateReference,
Tx,
TxExecutionPhase,
type TxValidator,
makeProcessedTxFromPrivateOnlyTx,
makeProcessedTxFromTxWithPublicCalls,
} from '@aztec/stdlib/tx';
Expand Down Expand Up @@ -384,10 +383,7 @@ export class PublicProcessor implements Traceable {
return [processedTx, returnValues ?? []];
}

private async doTreeInsertionsForPrivateOnlyTx(
processedTx: ProcessedTx,
txValidator?: TxValidator<ProcessedTx>,
): Promise<void> {
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
const treeInsertionStart = process.hrtime.bigint();

// Update the state so that the next tx in the loop has the correct .startState
Expand All @@ -406,14 +402,8 @@ export class PublicProcessor implements Traceable {
padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(n => n.toBuffer()),
NULLIFIER_SUBTREE_HEIGHT,
);
} catch {
if (txValidator) {
// Ideally the validator has already caught this above, but just in case:
throw new Error(`Transaction ${processedTx.hash} invalid after processing public functions`);
} else {
// We have no validator and assume this call should blindly process txs with duplicates being caught later
this.log.warn(`Detected duplicate nullifier after public processing for: ${processedTx.hash}.`);
}
} catch (cause) {
throw new Error(`Transaction ${processedTx.hash} failed with duplicate nullifiers`, { cause });
}

const treeInsertionEnd = process.hrtime.bigint();
Expand Down
Loading