@aztec/pxe 0.0.1-commit.e558bd1c → 0.0.1-commit.e5a3663dd
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 +4 -4
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -10
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +8 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +62 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +206 -76
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
- 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 +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- 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 +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +63 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +76 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +289 -97
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +58 -86
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +121 -95
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +124 -64
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +356 -126
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +7 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +69 -35
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +9 -4
- package/dest/debug/pxe_debug_utils.d.ts +5 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -7
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -3
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -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 +11 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +3 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -3
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +26 -5
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/logs/log_service.d.ts +7 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +33 -48
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +4 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +18 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +19 -18
- package/dest/pxe.d.ts +84 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +153 -83
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +36 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +148 -70
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +3 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -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 +8 -22
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -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 +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -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 +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_stream_source.ts +52 -0
- package/src/block_synchronizer/block_synchronizer.ts +33 -11
- package/src/config/index.ts +3 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +366 -138
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +91 -53
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +378 -140
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +151 -183
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +598 -156
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +102 -55
- package/src/contract_sync/helpers.ts +8 -3
- package/src/debug/pxe_debug_utils.ts +11 -14
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +11 -4
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +11 -4
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +2 -1
- package/src/entrypoints/server/utils.ts +9 -10
- package/src/events/event_service.ts +30 -5
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +63 -91
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +18 -16
- package/src/private_kernel/private_kernel_oracle.ts +21 -21
- package/src/pxe.ts +278 -131
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +181 -80
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +5 -5
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +12 -25
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
- 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
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SiloedTag
|
|
1
|
+
import { SiloedTag } from '@aztec/stdlib/logs';
|
|
2
2
|
import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
3
3
|
/**
|
|
4
|
-
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range
|
|
5
|
-
* `
|
|
6
|
-
* exclusive.
|
|
7
|
-
*/ export async function loadLogsForRange(
|
|
8
|
-
// Derive tags for the window
|
|
9
|
-
const
|
|
10
|
-
|
|
4
|
+
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
|
|
5
|
+
* `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
|
|
6
|
+
* `end` is exclusive.
|
|
7
|
+
*/ export async function loadLogsForRange(extendedSecret, aztecNode, start, end, anchorBlockNumber, anchorBlockHash) {
|
|
8
|
+
// Derive siloed tags for the window
|
|
9
|
+
const siloedTags = await Promise.all(Array.from({
|
|
10
|
+
length: end - start
|
|
11
|
+
}, (_, i)=>SiloedTag.compute({
|
|
12
|
+
extendedSecret,
|
|
11
13
|
index: start + i
|
|
12
|
-
}));
|
|
13
|
-
const siloedTags = await Promise.all(preTags.map((preTag)=>Tag.compute(preTag))).then((tags)=>Promise.all(tags.map((tag)=>SiloedTag.compute(tag, app))));
|
|
14
|
+
})));
|
|
14
15
|
// We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
|
|
15
16
|
// pagination here.
|
|
16
17
|
const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
|
|
@@ -18,7 +19,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
|
18
19
|
const logsWithIndexes = [];
|
|
19
20
|
for(let i = 0; i < logs.length; i++){
|
|
20
21
|
const logsForTag = logs[i];
|
|
21
|
-
const taggingIndex =
|
|
22
|
+
const taggingIndex = start + i;
|
|
22
23
|
for (const log of logsForTag){
|
|
23
24
|
if (log.blockNumber <= anchorBlockNumber) {
|
|
24
25
|
logsWithIndexes.push({
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
1
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
2
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import type {
|
|
3
|
+
import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
5
4
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
6
5
|
/**
|
|
7
6
|
* Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
|
|
8
7
|
*
|
|
9
|
-
* @param secret - The secret that's unique for (sender, recipient,
|
|
8
|
+
* @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
|
|
10
9
|
* sender -> recipient matters.
|
|
11
|
-
* @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
|
|
12
|
-
* second round of siloing in this function which is necessary because kernels do it as well (they silo first field
|
|
13
|
-
* of the private log which corresponds to the tag).
|
|
14
10
|
* @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
|
|
15
11
|
* pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
|
|
16
12
|
* is simply the highest pending index plus one (or finalized if pending is undefined).
|
|
17
13
|
* @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
|
|
18
14
|
* updates its status accordingly.
|
|
19
15
|
*/
|
|
20
|
-
export declare function syncSenderTaggingIndexes(secret:
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
export declare function syncSenderTaggingIndexes(secret: ExtendedDirectionalAppTaggingSecret, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU5RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7O0dBVUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSxtQ0FBbUMsRUFDM0MsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FxRmYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,mCAAmC,EAC3C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAqFf"}
|
|
@@ -4,17 +4,14 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
|
|
|
4
4
|
/**
|
|
5
5
|
* Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
|
|
6
6
|
*
|
|
7
|
-
* @param secret - The secret that's unique for (sender, recipient,
|
|
7
|
+
* @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
|
|
8
8
|
* sender -> recipient matters.
|
|
9
|
-
* @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
|
|
10
|
-
* second round of siloing in this function which is necessary because kernels do it as well (they silo first field
|
|
11
|
-
* of the private log which corresponds to the tag).
|
|
12
9
|
* @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
|
|
13
10
|
* pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
|
|
14
11
|
* is simply the highest pending index plus one (or finalized if pending is undefined).
|
|
15
12
|
* @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
|
|
16
13
|
* updates its status accordingly.
|
|
17
|
-
*/ export async function syncSenderTaggingIndexes(secret,
|
|
14
|
+
*/ export async function syncSenderTaggingIndexes(secret, aztecNode, taggingStore, anchorBlockHash, jobId) {
|
|
18
15
|
// # Explanation of how syncing works
|
|
19
16
|
//
|
|
20
17
|
// When choosing an index, we select: highest pending index + 1 (or highest finalized index + 1 if no pending).
|
|
@@ -40,15 +37,24 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
|
|
|
40
37
|
while(true){
|
|
41
38
|
// Load and store indexes for the current window. These indexes may already exist in the database if txs using
|
|
42
39
|
// them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
|
|
43
|
-
await loadAndStoreNewTaggingIndexes(secret,
|
|
40
|
+
await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
|
|
44
41
|
// Retrieve all indexes within the current window from storage and update their status accordingly.
|
|
45
42
|
const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
|
|
46
43
|
if (pendingTxHashes.length === 0) {
|
|
47
44
|
break;
|
|
48
45
|
}
|
|
49
|
-
const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
|
|
46
|
+
const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
|
|
50
47
|
await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
|
|
51
48
|
await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
|
|
49
|
+
if (txHashesWithExecutionReverted.length > 0) {
|
|
50
|
+
const indexedTxEffects = await Promise.all(txHashesWithExecutionReverted.map((txHash)=>aztecNode.getTxEffect(txHash)));
|
|
51
|
+
for (const indexedTxEffect of indexedTxEffects){
|
|
52
|
+
if (indexedTxEffect === undefined) {
|
|
53
|
+
throw new Error('TxEffect not found for execution-reverted tx. This is either a bug or a reorg has occurred.');
|
|
54
|
+
}
|
|
55
|
+
await taggingStore.finalizePendingIndexesOfAPartiallyRevertedTx(indexedTxEffect.data, jobId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
52
58
|
// We check if the finalized index has been updated.
|
|
53
59
|
newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
|
|
54
60
|
if (previousFinalizedIndex !== newFinalizedIndex) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
3
|
/**
|
|
4
|
-
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized
|
|
5
|
-
* dropped.
|
|
4
|
+
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
|
|
5
|
+
* dropped, or execution-reverted (but mined).
|
|
6
6
|
*/
|
|
7
7
|
export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: AztecNode): Promise<{
|
|
8
8
|
txHashesToFinalize: TxHash[];
|
|
9
9
|
txHashesToDrop: TxHash[];
|
|
10
|
+
txHashesWithExecutionReverted: TxHash[];
|
|
10
11
|
}>;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUNULGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQzdCLGNBQWMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUN6Qiw2QkFBNkIsRUFBRSxNQUFNLEVBQUUsQ0FBQztDQUN6QyxDQUFDLENBb0NEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IACT,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,6BAA6B,EAAE,MAAM,EAAE,CAAC;CACzC,CAAC,CAoCD"}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import { TxStatus } from '@aztec/stdlib/tx';
|
|
2
2
|
/**
|
|
3
|
-
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized
|
|
4
|
-
* dropped.
|
|
3
|
+
* Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
|
|
4
|
+
* dropped, or execution-reverted (but mined).
|
|
5
5
|
*/ export async function getStatusChangeOfPending(pending, aztecNode) {
|
|
6
6
|
// Get receipts for all pending tx hashes.
|
|
7
7
|
const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
|
|
8
8
|
const txHashesToFinalize = [];
|
|
9
9
|
const txHashesToDrop = [];
|
|
10
|
+
const txHashesWithExecutionReverted = [];
|
|
10
11
|
for(let i = 0; i < receipts.length; i++){
|
|
11
12
|
const receipt = receipts[i];
|
|
12
13
|
const txHash = pending[i];
|
|
13
|
-
if (receipt.status === TxStatus.FINALIZED
|
|
14
|
-
// Tx has been included in a block and the corresponding block is finalized
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (receipt.status === TxStatus.FINALIZED) {
|
|
15
|
+
// Tx has been included in a block and the corresponding block is finalized
|
|
16
|
+
if (receipt.hasExecutionSucceeded()) {
|
|
17
|
+
// No part of execution reverted - we just finalize all the indexes.
|
|
18
|
+
txHashesToFinalize.push(txHash);
|
|
19
|
+
} else if (receipt.hasExecutionReverted()) {
|
|
20
|
+
// Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
|
|
21
|
+
// phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
|
|
22
|
+
txHashesWithExecutionReverted.push(txHash);
|
|
23
|
+
} else {
|
|
24
|
+
// Defensive check - this branch should never be triggered
|
|
25
|
+
throw new Error('Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.');
|
|
26
|
+
}
|
|
27
|
+
} else if (receipt.isDropped()) {
|
|
28
|
+
// Tx was dropped from the mempool --> we drop the corresponding pending indexes.
|
|
20
29
|
txHashesToDrop.push(txHash);
|
|
21
30
|
} else {
|
|
22
31
|
// Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
|
|
@@ -24,6 +33,7 @@ import { TxStatus } from '@aztec/stdlib/tx';
|
|
|
24
33
|
}
|
|
25
34
|
return {
|
|
26
35
|
txHashesToFinalize,
|
|
27
|
-
txHashesToDrop
|
|
36
|
+
txHashesToDrop,
|
|
37
|
+
txHashesWithExecutionReverted
|
|
28
38
|
};
|
|
29
39
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
1
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
2
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
4
|
-
import type {
|
|
3
|
+
import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
5
4
|
import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
|
|
6
5
|
/**
|
|
7
6
|
* Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
|
|
8
7
|
* @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
|
|
9
8
|
* place is when a tx is being sent from this PXE.
|
|
10
|
-
* @param
|
|
11
|
-
* @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
|
|
12
|
-
* kernel circuit behavior.
|
|
9
|
+
* @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
|
|
13
10
|
* @param start - The starting index (inclusive) of the window to process.
|
|
14
11
|
* @param end - The ending index (exclusive) of the window to process.
|
|
15
12
|
* @param aztecNode - The Aztec node instance to query for logs.
|
|
16
13
|
* @param taggingStore - The data provider to store pending indexes.
|
|
14
|
+
* @param anchorBlockHash - Hash of a block to use as reference block when querying node.
|
|
17
15
|
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
18
16
|
* preserving way.
|
|
19
17
|
*/
|
|
20
|
-
export declare function loadAndStoreNewTaggingIndexes(
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
export declare function loadAndStoreNewTaggingIndexes(extendedSecret: ExtendedDirectionalAppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQXNCLDZCQUE2QixDQUNqRCxjQUFjLEVBQUUsbUNBQW1DLEVBQ25ELEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUsa0JBQWtCLEVBQ2hDLGVBQWUsRUFBRSxTQUFTLEVBQzFCLEtBQUssRUFBRSxNQUFNLGlCQWdCZCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;GAYG;AACH,wBAAsB,6BAA6B,CACjD,cAAc,EAAE,mCAAmC,EACnD,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAgBd"}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { SiloedTag
|
|
1
|
+
import { SiloedTag } from '@aztec/stdlib/logs';
|
|
2
2
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
3
|
import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
4
4
|
/**
|
|
5
5
|
* Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
|
|
6
6
|
* @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
|
|
7
7
|
* place is when a tx is being sent from this PXE.
|
|
8
|
-
* @param
|
|
9
|
-
* @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
|
|
10
|
-
* kernel circuit behavior.
|
|
8
|
+
* @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
|
|
11
9
|
* @param start - The starting index (inclusive) of the window to process.
|
|
12
10
|
* @param end - The ending index (exclusive) of the window to process.
|
|
13
11
|
* @param aztecNode - The Aztec node instance to query for logs.
|
|
14
12
|
* @param taggingStore - The data provider to store pending indexes.
|
|
13
|
+
* @param anchorBlockHash - Hash of a block to use as reference block when querying node.
|
|
15
14
|
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
16
15
|
* preserving way.
|
|
17
|
-
*/ export async function loadAndStoreNewTaggingIndexes(
|
|
16
|
+
*/ export async function loadAndStoreNewTaggingIndexes(extendedSecret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
|
|
18
17
|
// We compute the tags for the current window of indexes
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
const siloedTagsForWindow = await Promise.all(Array.from({
|
|
19
|
+
length: end - start
|
|
20
|
+
}, (_, i)=>SiloedTag.compute({
|
|
21
|
+
extendedSecret,
|
|
21
22
|
index: start + i
|
|
22
|
-
}));
|
|
23
|
-
const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
|
|
23
|
+
})));
|
|
24
24
|
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
25
|
-
const
|
|
26
|
-
// Now we iterate over the map,
|
|
27
|
-
for (const [txHashStr,
|
|
25
|
+
const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
|
|
26
|
+
// Now we iterate over the map, construct the tagging index ranges and store them in the db.
|
|
27
|
+
for (const [txHashStr, indexes] of txIndexesMap.entries()){
|
|
28
28
|
const txHash = TxHash.fromString(txHashStr);
|
|
29
|
-
|
|
29
|
+
const ranges = [
|
|
30
30
|
{
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
extendedSecret,
|
|
32
|
+
lowestIndex: Math.min(...indexes),
|
|
33
|
+
highestIndex: Math.max(...indexes)
|
|
33
34
|
}
|
|
34
|
-
]
|
|
35
|
+
];
|
|
36
|
+
await taggingStore.storePendingIndexes(ranges, txHash, jobId);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
// Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
|
|
@@ -42,19 +44,29 @@ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
|
|
|
42
44
|
const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
|
|
43
45
|
return allLogs.map((logs)=>logs.map((log)=>log.txHash));
|
|
44
46
|
}
|
|
45
|
-
// Returns a map of txHash to
|
|
46
|
-
function
|
|
47
|
-
if (txHashesForTags.length !==
|
|
48
|
-
throw new Error(`Number of tx hashes arrays does not match number of
|
|
47
|
+
// Returns a map of txHash to all indexes for that txHash.
|
|
48
|
+
function getTxIndexesMap(txHashesForTags, start, count) {
|
|
49
|
+
if (txHashesForTags.length !== count) {
|
|
50
|
+
throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
|
|
49
51
|
}
|
|
50
|
-
const
|
|
52
|
+
const indexesMap = new Map();
|
|
53
|
+
// Iterate over indexes
|
|
51
54
|
for(let i = 0; i < txHashesForTags.length; i++){
|
|
52
|
-
const taggingIndex =
|
|
55
|
+
const taggingIndex = start + i;
|
|
53
56
|
const txHashesForTag = txHashesForTags[i];
|
|
57
|
+
// iterate over tx hashes that used that index (tag)
|
|
54
58
|
for (const txHash of txHashesForTag){
|
|
55
59
|
const key = txHash.toString();
|
|
56
|
-
|
|
60
|
+
const existing = indexesMap.get(key);
|
|
61
|
+
// Add the index to the tx's indexes
|
|
62
|
+
if (existing) {
|
|
63
|
+
existing.push(taggingIndex);
|
|
64
|
+
} else {
|
|
65
|
+
indexesMap.set(key, [
|
|
66
|
+
taggingIndex
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
|
-
return
|
|
71
|
+
return indexesMap;
|
|
60
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e5a3663dd",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"typedocOptions": {
|
|
6
6
|
"entryPoints": [
|
|
@@ -70,19 +70,19 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
74
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
75
|
-
"@aztec/builder": "0.0.1-commit.
|
|
76
|
-
"@aztec/constants": "0.0.1-commit.
|
|
77
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
78
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
79
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
80
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
81
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
82
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
83
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
84
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
85
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
73
|
+
"@aztec/bb-prover": "0.0.1-commit.e5a3663dd",
|
|
74
|
+
"@aztec/bb.js": "0.0.1-commit.e5a3663dd",
|
|
75
|
+
"@aztec/builder": "0.0.1-commit.e5a3663dd",
|
|
76
|
+
"@aztec/constants": "0.0.1-commit.e5a3663dd",
|
|
77
|
+
"@aztec/ethereum": "0.0.1-commit.e5a3663dd",
|
|
78
|
+
"@aztec/foundation": "0.0.1-commit.e5a3663dd",
|
|
79
|
+
"@aztec/key-store": "0.0.1-commit.e5a3663dd",
|
|
80
|
+
"@aztec/kv-store": "0.0.1-commit.e5a3663dd",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.e5a3663dd",
|
|
82
|
+
"@aztec/noir-types": "0.0.1-commit.e5a3663dd",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.e5a3663dd",
|
|
84
|
+
"@aztec/simulator": "0.0.1-commit.e5a3663dd",
|
|
85
|
+
"@aztec/stdlib": "0.0.1-commit.e5a3663dd",
|
|
86
86
|
"koa": "^2.16.1",
|
|
87
87
|
"koa-router": "^13.1.1",
|
|
88
88
|
"lodash.omit": "^4.5.0",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@aztec/
|
|
95
|
-
"@aztec/
|
|
94
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.e5a3663dd",
|
|
95
|
+
"@aztec/world-state": "0.0.1-commit.e5a3663dd",
|
|
96
96
|
"@jest/globals": "^30.0.0",
|
|
97
97
|
"@types/jest": "^30.0.0",
|
|
98
98
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -13,8 +13,9 @@ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
|
|
|
13
13
|
*
|
|
14
14
|
* The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
|
|
15
15
|
* a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
|
|
16
|
-
* changed and the
|
|
17
|
-
*
|
|
16
|
+
* changed and the oracle version needs to be bumped:
|
|
17
|
+
* - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
|
|
18
|
+
* - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
|
|
18
19
|
*
|
|
19
20
|
* TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
|
|
20
21
|
* oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
|
|
@@ -26,9 +27,8 @@ function assertOracleInterfaceMatches(): void {
|
|
|
26
27
|
// We use keccak256 here just because we already have it in the dependencies.
|
|
27
28
|
const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
|
|
28
29
|
if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
|
|
29
|
-
// This check exists only to notify you when you need to update the ORACLE_VERSION constant.
|
|
30
30
|
throw new Error(
|
|
31
|
-
`The Oracle interface has changed
|
|
31
|
+
`The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { L2Block, type L2BlockSource } from '@aztec/stdlib/block';
|
|
4
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
5
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
|
|
7
|
+
// TODO(spl/new-rpc-api): delete once `L2BlockStream` is refactored to consume the new
|
|
8
|
+
// `BlockResponse` / `CheckpointResponse` shapes. For now the stream requires concrete `L2Block`
|
|
9
|
+
// and `PublishedCheckpoint` instances, so we rehydrate them from RPC responses.
|
|
10
|
+
/**
|
|
11
|
+
* Lifts an {@link AztecNode} RPC client into the shape {@link L2BlockStream} expects. `getBlocks`
|
|
12
|
+
* requests transaction bodies so that real `L2Block` instances can be constructed;
|
|
13
|
+
* `getCheckpoints` requests blocks + L1 info + attestations so that `PublishedCheckpoint`
|
|
14
|
+
* instances are fully populated.
|
|
15
|
+
*/
|
|
16
|
+
export function blockStreamSourceFromAztecNode(
|
|
17
|
+
node: AztecNode,
|
|
18
|
+
): Pick<L2BlockSource, 'getBlocks' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpoints' | 'getCheckpointedBlocks'> {
|
|
19
|
+
return {
|
|
20
|
+
getL2Tips: () => node.getL2Tips(),
|
|
21
|
+
getBlockHeader: number => node.getBlockHeader(number),
|
|
22
|
+
getCheckpointedBlocks: (from: BlockNumber, limit: number) => node.getCheckpointedBlocks(from, limit),
|
|
23
|
+
|
|
24
|
+
async getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]> {
|
|
25
|
+
const responses = await node.getBlocks(from, limit, { includeTransactions: true });
|
|
26
|
+
return responses.map(r => new L2Block(r.archive, r.header, r.body!, r.checkpointNumber, r.indexWithinCheckpoint));
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async getCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]> {
|
|
30
|
+
const responses = await node.getCheckpoints(from, limit, {
|
|
31
|
+
includeBlocks: true,
|
|
32
|
+
includeTransactions: true,
|
|
33
|
+
includeL1PublishInfo: true,
|
|
34
|
+
includeAttestations: true,
|
|
35
|
+
});
|
|
36
|
+
return responses.map(r => {
|
|
37
|
+
const checkpoint = new Checkpoint(
|
|
38
|
+
r.archive,
|
|
39
|
+
r.header,
|
|
40
|
+
r.blocks!.map(b => new L2Block(b.archive, b.header, b.body!, b.checkpointNumber, b.indexWithinCheckpoint)),
|
|
41
|
+
r.number,
|
|
42
|
+
r.feeAssetPriceModifier,
|
|
43
|
+
);
|
|
44
|
+
const l1 =
|
|
45
|
+
r.l1?.published === true
|
|
46
|
+
? new L1PublishedData(r.l1.blockNumber, r.l1.timestamp, r.l1.blockHash)
|
|
47
|
+
: new L1PublishedData(0n, 0n, Fr.ZERO.toString());
|
|
48
|
+
return new PublishedCheckpoint(checkpoint, l1, r.attestations ?? []);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
5
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
5
6
|
import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
@@ -11,6 +12,7 @@ import type { ContractSyncService } from '../contract_sync/contract_sync_service
|
|
|
11
12
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
12
13
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
13
14
|
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
15
|
+
import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
|
|
@@ -20,6 +22,7 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
|
|
|
20
22
|
export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
21
23
|
private log: Logger;
|
|
22
24
|
private isSyncing: Promise<void> | undefined;
|
|
25
|
+
private readonly eventQueue = new SerialQueue();
|
|
23
26
|
protected readonly blockStream: L2BlockStream;
|
|
24
27
|
|
|
25
28
|
constructor(
|
|
@@ -35,11 +38,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
35
38
|
) {
|
|
36
39
|
this.log = createLogger('pxe:block_synchronizer', bindings);
|
|
37
40
|
this.blockStream = this.createBlockStream(config);
|
|
41
|
+
this.eventQueue.start();
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
|
|
41
45
|
return new L2BlockStream(
|
|
42
|
-
this.node,
|
|
46
|
+
blockStreamSourceFromAztecNode(this.node),
|
|
43
47
|
this.l2TipsStore,
|
|
44
48
|
this,
|
|
45
49
|
createLogger('pxe:block_stream', this.log.getBindings()),
|
|
@@ -52,8 +56,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
52
56
|
);
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
/** Handle events emitted by the block stream. */
|
|
56
|
-
public
|
|
59
|
+
/** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
|
|
60
|
+
public handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
61
|
+
return this.eventQueue.put(() => this.doHandleBlockStreamEvent(event));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
57
65
|
await this.l2TipsStore.handleBlockStreamEvent(event);
|
|
58
66
|
|
|
59
67
|
switch (event.type) {
|
|
@@ -74,18 +82,22 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
74
82
|
}
|
|
75
83
|
case 'chain-proven': {
|
|
76
84
|
if (this.config.syncChainTip === 'proven') {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
await this.updateAnchorBlockHeader(
|
|
85
|
+
const block = await this.node.getBlock(BlockNumber(event.block.number));
|
|
86
|
+
if (block) {
|
|
87
|
+
await this.updateAnchorBlockHeader(block.header);
|
|
88
|
+
} else {
|
|
89
|
+
this.log.warn(`Block header not found for proven block ${event.block.number}, skipping anchor update`);
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
break;
|
|
83
93
|
}
|
|
84
94
|
case 'chain-finalized': {
|
|
85
95
|
if (this.config.syncChainTip === 'finalized') {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
await this.updateAnchorBlockHeader(
|
|
96
|
+
const block = await this.node.getBlock(BlockNumber(event.block.number));
|
|
97
|
+
if (block) {
|
|
98
|
+
await this.updateAnchorBlockHeader(block.header);
|
|
99
|
+
} else {
|
|
100
|
+
this.log.warn(`Block header not found for finalized block ${event.block.number}, skipping anchor update`);
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
break;
|
|
@@ -106,7 +118,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
106
118
|
// Note that the following is not necessarily the anchor block that will be used in the transaction - if
|
|
107
119
|
// the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
|
|
108
120
|
// forward.
|
|
109
|
-
const
|
|
121
|
+
const newAnchorBlock = await this.node.getBlock(BlockHash.fromString(event.block.hash));
|
|
122
|
+
const newAnchorBlockHeader = newAnchorBlock?.header;
|
|
110
123
|
|
|
111
124
|
if (!newAnchorBlockHeader) {
|
|
112
125
|
throw new Error(
|
|
@@ -152,6 +165,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
152
165
|
}
|
|
153
166
|
|
|
154
167
|
this.log.debug(`Syncing PXE with the node`);
|
|
168
|
+
// Capture the promise locally so we always await the exact promise we created, even if this.isSyncing is modified
|
|
169
|
+
// between assignment and await (e.g. due to future refactors introducing a yield point).
|
|
155
170
|
const isSyncing = this.doSync();
|
|
156
171
|
this.isSyncing = isSyncing;
|
|
157
172
|
try {
|
|
@@ -161,6 +176,13 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
161
176
|
}
|
|
162
177
|
}
|
|
163
178
|
|
|
179
|
+
/** Stops the block synchronizer, waiting for any in-progress sync and queued events to complete. */
|
|
180
|
+
public async stop() {
|
|
181
|
+
await this.isSyncing;
|
|
182
|
+
await this.blockStream.stop();
|
|
183
|
+
await this.eventQueue.end();
|
|
184
|
+
}
|
|
185
|
+
|
|
164
186
|
private async doSync() {
|
|
165
187
|
let currentHeader;
|
|
166
188
|
|
|
@@ -171,7 +193,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
171
193
|
}
|
|
172
194
|
if (!currentHeader) {
|
|
173
195
|
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
174
|
-
await this.anchorBlockStore.setHeader((await this.node.
|
|
196
|
+
await this.anchorBlockStore.setHeader((await this.node.getBlock(BlockNumber.ZERO))!.header);
|
|
175
197
|
}
|
|
176
198
|
await this.blockStream.sync();
|
|
177
199
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
booleanConfigHelper,
|
|
4
|
+
enumConfigHelper,
|
|
4
5
|
getConfigFromMappings,
|
|
5
6
|
numberConfigHelper,
|
|
6
7
|
parseBooleanEnv,
|
|
7
8
|
} from '@aztec/foundation/config';
|
|
8
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
9
9
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
10
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
10
11
|
|
|
11
12
|
export { getPackageInfo } from './package_info.js';
|
|
12
13
|
|
|
@@ -58,14 +59,7 @@ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
|
|
|
58
59
|
syncChainTip: {
|
|
59
60
|
env: 'PXE_SYNC_CHAIN_TIP',
|
|
60
61
|
description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
|
|
61
|
-
|
|
62
|
-
parseEnv: (val: string) => {
|
|
63
|
-
const allowedValues = ['proposed', 'checkpointed', 'proven', 'finalized'];
|
|
64
|
-
if (allowedValues.includes(val)) {
|
|
65
|
-
return val;
|
|
66
|
-
}
|
|
67
|
-
throw new Error(`Invalid value for PXE_SYNC_CHAIN_TIP: ${val}. Allowed values are: ${allowedValues.join(', ')}`);
|
|
68
|
-
},
|
|
62
|
+
...enumConfigHelper(['proposed', 'checkpointed', 'proven', 'finalized'], 'proposed'),
|
|
69
63
|
},
|
|
70
64
|
};
|
|
71
65
|
|