Skip to content

Commit

Permalink
Revert "feat: trace AVM side effects per enqueued call" (#9058)
Browse files Browse the repository at this point in the history
Reverts #8918

This was breaking e2e-prover-full with
```
2024-10-07T18:38:39.5367651Z [36m    +e2e-prover-full[0m |   [34;1maztec:prover-client:prover-agent [0m[INFO] Agent is running with 2 in-flight jobs: id=cf7ebac9,type=BASE_ROLLUP id=5f3f9a1b,type=PUBLIC_KERNEL_INNER [34m+5s[0m
2024-10-07T18:38:45.3223814Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Generated witness circuitName=base-rollup duration=14385.497549999971 inputSize=226276 outputSize=664 eventName=circuit-witness-generation [36m+7s[0m
2024-10-07T18:38:47.0520236Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Generated proof for PublicKernelInnerArtifact in 8754 ms, size: 463 fields circuitName=public-kernel-inner circuitSize=524288 duration=8753.659793999977 inputSize=52672 proofSize=93892 eventName=circuit-proving numPublicInputs=2487 [36m+2s[0m
2024-10-07T18:38:47.1351455Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Successfully verified proof from key in 79.74121499992907 ms [36m+84ms[0m
2024-10-07T18:38:47.1359511Z [36m    +e2e-prover-full[0m |   [34;1maztec:prover-client:prover-agent [0m[VERBOSE] Processed proving job id=5f3f9a1b type=PUBLIC_KERNEL_INNER duration=12543.893958999892ms [34m+8s[0m
2024-10-07T18:38:47.2392290Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Successfully verified proof from key in 84.31422300008126 ms [36m+104ms[0m
2024-10-07T18:38:48.1190928Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Generated witness circuitName=public-kernel-merge duration=805.3169080000371 inputSize=259272 outputSize=70692 eventName=circuit-witness-generation [36m+879ms[0m
2024-10-07T18:39:03.8562729Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[INFO] Generated proof for PublicKernelMergeArtifact in 15727 ms, size: 463 fields circuitName=public-kernel-merge circuitSize=2097152 duration=15726.628410000005 inputSize=70692 proofSize=114852 eventName=circuit-proving numPublicInputs=3142 [36m+16s[0m
2024-10-07T18:39:03.9344666Z [36m    +e2e-prover-full[0m |   [36;1maztec:bb-prover [0m[ERROR] Error running operation at /usr/src/bb/tmp-qnclFA: Error: Failed to verify proof from key! [36m+78ms[0m
2024-10-07T18:39:03.9649933Z [36m    +e2e-prover-full[0m |   [34;1maztec:prover-client:prover-agent [0m[ERROR] Error processing proving job id=6f1c2b0f type=PUBLIC_KERNEL_MERGE: Error: Failed to verify proof from key!: Error: Failed to verify proof from key!
2024-10-07T18:39:03.9653074Z [36m    +e2e-prover-full[0m |     at operation (/usr/src/yarn-project/bb-prover/src/prover/bb_prover.ts:844:15)
2024-10-07T18:39:03.9655268Z [36m    +e2e-prover-full[0m |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-10-07T18:39:03.9656773Z [36m    +e2e-prover-full[0m |     at runInDirectory (/usr/src/yarn-project/foundation/src/fs/run_in_dir.ts:17:12)
2024-10-07T18:39:03.9658121Z [36m    +e2e-prover-full[0m |     at BBNativeRollupProver.verifyWithKeyInternal (/usr/src/yarn-project/bb-prover/src/prover/bb_prover.ts:850:5)
2024-10-07T18:39:03.9659432Z [36m    +e2e-prover-full[0m |     at BBNativeRollupProver.verifyWithKey (/usr/src/yarn-project/bb-prover/src/prover/bb_prover.ts:823:12)
2024-10-07T18:39:03.9660661Z [36m    +e2e-prover-full[0m |     at BBNativeRollupProver.verifyProof (/usr/src/yarn-project/bb-prover/src/prover/bb_prover.ts:813:12)
2024-10-07T18:39:03.9661954Z [36m    +e2e-prover-full[0m |     at BBNativeRollupProver.getPublicKernelMergeProof (/usr/src/yarn-project/bb-prover/src/prover/bb_prover.ts:280:5)
2024-10-07T18:39:03.9663070Z [36m    +e2e-prover-full[0m |     at /usr/src/yarn-project/telemetry-client/src/telemetry.ts:150:23
2024-10-07T18:39:03.9663983Z [36m    +e2e-prover-full[0m |     at elapsed (/usr/src/yarn-project/foundation/src/timer/elapsed.ts:10:18)
2024-10-07T18:39:03.9665120Z [36m    +e2e-prover-full[0m |     at ProverAgent.work (/usr/src/yarn-project/prover-client/src/prover-agent/prover-agent.ts:129:30) [34m+17s[0m
2024-10-07T18:39:03.9667083Z [36m    +e2e-prover-full[0m |   [34;1maztec:prover-client:prover-pool:queue [0m[WARN] Job id=6f1c2b0f type=PUBLIC_KERNEL_MERGE failed with error: Failed to verify proof from key!. Retry 2/3 [34m+11m[0m
```
  • Loading branch information
ludamad authored Oct 7, 2024
1 parent e49bec5 commit 06b36f5
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 1,366 deletions.
4 changes: 0 additions & 4 deletions yarn-project/circuits.js/src/structs/l2_to_l1_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ export class L2ToL1Message {
isEmpty(): boolean {
return this.recipient.isZero() && this.content.isZero() && !this.counter;
}

scope(contractAddress: AztecAddress) {
return new ScopedL2ToL1Message(this, contractAddress);
}
}

export class ScopedL2ToL1Message {
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/circuits.js/src/structs/log_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export class LogHash implements Ordered {
return `value=${this.value} counter=${this.counter} length=${this.length}`;
}

scope(contractAddress: AztecAddress) {
return new ScopedLogHash(this, contractAddress);
}

[inspect.custom](): string {
return `LogHash { ${this.toString()} }`;
}
Expand Down
13 changes: 3 additions & 10 deletions yarn-project/prover-client/src/mocks/test_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ import {
type Tx,
type TxValidator,
} from '@aztec/circuit-types';
import {
type CombinedConstantData,
type Gas,
type GlobalVariables,
Header,
type Nullifier,
type TxContext,
} from '@aztec/circuits.js';
import { type Gas, type GlobalVariables, Header, type Nullifier, type TxContext } from '@aztec/circuits.js';
import { type Fr } from '@aztec/foundation/fields';
import { type DebugLogger } from '@aztec/foundation/log';
import { openTmpStore } from '@aztec/kv-store/utils';
Expand Down Expand Up @@ -162,7 +155,7 @@ export class TestContext {
) {
const defaultExecutorImplementation = (
execution: PublicExecutionRequest,
_constants: CombinedConstantData,
_globalVariables: GlobalVariables,
availableGas: Gas,
_txContext: TxContext,
_pendingNullifiers: Nullifier[],
Expand Down Expand Up @@ -202,7 +195,7 @@ export class TestContext {
txValidator?: TxValidator<ProcessedTx>,
executorMock?: (
execution: PublicExecutionRequest,
constants: CombinedConstantData,
globalVariables: GlobalVariables,
availableGas: Gas,
txContext: TxContext,
pendingNullifiers: Nullifier[],
Expand Down
75 changes: 1 addition & 74 deletions yarn-project/simulator/src/avm/avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { type Fieldable } from '@aztec/foundation/serialize';
import { randomInt } from 'crypto';
import { mock } from 'jest-mock-extended';

import { PublicEnqueuedCallSideEffectTrace } from '../public/enqueued_call_side_effect_trace.js';
import { type WorldStateDB } from '../public/public_db_sources.js';
import { type PublicSideEffectTraceInterface } from '../public/side_effect_trace_interface.js';
import { type AvmContext } from './avm_context.js';
Expand All @@ -31,23 +30,7 @@ import {
resolveAvmTestContractAssertionMessage,
} from './fixtures/index.js';
import { type AvmPersistableStateManager } from './journal/journal.js';
import {
Add,
CalldataCopy,
EmitNoteHash,
EmitNullifier,
EmitUnencryptedLog,
type Instruction,
Jump,
L1ToL2MessageExists,
NoteHashExists,
NullifierExists,
Return,
SLoad,
SStore,
SendL2ToL1Message,
Set,
} from './opcodes/index.js';
import { Add, CalldataCopy, Return, Set } from './opcodes/index.js';
import { encodeToBytecode } from './serialization/bytecode_serialization.js';
import { Opcode } from './serialization/instruction_serialization.js';
import {
Expand Down Expand Up @@ -953,62 +936,6 @@ describe('AVM simulator: transpiled Noir contracts', () => {
);
});
});

describe('Side effect trace errors on overflow', () => {
const trace = new PublicEnqueuedCallSideEffectTrace();
const persistableState = initPersistableStateManager({ worldStateDB, trace });

it.each([
['Public storage writes', () => new SStore(/*indirect=*/ 0, /*srcOffset=*/ 0, /*slotOffset=*/ 0)],
['Public storage reads', () => new SLoad(/*indirect=*/ 0, /*slotOffset=*/ 0, /*dstOffset=*/ 0)],
[
'Note hash checks',
() => new NoteHashExists(/*indirect=*/ 0, /*noteHashOffset=*/ 0, /*leafIndexOffest=*/ 0, /*existsOffset=*/ 1),
],
['New note hashes', () => new EmitNoteHash(/*indirect=*/ 0, /*noteHashOffset=*/ 0)],
[
'Nullifier checks',
() => new NullifierExists(/*indirect=*/ 0, /*nullifierOffset=*/ 0, /*addressOffest=*/ 0, /*existsOffset=*/ 1),
],
['New nullifiers', () => new EmitNullifier(/*indirect=*/ 0, /*noteHashOffset=*/ 0)],
[
'L1 to L2 message checks',
() =>
new L1ToL2MessageExists(
/*indirect=*/ 0,
/*msgHashOffset=*/ 0,
/*msgLeafIndexOffest=*/ 0,
/*existsOffset=*/ 1,
),
],
['New unencrypted logs', () => new EmitUnencryptedLog(/*indirect=*/ 0, /*logOffset=*/ 0, /*logSizeOffest=*/ 1)],
[
'New L1 to L2 messages',
() => new SendL2ToL1Message(/*indirect=*/ 0, /*recipientOffset=*/ 0, /*contentOffest=*/ 0),
],
])(`Overrun of %s`, async (_sideEffectType: string, createInstr: () => Instruction) => {
const bytecode = encodeToBytecode([
new Set(/*indirect*/ 0, TypeTag.FIELD, /*value*/ 0, /*dstOffset*/ 0).as(Opcode.SET_8, Set.wireFormat8),
new Set(/*indirect*/ 0, TypeTag.FIELD, /*value*/ 100, /*dstOffset*/ 100).as(Opcode.SET_8, Set.wireFormat8),
new Set(/*indirect*/ 0, TypeTag.UINT32, /*value*/ 1, /*dstOffset*/ 1).as(Opcode.SET_8, Set.wireFormat8),
createInstr(),
// change value at memory offset 0 so each instr operates on a different value (important for nullifier emission)
new Add(/*indirect=*/ 0, TypeTag.FIELD, /*aOffset=*/ 0, /*bOffset=*/ 100, /*dstOffset=*/ 0).as(
Opcode.ADD_8,
Add.wireFormat8,
),
// infinitely loop back to the tested instruction
// infinite loop should break on side effect overrun error,
// but otherwise will run out of gas
new Jump(/*jumpOffset*/ 2),
]);
const context = initContext({ persistableState });
const results = await new AvmSimulator(context).executeBytecode(markBytecodeAsAvm(bytecode));
expect(results.reverted).toBe(true);
expect(results.output).toEqual([]);
expect(results.revertReason?.message).toMatch('Reached the limit');
});
});
});
});

Expand Down
3 changes: 1 addition & 2 deletions yarn-project/simulator/src/avm/avm_simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';

import { strict as assert } from 'assert';

import { SideEffectLimitReachedError } from '../public/side_effect_errors.js';
import type { AvmContext } from './avm_context.js';
import { AvmContractCallResult } from './avm_contract_call_result.js';
import { isAvmBytecode } from './bytecode_utils.js';
Expand Down Expand Up @@ -99,7 +98,7 @@ export class AvmSimulator {
return results;
} catch (err: any) {
this.log.verbose('Exceptional halt (revert by something other than REVERT opcode)');
if (!(err instanceof AvmExecutionError || err instanceof SideEffectLimitReachedError)) {
if (!(err instanceof AvmExecutionError)) {
this.log.verbose(`Unknown error thrown by AVM: ${err}`);
throw err;
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/simulator/src/avm/journal/journal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AztecAddress, type FunctionSelector, type Gas } from '@aztec/circuits.js';
import { Fr } from '@aztec/foundation/fields';
import { createDebugLogger } from '@aztec/foundation/log';
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
import { SerializableContractInstance } from '@aztec/types/contracts';

import { getPublicFunctionDebugName } from '../../common/debug_fn_name.js';
Expand All @@ -22,7 +22,7 @@ import { PublicStorage } from './public_storage.js';
* Manages merging of successful/reverted child state into current state.
*/
export class AvmPersistableStateManager {
private readonly log = createDebugLogger('aztec:avm_simulator:state_manager');
private readonly log: DebugLogger = createDebugLogger('aztec:avm_simulator:state_manager');

constructor(
/** Reference to node storage */
Expand Down
169 changes: 0 additions & 169 deletions yarn-project/simulator/src/public/dual_side_effect_trace.ts

This file was deleted.

Loading

0 comments on commit 06b36f5

Please sign in to comment.