@aztec/pxe 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +66 -18
- 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 +8 -9
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +32 -21
- 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/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 +4 -3
- 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 +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +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 +15 -11
- 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 +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +43 -32
- 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 +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +11 -17
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +23 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +27 -17
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +72 -72
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +1 -1
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +3 -2
- 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 +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -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 +21 -13
- package/dest/notes/note_service.d.ts +5 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +30 -34
- 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/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 +70 -93
- 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 +1 -2
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +0 -12
- package/dest/storage/note_store/note_store.d.ts +45 -56
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +244 -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 +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +203 -68
- 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 +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/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 +46 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -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 +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- 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 +5 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -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 +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -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 +10 -5
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +77 -20
- 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 +37 -26
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -10
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +56 -41
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +39 -44
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +90 -76
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +3 -2
- 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 +2 -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 +27 -9
- package/src/notes/note_service.ts +37 -40
- package/src/oracle_version.ts +4 -3
- 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 +123 -127
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +0 -20
- package/src/storage/note_store/note_store.ts +286 -317
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +277 -76
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- 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/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +2 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +21 -7
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
- 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/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 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
2
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
4
5
|
|
|
5
6
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
6
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../
|
|
7
|
+
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
7
8
|
import { getStatusChangeOfPending } from './utils/get_status_change_of_pending.js';
|
|
8
9
|
import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_tagging_indexes.js';
|
|
9
10
|
|
|
@@ -26,6 +27,8 @@ export async function syncSenderTaggingIndexes(
|
|
|
26
27
|
app: AztecAddress,
|
|
27
28
|
aztecNode: AztecNode,
|
|
28
29
|
taggingStore: SenderTaggingStore,
|
|
30
|
+
anchorBlockHash: L2BlockHash,
|
|
31
|
+
jobId: string,
|
|
29
32
|
): Promise<void> {
|
|
30
33
|
// # Explanation of how syncing works
|
|
31
34
|
//
|
|
@@ -45,7 +48,7 @@ export async function syncSenderTaggingIndexes(
|
|
|
45
48
|
// Each window advance requires two queries (logs + tx status). For example, syncing indexes 0–500 with a window of
|
|
46
49
|
// 100 takes at least 10 round trips (5 windows × 2 queries).
|
|
47
50
|
|
|
48
|
-
const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
|
|
51
|
+
const finalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
|
|
49
52
|
|
|
50
53
|
let start = finalizedIndex === undefined ? 0 : finalizedIndex + 1;
|
|
51
54
|
let end = start + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN;
|
|
@@ -56,21 +59,21 @@ export async function syncSenderTaggingIndexes(
|
|
|
56
59
|
while (true) {
|
|
57
60
|
// Load and store indexes for the current window. These indexes may already exist in the database if txs using
|
|
58
61
|
// them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
|
|
59
|
-
await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore);
|
|
62
|
+
await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
|
|
60
63
|
|
|
61
64
|
// Retrieve all indexes within the current window from storage and update their status accordingly.
|
|
62
|
-
const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end);
|
|
65
|
+
const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
|
|
63
66
|
if (pendingTxHashes.length === 0) {
|
|
64
67
|
break;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
|
|
68
71
|
|
|
69
|
-
await taggingStore.dropPendingIndexes(txHashesToDrop);
|
|
70
|
-
await taggingStore.finalizePendingIndexes(txHashesToFinalize);
|
|
72
|
+
await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
|
|
73
|
+
await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
|
|
71
74
|
|
|
72
75
|
// We check if the finalized index has been updated.
|
|
73
|
-
newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret);
|
|
76
|
+
newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
|
|
74
77
|
if (previousFinalizedIndex !== newFinalizedIndex) {
|
|
75
78
|
// A new finalized index was found, so we'll run the loop again. For example:
|
|
76
79
|
// - Previous finalized index: 10
|
|
@@ -9,11 +9,8 @@ export async function getStatusChangeOfPending(
|
|
|
9
9
|
pending: TxHash[],
|
|
10
10
|
aztecNode: AztecNode,
|
|
11
11
|
): Promise<{ txHashesToFinalize: TxHash[]; txHashesToDrop: TxHash[] }> {
|
|
12
|
-
// Get receipts for all pending tx hashes
|
|
13
|
-
const
|
|
14
|
-
Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash))),
|
|
15
|
-
aztecNode.getL2Tips(),
|
|
16
|
-
]);
|
|
12
|
+
// Get receipts for all pending tx hashes.
|
|
13
|
+
const receipts = await Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash)));
|
|
17
14
|
|
|
18
15
|
const txHashesToFinalize: TxHash[] = [];
|
|
19
16
|
const txHashesToDrop: TxHash[] = [];
|
|
@@ -22,21 +19,16 @@ export async function getStatusChangeOfPending(
|
|
|
22
19
|
const receipt = receipts[i];
|
|
23
20
|
const txHash = pending[i];
|
|
24
21
|
|
|
25
|
-
if (receipt.status === TxStatus.
|
|
22
|
+
if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
|
|
26
23
|
// Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
|
|
27
24
|
// finalized.
|
|
28
25
|
txHashesToFinalize.push(txHash);
|
|
29
|
-
} else if (
|
|
30
|
-
receipt.status === TxStatus.DROPPED ||
|
|
31
|
-
receipt.status === TxStatus.APP_LOGIC_REVERTED ||
|
|
32
|
-
receipt.status === TxStatus.TEARDOWN_REVERTED ||
|
|
33
|
-
receipt.status === TxStatus.BOTH_REVERTED
|
|
34
|
-
) {
|
|
26
|
+
} else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
|
|
35
27
|
// Tx was dropped or reverted --> we drop the corresponding pending indexes.
|
|
36
28
|
// TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
|
|
37
29
|
txHashesToDrop.push(txHash);
|
|
38
30
|
} else {
|
|
39
|
-
// Tx is still pending or
|
|
31
|
+
// Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
2
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
4
5
|
import { SiloedTag, Tag } from '@aztec/stdlib/logs';
|
|
5
6
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
7
8
|
import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
|
|
9
|
+
import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
|
|
@@ -17,6 +19,8 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
|
|
|
17
19
|
* @param end - The ending index (exclusive) of the window to process.
|
|
18
20
|
* @param aztecNode - The Aztec node instance to query for logs.
|
|
19
21
|
* @param taggingStore - The data provider to store pending indexes.
|
|
22
|
+
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
23
|
+
* preserving way.
|
|
20
24
|
*/
|
|
21
25
|
export async function loadAndStoreNewTaggingIndexes(
|
|
22
26
|
secret: DirectionalAppTaggingSecret,
|
|
@@ -25,6 +29,8 @@ export async function loadAndStoreNewTaggingIndexes(
|
|
|
25
29
|
end: number,
|
|
26
30
|
aztecNode: AztecNode,
|
|
27
31
|
taggingStore: SenderTaggingStore,
|
|
32
|
+
anchorBlockHash: L2BlockHash,
|
|
33
|
+
jobId: string,
|
|
28
34
|
) {
|
|
29
35
|
// We compute the tags for the current window of indexes
|
|
30
36
|
const preTagsForWindow: PreTag[] = Array(end - start)
|
|
@@ -34,20 +40,26 @@ export async function loadAndStoreNewTaggingIndexes(
|
|
|
34
40
|
preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
|
|
35
41
|
);
|
|
36
42
|
|
|
37
|
-
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
|
|
43
|
+
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
38
44
|
const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
|
|
39
45
|
|
|
40
46
|
// Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
|
|
41
47
|
for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
|
|
42
48
|
const txHash = TxHash.fromString(txHashStr);
|
|
43
|
-
await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash);
|
|
49
|
+
await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash, jobId);
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
// Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
|
|
48
54
|
// an array for each tag.
|
|
49
|
-
async function getTxsContainingTags(
|
|
50
|
-
|
|
55
|
+
async function getTxsContainingTags(
|
|
56
|
+
tags: SiloedTag[],
|
|
57
|
+
aztecNode: AztecNode,
|
|
58
|
+
anchorBlockHash: L2BlockHash,
|
|
59
|
+
): Promise<TxHash[][]> {
|
|
60
|
+
// We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
|
|
61
|
+
// pagination here.
|
|
62
|
+
const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
|
|
51
63
|
return allLogs.map(logs => logs.map(log => log.txHash));
|
|
52
64
|
}
|
|
53
65
|
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
-
import type { NodeStats } from '@aztec/stdlib/tx';
|
|
3
|
-
export type ProxiedNode = AztecNode & {
|
|
4
|
-
getStats(): NodeStats;
|
|
5
|
-
};
|
|
6
|
-
export declare class ProxiedNodeFactory {
|
|
7
|
-
static create(node: AztecNode): ProxiedNode;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJveGllZF9ub2RlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RfZnVuY3Rpb25fc2ltdWxhdG9yL3Byb3hpZWRfbm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUtsRCxNQUFNLE1BQU0sV0FBVyxHQUFHLFNBQVMsR0FBRztJQUFFLFFBQVEsSUFBSSxTQUFTLENBQUE7Q0FBRSxDQUFDO0FBRWhFLHFCQUFhLGtCQUFrQjtJQUM3QixNQUFNLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRSxTQUFTLGVBcUI1QjtDQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxied_node.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,IAAI,SAAS,CAAA;CAAE,CAAC;AAEhE,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,eAqB5B;CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
export class ProxiedNodeFactory {
|
|
3
|
-
static create(node) {
|
|
4
|
-
const stats = {};
|
|
5
|
-
return new Proxy(node, {
|
|
6
|
-
get (target, prop) {
|
|
7
|
-
if (prop === 'getStats') {
|
|
8
|
-
return ()=>{
|
|
9
|
-
return stats;
|
|
10
|
-
};
|
|
11
|
-
} else {
|
|
12
|
-
return async function(...args) {
|
|
13
|
-
if (!stats[prop]) {
|
|
14
|
-
stats[prop] = {
|
|
15
|
-
times: []
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const timer = new Timer();
|
|
19
|
-
const result = await target[prop].apply(target, args);
|
|
20
|
-
stats[prop].times.push(timer.ms());
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
|
|
2
|
-
import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
3
|
-
import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
|
|
4
|
-
export declare class PrivateKernelResetPrivateInputsBuilder {
|
|
5
|
-
private previousKernelOutput;
|
|
6
|
-
private executionStack;
|
|
7
|
-
private noteHashNullifierCounterMap;
|
|
8
|
-
private splitCounter;
|
|
9
|
-
private previousKernel;
|
|
10
|
-
private nextIteration?;
|
|
11
|
-
private noteHashResetActions;
|
|
12
|
-
private nullifierResetActions;
|
|
13
|
-
private numTransientData?;
|
|
14
|
-
private transientDataSquashingHints;
|
|
15
|
-
private requestedDimensions;
|
|
16
|
-
constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number);
|
|
17
|
-
needsReset(): boolean;
|
|
18
|
-
build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>): Promise<PrivateKernelResetCircuitPrivateInputs>;
|
|
19
|
-
private reduceReadRequestActions;
|
|
20
|
-
private needsResetNoteHashReadRequests;
|
|
21
|
-
private needsResetNullifierReadRequests;
|
|
22
|
-
private needsResetNullifierKeys;
|
|
23
|
-
private needsResetTransientData;
|
|
24
|
-
private needsSiloNoteHashes;
|
|
25
|
-
private needsSiloNullifiers;
|
|
26
|
-
private needsSiloPrivateLogs;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfcHJpdmF0ZV9rZXJuZWxfcmVzZXRfcHJpdmF0ZV9pbnB1dHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9idWlsZF9wcml2YXRlX2tlcm5lbF9yZXNldF9wcml2YXRlX2lucHV0cy50cyJdLCJuYW1lcyI6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UFFRCxPQUFPLENBQUMsd0JBQXdCO0lBMkJoQyxPQUFPLENBQUMsOEJBQThCO0lBdUR0QyxPQUFPLENBQUMsK0JBQStCO0lBdUR2QyxPQUFPLENBQUMsdUJBQXVCO0lBYS9CLE9BQU8sQ0FBQyx1QkFBdUI7SUFzRS9CLE9BQU8sQ0FBQyxtQkFBbUI7SUFjM0IsT0FBTyxDQUFDLG1CQUFtQjtJQWtCM0IsT0FBTyxDQUFDLG9CQUFvQjtDQXFCN0IifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAejC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA4CvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,YAAY;IAdtB,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,oBAAoB,CAAqE;IACjG,OAAO,CAAC,qBAAqB,CAAqE;IAClG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,2BAA2B,CAAkE;IACrG,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,YACU,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,YAAY,EAAE,MAAM,EAW7B;IAED,UAAU,IAAI,OAAO,CAsBpB;IAEK,KAAK,CAAC,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,mDAoEjF;IAED,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,8BAA8B;IAuDtC,OAAO,CAAC,+BAA+B;IAuDvC,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,uBAAuB;IAsE/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,oBAAoB;CAqB7B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
-
import type { KeyStore } from '@aztec/key-store';
|
|
6
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
9
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
10
|
-
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
11
|
-
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
12
|
-
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
13
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
14
|
-
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
15
|
-
/**
|
|
16
|
-
* A data oracle that provides information needed for simulating a transaction.
|
|
17
|
-
*/
|
|
18
|
-
export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
19
|
-
private contractStore;
|
|
20
|
-
private keyStore;
|
|
21
|
-
private node;
|
|
22
|
-
private blockNumber;
|
|
23
|
-
private log;
|
|
24
|
-
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockNumber?: BlockParameter, log?: import("@aztec/foundation/log").Logger);
|
|
25
|
-
getContractAddressPreimage(address: AztecAddress): Promise<{
|
|
26
|
-
version: 1;
|
|
27
|
-
salt: Fr;
|
|
28
|
-
deployer: AztecAddress;
|
|
29
|
-
currentContractClassId: Fr;
|
|
30
|
-
originalContractClassId: Fr;
|
|
31
|
-
initializationHash: Fr;
|
|
32
|
-
publicKeys: import("../../../stdlib/dest/keys/public_keys.js").PublicKeys;
|
|
33
|
-
address: AztecAddress;
|
|
34
|
-
saltedInitializationHash: Fr;
|
|
35
|
-
}>;
|
|
36
|
-
getContractClassIdPreimage(contractClassId: Fr): Promise<import("@aztec/stdlib/contract").ContractClassIdPreimage>;
|
|
37
|
-
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<7>>;
|
|
38
|
-
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<7>>;
|
|
39
|
-
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
40
|
-
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
41
|
-
getNoteHashTreeRoot(): Promise<Fr>;
|
|
42
|
-
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
|
|
43
|
-
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
44
|
-
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlX2ltcGwuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml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EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,EACf,WAAW,GAAE,cAAyB,EACtC,GAAG,yCAAoC,EAC7C;IAES,0BAA0B,CAAC,OAAO,EAAE,YAAY;;;;;;;;;;OAS5D;IAEY,0BAA0B,CAAC,eAAe,EAAE,EAAE,qEAM1D;IAEY,4BAA4B,CAAC,eAAe,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,iCAQxF;IAEM,sBAAsB,CAAC,EAAE,EAAE,uBAAuB,iCAGxD;IAEK,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAO9G;IAED,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAE5F;IAEK,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAMvC;IAEM,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAEzE;IAEM,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtG;IAEY,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8B/F;CACF"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
|
-
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
5
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
|
-
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
7
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
8
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
9
|
-
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
10
|
-
// TODO: Block number should not be "latest".
|
|
11
|
-
// It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
|
|
12
|
-
/**
|
|
13
|
-
* A data oracle that provides information needed for simulating a transaction.
|
|
14
|
-
*/ export class PrivateKernelOracleImpl {
|
|
15
|
-
contractStore;
|
|
16
|
-
keyStore;
|
|
17
|
-
node;
|
|
18
|
-
blockNumber;
|
|
19
|
-
log;
|
|
20
|
-
constructor(contractStore, keyStore, node, blockNumber = 'latest', log = createLogger('pxe:kernel_oracle')){
|
|
21
|
-
this.contractStore = contractStore;
|
|
22
|
-
this.keyStore = keyStore;
|
|
23
|
-
this.node = node;
|
|
24
|
-
this.blockNumber = blockNumber;
|
|
25
|
-
this.log = log;
|
|
26
|
-
}
|
|
27
|
-
async getContractAddressPreimage(address) {
|
|
28
|
-
const instance = await this.contractStore.getContractInstance(address);
|
|
29
|
-
if (!instance) {
|
|
30
|
-
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
34
|
-
...instance
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async getContractClassIdPreimage(contractClassId) {
|
|
38
|
-
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
39
|
-
if (!contractClass) {
|
|
40
|
-
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
41
|
-
}
|
|
42
|
-
return computeContractClassIdPreimage(contractClass);
|
|
43
|
-
}
|
|
44
|
-
async getFunctionMembershipWitness(contractClassId, selector) {
|
|
45
|
-
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
46
|
-
if (!membershipWitness) {
|
|
47
|
-
throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
|
|
48
|
-
}
|
|
49
|
-
return membershipWitness;
|
|
50
|
-
}
|
|
51
|
-
getVkMembershipWitness(vk) {
|
|
52
|
-
const leafIndex = getVKIndex(vk);
|
|
53
|
-
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
54
|
-
}
|
|
55
|
-
async getNoteHashMembershipWitness(leafIndex) {
|
|
56
|
-
const path = await this.node.getNoteHashSiblingPath(this.blockNumber, leafIndex);
|
|
57
|
-
return new MembershipWitness(path.pathSize, leafIndex, path.toFields());
|
|
58
|
-
}
|
|
59
|
-
getNullifierMembershipWitness(nullifier) {
|
|
60
|
-
return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
|
|
61
|
-
}
|
|
62
|
-
async getNoteHashTreeRoot() {
|
|
63
|
-
const header = await this.node.getBlockHeader(this.blockNumber);
|
|
64
|
-
if (!header) {
|
|
65
|
-
throw new Error(`No block header found for block number ${this.blockNumber}`);
|
|
66
|
-
}
|
|
67
|
-
return header.state.partial.noteHashTree.root;
|
|
68
|
-
}
|
|
69
|
-
getMasterSecretKey(masterPublicKey) {
|
|
70
|
-
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
71
|
-
}
|
|
72
|
-
getDebugFunctionName(contractAddress, selector) {
|
|
73
|
-
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
74
|
-
}
|
|
75
|
-
async getUpdatedClassIdHints(contractAddress) {
|
|
76
|
-
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
77
|
-
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
|
|
78
|
-
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
|
|
79
|
-
if (!updatedClassIdWitness) {
|
|
80
|
-
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
81
|
-
}
|
|
82
|
-
const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
83
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
|
|
84
|
-
return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
6
|
-
export declare class PublicStorageService {
|
|
7
|
-
private readonly anchorBlockStore;
|
|
8
|
-
private readonly aztecNode;
|
|
9
|
-
constructor(anchorBlockStore: AnchorBlockStore, aztecNode: AztecNode);
|
|
10
|
-
/**
|
|
11
|
-
* Gets the storage value at the given contract storage slot.
|
|
12
|
-
*
|
|
13
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
14
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
15
|
-
*
|
|
16
|
-
* @param blockNumber - The block number at which to get the data.
|
|
17
|
-
* @param contract - Address of the contract to query.
|
|
18
|
-
* @param slot - Slot to query.
|
|
19
|
-
* @returns Storage value at the given contract slot.
|
|
20
|
-
* @throws If the contract is not deployed.
|
|
21
|
-
*/
|
|
22
|
-
getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3N0b3JhZ2Vfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpY19zdG9yYWdlL3B1YmxpY19zdG9yYWdlX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxREFBcUQsQ0FBQztBQUU1RixxQkFBYSxvQkFBb0I7SUFFN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0I7SUFDakMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBRjVCLFlBQ21CLGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxTQUFTLEVBQUUsU0FBUyxFQUNuQztJQUVKOzs7Ozs7Ozs7OztPQVdHO0lBQ1Usa0JBQWtCLENBQUMsV0FBVyxFQUFFLGNBQWMsRUFBRSxRQUFRLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQU0xRztDQUNGIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public_storage_service.d.ts","sourceRoot":"","sources":["../../src/public_storage/public_storage_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAE5F,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF5B,YACmB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACnC;IAEJ;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAM1G;CACF"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export class PublicStorageService {
|
|
2
|
-
anchorBlockStore;
|
|
3
|
-
aztecNode;
|
|
4
|
-
constructor(anchorBlockStore, aztecNode){
|
|
5
|
-
this.anchorBlockStore = anchorBlockStore;
|
|
6
|
-
this.aztecNode = aztecNode;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Gets the storage value at the given contract storage slot.
|
|
10
|
-
*
|
|
11
|
-
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
12
|
-
* Aztec's version of `eth_getStorageAt`.
|
|
13
|
-
*
|
|
14
|
-
* @param blockNumber - The block number at which to get the data.
|
|
15
|
-
* @param contract - Address of the contract to query.
|
|
16
|
-
* @param slot - Slot to query.
|
|
17
|
-
* @returns Storage value at the given contract slot.
|
|
18
|
-
* @throws If the contract is not deployed.
|
|
19
|
-
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
20
|
-
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
21
|
-
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
22
|
-
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
23
|
-
}
|
|
24
|
-
return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
6
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
8
|
-
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
|
-
export declare class TreeMembershipService {
|
|
10
|
-
#private;
|
|
11
|
-
private readonly aztecNode;
|
|
12
|
-
private readonly anchorBlockStore;
|
|
13
|
-
constructor(aztecNode: AztecNode, anchorBlockStore: AnchorBlockStore);
|
|
14
|
-
/**
|
|
15
|
-
* Gets the index of a nullifier in the nullifier tree.
|
|
16
|
-
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
17
|
-
*/
|
|
18
|
-
getNullifierIndex(nullifier: Fr): Promise<bigint | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
21
|
-
* @param blockNumber - The block number at which to get the membership witness.
|
|
22
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
23
|
-
* @param leafValue - The leaf value
|
|
24
|
-
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
25
|
-
*/
|
|
26
|
-
getMembershipWitness(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
29
|
-
* @param blockNumber - The block number at which to get the index.
|
|
30
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
31
|
-
* @returns The low nullifier membership witness (if found).
|
|
32
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
33
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
34
|
-
* we are trying to prove non-inclusion for.
|
|
35
|
-
*/
|
|
36
|
-
getLowNullifierMembershipWitness(blockNumber: BlockParameter, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
37
|
-
/**
|
|
38
|
-
* Returns a witness for a given slot of the public data tree at a given block.
|
|
39
|
-
* @param blockNumber - The block number at which to get the witness.
|
|
40
|
-
* @param leafSlot - The slot of the public data in the public data tree.
|
|
41
|
-
*/
|
|
42
|
-
getPublicDataWitness(blockNumber: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
45
|
-
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
46
|
-
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
47
|
-
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
48
|
-
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
49
|
-
*/
|
|
50
|
-
getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJlZV9tZW1iZXJzaG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EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAE5F,qBAAa,qBAAqB;;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAFnC,YACmB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EACjD;IAEJ;;;OAGG;IACI,iBAAiB,CAAC,SAAS,EAAE,EAAE,+BAErC;IAED;;;;;;OAMG;IACU,oBAAoB,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAMjH;IAED;;;;;;;;OAQG;IACU,gCAAgC,CAC3C,WAAW,EAAE,cAAc,EAC3B,SAAS,EAAE,EAAE,GACZ,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAMjD;IAED;;;;OAIG;IACU,oBAAoB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAMnH;IAED;;;;;;OAMG;IACI,0BAA0B,CAC/B,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,EAAE,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAEjE;CAyBF"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
2
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
3
|
-
export class TreeMembershipService {
|
|
4
|
-
aztecNode;
|
|
5
|
-
anchorBlockStore;
|
|
6
|
-
constructor(aztecNode, anchorBlockStore){
|
|
7
|
-
this.aztecNode = aztecNode;
|
|
8
|
-
this.anchorBlockStore = anchorBlockStore;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Gets the index of a nullifier in the nullifier tree.
|
|
12
|
-
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
13
|
-
*/ getNullifierIndex(nullifier) {
|
|
14
|
-
return this.#findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
18
|
-
* @param blockNumber - The block number at which to get the membership witness.
|
|
19
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
20
|
-
* @param leafValue - The leaf value
|
|
21
|
-
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
22
|
-
*/ async getMembershipWitness(blockNumber, treeId, leafValue) {
|
|
23
|
-
const witness = await this.#tryGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
24
|
-
if (!witness) {
|
|
25
|
-
throw new Error(`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block ${blockNumber}`);
|
|
26
|
-
}
|
|
27
|
-
return witness;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
31
|
-
* @param blockNumber - The block number at which to get the index.
|
|
32
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
33
|
-
* @returns The low nullifier membership witness (if found).
|
|
34
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
35
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
36
|
-
* we are trying to prove non-inclusion for.
|
|
37
|
-
*/ async getLowNullifierMembershipWitness(blockNumber, nullifier) {
|
|
38
|
-
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
39
|
-
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
40
|
-
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
41
|
-
}
|
|
42
|
-
return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns a witness for a given slot of the public data tree at a given block.
|
|
46
|
-
* @param blockNumber - The block number at which to get the witness.
|
|
47
|
-
* @param leafSlot - The slot of the public data in the public data tree.
|
|
48
|
-
*/ async getPublicDataWitness(blockNumber, leafSlot) {
|
|
49
|
-
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
50
|
-
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
51
|
-
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
52
|
-
}
|
|
53
|
-
return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
57
|
-
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
58
|
-
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
59
|
-
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
60
|
-
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
61
|
-
*/ getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
|
|
62
|
-
return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
|
|
63
|
-
}
|
|
64
|
-
async #tryGetMembershipWitness(blockNumber, treeId, value) {
|
|
65
|
-
switch(treeId){
|
|
66
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
67
|
-
return (await this.aztecNode.getNullifierMembershipWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
68
|
-
case MerkleTreeId.NOTE_HASH_TREE:
|
|
69
|
-
return (await this.aztecNode.getNoteHashMembershipWitness(blockNumber, value))?.toFields();
|
|
70
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
71
|
-
return (await this.aztecNode.getPublicDataWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
72
|
-
case MerkleTreeId.ARCHIVE:
|
|
73
|
-
return (await this.aztecNode.getArchiveMembershipWitness(blockNumber, value))?.toFields();
|
|
74
|
-
default:
|
|
75
|
-
throw new Error('Not implemented');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async #findLeafIndex(blockNumber, treeId, leafValue) {
|
|
79
|
-
const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [
|
|
80
|
-
leafValue
|
|
81
|
-
]);
|
|
82
|
-
return leafIndex?.data;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
-
import type { NodeStats } from '@aztec/stdlib/tx';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Proxy generator for an AztecNode that tracks the time taken for each RPC call.
|
|
7
|
-
*/
|
|
8
|
-
export type ProxiedNode = AztecNode & { getStats(): NodeStats };
|
|
9
|
-
|
|
10
|
-
export class ProxiedNodeFactory {
|
|
11
|
-
static create(node: AztecNode) {
|
|
12
|
-
const stats: Partial<Record<keyof AztecNode, { times: number[] }>> = {};
|
|
13
|
-
return new Proxy(node, {
|
|
14
|
-
get(target, prop: keyof ProxiedNode) {
|
|
15
|
-
if (prop === 'getStats') {
|
|
16
|
-
return () => {
|
|
17
|
-
return stats;
|
|
18
|
-
};
|
|
19
|
-
} else {
|
|
20
|
-
return async function (...args: any[]) {
|
|
21
|
-
if (!stats[prop]) {
|
|
22
|
-
stats[prop] = { times: [] };
|
|
23
|
-
}
|
|
24
|
-
const timer = new Timer();
|
|
25
|
-
const result = await (target[prop] as any).apply(target, args);
|
|
26
|
-
stats[prop].times.push(timer.ms());
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
}) as ProxiedNode;
|
|
32
|
-
}
|
|
33
|
-
}
|