@aztec/simulator 0.0.1-commit.a072138 → 0.0.1-commit.a5db02d
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/README.md +4 -4
- package/dest/client.d.ts +1 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +0 -2
- package/dest/private/acvm_wasm.d.ts +1 -1
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +3 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +36 -23
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +65 -69
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +7 -19
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +38 -42
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +11 -14
- package/dest/public/avm/avm_gas.js +3 -3
- package/dest/public/avm/avm_simulator.js +1 -1
- package/dest/public/avm/calldata.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts.map +1 -1
- package/dest/public/avm/calldata.js +3 -2
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +18 -3
- package/dest/public/avm/fixtures/utils.d.ts +1 -1
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +4 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +3 -4
- package/dest/public/avm/opcodes/contract.d.ts +3 -2
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +5 -1
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -4
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +13 -27
- package/dest/public/avm/serialization/bytecode_serialization.js +3 -3
- package/dest/public/avm/serialization/instruction_serialization.d.ts +2 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +1 -1
- package/dest/public/contracts_db_checkpoint.d.ts +2 -2
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/fixtures/amm_test.js +4 -4
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +33 -6
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +2 -2
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +8 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +91 -2
- package/dest/public/fixtures/opcode_spammer.d.ts +1 -1
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +8 -16
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +38 -9
- package/dest/public/fixtures/token_test.js +3 -3
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +21 -20
- package/dest/public/hinting_db_sources.d.ts +5 -5
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +8 -7
- package/dest/public/public_db_sources.d.ts +6 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +16 -10
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +5 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +5 -5
- package/dest/public/public_processor/public_processor.d.ts +8 -5
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +121 -67
- package/dest/public/public_processor/public_processor_metrics.d.ts +4 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +8 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +5 -4
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +2 -3
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +2 -2
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +7 -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 +8 -10
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +14 -9
- package/dest/public/state_manager/state_manager.js +1 -1
- package/dest/public/test_executor_metrics.d.ts +6 -1
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +22 -0
- package/package.json +16 -16
- package/src/client.ts +0 -2
- package/src/private/acvm_wasm.ts +4 -1
- package/src/private/circuit_recording/circuit_recorder.ts +84 -78
- package/src/private/circuit_recording/file_circuit_recorder.ts +38 -48
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +9 -15
- package/src/public/avm/avm_gas.ts +2 -2
- package/src/public/avm/avm_simulator.ts +1 -1
- package/src/public/avm/calldata.ts +3 -2
- package/src/public/avm/fixtures/account_proof.json +553 -0
- package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +23 -3
- package/src/public/avm/fixtures/utils.ts +4 -1
- package/src/public/avm/opcodes/accrued_substate.ts +3 -4
- package/src/public/avm/opcodes/contract.ts +5 -1
- package/src/public/avm/opcodes/ec_add.ts +12 -31
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
- package/src/public/avm/serialization/instruction_serialization.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +31 -6
- package/src/public/fixtures/custom_bytecode_tester.ts +2 -2
- package/src/public/fixtures/custom_bytecode_tests.ts +209 -2
- package/src/public/fixtures/opcode_spammer.ts +10 -18
- package/src/public/fixtures/public_tx_simulation_tester.ts +45 -5
- package/src/public/fixtures/token_test.ts +3 -3
- package/src/public/fixtures/utils.ts +23 -24
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +1 -1
- package/src/public/hinting_db_sources.ts +10 -7
- package/src/public/public_db_sources.ts +21 -14
- package/src/public/public_processor/guarded_merkle_tree.ts +6 -6
- package/src/public/public_processor/public_processor.ts +158 -88
- package/src/public/public_processor/public_processor_metrics.ts +12 -0
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +5 -4
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +2 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +2 -2
- package/src/public/public_tx_simulator/factories.ts +2 -1
- package/src/public/public_tx_simulator/public_tx_context.ts +8 -10
- package/src/public/public_tx_simulator/public_tx_simulator.ts +14 -10
- package/src/public/state_manager/state_manager.ts +1 -1
- package/src/public/test_executor_metrics.ts +24 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
2
|
+
|
|
1
3
|
import { strict as assert } from 'assert';
|
|
2
4
|
|
|
3
5
|
import { TypeTag } from '../avm/avm_memory_types.js';
|
|
4
6
|
import { Addressing, AddressingMode } from '../avm/opcodes/addressing_mode.js';
|
|
5
|
-
import { Add, CalldataCopy, Jump, Return, Set } from '../avm/opcodes/index.js';
|
|
7
|
+
import { Add, Call, CalldataCopy, Cast, Jump, Return, Set, Sha256Compression, Xor } from '../avm/opcodes/index.js';
|
|
6
8
|
import { encodeToBytecode } from '../avm/serialization/bytecode_serialization.js';
|
|
7
9
|
import {
|
|
8
10
|
MAX_OPCODE_VALUE,
|
|
@@ -10,7 +12,7 @@ import {
|
|
|
10
12
|
OperandType,
|
|
11
13
|
getOperandSize,
|
|
12
14
|
} from '../avm/serialization/instruction_serialization.js';
|
|
13
|
-
import { deployAndExecuteCustomBytecode } from './custom_bytecode_tester.js';
|
|
15
|
+
import { deployAndExecuteCustomBytecode, deployCustomBytecode } from './custom_bytecode_tester.js';
|
|
14
16
|
import { PublicTxSimulationTester } from './public_tx_simulation_tester.js';
|
|
15
17
|
|
|
16
18
|
// First instruction resolved a base address (offset 0) which is uninitialized and therefore
|
|
@@ -208,6 +210,144 @@ export async function invalidTagValueAndInstructionTruncatedTest(tester: PublicT
|
|
|
208
210
|
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
209
211
|
}
|
|
210
212
|
|
|
213
|
+
// Exercise SET truncation: set values whose widths exceed the target tag and
|
|
214
|
+
// rely on `buildFromTagTruncating` to truncate to the low bits of the tag.
|
|
215
|
+
// Covers sources larger than 128 bits (via SET_FF) and sources in (32, 128]
|
|
216
|
+
// bits (via SET_64) against destination tags U1/U8/U16/U32/U64/U128.
|
|
217
|
+
export async function setTruncationTest(tester: PublicTxSimulationTester) {
|
|
218
|
+
// 200-bit value: forces truncation for every target tag up to U128.
|
|
219
|
+
const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
|
|
220
|
+
// 40-bit value: forces truncation for target tags up to U32.
|
|
221
|
+
const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
|
|
222
|
+
|
|
223
|
+
const bytecode = encodeToBytecode([
|
|
224
|
+
// Zero U32 at offset 0 — used as the Return copy-size slot.
|
|
225
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
|
|
226
|
+
|
|
227
|
+
// Source >128 bits (via SET_FF) truncated to smaller target tags.
|
|
228
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT128, LARGE_FIELD_VALUE).as(
|
|
229
|
+
Opcode.SET_FF,
|
|
230
|
+
Set.wireFormatFF,
|
|
231
|
+
),
|
|
232
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, TypeTag.UINT64, LARGE_FIELD_VALUE).as(
|
|
233
|
+
Opcode.SET_FF,
|
|
234
|
+
Set.wireFormatFF,
|
|
235
|
+
),
|
|
236
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 3, TypeTag.UINT32, LARGE_FIELD_VALUE).as(
|
|
237
|
+
Opcode.SET_FF,
|
|
238
|
+
Set.wireFormatFF,
|
|
239
|
+
),
|
|
240
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 4, TypeTag.UINT16, LARGE_FIELD_VALUE).as(
|
|
241
|
+
Opcode.SET_FF,
|
|
242
|
+
Set.wireFormatFF,
|
|
243
|
+
),
|
|
244
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 5, TypeTag.UINT8, LARGE_FIELD_VALUE).as(
|
|
245
|
+
Opcode.SET_FF,
|
|
246
|
+
Set.wireFormatFF,
|
|
247
|
+
),
|
|
248
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 6, TypeTag.UINT1, LARGE_FIELD_VALUE).as(
|
|
249
|
+
Opcode.SET_FF,
|
|
250
|
+
Set.wireFormatFF,
|
|
251
|
+
),
|
|
252
|
+
|
|
253
|
+
// Source in (32, 128] bits (via SET_64) truncated to smaller target tags.
|
|
254
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 7, TypeTag.UINT32, LARGE_U64_VALUE).as(
|
|
255
|
+
Opcode.SET_64,
|
|
256
|
+
Set.wireFormat64,
|
|
257
|
+
),
|
|
258
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 8, TypeTag.UINT16, LARGE_U64_VALUE).as(
|
|
259
|
+
Opcode.SET_64,
|
|
260
|
+
Set.wireFormat64,
|
|
261
|
+
),
|
|
262
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 9, TypeTag.UINT8, LARGE_U64_VALUE).as(
|
|
263
|
+
Opcode.SET_64,
|
|
264
|
+
Set.wireFormat64,
|
|
265
|
+
),
|
|
266
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.UINT1, LARGE_U64_VALUE).as(
|
|
267
|
+
Opcode.SET_64,
|
|
268
|
+
Set.wireFormat64,
|
|
269
|
+
),
|
|
270
|
+
|
|
271
|
+
new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
const txLabel = 'SetTruncation';
|
|
275
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Exercise CAST truncation: store a wide source value in memory then CAST it
|
|
279
|
+
// to smaller destination tags. Covers sources larger than 128 bits (FIELD
|
|
280
|
+
// source) and sources in (32, 128] bits (UINT64 source) against destination
|
|
281
|
+
// tags U1/U8/U16/U32/U64/U128.
|
|
282
|
+
export async function castTruncationTest(tester: PublicTxSimulationTester) {
|
|
283
|
+
// 200-bit source: stored as FIELD so that CASTs to any integer tag truncate.
|
|
284
|
+
const LARGE_FIELD_VALUE = (1n << 200n) + 0x1234567890abcdef1234567890abcdefn;
|
|
285
|
+
// 40-bit source: stored as UINT64 so CASTs to U1/U8/U16/U32 truncate.
|
|
286
|
+
const LARGE_U64_VALUE = (1n << 40n) + 0xdeadbeefn;
|
|
287
|
+
|
|
288
|
+
const bytecode = encodeToBytecode([
|
|
289
|
+
// Zero U32 at offset 0 — used as the Return copy-size slot.
|
|
290
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
|
|
291
|
+
|
|
292
|
+
// Store wide FIELD source at offset 10, then CAST to smaller tags.
|
|
293
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10, TypeTag.FIELD, LARGE_FIELD_VALUE).as(
|
|
294
|
+
Opcode.SET_FF,
|
|
295
|
+
Set.wireFormatFF,
|
|
296
|
+
),
|
|
297
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 11, TypeTag.UINT128).as(
|
|
298
|
+
Opcode.CAST_8,
|
|
299
|
+
Cast.wireFormat8,
|
|
300
|
+
),
|
|
301
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 12, TypeTag.UINT64).as(
|
|
302
|
+
Opcode.CAST_8,
|
|
303
|
+
Cast.wireFormat8,
|
|
304
|
+
),
|
|
305
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 13, TypeTag.UINT32).as(
|
|
306
|
+
Opcode.CAST_8,
|
|
307
|
+
Cast.wireFormat8,
|
|
308
|
+
),
|
|
309
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 14, TypeTag.UINT16).as(
|
|
310
|
+
Opcode.CAST_8,
|
|
311
|
+
Cast.wireFormat8,
|
|
312
|
+
),
|
|
313
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 15, TypeTag.UINT8).as(
|
|
314
|
+
Opcode.CAST_8,
|
|
315
|
+
Cast.wireFormat8,
|
|
316
|
+
),
|
|
317
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 10, /*dstOffset=*/ 16, TypeTag.UINT1).as(
|
|
318
|
+
Opcode.CAST_8,
|
|
319
|
+
Cast.wireFormat8,
|
|
320
|
+
),
|
|
321
|
+
|
|
322
|
+
// Store UINT64 source at offset 20, then CAST to smaller integer tags.
|
|
323
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 20, TypeTag.UINT64, LARGE_U64_VALUE).as(
|
|
324
|
+
Opcode.SET_64,
|
|
325
|
+
Set.wireFormat64,
|
|
326
|
+
),
|
|
327
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 21, TypeTag.UINT32).as(
|
|
328
|
+
Opcode.CAST_8,
|
|
329
|
+
Cast.wireFormat8,
|
|
330
|
+
),
|
|
331
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 22, TypeTag.UINT16).as(
|
|
332
|
+
Opcode.CAST_8,
|
|
333
|
+
Cast.wireFormat8,
|
|
334
|
+
),
|
|
335
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 23, TypeTag.UINT8).as(
|
|
336
|
+
Opcode.CAST_8,
|
|
337
|
+
Cast.wireFormat8,
|
|
338
|
+
),
|
|
339
|
+
new Cast(/*addressing_mode=*/ 0, /*srcOffset=*/ 20, /*dstOffset=*/ 24, TypeTag.UINT1).as(
|
|
340
|
+
Opcode.CAST_8,
|
|
341
|
+
Cast.wireFormat8,
|
|
342
|
+
),
|
|
343
|
+
|
|
344
|
+
new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
345
|
+
]);
|
|
346
|
+
|
|
347
|
+
const txLabel = 'CastTruncation';
|
|
348
|
+
return await deployAndExecuteCustomBytecode(bytecode, tester, txLabel);
|
|
349
|
+
}
|
|
350
|
+
|
|
211
351
|
/**
|
|
212
352
|
* Returns the offset of the tag in an instruction.
|
|
213
353
|
* @details Loops over the wire format operand type entries until it finds the tag.
|
|
@@ -226,3 +366,70 @@ function getTagOffsetInInstruction(wireFormat: OperandType[]): number {
|
|
|
226
366
|
}
|
|
227
367
|
return offset;
|
|
228
368
|
}
|
|
369
|
+
|
|
370
|
+
export async function deployBitwiseSha256ErrorRowCollisionContracts(
|
|
371
|
+
tester: PublicTxSimulationTester,
|
|
372
|
+
): Promise<{ innerContract: ContractInstanceWithAddress; outerContract: ContractInstanceWithAddress }> {
|
|
373
|
+
const innerBytecode = encodeToBytecode([
|
|
374
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
|
|
375
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT16, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
|
|
376
|
+
new Xor(/*addressing_mode=*/ 0, /*aOffset=*/ 0, /*bOffset=*/ 1, /*dstOffset=*/ 2).as(Opcode.XOR_8, Xor.wireFormat8),
|
|
377
|
+
new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
378
|
+
]);
|
|
379
|
+
|
|
380
|
+
const outerInstructions = [
|
|
381
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 0, TypeTag.UINT32, /*value=*/ 0).as(Opcode.SET_8, Set.wireFormat8),
|
|
382
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 1, TypeTag.UINT32, /*value=*/ 1).as(Opcode.SET_8, Set.wireFormat8),
|
|
383
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 2, TypeTag.UINT32, /*value=*/ 100_000).as(
|
|
384
|
+
Opcode.SET_32,
|
|
385
|
+
Set.wireFormat32,
|
|
386
|
+
),
|
|
387
|
+
new CalldataCopy(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 1, /*cdStartOffset=*/ 0, /*dstOffset=*/ 3),
|
|
388
|
+
new Call(
|
|
389
|
+
/*addressing_mode=*/ 0,
|
|
390
|
+
/*l2GasOffset=*/ 2,
|
|
391
|
+
/*daGasOffset=*/ 2,
|
|
392
|
+
/*addrOffset=*/ 3,
|
|
393
|
+
/*argsSizeOffset=*/ 0,
|
|
394
|
+
/*argsOffset=*/ 0,
|
|
395
|
+
),
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
for (let i = 0; i < 8; i++) {
|
|
399
|
+
outerInstructions.push(
|
|
400
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 10 + i, TypeTag.UINT32, /*value=*/ 0).as(
|
|
401
|
+
Opcode.SET_8,
|
|
402
|
+
Set.wireFormat8,
|
|
403
|
+
),
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
outerInstructions.push(
|
|
408
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 18, TypeTag.UINT32, /*value=*/ 0x61626364).as(
|
|
409
|
+
Opcode.SET_32,
|
|
410
|
+
Set.wireFormat32,
|
|
411
|
+
),
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
for (let i = 0; i < 15; i++) {
|
|
415
|
+
outerInstructions.push(
|
|
416
|
+
new Set(/*addressing_mode=*/ 0, /*dstOffset=*/ 19 + i, TypeTag.UINT32, /*value=*/ 0).as(
|
|
417
|
+
Opcode.SET_8,
|
|
418
|
+
Set.wireFormat8,
|
|
419
|
+
),
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
outerInstructions.push(
|
|
424
|
+
new Sha256Compression(/*addressing_mode=*/ 0, /*outputOffset=*/ 34, /*stateOffset=*/ 10, /*inputsOffset=*/ 18),
|
|
425
|
+
new Return(/*addressing_mode=*/ 0, /*copySizeOffset=*/ 0, /*returnOffset=*/ 0),
|
|
426
|
+
);
|
|
427
|
+
|
|
428
|
+
const innerContract = await deployCustomBytecode(innerBytecode, tester, 'BitwiseSha256CollisionInner');
|
|
429
|
+
const outerContract = await deployCustomBytecode(
|
|
430
|
+
encodeToBytecode(outerInstructions),
|
|
431
|
+
tester,
|
|
432
|
+
'BitwiseSha256CollisionOuter',
|
|
433
|
+
);
|
|
434
|
+
return { innerContract, outerContract };
|
|
435
|
+
}
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
* - `EMITNOTEHASH`: max 64 per TX
|
|
144
144
|
* - `EMITNULLIFIER`: max 63 per TX (one reserved for TX nullifier)
|
|
145
145
|
* - `SENDL2TOL1MSG`: max 8 per TX
|
|
146
|
-
* - `
|
|
146
|
+
* - `EMITPUBLICLOG`: limited by total log payload size
|
|
147
147
|
*
|
|
148
148
|
* By having the inner contract REVERT after emitting side effects, those effects are discarded, allowing the outer contract to call it again. This enables thousands of opcode executions per TX instead of just the limit.
|
|
149
149
|
*
|
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
EcAdd,
|
|
183
183
|
EmitNoteHash,
|
|
184
184
|
EmitNullifier,
|
|
185
|
-
|
|
185
|
+
EmitPublicLog,
|
|
186
186
|
Eq,
|
|
187
187
|
FieldDiv,
|
|
188
188
|
GetContractInstance,
|
|
@@ -1242,17 +1242,15 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
|
|
|
1242
1242
|
},
|
|
1243
1243
|
],
|
|
1244
1244
|
|
|
1245
|
-
//
|
|
1246
|
-
[Opcode.
|
|
1245
|
+
// EMITPUBLICLOG - two configs: minimal (many small logs) and max-size (one large log)
|
|
1246
|
+
[Opcode.EMITPUBLICLOG]: [
|
|
1247
1247
|
{
|
|
1248
1248
|
label: 'Many empty logs, revert, repeat',
|
|
1249
1249
|
setup: [
|
|
1250
1250
|
{ offset: 0, value: new Uint32(0n) }, // logSize = 0 fields (minimal)
|
|
1251
1251
|
{ offset: 1, value: new Uint32(0n) }, // revertSize
|
|
1252
1252
|
],
|
|
1253
|
-
targetInstructions: () => [
|
|
1254
|
-
new EmitUnencryptedLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 1),
|
|
1255
|
-
], // logOffset doesn't matter when size is 0
|
|
1253
|
+
targetInstructions: () => [new EmitPublicLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 1)], // logOffset doesn't matter when size is 0
|
|
1256
1254
|
cleanupInstructions: () => [
|
|
1257
1255
|
new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 1, /*returnOffset=*/ 0).as(
|
|
1258
1256
|
Opcode.REVERT_8,
|
|
@@ -1276,9 +1274,7 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
|
|
|
1276
1274
|
// value: new Field(0n),
|
|
1277
1275
|
//})),
|
|
1278
1276
|
],
|
|
1279
|
-
targetInstructions: () => [
|
|
1280
|
-
new EmitUnencryptedLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 2),
|
|
1281
|
-
], // uses logOffset 2 (uninitialized Field(0))
|
|
1277
|
+
targetInstructions: () => [new EmitPublicLog(/*addressing_mode=*/ 0, /*logSizeOffset=*/ 0, /*logOffset=*/ 2)], // uses logOffset 2 (uninitialized Field(0))
|
|
1282
1278
|
cleanupInstructions: () => [
|
|
1283
1279
|
new Revert(/*addressing_mode=*/ 0, /*retSizeOffset=*/ 1, /*returnOffset=*/ 0).as(
|
|
1284
1280
|
Opcode.REVERT_8,
|
|
@@ -1343,20 +1339,16 @@ export const SPAM_CONFIGS: Partial<Record<Opcode, SpamConfig[]>> = {
|
|
|
1343
1339
|
setup: [
|
|
1344
1340
|
{ offset: 0, value: new Field(Grumpkin.generator.x) }, // p1X = G.x
|
|
1345
1341
|
{ offset: 1, value: new Field(Grumpkin.generator.y) }, // p1Y = G.y
|
|
1346
|
-
{ offset: 2, value: new
|
|
1347
|
-
{ offset: 3, value: new Field(Grumpkin.generator.
|
|
1348
|
-
{ offset: 4, value: new Field(Grumpkin.generator.y) }, // p2Y = G.y
|
|
1349
|
-
{ offset: 5, value: new Uint1(0n) }, // p2IsInfinite = false
|
|
1342
|
+
{ offset: 2, value: new Field(Grumpkin.generator.x) }, // p2X = G.x
|
|
1343
|
+
{ offset: 3, value: new Field(Grumpkin.generator.y) }, // p2Y = G.y
|
|
1350
1344
|
],
|
|
1351
1345
|
targetInstructions: () => [
|
|
1352
1346
|
new EcAdd(
|
|
1353
1347
|
/*addressing_mode=*/ 0,
|
|
1354
1348
|
/*p1XOffset=*/ 0,
|
|
1355
1349
|
/*p1YOffset=*/ 1,
|
|
1356
|
-
/*
|
|
1357
|
-
/*
|
|
1358
|
-
/*p2YOffset=*/ 4,
|
|
1359
|
-
/*p2IsInfiniteOffset=*/ 5,
|
|
1350
|
+
/*p2XOffset=*/ 2,
|
|
1351
|
+
/*p2YOffset=*/ 3,
|
|
1360
1352
|
/*dstOffset=*/ 0,
|
|
1361
1353
|
),
|
|
1362
1354
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PUBLIC_TX_L2_GAS_OVERHEAD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
|
|
2
2
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
3
3
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -27,6 +27,8 @@ import { SimpleContractDataSource } from './simple_contract_data_source.js';
|
|
|
27
27
|
import { type TestPrivateInsertions, createTxForPublicCalls } from './utils.js';
|
|
28
28
|
|
|
29
29
|
const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
30
|
+
const TEARDOWN_DA_GAS_LIMIT = 98_304;
|
|
31
|
+
const TEARDOWN_L2_GAS_LIMIT = 817_500;
|
|
30
32
|
|
|
31
33
|
export type TestEnqueuedCall = {
|
|
32
34
|
sender?: AztecAddress;
|
|
@@ -112,6 +114,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
112
114
|
feePayer: AztecAddress = sender,
|
|
113
115
|
/* need some unique first nullifier for note-nonce computations */
|
|
114
116
|
privateInsertions: TestPrivateInsertions = { nonRevertible: { nullifiers: [new Fr(420000 + this.txCount)] } },
|
|
117
|
+
gasLimits?: Gas,
|
|
115
118
|
): Promise<Tx> {
|
|
116
119
|
const setupCallRequests = await asyncMap(setupCalls, call =>
|
|
117
120
|
this.#createPubicCallRequestForCall(call, call.sender ?? sender),
|
|
@@ -131,9 +134,10 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
131
134
|
teardownCallRequest,
|
|
132
135
|
feePayer,
|
|
133
136
|
/*gasUsedByPrivate*/ teardownCall
|
|
134
|
-
? new Gas(
|
|
135
|
-
: Gas
|
|
137
|
+
? new Gas(TEARDOWN_DA_GAS_LIMIT + TX_DA_GAS_OVERHEAD, TEARDOWN_L2_GAS_LIMIT + PUBLIC_TX_L2_GAS_OVERHEAD)
|
|
138
|
+
: new Gas(TX_DA_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD),
|
|
136
139
|
defaultGlobals(),
|
|
140
|
+
gasLimits,
|
|
137
141
|
);
|
|
138
142
|
}
|
|
139
143
|
|
|
@@ -146,8 +150,9 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
146
150
|
/* need some unique first nullifier for note-nonce computations */
|
|
147
151
|
privateInsertions?: TestPrivateInsertions,
|
|
148
152
|
txLabel: string = 'unlabeledTx',
|
|
153
|
+
gasLimits?: Gas,
|
|
149
154
|
): Promise<PublicTxResult> {
|
|
150
|
-
const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions);
|
|
155
|
+
const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions, gasLimits);
|
|
151
156
|
|
|
152
157
|
await this.setFeePayerBalance(feePayer);
|
|
153
158
|
|
|
@@ -161,6 +166,8 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
161
166
|
}
|
|
162
167
|
const avmResult = await this.simulator.simulate(tx, fullTxLabel);
|
|
163
168
|
|
|
169
|
+
await this.#recordBytecodeSizes(fullTxLabel, [...setupCalls, ...appCalls, ...(teardownCall ? [teardownCall] : [])]);
|
|
170
|
+
|
|
164
171
|
// Something like this is often useful for debugging:
|
|
165
172
|
//if (avmResult.revertReason) {
|
|
166
173
|
// // resolve / enrich revert reason
|
|
@@ -190,8 +197,18 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
190
197
|
teardownCall?: TestEnqueuedCall,
|
|
191
198
|
feePayer?: AztecAddress,
|
|
192
199
|
privateInsertions?: TestPrivateInsertions,
|
|
200
|
+
gasLimits?: Gas,
|
|
193
201
|
): Promise<PublicTxResult> {
|
|
194
|
-
return await this.simulateTx(
|
|
202
|
+
return await this.simulateTx(
|
|
203
|
+
sender,
|
|
204
|
+
setupCalls,
|
|
205
|
+
appCalls,
|
|
206
|
+
teardownCall,
|
|
207
|
+
feePayer,
|
|
208
|
+
privateInsertions,
|
|
209
|
+
txLabel,
|
|
210
|
+
gasLimits,
|
|
211
|
+
);
|
|
195
212
|
}
|
|
196
213
|
|
|
197
214
|
/**
|
|
@@ -209,6 +226,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
209
226
|
teardownCall?: TestEnqueuedCall,
|
|
210
227
|
feePayer?: AztecAddress,
|
|
211
228
|
privateInsertions?: TestPrivateInsertions,
|
|
229
|
+
gasLimits?: Gas,
|
|
212
230
|
): Promise<PublicTxResult> {
|
|
213
231
|
return await this.simulateTxWithLabel(
|
|
214
232
|
txLabel,
|
|
@@ -218,6 +236,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
218
236
|
teardownCall,
|
|
219
237
|
feePayer,
|
|
220
238
|
privateInsertions,
|
|
239
|
+
gasLimits,
|
|
221
240
|
);
|
|
222
241
|
}
|
|
223
242
|
|
|
@@ -277,6 +296,27 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
277
296
|
|
|
278
297
|
return new PublicCallRequestWithCalldata(request, calldata);
|
|
279
298
|
}
|
|
299
|
+
|
|
300
|
+
// WARNING: Deduplicates by artifact name, so two different artifacts with the same name
|
|
301
|
+
// in a single tx would only record the first one's bytecode size.
|
|
302
|
+
async #recordBytecodeSizes(txLabel: string, calls: TestEnqueuedCall[]) {
|
|
303
|
+
const seenArtifactNames = new Set<string>();
|
|
304
|
+
for (const call of calls) {
|
|
305
|
+
const artifact = await this.contractDataSource.getContractArtifact(call.address);
|
|
306
|
+
if (!artifact || seenArtifactNames.has(artifact.name)) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
seenArtifactNames.add(artifact.name);
|
|
310
|
+
const instance = await this.contractDataSource.getContract(call.address);
|
|
311
|
+
if (!instance) {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const contractClass = await this.contractDataSource.getContractClass(instance.currentContractClassId);
|
|
315
|
+
if (contractClass) {
|
|
316
|
+
this.metrics.recordBytecodeSize(txLabel, artifact.name, contractClass.packedBytecode.length);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
280
320
|
}
|
|
281
321
|
|
|
282
322
|
export function defaultGlobals() {
|
|
@@ -21,9 +21,9 @@ export async function tokenTest(
|
|
|
21
21
|
) {
|
|
22
22
|
const timer = new Timer();
|
|
23
23
|
|
|
24
|
-
const admin = AztecAddress.
|
|
25
|
-
const sender = AztecAddress.
|
|
26
|
-
const receiver = AztecAddress.
|
|
24
|
+
const admin = AztecAddress.fromNumberUnsafe(42);
|
|
25
|
+
const sender = AztecAddress.fromNumberUnsafe(111);
|
|
26
|
+
const receiver = AztecAddress.fromNumberUnsafe(222);
|
|
27
27
|
|
|
28
28
|
const token = await setUpToken(tester, tokenArtifact, admin, expectToBeTrue);
|
|
29
29
|
|
|
@@ -2,10 +2,8 @@ import {
|
|
|
2
2
|
CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE,
|
|
3
3
|
CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
|
|
4
4
|
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
8
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
5
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
6
|
+
MAX_PROCESSABLE_L2_GAS,
|
|
9
7
|
PRIVATE_LOG_SIZE_IN_FIELDS,
|
|
10
8
|
} from '@aztec/constants';
|
|
11
9
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
@@ -38,6 +36,9 @@ import {
|
|
|
38
36
|
|
|
39
37
|
import { strict as assert } from 'assert';
|
|
40
38
|
|
|
39
|
+
const TEARDOWN_DA_GAS_LIMIT = 98_304;
|
|
40
|
+
const TEARDOWN_L2_GAS_LIMIT = 817_500;
|
|
41
|
+
|
|
41
42
|
export type TestPrivateInsertions = {
|
|
42
43
|
revertible?: {
|
|
43
44
|
nullifiers?: Fr[];
|
|
@@ -62,13 +63,14 @@ export async function createTxForPublicCalls(
|
|
|
62
63
|
feePayer = AztecAddress.zero(),
|
|
63
64
|
gasUsedByPrivate: Gas = Gas.empty(),
|
|
64
65
|
globals: GlobalVariables = GlobalVariables.empty(),
|
|
66
|
+
gasLimits?: Gas,
|
|
65
67
|
): Promise<Tx> {
|
|
66
68
|
assert(
|
|
67
69
|
setupCallRequests.length > 0 || appCallRequests.length > 0 || teardownCallRequest !== undefined,
|
|
68
70
|
"Can't create public tx with no enqueued calls",
|
|
69
71
|
);
|
|
70
72
|
// use max limits
|
|
71
|
-
|
|
73
|
+
gasLimits = gasLimits ?? new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
72
74
|
|
|
73
75
|
const forPublic = PartialPrivateTailPublicInputsForPublic.empty();
|
|
74
76
|
|
|
@@ -127,20 +129,18 @@ export async function createTxForPublicCalls(
|
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
const maxFeesPerGas = feePayer.isZero() ? GasFees.empty() : new GasFees(10, 10);
|
|
130
|
-
const teardownGasLimits = teardownCallRequest
|
|
131
|
-
? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT)
|
|
132
|
-
: Gas.empty();
|
|
132
|
+
const teardownGasLimits = teardownCallRequest ? new Gas(TEARDOWN_DA_GAS_LIMIT, TEARDOWN_L2_GAS_LIMIT) : Gas.empty();
|
|
133
133
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, maxFeesPerGas, GasFees.empty());
|
|
134
134
|
const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
|
|
135
135
|
const header = BlockHeader.empty({ globalVariables: globals });
|
|
136
136
|
const constantData = new TxConstantData(header, txContext, Fr.zero(), Fr.zero());
|
|
137
|
-
const
|
|
137
|
+
const expirationTimestamp = 0n; // Not used in the simulator.
|
|
138
138
|
|
|
139
139
|
const txData = new PrivateKernelTailCircuitPublicInputs(
|
|
140
140
|
constantData,
|
|
141
141
|
/*gasUsed=*/ gasUsedByPrivate,
|
|
142
142
|
feePayer,
|
|
143
|
-
|
|
143
|
+
expirationTimestamp,
|
|
144
144
|
forPublic,
|
|
145
145
|
);
|
|
146
146
|
|
|
@@ -163,7 +163,7 @@ export async function createTxForPrivateOnly(
|
|
|
163
163
|
gasUsedByPrivate: Gas = new Gas(10, 10),
|
|
164
164
|
): Promise<Tx> {
|
|
165
165
|
// use max limits
|
|
166
|
-
const gasLimits = new Gas(
|
|
166
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
167
167
|
|
|
168
168
|
const forRollup = PartialPrivateTailPublicInputsForRollup.empty();
|
|
169
169
|
|
|
@@ -171,13 +171,13 @@ export async function createTxForPrivateOnly(
|
|
|
171
171
|
const gasSettings = new GasSettings(gasLimits, Gas.empty(), maxFeesPerGas, GasFees.empty());
|
|
172
172
|
const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
|
|
173
173
|
const constantData = new TxConstantData(BlockHeader.empty(), txContext, Fr.zero(), Fr.zero());
|
|
174
|
-
const
|
|
174
|
+
const expirationTimestamp = 0n; // Not used in the simulator.
|
|
175
175
|
|
|
176
176
|
const txData = new PrivateKernelTailCircuitPublicInputs(
|
|
177
177
|
constantData,
|
|
178
178
|
/*gasUsed=*/ gasUsedByPrivate,
|
|
179
179
|
feePayer,
|
|
180
|
-
|
|
180
|
+
expirationTimestamp,
|
|
181
181
|
/*forPublic=*/ undefined,
|
|
182
182
|
forRollup,
|
|
183
183
|
);
|
|
@@ -228,17 +228,15 @@ export async function addNewContractInstanceToTx(
|
|
|
228
228
|
contractInstance: ContractInstanceWithAddress,
|
|
229
229
|
skipNullifierInsertion = false,
|
|
230
230
|
) {
|
|
231
|
-
//
|
|
232
|
-
// is not broadcast in such private logs
|
|
231
|
+
// Only ivpk_m is broadcast as a point (x, y); the other five keys are hashes.
|
|
233
232
|
const publicKeysAsFields = [
|
|
234
|
-
contractInstance.publicKeys.
|
|
235
|
-
contractInstance.publicKeys.
|
|
236
|
-
contractInstance.publicKeys.
|
|
237
|
-
contractInstance.publicKeys.
|
|
238
|
-
contractInstance.publicKeys.
|
|
239
|
-
contractInstance.publicKeys.
|
|
240
|
-
contractInstance.publicKeys.
|
|
241
|
-
contractInstance.publicKeys.masterTaggingPublicKey.y,
|
|
233
|
+
contractInstance.publicKeys.npkMHash,
|
|
234
|
+
contractInstance.publicKeys.ivpkM.x,
|
|
235
|
+
contractInstance.publicKeys.ivpkM.y,
|
|
236
|
+
contractInstance.publicKeys.ovpkMHash,
|
|
237
|
+
contractInstance.publicKeys.tpkMHash,
|
|
238
|
+
contractInstance.publicKeys.mspkMHash,
|
|
239
|
+
contractInstance.publicKeys.fbpkMHash,
|
|
242
240
|
];
|
|
243
241
|
const logFields = [
|
|
244
242
|
CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG,
|
|
@@ -247,6 +245,7 @@ export async function addNewContractInstanceToTx(
|
|
|
247
245
|
new Fr(contractInstance.salt),
|
|
248
246
|
contractInstance.currentContractClassId,
|
|
249
247
|
contractInstance.initializationHash,
|
|
248
|
+
contractInstance.immutablesHash,
|
|
250
249
|
...publicKeysAsFields,
|
|
251
250
|
contractInstance.deployer.toField(),
|
|
252
251
|
];
|
|
@@ -256,7 +255,7 @@ export async function addNewContractInstanceToTx(
|
|
|
256
255
|
);
|
|
257
256
|
|
|
258
257
|
const contractAddressNullifier = await siloNullifier(
|
|
259
|
-
AztecAddress.
|
|
258
|
+
AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
|
|
260
259
|
contractInstance.address.toField(),
|
|
261
260
|
);
|
|
262
261
|
|
|
@@ -146,7 +146,7 @@ async function createTxFromHint(cppTx: AvmTxHint): Promise<Tx> {
|
|
|
146
146
|
constants,
|
|
147
147
|
cppTx.gasUsedByPrivate,
|
|
148
148
|
cppTx.feePayer,
|
|
149
|
-
0n, //
|
|
149
|
+
0n, // expirationTimestamp
|
|
150
150
|
forPublic,
|
|
151
151
|
undefined, // forRollup - not needed for public simulation
|
|
152
152
|
);
|
|
@@ -83,6 +83,7 @@ export class HintingPublicContractsDB implements PublicContractsDBInterface {
|
|
|
83
83
|
instance.currentContractClassId,
|
|
84
84
|
instance.originalContractClassId,
|
|
85
85
|
instance.initializationHash,
|
|
86
|
+
instance.immutablesHash,
|
|
86
87
|
instance.publicKeys,
|
|
87
88
|
),
|
|
88
89
|
);
|
|
@@ -410,12 +411,12 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
410
411
|
}
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
public async createCheckpoint(): Promise<
|
|
414
|
+
public async createCheckpoint(): Promise<number> {
|
|
414
415
|
const actionCounter = this.checkpointActionCounter++;
|
|
415
416
|
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
416
417
|
const treesStateHash = await this.getTreesStateHash();
|
|
417
418
|
|
|
418
|
-
await this.db.createCheckpoint();
|
|
419
|
+
const depth = await this.db.createCheckpoint();
|
|
419
420
|
this.checkpointStack.push(this.nextCheckpointId++);
|
|
420
421
|
const newCheckpointId = this.getCurrentCheckpointId();
|
|
421
422
|
|
|
@@ -424,14 +425,16 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
424
425
|
HintingMerkleWriteOperations.log.trace(
|
|
425
426
|
`[createCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`,
|
|
426
427
|
);
|
|
428
|
+
|
|
429
|
+
return depth;
|
|
427
430
|
}
|
|
428
431
|
|
|
429
|
-
public
|
|
430
|
-
throw new Error('
|
|
432
|
+
public commitAllCheckpointsTo(_depth: number): Promise<void> {
|
|
433
|
+
throw new Error('commitAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
431
434
|
}
|
|
432
435
|
|
|
433
|
-
public
|
|
434
|
-
throw new Error('
|
|
436
|
+
public revertAllCheckpointsTo(_depth: number): Promise<void> {
|
|
437
|
+
throw new Error('revertAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
435
438
|
}
|
|
436
439
|
|
|
437
440
|
public async commitCheckpoint(): Promise<void> {
|
|
@@ -572,7 +575,7 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
572
575
|
return await this.db.close();
|
|
573
576
|
}
|
|
574
577
|
|
|
575
|
-
async [Symbol.
|
|
578
|
+
async [Symbol.asyncDispose](): Promise<void> {
|
|
576
579
|
await this.close();
|
|
577
580
|
}
|
|
578
581
|
|