@aztec/pxe 0.0.1-commit.24de95ac → 0.0.1-commit.5daedc8
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/bin/check_oracle_version.d.ts +1 -1
- package/dest/config/index.d.ts +2 -10
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +7 -13
- package/dest/config/package_info.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +9 -10
- package/dest/contract_function_simulator/execution_data_provider.d.ts +2 -11
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +6 -5
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +17 -10
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -3
- 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 +9 -3
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +5 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +1 -3
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +5 -3
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +4 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +9 -4
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +4 -9
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +13 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +2 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +3 -3
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +8 -15
- package/dest/entrypoints/client/bundle/index.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +1 -1
- package/dest/entrypoints/server/index.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +4 -15
- package/dest/error_enriching.d.ts +1 -1
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts +3 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_side_effect_uniqueness_hints.js +48 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/index.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +11 -7
- package/dest/private_kernel/private_kernel_oracle.d.ts +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/pxe.d.ts +20 -13
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +19 -37
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -1
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/index.d.ts +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -12
- 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 -12
- package/dest/storage/contract_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/index.d.ts +1 -1
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/note_data_provider/index.d.ts +2 -2
- package/dest/storage/note_data_provider/index.d.ts.map +1 -1
- package/dest/storage/note_data_provider/index.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +13 -10
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +2 -8
- 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 +3 -2
- package/dest/storage/sync_data_provider/index.d.ts +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/index.d.ts +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/synchronizer/index.d.ts +1 -1
- package/dest/synchronizer/synchronizer.d.ts +1 -1
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/tagging/constants.d.ts +1 -1
- package/dest/tagging/index.d.ts +1 -1
- package/dest/tagging/siloed_tag.d.ts +1 -1
- package/dest/tagging/siloed_tag.d.ts.map +1 -1
- package/dest/tagging/tag.d.ts +1 -1
- package/dest/tagging/tag.d.ts.map +1 -1
- package/dest/tagging/utils.d.ts +1 -1
- package/package.json +20 -19
- package/src/config/index.ts +8 -23
- package/src/contract_function_simulator/contract_function_simulator.ts +17 -12
- package/src/contract_function_simulator/execution_data_provider.ts +1 -11
- package/src/contract_function_simulator/execution_note_cache.ts +15 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +10 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +5 -3
- package/src/contract_function_simulator/oracle/oracle.ts +10 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +9 -1
- package/src/contract_function_simulator/pxe_oracle_interface.ts +20 -31
- package/src/entrypoints/client/bundle/utils.ts +2 -2
- package/src/entrypoints/client/lazy/utils.ts +2 -2
- package/src/entrypoints/server/utils.ts +4 -18
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +4 -8
- package/src/private_kernel/hints/compute_side_effect_uniqueness_hints.ts +173 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +12 -12
- package/src/pxe.ts +36 -64
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -17
- package/src/storage/note_data_provider/index.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +15 -9
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +4 -9
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/src/storage/note_data_provider/note_dao.ts +0 -154
|
@@ -3,12 +3,7 @@ import { timesParallel } from '@aztec/foundation/collection';
|
|
|
3
3
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type { KeyStore } from '@aztec/key-store';
|
|
6
|
-
import {
|
|
7
|
-
EventSelector,
|
|
8
|
-
type FunctionArtifactWithContractName,
|
|
9
|
-
FunctionSelector,
|
|
10
|
-
getFunctionArtifact,
|
|
11
|
-
} from '@aztec/stdlib/abi';
|
|
6
|
+
import { EventSelector, type FunctionArtifactWithContractName, FunctionSelector } from '@aztec/stdlib/abi';
|
|
12
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
8
|
import type { InBlock, L2Block, L2BlockNumber } from '@aztec/stdlib/block';
|
|
14
9
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
@@ -26,6 +21,7 @@ import {
|
|
|
26
21
|
} from '@aztec/stdlib/logs';
|
|
27
22
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
28
23
|
import { Note, type NoteStatus } from '@aztec/stdlib/note';
|
|
24
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
29
25
|
import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
30
26
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
31
27
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
@@ -36,7 +32,6 @@ import { ORACLE_VERSION } from '../oracle_version.js';
|
|
|
36
32
|
import type { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
|
|
37
33
|
import type { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
|
|
38
34
|
import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
|
|
39
|
-
import { NoteDao } from '../storage/note_data_provider/note_dao.js';
|
|
40
35
|
import type { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
|
|
41
36
|
import type { PrivateEventDataProvider } from '../storage/private_event_data_provider/private_event_data_provider.js';
|
|
42
37
|
import type { SyncDataProvider } from '../storage/sync_data_provider/sync_data_provider.js';
|
|
@@ -102,16 +97,19 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
102
97
|
status,
|
|
103
98
|
scopes,
|
|
104
99
|
});
|
|
105
|
-
return noteDaos.map(
|
|
106
|
-
contractAddress,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
return noteDaos.map(
|
|
101
|
+
({ contractAddress, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
|
|
102
|
+
contractAddress,
|
|
103
|
+
storageSlot,
|
|
104
|
+
randomness,
|
|
105
|
+
noteNonce,
|
|
106
|
+
note,
|
|
107
|
+
noteHash,
|
|
108
|
+
siloedNullifier,
|
|
109
|
+
// PXE can use this index to get full MembershipWitness
|
|
110
|
+
index,
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
async getFunctionArtifact(
|
|
@@ -129,18 +127,6 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
129
127
|
};
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
async getFunctionArtifactByName(
|
|
133
|
-
contractAddress: AztecAddress,
|
|
134
|
-
functionName: string,
|
|
135
|
-
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
136
|
-
const instance = await this.contractDataProvider.getContractInstance(contractAddress);
|
|
137
|
-
if (!instance) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const artifact = await this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
|
|
141
|
-
return artifact && getFunctionArtifact(artifact, functionName);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
130
|
/**
|
|
145
131
|
* Fetches a message from the db, given its key.
|
|
146
132
|
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
@@ -614,6 +600,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
614
600
|
this.deliverNote(
|
|
615
601
|
request.contractAddress,
|
|
616
602
|
request.storageSlot,
|
|
603
|
+
request.randomness,
|
|
617
604
|
request.noteNonce,
|
|
618
605
|
request.content,
|
|
619
606
|
request.noteHash,
|
|
@@ -644,6 +631,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
644
631
|
async deliverNote(
|
|
645
632
|
contractAddress: AztecAddress,
|
|
646
633
|
storageSlot: Fr,
|
|
634
|
+
randomness: Fr,
|
|
647
635
|
noteNonce: Fr,
|
|
648
636
|
content: Fr[],
|
|
649
637
|
noteHash: Fr,
|
|
@@ -695,6 +683,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
695
683
|
new Note(content),
|
|
696
684
|
contractAddress,
|
|
697
685
|
storageSlot,
|
|
686
|
+
randomness,
|
|
698
687
|
noteNonce,
|
|
699
688
|
noteHash,
|
|
700
689
|
siloedNullifier,
|
|
@@ -702,9 +691,9 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
702
691
|
uniqueNoteHashTreeIndexInBlock?.l2BlockNumber,
|
|
703
692
|
uniqueNoteHashTreeIndexInBlock?.l2BlockHash.toString(),
|
|
704
693
|
uniqueNoteHashTreeIndexInBlock?.data,
|
|
705
|
-
recipient,
|
|
706
694
|
);
|
|
707
695
|
|
|
696
|
+
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
708
697
|
await this.noteDataProvider.addNotes([noteDao], recipient);
|
|
709
698
|
this.log.verbose('Added note', {
|
|
710
699
|
index: noteDao.index,
|
|
@@ -767,7 +756,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
767
756
|
privateLog.firstNullifierInTx,
|
|
768
757
|
);
|
|
769
758
|
} else {
|
|
770
|
-
null;
|
|
759
|
+
return null;
|
|
771
760
|
}
|
|
772
761
|
}),
|
|
773
762
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
2
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
@@ -49,7 +49,7 @@ export async function createPXE(
|
|
|
49
49
|
? loggers.prover
|
|
50
50
|
: createLogger('pxe:bb:wasm:bundle' + (logSuffix ? `:${logSuffix}` : ''));
|
|
51
51
|
|
|
52
|
-
const prover = options.prover ?? new
|
|
52
|
+
const prover = options.prover ?? new BBBundlePrivateKernelProver(simulator, proverLogger);
|
|
53
53
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
54
54
|
|
|
55
55
|
const pxeLogger = loggers.pxe ? loggers.pxe : createLogger('pxe:service' + (logSuffix ? `:${logSuffix}` : ''));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BBLazyPrivateKernelProver } from '@aztec/bb-prover/client/lazy';
|
|
2
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
@@ -48,7 +48,7 @@ export async function createPXE(
|
|
|
48
48
|
? loggers.prover
|
|
49
49
|
: createLogger('pxe:bb:wasm:bundle' + (logSuffix ? `:${logSuffix}` : ''));
|
|
50
50
|
|
|
51
|
-
const prover = options.prover ?? new
|
|
51
|
+
const prover = options.prover ?? new BBLazyPrivateKernelProver(simulator, proverLogger);
|
|
52
52
|
|
|
53
53
|
const protocolContractsProvider = new LazyProtocolContractsProvider();
|
|
54
54
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BBWASMBundlePrivateKernelProver } from '@aztec/bb-prover/client/wasm/bundle';
|
|
1
|
+
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
3
2
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
4
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
@@ -59,7 +58,7 @@ export async function createPXE(
|
|
|
59
58
|
? loggers.prover
|
|
60
59
|
: createLogger('pxe:bb:native' + (logSuffix ? `:${logSuffix}` : ''));
|
|
61
60
|
|
|
62
|
-
const prover = options.prover ??
|
|
61
|
+
const prover = options.prover ?? createProver(simulator, proverLogger);
|
|
63
62
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
64
63
|
|
|
65
64
|
const pxeLogger = loggers.pxe ? loggers.pxe : createLogger('pxe:service' + (logSuffix ? `:${logSuffix}` : ''));
|
|
@@ -75,19 +74,6 @@ export async function createPXE(
|
|
|
75
74
|
return pxe;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
function createProver(
|
|
79
|
-
|
|
80
|
-
simulator: CircuitSimulator,
|
|
81
|
-
logger?: Logger,
|
|
82
|
-
) {
|
|
83
|
-
if (!config.bbBinaryPath || !config.bbWorkingDirectory) {
|
|
84
|
-
return new BBWASMBundlePrivateKernelProver(simulator, 16, logger);
|
|
85
|
-
} else {
|
|
86
|
-
const bbConfig = config as Required<Pick<PXEConfig, 'bbBinaryPath' | 'bbWorkingDirectory'>> & PXEConfig;
|
|
87
|
-
return BBNativePrivateKernelProver.new(
|
|
88
|
-
{ bbSkipCleanup: false, numConcurrentIVCVerifiers: 1, bbIVCConcurrency: 1, ...bbConfig },
|
|
89
|
-
simulator,
|
|
90
|
-
logger,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
77
|
+
function createProver(simulator: CircuitSimulator, logger?: Logger) {
|
|
78
|
+
return new BBBundlePrivateKernelProver(simulator, logger);
|
|
93
79
|
}
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
///
|
|
5
5
|
/// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 4;
|
|
8
8
|
|
|
9
9
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
10
10
|
/// which in turn implies that you need to update the ORACLE_VERSION constant.
|
|
11
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
11
|
+
export const ORACLE_INTERFACE_HASH = 'd1496df59c0b51a481d5ef93f218b5c35ddfce6242da28d60bb5c66386940eac';
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
PrivateKernelResetDimensions,
|
|
25
25
|
PrivateKernelResetHints,
|
|
26
26
|
type PrivateKernelSimulateOutput,
|
|
27
|
-
type ReadRequest,
|
|
28
27
|
ReadRequestActionEnum,
|
|
29
28
|
ReadRequestResetActions,
|
|
30
29
|
type ScopedKeyValidationRequestAndGenerator,
|
|
@@ -47,12 +46,10 @@ import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
|
|
|
47
46
|
|
|
48
47
|
function collectNestedReadRequests<N extends number>(
|
|
49
48
|
executionStack: PrivateCallExecutionResult[],
|
|
50
|
-
extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<
|
|
49
|
+
extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<ScopedReadRequest, N>,
|
|
51
50
|
): ScopedReadRequest[] {
|
|
52
51
|
return collectNested(executionStack, executionResult => {
|
|
53
|
-
return extractReadRequests(executionResult)
|
|
54
|
-
.getActiveItems()
|
|
55
|
-
.map(readRequest => new ScopedReadRequest(readRequest, executionResult.publicInputs.callContext.contractAddress));
|
|
52
|
+
return extractReadRequests(executionResult).getActiveItems();
|
|
56
53
|
});
|
|
57
54
|
}
|
|
58
55
|
|
|
@@ -104,7 +101,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
104
101
|
private previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>,
|
|
105
102
|
private executionStack: PrivateCallExecutionResult[],
|
|
106
103
|
private noteHashNullifierCounterMap: Map<number, number>,
|
|
107
|
-
private
|
|
104
|
+
private splitCounter: number,
|
|
108
105
|
) {
|
|
109
106
|
this.previousKernel = previousKernelOutput.publicInputs;
|
|
110
107
|
this.requestedDimensions = PrivateKernelResetDimensions.empty();
|
|
@@ -206,7 +203,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
206
203
|
oracle,
|
|
207
204
|
),
|
|
208
205
|
this.transientDataSquashingHints,
|
|
209
|
-
this.validationRequestsSplitCounter,
|
|
210
206
|
),
|
|
211
207
|
dimensions,
|
|
212
208
|
);
|
|
@@ -403,7 +399,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
403
399
|
futureNoteHashReads,
|
|
404
400
|
futureNullifierReads,
|
|
405
401
|
this.noteHashNullifierCounterMap,
|
|
406
|
-
this.
|
|
402
|
+
this.splitCounter,
|
|
407
403
|
);
|
|
408
404
|
|
|
409
405
|
if (this.nextIteration && !numTransientData) {
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET,
|
|
3
|
+
GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET,
|
|
4
|
+
GLOBAL_INDEX_NOTE_HASH_OFFSET,
|
|
5
|
+
GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET,
|
|
6
|
+
GLOBAL_INDEX_NULLIFIER_OFFSET,
|
|
7
|
+
GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET,
|
|
8
|
+
GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET,
|
|
9
|
+
GLOBAL_INDEX_PRIVATE_LOG_OFFSET,
|
|
10
|
+
GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET,
|
|
11
|
+
MAX_CONTRACT_CLASS_LOGS_PER_CALL,
|
|
12
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
13
|
+
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
14
|
+
MAX_NOTE_HASHES_PER_CALL,
|
|
15
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
16
|
+
MAX_NULLIFIERS_PER_CALL,
|
|
17
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
18
|
+
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
|
|
19
|
+
MAX_PRIVATE_LOGS_PER_CALL,
|
|
20
|
+
TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL,
|
|
21
|
+
} from '@aztec/constants';
|
|
22
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
23
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
24
|
+
import type { Serializable } from '@aztec/foundation/serialize';
|
|
25
|
+
import {
|
|
26
|
+
ClaimedLengthArray,
|
|
27
|
+
PrivateCallRequest,
|
|
28
|
+
type PrivateCircuitPublicInputs,
|
|
29
|
+
SideEffectCounterRange,
|
|
30
|
+
SideEffectUniquenessHints,
|
|
31
|
+
} from '@aztec/stdlib/kernel';
|
|
32
|
+
|
|
33
|
+
export function computeSideEffectUniquenessHints(publicInputs: PrivateCircuitPublicInputs): SideEffectUniquenessHints {
|
|
34
|
+
let sideEffectRanges: SideEffectCounterRange[] = [];
|
|
35
|
+
|
|
36
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
37
|
+
createRangesFromClaimedLengthArray(
|
|
38
|
+
publicInputs.noteHashReadRequests,
|
|
39
|
+
GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET,
|
|
40
|
+
createRangeFromCountedItem,
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
44
|
+
createRangesFromClaimedLengthArray(
|
|
45
|
+
publicInputs.nullifierReadRequests,
|
|
46
|
+
GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET,
|
|
47
|
+
createRangeFromCountedItem,
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
51
|
+
createRangesFromClaimedLengthArray(
|
|
52
|
+
publicInputs.noteHashes,
|
|
53
|
+
GLOBAL_INDEX_NOTE_HASH_OFFSET,
|
|
54
|
+
createRangeFromCountedItem,
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
58
|
+
createRangesFromClaimedLengthArray(
|
|
59
|
+
publicInputs.nullifiers,
|
|
60
|
+
GLOBAL_INDEX_NULLIFIER_OFFSET,
|
|
61
|
+
createRangeFromCountedItem,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
65
|
+
createRangesFromClaimedLengthArray(
|
|
66
|
+
publicInputs.privateCallRequests,
|
|
67
|
+
GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET,
|
|
68
|
+
createRangeFromPrivateCallRequest,
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
72
|
+
createRangesFromClaimedLengthArray(
|
|
73
|
+
publicInputs.publicCallRequests,
|
|
74
|
+
GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET,
|
|
75
|
+
createRangeFromCountedItem,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
79
|
+
createRangesFromClaimedLengthArray(
|
|
80
|
+
publicInputs.l2ToL1Msgs,
|
|
81
|
+
GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET,
|
|
82
|
+
createRangeFromCountedItem,
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
86
|
+
createRangesFromClaimedLengthArray(
|
|
87
|
+
publicInputs.privateLogs,
|
|
88
|
+
GLOBAL_INDEX_PRIVATE_LOG_OFFSET,
|
|
89
|
+
createRangeFromCountedItem,
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
sideEffectRanges = sideEffectRanges.concat(
|
|
93
|
+
createRangesFromClaimedLengthArray(
|
|
94
|
+
publicInputs.contractClassLogsHashes,
|
|
95
|
+
GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET,
|
|
96
|
+
createRangeFromCountedItem,
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
sideEffectRanges.sort((a, b) => a.start - b.start);
|
|
101
|
+
|
|
102
|
+
const sideEffectRangeIndices = makeTuple(TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL, () => 0);
|
|
103
|
+
for (let i = 0; i < sideEffectRanges.length; i++) {
|
|
104
|
+
const range = sideEffectRanges[i];
|
|
105
|
+
sideEffectRangeIndices[range.sideEffectGlobalIndex] = i;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const hints = SideEffectUniquenessHints.from({
|
|
109
|
+
sideEffectRanges: padArrayEnd(
|
|
110
|
+
sideEffectRanges,
|
|
111
|
+
SideEffectCounterRange.empty(),
|
|
112
|
+
TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL,
|
|
113
|
+
),
|
|
114
|
+
noteHashReadRequestIndices: makeTuple(
|
|
115
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
116
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NOTE_HASH_READ_REQUEST_OFFSET],
|
|
117
|
+
),
|
|
118
|
+
nullifierReadRequestIndices: makeTuple(
|
|
119
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
120
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NULLIFIER_READ_REQUEST_OFFSET],
|
|
121
|
+
),
|
|
122
|
+
noteHashesIndices: makeTuple(
|
|
123
|
+
MAX_NOTE_HASHES_PER_CALL,
|
|
124
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NOTE_HASH_OFFSET],
|
|
125
|
+
),
|
|
126
|
+
nullifiersIndices: makeTuple(
|
|
127
|
+
MAX_NULLIFIERS_PER_CALL,
|
|
128
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_NULLIFIER_OFFSET],
|
|
129
|
+
),
|
|
130
|
+
privateCallRequestsIndices: makeTuple(
|
|
131
|
+
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
|
|
132
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PRIVATE_CALL_REQUEST_OFFSET],
|
|
133
|
+
),
|
|
134
|
+
publicCallRequestsIndices: makeTuple(
|
|
135
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
136
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PUBLIC_CALL_REQUEST_OFFSET],
|
|
137
|
+
),
|
|
138
|
+
l2ToL1MsgsIndices: makeTuple(
|
|
139
|
+
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
140
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_L2_TO_L1_MSG_OFFSET],
|
|
141
|
+
),
|
|
142
|
+
privateLogsIndices: makeTuple(
|
|
143
|
+
MAX_PRIVATE_LOGS_PER_CALL,
|
|
144
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_PRIVATE_LOG_OFFSET],
|
|
145
|
+
),
|
|
146
|
+
contractClassLogsHashesIndices: makeTuple(
|
|
147
|
+
MAX_CONTRACT_CLASS_LOGS_PER_CALL,
|
|
148
|
+
i => sideEffectRangeIndices[i + GLOBAL_INDEX_CONTRACT_CLASS_LOG_HASH_OFFSET],
|
|
149
|
+
),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return hints;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createRangesFromClaimedLengthArray<T extends Serializable, N extends number>(
|
|
156
|
+
array: ClaimedLengthArray<T, N>,
|
|
157
|
+
globalIndexOffset: number,
|
|
158
|
+
rangeConstructor: (item: T, globalIndex: number) => SideEffectCounterRange,
|
|
159
|
+
): SideEffectCounterRange[] {
|
|
160
|
+
const ranges = [];
|
|
161
|
+
for (let i = 0; i < array.claimedLength; i++) {
|
|
162
|
+
ranges.push(rangeConstructor(array.array[i], globalIndexOffset + i));
|
|
163
|
+
}
|
|
164
|
+
return ranges;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function createRangeFromCountedItem(item: { counter: number }, globalIndex: number): SideEffectCounterRange {
|
|
168
|
+
return new SideEffectCounterRange(item.counter, item.counter, globalIndex);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function createRangeFromPrivateCallRequest(item: PrivateCallRequest, globalIndex: number): SideEffectCounterRange {
|
|
172
|
+
return new SideEffectCounterRange(item.startSideEffectCounter, item.endSideEffectCounter, globalIndex);
|
|
173
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
36
36
|
|
|
37
37
|
import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
|
|
38
|
+
import { computeSideEffectUniquenessHints } from './hints/compute_side_effect_uniqueness_hints.js';
|
|
38
39
|
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
39
40
|
|
|
40
41
|
const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
|
|
@@ -103,9 +104,8 @@ export class PrivateKernelExecutionProver {
|
|
|
103
104
|
|
|
104
105
|
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
105
106
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
: getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
107
|
+
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
108
|
+
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
109
109
|
|
|
110
110
|
while (executionStack.length) {
|
|
111
111
|
if (!firstIteration) {
|
|
@@ -113,7 +113,7 @@ export class PrivateKernelExecutionProver {
|
|
|
113
113
|
output,
|
|
114
114
|
executionStack,
|
|
115
115
|
noteHashNullifierCounterMap,
|
|
116
|
-
|
|
116
|
+
splitCounter,
|
|
117
117
|
);
|
|
118
118
|
while (resetBuilder.needsReset()) {
|
|
119
119
|
const witgenTimer = new Timer();
|
|
@@ -134,7 +134,7 @@ export class PrivateKernelExecutionProver {
|
|
|
134
134
|
output,
|
|
135
135
|
executionStack,
|
|
136
136
|
noteHashNullifierCounterMap,
|
|
137
|
-
|
|
137
|
+
splitCounter,
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
@@ -171,6 +171,7 @@ export class PrivateKernelExecutionProver {
|
|
|
171
171
|
privateCallData,
|
|
172
172
|
isPrivateOnlyTx,
|
|
173
173
|
executionResult.firstNullifier,
|
|
174
|
+
minRevertibleSideEffectCounter,
|
|
174
175
|
);
|
|
175
176
|
this.log.debug(
|
|
176
177
|
`Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
|
|
@@ -220,7 +221,7 @@ export class PrivateKernelExecutionProver {
|
|
|
220
221
|
output,
|
|
221
222
|
[],
|
|
222
223
|
noteHashNullifierCounterMap,
|
|
223
|
-
|
|
224
|
+
splitCounter,
|
|
224
225
|
);
|
|
225
226
|
while (resetBuilder.needsReset()) {
|
|
226
227
|
const witgenTimer = new Timer();
|
|
@@ -239,12 +240,7 @@ export class PrivateKernelExecutionProver {
|
|
|
239
240
|
},
|
|
240
241
|
});
|
|
241
242
|
|
|
242
|
-
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
|
|
243
|
-
output,
|
|
244
|
-
[],
|
|
245
|
-
noteHashNullifierCounterMap,
|
|
246
|
-
validationRequestsSplitCounter,
|
|
247
|
-
);
|
|
243
|
+
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
248
244
|
}
|
|
249
245
|
|
|
250
246
|
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
@@ -420,6 +416,9 @@ export class PrivateKernelExecutionProver {
|
|
|
420
416
|
await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
421
417
|
|
|
422
418
|
const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
|
|
419
|
+
|
|
420
|
+
const sideEffectUniquenessHints = computeSideEffectUniquenessHints(publicInputs);
|
|
421
|
+
|
|
423
422
|
return PrivateCallData.from({
|
|
424
423
|
publicInputs,
|
|
425
424
|
vk,
|
|
@@ -431,6 +430,7 @@ export class PrivateKernelExecutionProver {
|
|
|
431
430
|
functionLeafMembershipWitness,
|
|
432
431
|
updatedClassIdHints,
|
|
433
432
|
}),
|
|
433
|
+
sideEffectUniquenessHints,
|
|
434
434
|
});
|
|
435
435
|
}
|
|
436
436
|
}
|