@aztec/pxe 0.0.1-commit.8f9871590 → 0.0.1-commit.9117c5f5a
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/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +8 -8
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- 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 +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +4 -7
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +4 -4
- 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 +13 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +8 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +37 -29
- 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 +140 -64
- 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 +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
- package/dest/tagging/index.d.ts +2 -2
- 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 +3 -3
- 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 +3 -6
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -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 +14 -15
- package/package.json +16 -16
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +15 -17
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -20
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +8 -7
- package/src/contract_logging.ts +39 -0
- package/src/debug/pxe_debug_utils.ts +4 -4
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/logs/log_service.ts +10 -5
- 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 +13 -6
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +41 -34
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU5RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7O0dBVUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSxtQ0FBbUMsRUFDM0MsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FtRWYifQ==
|
|
@@ -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,CAmEf"}
|
|
@@ -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,7 +37,7 @@ 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) {
|
|
@@ -1,15 +1,12 @@
|
|
|
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.
|
|
@@ -17,5 +14,5 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
|
|
|
17
14
|
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
18
15
|
* preserving way.
|
|
19
16
|
*/
|
|
20
|
-
export declare function loadAndStoreNewTaggingIndexes(
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
export declare function loadAndStoreNewTaggingIndexes(extendedSecret: ExtendedDirectionalAppTaggingSecret, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7O0dBV0c7QUFDSCx3QkFBc0IsNkJBQTZCLENBQ2pELGNBQWMsRUFBRSxtQ0FBbUMsRUFDbkQsS0FBSyxFQUFFLE1BQU0sRUFDYixHQUFHLEVBQUUsTUFBTSxFQUNYLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFlBQVksRUFBRSxrQkFBa0IsRUFDaEMsZUFBZSxFQUFFLFNBQVMsRUFDMUIsS0FBSyxFQUFFLE1BQU0saUJBZWQifQ==
|
|
@@ -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;;;;;;;;;;;GAWG;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,iBAed"}
|
|
@@ -1,34 +1,33 @@
|
|
|
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.
|
|
15
13
|
* @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
|
|
16
14
|
* preserving way.
|
|
17
|
-
*/ export async function loadAndStoreNewTaggingIndexes(
|
|
15
|
+
*/ export async function loadAndStoreNewTaggingIndexes(extendedSecret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
|
|
18
16
|
// We compute the tags for the current window of indexes
|
|
19
|
-
const
|
|
20
|
-
|
|
17
|
+
const siloedTagsForWindow = await Promise.all(Array.from({
|
|
18
|
+
length: end - start
|
|
19
|
+
}, (_, i)=>SiloedTag.compute({
|
|
20
|
+
extendedSecret,
|
|
21
21
|
index: start + i
|
|
22
|
-
}));
|
|
23
|
-
const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
|
|
22
|
+
})));
|
|
24
23
|
const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
|
|
25
|
-
const highestIndexMap = getTxHighestIndexMap(txsForTags,
|
|
24
|
+
const highestIndexMap = getTxHighestIndexMap(txsForTags, start, siloedTagsForWindow.length);
|
|
26
25
|
// Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
|
|
27
26
|
for (const [txHashStr, highestIndex] of highestIndexMap.entries()){
|
|
28
27
|
const txHash = TxHash.fromString(txHashStr);
|
|
29
28
|
await taggingStore.storePendingIndexes([
|
|
30
29
|
{
|
|
31
|
-
|
|
30
|
+
extendedSecret,
|
|
32
31
|
index: highestIndex
|
|
33
32
|
}
|
|
34
33
|
], txHash, jobId);
|
|
@@ -43,13 +42,13 @@ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
|
|
|
43
42
|
return allLogs.map((logs)=>logs.map((log)=>log.txHash));
|
|
44
43
|
}
|
|
45
44
|
// Returns a map of txHash to the highest index for that txHash.
|
|
46
|
-
function getTxHighestIndexMap(txHashesForTags,
|
|
47
|
-
if (txHashesForTags.length !==
|
|
48
|
-
throw new Error(`Number of tx hashes arrays does not match number of
|
|
45
|
+
function getTxHighestIndexMap(txHashesForTags, start, count) {
|
|
46
|
+
if (txHashesForTags.length !== count) {
|
|
47
|
+
throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
|
|
49
48
|
}
|
|
50
49
|
const highestIndexMap = new Map();
|
|
51
50
|
for(let i = 0; i < txHashesForTags.length; i++){
|
|
52
|
-
const taggingIndex =
|
|
51
|
+
const taggingIndex = start + i;
|
|
53
52
|
const txHashesForTag = txHashesForTags[i];
|
|
54
53
|
for (const txHash of txHashesForTag){
|
|
55
54
|
const key = txHash.toString();
|
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.9117c5f5a",
|
|
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.9117c5f5a",
|
|
74
|
+
"@aztec/bb.js": "0.0.1-commit.9117c5f5a",
|
|
75
|
+
"@aztec/builder": "0.0.1-commit.9117c5f5a",
|
|
76
|
+
"@aztec/constants": "0.0.1-commit.9117c5f5a",
|
|
77
|
+
"@aztec/ethereum": "0.0.1-commit.9117c5f5a",
|
|
78
|
+
"@aztec/foundation": "0.0.1-commit.9117c5f5a",
|
|
79
|
+
"@aztec/key-store": "0.0.1-commit.9117c5f5a",
|
|
80
|
+
"@aztec/kv-store": "0.0.1-commit.9117c5f5a",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.9117c5f5a",
|
|
82
|
+
"@aztec/noir-types": "0.0.1-commit.9117c5f5a",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9117c5f5a",
|
|
84
|
+
"@aztec/simulator": "0.0.1-commit.9117c5f5a",
|
|
85
|
+
"@aztec/stdlib": "0.0.1-commit.9117c5f5a",
|
|
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/merkle-tree": "0.0.1-commit.
|
|
95
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
94
|
+
"@aztec/merkle-tree": "0.0.1-commit.9117c5f5a",
|
|
95
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.9117c5f5a",
|
|
96
96
|
"@jest/globals": "^30.0.0",
|
|
97
97
|
"@types/jest": "^30.0.0",
|
|
98
98
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -2,11 +2,8 @@ import {
|
|
|
2
2
|
AVM_EMITNOTEHASH_BASE_L2_GAS,
|
|
3
3
|
AVM_EMITNULLIFIER_BASE_L2_GAS,
|
|
4
4
|
AVM_SENDL2TOL1MSG_BASE_L2_GAS,
|
|
5
|
-
|
|
6
|
-
DA_GAS_PER_BYTE,
|
|
5
|
+
DA_GAS_PER_FIELD,
|
|
7
6
|
FIXED_AVM_STARTUP_L2_GAS,
|
|
8
|
-
FIXED_DA_GAS,
|
|
9
|
-
FIXED_L2_GAS,
|
|
10
7
|
L2_GAS_PER_CONTRACT_CLASS_LOG,
|
|
11
8
|
L2_GAS_PER_L2_TO_L1_MSG,
|
|
12
9
|
L2_GAS_PER_NOTE_HASH,
|
|
@@ -20,6 +17,9 @@ import {
|
|
|
20
17
|
MAX_NULLIFIERS_PER_TX,
|
|
21
18
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
22
19
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
20
|
+
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
21
|
+
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
22
|
+
TX_DA_GAS_OVERHEAD,
|
|
23
23
|
} from '@aztec/constants';
|
|
24
24
|
import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
|
|
25
25
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -361,7 +361,7 @@ export class ContractFunctionSimulator {
|
|
|
361
361
|
);
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
-
this.log.verbose(`Utility
|
|
364
|
+
this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
365
365
|
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
366
366
|
} catch (err) {
|
|
367
367
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
@@ -654,7 +654,12 @@ export async function generateSimulatedProvingResult(
|
|
|
654
654
|
|
|
655
655
|
const publicInputs = new PrivateKernelTailCircuitPublicInputs(
|
|
656
656
|
constantData,
|
|
657
|
-
/*gasUsed=*/ gasUsed.add(
|
|
657
|
+
/*gasUsed=*/ gasUsed.add(
|
|
658
|
+
Gas.from({
|
|
659
|
+
l2Gas: isPrivateOnlyTx ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
660
|
+
daGas: TX_DA_GAS_OVERHEAD,
|
|
661
|
+
}),
|
|
662
|
+
),
|
|
658
663
|
/*feePayer=*/ AztecAddress.zero(),
|
|
659
664
|
/*expirationTimestamp=*/ 0n,
|
|
660
665
|
hasPublicCalls ? inputsForPublic : undefined,
|
|
@@ -684,6 +689,7 @@ function squashTransientSideEffects(
|
|
|
684
689
|
scopedNullifiersCLA,
|
|
685
690
|
/*futureNoteHashReads=*/ [],
|
|
686
691
|
/*futureNullifierReads=*/ [],
|
|
692
|
+
/*futureLogs=*/ [],
|
|
687
693
|
noteHashNullifierCounterMap,
|
|
688
694
|
minRevertibleSideEffectCounter,
|
|
689
695
|
);
|
|
@@ -726,16 +732,8 @@ async function verifyReadRequests(
|
|
|
726
732
|
nullifierReadRequests.length,
|
|
727
733
|
);
|
|
728
734
|
|
|
729
|
-
const noteHashResetActions = getNoteHashReadRequestResetActions(
|
|
730
|
-
|
|
731
|
-
scopedNoteHashesCLA,
|
|
732
|
-
/*futureNoteHashes=*/ [],
|
|
733
|
-
);
|
|
734
|
-
const nullifierResetActions = getNullifierReadRequestResetActions(
|
|
735
|
-
nullifierReadRequestsCLA,
|
|
736
|
-
scopedNullifiersCLA,
|
|
737
|
-
/*futureNullifiers=*/ [],
|
|
738
|
-
);
|
|
735
|
+
const noteHashResetActions = getNoteHashReadRequestResetActions(noteHashReadRequestsCLA, scopedNoteHashesCLA);
|
|
736
|
+
const nullifierResetActions = getNullifierReadRequestResetActions(nullifierReadRequestsCLA, scopedNullifiersCLA);
|
|
739
737
|
|
|
740
738
|
const settledNoteHashReads: { index: number; value: Fr }[] = [];
|
|
741
739
|
for (let i = 0; i < noteHashResetActions.actions.length; i++) {
|
|
@@ -818,7 +816,7 @@ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccu
|
|
|
818
816
|
);
|
|
819
817
|
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
820
818
|
|
|
821
|
-
const meteredDAGas = meteredDAFields *
|
|
819
|
+
const meteredDAGas = meteredDAFields * DA_GAS_PER_FIELD;
|
|
822
820
|
|
|
823
821
|
if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
|
|
824
822
|
const dataForPublic = data as PrivateToPublicAccumulatedData;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A map that stores the tagging index for a given directional app tagging secret.
|
|
4
|
+
* A map that stores the tagging index for a given extended directional app tagging secret.
|
|
5
5
|
* Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
|
|
6
6
|
* of sender -> recipient matters.
|
|
7
7
|
*/
|
|
8
8
|
export class ExecutionTaggingIndexCache {
|
|
9
9
|
private taggingIndexMap: Map<string, number> = new Map();
|
|
10
10
|
|
|
11
|
-
public getLastUsedIndex(secret:
|
|
11
|
+
public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
|
|
12
12
|
return this.taggingIndexMap.get(secret.toString());
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
public setLastUsedIndex(secret:
|
|
15
|
+
public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
|
|
16
16
|
const currentValue = this.taggingIndexMap.get(secret.toString());
|
|
17
17
|
if (currentValue !== undefined && currentValue !== index - 1) {
|
|
18
18
|
throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
|
|
@@ -25,7 +25,7 @@ export class ExecutionTaggingIndexCache {
|
|
|
25
25
|
*/
|
|
26
26
|
public getUsedPreTags(): PreTag[] {
|
|
27
27
|
return Array.from(this.taggingIndexMap.entries()).map(([secret, index]) => ({
|
|
28
|
-
|
|
28
|
+
extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
|
|
29
29
|
index,
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
@@ -5,7 +5,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
8
|
-
const MAX_EVENT_SERIALIZED_LEN =
|
|
8
|
+
const MAX_EVENT_SERIALIZED_LEN = 10;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
@@ -4,7 +4,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
7
|
-
export const MAX_NOTE_PACKED_LEN =
|
|
7
|
+
export const MAX_NOTE_PACKED_LEN = 8;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
15
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
16
16
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
17
|
-
import { type ContractClassLog,
|
|
17
|
+
import { type ContractClassLog, ExtendedDirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
18
18
|
import { Tag } from '@aztec/stdlib/logs';
|
|
19
19
|
import { Note, type NoteStatus } from '@aztec/stdlib/note';
|
|
20
20
|
import {
|
|
@@ -216,25 +216,29 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
216
216
|
* @returns An app tag to be used in a log.
|
|
217
217
|
*/
|
|
218
218
|
public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
|
|
219
|
-
const
|
|
219
|
+
const extendedSecret = await this.#calculateExtendedDirectionalAppTaggingSecret(
|
|
220
|
+
this.contractAddress,
|
|
221
|
+
sender,
|
|
222
|
+
recipient,
|
|
223
|
+
);
|
|
220
224
|
|
|
221
|
-
const index = await this.#getIndexToUseForSecret(
|
|
225
|
+
const index = await this.#getIndexToUseForSecret(extendedSecret);
|
|
222
226
|
this.log.debug(
|
|
223
227
|
`Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
|
|
224
228
|
);
|
|
225
|
-
this.taggingIndexCache.setLastUsedIndex(
|
|
229
|
+
this.taggingIndexCache.setLastUsedIndex(extendedSecret, index);
|
|
226
230
|
|
|
227
|
-
return Tag.compute({
|
|
231
|
+
return Tag.compute({ extendedSecret, index });
|
|
228
232
|
}
|
|
229
233
|
|
|
230
|
-
async #
|
|
234
|
+
async #calculateExtendedDirectionalAppTaggingSecret(
|
|
231
235
|
contractAddress: AztecAddress,
|
|
232
236
|
sender: AztecAddress,
|
|
233
237
|
recipient: AztecAddress,
|
|
234
238
|
) {
|
|
235
239
|
const senderCompleteAddress = await this.getCompleteAddressOrFail(sender);
|
|
236
240
|
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
|
|
237
|
-
return
|
|
241
|
+
return ExtendedDirectionalAppTaggingSecret.compute(
|
|
238
242
|
senderCompleteAddress,
|
|
239
243
|
senderIvsk,
|
|
240
244
|
recipient,
|
|
@@ -243,7 +247,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
243
247
|
);
|
|
244
248
|
}
|
|
245
249
|
|
|
246
|
-
async #getIndexToUseForSecret(secret:
|
|
250
|
+
async #getIndexToUseForSecret(secret: ExtendedDirectionalAppTaggingSecret): Promise<number> {
|
|
247
251
|
// If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
|
|
248
252
|
const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
|
|
249
253
|
|
|
@@ -255,7 +259,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
255
259
|
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
256
260
|
await syncSenderTaggingIndexes(
|
|
257
261
|
secret,
|
|
258
|
-
this.contractAddress,
|
|
259
262
|
this.aztecNode,
|
|
260
263
|
this.senderTaggingStore,
|
|
261
264
|
await this.anchorBlockHeader.hash(),
|
|
@@ -527,22 +530,13 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
527
530
|
|
|
528
531
|
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
529
532
|
|
|
530
|
-
// When scopes are set and the target contract is a registered account (has keys in the keyStore),
|
|
531
|
-
// expand scopes to include it so nested private calls can sync and read the contract's own notes.
|
|
532
|
-
// We only expand for registered accounts because the log service needs the recipient's keys to derive
|
|
533
|
-
// tagging secrets, which are only available for registered accounts.
|
|
534
|
-
const expandedScopes =
|
|
535
|
-
this.scopes !== 'ALL_SCOPES' && (await this.keyStore.hasAccount(targetContractAddress))
|
|
536
|
-
? [...this.scopes, targetContractAddress]
|
|
537
|
-
: this.scopes;
|
|
538
|
-
|
|
539
533
|
await this.contractSyncService.ensureContractSynced(
|
|
540
534
|
targetContractAddress,
|
|
541
535
|
functionSelector,
|
|
542
536
|
this.utilityExecutor,
|
|
543
537
|
this.anchorBlockHeader,
|
|
544
538
|
this.jobId,
|
|
545
|
-
|
|
539
|
+
this.scopes,
|
|
546
540
|
);
|
|
547
541
|
|
|
548
542
|
const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
|
|
@@ -580,7 +574,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
580
574
|
totalPublicCalldataCount: this.totalPublicCalldataCount,
|
|
581
575
|
sideEffectCounter,
|
|
582
576
|
log: this.log,
|
|
583
|
-
scopes:
|
|
577
|
+
scopes: this.scopes,
|
|
584
578
|
senderForTags: this.senderForTags,
|
|
585
579
|
simulator: this.simulator!,
|
|
586
580
|
});
|
|
@@ -3,7 +3,7 @@ import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { Aes128 } from '@aztec/foundation/crypto/aes128';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
6
|
-
import { LogLevels, type Logger,
|
|
6
|
+
import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log';
|
|
7
7
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
8
|
import type { KeyStore } from '@aztec/key-store';
|
|
9
9
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -21,6 +21,7 @@ import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from
|
|
|
21
21
|
import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
|
|
22
22
|
|
|
23
23
|
import type { AccessScopes } from '../../access_scopes.js';
|
|
24
|
+
import { createContractLogger, logContractMessage } from '../../contract_logging.js';
|
|
24
25
|
import { EventService } from '../../events/event_service.js';
|
|
25
26
|
import { LogService } from '../../logs/log_service.js';
|
|
26
27
|
import { NoteService } from '../../notes/note_service.js';
|
|
@@ -402,12 +403,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
402
403
|
*/
|
|
403
404
|
async #getContractLogger(): Promise<Logger> {
|
|
404
405
|
if (!this.contractLogger) {
|
|
405
|
-
const addrAbbrev = this.contractAddress.toString().slice(0, 10);
|
|
406
|
-
const name = await this.contractStore.getDebugContractName(this.contractAddress);
|
|
407
|
-
const module = name ? `contract_log::${name}(${addrAbbrev})` : `contract_log::${addrAbbrev}`;
|
|
408
406
|
// Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
|
|
409
407
|
// to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
|
|
410
|
-
this.contractLogger =
|
|
408
|
+
this.contractLogger = await createContractLogger(
|
|
409
|
+
this.contractAddress,
|
|
410
|
+
addr => this.contractStore.getDebugContractName(addr),
|
|
411
|
+
{ instanceId: this.jobId },
|
|
412
|
+
);
|
|
411
413
|
}
|
|
412
414
|
return this.contractLogger;
|
|
413
415
|
}
|
|
@@ -416,9 +418,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
416
418
|
if (!LogLevels[level]) {
|
|
417
419
|
throw new Error(`Invalid log level: ${level}`);
|
|
418
420
|
}
|
|
419
|
-
const levelName = LogLevels[level];
|
|
420
421
|
const logger = await this.#getContractLogger();
|
|
421
|
-
logger[
|
|
422
|
+
logContractMessage(logger, LogLevels[level], message, fields);
|
|
422
423
|
}
|
|
423
424
|
|
|
424
425
|
public async utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type LogLevel, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
5
|
+
|
|
6
|
+
/** Resolves a contract address to a human-readable name, if available. */
|
|
7
|
+
export type ContractNameResolver = (address: AztecAddress) => Promise<string | undefined>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a logger whose output is prefixed with `contract_log::<name>(<addrAbbrev>)`.
|
|
11
|
+
*/
|
|
12
|
+
export async function createContractLogger(
|
|
13
|
+
contractAddress: AztecAddress,
|
|
14
|
+
getContractName: ContractNameResolver,
|
|
15
|
+
options?: { instanceId?: string },
|
|
16
|
+
): Promise<Logger> {
|
|
17
|
+
const addrAbbrev = contractAddress.toString().slice(0, 10);
|
|
18
|
+
const name = await getContractName(contractAddress);
|
|
19
|
+
const module = name ? `contract_log::${name}(${addrAbbrev})` : `contract_log::Unknown(${addrAbbrev})`;
|
|
20
|
+
return createLogger(module, options);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Formats and emits a single contract log message through the given logger.
|
|
25
|
+
*/
|
|
26
|
+
export function logContractMessage(logger: Logger, level: LogLevel, message: string, fields: Fr[]): void {
|
|
27
|
+
logger[level](applyStringFormatting(message, fields));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Displays debug logs collected during public function simulation,
|
|
32
|
+
* using the `contract_log::` prefixed logger format.
|
|
33
|
+
*/
|
|
34
|
+
export async function displayDebugLogs(debugLogs: DebugLog[], getContractName: ContractNameResolver): Promise<void> {
|
|
35
|
+
for (const log of debugLogs) {
|
|
36
|
+
const logger = await createContractLogger(log.contractAddress, getContractName);
|
|
37
|
+
logContractMessage(logger, log.level, log.message, log.fields);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -18,7 +18,7 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
18
18
|
export class PXEDebugUtils {
|
|
19
19
|
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
20
20
|
#getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
|
|
21
|
-
#
|
|
21
|
+
#executeUtility!: (
|
|
22
22
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
23
23
|
call: FunctionCall,
|
|
24
24
|
authWitnesses: AuthWitness[] | undefined,
|
|
@@ -37,7 +37,7 @@ export class PXEDebugUtils {
|
|
|
37
37
|
public setPXEHelpers(
|
|
38
38
|
putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
|
|
39
39
|
getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
|
|
40
|
-
|
|
40
|
+
executeUtility: (
|
|
41
41
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
42
42
|
call: FunctionCall,
|
|
43
43
|
authWitnesses: AuthWitness[] | undefined,
|
|
@@ -47,7 +47,7 @@ export class PXEDebugUtils {
|
|
|
47
47
|
) {
|
|
48
48
|
this.#putJobInQueue = putJobInQueue;
|
|
49
49
|
this.#getSimulatorForTx = getSimulatorForTx;
|
|
50
|
-
this.#
|
|
50
|
+
this.#executeUtility = executeUtility;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -73,7 +73,7 @@ export class PXEDebugUtils {
|
|
|
73
73
|
filter.contractAddress,
|
|
74
74
|
null,
|
|
75
75
|
async (privateSyncCall, execScopes) =>
|
|
76
|
-
await this.#
|
|
76
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
77
77
|
anchorBlockHeader,
|
|
78
78
|
jobId,
|
|
79
79
|
filter.scopes,
|
|
@@ -3,6 +3,7 @@ export * from '../../../notes_filter.js';
|
|
|
3
3
|
export * from '../../../pxe.js';
|
|
4
4
|
export * from '../../../config/index.js';
|
|
5
5
|
export * from '../../../error_enriching.js';
|
|
6
|
+
export * from '../../../contract_logging.js';
|
|
6
7
|
export * from '../../../storage/index.js';
|
|
7
8
|
export * from './utils.js';
|
|
8
9
|
export type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -4,5 +4,6 @@ export * from '../../../pxe.js';
|
|
|
4
4
|
export * from '../../../config/index.js';
|
|
5
5
|
export * from '../../../storage/index.js';
|
|
6
6
|
export * from '../../../error_enriching.js';
|
|
7
|
+
export * from '../../../contract_logging.js';
|
|
7
8
|
export * from './utils.js';
|
|
8
9
|
export { type PXECreationOptions } from '../../pxe_creation_options.js';
|