@aztec/pxe 2.1.0-rc.9 → 3.0.0-devnet.2
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 +5 -5
- package/dest/bin/check_oracle_version.js +18 -8
- package/dest/config/index.d.ts +8 -8
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +3 -3
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +82 -26
- package/dest/contract_function_simulator/execution_data_provider.d.ts +27 -38
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +7 -4
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/index.d.ts +3 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +7 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -11
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +79 -76
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +6 -15
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +69 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +10 -22
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +33 -38
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +19 -55
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +174 -187
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +8 -8
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +8 -8
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +7 -7
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +7 -7
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.d.ts +4 -23
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +4 -25
- package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +23 -18
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
- package/dest/pxe.d.ts +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +215 -217
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +1 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -3
- package/dest/storage/index.d.ts +0 -1
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +1 -1
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +70 -7
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +120 -72
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +1 -3
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -3
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -3
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +2 -3
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +18 -21
- package/src/bin/check_oracle_version.ts +23 -9
- package/src/config/index.ts +11 -10
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +128 -44
- package/src/contract_function_simulator/execution_data_provider.ts +29 -47
- package/src/contract_function_simulator/execution_note_cache.ts +11 -6
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/index.ts +3 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -3
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
- package/src/contract_function_simulator/oracle/oracle.ts +102 -77
- package/src/contract_function_simulator/oracle/private_execution.ts +7 -15
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +106 -45
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +51 -76
- package/src/contract_function_simulator/pxe_oracle_interface.ts +199 -218
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +11 -19
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +10 -18
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +9 -39
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +35 -23
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +230 -261
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -11
- package/src/storage/contract_data_provider/contract_data_provider.ts +3 -9
- package/src/storage/index.ts +0 -1
- package/src/storage/note_data_provider/note_dao.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +142 -99
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +1 -7
- package/src/storage/sync_data_provider/sync_data_provider.ts +1 -7
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
- package/src/synchronizer/synchronizer.ts +2 -3
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -48
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
- package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
- package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
- package/dest/contract_function_simulator/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -101
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -62
- package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
- package/src/contract_function_simulator/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/storage/data_provider.ts +0 -3
- package/src/test/pxe_test_suite.ts +0 -113
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AVM_EMITNOTEHASH_BASE_L2_GAS,
|
|
3
|
+
AVM_EMITNULLIFIER_BASE_L2_GAS,
|
|
4
|
+
AVM_SENDL2TOL1MSG_BASE_L2_GAS,
|
|
5
|
+
DA_BYTES_PER_FIELD,
|
|
6
|
+
DA_GAS_PER_BYTE,
|
|
7
|
+
FIXED_AVM_STARTUP_L2_GAS,
|
|
8
|
+
FIXED_DA_GAS,
|
|
9
|
+
FIXED_L2_GAS,
|
|
10
|
+
L2_GAS_PER_CONTRACT_CLASS_LOG,
|
|
11
|
+
L2_GAS_PER_PRIVATE_LOG,
|
|
2
12
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
3
13
|
MAX_ENQUEUED_CALLS_PER_TX,
|
|
4
14
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
@@ -6,13 +16,13 @@ import {
|
|
|
6
16
|
MAX_NULLIFIERS_PER_TX,
|
|
7
17
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
8
18
|
} from '@aztec/constants';
|
|
9
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
19
|
+
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
10
20
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
11
21
|
import { Fr } from '@aztec/foundation/fields';
|
|
12
22
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
13
23
|
import { Timer } from '@aztec/foundation/timer';
|
|
14
24
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
15
|
-
import {
|
|
25
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
16
26
|
import {
|
|
17
27
|
type CircuitSimulator,
|
|
18
28
|
ExecutionError,
|
|
@@ -49,11 +59,13 @@ import {
|
|
|
49
59
|
TxConstantData,
|
|
50
60
|
TxExecutionRequest,
|
|
51
61
|
collectNested,
|
|
62
|
+
getFinalMinRevertibleSideEffectCounter,
|
|
52
63
|
} from '@aztec/stdlib/tx';
|
|
53
64
|
|
|
54
65
|
import type { ContractDataProvider } from '../storage/index.js';
|
|
55
66
|
import type { ExecutionDataProvider } from './execution_data_provider.js';
|
|
56
67
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
68
|
+
import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
57
69
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
58
70
|
import { Oracle } from './oracle/oracle.js';
|
|
59
71
|
import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
|
|
@@ -94,7 +106,7 @@ export class ContractFunctionSimulator {
|
|
|
94
106
|
scopes?: AztecAddress[],
|
|
95
107
|
): Promise<PrivateExecutionResult> {
|
|
96
108
|
const simulatorSetupTimer = new Timer();
|
|
97
|
-
const
|
|
109
|
+
const anchorBlockHeader = await this.executionDataProvider.getAnchorBlockHeader();
|
|
98
110
|
|
|
99
111
|
await verifyCurrentClassId(contractAddress, this.executionDataProvider);
|
|
100
112
|
|
|
@@ -122,23 +134,25 @@ export class ContractFunctionSimulator {
|
|
|
122
134
|
|
|
123
135
|
const txRequestHash = await request.toTxRequest().hash();
|
|
124
136
|
const noteCache = new ExecutionNoteCache(txRequestHash);
|
|
137
|
+
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
125
138
|
|
|
126
139
|
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
127
140
|
request.firstCallArgsHash,
|
|
128
141
|
request.txContext,
|
|
129
142
|
callContext,
|
|
130
|
-
|
|
143
|
+
anchorBlockHeader,
|
|
131
144
|
request.authWitnesses,
|
|
132
145
|
request.capsules,
|
|
133
146
|
HashedValuesCache.create(request.argsOfCalls),
|
|
134
147
|
noteCache,
|
|
148
|
+
taggingIndexCache,
|
|
135
149
|
this.executionDataProvider,
|
|
136
|
-
this.simulator,
|
|
137
150
|
0, // totalPublicArgsCount
|
|
138
151
|
startSideEffectCounter,
|
|
139
152
|
undefined, // log
|
|
140
153
|
scopes,
|
|
141
154
|
senderForTags,
|
|
155
|
+
this.simulator,
|
|
142
156
|
);
|
|
143
157
|
|
|
144
158
|
const setupTime = simulatorSetupTimer.ms();
|
|
@@ -358,30 +372,35 @@ export async function generateSimulatedProvingResult(
|
|
|
358
372
|
}
|
|
359
373
|
|
|
360
374
|
const constantData = new TxConstantData(
|
|
361
|
-
privateExecutionResult.entrypoint.publicInputs.
|
|
375
|
+
privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader,
|
|
362
376
|
privateExecutionResult.entrypoint.publicInputs.txContext,
|
|
363
377
|
getVKTreeRoot(),
|
|
364
|
-
|
|
378
|
+
protocolContractsHash,
|
|
365
379
|
);
|
|
366
380
|
|
|
367
381
|
const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
|
|
368
382
|
let inputsForRollup;
|
|
369
383
|
let inputsForPublic;
|
|
384
|
+
let gasUsed;
|
|
370
385
|
|
|
371
386
|
const sortByCounter = <T>(a: OrderedSideEffect<T>, b: OrderedSideEffect<T>) => a.counter - b.counter;
|
|
372
387
|
const getEffect = <T>(orderedSideEffect: OrderedSideEffect<T>) => orderedSideEffect.sideEffect;
|
|
373
388
|
|
|
374
|
-
const
|
|
389
|
+
const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
|
|
390
|
+
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
|
|
375
391
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
392
|
+
const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(
|
|
393
|
+
nullifiers.sort(sortByCounter),
|
|
394
|
+
minRevertibleSideEffectCounter,
|
|
395
|
+
);
|
|
396
|
+
if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
|
|
397
|
+
throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
|
|
398
|
+
} else {
|
|
399
|
+
nonRevertibleNullifiers.unshift(nonceGenerator);
|
|
380
400
|
}
|
|
381
401
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
// In case the tx only contains private functions, we must make the note hashes unique by using the
|
|
402
|
+
if (isPrivateOnlyTx) {
|
|
403
|
+
// We must make the note hashes unique by using the
|
|
385
404
|
// nonce generator and their index in the tx.
|
|
386
405
|
const uniqueNoteHashes = await Promise.all(
|
|
387
406
|
siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i) => {
|
|
@@ -393,7 +412,7 @@ export async function generateSimulatedProvingResult(
|
|
|
393
412
|
);
|
|
394
413
|
const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(
|
|
395
414
|
padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
396
|
-
padArrayEnd(
|
|
415
|
+
padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX),
|
|
397
416
|
padArrayEnd(
|
|
398
417
|
l2ToL1Messages.sort(sortByCounter).map(getEffect),
|
|
399
418
|
ScopedL2ToL1Message.empty(),
|
|
@@ -406,39 +425,51 @@ export async function generateSimulatedProvingResult(
|
|
|
406
425
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
407
426
|
),
|
|
408
427
|
);
|
|
409
|
-
|
|
428
|
+
gasUsed = meterGasUsed(accumulatedDataForRollup);
|
|
410
429
|
inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
|
|
411
430
|
} else {
|
|
412
|
-
const
|
|
431
|
+
const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(
|
|
432
|
+
siloedNoteHashes.sort(sortByCounter),
|
|
433
|
+
minRevertibleSideEffectCounter,
|
|
434
|
+
);
|
|
435
|
+
const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(
|
|
436
|
+
l2ToL1Messages.sort(sortByCounter),
|
|
437
|
+
minRevertibleSideEffectCounter,
|
|
438
|
+
);
|
|
439
|
+
const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
|
|
440
|
+
taggedPrivateLogs,
|
|
441
|
+
minRevertibleSideEffectCounter,
|
|
442
|
+
);
|
|
443
|
+
const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(
|
|
444
|
+
contractClassLogsHashes.sort(sortByCounter),
|
|
445
|
+
minRevertibleSideEffectCounter,
|
|
446
|
+
);
|
|
447
|
+
const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(
|
|
448
|
+
publicCallRequests.sort(sortByCounter),
|
|
449
|
+
minRevertibleSideEffectCounter,
|
|
450
|
+
);
|
|
413
451
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
452
|
+
const nonRevertibleData = new PrivateToPublicAccumulatedData(
|
|
453
|
+
padArrayEnd(nonRevertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
454
|
+
padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
|
|
455
|
+
padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
|
|
456
|
+
padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
|
|
457
|
+
padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
|
|
458
|
+
padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
|
|
459
|
+
);
|
|
421
460
|
|
|
422
461
|
const revertibleData = new PrivateToPublicAccumulatedData(
|
|
423
|
-
padArrayEnd(
|
|
424
|
-
padArrayEnd(
|
|
425
|
-
padArrayEnd(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
),
|
|
430
|
-
padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
|
|
431
|
-
padArrayEnd(
|
|
432
|
-
contractClassLogsHashes.sort(sortByCounter).map(getEffect),
|
|
433
|
-
ScopedLogHash.empty(),
|
|
434
|
-
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
435
|
-
),
|
|
436
|
-
padArrayEnd(
|
|
437
|
-
publicCallRequests.sort(sortByCounter).map(getEffect),
|
|
438
|
-
PublicCallRequest.empty(),
|
|
439
|
-
MAX_ENQUEUED_CALLS_PER_TX,
|
|
440
|
-
),
|
|
462
|
+
padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
463
|
+
padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
|
|
464
|
+
padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
|
|
465
|
+
padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
|
|
466
|
+
padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
|
|
467
|
+
padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
|
|
441
468
|
);
|
|
469
|
+
gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
|
|
470
|
+
if (publicTeardownCallRequest) {
|
|
471
|
+
gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
|
|
472
|
+
}
|
|
442
473
|
|
|
443
474
|
inputsForPublic = new PartialPrivateTailPublicInputsForPublic(
|
|
444
475
|
nonRevertibleData,
|
|
@@ -449,7 +480,7 @@ export async function generateSimulatedProvingResult(
|
|
|
449
480
|
|
|
450
481
|
const publicInputs = new PrivateKernelTailCircuitPublicInputs(
|
|
451
482
|
constantData,
|
|
452
|
-
/*gasUsed=*/
|
|
483
|
+
/*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
|
|
453
484
|
/*feePayer=*/ AztecAddress.zero(),
|
|
454
485
|
/*includeByTimestamp=*/ 0n,
|
|
455
486
|
hasPublicCalls ? inputsForPublic : undefined,
|
|
@@ -462,3 +493,56 @@ export async function generateSimulatedProvingResult(
|
|
|
462
493
|
executionSteps: executionSteps,
|
|
463
494
|
};
|
|
464
495
|
}
|
|
496
|
+
|
|
497
|
+
function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertibleSideEffectCounter: number) {
|
|
498
|
+
const revertibleSideEffects: T[] = [];
|
|
499
|
+
const nonRevertibleSideEffects: T[] = [];
|
|
500
|
+
effects.forEach(effect => {
|
|
501
|
+
if (effect.counter < minRevertibleSideEffectCounter) {
|
|
502
|
+
nonRevertibleSideEffects.push(effect.sideEffect);
|
|
503
|
+
} else {
|
|
504
|
+
revertibleSideEffects.push(effect.sideEffect);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
return [nonRevertibleSideEffects, revertibleSideEffects];
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData) {
|
|
511
|
+
let meteredDAFields = 0;
|
|
512
|
+
let meteredL2Gas = 0;
|
|
513
|
+
|
|
514
|
+
const numNoteHashes = arrayNonEmptyLength(data.noteHashes, hash => hash.isEmpty());
|
|
515
|
+
meteredDAFields += numNoteHashes;
|
|
516
|
+
meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
|
|
517
|
+
|
|
518
|
+
const numNullifiers = arrayNonEmptyLength(data.nullifiers, nullifier => nullifier.isEmpty());
|
|
519
|
+
meteredDAFields += numNullifiers;
|
|
520
|
+
meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
|
|
521
|
+
|
|
522
|
+
const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, msg => msg.isEmpty());
|
|
523
|
+
meteredDAFields += numL2toL1Messages;
|
|
524
|
+
meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
|
|
525
|
+
|
|
526
|
+
const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, log => log.isEmpty());
|
|
527
|
+
// Every private log emits its length as an additional field
|
|
528
|
+
meteredDAFields += data.privateLogs.reduce((acc, log) => (!log.isEmpty() ? acc + log.emittedLength + 1 : acc), 0);
|
|
529
|
+
meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
|
|
530
|
+
|
|
531
|
+
const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
|
|
532
|
+
// Every contract class log emits its length and contract address as additional fields
|
|
533
|
+
meteredDAFields += data.contractClassLogsHashes.reduce(
|
|
534
|
+
(acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 2 : acc),
|
|
535
|
+
0,
|
|
536
|
+
);
|
|
537
|
+
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
538
|
+
|
|
539
|
+
const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
|
|
540
|
+
|
|
541
|
+
if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
|
|
542
|
+
const dataForPublic = data as PrivateToPublicAccumulatedData;
|
|
543
|
+
|
|
544
|
+
const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, req => req.isEmpty());
|
|
545
|
+
meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
|
|
546
|
+
}
|
|
547
|
+
return Gas.from({ l2Gas: meteredL2Gas, daGas: meteredDAGas });
|
|
548
|
+
}
|
|
@@ -5,14 +5,13 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
5
5
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
6
6
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
7
7
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
8
|
-
import {
|
|
8
|
+
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
9
9
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
10
10
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
11
11
|
import type { BlockHeader, NodeStats } from '@aztec/stdlib/tx';
|
|
12
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
13
12
|
|
|
13
|
+
import type { NoteData } from './oracle/interfaces.js';
|
|
14
14
|
import type { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
|
|
15
|
-
import type { NoteData } from './oracle/typed_oracle.js';
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Error thrown when a contract is not found in the database.
|
|
@@ -146,11 +145,12 @@ export interface ExecutionDataProvider {
|
|
|
146
145
|
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
|
-
* Retrieve the latest block header synchronized by the
|
|
150
|
-
*
|
|
151
|
-
*
|
|
148
|
+
* Retrieve the latest block header synchronized by the execution data provider. This block header is referred
|
|
149
|
+
* to as the anchor block header in Aztec terminology and it defines the state that is used during private function
|
|
150
|
+
* execution.
|
|
151
|
+
* @returns The anchor block header.
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
getAnchorBlockHeader(): Promise<BlockHeader>;
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
@@ -215,54 +215,36 @@ export interface ExecutionDataProvider {
|
|
|
215
215
|
assertCompatibleOracleVersion(version: number): void;
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
219
|
-
* @returns The block number.
|
|
220
|
-
*/
|
|
221
|
-
getBlockNumber(): Promise<number>;
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Fetches the timestamp of the latest block synchronized by the node.
|
|
225
|
-
* @returns The timestamp.
|
|
226
|
-
*/
|
|
227
|
-
getTimestamp(): Promise<UInt64>;
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Fetches the current chain id.
|
|
231
|
-
* @returns The chain id.
|
|
232
|
-
*/
|
|
233
|
-
getChainId(): Promise<number>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Fetches the current chain id.
|
|
237
|
-
* @returns The chain id.
|
|
238
|
-
*/
|
|
239
|
-
getVersion(): Promise<number>;
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Returns the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
|
|
243
|
-
* Includes the next index to be used used for tagging with this secret.
|
|
218
|
+
* Calculates the directional app tagging secret for a given contract, sender and recipient.
|
|
244
219
|
* @param contractAddress - The contract address to silo the secret for
|
|
245
220
|
* @param sender - The address sending the note
|
|
246
221
|
* @param recipient - The address receiving the note
|
|
247
|
-
* @returns
|
|
222
|
+
* @returns The directional app tagging secret
|
|
248
223
|
*/
|
|
249
|
-
|
|
224
|
+
calculateDirectionalAppTaggingSecret(
|
|
250
225
|
contractAddress: AztecAddress,
|
|
251
226
|
sender: AztecAddress,
|
|
252
227
|
recipient: AztecAddress,
|
|
253
|
-
): Promise<
|
|
228
|
+
): Promise<DirectionalAppTaggingSecret>;
|
|
254
229
|
|
|
255
230
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* @param
|
|
259
|
-
*
|
|
231
|
+
* Updates the local index of the shared tagging secret of a (sender, recipient, contract) tuple if a log with
|
|
232
|
+
* a larger index is found from the node.
|
|
233
|
+
* @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction
|
|
234
|
+
* of sender -> recipient matters.
|
|
235
|
+
* @param contractAddress - The address of the contract that the logs are tagged for. Needs to be provided to store
|
|
236
|
+
* because the function performs second round of siloing which is necessary because kernels do it as well (they silo
|
|
237
|
+
* first field of the private log which corresponds to the tag).
|
|
260
238
|
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
239
|
+
syncTaggedLogsAsSender(secret: DirectionalAppTaggingSecret, contractAddress: AztecAddress): Promise<void>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Returns the last used index when sending a log with a given secret.
|
|
243
|
+
* @param secret - The directional app tagging secret.
|
|
244
|
+
* @returns The last used index for the given directional app tagging secret, or undefined if we never sent a log
|
|
245
|
+
* from this sender to a recipient in a given contract (implicitly included in the secret).
|
|
246
|
+
*/
|
|
247
|
+
getLastUsedIndexAsSender(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
|
|
266
248
|
|
|
267
249
|
/**
|
|
268
250
|
* Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found
|
|
@@ -301,9 +283,9 @@ export interface ExecutionDataProvider {
|
|
|
301
283
|
): Promise<void>;
|
|
302
284
|
|
|
303
285
|
/**
|
|
304
|
-
*
|
|
286
|
+
* Looks for nullifiers of active contract notes and marks them as nullified in the db if a nullifier is found.
|
|
305
287
|
*/
|
|
306
|
-
|
|
288
|
+
syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
|
|
307
289
|
|
|
308
290
|
/**
|
|
309
291
|
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
@@ -2,7 +2,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
4
4
|
|
|
5
|
-
import type { NoteData } from './oracle/
|
|
5
|
+
import type { NoteData } from './oracle/interfaces.js';
|
|
6
6
|
|
|
7
7
|
interface PendingNote {
|
|
8
8
|
note: NoteData;
|
|
@@ -126,7 +126,7 @@ export class ExecutionNoteCache {
|
|
|
126
126
|
* transaction (and thus not a new note).
|
|
127
127
|
*/
|
|
128
128
|
public async nullifyNote(contractAddress: AztecAddress, innerNullifier: Fr, noteHash: Fr) {
|
|
129
|
-
const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
|
|
129
|
+
const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
|
|
130
130
|
let nullifiedNoteHashCounter: number | undefined = undefined;
|
|
131
131
|
// Find and remove the matching new note and log(s) if the emitted noteHash is not empty.
|
|
132
132
|
if (!noteHash.isEmpty()) {
|
|
@@ -158,7 +158,7 @@ export class ExecutionNoteCache {
|
|
|
158
158
|
* @param innerNullifier
|
|
159
159
|
*/
|
|
160
160
|
public async nullifierCreated(contractAddress: AztecAddress, innerNullifier: Fr) {
|
|
161
|
-
const siloedNullifier = await siloNullifier(contractAddress, innerNullifier);
|
|
161
|
+
const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
|
|
162
162
|
this.recordNullifier(contractAddress, siloedNullifier);
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -208,10 +208,15 @@ export class ExecutionNoteCache {
|
|
|
208
208
|
return [...this.allNullifiers].map(n => new Fr(n));
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
recordNullifier(contractAddress: AztecAddress, siloedNullifier:
|
|
211
|
+
recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint) {
|
|
212
212
|
const nullifiers = this.getNullifiers(contractAddress);
|
|
213
|
-
|
|
213
|
+
|
|
214
|
+
if (nullifiers.has(siloedNullifier)) {
|
|
215
|
+
throw new Error(`Duplicate siloed nullifier ${siloedNullifier} emitted by contract ${contractAddress}`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
nullifiers.add(siloedNullifier);
|
|
214
219
|
this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
|
|
215
|
-
this.allNullifiers.add(siloedNullifier
|
|
220
|
+
this.allNullifiers.add(siloedNullifier);
|
|
216
221
|
}
|
|
217
222
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A map that stores the tagging index for a given directional app tagging secret.
|
|
5
|
+
* Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
|
|
6
|
+
* of sender -> recipient matters.
|
|
7
|
+
*/
|
|
8
|
+
export class ExecutionTaggingIndexCache {
|
|
9
|
+
private taggingIndexMap: Map<string, number> = new Map();
|
|
10
|
+
|
|
11
|
+
public getLastUsedIndex(secret: DirectionalAppTaggingSecret): number | undefined {
|
|
12
|
+
return this.taggingIndexMap.get(secret.toString());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public setLastUsedIndex(secret: DirectionalAppTaggingSecret, index: number) {
|
|
16
|
+
const currentValue = this.taggingIndexMap.get(secret.toString());
|
|
17
|
+
if (currentValue !== undefined && currentValue !== index - 1) {
|
|
18
|
+
throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
|
|
19
|
+
}
|
|
20
|
+
this.taggingIndexMap.set(secret.toString(), index);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Returns the pre tags that were used in this execution (and that need to be stored in the db).
|
|
25
|
+
*/
|
|
26
|
+
public getUsedPreTags(): PreTag[] {
|
|
27
|
+
return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
|
|
28
|
+
secret: DirectionalAppTaggingSecret.fromString(secret),
|
|
29
|
+
index,
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ExecutionNoteCache } from './execution_note_cache.js';
|
|
2
|
+
export { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
2
3
|
export { HashedValuesCache } from './hashed_values_cache.js';
|
|
3
4
|
export { pickNotes } from './pick_notes.js';
|
|
4
|
-
export {
|
|
5
|
+
export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
|
|
5
6
|
export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
|
|
6
7
|
export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
7
8
|
export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
@@ -9,3 +10,4 @@ export { Oracle } from './oracle/oracle.js';
|
|
|
9
10
|
export { executePrivateFunction, extractPrivateCircuitPublicInputs } from './oracle/private_execution.js';
|
|
10
11
|
export { generateSimulatedProvingResult } from './contract_function_simulator.js';
|
|
11
12
|
export { packAsRetrievedNote } from './oracle/note_packing_utils.js';
|
|
13
|
+
export { UtilityContext } from './noir-structs/utility_context.js';
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_CIPHERTEXT_LEN } from '@aztec/constants';
|
|
2
2
|
import { range } from '@aztec/foundation/array';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { MAX_NOTE_PACKED_LEN } from './note_validation_request.js';
|
|
7
|
+
|
|
8
|
+
const MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION = MAX_NOTE_PACKED_LEN;
|
|
9
|
+
const MAX_LOG_CONTENT_LEN = Math.max(MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION, PRIVATE_LOG_CIPHERTEXT_LEN);
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
|
|
@@ -19,7 +22,9 @@ export class LogRetrievalResponse {
|
|
|
19
22
|
|
|
20
23
|
toFields(): Fr[] {
|
|
21
24
|
return [
|
|
22
|
-
|
|
25
|
+
// We need to trim the payload since public logs can be larger than MAX_LOG_CONTENT_LEN.
|
|
26
|
+
// This is currently not a problem since this class is only used with public logs for note completion.
|
|
27
|
+
...serializeBoundedVec(this.logPayload.slice(0, MAX_LOG_CONTENT_LEN), MAX_LOG_CONTENT_LEN),
|
|
23
28
|
this.txHash.hash,
|
|
24
29
|
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
25
30
|
this.firstNullifierInTx,
|
|
@@ -4,7 +4,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
7
|
-
const MAX_NOTE_PACKED_LEN = 12;
|
|
7
|
+
export const MAX_NOTE_PACKED_LEN = 12;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateEnqueuedNotesAndEvents` oracle
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
|
|
8
|
+
*/
|
|
9
|
+
export class UtilityContext {
|
|
10
|
+
private constructor(
|
|
11
|
+
public readonly blockNumber: number,
|
|
12
|
+
public readonly timestamp: UInt64,
|
|
13
|
+
public readonly contractAddress: AztecAddress,
|
|
14
|
+
public readonly version: Fr,
|
|
15
|
+
public readonly chainId: Fr,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
static from(fields: FieldsOf<UtilityContext>) {
|
|
19
|
+
return new UtilityContext(
|
|
20
|
+
fields.blockNumber,
|
|
21
|
+
fields.timestamp,
|
|
22
|
+
fields.contractAddress,
|
|
23
|
+
fields.version,
|
|
24
|
+
fields.chainId,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a representation of the utility context as expected by intrinsic Noir deserialization.
|
|
30
|
+
* The order of the fields has to be the same as the order of the fields in the utility_context.nr.
|
|
31
|
+
*/
|
|
32
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
33
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
34
|
+
return [
|
|
35
|
+
new Fr(this.blockNumber).toString() as string,
|
|
36
|
+
new Fr(this.timestamp).toString() as string,
|
|
37
|
+
this.contractAddress.toString() as string,
|
|
38
|
+
this.version.toString() as string,
|
|
39
|
+
this.chainId.toString() as string,
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
}
|