@aztec/pxe 0.0.1-commit.ef17749e1 → 0.0.1-commit.f1b29a41e
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/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +29 -6
- 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 +17 -9
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- 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 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +5 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +21 -20
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +39 -19
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +91 -44
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +11 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +12 -44
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +43 -25
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +157 -61
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +7 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +59 -32
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +7 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +6 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -28
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +2 -2
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -5
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +6 -3
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +37 -21
- package/dest/storage/capsule_store/capsule_service.d.ts +22 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
- 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 +24 -11
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +40 -7
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
- package/src/contract_function_simulator/oracle/interfaces.ts +34 -28
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +120 -64
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -62
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +279 -72
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +89 -49
- package/src/contract_sync/helpers.ts +3 -2
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +51 -46
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +16 -5
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +55 -19
- package/src/storage/capsule_store/capsule_service.ts +91 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
|
@@ -8,25 +8,27 @@ import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
|
8
8
|
aztecNode;
|
|
9
9
|
contractStore;
|
|
10
10
|
noteStore;
|
|
11
|
+
getRegisteredAccounts;
|
|
11
12
|
log;
|
|
12
13
|
storeName;
|
|
13
14
|
// Tracks contracts synced since last wipe. The cache is keyed per individual scope address
|
|
14
|
-
// (`contractAddress:scopeAddress`), or `contractAddress:*` for
|
|
15
|
+
// (`contractAddress:scopeAddress`), or `contractAddress:*` for all scopes (all accounts).
|
|
15
16
|
// The value is a promise that resolves when the contract is synced.
|
|
16
17
|
syncedContracts;
|
|
17
|
-
// Per-job
|
|
18
|
-
|
|
19
|
-
constructor(aztecNode, contractStore, noteStore, log){
|
|
18
|
+
// Per-job excluded contract addresses - these contracts should not be synced.
|
|
19
|
+
excludedFromSync;
|
|
20
|
+
constructor(aztecNode, contractStore, noteStore, getRegisteredAccounts, log){
|
|
20
21
|
this.aztecNode = aztecNode;
|
|
21
22
|
this.contractStore = contractStore;
|
|
22
23
|
this.noteStore = noteStore;
|
|
24
|
+
this.getRegisteredAccounts = getRegisteredAccounts;
|
|
23
25
|
this.log = log;
|
|
24
26
|
this.storeName = 'contract_sync';
|
|
25
27
|
this.syncedContracts = new Map();
|
|
26
|
-
this.
|
|
28
|
+
this.excludedFromSync = new Map();
|
|
27
29
|
}
|
|
28
|
-
/** Sets contracts that should be skipped during sync for a specific job. */
|
|
29
|
-
this.
|
|
30
|
+
/** Sets contracts that should be skipped during sync for a specific job. */ setExcludedFromSync(jobId, addresses) {
|
|
31
|
+
this.excludedFromSync.set(jobId, addresses);
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
34
|
* Ensures a contract's private state is synchronized and that the PXE holds the current class artifact.
|
|
@@ -37,35 +39,31 @@ import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
|
37
39
|
* @param utilityExecutor - Executor function for running the sync_state utility function.
|
|
38
40
|
* @param scopes - Access scopes to pass through to the utility executor (affects whose account's private state is discovered).
|
|
39
41
|
*/ async ensureContractSynced(contractAddress, functionToInvokeAfterSync, utilityExecutor, anchorBlockHeader, jobId, scopes) {
|
|
40
|
-
|
|
41
|
-
const overrides = this.overriddenContracts.get(jobId);
|
|
42
|
-
if (overrides?.has(contractAddress.toString())) {
|
|
42
|
+
if (this.#shouldSkipSync(jobId, contractAddress)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
this.#startSyncIfNeeded(contractAddress, scopes, (scopesToSync)=>this.#syncContract(contractAddress, functionToInvokeAfterSync, utilityExecutor, anchorBlockHeader, jobId, scopesToSync));
|
|
46
|
+
await this.#awaitSync(contractAddress, scopes);
|
|
47
|
+
}
|
|
48
|
+
/** Clears sync cache entries for the given scopes of a contract. Also clears the ALL_SCOPES entry. */ invalidateContractForScopes(contractAddress, scopes) {
|
|
49
|
+
if (scopes.length === 0) {
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (unsyncedScopesKeys.length > 0) {
|
|
54
|
-
// Start sync and store the promise for all unsynced scopes
|
|
55
|
-
const promise = this.#doSync(contractAddress, functionToInvokeAfterSync, utilityExecutor, anchorBlockHeader, jobId, unsyncedScopes).catch((err)=>{
|
|
56
|
-
// There was an error syncing the contract, so we remove it from the cache so that it can be retried.
|
|
57
|
-
unsyncedScopesKeys.forEach((key)=>this.syncedContracts.delete(key));
|
|
58
|
-
throw err;
|
|
59
|
-
});
|
|
60
|
-
unsyncedScopesKeys.forEach((key)=>this.syncedContracts.set(key, promise));
|
|
61
|
-
}
|
|
62
|
-
const promises = toKeys(contractAddress, scopes).map((key)=>this.syncedContracts.get(key));
|
|
63
|
-
await Promise.all(promises);
|
|
52
|
+
scopes.forEach((scope)=>this.syncedContracts.delete(toKey(contractAddress, scope)));
|
|
53
|
+
this.syncedContracts.delete(toKey(contractAddress, 'ALL_SCOPES'));
|
|
64
54
|
}
|
|
65
|
-
async #
|
|
55
|
+
async #syncContract(contractAddress, functionToInvokeAfterSync, utilityExecutor, anchorBlockHeader, jobId, scopes) {
|
|
66
56
|
this.log.debug(`Syncing contract ${contractAddress}`);
|
|
57
|
+
// Resolve ALL_SCOPES to actual registered accounts, since sync_state must be called once per account.
|
|
58
|
+
const scopeAddresses = scopes === 'ALL_SCOPES' ? await this.getRegisteredAccounts() : scopes;
|
|
67
59
|
await Promise.all([
|
|
68
|
-
|
|
60
|
+
// Call sync_state sequentially for each scope address — each invocation synchronizes one account's private
|
|
61
|
+
// state using scoped capsule arrays.
|
|
62
|
+
(async ()=>{
|
|
63
|
+
for (const scope of scopeAddresses){
|
|
64
|
+
await syncState(contractAddress, this.contractStore, functionToInvokeAfterSync, utilityExecutor, this.noteStore, this.aztecNode, anchorBlockHeader, jobId, scope);
|
|
65
|
+
}
|
|
66
|
+
})(),
|
|
69
67
|
verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader)
|
|
70
68
|
]);
|
|
71
69
|
this.log.debug(`Contract ${contractAddress} synced`);
|
|
@@ -75,17 +73,46 @@ import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
|
75
73
|
this.syncedContracts.clear();
|
|
76
74
|
}
|
|
77
75
|
commit(jobId) {
|
|
78
|
-
// Clear
|
|
79
|
-
this.
|
|
76
|
+
// Clear excluded contracts for this job
|
|
77
|
+
this.excludedFromSync.delete(jobId);
|
|
80
78
|
return Promise.resolve();
|
|
81
79
|
}
|
|
82
80
|
discardStaged(jobId) {
|
|
83
81
|
// We clear the synced contracts cache here because, when the job is discarded, any associated database writes from
|
|
84
82
|
// the sync are also undone.
|
|
85
83
|
this.syncedContracts.clear();
|
|
86
|
-
this.
|
|
84
|
+
this.excludedFromSync.delete(jobId);
|
|
87
85
|
return Promise.resolve();
|
|
88
86
|
}
|
|
87
|
+
/** Returns true if sync should be skipped for this contract */ #shouldSkipSync(jobId, contractAddress) {
|
|
88
|
+
return !!this.excludedFromSync.get(jobId)?.has(contractAddress.toString());
|
|
89
|
+
}
|
|
90
|
+
/** If there are unsynced scopes, starts sync and stores the promise in cache with error cleanup. */ #startSyncIfNeeded(contractAddress, scopes, syncFn) {
|
|
91
|
+
const scopesToSync = this.#getScopesToSync(contractAddress, scopes);
|
|
92
|
+
const keys = toKeys(contractAddress, scopesToSync);
|
|
93
|
+
if (keys.length === 0) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const promise = syncFn(scopesToSync).catch((err)=>{
|
|
97
|
+
keys.forEach((key)=>this.syncedContracts.delete(key));
|
|
98
|
+
throw err;
|
|
99
|
+
});
|
|
100
|
+
keys.forEach((key)=>this.syncedContracts.set(key, promise));
|
|
101
|
+
}
|
|
102
|
+
/** Filters out scopes that are already cached, returning only those that still need syncing. */ #getScopesToSync(contractAddress, scopes) {
|
|
103
|
+
if (this.syncedContracts.has(toKey(contractAddress, 'ALL_SCOPES'))) {
|
|
104
|
+
// If we are already syncing all scopes, then return an empty list
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
if (scopes === 'ALL_SCOPES') {
|
|
108
|
+
return 'ALL_SCOPES';
|
|
109
|
+
}
|
|
110
|
+
return scopes.filter((scope)=>!this.syncedContracts.has(toKey(contractAddress, scope)));
|
|
111
|
+
}
|
|
112
|
+
/** Collects all relevant scope promises (including in-flight ones from concurrent calls) and awaits them. */ async #awaitSync(contractAddress, scopes) {
|
|
113
|
+
const promises = toKeys(contractAddress, scopes).map((key)=>this.syncedContracts.get(key)).filter((p)=>p !== undefined);
|
|
114
|
+
await Promise.all(promises);
|
|
115
|
+
}
|
|
89
116
|
}
|
|
90
117
|
function toKeys(contract, scopes) {
|
|
91
118
|
return scopes === 'ALL_SCOPES' ? [
|
|
@@ -16,7 +16,7 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
16
16
|
* @returns The current class id.
|
|
17
17
|
*/
|
|
18
18
|
export declare function readCurrentClassId(contractAddress: AztecAddress, instance: ContractInstance, aztecNode: AztecNode, header: BlockHeader): Promise<import("@aztec/foundation/schemas").Fr>;
|
|
19
|
-
export declare function syncState(contractAddress: AztecAddress, contractStore: ContractStore, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall, scopes: AccessScopes) => Promise<any>, noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string,
|
|
19
|
+
export declare function syncState(contractAddress: AztecAddress, contractStore: ContractStore, functionToInvokeAfterSync: FunctionSelector | null, utilityExecutor: (privateSyncCall: FunctionCall, scopes: AccessScopes) => Promise<any>, noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string, scope: AztecAddress): Promise<void>;
|
|
20
20
|
/**
|
|
21
21
|
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
22
22
|
* provider (i.e. PXE's own storage).
|
|
@@ -26,4 +26,4 @@ export declare function syncState(contractAddress: AztecAddress, contractStore:
|
|
|
26
26
|
* @param header - The header of the block at which to verify the current class id.
|
|
27
27
|
*/
|
|
28
28
|
export declare function verifyCurrentClassId(contractAddress: AztecAddress, aztecNode: AztecNode, contractStore: ContractStore, header: BlockHeader): Promise<void>;
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X3N5bmMvaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRS9ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRXhELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLDZDQUE2QyxDQUFDO0FBQ2pGLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBRXJFOzs7Ozs7OztHQVFHO0FB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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,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,CAAC,EACtF,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,iBAqBpB;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,WAAW,iBAapB"}
|
|
@@ -20,14 +20,19 @@ import { NoteService } from '../notes/note_service.js';
|
|
|
20
20
|
}
|
|
21
21
|
return currentClassId;
|
|
22
22
|
}
|
|
23
|
-
export async function syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor, noteStore, aztecNode, anchorBlockHeader, jobId,
|
|
23
|
+
export async function syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor, noteStore, aztecNode, anchorBlockHeader, jobId, scope) {
|
|
24
24
|
// Protocol contracts don't have private state to sync
|
|
25
25
|
if (!isProtocolContract(contractAddress)) {
|
|
26
|
-
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [
|
|
26
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [
|
|
27
|
+
scope
|
|
28
|
+
], contractAddress);
|
|
27
29
|
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
28
30
|
throw new Error('Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.');
|
|
29
31
|
}
|
|
30
32
|
const noteService = new NoteService(noteStore, aztecNode, anchorBlockHeader, jobId);
|
|
33
|
+
const scopes = [
|
|
34
|
+
scope
|
|
35
|
+
];
|
|
31
36
|
// Both sync_state and syncNoteNullifiers interact with the note store, but running them in parallel is safe
|
|
32
37
|
// because note store is designed to handle concurrent operations.
|
|
33
38
|
await Promise.all([
|
|
@@ -9,7 +9,8 @@ export declare class EventService {
|
|
|
9
9
|
private readonly aztecNode;
|
|
10
10
|
private readonly privateEventStore;
|
|
11
11
|
private readonly jobId;
|
|
12
|
-
|
|
12
|
+
private readonly log;
|
|
13
|
+
constructor(anchorBlockHeader: BlockHeader, aztecNode: AztecNode, privateEventStore: PrivateEventStore, jobId: string, log?: import("@aztec/foundation/log").Logger);
|
|
13
14
|
validateAndStoreEvent(contractAddress: AztecAddress, selector: EventSelector, randomness: Fr, content: Fr[], eventCommitment: Fr, txHash: TxHash, scope: AztecAddress): Promise<void>;
|
|
14
15
|
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2V2ZW50cy9ldmVudF9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXpELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU1RCxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx1REFBdUQsQ0FBQztBQUUxRixxQkFBYSxZQUFZO0lBRXJCLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBQ2xDLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGlCQUFpQjtJQUNsQyxPQUFPLENBQUMsUUFBUSxDQUFDLEtBQUs7SUFDdEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBTHRCLFlBQ21CLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsaUJBQWlCLEVBQUUsaUJBQWlCLEVBQ3BDLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyx5Q0FBb0MsRUFDdEQ7SUFFUyxxQkFBcUIsQ0FDaEMsZUFBZSxFQUFFLFlBQVksRUFDN0IsUUFBUSxFQUFFLGFBQWEsRUFDdkIsVUFBVSxFQUFFLEVBQUUsRUFDZCxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQ2IsZUFBZSxFQUFFLEVBQUUsRUFDbkIsTUFBTSxFQUFFLE1BQU0sRUFDZCxLQUFLLEVBQUUsWUFBWSxHQUNsQixPQUFPLENBQUMsSUFBSSxDQUFDLENBdURmO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,YACmB,iBAAiB,EAAE,WAAW,EAC9B,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,GAAG,yCAAoC,EACtD;IAES,qBAAqB,CAChC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,EAAE,EACb,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAuDf;CACF"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
1
2
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
2
3
|
export class EventService {
|
|
3
4
|
anchorBlockHeader;
|
|
4
5
|
aztecNode;
|
|
5
6
|
privateEventStore;
|
|
6
7
|
jobId;
|
|
7
|
-
|
|
8
|
+
log;
|
|
9
|
+
constructor(anchorBlockHeader, aztecNode, privateEventStore, jobId, log = createLogger('pxe:event_service')){
|
|
8
10
|
this.anchorBlockHeader = anchorBlockHeader;
|
|
9
11
|
this.aztecNode = aztecNode;
|
|
10
12
|
this.privateEventStore = privateEventStore;
|
|
11
13
|
this.jobId = jobId;
|
|
14
|
+
this.log = log;
|
|
12
15
|
}
|
|
13
16
|
async validateAndStoreEvent(contractAddress, selector, randomness, content, eventCommitment, txHash, scope) {
|
|
14
17
|
// While using 'latest' block number would be fine for private events since they cannot be accessed from Aztec.nr
|
|
@@ -21,15 +24,24 @@ export class EventService {
|
|
|
21
24
|
]);
|
|
22
25
|
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
23
26
|
if (!txEffect) {
|
|
24
|
-
|
|
27
|
+
// We error out instead of just logging a warning and skipping the event because this would indicate a bug. This
|
|
28
|
+
// is because the node has already served info about this tx either when obtaining the log (TxScopedL2Log contain
|
|
29
|
+
// tx info) or when getting metadata for the offchain message (before the message got passed to `process_log`).
|
|
30
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} when processing an event.`);
|
|
25
31
|
}
|
|
26
32
|
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
27
|
-
|
|
33
|
+
// We should never process a message from a tx past the anchor block. If we got here, a preprocessing step made
|
|
34
|
+
// a mistake.
|
|
35
|
+
throw new Error(`Obtained a newer tx effect for ${txHash} for an event validation request than the anchor block ${anchorBlockNumber}. This is a bug as smart contracts should not issue event validation requests for events from blocks newer than the anchor block.`);
|
|
28
36
|
}
|
|
29
37
|
// Find the index of the event commitment in the nullifiers array to determine event ordering within the tx
|
|
30
38
|
const eventIndexInTx = txEffect.data.nullifiers.findIndex((n)=>n.equals(siloedEventCommitment));
|
|
31
39
|
if (eventIndexInTx === -1) {
|
|
32
|
-
|
|
40
|
+
// Unlike in NoteService, this might not be a bug since the commitment hasn't been verified yet in the message
|
|
41
|
+
// processing pipeline. A malformed or malicious message could trigger this condition. Because of this we don't
|
|
42
|
+
// error out and we just show a warning.
|
|
43
|
+
this.log.warn(`Skipping event whose commitment is not present in its tx. siloedEventCommitment=${siloedEventCommitment}, contract=${contractAddress}, selector=${selector}, eventCommitment=${eventCommitment}, txHash=${txHash}`);
|
|
44
|
+
return;
|
|
33
45
|
}
|
|
34
46
|
return this.privateEventStore.storePrivateEventLog(selector, randomness, content, siloedEventCommitment, {
|
|
35
47
|
contractAddress,
|
|
@@ -4,11 +4,10 @@ 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
6
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
7
|
-
import type { AccessScopes } from '../access_scopes.js';
|
|
8
7
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
9
8
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
10
9
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
11
|
-
import {
|
|
10
|
+
import type { CapsuleService } from '../storage/capsule_store/capsule_service.js';
|
|
12
11
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
13
12
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
14
13
|
export declare class LogService {
|
|
@@ -16,14 +15,14 @@ export declare class LogService {
|
|
|
16
15
|
private readonly aztecNode;
|
|
17
16
|
private readonly anchorBlockHeader;
|
|
18
17
|
private readonly keyStore;
|
|
19
|
-
private readonly
|
|
18
|
+
private readonly capsuleService;
|
|
20
19
|
private readonly recipientTaggingStore;
|
|
21
20
|
private readonly senderAddressBookStore;
|
|
22
21
|
private readonly addressStore;
|
|
23
22
|
private readonly jobId;
|
|
24
23
|
private log;
|
|
25
|
-
constructor(aztecNode: AztecNode, anchorBlockHeader: BlockHeader, keyStore: KeyStore,
|
|
26
|
-
|
|
27
|
-
fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr,
|
|
24
|
+
constructor(aztecNode: AztecNode, anchorBlockHeader: BlockHeader, keyStore: KeyStore, capsuleService: CapsuleService, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, addressStore: AddressStore, jobId: string, bindings?: LoggerBindings);
|
|
25
|
+
fetchLogsByTag(contractAddress: AztecAddress, logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]>;
|
|
26
|
+
fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, recipient: AztecAddress): Promise<void>;
|
|
28
27
|
}
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nX3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2dzL2xvZ19zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sRUFBZSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUN2RixPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNqRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFRakUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxzRUFBc0UsQ0FBQztBQUNoSCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1RUFBdUUsQ0FBQztBQUM3RyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU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BQUUsQ0FBQyxDQXVCMUM7SUFxRFksZUFBZSxDQUMxQixlQUFlLEVBQUUsWUFBWSxFQUM3Qiw2QkFBNkIsRUFBRSxFQUFFLEVBQ2pDLFNBQVMsRUFBRSxZQUFZLGlCQStCeEI7Q0E2REYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAQjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAQjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sEAAsE,CAAC;AAChH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE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
12
12
|
senderAddressBookStore;
|
|
13
13
|
addressStore;
|
|
14
14
|
jobId;
|
|
15
15
|
log;
|
|
16
|
-
constructor(aztecNode, anchorBlockHeader, keyStore,
|
|
16
|
+
constructor(aztecNode, anchorBlockHeader, keyStore, capsuleService, recipientTaggingStore, senderAddressBookStore, addressStore, jobId, bindings){
|
|
17
17
|
this.aztecNode = aztecNode;
|
|
18
18
|
this.anchorBlockHeader = anchorBlockHeader;
|
|
19
19
|
this.keyStore = keyStore;
|
|
20
|
-
this.
|
|
20
|
+
this.capsuleService = capsuleService;
|
|
21
21
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
22
22
|
this.senderAddressBookStore = senderAddressBookStore;
|
|
23
23
|
this.addressStore = addressStore;
|
|
24
24
|
this.jobId = jobId;
|
|
25
25
|
this.log = createLogger('pxe:log_service', bindings);
|
|
26
26
|
}
|
|
27
|
-
async
|
|
27
|
+
async fetchLogsByTag(contractAddress, logRetrievalRequests) {
|
|
28
|
+
for (const request of logRetrievalRequests){
|
|
29
|
+
if (!contractAddress.equals(request.contractAddress)) {
|
|
30
|
+
throw new Error(`Got a log retrieval request from ${request.contractAddress}, expected ${contractAddress}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
28
33
|
return await Promise.all(logRetrievalRequests.map(async (request)=>{
|
|
29
34
|
const [publicLog, privateLog] = await Promise.all([
|
|
30
35
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
31
36
|
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress))
|
|
32
37
|
]);
|
|
33
38
|
if (publicLog !== null && privateLog !== null) {
|
|
34
|
-
|
|
39
|
+
this.log.warn(`Found both a public and private log for tag ${request.tag} from contract ${request.contractAddress}. This may indicate a contract bug. Returning the public log.`);
|
|
35
40
|
}
|
|
36
41
|
return publicLog ?? privateLog;
|
|
37
42
|
}));
|
|
@@ -45,8 +50,7 @@ export class LogService {
|
|
|
45
50
|
if (logsForTag.length === 0) {
|
|
46
51
|
return null;
|
|
47
52
|
} else if (logsForTag.length > 1) {
|
|
48
|
-
|
|
49
|
-
throw new Error(`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`);
|
|
53
|
+
this.log.warn(`Expected at most 1 public log for tag ${tag} and contract ${contractAddress.toString()}, got ${logsForTag.length}. This may indicate a contract bug. Returning the first log.`);
|
|
50
54
|
}
|
|
51
55
|
const scopedLog = logsForTag[0];
|
|
52
56
|
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
@@ -60,33 +64,25 @@ export class LogService {
|
|
|
60
64
|
if (logsForTag.length === 0) {
|
|
61
65
|
return null;
|
|
62
66
|
} else if (logsForTag.length > 1) {
|
|
63
|
-
|
|
64
|
-
throw new Error(`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`);
|
|
67
|
+
this.log.warn(`Expected at most 1 private log for tag ${siloedTag}, got ${logsForTag.length}. This may indicate a contract bug. Returning the first log.`);
|
|
65
68
|
}
|
|
66
69
|
const scopedLog = logsForTag[0];
|
|
67
70
|
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
68
71
|
}
|
|
69
|
-
async fetchTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot,
|
|
72
|
+
async fetchTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient) {
|
|
70
73
|
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
71
74
|
// We only load logs from block up to and including the anchor block number
|
|
72
75
|
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
73
76
|
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
74
|
-
//
|
|
75
|
-
const
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// Flatten all logs from all secrets
|
|
84
|
-
const allLogs = logArrays.flat();
|
|
85
|
-
// Store the logs for this recipient
|
|
86
|
-
if (allLogs.length > 0) {
|
|
87
|
-
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
77
|
+
// Get all secrets for this recipient (one per sender)
|
|
78
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
79
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
80
|
+
const logArrays = await Promise.all(secrets.map((secret)=>loadPrivateLogsForSenderRecipientPair(secret, this.aztecNode, this.recipientTaggingStore, anchorBlockNumber, anchorBlockHash, this.jobId)));
|
|
81
|
+
// Flatten all logs from all secrets
|
|
82
|
+
const allLogs = logArrays.flat();
|
|
83
|
+
if (allLogs.length > 0) {
|
|
84
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
85
|
+
}
|
|
90
86
|
}
|
|
91
87
|
async #getSecretsForSenders(contractAddress, recipient) {
|
|
92
88
|
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
@@ -109,10 +105,10 @@ export class LogService {
|
|
|
109
105
|
#storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
|
|
110
106
|
// Build all pending tagged logs from the scoped logs
|
|
111
107
|
const pendingTaggedLogs = privateLogs.map((scopedLog)=>{
|
|
112
|
-
const pendingTaggedLog = new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier
|
|
108
|
+
const pendingTaggedLog = new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
113
109
|
return pendingTaggedLog.toFields();
|
|
114
110
|
});
|
|
115
111
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
116
|
-
return this.
|
|
112
|
+
return this.capsuleService.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId, recipient);
|
|
117
113
|
}
|
|
118
114
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
3
|
+
import { MessageContext } from '@aztec/stdlib/logs';
|
|
4
|
+
/** Resolves transaction hashes into the context needed to process messages. */
|
|
5
|
+
export declare class MessageContextService {
|
|
6
|
+
private readonly aztecNode;
|
|
7
|
+
constructor(aztecNode: AztecNode);
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a list of tx hashes into their message contexts.
|
|
10
|
+
*
|
|
11
|
+
* For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
|
|
12
|
+
* process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
|
|
13
|
+
* available, or in blocks beyond the anchor block.
|
|
14
|
+
*/
|
|
15
|
+
getMessageContextsByTxHash(txHashes: Fr[], anchorBlockNumber: number): Promise<(MessageContext | null)[]>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzc2FnZV9jb250ZXh0X3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tZXNzYWdlcy9tZXNzYWdlX2NvbnRleHRfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBR3BELCtFQUErRTtBQUMvRSxxQkFBYSxxQkFBcUI7SUFDcEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQXRDLFlBQTZCLFNBQVMsRUFBRSxTQUFTLEVBQUk7SUFFckQ7Ozs7OztPQU1HO0lBQ0gsMEJBQTBCLENBQUMsUUFBUSxFQUFFLEVBQUUsRUFBRSxFQUFFLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQTBCeEc7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message_context_service.d.ts","sourceRoot":"","sources":["../../src/messages/message_context_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,+EAA+E;AAC/E,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,SAAS,EAAI;IAErD;;;;;;OAMG;IACH,0BAA0B,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,CA0BxG;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MessageContext } from '@aztec/stdlib/logs';
|
|
2
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
/** Resolves transaction hashes into the context needed to process messages. */ export class MessageContextService {
|
|
4
|
+
aztecNode;
|
|
5
|
+
constructor(aztecNode){
|
|
6
|
+
this.aztecNode = aztecNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a list of tx hashes into their message contexts.
|
|
10
|
+
*
|
|
11
|
+
* For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
|
|
12
|
+
* process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
|
|
13
|
+
* available, or in blocks beyond the anchor block.
|
|
14
|
+
*/ getMessageContextsByTxHash(txHashes, anchorBlockNumber) {
|
|
15
|
+
// TODO: optimize, we might be hitting the node to get the same txHash repeatedly
|
|
16
|
+
return Promise.all(txHashes.map(async (txHashField)=>{
|
|
17
|
+
// A zero tx hash indicates a tx-less offchain message (e.g. one not tied to any onchain transaction).
|
|
18
|
+
// These messages don't have a transaction context to resolve, so we return null.
|
|
19
|
+
if (txHashField.isZero()) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const txHash = TxHash.fromField(txHashField);
|
|
23
|
+
const txEffect = await this.aztecNode.getTxEffect(txHash);
|
|
24
|
+
if (!txEffect || txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
// Every tx has at least one nullifier (the first nullifier derived from the tx hash). Hitting this condition
|
|
28
|
+
// would mean a buggy node, but since we need to access data.nullifiers[0], the defensive check does no harm.
|
|
29
|
+
const data = txEffect.data;
|
|
30
|
+
if (data.nullifiers.length === 0) {
|
|
31
|
+
throw new Error(`Tx effect for ${txHash} has no nullifiers`);
|
|
32
|
+
}
|
|
33
|
+
return new MessageContext(data.txHash, data.noteHashes, data.nullifiers[0]);
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -44,6 +44,6 @@ export declare class NoteService {
|
|
|
44
44
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
45
45
|
*/
|
|
46
46
|
syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void>;
|
|
47
|
-
validateAndStoreNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash,
|
|
47
|
+
validateAndStoreNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, scope: AztecAddress): Promise<void>;
|
|
48
48
|
}
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZXMvbm90ZV9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUdoRSxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RSxPQUFPLEVBQUUsSUFBSSxFQUFXLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRS9ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU1RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVyRSxxQkFBYSxXQUFXO0lBRXBCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxpQkFBaUI7SUFDbEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBSnhCLFlBQ21CLFNBQVMsRUFBRSxTQUFTLEVBQ3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}
|
|
@@ -87,7 +87,7 @@ export class NoteService {
|
|
|
87
87
|
}).filter((nullifier)=>nullifier !== undefined);
|
|
88
88
|
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
89
89
|
}
|
|
90
|
-
async validateAndStoreNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash,
|
|
90
|
+
async validateAndStoreNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, scope) {
|
|
91
91
|
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
92
92
|
// There's two things we need to check before we do this however:
|
|
93
93
|
// - we must make sure the note does actually exist in the note hash tree
|
|
@@ -119,21 +119,30 @@ export class NoteService {
|
|
|
119
119
|
])
|
|
120
120
|
]);
|
|
121
121
|
if (!txEffect) {
|
|
122
|
-
|
|
122
|
+
// We error out instead of just logging a warning and skipping the note because this would indicate a bug. This
|
|
123
|
+
// is because the node has already served info about this tx either when obtaining the log (TxScopedL2Log contain
|
|
124
|
+
// tx info) or when getting metadata for the offchain message (before the message got passed to `process_log`).
|
|
125
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} when processing a note.`);
|
|
123
126
|
}
|
|
124
127
|
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
125
|
-
|
|
128
|
+
// If the message was delivered onchain, this would indicate a bug: log sync should never load logs from blocks
|
|
129
|
+
// newer than the anchor block. If the note came via an offchain message, it would likely also be a bug, since we
|
|
130
|
+
// sync a new anchor block before calling `process_message`. For this not to be a bug, the message would need to
|
|
131
|
+
// come from a newer block than the anchor served by the node, implying the node isn't properly synced.
|
|
132
|
+
// We therefore error out here rather than assuming the offchain message was constructed by a malicious
|
|
133
|
+
// sender with the intention of bricking recipient's PXE (if we assumed that we would just ignore the message).
|
|
134
|
+
throw new Error(`Obtained a newer tx effect for ${txHash} for a note validation request than the anchor block ${anchorBlockNumber}. This is a bug as we should not ever be processing a note from a newer block than the anchor block.`);
|
|
126
135
|
}
|
|
127
136
|
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
128
137
|
const noteIndexInTx = txEffect.data.noteHashes.findIndex((nh)=>nh.equals(uniqueNoteHash));
|
|
129
138
|
if (noteIndexInTx === -1) {
|
|
139
|
+
// Similar to the comment above - we error out as this would indicate a bug in nonce discovery.
|
|
130
140
|
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
131
141
|
}
|
|
132
142
|
const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, txEffect.l2BlockNumber, txEffect.l2BlockHash.toString(), txEffect.txIndexInBlock, noteIndexInTx);
|
|
133
|
-
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
134
143
|
await this.noteStore.addNotes([
|
|
135
144
|
noteDao
|
|
136
|
-
],
|
|
145
|
+
], scope, this.jobId);
|
|
137
146
|
if (nullifierIndex !== undefined) {
|
|
138
147
|
// We found nullifier index which implies that the note has already been nullified.
|
|
139
148
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
package/dest/oracle_version.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const ORACLE_VERSION =
|
|
2
|
-
export declare const ORACLE_INTERFACE_HASH = "
|
|
1
|
+
export declare const ORACLE_VERSION = 21;
|
|
2
|
+
export declare const ORACLE_INTERFACE_HASH = "83f1de1a9741a34916fd58cf12b857d0bac90f74bf00751b20304301a3f5c8eb";
|
|
3
3
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcmFjbGVfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxlQUFPLE1BQU0sY0FBYyxLQUFLLENBQUM7QUFLakMsZUFBTyxNQUFNLHFCQUFxQixxRUFBcUUsQ0FBQyJ9
|
package/dest/oracle_version.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
///
|
|
5
5
|
/// @dev Whenever a contract function or Noir test is run, the `aztec_utl_assertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 21;
|
|
8
8
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
9
9
|
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
10
10
|
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
11
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
11
|
+
export const ORACLE_INTERFACE_HASH = '83f1de1a9741a34916fd58cf12b857d0bac90f74bf00751b20304301a3f5c8eb';
|