@aztec/simulator 3.0.0-nightly.20251007 → 3.0.0-nightly.20251009
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +4 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +5 -10
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +6 -6
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +4 -8
- package/package.json +15 -15
- package/src/public/avm/avm_simulator.ts +6 -1
- package/src/public/fixtures/minimal_public_tx.ts +5 -16
- package/src/public/public_tx_simulator/public_tx_context.ts +5 -4
- package/src/public/public_tx_simulator/public_tx_simulator.ts +3 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/avm/avm_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EAEL,KAAK,cAAc,EAEpB,MA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|
|
@@ -76,6 +76,7 @@ export class AvmSimulator {
|
|
|
76
76
|
const timer = new Timer();
|
|
77
77
|
assert(bytecode.length > 0, "AVM simulator can't execute empty bytecode");
|
|
78
78
|
this.bytecode = bytecode;
|
|
79
|
+
let instructionName = 'NONE'; // This is used for logging purposes
|
|
79
80
|
const { machineState } = this.context;
|
|
80
81
|
const callStartGas = machineState.gasLeft; // Save gas before executing instruction (for profiling)
|
|
81
82
|
try {
|
|
@@ -95,6 +96,7 @@ export class AvmSimulator {
|
|
|
95
96
|
this.log.trace(`[PC:${machineState.pc}] [IC:${machineState.instrCounter}] ${instruction.toString()} (gasLeft l2=${machineState.l2GasLeft} da=${machineState.daGasLeft})`);
|
|
96
97
|
}
|
|
97
98
|
machineState.nextPc = machineState.pc + bytesRead;
|
|
99
|
+
instructionName = instruction.constructor.name;
|
|
98
100
|
// Execute the instruction.
|
|
99
101
|
// Normal returns and reverts will return normally here.
|
|
100
102
|
// "Exceptional halts" will throw.
|
|
@@ -130,7 +132,8 @@ export class AvmSimulator {
|
|
|
130
132
|
// Return results for processing by calling context
|
|
131
133
|
return results;
|
|
132
134
|
} catch (err) {
|
|
133
|
-
this.log.
|
|
135
|
+
this.log.info(`Exceptional halt (revert by something other than REVERT opcode) for instruction
|
|
136
|
+
${instructionName} at pc ${machineState.pc} and instruction counter ${machineState.instrCounter}`);
|
|
134
137
|
if (!(err instanceof CheckedPublicExecutionError)) {
|
|
135
138
|
this.log.error(`Unchecked/unknown error thrown by AVM. This is a bug. Error: ${err}`);
|
|
136
139
|
throw err;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minimal_public_tx.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/minimal_public_tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"minimal_public_tx.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/minimal_public_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAIpF,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,cAAc,CAAC,CAiBrE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,gBAAgB,CAEvE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
1
|
+
import { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
2
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
4
3
|
import avmMinimalCircuitInputsJson from '../../../artifacts/avm_minimal_inputs.json' with {
|
|
5
4
|
type: 'json'
|
|
6
5
|
};
|
|
@@ -19,13 +18,9 @@ export async function simAvmMinimalPublicTx() {
|
|
|
19
18
|
]);
|
|
20
19
|
const tester = await PublicTxSimulationTester.create();
|
|
21
20
|
const result = await testCustomBytecode(minimalBytecode, tester, 'MinimalTx', 'AvmMinimalContract');
|
|
22
|
-
// Modify the
|
|
23
|
-
|
|
24
|
-
result.avmProvingRequest.inputs.
|
|
25
|
-
result.avmProvingRequest.inputs.publicInputs.protocolContractTreeRoot = Fr.fromString('0x0dcca15f6b97b59e13712bd9e5a6a2e7fe2349ebb82b5a82a4ae554358bac73a');
|
|
26
|
-
// You can uncomment this to log the actual root if you want to verify it it matches
|
|
27
|
-
// const protocolContractTree = await buildProtocolContractTree([]);
|
|
28
|
-
// console.log(Fr.fromBuffer(protocolContractTree.root));
|
|
21
|
+
// Modify the protocol contracts to be all zeros
|
|
22
|
+
result.avmProvingRequest.inputs.hints.protocolContracts = ProtocolContracts.empty();
|
|
23
|
+
result.avmProvingRequest.inputs.publicInputs.protocolContracts = ProtocolContracts.empty();
|
|
29
24
|
return result;
|
|
30
25
|
}
|
|
31
26
|
/**
|
|
@@ -4,7 +4,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
5
5
|
import { Gas } from '@aztec/stdlib/gas';
|
|
6
6
|
import { PrivateToPublicAccumulatedData } from '@aztec/stdlib/kernel';
|
|
7
|
-
import { type GlobalVariables, PublicCallRequestWithCalldata, type Tx, TxExecutionPhase, type TxHash } from '@aztec/stdlib/tx';
|
|
7
|
+
import { type GlobalVariables, ProtocolContracts, PublicCallRequestWithCalldata, type Tx, TxExecutionPhase, type TxHash } from '@aztec/stdlib/tx';
|
|
8
8
|
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
9
9
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
10
10
|
import { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
@@ -16,7 +16,7 @@ export declare class PublicTxContext {
|
|
|
16
16
|
readonly state: PhaseStateManager;
|
|
17
17
|
private readonly startTreeSnapshots;
|
|
18
18
|
private readonly globalVariables;
|
|
19
|
-
private readonly
|
|
19
|
+
private readonly protocolContracts;
|
|
20
20
|
private readonly proverId;
|
|
21
21
|
private readonly gasSettings;
|
|
22
22
|
private readonly gasUsedByPrivate;
|
|
@@ -36,7 +36,7 @@ export declare class PublicTxContext {
|
|
|
36
36
|
private revertCode;
|
|
37
37
|
revertReason: SimulationError | undefined;
|
|
38
38
|
private constructor();
|
|
39
|
-
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, tx: Tx, globalVariables: GlobalVariables,
|
|
39
|
+
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, tx: Tx, globalVariables: GlobalVariables, protocolContracts: ProtocolContracts, doMerkleOperations: boolean, proverId: Fr): Promise<PublicTxContext>;
|
|
40
40
|
/**
|
|
41
41
|
* Signal that the entire transaction execution is done.
|
|
42
42
|
* All phases have been processed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,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
23
23
|
startTreeSnapshots;
|
|
24
24
|
globalVariables;
|
|
25
|
-
|
|
25
|
+
protocolContracts;
|
|
26
26
|
proverId;
|
|
27
27
|
gasSettings;
|
|
28
28
|
gasUsedByPrivate;
|
|
@@ -41,12 +41,12 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
41
41
|
/* Entire transaction execution is done. */ halted;
|
|
42
42
|
/* Where did reverts happen (if at all)? */ revertCode;
|
|
43
43
|
/* What caused a revert (if one occurred)? */ revertReason;
|
|
44
|
-
constructor(txHash, state, startTreeSnapshots, globalVariables,
|
|
44
|
+
constructor(txHash, state, startTreeSnapshots, globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, setupCallRequests, appLogicCallRequests, teardownCallRequests, nonRevertibleAccumulatedDataFromPrivate, revertibleAccumulatedDataFromPrivate, feePayer, trace){
|
|
45
45
|
this.txHash = txHash;
|
|
46
46
|
this.state = state;
|
|
47
47
|
this.startTreeSnapshots = startTreeSnapshots;
|
|
48
48
|
this.globalVariables = globalVariables;
|
|
49
|
-
this.
|
|
49
|
+
this.protocolContracts = protocolContracts;
|
|
50
50
|
this.proverId = proverId;
|
|
51
51
|
this.gasSettings = gasSettings;
|
|
52
52
|
this.gasUsedByPrivate = gasUsedByPrivate;
|
|
@@ -65,7 +65,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
65
65
|
this.revertCode = RevertCode.OK;
|
|
66
66
|
this.log = createLogger(`simulator:public_tx_context`);
|
|
67
67
|
}
|
|
68
|
-
static async create(treesDB, contractsDB, tx, globalVariables,
|
|
68
|
+
static async create(treesDB, contractsDB, tx, globalVariables, protocolContracts, doMerkleOperations, proverId) {
|
|
69
69
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic.nonRevertibleAccumulatedData;
|
|
70
70
|
const trace = new SideEffectTrace();
|
|
71
71
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
@@ -75,7 +75,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
75
75
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
76
76
|
const gasAllocatedToPublic = gasSettings.gasLimits.sub(gasUsedByPrivate);
|
|
77
77
|
const gasAllocatedToPublicTeardown = gasSettings.teardownGasLimits;
|
|
78
|
-
return new PublicTxContext(tx.getTxHash(), new PhaseStateManager(txStateManager), await txStateManager.getTreeSnapshots(), globalVariables,
|
|
78
|
+
return new PublicTxContext(tx.getTxHash(), new PhaseStateManager(txStateManager), await txStateManager.getTreeSnapshots(), globalVariables, protocolContracts, proverId, gasSettings, gasUsedByPrivate, gasAllocatedToPublic, gasAllocatedToPublicTeardown, getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC), getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN), tx.data.forPublic.nonRevertibleAccumulatedData, tx.data.forPublic.revertibleAccumulatedData, tx.data.feePayer, trace);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Signal that the entire transaction execution is done.
|
|
@@ -244,7 +244,7 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
244
244
|
// This converts the private accumulated data to the avm accumulated data format.
|
|
245
245
|
const convertAccumulatedData = (from)=>new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs);
|
|
246
246
|
const getPreviousAccumulatedDataArrayLengths = (from)=>new PrivateToAvmAccumulatedDataArrayLengths(countAccumulatedItems(from.noteHashes), countAccumulatedItems(from.nullifiers), countAccumulatedItems(from.l2ToL1Msgs));
|
|
247
|
-
return new AvmCircuitPublicInputs(this.globalVariables, this.
|
|
247
|
+
return new AvmCircuitPublicInputs(this.globalVariables, this.protocolContracts, this.startTreeSnapshots, /*startGasUsed=*/ this.gasUsedByPrivate, this.gasSettings, computeEffectiveGasFees(this.globalVariables.gasFees, this.gasSettings), this.feePayer, this.proverId, /*publicCallRequestArrayLengths=*/ new PublicCallRequestArrayLengths(this.setupCallRequests.length, this.appLogicCallRequests.length, this.teardownCallRequests.length > 0), /*publicSetupCallRequests=*/ padArrayEnd(this.setupCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicAppLogicCallRequests=*/ padArrayEnd(this.appLogicCallRequests.map((r)=>r.request), PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), /*publicTeardownCallRequests=*/ this.teardownCallRequests.length > 0 ? this.teardownCallRequests[0].request : PublicCallRequest.empty(), getPreviousAccumulatedDataArrayLengths(this.nonRevertibleAccumulatedDataFromPrivate), getPreviousAccumulatedDataArrayLengths(this.revertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.nonRevertibleAccumulatedDataFromPrivate), convertAccumulatedData(this.revertibleAccumulatedDataFromPrivate), endTreeSnapshots, this.getTotalGasUsed(), accumulatedDataArrayLengths, accumulatedData, /*transactionFee=*/ this.getTransactionFeeUnsafe(), /*isReverted=*/ !this.revertCode.isOK());
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAIL,KAAK,iBAAiB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,sBAAsB;CAStC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS, DEFAULT_MAX_DEBUG_LOG_MEMORY_READS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { ProtocolContractAddress,
|
|
4
|
+
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
5
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
6
|
-
import { AvmCircuitInputs, AvmExecutionHints,
|
|
7
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { AvmCircuitInputs, AvmExecutionHints, AvmTxHint } from '@aztec/stdlib/avm';
|
|
8
7
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
9
8
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
10
9
|
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
@@ -72,15 +71,12 @@ export class PublicTxSimulator {
|
|
|
72
71
|
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
73
72
|
txHash
|
|
74
73
|
});
|
|
75
|
-
// These values are technically derivable from the contractsDB. However, since the trees are not persisted
|
|
76
|
-
// computing them for every tx would be time consuming for this TS simulator. So instead we just import them
|
|
77
|
-
const protocolContractHints = protocolContractNames.map((name)=>new AvmProtocolContractAddressHint(/*Canonical Address=*/ ProtocolContractAddress[name], /*Derived Address=*/ AztecAddress.fromField(ProtocolContractLeaves[name])));
|
|
78
74
|
// Create hinting DBs.
|
|
79
|
-
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
75
|
+
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees), ProtocolContractsList);
|
|
80
76
|
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
81
77
|
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
82
78
|
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
83
|
-
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables,
|
|
79
|
+
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables, ProtocolContractsList, this.config.doMerkleOperations, this.config.proverId);
|
|
84
80
|
// This will throw if there is a nullifier collision.
|
|
85
81
|
// In that case the transaction will be thrown out.
|
|
86
82
|
await this.insertNonRevertiblesFromPrivate(context, tx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251009",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -63,25 +63,25 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
67
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
68
|
-
"@aztec/noir-acvm_js": "3.0.0-nightly.
|
|
69
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
70
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
71
|
-
"@aztec/noir-types": "3.0.0-nightly.
|
|
72
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
73
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
74
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
75
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
66
|
+
"@aztec/constants": "3.0.0-nightly.20251009",
|
|
67
|
+
"@aztec/foundation": "3.0.0-nightly.20251009",
|
|
68
|
+
"@aztec/noir-acvm_js": "3.0.0-nightly.20251009",
|
|
69
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251009",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251009",
|
|
71
|
+
"@aztec/noir-types": "3.0.0-nightly.20251009",
|
|
72
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251009",
|
|
73
|
+
"@aztec/stdlib": "3.0.0-nightly.20251009",
|
|
74
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251009",
|
|
75
|
+
"@aztec/world-state": "3.0.0-nightly.20251009",
|
|
76
76
|
"lodash.clonedeep": "^4.5.0",
|
|
77
77
|
"lodash.merge": "^4.6.2",
|
|
78
78
|
"tslib": "^2.4.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
82
|
-
"@aztec/merkle-tree": "3.0.0-nightly.
|
|
83
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
84
|
-
"@aztec/noir-test-contracts.js": "3.0.0-nightly.
|
|
81
|
+
"@aztec/kv-store": "3.0.0-nightly.20251009",
|
|
82
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251009",
|
|
83
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251009",
|
|
84
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251009",
|
|
85
85
|
"@jest/globals": "^30.0.0",
|
|
86
86
|
"@types/jest": "^30.0.0",
|
|
87
87
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -128,6 +128,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
128
128
|
assert(bytecode.length > 0, "AVM simulator can't execute empty bytecode");
|
|
129
129
|
|
|
130
130
|
this.bytecode = bytecode;
|
|
131
|
+
let instructionName = 'NONE'; // This is used for logging purposes
|
|
131
132
|
|
|
132
133
|
const { machineState } = this.context;
|
|
133
134
|
const callStartGas = machineState.gasLeft; // Save gas before executing instruction (for profiling)
|
|
@@ -156,6 +157,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
156
157
|
}
|
|
157
158
|
machineState.nextPc = machineState.pc + bytesRead;
|
|
158
159
|
|
|
160
|
+
instructionName = instruction.constructor.name;
|
|
159
161
|
// Execute the instruction.
|
|
160
162
|
// Normal returns and reverts will return normally here.
|
|
161
163
|
// "Exceptional halts" will throw.
|
|
@@ -204,7 +206,10 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
204
206
|
// Return results for processing by calling context
|
|
205
207
|
return results;
|
|
206
208
|
} catch (err: any) {
|
|
207
|
-
this.log.
|
|
209
|
+
this.log.info(
|
|
210
|
+
`Exceptional halt (revert by something other than REVERT opcode) for instruction
|
|
211
|
+
${instructionName} at pc ${machineState.pc} and instruction counter ${machineState.instrCounter}`,
|
|
212
|
+
);
|
|
208
213
|
if (!(err instanceof CheckedPublicExecutionError)) {
|
|
209
214
|
this.log.error(`Unchecked/unknown error thrown by AVM. This is a bug. Error: ${err}`);
|
|
210
215
|
throw err;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
1
|
+
import { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
2
|
+
import { ProtocolContracts } from '@aztec/stdlib/tx';
|
|
4
3
|
|
|
5
4
|
import avmMinimalCircuitInputsJson from '../../../artifacts/avm_minimal_inputs.json' with { type: 'json' };
|
|
6
5
|
import { TypeTag } from '../avm/avm_memory_types.js';
|
|
@@ -23,19 +22,9 @@ export async function simAvmMinimalPublicTx(): Promise<PublicTxResult> {
|
|
|
23
22
|
|
|
24
23
|
const result = await testCustomBytecode(minimalBytecode, tester, 'MinimalTx', 'AvmMinimalContract');
|
|
25
24
|
|
|
26
|
-
// Modify the
|
|
27
|
-
|
|
28
|
-
result.avmProvingRequest.inputs.
|
|
29
|
-
result.avmProvingRequest.inputs.hints.protocolContractDerivedAddresses.map(
|
|
30
|
-
() => new AvmProtocolContractAddressHint(AztecAddress.ZERO, AztecAddress.ZERO),
|
|
31
|
-
);
|
|
32
|
-
result.avmProvingRequest.inputs.publicInputs.protocolContractTreeRoot = Fr.fromString(
|
|
33
|
-
'0x0dcca15f6b97b59e13712bd9e5a6a2e7fe2349ebb82b5a82a4ae554358bac73a',
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
// You can uncomment this to log the actual root if you want to verify it it matches
|
|
37
|
-
// const protocolContractTree = await buildProtocolContractTree([]);
|
|
38
|
-
// console.log(Fr.fromBuffer(protocolContractTree.root));
|
|
25
|
+
// Modify the protocol contracts to be all zeros
|
|
26
|
+
result.avmProvingRequest.inputs.hints.protocolContracts = ProtocolContracts.empty();
|
|
27
|
+
result.avmProvingRequest.inputs.publicInputs.protocolContracts = ProtocolContracts.empty();
|
|
39
28
|
|
|
40
29
|
return result;
|
|
41
30
|
}
|
|
@@ -32,6 +32,7 @@ import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
|
32
32
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
33
33
|
import {
|
|
34
34
|
type GlobalVariables,
|
|
35
|
+
ProtocolContracts,
|
|
35
36
|
PublicCallRequestWithCalldata,
|
|
36
37
|
TreeSnapshots,
|
|
37
38
|
type Tx,
|
|
@@ -70,7 +71,7 @@ export class PublicTxContext {
|
|
|
70
71
|
public readonly state: PhaseStateManager,
|
|
71
72
|
private readonly startTreeSnapshots: TreeSnapshots,
|
|
72
73
|
private readonly globalVariables: GlobalVariables,
|
|
73
|
-
private readonly
|
|
74
|
+
private readonly protocolContracts: ProtocolContracts,
|
|
74
75
|
private readonly proverId: Fr,
|
|
75
76
|
private readonly gasSettings: GasSettings,
|
|
76
77
|
private readonly gasUsedByPrivate: Gas,
|
|
@@ -92,7 +93,7 @@ export class PublicTxContext {
|
|
|
92
93
|
contractsDB: PublicContractsDBInterface,
|
|
93
94
|
tx: Tx,
|
|
94
95
|
globalVariables: GlobalVariables,
|
|
95
|
-
|
|
96
|
+
protocolContracts: ProtocolContracts,
|
|
96
97
|
doMerkleOperations: boolean,
|
|
97
98
|
proverId: Fr,
|
|
98
99
|
) {
|
|
@@ -122,7 +123,7 @@ export class PublicTxContext {
|
|
|
122
123
|
new PhaseStateManager(txStateManager),
|
|
123
124
|
await txStateManager.getTreeSnapshots(),
|
|
124
125
|
globalVariables,
|
|
125
|
-
|
|
126
|
+
protocolContracts,
|
|
126
127
|
proverId,
|
|
127
128
|
gasSettings,
|
|
128
129
|
gasUsedByPrivate,
|
|
@@ -380,7 +381,7 @@ export class PublicTxContext {
|
|
|
380
381
|
|
|
381
382
|
return new AvmCircuitPublicInputs(
|
|
382
383
|
this.globalVariables,
|
|
383
|
-
this.
|
|
384
|
+
this.protocolContracts,
|
|
384
385
|
this.startTreeSnapshots,
|
|
385
386
|
/*startGasUsed=*/ this.gasUsedByPrivate,
|
|
386
387
|
this.gasSettings,
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS, DEFAULT_MAX_DEBUG_LOG_MEMORY_READS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
5
|
-
ProtocolContractAddress,
|
|
6
|
-
ProtocolContractLeaves,
|
|
7
|
-
protocolContractNames,
|
|
8
|
-
protocolContractTreeRoot,
|
|
9
|
-
} from '@aztec/protocol-contracts';
|
|
4
|
+
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
10
5
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
11
6
|
import {
|
|
12
7
|
AvmCircuitInputs,
|
|
13
8
|
AvmCircuitPublicInputs,
|
|
14
9
|
AvmExecutionHints,
|
|
15
|
-
AvmProtocolContractAddressHint,
|
|
16
10
|
type AvmProvingRequest,
|
|
17
11
|
AvmTxHint,
|
|
18
12
|
type RevertCode,
|
|
19
13
|
} from '@aztec/stdlib/avm';
|
|
20
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
14
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
22
15
|
import type { Gas, GasUsed } from '@aztec/stdlib/gas';
|
|
23
16
|
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
@@ -139,21 +132,11 @@ export class PublicTxSimulator {
|
|
|
139
132
|
const txHash = this.computeTxHash(tx);
|
|
140
133
|
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, { txHash });
|
|
141
134
|
|
|
142
|
-
// These values are technically derivable from the contractsDB. However, since the trees are not persisted
|
|
143
|
-
// computing them for every tx would be time consuming for this TS simulator. So instead we just import them
|
|
144
|
-
const protocolContractHints = protocolContractNames.map(
|
|
145
|
-
name =>
|
|
146
|
-
new AvmProtocolContractAddressHint(
|
|
147
|
-
/*Canonical Address=*/ ProtocolContractAddress[name],
|
|
148
|
-
/*Derived Address=*/ AztecAddress.fromField(ProtocolContractLeaves[name]),
|
|
149
|
-
),
|
|
150
|
-
);
|
|
151
|
-
|
|
152
135
|
// Create hinting DBs.
|
|
153
136
|
const hints = new AvmExecutionHints(
|
|
154
137
|
this.globalVariables,
|
|
155
138
|
AvmTxHint.fromTx(tx, this.globalVariables.gasFees),
|
|
156
|
-
|
|
139
|
+
ProtocolContractsList, // imported from file
|
|
157
140
|
);
|
|
158
141
|
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
159
142
|
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
@@ -164,7 +147,7 @@ export class PublicTxSimulator {
|
|
|
164
147
|
hintingContractsDB,
|
|
165
148
|
tx,
|
|
166
149
|
this.globalVariables,
|
|
167
|
-
|
|
150
|
+
ProtocolContractsList, // imported from file
|
|
168
151
|
this.config.doMerkleOperations,
|
|
169
152
|
this.config.proverId,
|
|
170
153
|
);
|