@aztec/pxe 0.0.1-commit.cf93bcc56 → 0.0.1-commit.d0fcfb7f
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 +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +7 -3
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +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 +8 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +9 -5
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +15 -11
- 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 +125 -64
- 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 +6 -6
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +27 -23
- 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/interfaces.ts +5 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +12 -9
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +20 -13
- 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 +157 -110
- 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 +33 -30
- 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,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
|
|
@@ -6,8 +6,9 @@ import { MembershipWitness } from '@aztec/foundation/trees';
|
|
|
6
6
|
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
11
|
+
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
11
12
|
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
|
|
12
13
|
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
13
14
|
import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -85,7 +86,9 @@ export interface IUtilityExecutionOracle {
|
|
|
85
86
|
nullifier: Fr,
|
|
86
87
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
87
88
|
utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
|
|
88
|
-
utilityTryGetPublicKeysAndPartialAddress(
|
|
89
|
+
utilityTryGetPublicKeysAndPartialAddress(
|
|
90
|
+
account: AztecAddress,
|
|
91
|
+
): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
|
|
89
92
|
utilityGetAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
|
|
90
93
|
utilityGetNotes(
|
|
91
94
|
owner: AztecAddress | undefined,
|
|
@@ -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(),
|
|
@@ -3,17 +3,17 @@ 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';
|
|
10
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
11
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
12
|
-
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
12
|
+
import type { CompleteAddress, ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
|
|
13
13
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
14
14
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
15
15
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
16
|
-
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
16
|
+
import { type PublicKeys, computeAddressSecret } from '@aztec/stdlib/keys';
|
|
17
17
|
import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
18
18
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
19
19
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
@@ -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';
|
|
@@ -231,12 +232,18 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
/**
|
|
234
|
-
* Retrieve the
|
|
235
|
+
* Retrieve the public keys and partial address associated to a given address.
|
|
235
236
|
* @param account - The account address.
|
|
236
|
-
* @returns
|
|
237
|
+
* @returns The public keys and partial address, or `undefined` if the account is not registered.
|
|
237
238
|
*/
|
|
238
|
-
public utilityTryGetPublicKeysAndPartialAddress(
|
|
239
|
-
|
|
239
|
+
public async utilityTryGetPublicKeysAndPartialAddress(
|
|
240
|
+
account: AztecAddress,
|
|
241
|
+
): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined> {
|
|
242
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
243
|
+
if (!completeAddress) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
return { publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress };
|
|
240
247
|
}
|
|
241
248
|
|
|
242
249
|
protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
|
|
@@ -402,12 +409,13 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
402
409
|
*/
|
|
403
410
|
async #getContractLogger(): Promise<Logger> {
|
|
404
411
|
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
412
|
// Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
|
|
409
413
|
// to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
|
|
410
|
-
this.contractLogger =
|
|
414
|
+
this.contractLogger = await createContractLogger(
|
|
415
|
+
this.contractAddress,
|
|
416
|
+
addr => this.contractStore.getDebugContractName(addr),
|
|
417
|
+
{ instanceId: this.jobId },
|
|
418
|
+
);
|
|
411
419
|
}
|
|
412
420
|
return this.contractLogger;
|
|
413
421
|
}
|
|
@@ -416,9 +424,8 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
416
424
|
if (!LogLevels[level]) {
|
|
417
425
|
throw new Error(`Invalid log level: ${level}`);
|
|
418
426
|
}
|
|
419
|
-
const levelName = LogLevels[level];
|
|
420
427
|
const logger = await this.#getContractLogger();
|
|
421
|
-
logger[
|
|
428
|
+
logContractMessage(logger, LogLevels[level], message, fields);
|
|
422
429
|
}
|
|
423
430
|
|
|
424
431
|
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';
|
package/src/logs/log_service.ts
CHANGED
|
@@ -3,7 +3,13 @@ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundatio
|
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ExtendedDirectionalAppTaggingSecret,
|
|
8
|
+
PendingTaggedLog,
|
|
9
|
+
SiloedTag,
|
|
10
|
+
Tag,
|
|
11
|
+
TxScopedL2Log,
|
|
12
|
+
} from '@aztec/stdlib/logs';
|
|
7
13
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
14
|
|
|
9
15
|
import type { AccessScopes } from '../access_scopes.js';
|
|
@@ -41,7 +47,7 @@ export class LogService {
|
|
|
41
47
|
logRetrievalRequests.map(async request => {
|
|
42
48
|
const [publicLog, privateLog] = await Promise.all([
|
|
43
49
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
44
|
-
this.#getPrivateLogByTag(await SiloedTag.
|
|
50
|
+
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
|
|
45
51
|
]);
|
|
46
52
|
|
|
47
53
|
if (publicLog !== null && privateLog !== null) {
|
|
@@ -130,7 +136,6 @@ export class LogService {
|
|
|
130
136
|
secrets.map(secret =>
|
|
131
137
|
loadPrivateLogsForSenderRecipientPair(
|
|
132
138
|
secret,
|
|
133
|
-
contractAddress,
|
|
134
139
|
this.aztecNode,
|
|
135
140
|
this.recipientTaggingStore,
|
|
136
141
|
anchorBlockNumber,
|
|
@@ -154,7 +159,7 @@ export class LogService {
|
|
|
154
159
|
async #getSecretsForSenders(
|
|
155
160
|
contractAddress: AztecAddress,
|
|
156
161
|
recipient: AztecAddress,
|
|
157
|
-
): Promise<
|
|
162
|
+
): Promise<ExtendedDirectionalAppTaggingSecret[]> {
|
|
158
163
|
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
159
164
|
if (!recipientCompleteAddress) {
|
|
160
165
|
return [];
|
|
@@ -172,7 +177,7 @@ export class LogService {
|
|
|
172
177
|
|
|
173
178
|
return Promise.all(
|
|
174
179
|
deduplicatedSenders.map(sender => {
|
|
175
|
-
return
|
|
180
|
+
return ExtendedDirectionalAppTaggingSecret.compute(
|
|
176
181
|
recipientCompleteAddress,
|
|
177
182
|
recipientIvsk,
|
|
178
183
|
sender,
|