@aztec/pxe 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2
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/block_synchronizer/block_synchronizer.d.ts +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +21 -13
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -9
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +33 -16
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -8
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- 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 +4 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +5 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +20 -19
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +5 -9
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +11 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -18
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -35
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +14 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +54 -52
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- 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 +11 -7
- package/dest/events/event_service.d.ts +4 -3
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +17 -19
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +5 -3
- package/dest/notes/note_service.d.ts +3 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +23 -28
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- 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 +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +8 -36
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +65 -87
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +132 -23
- package/dest/storage/contract_store/contract_store.d.ts +2 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +12 -0
- package/dest/storage/note_store/note_store.d.ts +6 -5
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +89 -94
- package/dest/storage/private_event_store/private_event_store.d.ts +33 -6
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +139 -32
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +69 -12
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +110 -28
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +2 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +2 -2
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -2
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +4 -2
- package/dest/tree_membership/tree_membership_service.d.ts +9 -11
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -1
- package/dest/tree_membership/tree_membership_service.js +25 -34
- package/package.json +18 -18
- package/src/block_synchronizer/block_synchronizer.ts +30 -12
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +42 -16
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +4 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +8 -7
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +6 -6
- package/src/contract_function_simulator/oracle/oracle.ts +24 -22
- package/src/contract_function_simulator/oracle/private_execution.ts +10 -19
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +13 -38
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +56 -50
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/events/event_service.ts +17 -21
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +3 -1
- package/src/notes/note_service.ts +23 -29
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +98 -116
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +20 -0
- package/src/storage/note_store/note_store.ts +98 -95
- package/src/storage/private_event_store/private_event_store.ts +199 -37
- package/src/storage/tagging_store/recipient_tagging_store.ts +89 -13
- package/src/storage/tagging_store/sender_tagging_store.ts +129 -28
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/index.ts +1 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +10 -6
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +8 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +6 -2
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -1
- package/src/tree_membership/tree_membership_service.ts +27 -42
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface that stores must implement to support staged writes.
|
|
7
|
+
*/
|
|
8
|
+
export interface StagedStore {
|
|
9
|
+
/** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
|
|
10
|
+
readonly storeName: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Commits staged data to main storage.
|
|
14
|
+
* Should be called within a transaction for atomicity.
|
|
15
|
+
*
|
|
16
|
+
* @param jobId - The job identifier
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Discards staged data without committing.
|
|
22
|
+
* Called on abort.
|
|
23
|
+
*
|
|
24
|
+
* @param jobId - The job identifier
|
|
25
|
+
*/
|
|
26
|
+
discardStaged(jobId: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
|
|
31
|
+
*
|
|
32
|
+
* It uses a staged writes pattern:
|
|
33
|
+
* 1. When a job begins, a unique job ID is created
|
|
34
|
+
* 2. During the job, all writes go to staging (keyed by job ID)
|
|
35
|
+
* 3. On commit, staging is promoted to main storage
|
|
36
|
+
* 4. On abort, staged data is discarded
|
|
37
|
+
*
|
|
38
|
+
* Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
|
|
39
|
+
* orchestrate concurrent jobs. Right now it doesn't make a difference because we're
|
|
40
|
+
* using a job queue with concurrency=1.
|
|
41
|
+
*/
|
|
42
|
+
export class JobCoordinator {
|
|
43
|
+
private readonly log = createLogger('pxe:job_coordinator');
|
|
44
|
+
|
|
45
|
+
/** The underlying KV store */
|
|
46
|
+
kvStore: AztecAsyncKVStore;
|
|
47
|
+
|
|
48
|
+
#currentJobId: string | undefined;
|
|
49
|
+
#stores: Map<string, StagedStore> = new Map();
|
|
50
|
+
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore) {
|
|
52
|
+
this.kvStore = kvStore;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Registers a staged store.
|
|
57
|
+
* Must be called during initialization for all stores that need staging support.
|
|
58
|
+
*/
|
|
59
|
+
registerStore(store: StagedStore): void {
|
|
60
|
+
if (this.#stores.has(store.storeName)) {
|
|
61
|
+
throw new Error(`Store "${store.storeName}" is already registered`);
|
|
62
|
+
}
|
|
63
|
+
this.#stores.set(store.storeName, store);
|
|
64
|
+
this.log.debug(`Registered staged store: ${store.storeName}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Registers multiple staged stores.
|
|
69
|
+
*/
|
|
70
|
+
registerStores(stores: StagedStore[]): void {
|
|
71
|
+
for (const store of stores) {
|
|
72
|
+
this.registerStore(store);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Begins a new job and returns a job ID for staged writes.
|
|
78
|
+
*
|
|
79
|
+
* @returns Job ID to pass to store operations
|
|
80
|
+
*/
|
|
81
|
+
beginJob(): string {
|
|
82
|
+
if (this.#currentJobId) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Cannot begin job: job ${this.#currentJobId} is already in progress. ` +
|
|
85
|
+
`This should not happen - ensure jobs are properly committed or aborted.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const jobId = randomBytes(8).toString('hex');
|
|
90
|
+
this.#currentJobId = jobId;
|
|
91
|
+
|
|
92
|
+
this.log.debug(`Started job ${jobId}`);
|
|
93
|
+
return jobId;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Commits a job by promoting all staged data to main storage.
|
|
98
|
+
*
|
|
99
|
+
* @param jobId - The job ID returned from beginJob
|
|
100
|
+
*/
|
|
101
|
+
async commitJob(jobId: string): Promise<void> {
|
|
102
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.log.debug(`Committing job ${jobId}`);
|
|
109
|
+
|
|
110
|
+
// Commit all stores atomically in a single transaction.
|
|
111
|
+
// Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
|
|
112
|
+
await this.kvStore.transactionAsync(async () => {
|
|
113
|
+
for (const store of this.#stores.values()) {
|
|
114
|
+
await store.commit(jobId);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.#currentJobId = undefined;
|
|
119
|
+
this.log.debug(`Job ${jobId} committed successfully`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Aborts a job by discarding all staged data.
|
|
124
|
+
*
|
|
125
|
+
* @param jobId - The job ID returned from beginJob
|
|
126
|
+
*/
|
|
127
|
+
async abortJob(jobId: string): Promise<void> {
|
|
128
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
129
|
+
// Job may have already been aborted or never started properly
|
|
130
|
+
this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.log.debug(`Aborting job ${jobId}`);
|
|
134
|
+
|
|
135
|
+
for (const store of this.#stores.values()) {
|
|
136
|
+
await store.discardStaged(jobId);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.#currentJobId = undefined;
|
|
140
|
+
this.log.debug(`Job ${jobId} aborted`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Checks if there's a job currently in progress.
|
|
145
|
+
*/
|
|
146
|
+
hasJobInProgress(): boolean {
|
|
147
|
+
return this.#currentJobId !== undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
package/src/logs/log_service.ts
CHANGED
|
@@ -26,6 +26,7 @@ export class LogService {
|
|
|
26
26
|
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
27
27
|
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
28
28
|
private readonly addressStore: AddressStore,
|
|
29
|
+
private readonly jobId: string,
|
|
29
30
|
) {}
|
|
30
31
|
|
|
31
32
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
@@ -122,6 +123,7 @@ export class LogService {
|
|
|
122
123
|
this.aztecNode,
|
|
123
124
|
this.recipientTaggingStore,
|
|
124
125
|
anchorBlockNumber,
|
|
126
|
+
this.jobId,
|
|
125
127
|
),
|
|
126
128
|
),
|
|
127
129
|
);
|
|
@@ -186,7 +188,7 @@ export class LogService {
|
|
|
186
188
|
});
|
|
187
189
|
|
|
188
190
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
189
|
-
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
191
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
4
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
4
5
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
5
6
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
6
7
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
@@ -41,7 +42,7 @@ export class NoteService {
|
|
|
41
42
|
scopes,
|
|
42
43
|
});
|
|
43
44
|
return noteDaos.map(
|
|
44
|
-
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier
|
|
45
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
45
46
|
contractAddress,
|
|
46
47
|
owner,
|
|
47
48
|
storageSlot,
|
|
@@ -49,9 +50,8 @@ export class NoteService {
|
|
|
49
50
|
noteNonce,
|
|
50
51
|
note,
|
|
51
52
|
noteHash,
|
|
53
|
+
isPending: false, // Note service deals only with settled notes
|
|
52
54
|
siloedNullifier,
|
|
53
|
-
// PXE can use this index to get full MembershipWitness
|
|
54
|
-
index,
|
|
55
55
|
}),
|
|
56
56
|
);
|
|
57
57
|
}
|
|
@@ -69,7 +69,7 @@ export class NoteService {
|
|
|
69
69
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
70
70
|
*/
|
|
71
71
|
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
72
|
-
const
|
|
72
|
+
const anchorBlockHash = L2BlockHash.fromField(await (await this.anchorBlockStore.getBlockHeader()).hash());
|
|
73
73
|
|
|
74
74
|
const contractNotes = await this.noteStore.getNotes({ contractAddress });
|
|
75
75
|
|
|
@@ -92,7 +92,7 @@ export class NoteService {
|
|
|
92
92
|
const nullifierIndexes = (
|
|
93
93
|
await Promise.all(
|
|
94
94
|
nullifierBatches.map(batch =>
|
|
95
|
-
this.aztecNode.findLeavesIndexes(
|
|
95
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
|
|
96
96
|
),
|
|
97
97
|
)
|
|
98
98
|
).flat();
|
|
@@ -108,7 +108,7 @@ export class NoteService {
|
|
|
108
108
|
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
public async
|
|
111
|
+
public async storeNote(
|
|
112
112
|
contractAddress: AztecAddress,
|
|
113
113
|
owner: AztecAddress,
|
|
114
114
|
storageSlot: Fr,
|
|
@@ -139,41 +139,33 @@ export class NoteService {
|
|
|
139
139
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
140
140
|
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
141
141
|
// logs up to the synced block making this only an additional safety check.
|
|
142
|
-
const
|
|
142
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
143
|
+
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
144
|
+
const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
|
|
143
145
|
|
|
144
146
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
145
147
|
// of other contracts, which would constitute a security breach.
|
|
146
148
|
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
147
149
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
148
150
|
|
|
149
|
-
const txEffect = await
|
|
151
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
152
|
+
this.aztecNode.getTxEffect(txHash),
|
|
153
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
154
|
+
]);
|
|
150
155
|
if (!txEffect) {
|
|
151
156
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
if (txEffect.l2BlockNumber >
|
|
155
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
159
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
160
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
164
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
|
|
165
|
+
if (noteIndexInTx === -1) {
|
|
160
166
|
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
161
167
|
}
|
|
162
168
|
|
|
163
|
-
// We store notes by their index in the global note hash tree, which has the convenient side effect of validating
|
|
164
|
-
// note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
|
|
165
|
-
// queries in a single round-trip.
|
|
166
|
-
const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
|
|
167
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]),
|
|
168
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
|
-
if (uniqueNoteHashTreeIndexInBlock === undefined) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
169
|
const noteDao = new NoteDao(
|
|
178
170
|
new Note(content),
|
|
179
171
|
contractAddress,
|
|
@@ -184,15 +176,17 @@ export class NoteService {
|
|
|
184
176
|
noteHash,
|
|
185
177
|
siloedNullifier,
|
|
186
178
|
txHash,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
179
|
+
txEffect.l2BlockNumber,
|
|
180
|
+
txEffect.l2BlockHash.toString(),
|
|
181
|
+
txEffect.txIndexInBlock,
|
|
182
|
+
noteIndexInTx,
|
|
190
183
|
);
|
|
191
184
|
|
|
192
185
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
193
186
|
await this.noteStore.addNotes([noteDao], recipient);
|
|
194
187
|
|
|
195
188
|
if (nullifierIndex !== undefined) {
|
|
189
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
196
190
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
197
191
|
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
198
192
|
}
|
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 = 6;
|
|
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 = 'cc2a1f26a3b39ef194d710f94683929f63939d725f10b4fe2c82749a47a74c7b';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
2
|
export * from './compute_tx_include_by_timestamp.js';
|
|
@@ -138,7 +138,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
async build(oracle: PrivateKernelOracle
|
|
141
|
+
async build(oracle: PrivateKernelOracle) {
|
|
142
142
|
if (privateKernelResetDimensionNames.every(name => !this.requestedDimensions[name])) {
|
|
143
143
|
throw new Error('Reset is not required.');
|
|
144
144
|
}
|
|
@@ -157,16 +157,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
157
157
|
allowRemainder,
|
|
158
158
|
);
|
|
159
159
|
|
|
160
|
-
const previousVkMembershipWitness = await oracle.getVkMembershipWitness(
|
|
161
|
-
this.previousKernelOutput.verificationKey.keyAsFields,
|
|
162
|
-
);
|
|
163
|
-
const vkData = new VkData(
|
|
164
|
-
this.previousKernelOutput.verificationKey,
|
|
165
|
-
Number(previousVkMembershipWitness.leafIndex),
|
|
166
|
-
previousVkMembershipWitness.siblingPath,
|
|
167
|
-
);
|
|
168
|
-
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
169
|
-
|
|
170
160
|
this.reduceReadRequestActions(
|
|
171
161
|
this.noteHashResetActions,
|
|
172
162
|
dimensions.NOTE_HASH_PENDING_READ,
|
|
@@ -178,30 +168,51 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
178
168
|
dimensions.NULLIFIER_SETTLED_READ,
|
|
179
169
|
);
|
|
180
170
|
|
|
181
|
-
//
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
171
|
+
// Execute all the expensive node querying operations in parallel.
|
|
172
|
+
const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] =
|
|
173
|
+
await Promise.all([
|
|
174
|
+
oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
|
|
175
|
+
buildNoteHashReadRequestHintsFromResetActions<
|
|
176
|
+
typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
177
|
+
typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX
|
|
178
|
+
>(
|
|
189
179
|
oracle,
|
|
190
180
|
this.previousKernel.validationRequests.noteHashReadRequests,
|
|
191
181
|
this.previousKernel.end.noteHashes,
|
|
192
182
|
this.noteHashResetActions,
|
|
193
|
-
noteHashLeafIndexMap,
|
|
194
183
|
),
|
|
195
|
-
|
|
184
|
+
buildNullifierReadRequestHintsFromResetActions<
|
|
185
|
+
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
186
|
+
typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX
|
|
187
|
+
>(
|
|
196
188
|
{ getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle) },
|
|
197
189
|
this.previousKernel.validationRequests.nullifierReadRequests,
|
|
198
190
|
this.nullifierResetActions,
|
|
199
191
|
),
|
|
200
|
-
|
|
192
|
+
getMasterSecretKeysAndAppKeyGenerators(
|
|
201
193
|
this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators,
|
|
202
194
|
dimensions.KEY_VALIDATION,
|
|
203
195
|
oracle,
|
|
204
196
|
),
|
|
197
|
+
]);
|
|
198
|
+
|
|
199
|
+
const vkData = new VkData(
|
|
200
|
+
this.previousKernelOutput.verificationKey,
|
|
201
|
+
Number(previousVkMembershipWitness.leafIndex),
|
|
202
|
+
previousVkMembershipWitness.siblingPath,
|
|
203
|
+
);
|
|
204
|
+
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
205
|
+
|
|
206
|
+
// TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
|
|
207
|
+
const paddedSideEffects = PaddedSideEffects.empty();
|
|
208
|
+
|
|
209
|
+
return new PrivateKernelResetCircuitPrivateInputs(
|
|
210
|
+
previousKernelData,
|
|
211
|
+
paddedSideEffects,
|
|
212
|
+
new PrivateKernelResetHints(
|
|
213
|
+
noteHashReadRequestHints,
|
|
214
|
+
nullifierReadRequestHints,
|
|
215
|
+
keyValidationHints,
|
|
205
216
|
this.transientDataSquashingHints,
|
|
206
217
|
),
|
|
207
218
|
dimensions,
|
|
@@ -28,13 +28,12 @@ import {
|
|
|
28
28
|
type PrivateCallExecutionResult,
|
|
29
29
|
type PrivateExecutionResult,
|
|
30
30
|
TxRequest,
|
|
31
|
-
collectNoteHashLeafIndexMap,
|
|
32
31
|
collectNoteHashNullifierCounterMap,
|
|
33
32
|
getFinalMinRevertibleSideEffectCounter,
|
|
34
33
|
} from '@aztec/stdlib/tx';
|
|
35
34
|
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
36
35
|
|
|
37
|
-
import { PrivateKernelResetPrivateInputsBuilder } from './hints/
|
|
36
|
+
import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
|
|
38
37
|
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
39
38
|
|
|
40
39
|
const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
|
|
@@ -101,7 +100,6 @@ export class PrivateKernelExecutionProver {
|
|
|
101
100
|
|
|
102
101
|
const executionSteps: PrivateExecutionStep[] = [];
|
|
103
102
|
|
|
104
|
-
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
105
103
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
106
104
|
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
107
105
|
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
@@ -116,7 +114,7 @@ export class PrivateKernelExecutionProver {
|
|
|
116
114
|
);
|
|
117
115
|
while (resetBuilder.needsReset()) {
|
|
118
116
|
const witgenTimer = new Timer();
|
|
119
|
-
const privateInputs = await resetBuilder.build(this.oracle
|
|
117
|
+
const privateInputs = await resetBuilder.build(this.oracle);
|
|
120
118
|
output = generateWitnesses
|
|
121
119
|
? await this.proofCreator.generateResetOutput(privateInputs)
|
|
122
120
|
: await this.proofCreator.simulateReset(privateInputs);
|
|
@@ -224,7 +222,7 @@ export class PrivateKernelExecutionProver {
|
|
|
224
222
|
);
|
|
225
223
|
while (resetBuilder.needsReset()) {
|
|
226
224
|
const witgenTimer = new Timer();
|
|
227
|
-
const privateInputs = await resetBuilder.build(this.oracle
|
|
225
|
+
const privateInputs = await resetBuilder.build(this.oracle);
|
|
228
226
|
output = generateWitnesses
|
|
229
227
|
? await this.proofCreator.generateResetOutput(privateInputs)
|
|
230
228
|
: await this.proofCreator.simulateReset(privateInputs);
|
|
@@ -1,72 +1,152 @@
|
|
|
1
|
-
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
1
|
+
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
6
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
7
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
8
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
11
|
+
import {
|
|
12
|
+
type ContractInstanceWithAddress,
|
|
13
|
+
computeContractClassIdPreimage,
|
|
14
|
+
computeSaltedInitializationHash,
|
|
15
|
+
} from '@aztec/stdlib/contract';
|
|
16
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
17
|
+
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
18
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
19
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
8
|
-
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
9
20
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
10
21
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
11
22
|
|
|
23
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
24
|
+
|
|
12
25
|
/**
|
|
13
26
|
* Provides functionality needed by the private kernel for interacting with our state trees.
|
|
14
|
-
* This is either PrivateKernelOracleImpl, or a mocked test implementation.
|
|
15
27
|
*/
|
|
16
|
-
export
|
|
28
|
+
export class PrivateKernelOracle {
|
|
29
|
+
constructor(
|
|
30
|
+
private contractStore: ContractStore,
|
|
31
|
+
private keyStore: KeyStore,
|
|
32
|
+
private node: AztecNode,
|
|
33
|
+
private blockHash: L2BlockHash,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
17
36
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
|
18
|
-
getContractAddressPreimage(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
public async getContractAddressPreimage(
|
|
38
|
+
address: AztecAddress,
|
|
39
|
+
): Promise<ContractInstanceWithAddress & { saltedInitializationHash: Fr }> {
|
|
40
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
41
|
+
if (!instance) {
|
|
42
|
+
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
46
|
+
...instance,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
24
49
|
|
|
25
50
|
/** Retrieves the preimage of a contract class id from the contract classes db. */
|
|
26
|
-
getContractClassIdPreimage(
|
|
27
|
-
contractClassId
|
|
28
|
-
|
|
51
|
+
public async getContractClassIdPreimage(contractClassId: Fr) {
|
|
52
|
+
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
53
|
+
if (!contractClass) {
|
|
54
|
+
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
55
|
+
}
|
|
56
|
+
return computeContractClassIdPreimage(contractClass);
|
|
57
|
+
}
|
|
29
58
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
getFunctionMembershipWitness(
|
|
59
|
+
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
|
|
60
|
+
public async getFunctionMembershipWitness(
|
|
34
61
|
contractClassId: Fr,
|
|
35
62
|
selector: FunctionSelector,
|
|
36
|
-
): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT
|
|
63
|
+
): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
|
|
64
|
+
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
65
|
+
if (!membershipWitness) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return membershipWitness;
|
|
71
|
+
}
|
|
37
72
|
|
|
38
73
|
/**
|
|
39
74
|
* Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
|
|
40
75
|
* Used to validate the previous kernel's verification key.
|
|
41
76
|
*/
|
|
42
|
-
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT
|
|
77
|
+
public getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>> {
|
|
78
|
+
const leafIndex = getVKIndex(vk);
|
|
79
|
+
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
80
|
+
}
|
|
43
81
|
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
82
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
|
|
83
|
+
getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
84
|
+
return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
|
|
85
|
+
}
|
|
47
86
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
|
|
88
|
+
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
|
|
89
|
+
return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Returns the root of our note hash merkle tree. */
|
|
93
|
+
async getNoteHashTreeRoot(): Promise<Fr> {
|
|
94
|
+
const header = await this.node.getBlockHeader(this.blockHash);
|
|
95
|
+
if (!header) {
|
|
96
|
+
throw new Error(`No block header found for block hash ${this.blockHash}`);
|
|
97
|
+
}
|
|
98
|
+
return header.state.partial.noteHashTree.root;
|
|
99
|
+
}
|
|
56
100
|
|
|
57
101
|
/**
|
|
58
102
|
* Retrieves the sk_m corresponding to the pk_m.
|
|
59
103
|
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
60
|
-
* @param
|
|
104
|
+
* @param masterPublicKey - The master public key to get secret key for.
|
|
61
105
|
* @returns A Promise that resolves to sk_m.
|
|
62
106
|
* @dev Used when feeding the sk_m to the kernel circuit for keys verification.
|
|
63
107
|
*/
|
|
64
|
-
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar
|
|
108
|
+
public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
|
|
109
|
+
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
110
|
+
}
|
|
65
111
|
|
|
66
112
|
/** Use debug data to get the function name corresponding to a selector. */
|
|
67
|
-
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined
|
|
113
|
+
public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
114
|
+
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns a membership witness and leaf index to our public data indexed merkle tree,
|
|
119
|
+
* along with an associated DelayedPublicMutable containing the class ID to update.
|
|
120
|
+
*/
|
|
121
|
+
public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
|
|
122
|
+
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
|
|
123
|
+
await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
124
|
+
|
|
125
|
+
const hashLeafSlot = await computePublicDataTreeLeafSlot(
|
|
126
|
+
ProtocolContractAddress.ContractInstanceRegistry,
|
|
127
|
+
delayedPublicMutableHashSlot,
|
|
128
|
+
);
|
|
129
|
+
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
|
|
130
|
+
|
|
131
|
+
if (!updatedClassIdWitness) {
|
|
132
|
+
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const readStorage = (storageSlot: Fr) =>
|
|
136
|
+
this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
137
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
|
|
138
|
+
delayedPublicMutableSlot,
|
|
139
|
+
readStorage,
|
|
140
|
+
);
|
|
68
141
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
142
|
+
return new UpdatedClassIdHints(
|
|
143
|
+
new MembershipWitness(
|
|
144
|
+
PUBLIC_DATA_TREE_HEIGHT,
|
|
145
|
+
updatedClassIdWitness.index,
|
|
146
|
+
updatedClassIdWitness.siblingPath.toTuple(),
|
|
147
|
+
),
|
|
148
|
+
updatedClassIdWitness.leafPreimage,
|
|
149
|
+
delayedPublicMutableValues,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
72
152
|
}
|