@aztec/pxe 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d52e
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 +11 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -21
- 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/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 +57 -35
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +198 -84
- 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/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/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +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.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/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 +17 -13
- 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 +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +97 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +66 -33
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +130 -111
- 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 +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -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 +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- 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 +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 +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +31 -33
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- 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 +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- 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} +15 -9
- 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 +9 -9
- package/dest/private_kernel/private_kernel_oracle.d.ts +23 -24
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +75 -58
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +124 -132
- 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.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- 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 +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- 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 +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +226 -111
- 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 +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -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 +20 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +253 -101
- 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 +11 -11
- 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 +8 -11
- 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 +7 -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 +23 -19
- package/package.json +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +91 -33
- package/src/config/index.ts +14 -0
- 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 +356 -148
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/index.ts +1 -1
- 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/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -67
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +137 -111
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +197 -116
- 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 +4 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +17 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +51 -40
- package/src/notes/note_service.ts +41 -45
- 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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +38 -26
- package/src/private_kernel/private_kernel_execution_prover.ts +13 -10
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +235 -209
- 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 +159 -23
- 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 +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +292 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +296 -111
- 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 +22 -14
- 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 +12 -14
- 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 +26 -23
- 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/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/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 -85
- 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/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -3,20 +3,19 @@ import type { EventSelector } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import {
|
|
7
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
8
7
|
|
|
9
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
10
8
|
import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
11
9
|
|
|
12
10
|
export class EventService {
|
|
13
11
|
constructor(
|
|
14
|
-
private readonly
|
|
12
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
15
13
|
private readonly aztecNode: AztecNode,
|
|
16
14
|
private readonly privateEventStore: PrivateEventStore,
|
|
15
|
+
private readonly jobId: string,
|
|
17
16
|
) {}
|
|
18
17
|
|
|
19
|
-
public async
|
|
18
|
+
public async validateAndStoreEvent(
|
|
20
19
|
contractAddress: AztecAddress,
|
|
21
20
|
selector: EventSelector,
|
|
22
21
|
randomness: Fr,
|
|
@@ -29,51 +28,44 @@ export class EventService {
|
|
|
29
28
|
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
30
29
|
// maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
|
|
31
30
|
// since `fetchTaggedLogs` only processes logs up to the synced block.
|
|
32
|
-
const [
|
|
33
|
-
this.anchorBlockStore.getBlockHeader(),
|
|
31
|
+
const [siloedEventCommitment, txEffect] = await Promise.all([
|
|
34
32
|
siloNullifier(contractAddress, eventCommitment),
|
|
35
33
|
this.aztecNode.getTxEffect(txHash),
|
|
36
34
|
]);
|
|
37
35
|
|
|
38
|
-
const
|
|
36
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
39
37
|
|
|
40
38
|
if (!txEffect) {
|
|
41
39
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
if (txEffect.l2BlockNumber >
|
|
45
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
42
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
43
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
// Find the index of the event commitment in the nullifiers array to determine event ordering within the tx
|
|
47
|
+
const eventIndexInTx = txEffect.data.nullifiers.findIndex(n => n.equals(siloedEventCommitment));
|
|
48
|
+
if (eventIndexInTx === -1) {
|
|
50
49
|
throw new Error(
|
|
51
50
|
`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present in tx ${txHash}`,
|
|
52
51
|
);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
const [nullifierIndex] = await this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
|
|
56
|
-
siloedEventCommitment,
|
|
57
|
-
]);
|
|
58
|
-
|
|
59
|
-
if (nullifierIndex === undefined) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present on the nullifier tree at block ${syncedBlockNumber} (from tx ${txHash})`,
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
54
|
return this.privateEventStore.storePrivateEventLog(
|
|
66
55
|
selector,
|
|
67
56
|
randomness,
|
|
68
57
|
content,
|
|
69
|
-
|
|
58
|
+
siloedEventCommitment,
|
|
70
59
|
{
|
|
71
60
|
contractAddress,
|
|
72
61
|
scope,
|
|
73
62
|
txHash,
|
|
74
|
-
l2BlockNumber:
|
|
75
|
-
l2BlockHash:
|
|
63
|
+
l2BlockNumber: txEffect.l2BlockNumber,
|
|
64
|
+
l2BlockHash: txEffect.l2BlockHash,
|
|
65
|
+
txIndexInBlock: txEffect.txIndexInBlock,
|
|
66
|
+
eventIndexInTx,
|
|
76
67
|
},
|
|
68
|
+
this.jobId,
|
|
77
69
|
);
|
|
78
70
|
}
|
|
79
71
|
}
|
|
@@ -2,13 +2,12 @@ import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
|
2
2
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
3
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
|
|
5
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
6
5
|
import type { PrivateEventStoreFilter } from '../storage/private_event_store/private_event_store.js';
|
|
7
6
|
|
|
8
7
|
export class PrivateEventFilterValidator {
|
|
9
|
-
constructor(private
|
|
8
|
+
constructor(private lastBlock: BlockNumber) {}
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
validate(filter: PrivateEventFilter): PrivateEventStoreFilter {
|
|
12
11
|
let { fromBlock, toBlock } = filter;
|
|
13
12
|
|
|
14
13
|
// Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
|
|
@@ -16,9 +15,8 @@ export class PrivateEventFilterValidator {
|
|
|
16
15
|
// We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
|
|
17
16
|
// the first block to the latest known block.
|
|
18
17
|
if (!fromBlock || !toBlock) {
|
|
19
|
-
const lastKnownBlock = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
20
18
|
fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
|
|
21
|
-
toBlock = toBlock ?? BlockNumber(
|
|
19
|
+
toBlock = toBlock ?? BlockNumber(this.lastBlock + 1);
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
if (filter.scopes.length === 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -40,7 +40,7 @@ export interface StagedStore {
|
|
|
40
40
|
* using a job queue with concurrency=1.
|
|
41
41
|
*/
|
|
42
42
|
export class JobCoordinator {
|
|
43
|
-
private readonly log
|
|
43
|
+
private readonly log: Logger;
|
|
44
44
|
|
|
45
45
|
/** The underlying KV store */
|
|
46
46
|
kvStore: AztecAsyncKVStore;
|
|
@@ -48,8 +48,9 @@ export class JobCoordinator {
|
|
|
48
48
|
#currentJobId: string | undefined;
|
|
49
49
|
#stores: Map<string, StagedStore> = new Map();
|
|
50
50
|
|
|
51
|
-
constructor(kvStore: AztecAsyncKVStore) {
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings) {
|
|
52
52
|
this.kvStore = kvStore;
|
|
53
|
+
this.log = createLogger('pxe:job_coordinator', bindings);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
/**
|
package/src/logs/log_service.ts
CHANGED
|
@@ -1,39 +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,
|
|
40
|
+
bindings?: LoggerBindings,
|
|
41
|
+
) {
|
|
42
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
43
|
+
}
|
|
30
44
|
|
|
31
45
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
32
46
|
return await Promise.all(
|
|
33
47
|
logRetrievalRequests.map(async request => {
|
|
34
48
|
const [publicLog, privateLog] = await Promise.all([
|
|
35
49
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
36
|
-
this.#getPrivateLogByTag(await SiloedTag.
|
|
50
|
+
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
|
|
37
51
|
]);
|
|
38
52
|
|
|
39
53
|
if (publicLog !== null && privateLog !== null) {
|
|
@@ -48,10 +62,16 @@ export class LogService {
|
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
51
|
-
const
|
|
52
|
-
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];
|
|
53
73
|
|
|
54
|
-
if (logsForTag.length
|
|
74
|
+
if (logsForTag.length === 0) {
|
|
55
75
|
return null;
|
|
56
76
|
} else if (logsForTag.length > 1) {
|
|
57
77
|
// TODO(#11627): handle this case
|
|
@@ -71,10 +91,11 @@ export class LogService {
|
|
|
71
91
|
}
|
|
72
92
|
|
|
73
93
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
74
|
-
const
|
|
75
|
-
const
|
|
94
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
95
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
96
|
+
const logsForTag = allLogsPerTag[0];
|
|
76
97
|
|
|
77
|
-
if (logsForTag.length
|
|
98
|
+
if (logsForTag.length === 0) {
|
|
78
99
|
return null;
|
|
79
100
|
} else if (logsForTag.length > 1) {
|
|
80
101
|
// TODO(#11627): handle this case
|
|
@@ -93,18 +114,15 @@ export class LogService {
|
|
|
93
114
|
);
|
|
94
115
|
}
|
|
95
116
|
|
|
96
|
-
public async
|
|
97
|
-
contractAddress
|
|
98
|
-
pendingTaggedLogArrayBaseSlot: Fr,
|
|
99
|
-
scopes?: AztecAddress[],
|
|
100
|
-
) {
|
|
101
|
-
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()}`);
|
|
102
119
|
|
|
103
120
|
// We only load logs from block up to and including the anchor block number
|
|
104
|
-
const anchorBlockNumber =
|
|
121
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
122
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
105
123
|
|
|
106
124
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
107
|
-
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();
|
|
108
126
|
|
|
109
127
|
// For each recipient, fetch secrets, load logs, and store them.
|
|
110
128
|
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
@@ -118,10 +136,11 @@ export class LogService {
|
|
|
118
136
|
secrets.map(secret =>
|
|
119
137
|
loadPrivateLogsForSenderRecipientPair(
|
|
120
138
|
secret,
|
|
121
|
-
contractAddress,
|
|
122
139
|
this.aztecNode,
|
|
123
140
|
this.recipientTaggingStore,
|
|
124
141
|
anchorBlockNumber,
|
|
142
|
+
anchorBlockHash,
|
|
143
|
+
this.jobId,
|
|
125
144
|
),
|
|
126
145
|
),
|
|
127
146
|
);
|
|
@@ -140,8 +159,11 @@ export class LogService {
|
|
|
140
159
|
async #getSecretsForSenders(
|
|
141
160
|
contractAddress: AztecAddress,
|
|
142
161
|
recipient: AztecAddress,
|
|
143
|
-
): Promise<
|
|
144
|
-
const recipientCompleteAddress = await this
|
|
162
|
+
): Promise<ExtendedDirectionalAppTaggingSecret[]> {
|
|
163
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
164
|
+
if (!recipientCompleteAddress) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
145
167
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
146
168
|
|
|
147
169
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -155,7 +177,7 @@ export class LogService {
|
|
|
155
177
|
|
|
156
178
|
return Promise.all(
|
|
157
179
|
deduplicatedSenders.map(sender => {
|
|
158
|
-
return
|
|
180
|
+
return ExtendedDirectionalAppTaggingSecret.compute(
|
|
159
181
|
recipientCompleteAddress,
|
|
160
182
|
recipientIvsk,
|
|
161
183
|
sender,
|
|
@@ -186,17 +208,6 @@ export class LogService {
|
|
|
186
208
|
});
|
|
187
209
|
|
|
188
210
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
189
|
-
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
193
|
-
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
194
|
-
if (!completeAddress) {
|
|
195
|
-
throw new Error(
|
|
196
|
-
`No public key registered for address ${account}.
|
|
197
|
-
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`,
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
return completeAddress;
|
|
211
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
201
212
|
}
|
|
202
213
|
}
|
|
@@ -5,16 +5,17 @@ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdli
|
|
|
5
5
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
11
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
12
|
|
|
13
13
|
export class NoteService {
|
|
14
14
|
constructor(
|
|
15
15
|
private readonly noteStore: NoteStore,
|
|
16
16
|
private readonly aztecNode: AztecNode,
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
18
|
+
private readonly jobId: string,
|
|
18
19
|
) {}
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -31,17 +32,20 @@ export class NoteService {
|
|
|
31
32
|
owner: AztecAddress | undefined,
|
|
32
33
|
storageSlot: Fr,
|
|
33
34
|
status: NoteStatus,
|
|
34
|
-
scopes
|
|
35
|
+
scopes: AccessScopes,
|
|
35
36
|
) {
|
|
36
|
-
const noteDaos = await this.noteStore.getNotes(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
+
{
|
|
39
|
+
contractAddress,
|
|
40
|
+
owner,
|
|
41
|
+
storageSlot,
|
|
42
|
+
status,
|
|
43
|
+
scopes,
|
|
44
|
+
},
|
|
45
|
+
this.jobId,
|
|
46
|
+
);
|
|
43
47
|
return noteDaos.map(
|
|
44
|
-
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier
|
|
48
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
45
49
|
contractAddress,
|
|
46
50
|
owner,
|
|
47
51
|
storageSlot,
|
|
@@ -49,9 +53,8 @@ export class NoteService {
|
|
|
49
53
|
noteNonce,
|
|
50
54
|
note,
|
|
51
55
|
noteHash,
|
|
56
|
+
isPending: false, // Note service deals only with settled notes
|
|
52
57
|
siloedNullifier,
|
|
53
|
-
// PXE can use this index to get full MembershipWitness
|
|
54
|
-
index,
|
|
55
58
|
}),
|
|
56
59
|
);
|
|
57
60
|
}
|
|
@@ -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
|
|
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;
|
|
@@ -92,7 +95,7 @@ export class NoteService {
|
|
|
92
95
|
const nullifierIndexes = (
|
|
93
96
|
await Promise.all(
|
|
94
97
|
nullifierBatches.map(batch =>
|
|
95
|
-
this.aztecNode.findLeavesIndexes(
|
|
98
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
|
|
96
99
|
),
|
|
97
100
|
)
|
|
98
101
|
).flat();
|
|
@@ -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,41 +142,32 @@ 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
|
|
145
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
146
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
143
147
|
|
|
144
148
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
145
149
|
// of other contracts, which would constitute a security breach.
|
|
146
150
|
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
147
151
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
148
152
|
|
|
149
|
-
const txEffect = await
|
|
153
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
154
|
+
this.aztecNode.getTxEffect(txHash),
|
|
155
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
156
|
+
]);
|
|
150
157
|
if (!txEffect) {
|
|
151
158
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
152
159
|
}
|
|
153
160
|
|
|
154
|
-
if (txEffect.l2BlockNumber >
|
|
155
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
161
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
162
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
166
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
|
|
167
|
+
if (noteIndexInTx === -1) {
|
|
160
168
|
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
161
169
|
}
|
|
162
170
|
|
|
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
171
|
const noteDao = new NoteDao(
|
|
178
172
|
new Note(content),
|
|
179
173
|
contractAddress,
|
|
@@ -184,17 +178,19 @@ export class NoteService {
|
|
|
184
178
|
noteHash,
|
|
185
179
|
siloedNullifier,
|
|
186
180
|
txHash,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
txEffect.l2BlockNumber,
|
|
182
|
+
txEffect.l2BlockHash.toString(),
|
|
183
|
+
txEffect.txIndexInBlock,
|
|
184
|
+
noteIndexInTx,
|
|
190
185
|
);
|
|
191
186
|
|
|
192
187
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
193
|
-
await this.noteStore.addNotes([noteDao], recipient);
|
|
188
|
+
await this.noteStore.addNotes([noteDao], recipient, this.jobId);
|
|
194
189
|
|
|
195
190
|
if (nullifierIndex !== undefined) {
|
|
191
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
196
192
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
197
|
-
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
193
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
|
|
198
194
|
}
|
|
199
195
|
}
|
|
200
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
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
|
+
export * from './compute_tx_expiration_timestamp.js';
|