@aztec/pxe 3.0.0-nightly.20251208 → 3.0.0-nightly.20251210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +2 -2
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +2 -2
- package/dest/contract_function_simulator/execution_data_provider.d.ts +3 -2
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +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 +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/utility_context.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +2 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +4 -3
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +8 -2
- package/dest/entrypoints/client/bundle/utils.js +1 -1
- package/dest/entrypoints/client/lazy/utils.js +1 -1
- package/dest/entrypoints/server/utils.js +1 -1
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +8 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +39 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -4
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/pxe.d.ts +14 -14
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +15 -12
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +2 -2
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -2
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +30 -16
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +35 -25
- package/dest/tagging/siloed_tag.d.ts +2 -2
- package/dest/tagging/siloed_tag.d.ts.map +1 -1
- package/dest/tagging/siloed_tag.js +1 -1
- package/dest/tagging/tag.d.ts +2 -2
- package/dest/tagging/tag.d.ts.map +1 -1
- package/dest/tagging/tag.js +1 -1
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +2 -2
- package/src/contract_function_simulator/execution_data_provider.ts +2 -1
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +2 -1
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +2 -1
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +1 -1
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +3 -2
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/pxe_oracle_interface.ts +10 -7
- package/src/entrypoints/client/bundle/utils.ts +1 -1
- package/src/entrypoints/client/lazy/utils.ts +1 -1
- package/src/entrypoints/server/utils.ts +1 -1
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +47 -0
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +1 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +4 -4
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +2 -1
- package/src/pxe.ts +23 -25
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +1 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +1 -1
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +58 -39
- package/src/tagging/siloed_tag.ts +2 -2
- package/src/tagging/tag.ts +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Aes128 } from '@aztec/foundation/crypto';
|
|
3
|
-
import { Fr
|
|
2
|
+
import { Aes128 } from '@aztec/foundation/crypto/aes128';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { timesParallel } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { KeyStore } from '@aztec/key-store';
|
|
6
7
|
import { EventSelector, type FunctionArtifactWithContractName, FunctionSelector } from '@aztec/stdlib/abi';
|
|
@@ -793,7 +794,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
793
794
|
content: Fr[],
|
|
794
795
|
eventCommitment: Fr,
|
|
795
796
|
txHash: TxHash,
|
|
796
|
-
|
|
797
|
+
scope: AztecAddress,
|
|
797
798
|
): Promise<void> {
|
|
798
799
|
// While using 'latest' block number would be fine for private events since they cannot be accessed from Aztec.nr
|
|
799
800
|
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
@@ -831,14 +832,16 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
831
832
|
}
|
|
832
833
|
|
|
833
834
|
return this.privateEventDataProvider.storePrivateEventLog(
|
|
834
|
-
contractAddress,
|
|
835
|
-
recipient,
|
|
836
835
|
selector,
|
|
837
836
|
content,
|
|
838
|
-
txHash,
|
|
839
837
|
Number(nullifierIndex.data), // Index of the event commitment in the nullifier tree
|
|
840
|
-
|
|
841
|
-
|
|
838
|
+
{
|
|
839
|
+
contractAddress,
|
|
840
|
+
scope,
|
|
841
|
+
txHash,
|
|
842
|
+
l2BlockNumber: nullifierIndex.l2BlockNumber, // Block number in which the event was emitted
|
|
843
|
+
l2BlockHash: nullifierIndex.l2BlockHash, // Block hash in which the event was emitted
|
|
844
|
+
},
|
|
842
845
|
);
|
|
843
846
|
}
|
|
844
847
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
2
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
5
5
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BBLazyPrivateKernelProver } from '@aztec/bb-prover/client/lazy';
|
|
2
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
5
5
|
import { LazyProtocolContractsProvider } from '@aztec/protocol-contracts/providers/lazy';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
2
|
-
import { randomBytes } from '@aztec/foundation/crypto';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
5
5
|
import {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './private_event_filter_validator.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
|
|
5
|
+
import type { PrivateEventDataProviderFilter, SyncDataProvider } from '../storage/index.js';
|
|
6
|
+
|
|
7
|
+
export class PrivateEventFilterValidator {
|
|
8
|
+
constructor(private syncDataProvider: SyncDataProvider) {}
|
|
9
|
+
|
|
10
|
+
async validate(filter: PrivateEventFilter): Promise<PrivateEventDataProviderFilter> {
|
|
11
|
+
let { fromBlock, toBlock } = filter;
|
|
12
|
+
|
|
13
|
+
// Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
|
|
14
|
+
// we respect that convention here for consistency.
|
|
15
|
+
// We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
|
|
16
|
+
// the first block to the latest known block.
|
|
17
|
+
if (!fromBlock || !toBlock) {
|
|
18
|
+
const lastKnownBlock = await this.syncDataProvider.getBlockNumber();
|
|
19
|
+
fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
|
|
20
|
+
toBlock = toBlock ?? BlockNumber(lastKnownBlock + 1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (filter.scopes.length === 0) {
|
|
24
|
+
throw new Error('At least one scope is required to get private events');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (fromBlock < 1) {
|
|
28
|
+
throw new Error('fromBlock must be greater than or equal to 1');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (toBlock < 1) {
|
|
32
|
+
throw new Error('toBlock must be greater than or equal to 1');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (fromBlock >= toBlock) {
|
|
36
|
+
throw new Error('toBlock must be strictly greater than fromBlock');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
contractAddress: filter.contractAddress,
|
|
41
|
+
scopes: filter.scopes,
|
|
42
|
+
txHash: filter.txHash,
|
|
43
|
+
toBlock,
|
|
44
|
+
fromBlock,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@aztec/constants';
|
|
10
10
|
import { makeTuple } from '@aztec/foundation/array';
|
|
11
11
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
12
|
-
import type { Fr } from '@aztec/foundation/
|
|
12
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
14
14
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
15
15
|
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
5
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -290,8 +290,8 @@ export class PrivateKernelExecutionProver {
|
|
|
290
290
|
},
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
// Hiding
|
|
294
|
-
// For simulation, we can end with the tail, since the
|
|
293
|
+
// Hiding kernel is only executed if we are generating witnesses.
|
|
294
|
+
// For simulation, we can end with the tail, since the Hiding kernel will simply return the same tail output.
|
|
295
295
|
if (generateWitnesses) {
|
|
296
296
|
const previousKernelVkData = await this.getVkData(tailOutput.verificationKey);
|
|
297
297
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
3
4
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
5
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
5
6
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
package/src/pxe.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -18,7 +19,6 @@ import {
|
|
|
18
19
|
} from '@aztec/stdlib/abi';
|
|
19
20
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
21
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
-
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
22
|
import {
|
|
23
23
|
CompleteAddress,
|
|
24
24
|
type ContractClassWithId,
|
|
@@ -39,6 +39,7 @@ import type { NotesFilter } from '@aztec/stdlib/note';
|
|
|
39
39
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
40
40
|
import {
|
|
41
41
|
type ContractOverrides,
|
|
42
|
+
type InTx,
|
|
42
43
|
PrivateExecutionResult,
|
|
43
44
|
PrivateSimulationResult,
|
|
44
45
|
type ProvingTimings,
|
|
@@ -47,7 +48,6 @@ import {
|
|
|
47
48
|
type SimulationTimings,
|
|
48
49
|
Tx,
|
|
49
50
|
TxExecutionRequest,
|
|
50
|
-
TxHash,
|
|
51
51
|
TxProfileResult,
|
|
52
52
|
TxProvingResult,
|
|
53
53
|
TxSimulationResult,
|
|
@@ -66,6 +66,7 @@ import { ProxiedContractDataProviderFactory } from './contract_function_simulato
|
|
|
66
66
|
import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.js';
|
|
67
67
|
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
68
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
|
+
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
69
70
|
import {
|
|
70
71
|
PrivateKernelExecutionProver,
|
|
71
72
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -80,12 +81,8 @@ import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provide
|
|
|
80
81
|
import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
|
|
81
82
|
import { Synchronizer } from './synchronizer/index.js';
|
|
82
83
|
|
|
83
|
-
export type
|
|
84
|
+
export type PackedPrivateEvent = InTx & {
|
|
84
85
|
packedEvent: Fr[];
|
|
85
|
-
blockNumber: number;
|
|
86
|
-
blockHash: L2BlockHash;
|
|
87
|
-
txHash: TxHash;
|
|
88
|
-
recipient: AztecAddress;
|
|
89
86
|
eventSelector: EventSelector;
|
|
90
87
|
};
|
|
91
88
|
|
|
@@ -1049,31 +1046,32 @@ export class PXE {
|
|
|
1049
1046
|
|
|
1050
1047
|
/**
|
|
1051
1048
|
* Returns the private events given search parameters.
|
|
1052
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
1053
1049
|
* @param eventSelector - Event selector to search for.
|
|
1054
|
-
* @param
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1050
|
+
* @param filter
|
|
1051
|
+
* contractAddress - The address of the contract to get events from. Required.
|
|
1052
|
+
* scopes - One or more event scope addresses to filter by. Required.
|
|
1053
|
+
* fromBlock - The block number to search from (inclusive). Optional. If provided, it must be >= 0.
|
|
1054
|
+
* Defaults to 0.
|
|
1055
|
+
* If toBlock is defined but fromBlock is not, fromBlock defaults to toBlock - 1.
|
|
1056
|
+
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
1057
|
+
* Defaults to the latest known block to PXE + 1.
|
|
1057
1058
|
* @returns - The packed events with block and tx metadata.
|
|
1058
1059
|
*/
|
|
1059
1060
|
public async getPrivateEvents(
|
|
1060
|
-
contractAddress: AztecAddress,
|
|
1061
1061
|
eventSelector: EventSelector,
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
recipients: AztecAddress[],
|
|
1065
|
-
): Promise<PrivateEvent[]> {
|
|
1066
|
-
if (recipients.length === 0) {
|
|
1067
|
-
throw new Error('Recipients are required to get private events');
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
1071
|
-
|
|
1062
|
+
filter: PrivateEventFilter,
|
|
1063
|
+
): Promise<PackedPrivateEvent[]> {
|
|
1072
1064
|
// We need to manually trigger private state sync to have a guarantee that all the events are available.
|
|
1073
|
-
const call = await this.#getFunctionCall('sync_private_state', [], contractAddress);
|
|
1065
|
+
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
1074
1066
|
await this.simulateUtility(call);
|
|
1075
1067
|
|
|
1076
|
-
|
|
1068
|
+
const sanitizedFilter = await new PrivateEventFilterValidator(this.syncDataProvider).validate(filter);
|
|
1069
|
+
|
|
1070
|
+
this.log.error(
|
|
1071
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1072
|
+
);
|
|
1073
|
+
|
|
1074
|
+
return this.privateEventDataProvider.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1077
1075
|
}
|
|
1078
1076
|
|
|
1079
1077
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
4
4
|
import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
|
|
5
5
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
6
|
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
8
|
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
8
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
import { type InTx, TxHash } from '@aztec/stdlib/tx';
|
|
9
10
|
|
|
10
|
-
import type {
|
|
11
|
+
import type { PackedPrivateEvent } from '../../pxe.js';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
export type PrivateEventDataProviderFilter = {
|
|
14
|
+
contractAddress: AztecAddress;
|
|
15
|
+
fromBlock: number;
|
|
16
|
+
toBlock: number;
|
|
17
|
+
scopes: AztecAddress[];
|
|
18
|
+
txHash?: TxHash;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type PrivateEventEntry = {
|
|
13
22
|
msgContent: Buffer;
|
|
14
|
-
blockNumber: number;
|
|
15
|
-
blockHash: Buffer;
|
|
16
23
|
eventCommitmentIndex: number;
|
|
24
|
+
l2BlockNumber: number;
|
|
25
|
+
l2BlockHash: Buffer;
|
|
17
26
|
txHash: Buffer;
|
|
18
|
-
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type PrivateEventMetadata = InTx & {
|
|
30
|
+
contractAddress: AztecAddress;
|
|
31
|
+
scope: AztecAddress;
|
|
32
|
+
};
|
|
19
33
|
|
|
20
34
|
/**
|
|
21
35
|
* Stores decrypted private event logs.
|
|
@@ -24,7 +38,7 @@ export class PrivateEventDataProvider {
|
|
|
24
38
|
#store: AztecAsyncKVStore;
|
|
25
39
|
/** Array storing the actual private event log entries containing the log content and block number */
|
|
26
40
|
#eventLogs: AztecAsyncArray<PrivateEventEntry>;
|
|
27
|
-
/** Map from
|
|
41
|
+
/** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
|
|
28
42
|
#eventLogIndex: AztecAsyncMap<string, number[]>;
|
|
29
43
|
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
|
|
30
44
|
#seenLogs: AztecAsyncMap<number, boolean>;
|
|
@@ -38,28 +52,31 @@ export class PrivateEventDataProvider {
|
|
|
38
52
|
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
39
53
|
}
|
|
40
54
|
|
|
55
|
+
#keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
|
|
56
|
+
return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
/**
|
|
42
60
|
* Store a private event log.
|
|
43
|
-
* @param contractAddress - The address of the contract that emitted the event.
|
|
44
|
-
* @param recipient - The recipient of the event.
|
|
45
61
|
* @param eventSelector - The event selector of the event.
|
|
46
62
|
* @param msgContent - The content of the event.
|
|
47
|
-
* @param txHash - The transaction hash of the event log.
|
|
48
63
|
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
49
|
-
* @param
|
|
64
|
+
* @param metadata
|
|
65
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
66
|
+
* scope - The address to which the event is scoped.
|
|
67
|
+
* txHash - The transaction hash of the event log.
|
|
68
|
+
* blockNumber - The block number in which the event was emitted.
|
|
50
69
|
*/
|
|
51
70
|
storePrivateEventLog(
|
|
52
|
-
contractAddress: AztecAddress,
|
|
53
|
-
recipient: AztecAddress,
|
|
54
71
|
eventSelector: EventSelector,
|
|
55
72
|
msgContent: Fr[],
|
|
56
|
-
txHash: TxHash,
|
|
57
73
|
eventCommitmentIndex: number,
|
|
58
|
-
|
|
59
|
-
blockHash: L2BlockHash,
|
|
74
|
+
metadata: PrivateEventMetadata,
|
|
60
75
|
): Promise<void> {
|
|
76
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
77
|
+
|
|
61
78
|
return this.#store.transactionAsync(async () => {
|
|
62
|
-
const key =
|
|
79
|
+
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
63
80
|
|
|
64
81
|
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
65
82
|
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
@@ -68,13 +85,13 @@ export class PrivateEventDataProvider {
|
|
|
68
85
|
return;
|
|
69
86
|
}
|
|
70
87
|
|
|
71
|
-
this.logger.verbose('storing private event log', { contractAddress,
|
|
88
|
+
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
72
89
|
|
|
73
90
|
const index = await this.#eventLogs.lengthAsync();
|
|
74
91
|
await this.#eventLogs.push({
|
|
75
92
|
msgContent: serializeToBuffer(msgContent),
|
|
76
|
-
|
|
77
|
-
|
|
93
|
+
l2BlockNumber,
|
|
94
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
78
95
|
eventCommitmentIndex,
|
|
79
96
|
txHash: txHash.toBuffer(),
|
|
80
97
|
});
|
|
@@ -89,29 +106,28 @@ export class PrivateEventDataProvider {
|
|
|
89
106
|
|
|
90
107
|
/**
|
|
91
108
|
* Returns the private events given search parameters.
|
|
92
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
93
|
-
* @param from - The block number to search from.
|
|
94
|
-
* @param numBlocks - The amount of blocks to search.
|
|
95
|
-
* @param recipients - The addresses that decrypted the logs.
|
|
96
109
|
* @param eventSelector - The event selector to filter by.
|
|
97
|
-
* @
|
|
110
|
+
* @param filter - Filtering criteria:
|
|
111
|
+
* contractAddress: The address of the contract to get events from.
|
|
112
|
+
* fromBlock: The block number to search from (inclusive).
|
|
113
|
+
* toBlock: The block number to search upto (exclusive).
|
|
114
|
+
* scope: - The addresses that decrypted the logs.
|
|
115
|
+
* @returns - The event log contents, augmented with metadata about
|
|
116
|
+
* the transaction and block it the event was included in .
|
|
98
117
|
*/
|
|
99
118
|
public async getPrivateEvents(
|
|
100
|
-
contractAddress: AztecAddress,
|
|
101
|
-
from: number,
|
|
102
|
-
numBlocks: number,
|
|
103
|
-
recipients: AztecAddress[],
|
|
104
119
|
eventSelector: EventSelector,
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
filter: PrivateEventDataProviderFilter,
|
|
121
|
+
): Promise<PackedPrivateEvent[]> {
|
|
122
|
+
const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
|
|
107
123
|
|
|
108
|
-
for (const
|
|
109
|
-
const key =
|
|
124
|
+
for (const scope of filter.scopes) {
|
|
125
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
110
126
|
const indices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
111
127
|
|
|
112
128
|
for (const index of indices) {
|
|
113
129
|
const entry = await this.#eventLogs.atAsync(index);
|
|
114
|
-
if (!entry || entry.
|
|
130
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
115
131
|
continue;
|
|
116
132
|
}
|
|
117
133
|
|
|
@@ -120,16 +136,19 @@ export class PrivateEventDataProvider {
|
|
|
120
136
|
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
121
137
|
const msgContent = reader.readArray(numFields, Fr);
|
|
122
138
|
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
123
|
-
const
|
|
139
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
140
|
+
|
|
141
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
124
144
|
|
|
125
145
|
events.push({
|
|
126
146
|
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
127
147
|
event: {
|
|
128
148
|
packedEvent: msgContent,
|
|
129
|
-
|
|
130
|
-
recipient,
|
|
149
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
131
150
|
txHash,
|
|
132
|
-
|
|
151
|
+
l2BlockHash,
|
|
133
152
|
eventSelector,
|
|
134
153
|
},
|
|
135
154
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
|
|
5
5
|
import type { Tag } from './tag.js';
|
package/src/tagging/tag.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { PreTag } from '@aztec/stdlib/logs';
|
|
4
4
|
|
|
5
5
|
/**
|