@aztec/pxe 0.0.1-commit.2ed92850 → 0.0.1-commit.3469e52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +4 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +11 -51
- package/dest/config/index.d.ts +1 -3
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +0 -17
- 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 +4 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- 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 +5 -8
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +11 -21
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +22 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +37 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -9
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +5 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +7 -15
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +36 -34
- package/dest/debug/pxe_debug_utils.d.ts +1 -1
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +2 -3
- package/dest/entrypoints/server/index.d.ts +1 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +0 -1
- package/dest/events/event_service.d.ts +2 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +1 -1
- 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 +11 -17
- package/dest/notes/note_service.d.ts +3 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +10 -11
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +3 -4
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +9 -11
- package/dest/storage/contract_store/contract_store.d.ts +2 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +12 -0
- package/dest/storage/note_store/note_store.d.ts +55 -43
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +252 -238
- package/dest/storage/private_event_store/private_event_store.d.ts +4 -17
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +135 -163
- package/dest/tagging/index.d.ts +1 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -3
- 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 +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +2 -3
- 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 +2 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +2 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +2 -2
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +8 -5
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -3
- 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 +4 -7
- package/dest/tree_membership/tree_membership_service.d.ts +50 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +75 -0
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +0 -1
- package/src/block_synchronizer/block_synchronizer.ts +14 -53
- package/src/config/index.ts +0 -14
- package/src/contract_function_simulator/contract_function_simulator.ts +9 -1
- 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 +4 -13
- package/src/contract_function_simulator/oracle/oracle.ts +15 -28
- package/src/contract_function_simulator/oracle/private_execution.ts +60 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +6 -32
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +41 -49
- package/src/debug/pxe_debug_utils.ts +2 -3
- package/src/entrypoints/server/index.ts +0 -1
- package/src/events/event_service.ts +1 -1
- package/src/logs/log_service.ts +8 -24
- package/src/notes/note_service.ts +15 -18
- package/src/oracle_version.ts +3 -4
- package/src/pxe.ts +10 -33
- package/src/storage/contract_store/contract_store.ts +20 -0
- package/src/storage/note_store/note_store.ts +313 -279
- package/src/storage/private_event_store/private_event_store.ts +175 -214
- package/src/tagging/index.ts +0 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +1 -11
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +1 -7
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -3
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +17 -5
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +3 -12
- package/src/tree_membership/tree_membership_service.ts +97 -0
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/contract_sync/index.js +0 -54
- package/dest/storage/note_store/stored_note.d.ts +0 -16
- package/dest/storage/note_store/stored_note.d.ts.map +0 -1
- package/dest/storage/note_store/stored_note.js +0 -43
- package/dest/storage/private_event_store/stored_private_event.d.ts +0 -23
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +0 -1
- package/dest/storage/private_event_store/stored_private_event.js +0 -56
- package/dest/tagging/get_all_logs_by_tags.d.ts +0 -24
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +0 -1
- package/dest/tagging/get_all_logs_by_tags.js +0 -46
- package/src/contract_sync/index.ts +0 -98
- package/src/storage/note_store/stored_note.ts +0 -48
- package/src/storage/private_event_store/stored_private_event.ts +0 -73
- package/src/tagging/get_all_logs_by_tags.ts +0 -68
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
8
|
+
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
9
|
+
|
|
10
|
+
// TODO: REmove this class as it no longer seems valuable. The only somewhat real functionality in this class is in
|
|
11
|
+
// the `getMembershipWitness` method that is used by `utilityGetMembershipWitness` oracle by then in Aztec.nr we
|
|
12
|
+
// have helper functions around that oracle for archive and note hash tree and the generic method itself is not used
|
|
13
|
+
// anywhere else - make sense to just have simple specific handlers for the archive and note hash trees and drop this.
|
|
14
|
+
export class TreeMembershipService {
|
|
15
|
+
constructor(private readonly aztecNode: AztecNode) {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets the index of a nullifier in the nullifier tree.
|
|
19
|
+
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
20
|
+
*/
|
|
21
|
+
public async getNullifierIndex(nullifier: Fr): Promise<bigint | undefined> {
|
|
22
|
+
const [leafIndex] = await this.aztecNode.findLeavesIndexes('latest', MerkleTreeId.NULLIFIER_TREE, [nullifier]);
|
|
23
|
+
return leafIndex?.data;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
28
|
+
* @param blockHash - The block hash at which to get the membership witness.
|
|
29
|
+
* @param treeId - Id of the tree to get the sibling path from.
|
|
30
|
+
* @param leafValue - The leaf value
|
|
31
|
+
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
32
|
+
*/
|
|
33
|
+
public async getMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
|
|
34
|
+
const witness = await this.#tryGetMembershipWitness(blockHash, treeId, leafValue);
|
|
35
|
+
if (!witness) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block hash ${blockHash.toString()}`,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return witness;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
45
|
+
* @param blockHash - The block hash at which to get the index.
|
|
46
|
+
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
47
|
+
* @returns The low nullifier membership witness (if found).
|
|
48
|
+
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
49
|
+
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
50
|
+
* we are trying to prove non-inclusion for.
|
|
51
|
+
*/
|
|
52
|
+
public getLowNullifierMembershipWitness(
|
|
53
|
+
blockHash: L2BlockHash,
|
|
54
|
+
nullifier: Fr,
|
|
55
|
+
): Promise<NullifierMembershipWitness | undefined> {
|
|
56
|
+
return this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns a witness for a given slot of the public data tree at a given block.
|
|
61
|
+
* @param blockHash - The block hash at which to get the witness.
|
|
62
|
+
* @param leafSlot - The slot of the public data in the public data tree.
|
|
63
|
+
*/
|
|
64
|
+
public getPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
65
|
+
return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
70
|
+
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
71
|
+
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
72
|
+
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
73
|
+
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
74
|
+
*/
|
|
75
|
+
public getL1ToL2MembershipWitness(
|
|
76
|
+
contractAddress: AztecAddress,
|
|
77
|
+
messageHash: Fr,
|
|
78
|
+
secret: Fr,
|
|
79
|
+
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
80
|
+
return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async #tryGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, value: Fr): Promise<Fr[] | undefined> {
|
|
84
|
+
switch (treeId) {
|
|
85
|
+
case MerkleTreeId.NULLIFIER_TREE:
|
|
86
|
+
return (await this.aztecNode.getNullifierMembershipWitness(blockHash, value))?.withoutPreimage().toFields();
|
|
87
|
+
case MerkleTreeId.NOTE_HASH_TREE:
|
|
88
|
+
return (await this.aztecNode.getNoteHashMembershipWitness(blockHash, value))?.toFields();
|
|
89
|
+
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
90
|
+
return (await this.aztecNode.getPublicDataWitness(blockHash, value))?.withoutPreimage().toFields();
|
|
91
|
+
case MerkleTreeId.ARCHIVE:
|
|
92
|
+
return (await this.aztecNode.getArchiveMembershipWitness(blockHash, value))?.toFields();
|
|
93
|
+
default:
|
|
94
|
+
throw new Error('Not implemented');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
6
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
7
|
-
/**
|
|
8
|
-
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
9
|
-
* from the instance is used.
|
|
10
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
11
|
-
* @param instance - The instance of the contract.
|
|
12
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
13
|
-
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
14
|
-
* @returns The current class id.
|
|
15
|
-
*/
|
|
16
|
-
export declare function readCurrentClassId(contractAddress: AztecAddress, instance: ContractInstance, aztecNode: AztecNode, header: BlockHeader): Promise<import("@aztec/foundation/schemas").Fr>;
|
|
17
|
-
export declare function syncState(contractAddress: AztecAddress, contractStore: ContractStore, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>): Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
20
|
-
* the contract.
|
|
21
|
-
*/
|
|
22
|
-
export declare function ensureContractSynced(contractAddress: AztecAddress, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (call: FunctionCall) => Promise<any>, aztecNode: AztecNode, contractStore: ContractStore, header: BlockHeader): Promise<void>;
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdF9zeW5jL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFL0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsV0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gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,mDAapB;AAED,wBAAsB,SAAS,CAC7B,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,eAAe,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,gBAajE;AA0BD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,YAAY,EAC7B,yBAAyB,EAAE,gBAAgB,GAAG,IAAI,EAClD,eAAe,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,EACrD,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress, isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
3
|
-
/**
|
|
4
|
-
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
5
|
-
* from the instance is used.
|
|
6
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
7
|
-
* @param instance - The instance of the contract.
|
|
8
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
9
|
-
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
10
|
-
* @returns The current class id.
|
|
11
|
-
*/ export async function readCurrentClassId(contractAddress, instance, aztecNode, header) {
|
|
12
|
-
const blockHash = await header.hash();
|
|
13
|
-
const timestamp = header.globalVariables.timestamp;
|
|
14
|
-
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
15
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, (slot)=>aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot));
|
|
16
|
-
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
17
|
-
if (currentClassId.isZero()) {
|
|
18
|
-
currentClassId = instance.originalContractClassId;
|
|
19
|
-
}
|
|
20
|
-
return currentClassId;
|
|
21
|
-
}
|
|
22
|
-
export async function syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor) {
|
|
23
|
-
// Protocol contracts don't have private state to sync
|
|
24
|
-
if (!isProtocolContract(contractAddress)) {
|
|
25
|
-
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
26
|
-
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
27
|
-
throw new Error('Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.');
|
|
28
|
-
}
|
|
29
|
-
return utilityExecutor(syncStateFunctionCall);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
34
|
-
* provider (i.e. PXE's own storage).
|
|
35
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
36
|
-
*/ async function verifyCurrentClassId(contractAddress, aztecNode, contractStore, header) {
|
|
37
|
-
const instance = await contractStore.getContractInstance(contractAddress);
|
|
38
|
-
if (!instance) {
|
|
39
|
-
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
40
|
-
}
|
|
41
|
-
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
42
|
-
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
43
|
-
throw new Error(`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
48
|
-
* the contract.
|
|
49
|
-
*/ export async function ensureContractSynced(contractAddress, functionToInvokeAfterSync, utilityExecutor, aztecNode, contractStore, header) {
|
|
50
|
-
await Promise.all([
|
|
51
|
-
syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor),
|
|
52
|
-
verifyCurrentClassId(contractAddress, aztecNode, contractStore, header)
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
3
|
-
export declare class StoredNote {
|
|
4
|
-
readonly noteDao: NoteDao;
|
|
5
|
-
readonly scopes: Set<string>;
|
|
6
|
-
private _nullifiedAt;
|
|
7
|
-
constructor(noteDao: NoteDao, scopes: Set<string>, _nullifiedAt?: BlockNumber | undefined);
|
|
8
|
-
static fromBuffer(buffer: Buffer): StoredNote;
|
|
9
|
-
toBuffer(): Buffer;
|
|
10
|
-
addScope(scope: string): void;
|
|
11
|
-
markAsNullified(blockNumber: BlockNumber): void;
|
|
12
|
-
markAsActive(): void;
|
|
13
|
-
isNullified(): boolean;
|
|
14
|
-
get nullifiedAt(): BlockNumber | undefined;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVkX25vdGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2Vz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AAC,MAAM,CAAC;IAC5B,OAAO,CAAC,YAAY;IAHtB,YACW,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,YAAY,GAAE,WAAW,GAAG,SAAqB,EACvD;IAEJ,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,cAU/B;IAED,QAAQ,IAAI,MAAM,CAGjB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,QAErB;IAED,eAAe,CAAC,WAAW,EAAE,WAAW,QAEvC;IAED,YAAY,SAEX;IAED,WAAW,YAEV;IAED,IAAI,WAAW,4BAEd;CACF"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
3
|
-
export class StoredNote {
|
|
4
|
-
noteDao;
|
|
5
|
-
scopes;
|
|
6
|
-
_nullifiedAt;
|
|
7
|
-
constructor(noteDao, scopes, _nullifiedAt = undefined){
|
|
8
|
-
this.noteDao = noteDao;
|
|
9
|
-
this.scopes = scopes;
|
|
10
|
-
this._nullifiedAt = _nullifiedAt;
|
|
11
|
-
}
|
|
12
|
-
static fromBuffer(buffer) {
|
|
13
|
-
const reader = BufferReader.asReader(buffer);
|
|
14
|
-
const noteDao = NoteDao.fromBuffer(reader);
|
|
15
|
-
const scopes = reader.readVector({
|
|
16
|
-
fromBuffer: (r)=>r.readString()
|
|
17
|
-
});
|
|
18
|
-
const nullifiedAtRaw = reader.readNumber();
|
|
19
|
-
const nullifiedAt = nullifiedAtRaw === 0 ? undefined : nullifiedAtRaw;
|
|
20
|
-
return new StoredNote(noteDao, new Set(scopes), nullifiedAt);
|
|
21
|
-
}
|
|
22
|
-
toBuffer() {
|
|
23
|
-
const scopesArray = [
|
|
24
|
-
...this.scopes
|
|
25
|
-
];
|
|
26
|
-
return serializeToBuffer(this.noteDao, scopesArray.length, ...scopesArray, this._nullifiedAt ?? 0);
|
|
27
|
-
}
|
|
28
|
-
addScope(scope) {
|
|
29
|
-
this.scopes.add(scope);
|
|
30
|
-
}
|
|
31
|
-
markAsNullified(blockNumber) {
|
|
32
|
-
this._nullifiedAt = blockNumber;
|
|
33
|
-
}
|
|
34
|
-
markAsActive() {
|
|
35
|
-
this._nullifiedAt = undefined;
|
|
36
|
-
}
|
|
37
|
-
isNullified() {
|
|
38
|
-
return this._nullifiedAt !== undefined;
|
|
39
|
-
}
|
|
40
|
-
get nullifiedAt() {
|
|
41
|
-
return this._nullifiedAt;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { EventSelector } from '@aztec/stdlib/abi';
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
5
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
-
/** Serializable private event entry with scope tracking. */
|
|
7
|
-
export declare class StoredPrivateEvent {
|
|
8
|
-
readonly randomness: Fr;
|
|
9
|
-
readonly msgContent: Fr[];
|
|
10
|
-
readonly l2BlockNumber: number;
|
|
11
|
-
readonly l2BlockHash: L2BlockHash;
|
|
12
|
-
readonly txHash: TxHash;
|
|
13
|
-
readonly txIndexInBlock: number;
|
|
14
|
-
readonly eventIndexInTx: number;
|
|
15
|
-
readonly contractAddress: AztecAddress;
|
|
16
|
-
readonly eventSelector: EventSelector;
|
|
17
|
-
readonly scopes: Set<string>;
|
|
18
|
-
constructor(randomness: Fr, msgContent: Fr[], l2BlockNumber: number, l2BlockHash: L2BlockHash, txHash: TxHash, txIndexInBlock: number, eventIndexInTx: number, contractAddress: AztecAddress, eventSelector: EventSelector, scopes: Set<string>);
|
|
19
|
-
addScope(scope: string): void;
|
|
20
|
-
toBuffer(): Buffer;
|
|
21
|
-
static fromBuffer(buffer: Buffer): StoredPrivateEvent;
|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Q,CAAC,cAAc,EAAE,MAAM;IAC/B,QAAQ,CAAC,eAAe,EAAE,YAAY;IACtC,QAAQ,CAAC,aAAa,EAAE,aAAa;IACrC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IAV9B,YACW,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EAAE,EAChB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EAC1B;IAEJ,QAAQ,CAAC,KAAK,EAAE,MAAM,QAErB;IAED,QAAQ,IAAI,MAAM,CAgBjB;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CA2BpD;CACF"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import { EventSelector } from '@aztec/stdlib/abi';
|
|
4
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
|
-
/** Serializable private event entry with scope tracking. */ export class StoredPrivateEvent {
|
|
8
|
-
randomness;
|
|
9
|
-
msgContent;
|
|
10
|
-
l2BlockNumber;
|
|
11
|
-
l2BlockHash;
|
|
12
|
-
txHash;
|
|
13
|
-
txIndexInBlock;
|
|
14
|
-
eventIndexInTx;
|
|
15
|
-
contractAddress;
|
|
16
|
-
eventSelector;
|
|
17
|
-
scopes;
|
|
18
|
-
constructor(randomness, msgContent, l2BlockNumber, l2BlockHash, txHash, txIndexInBlock, eventIndexInTx, contractAddress, eventSelector, scopes){
|
|
19
|
-
this.randomness = randomness;
|
|
20
|
-
this.msgContent = msgContent;
|
|
21
|
-
this.l2BlockNumber = l2BlockNumber;
|
|
22
|
-
this.l2BlockHash = l2BlockHash;
|
|
23
|
-
this.txHash = txHash;
|
|
24
|
-
this.txIndexInBlock = txIndexInBlock;
|
|
25
|
-
this.eventIndexInTx = eventIndexInTx;
|
|
26
|
-
this.contractAddress = contractAddress;
|
|
27
|
-
this.eventSelector = eventSelector;
|
|
28
|
-
this.scopes = scopes;
|
|
29
|
-
}
|
|
30
|
-
addScope(scope) {
|
|
31
|
-
this.scopes.add(scope);
|
|
32
|
-
}
|
|
33
|
-
toBuffer() {
|
|
34
|
-
const scopesArray = [
|
|
35
|
-
...this.scopes
|
|
36
|
-
];
|
|
37
|
-
return serializeToBuffer(this.randomness, this.msgContent.length, ...this.msgContent, this.l2BlockNumber, this.l2BlockHash, this.txHash, this.txIndexInBlock, this.eventIndexInTx, this.contractAddress, this.eventSelector.toBuffer(), scopesArray.length, ...scopesArray);
|
|
38
|
-
}
|
|
39
|
-
static fromBuffer(buffer) {
|
|
40
|
-
const reader = BufferReader.asReader(buffer);
|
|
41
|
-
const randomness = Fr.fromBuffer(reader);
|
|
42
|
-
const msgContentLength = reader.readNumber();
|
|
43
|
-
const msgContent = reader.readArray(msgContentLength, Fr);
|
|
44
|
-
const l2BlockNumber = reader.readNumber();
|
|
45
|
-
const l2BlockHash = L2BlockHash.fromBuffer(reader);
|
|
46
|
-
const txHash = TxHash.fromBuffer(reader);
|
|
47
|
-
const txIndexInBlock = reader.readNumber();
|
|
48
|
-
const eventIndexInTx = reader.readNumber();
|
|
49
|
-
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
50
|
-
const eventSelector = EventSelector.fromBuffer(reader);
|
|
51
|
-
const scopes = reader.readVector({
|
|
52
|
-
fromBuffer: (r)=>r.readString()
|
|
53
|
-
});
|
|
54
|
-
return new StoredPrivateEvent(randomness, msgContent, l2BlockNumber, l2BlockHash, txHash, txIndexInBlock, eventIndexInTx, contractAddress, eventSelector, new Set(scopes));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
-
import type { L2BlockHash } from '@aztec/stdlib/block';
|
|
3
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
-
import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
5
|
-
/**
|
|
6
|
-
* Fetches all private logs for the given tags, automatically paginating through all pages.
|
|
7
|
-
* @param aztecNode - The Aztec node to query.
|
|
8
|
-
* @param tags - The siloed tags to search for.
|
|
9
|
-
* @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
|
|
10
|
-
* because of reorgs).
|
|
11
|
-
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getAllPrivateLogsByTags(aztecNode: AztecNode, tags: SiloedTag[], anchorBlockHash: L2BlockHash): Promise<TxScopedL2Log[][]>;
|
|
14
|
-
/**
|
|
15
|
-
* Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
|
|
16
|
-
* @param aztecNode - The Aztec node to query.
|
|
17
|
-
* @param contractAddress - The contract address to search logs for.
|
|
18
|
-
* @param tags - The tags to search for.
|
|
19
|
-
* @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
|
|
20
|
-
* because of reorgs).
|
|
21
|
-
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
22
|
-
*/
|
|
23
|
-
export declare function getAllPublicLogsByTagsFromContract(aztecNode: AztecNode, contractAddress: AztecAddress, tags: Tag[], anchorBlockHash: L2BlockHash): Promise<TxScopedL2Log[][]>;
|
|
24
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X2FsbF9sb2dzX2J5X3RhZ3MuZC50cyIsInNvdXJjZVJvb3QiOi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AAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA6BxE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EAAE,EACjB,eAAe,EAAE,WAAW,GAC3B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAE5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,EAAE,WAAW,GAC3B,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAI5B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
|
|
2
|
-
/**
|
|
3
|
-
* Generic pagination helper that fetches all pages of results.
|
|
4
|
-
* @param numTags - The number of tags being queried (determines result array size).
|
|
5
|
-
* @param fetchPage - Function that fetches a single page of results given a page number.
|
|
6
|
-
* @returns An array of arrays, one per tag, containing all results across all pages.
|
|
7
|
-
*/ async function getAllPages(numTags, fetchPage) {
|
|
8
|
-
const allResultsPerTag = Array.from({
|
|
9
|
-
length: numTags
|
|
10
|
-
}, ()=>[]);
|
|
11
|
-
let page = 0;
|
|
12
|
-
let hasMore = true;
|
|
13
|
-
while(hasMore){
|
|
14
|
-
const resultsPage = await fetchPage(page);
|
|
15
|
-
hasMore = false;
|
|
16
|
-
for(let i = 0; i < resultsPage.length; i++){
|
|
17
|
-
allResultsPerTag[i].push(...resultsPage[i]);
|
|
18
|
-
if (resultsPage[i].length === MAX_LOGS_PER_TAG) {
|
|
19
|
-
hasMore = true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
page++;
|
|
23
|
-
}
|
|
24
|
-
return allResultsPerTag;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Fetches all private logs for the given tags, automatically paginating through all pages.
|
|
28
|
-
* @param aztecNode - The Aztec node to query.
|
|
29
|
-
* @param tags - The siloed tags to search for.
|
|
30
|
-
* @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
|
|
31
|
-
* because of reorgs).
|
|
32
|
-
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
33
|
-
*/ export function getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash) {
|
|
34
|
-
return getAllPages(tags.length, (page)=>aztecNode.getPrivateLogsByTags(tags, page, anchorBlockHash));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Fetches all public logs for the given tags from a contract, automatically paginating through all pages.
|
|
38
|
-
* @param aztecNode - The Aztec node to query.
|
|
39
|
-
* @param contractAddress - The contract address to search logs for.
|
|
40
|
-
* @param tags - The tags to search for.
|
|
41
|
-
* @param anchorBlockHash - reference block for the Aztec node query, throws if block is not found there (typically
|
|
42
|
-
* because of reorgs).
|
|
43
|
-
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
44
|
-
*/ export function getAllPublicLogsByTagsFromContract(aztecNode, contractAddress, tags, anchorBlockHash) {
|
|
45
|
-
return getAllPages(tags.length, (page)=>aztecNode.getPublicLogsByTagsFromContract(contractAddress, tags, page, anchorBlockHash));
|
|
46
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress, isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
-
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
5
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
6
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
|
-
|
|
9
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
13
|
-
* from the instance is used.
|
|
14
|
-
* @param contractAddress - The address of the contract to read the class id for.
|
|
15
|
-
* @param instance - The instance of the contract.
|
|
16
|
-
* @param aztecNode - The Aztec node to query for storage.
|
|
17
|
-
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
18
|
-
* @returns The current class id.
|
|
19
|
-
*/
|
|
20
|
-
export async function readCurrentClassId(
|
|
21
|
-
contractAddress: AztecAddress,
|
|
22
|
-
instance: ContractInstance,
|
|
23
|
-
aztecNode: AztecNode,
|
|
24
|
-
header: BlockHeader,
|
|
25
|
-
) {
|
|
26
|
-
const blockHash = await header.hash();
|
|
27
|
-
const timestamp = header.globalVariables.timestamp;
|
|
28
|
-
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
29
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
30
|
-
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
31
|
-
);
|
|
32
|
-
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
33
|
-
if (currentClassId.isZero()) {
|
|
34
|
-
currentClassId = instance.originalContractClassId;
|
|
35
|
-
}
|
|
36
|
-
return currentClassId;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function syncState(
|
|
40
|
-
contractAddress: AztecAddress,
|
|
41
|
-
contractStore: ContractStore,
|
|
42
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
43
|
-
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
44
|
-
) {
|
|
45
|
-
// Protocol contracts don't have private state to sync
|
|
46
|
-
if (!isProtocolContract(contractAddress)) {
|
|
47
|
-
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
48
|
-
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
'Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return utilityExecutor(syncStateFunctionCall);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
60
|
-
* provider (i.e. PXE's own storage).
|
|
61
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
62
|
-
*/
|
|
63
|
-
async function verifyCurrentClassId(
|
|
64
|
-
contractAddress: AztecAddress,
|
|
65
|
-
aztecNode: AztecNode,
|
|
66
|
-
contractStore: ContractStore,
|
|
67
|
-
header: BlockHeader,
|
|
68
|
-
) {
|
|
69
|
-
const instance = await contractStore.getContractInstance(contractAddress);
|
|
70
|
-
if (!instance) {
|
|
71
|
-
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
75
|
-
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
84
|
-
* the contract.
|
|
85
|
-
*/
|
|
86
|
-
export async function ensureContractSynced(
|
|
87
|
-
contractAddress: AztecAddress,
|
|
88
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
89
|
-
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
90
|
-
aztecNode: AztecNode,
|
|
91
|
-
contractStore: ContractStore,
|
|
92
|
-
header: BlockHeader,
|
|
93
|
-
): Promise<void> {
|
|
94
|
-
await Promise.all([
|
|
95
|
-
syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor),
|
|
96
|
-
verifyCurrentClassId(contractAddress, aztecNode, contractStore, header),
|
|
97
|
-
]);
|
|
98
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
4
|
-
|
|
5
|
-
export class StoredNote {
|
|
6
|
-
constructor(
|
|
7
|
-
readonly noteDao: NoteDao,
|
|
8
|
-
readonly scopes: Set<string>,
|
|
9
|
-
private _nullifiedAt: BlockNumber | undefined = undefined,
|
|
10
|
-
) {}
|
|
11
|
-
|
|
12
|
-
static fromBuffer(buffer: Buffer) {
|
|
13
|
-
const reader = BufferReader.asReader(buffer);
|
|
14
|
-
|
|
15
|
-
const noteDao = NoteDao.fromBuffer(reader);
|
|
16
|
-
const scopes = reader.readVector({ fromBuffer: (r: BufferReader) => r.readString() });
|
|
17
|
-
|
|
18
|
-
const nullifiedAtRaw = reader.readNumber();
|
|
19
|
-
const nullifiedAt = nullifiedAtRaw === 0 ? undefined : (nullifiedAtRaw as BlockNumber);
|
|
20
|
-
|
|
21
|
-
return new StoredNote(noteDao, new Set(scopes), nullifiedAt);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
toBuffer(): Buffer {
|
|
25
|
-
const scopesArray = [...this.scopes];
|
|
26
|
-
return serializeToBuffer(this.noteDao, scopesArray.length, ...scopesArray, this._nullifiedAt ?? 0);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
addScope(scope: string) {
|
|
30
|
-
this.scopes.add(scope);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
markAsNullified(blockNumber: BlockNumber) {
|
|
34
|
-
this._nullifiedAt = blockNumber;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
markAsActive() {
|
|
38
|
-
this._nullifiedAt = undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
isNullified() {
|
|
42
|
-
return this._nullifiedAt !== undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get nullifiedAt() {
|
|
46
|
-
return this._nullifiedAt;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import { EventSelector } from '@aztec/stdlib/abi';
|
|
4
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
|
-
|
|
8
|
-
/** Serializable private event entry with scope tracking. */
|
|
9
|
-
export class StoredPrivateEvent {
|
|
10
|
-
constructor(
|
|
11
|
-
readonly randomness: Fr,
|
|
12
|
-
readonly msgContent: Fr[],
|
|
13
|
-
readonly l2BlockNumber: number,
|
|
14
|
-
readonly l2BlockHash: L2BlockHash,
|
|
15
|
-
readonly txHash: TxHash,
|
|
16
|
-
readonly txIndexInBlock: number,
|
|
17
|
-
readonly eventIndexInTx: number,
|
|
18
|
-
readonly contractAddress: AztecAddress,
|
|
19
|
-
readonly eventSelector: EventSelector,
|
|
20
|
-
readonly scopes: Set<string>,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
addScope(scope: string) {
|
|
24
|
-
this.scopes.add(scope);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
toBuffer(): Buffer {
|
|
28
|
-
const scopesArray = [...this.scopes];
|
|
29
|
-
return serializeToBuffer(
|
|
30
|
-
this.randomness,
|
|
31
|
-
this.msgContent.length,
|
|
32
|
-
...this.msgContent,
|
|
33
|
-
this.l2BlockNumber,
|
|
34
|
-
this.l2BlockHash,
|
|
35
|
-
this.txHash,
|
|
36
|
-
this.txIndexInBlock,
|
|
37
|
-
this.eventIndexInTx,
|
|
38
|
-
this.contractAddress,
|
|
39
|
-
this.eventSelector.toBuffer(),
|
|
40
|
-
scopesArray.length,
|
|
41
|
-
...scopesArray,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static fromBuffer(buffer: Buffer): StoredPrivateEvent {
|
|
46
|
-
const reader = BufferReader.asReader(buffer);
|
|
47
|
-
|
|
48
|
-
const randomness = Fr.fromBuffer(reader);
|
|
49
|
-
const msgContentLength = reader.readNumber();
|
|
50
|
-
const msgContent = reader.readArray(msgContentLength, Fr);
|
|
51
|
-
const l2BlockNumber = reader.readNumber();
|
|
52
|
-
const l2BlockHash = L2BlockHash.fromBuffer(reader);
|
|
53
|
-
const txHash = TxHash.fromBuffer(reader);
|
|
54
|
-
const txIndexInBlock = reader.readNumber();
|
|
55
|
-
const eventIndexInTx = reader.readNumber();
|
|
56
|
-
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
57
|
-
const eventSelector = EventSelector.fromBuffer(reader);
|
|
58
|
-
const scopes = reader.readVector({ fromBuffer: (r: BufferReader) => r.readString() });
|
|
59
|
-
|
|
60
|
-
return new StoredPrivateEvent(
|
|
61
|
-
randomness,
|
|
62
|
-
msgContent,
|
|
63
|
-
l2BlockNumber,
|
|
64
|
-
l2BlockHash,
|
|
65
|
-
txHash,
|
|
66
|
-
txIndexInBlock,
|
|
67
|
-
eventIndexInTx,
|
|
68
|
-
contractAddress,
|
|
69
|
-
eventSelector,
|
|
70
|
-
new Set(scopes),
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|