@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +62 -16
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +175 -74
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -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 +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +51 -29
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +86 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +62 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +107 -88
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- 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 +21 -7
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- 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 +4 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +28 -9
- package/dest/events/event_service.d.ts +5 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +6 -7
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +28 -32
- package/dest/notes/note_service.d.ts +9 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -16
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +69 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +104 -67
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.js +6 -8
- package/dest/storage/contract_store/contract_store.d.ts +42 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -84
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +47 -49
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +278 -252
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +198 -147
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- 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/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
- 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 +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- 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 +20 -18
- package/package.json +25 -16
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +76 -33
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +324 -137
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
- package/src/contract_function_simulator/oracle/oracle.ts +56 -26
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -110
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +172 -95
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +3 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +5 -7
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +48 -39
- package/src/notes/note_service.ts +24 -22
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +25 -15
- package/src/private_kernel/private_kernel_oracle.ts +9 -9
- package/src/pxe.ts +211 -112
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +8 -8
- package/src/storage/contract_store/contract_store.ts +186 -96
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +321 -318
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +250 -190
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +214 -130
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +17 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -9
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +23 -23
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.d.ts +0 -50
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -75
- package/src/tree_membership/tree_membership_service.ts +0 -97
package/src/logs/log_service.ts
CHANGED
|
@@ -1,40 +1,53 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
ExtendedDirectionalAppTaggingSecret,
|
|
8
|
+
PendingTaggedLog,
|
|
9
|
+
SiloedTag,
|
|
10
|
+
Tag,
|
|
11
|
+
TxScopedL2Log,
|
|
12
|
+
} from '@aztec/stdlib/logs';
|
|
13
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
14
|
+
|
|
15
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
9
16
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
17
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
18
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
13
19
|
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
20
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
21
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
16
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
getAllPrivateLogsByTags,
|
|
24
|
+
getAllPublicLogsByTagsFromContract,
|
|
25
|
+
loadPrivateLogsForSenderRecipientPair,
|
|
26
|
+
} from '../tagging/index.js';
|
|
17
27
|
|
|
18
28
|
export class LogService {
|
|
19
|
-
private log
|
|
29
|
+
private log: Logger;
|
|
20
30
|
|
|
21
31
|
constructor(
|
|
22
32
|
private readonly aztecNode: AztecNode,
|
|
23
|
-
private readonly
|
|
33
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
24
34
|
private readonly keyStore: KeyStore,
|
|
25
35
|
private readonly capsuleStore: CapsuleStore,
|
|
26
36
|
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
27
37
|
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
28
38
|
private readonly addressStore: AddressStore,
|
|
29
39
|
private readonly jobId: string,
|
|
30
|
-
|
|
40
|
+
bindings?: LoggerBindings,
|
|
41
|
+
) {
|
|
42
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
43
|
+
}
|
|
31
44
|
|
|
32
45
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
33
46
|
return await Promise.all(
|
|
34
47
|
logRetrievalRequests.map(async request => {
|
|
35
48
|
const [publicLog, privateLog] = await Promise.all([
|
|
36
49
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
37
|
-
this.#getPrivateLogByTag(await SiloedTag.
|
|
50
|
+
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
|
|
38
51
|
]);
|
|
39
52
|
|
|
40
53
|
if (publicLog !== null && privateLog !== null) {
|
|
@@ -49,10 +62,16 @@ export class LogService {
|
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
65
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
66
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
67
|
+
this.aztecNode,
|
|
68
|
+
contractAddress,
|
|
69
|
+
[tag],
|
|
70
|
+
anchorBlockHash,
|
|
71
|
+
);
|
|
72
|
+
const logsForTag = allLogsPerTag[0];
|
|
54
73
|
|
|
55
|
-
if (logsForTag.length
|
|
74
|
+
if (logsForTag.length === 0) {
|
|
56
75
|
return null;
|
|
57
76
|
} else if (logsForTag.length > 1) {
|
|
58
77
|
// TODO(#11627): handle this case
|
|
@@ -72,10 +91,11 @@ export class LogService {
|
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
94
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
95
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
96
|
+
const logsForTag = allLogsPerTag[0];
|
|
77
97
|
|
|
78
|
-
if (logsForTag.length
|
|
98
|
+
if (logsForTag.length === 0) {
|
|
79
99
|
return null;
|
|
80
100
|
} else if (logsForTag.length > 1) {
|
|
81
101
|
// TODO(#11627): handle this case
|
|
@@ -94,18 +114,15 @@ export class LogService {
|
|
|
94
114
|
);
|
|
95
115
|
}
|
|
96
116
|
|
|
97
|
-
public async
|
|
98
|
-
contractAddress
|
|
99
|
-
pendingTaggedLogArrayBaseSlot: Fr,
|
|
100
|
-
scopes?: AztecAddress[],
|
|
101
|
-
) {
|
|
102
|
-
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
117
|
+
public async fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes) {
|
|
118
|
+
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
103
119
|
|
|
104
120
|
// We only load logs from block up to and including the anchor block number
|
|
105
|
-
const anchorBlockNumber =
|
|
121
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
122
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
106
123
|
|
|
107
124
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
108
|
-
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
125
|
+
const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
109
126
|
|
|
110
127
|
// For each recipient, fetch secrets, load logs, and store them.
|
|
111
128
|
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
@@ -119,10 +136,10 @@ export class LogService {
|
|
|
119
136
|
secrets.map(secret =>
|
|
120
137
|
loadPrivateLogsForSenderRecipientPair(
|
|
121
138
|
secret,
|
|
122
|
-
contractAddress,
|
|
123
139
|
this.aztecNode,
|
|
124
140
|
this.recipientTaggingStore,
|
|
125
141
|
anchorBlockNumber,
|
|
142
|
+
anchorBlockHash,
|
|
126
143
|
this.jobId,
|
|
127
144
|
),
|
|
128
145
|
),
|
|
@@ -142,8 +159,11 @@ export class LogService {
|
|
|
142
159
|
async #getSecretsForSenders(
|
|
143
160
|
contractAddress: AztecAddress,
|
|
144
161
|
recipient: AztecAddress,
|
|
145
|
-
): Promise<
|
|
146
|
-
const recipientCompleteAddress = await this
|
|
162
|
+
): Promise<ExtendedDirectionalAppTaggingSecret[]> {
|
|
163
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
164
|
+
if (!recipientCompleteAddress) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
147
167
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
148
168
|
|
|
149
169
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -157,7 +177,7 @@ export class LogService {
|
|
|
157
177
|
|
|
158
178
|
return Promise.all(
|
|
159
179
|
deduplicatedSenders.map(sender => {
|
|
160
|
-
return
|
|
180
|
+
return ExtendedDirectionalAppTaggingSecret.compute(
|
|
161
181
|
recipientCompleteAddress,
|
|
162
182
|
recipientIvsk,
|
|
163
183
|
sender,
|
|
@@ -190,15 +210,4 @@ export class LogService {
|
|
|
190
210
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
191
211
|
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
192
212
|
}
|
|
193
|
-
|
|
194
|
-
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
195
|
-
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
196
|
-
if (!completeAddress) {
|
|
197
|
-
throw new Error(
|
|
198
|
-
`No public key registered for address ${account}.
|
|
199
|
-
Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
return completeAddress;
|
|
203
|
-
}
|
|
204
213
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
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';
|
|
5
4
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
6
5
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
8
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
10
9
|
|
|
11
|
-
import type {
|
|
10
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
12
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
13
12
|
|
|
14
13
|
export class NoteService {
|
|
15
14
|
constructor(
|
|
16
15
|
private readonly noteStore: NoteStore,
|
|
17
16
|
private readonly aztecNode: AztecNode,
|
|
18
|
-
private readonly
|
|
17
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
18
|
+
private readonly jobId: string,
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -32,15 +32,18 @@ export class NoteService {
|
|
|
32
32
|
owner: AztecAddress | undefined,
|
|
33
33
|
storageSlot: Fr,
|
|
34
34
|
status: NoteStatus,
|
|
35
|
-
scopes
|
|
35
|
+
scopes: AccessScopes,
|
|
36
36
|
) {
|
|
37
|
-
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
+
{
|
|
39
|
+
contractAddress,
|
|
40
|
+
owner,
|
|
41
|
+
storageSlot,
|
|
42
|
+
status,
|
|
43
|
+
scopes,
|
|
44
|
+
},
|
|
45
|
+
this.jobId,
|
|
46
|
+
);
|
|
44
47
|
return noteDaos.map(
|
|
45
48
|
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
46
49
|
contractAddress,
|
|
@@ -68,10 +71,10 @@ export class NoteService {
|
|
|
68
71
|
*
|
|
69
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
70
73
|
*/
|
|
71
|
-
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
72
|
-
const anchorBlockHash =
|
|
74
|
+
public async syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void> {
|
|
75
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
73
76
|
|
|
74
|
-
const contractNotes = await this.noteStore.getNotes({ contractAddress });
|
|
77
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress, scopes }, this.jobId);
|
|
75
78
|
|
|
76
79
|
if (contractNotes.length === 0) {
|
|
77
80
|
return;
|
|
@@ -105,10 +108,10 @@ export class NoteService {
|
|
|
105
108
|
})
|
|
106
109
|
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
107
110
|
|
|
108
|
-
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
111
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
public async
|
|
114
|
+
public async validateAndStoreNote(
|
|
112
115
|
contractAddress: AztecAddress,
|
|
113
116
|
owner: AztecAddress,
|
|
114
117
|
storageSlot: Fr,
|
|
@@ -139,9 +142,8 @@ export class NoteService {
|
|
|
139
142
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
140
143
|
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
141
144
|
// logs up to the synced block making this only an additional safety check.
|
|
142
|
-
const
|
|
143
|
-
const
|
|
144
|
-
const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
|
|
145
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
146
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
145
147
|
|
|
146
148
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
147
149
|
// of other contracts, which would constitute a security breach.
|
|
@@ -183,12 +185,12 @@ export class NoteService {
|
|
|
183
185
|
);
|
|
184
186
|
|
|
185
187
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
186
|
-
await this.noteStore.addNotes([noteDao], recipient);
|
|
188
|
+
await this.noteStore.addNotes([noteDao], recipient, this.jobId);
|
|
187
189
|
|
|
188
190
|
if (nullifierIndex !== undefined) {
|
|
189
191
|
// We found nullifier index which implies that the note has already been nullified.
|
|
190
192
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
191
|
-
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
193
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
4
|
+
|
|
5
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A filter used to fetch notes.
|
|
9
|
+
* @remarks This filter is applied as an intersection of all its params.
|
|
10
|
+
*/
|
|
11
|
+
export type NotesFilter = {
|
|
12
|
+
/**
|
|
13
|
+
* The contract address the note belongs to.
|
|
14
|
+
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
15
|
+
*/
|
|
16
|
+
contractAddress: AztecAddress;
|
|
17
|
+
/** The owner of the note. */
|
|
18
|
+
owner?: AztecAddress;
|
|
19
|
+
/** The specific storage location of the note on the contract. */
|
|
20
|
+
storageSlot?: Fr;
|
|
21
|
+
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
22
|
+
status?: NoteStatus;
|
|
23
|
+
/** The siloed nullifier for the note. */
|
|
24
|
+
siloedNullifier?: Fr;
|
|
25
|
+
scopes: AccessScopes;
|
|
26
|
+
};
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
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 = 12;
|
|
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
|
-
/// which in turn implies that you need to update the ORACLE_VERSION constant
|
|
11
|
-
|
|
10
|
+
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
|
+
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = '666a8a7fc697f72b29dbf0ae7464db269cf5afa019acac8861f814543147dbb4';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_TX_LIFETIME } from '@aztec/constants';
|
|
2
2
|
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
3
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
4
|
|
|
@@ -8,12 +8,12 @@ const ROUNDED_DURATIONS = [
|
|
|
8
8
|
1, // 1 second
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
-
function roundTimestamp(blockTimestamp: bigint,
|
|
11
|
+
function roundTimestamp(blockTimestamp: bigint, expirationTimestamp: bigint): UInt64 {
|
|
12
12
|
return ROUNDED_DURATIONS.reduce((timestamp, duration) => {
|
|
13
13
|
if (timestamp <= blockTimestamp) {
|
|
14
14
|
// The timestamp must be greater than the block timestamp.
|
|
15
15
|
// If it is too small, round it down again using a smaller duration.
|
|
16
|
-
const totalDuration =
|
|
16
|
+
const totalDuration = expirationTimestamp - blockTimestamp;
|
|
17
17
|
const roundedDuration = totalDuration - (totalDuration % BigInt(duration));
|
|
18
18
|
return blockTimestamp + roundedDuration;
|
|
19
19
|
}
|
|
@@ -21,36 +21,36 @@ function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UIn
|
|
|
21
21
|
}, 0n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function computeTxExpirationTimestamp(
|
|
25
25
|
previousKernel: PrivateKernelCircuitPublicInputs,
|
|
26
|
-
|
|
26
|
+
txLifetime = MAX_TX_LIFETIME,
|
|
27
27
|
): UInt64 {
|
|
28
|
-
if (
|
|
28
|
+
if (txLifetime > MAX_TX_LIFETIME) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Custom
|
|
30
|
+
`Custom tx lifetime cannot be greater than the max allowed. Max allowed: ${MAX_TX_LIFETIME}. Custom value: ${txLifetime}.`,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
35
|
-
const maxTimestamp = anchorBlockTimestamp + BigInt(
|
|
36
|
-
const
|
|
35
|
+
const maxTimestamp = anchorBlockTimestamp + BigInt(txLifetime);
|
|
36
|
+
const expirationTimestamp = previousKernel.expirationTimestamp;
|
|
37
37
|
|
|
38
|
-
// If the
|
|
38
|
+
// If the expirationTimestamp set during the tx execution is greater than or equal to the max allowed duration,
|
|
39
39
|
// use the maximum allowed timestamp.
|
|
40
40
|
// Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
|
|
41
|
-
if (
|
|
41
|
+
if (expirationTimestamp >= maxTimestamp) {
|
|
42
42
|
return maxTimestamp;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
|
|
46
46
|
// This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
|
|
47
|
-
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp,
|
|
47
|
+
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, expirationTimestamp);
|
|
48
48
|
|
|
49
49
|
// The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
|
|
50
50
|
// Future blocks will have a greater timestamp, so the tx would never be included.
|
|
51
51
|
if (roundedTimestamp <= anchorBlockTimestamp) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
53
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestamp}.`,
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './compute_tx_expiration_timestamp.js';
|