@aztec/pxe 0.0.1-commit.8f9871590 → 0.0.1-commit.9117c5f5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +8 -8
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +4 -7
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +4 -4
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +13 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +8 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +37 -29
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
- package/package.json +16 -16
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +15 -17
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -20
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +8 -7
- package/src/contract_logging.ts +39 -0
- package/src/debug/pxe_debug_utils.ts +4 -4
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/logs/log_service.ts +10 -5
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +13 -6
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +41 -34
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
- package/src/tagging/index.ts +1 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
|
@@ -1,8 +1,53 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
1
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
|
+
import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
2
4
|
import { FunctionCall, FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
6
|
import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
5
7
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
8
|
+
const VERSION = 1;
|
|
9
|
+
/**
|
|
10
|
+
* All contract class data except the large packedBytecode.
|
|
11
|
+
* The expensive data from the ContractClass is precomputed and stored in this format to avoid redundant hashing.
|
|
12
|
+
* Since we have to store the artifacts anyway, the final ContractClass is reconstructed by combining this data
|
|
13
|
+
* with the packedBytecode obtained from the former. That way we can have quick class lookups without wasted storage.
|
|
14
|
+
*/ export class SerializableContractClassData {
|
|
15
|
+
version = VERSION;
|
|
16
|
+
id;
|
|
17
|
+
artifactHash;
|
|
18
|
+
privateFunctionsRoot;
|
|
19
|
+
publicBytecodeCommitment;
|
|
20
|
+
privateFunctions;
|
|
21
|
+
constructor(data){
|
|
22
|
+
this.id = data.id;
|
|
23
|
+
this.artifactHash = data.artifactHash;
|
|
24
|
+
this.privateFunctionsRoot = data.privateFunctionsRoot;
|
|
25
|
+
this.publicBytecodeCommitment = data.publicBytecodeCommitment;
|
|
26
|
+
this.privateFunctions = data.privateFunctions;
|
|
27
|
+
}
|
|
28
|
+
toBuffer() {
|
|
29
|
+
return serializeToBuffer(numToUInt8(this.version), this.id, this.artifactHash, this.privateFunctionsRoot, this.publicBytecodeCommitment, this.privateFunctions.length, ...this.privateFunctions.map((fn)=>serializeToBuffer(fn.selector, fn.vkHash)));
|
|
30
|
+
}
|
|
31
|
+
static fromBuffer(bufferOrReader) {
|
|
32
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
33
|
+
const version = reader.readUInt8();
|
|
34
|
+
if (version !== VERSION) {
|
|
35
|
+
throw new Error(`Unexpected contract class data version ${version}`);
|
|
36
|
+
}
|
|
37
|
+
return new SerializableContractClassData({
|
|
38
|
+
id: reader.readObject(Fr),
|
|
39
|
+
artifactHash: reader.readObject(Fr),
|
|
40
|
+
privateFunctionsRoot: reader.readObject(Fr),
|
|
41
|
+
publicBytecodeCommitment: reader.readObject(Fr),
|
|
42
|
+
privateFunctions: reader.readVector({
|
|
43
|
+
fromBuffer: (r)=>({
|
|
44
|
+
selector: r.readObject(FunctionSelector),
|
|
45
|
+
vkHash: r.readObject(Fr)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
6
51
|
/**
|
|
7
52
|
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
8
53
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
@@ -12,24 +57,46 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
12
57
|
*/ export class ContractStore {
|
|
13
58
|
/** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
14
59
|
#privateFunctionTrees = new Map();
|
|
15
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* In-memory cache of deserialized ContractArtifact objects, keyed by class id string.
|
|
62
|
+
* Avoids repeated LMDB reads + JSON.parse + Zod validation on every oracle call.
|
|
63
|
+
* Artifacts are large but immutable after registration — safe to cache for the lifetime of the store.
|
|
64
|
+
*/ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
65
|
+
#contractArtifactCache = new Map();
|
|
66
|
+
/** Map from contract address to contract class id (avoids KV round-trip on hot path). */ #contractClassIdMap = new Map();
|
|
16
67
|
#store;
|
|
17
68
|
#contractArtifacts;
|
|
69
|
+
#contractClassData;
|
|
18
70
|
#contractInstances;
|
|
19
71
|
constructor(store){
|
|
20
72
|
this.#store = store;
|
|
21
73
|
this.#contractArtifacts = store.openMap('contract_artifacts');
|
|
74
|
+
this.#contractClassData = store.openMap('contract_classes');
|
|
22
75
|
this.#contractInstances = store.openMap('contracts_instances');
|
|
23
76
|
}
|
|
24
77
|
// Setters
|
|
25
|
-
|
|
26
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Registers a new contract artifact and its corresponding class data.
|
|
80
|
+
* IMPORTANT: This method does not verify that the provided artifact matches the class data or that the class id matches the artifact.
|
|
81
|
+
* It is the caller's responsibility to ensure the consistency and correctness of the provided data.
|
|
82
|
+
* This is done to avoid redundant, expensive contract class computations
|
|
83
|
+
*/ async addContractArtifact(contract, contractClassWithIdAndPreimage) {
|
|
84
|
+
const contractClass = contractClassWithIdAndPreimage ?? await getContractClassFromArtifact(contract);
|
|
85
|
+
const key = contractClass.id.toString();
|
|
86
|
+
if (this.#contractArtifactCache.has(key)) {
|
|
87
|
+
return contractClass.id;
|
|
88
|
+
}
|
|
27
89
|
const privateFunctions = contract.functions.filter((functionArtifact)=>functionArtifact.functionType === FunctionType.PRIVATE);
|
|
28
|
-
const privateSelectors = await Promise.all(privateFunctions.map(async (
|
|
90
|
+
const privateSelectors = await Promise.all(privateFunctions.map(async (fn)=>(await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)).toString()));
|
|
29
91
|
if (privateSelectors.length !== new Set(privateSelectors).size) {
|
|
30
92
|
throw new Error('Repeated function selectors of private functions');
|
|
31
93
|
}
|
|
32
|
-
|
|
94
|
+
this.#contractArtifactCache.set(key, contract);
|
|
95
|
+
await this.#store.transactionAsync(async ()=>{
|
|
96
|
+
await this.#contractArtifacts.set(key, contractArtifactToBuffer(contract));
|
|
97
|
+
await this.#contractClassData.set(key, new SerializableContractClassData(contractClass).toBuffer());
|
|
98
|
+
});
|
|
99
|
+
return contractClass.id;
|
|
33
100
|
}
|
|
34
101
|
async addContractInstance(contract) {
|
|
35
102
|
this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
|
|
@@ -37,25 +104,17 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
37
104
|
}
|
|
38
105
|
// Private getters
|
|
39
106
|
async #getContractClassId(contractAddress) {
|
|
40
|
-
|
|
107
|
+
const key = contractAddress.toString();
|
|
108
|
+
if (!this.#contractClassIdMap.has(key)) {
|
|
41
109
|
const instance = await this.getContractInstance(contractAddress);
|
|
42
110
|
if (!instance) {
|
|
43
111
|
return;
|
|
44
112
|
}
|
|
45
|
-
this.#contractClassIdMap.set(
|
|
113
|
+
this.#contractClassIdMap.set(key, instance.currentContractClassId);
|
|
46
114
|
}
|
|
47
|
-
return this.#contractClassIdMap.get(
|
|
115
|
+
return this.#contractClassIdMap.get(key);
|
|
48
116
|
}
|
|
49
|
-
|
|
50
|
-
* Retrieve or create a ContractTree instance based on the provided class id.
|
|
51
|
-
* If an existing tree with the same class id is found in the cache, it will be returned.
|
|
52
|
-
* Otherwise, a new ContractTree instance will be created using the contract data from the database
|
|
53
|
-
* and added to the cache before returning.
|
|
54
|
-
*
|
|
55
|
-
* @param classId - The class id of the contract for which the ContractTree is required.
|
|
56
|
-
* @returns A ContractTree instance associated with the specified contract address.
|
|
57
|
-
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
58
|
-
*/ async #getPrivateFunctionTreeForClassId(classId) {
|
|
117
|
+
async #getPrivateFunctionTreeForClassId(classId) {
|
|
59
118
|
if (!this.#privateFunctionTrees.has(classId.toString())) {
|
|
60
119
|
const artifact = await this.getContractArtifact(classId);
|
|
61
120
|
if (!artifact) {
|
|
@@ -66,9 +125,9 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
66
125
|
}
|
|
67
126
|
return this.#privateFunctionTrees.get(classId.toString());
|
|
68
127
|
}
|
|
69
|
-
async #
|
|
70
|
-
const
|
|
71
|
-
return
|
|
128
|
+
async #getArtifactByAddress(contractAddress) {
|
|
129
|
+
const classId = await this.#getContractClassId(contractAddress);
|
|
130
|
+
return classId && this.getContractArtifact(classId);
|
|
72
131
|
}
|
|
73
132
|
// Public getters
|
|
74
133
|
getContractsAddresses() {
|
|
@@ -77,22 +136,43 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
77
136
|
return keys.map(AztecAddress.fromString);
|
|
78
137
|
});
|
|
79
138
|
}
|
|
80
|
-
/** Returns a contract instance for a given address.
|
|
139
|
+
/** Returns a contract instance for a given address. */ getContractInstance(contractAddress) {
|
|
81
140
|
return this.#store.transactionAsync(async ()=>{
|
|
82
141
|
const contract = await this.#contractInstances.getAsync(contractAddress.toString());
|
|
83
142
|
return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
|
|
84
143
|
});
|
|
85
144
|
}
|
|
86
|
-
getContractArtifact(contractClassId) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return
|
|
145
|
+
/** Returns the raw contract artifact for a given class id. */ async getContractArtifact(contractClassId) {
|
|
146
|
+
const key = contractClassId.toString();
|
|
147
|
+
const cached = this.#contractArtifactCache.get(key);
|
|
148
|
+
if (cached) {
|
|
149
|
+
return cached;
|
|
150
|
+
}
|
|
151
|
+
const artifact = await this.#store.transactionAsync(async ()=>{
|
|
152
|
+
const buf = await this.#contractArtifacts.getAsync(key);
|
|
153
|
+
return buf && contractArtifactFromBuffer(buf);
|
|
91
154
|
});
|
|
155
|
+
if (artifact) {
|
|
156
|
+
this.#contractArtifactCache.set(key, artifact);
|
|
157
|
+
}
|
|
158
|
+
return artifact;
|
|
92
159
|
}
|
|
93
|
-
/** Returns a contract class for a given class id.
|
|
160
|
+
/** Returns a contract class for a given class id. */ async getContractClassWithPreimage(contractClassId) {
|
|
161
|
+
const key = contractClassId.toString();
|
|
162
|
+
const buf = await this.#contractClassData.getAsync(key);
|
|
163
|
+
if (!buf) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
const classData = SerializableContractClassData.fromBuffer(buf);
|
|
94
167
|
const artifact = await this.getContractArtifact(contractClassId);
|
|
95
|
-
|
|
168
|
+
if (!artifact) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
const packedBytecode = artifact.functions.find((f)=>f.name === 'public_dispatch')?.bytecode ?? Buffer.alloc(0);
|
|
172
|
+
return {
|
|
173
|
+
...classData,
|
|
174
|
+
packedBytecode
|
|
175
|
+
};
|
|
96
176
|
}
|
|
97
177
|
async getContract(address) {
|
|
98
178
|
const instance = await this.getContractInstance(address);
|
|
@@ -110,17 +190,18 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
110
190
|
}
|
|
111
191
|
/**
|
|
112
192
|
* Retrieves the artifact of a specified function within a given contract.
|
|
113
|
-
* The function is identified by its selector, which is a unique code generated from the function's signature.
|
|
114
|
-
* Throws an error if the contract address or function selector are invalid or not found.
|
|
115
193
|
*
|
|
116
194
|
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
117
195
|
* @param selector - The function selector.
|
|
118
196
|
* @returns The corresponding function's artifact as an object.
|
|
119
197
|
*/ async getFunctionArtifact(contractAddress, selector) {
|
|
120
|
-
const artifact = await this.#
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
198
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
199
|
+
if (!artifact) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
const fn = await this.#findFunctionArtifactBySelector(artifact, selector);
|
|
203
|
+
return fn && {
|
|
204
|
+
...fn,
|
|
124
205
|
contractName: artifact.name
|
|
125
206
|
};
|
|
126
207
|
}
|
|
@@ -136,40 +217,38 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
136
217
|
};
|
|
137
218
|
}
|
|
138
219
|
async getPublicFunctionArtifact(contractAddress) {
|
|
139
|
-
const artifact = await this.#
|
|
140
|
-
const
|
|
141
|
-
return
|
|
142
|
-
...
|
|
220
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
221
|
+
const fn = artifact && artifact.functions.find((f)=>f.functionType === FunctionType.PUBLIC);
|
|
222
|
+
return fn && {
|
|
223
|
+
...fn,
|
|
143
224
|
contractName: artifact.name
|
|
144
225
|
};
|
|
145
226
|
}
|
|
146
227
|
async getFunctionAbi(contractAddress, selector) {
|
|
147
|
-
const artifact = await this.#
|
|
228
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
148
229
|
return artifact && await this.#findFunctionAbiBySelector(artifact, selector);
|
|
149
230
|
}
|
|
150
231
|
/**
|
|
151
232
|
* Retrieves the debug metadata of a specified function within a given contract.
|
|
152
|
-
* The function is identified by its selector, which is a unique code generated from the function's signature.
|
|
153
|
-
* Returns undefined if the debug metadata for the given function is not found.
|
|
154
|
-
* Throws if the contract has not been added to the database.
|
|
155
233
|
*
|
|
156
234
|
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
157
235
|
* @param selector - The function selector.
|
|
158
|
-
* @returns The corresponding function's
|
|
236
|
+
* @returns The corresponding function's debug metadata, or undefined.
|
|
159
237
|
*/ async getFunctionDebugMetadata(contractAddress, selector) {
|
|
160
|
-
const artifact = await this.#
|
|
161
|
-
|
|
162
|
-
|
|
238
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
239
|
+
if (!artifact) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const fn = await this.#findFunctionArtifactBySelector(artifact, selector);
|
|
243
|
+
return fn && getFunctionDebugMetadata(artifact, fn);
|
|
163
244
|
}
|
|
164
245
|
async getPublicFunctionDebugMetadata(contractAddress) {
|
|
165
|
-
const artifact = await this.#
|
|
166
|
-
const
|
|
167
|
-
return
|
|
246
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
247
|
+
const fn = artifact && artifact.functions.find((f)=>f.functionType === FunctionType.PUBLIC);
|
|
248
|
+
return fn && getFunctionDebugMetadata(artifact, fn);
|
|
168
249
|
}
|
|
169
250
|
/**
|
|
170
251
|
* Retrieve the function membership witness for the given contract class and function selector.
|
|
171
|
-
* The function membership witness represents a proof that the function belongs to the specified contract.
|
|
172
|
-
* Throws an error if the contract address or function selector is unknown.
|
|
173
252
|
*
|
|
174
253
|
* @param contractClassId - The id of the class.
|
|
175
254
|
* @param selector - The function selector.
|
|
@@ -179,18 +258,16 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
179
258
|
return tree?.getFunctionMembershipWitness(selector);
|
|
180
259
|
}
|
|
181
260
|
async getDebugContractName(contractAddress) {
|
|
182
|
-
const artifact = await this.#
|
|
261
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
183
262
|
return artifact?.name;
|
|
184
263
|
}
|
|
185
264
|
async getDebugFunctionName(contractAddress, selector) {
|
|
186
|
-
const artifact = await this.#
|
|
187
|
-
const
|
|
188
|
-
return `${artifact?.name ?? contractAddress}:${
|
|
265
|
+
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
266
|
+
const fn = artifact && await this.#findFunctionAbiBySelector(artifact, selector);
|
|
267
|
+
return `${artifact?.name ?? contractAddress}:${fn?.name ?? selector}`;
|
|
189
268
|
}
|
|
190
269
|
async #findFunctionArtifactBySelector(artifact, selector) {
|
|
191
|
-
const
|
|
192
|
-
for(let i = 0; i < functions.length; i++){
|
|
193
|
-
const fn = functions[i];
|
|
270
|
+
for (const fn of artifact.functions){
|
|
194
271
|
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
195
272
|
if (fnSelector.equals(selector)) {
|
|
196
273
|
return fn;
|
|
@@ -198,12 +275,10 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
198
275
|
}
|
|
199
276
|
}
|
|
200
277
|
async #findFunctionAbiBySelector(artifact, selector) {
|
|
201
|
-
const
|
|
278
|
+
for (const fn of [
|
|
202
279
|
...artifact.functions,
|
|
203
280
|
...artifact.nonDispatchPublicFunctions ?? []
|
|
204
|
-
]
|
|
205
|
-
for(let i = 0; i < functions.length; i++){
|
|
206
|
-
const fn = functions[i];
|
|
281
|
+
]){
|
|
207
282
|
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
208
283
|
if (fnSelector.equals(selector)) {
|
|
209
284
|
return fn;
|
|
@@ -219,10 +294,11 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
219
294
|
if (!functionDao) {
|
|
220
295
|
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
221
296
|
}
|
|
297
|
+
const selector = await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters);
|
|
222
298
|
return FunctionCall.from({
|
|
223
299
|
name: functionDao.name,
|
|
224
300
|
to,
|
|
225
|
-
selector
|
|
301
|
+
selector,
|
|
226
302
|
type: functionDao.functionType,
|
|
227
303
|
hideMsgSender: false,
|
|
228
304
|
isStatic: functionDao.isStatic,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
3
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
4
4
|
/**
|
|
5
5
|
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
@@ -20,9 +20,9 @@ export declare class RecipientTaggingStore implements StagedStore {
|
|
|
20
20
|
*/
|
|
21
21
|
commit(jobId: string): Promise<void>;
|
|
22
22
|
discardStaged(jobId: string): Promise<void>;
|
|
23
|
-
getHighestAgedIndex(secret:
|
|
24
|
-
updateHighestAgedIndex(secret:
|
|
25
|
-
getHighestFinalizedIndex(secret:
|
|
26
|
-
updateHighestFinalizedIndex(secret:
|
|
23
|
+
getHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
24
|
+
updateHighestAgedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number, jobId: string): Promise<void>;
|
|
25
|
+
getHighestFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
26
|
+
updateHighestFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number, jobId: string): Promise<void>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvcmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU5RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwwQ0FBMEMsQ0FBQztBQUU1RTs7Ozs7OztHQU9HO0FBQ0gscUJBQWEscUJBQXNCLFlBQVcsV0FBVzs7SUFDdkQsU0FBUyxFQUFFLE1BQU0sQ0FBdUI7SUFheEMsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBUW5DO0lBNENEOzs7O09BSUc7SUFDRyxNQUFNLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBZ0J6QztJQUVELGFBQWEsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FJMUM7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsbUNBQW1DLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUUzRztJQUVELHNCQUFzQixDQUFDLE1BQU0sRUFBRSxtQ0FBbUMsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVMvRztJQUVELHdCQUF3QixDQUFDLE1BQU0sRUFBRSxtQ0FBbUMsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRWhIO0lBRUQsMkJBQTJCLENBQ3pCLE1BQU0sRUFBRSxtQ0FBbUMsRUFDM0MsS0FBSyxFQUFFLE1BQU0sRUFDYixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FVZjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;;IACvD,SAAS,EAAE,MAAM,CAAuB;IAaxC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED,mBAAmB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE3G;IAED,sBAAsB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/G;IAED,wBAAwB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEhH;IAED,2BAA2B,CACzB,MAAM,EAAE,mCAAmC,EAC3C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAUf;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtendedDirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
3
3
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
4
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
5
5
|
/**
|
|
@@ -50,20 +50,20 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
50
50
|
* @returns An array of unique transaction hashes for pending transactions that contain indexes in the range
|
|
51
51
|
* [startIndex, endIndex). Returns an empty array if no pending indexes exist in the range.
|
|
52
52
|
*/
|
|
53
|
-
getTxHashesOfPendingIndexes(secret:
|
|
53
|
+
getTxHashesOfPendingIndexes(secret: ExtendedDirectionalAppTaggingSecret, startIndex: number, endIndex: number, jobId: string): Promise<TxHash[]>;
|
|
54
54
|
/**
|
|
55
55
|
* Returns the last (highest) finalized index for a given secret.
|
|
56
56
|
* @param secret - The secret to get the last finalized index for.
|
|
57
57
|
* @returns The last (highest) finalized index for the given secret.
|
|
58
58
|
*/
|
|
59
|
-
getLastFinalizedIndex(secret:
|
|
59
|
+
getLastFinalizedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
60
60
|
/**
|
|
61
61
|
* Returns the last used index for a given directional app tagging secret, considering both finalized and pending
|
|
62
62
|
* indexes.
|
|
63
63
|
* @param secret - The directional app tagging secret to query the last used index for.
|
|
64
64
|
* @returns The last used index.
|
|
65
65
|
*/
|
|
66
|
-
getLastUsedIndex(secret:
|
|
66
|
+
getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
67
67
|
/**
|
|
68
68
|
* Drops all pending indexes corresponding to the given transaction hashes.
|
|
69
69
|
*/
|
|
@@ -74,4 +74,4 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
74
74
|
*/
|
|
75
75
|
finalizePendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
|
|
76
76
|
}
|
|
77
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvc2VuZGVyX3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsbUNBQW1DLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDdEYsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTFDLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBDQUEwQyxDQUFDO0FBRzVFOzs7O0dBSUc7QUFDSCxxQkFBYSxrQkFBbUIsWUFBVyxXQUFXOztJQUNwRCxRQUFRLENBQUMsU0FBUyxvQkFBb0I7SUE2QnRDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQVFuQztJQTRDRDs7OztPQUlHO0lBQ0csTUFBTSxDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQW9CekM7SUFFRCxhQUFhLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBSTFDO0lBRUQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztPQXFCRztJQUNILG1CQUFtQixDQUFDLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTBFbkY7SUFFRDs7Ozs7Ozs7T0FRRztJQUNILDJCQUEyQixDQUN6QixNQUFNLEVBQUUsbUNBQW1DLEVBQzNDLFVBQVUsRUFBRSxNQUFNLEVBQ2xCLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLEtBQUssRUFBRSxNQUFNLEdBQ1osT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBUW5CO0lBRUQ7Ozs7T0FJRztJQUNILHFCQUFxQixDQUFDLE1BQU0sRUFBRSxtQ0FBbUMsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRTdHO0lBRUQ7Ozs7O09BS0c7SUFDSCxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsbUNBQW1DLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQWtCeEc7SUFFRDs7T0FFRztJQUNILGtCQUFrQixDQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0EyQ25FO0lBRUQ7OztPQUdHO0lBQ0gsc0JBQXNCLENBQUMsUUFBUSxFQUFFLE1BQU0sRUFBRSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJGdkU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,WAAW;;IACpD,QAAQ,CAAC,SAAS,oBAAoB;IA6BtC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EnF;IAED;;;;;;;;OAQG;IACH,2BAA2B,CACzB,MAAM,EAAE,mCAAmC,EAC3C,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7G;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,mCAAmC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkBxG;IAED;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CnE;IAED;;;OAGG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2FvE;CACF"}
|
|
@@ -126,17 +126,17 @@ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/constants.
|
|
|
126
126
|
}
|
|
127
127
|
// The secrets in pre-tags should be unique because we always store just the highest index per given secret-txHash
|
|
128
128
|
// pair. Below we check that this is the case.
|
|
129
|
-
const secretsSet = new Set(preTags.map((preTag)=>preTag.
|
|
129
|
+
const secretsSet = new Set(preTags.map((preTag)=>preTag.extendedSecret.toString()));
|
|
130
130
|
if (secretsSet.size !== preTags.length) {
|
|
131
131
|
return Promise.reject(new Error(`Duplicate secrets found when storing pending indexes`));
|
|
132
132
|
}
|
|
133
133
|
const txHashStr = txHash.toString();
|
|
134
134
|
return this.#store.transactionAsync(async ()=>{
|
|
135
135
|
// Prefetch all data, start reads during iteration to keep IndexedDB transaction alive
|
|
136
|
-
const preTagReadPromises = preTags.map(({
|
|
137
|
-
const secretStr =
|
|
136
|
+
const preTagReadPromises = preTags.map(({ extendedSecret, index })=>{
|
|
137
|
+
const secretStr = extendedSecret.toString();
|
|
138
138
|
return {
|
|
139
|
-
|
|
139
|
+
extendedSecret,
|
|
140
140
|
secretStr,
|
|
141
141
|
index,
|
|
142
142
|
pending: this.#readPendingIndexes(jobId, secretStr),
|
package/dest/tagging/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export { loadPrivateLogsForSenderRecipientPair } from './recipient_sync/load_pri
|
|
|
12
12
|
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
|
|
13
13
|
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
14
14
|
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
|
|
15
|
-
export {
|
|
15
|
+
export { ExtendedDirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
16
16
|
export { type PreTag } from '@aztec/stdlib/logs';
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YWdnaW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7R0FTRztBQUVILE9BQU8sRUFBRSxxQ0FBcUMsRUFBRSxNQUFNLGlFQUFpRSxDQUFDO0FBQ3hILE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDhDQUE4QyxDQUFDO0FBQ3hGLE9BQU8sRUFBRSxzQ0FBc0MsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxrQ0FBa0MsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBR3hHLE9BQU8sRUFBRSxtQ0FBbUMsRUFBRSxHQUFHLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDekYsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tagging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,qCAAqC,EAAE,MAAM,iEAAiE,CAAC;AACxH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAGxG,OAAO,EAAE,mCAAmC,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dest/tagging/index.js
CHANGED
|
@@ -12,4 +12,4 @@ export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_inde
|
|
|
12
12
|
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
13
13
|
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
|
|
14
14
|
// Re-export tagging-related types from stdlib
|
|
15
|
-
export {
|
|
15
|
+
export { ExtendedDirectionalAppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
4
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
6
5
|
import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
|
|
7
6
|
/**
|
|
8
|
-
* Loads private logs for
|
|
7
|
+
* Loads private logs for the app-sender-recipient triplet defined by `secret` and updates the highest aged and
|
|
9
8
|
* finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
|
|
10
9
|
*
|
|
11
10
|
* @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
|
|
12
11
|
* in the tagging data provider is indexed by the secret and hence completely disjoint.
|
|
13
12
|
*/
|
|
14
|
-
export declare function loadPrivateLogsForSenderRecipientPair(secret:
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
export declare function loadPrivateLogsForSenderRecipientPair(secret: ExtendedDirectionalAppTaggingSecret, aztecNode: AztecNode, taggingStore: RecipientTaggingStore, anchorBlockNumber: BlockNumber, anchorBlockHash: BlockHash, jobId: string): Promise<TxScopedL2Log[]>;
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9wcml2YXRlX2xvZ3NfZm9yX3NlbmRlcl9yZWNpcGllbnRfcGFpci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvbG9hZF9wcml2YXRlX2xvZ3NfZm9yX3NlbmRlcl9yZWNpcGllbnRfcGFpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUU3RixPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHdEQUF3RCxDQUFDO0FBS3BHOzs7Ozs7R0FNRztBQUNILHdCQUFzQixxQ0FBcUMsQ0FDekQsTUFBTSxFQUFFLG1DQUFtQyxFQUMzQyxTQUFTLEVBQUUsU0FBUyxFQUNwQixZQUFZLEVBQUUscUJBQXFCLEVBQ25DLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsZUFBZSxFQUFFLFNBQVMsRUFDMUIsS0FBSyxFQUFFLE1BQU0sR0FDWixPQUFPLENBQUMsYUFBYSxFQUFFLENBQUMsQ0FtSDFCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load_private_logs_for_sender_recipient_pair.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"load_private_logs_for_sender_recipient_pair.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG;;;;;;GAMG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,mCAAmC,EAC3C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,EACnC,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,EAAE,CAAC,CAmH1B"}
|
|
@@ -2,12 +2,12 @@ import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
|
|
|
2
2
|
import { findHighestIndexes } from './utils/find_highest_indexes.js';
|
|
3
3
|
import { loadLogsForRange } from './utils/load_logs_for_range.js';
|
|
4
4
|
/**
|
|
5
|
-
* Loads private logs for
|
|
5
|
+
* Loads private logs for the app-sender-recipient triplet defined by `secret` and updates the highest aged and
|
|
6
6
|
* finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
|
|
7
7
|
*
|
|
8
8
|
* @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
|
|
9
9
|
* in the tagging data provider is indexed by the secret and hence completely disjoint.
|
|
10
|
-
*/ export async function loadPrivateLogsForSenderRecipientPair(secret,
|
|
10
|
+
*/ export async function loadPrivateLogsForSenderRecipientPair(secret, aztecNode, taggingStore, anchorBlockNumber, anchorBlockHash, jobId) {
|
|
11
11
|
// # Explanation of how the algorithm works
|
|
12
12
|
// When we perform the sync we will look at logs that correspond to the tagging index range
|
|
13
13
|
// (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
|
|
@@ -72,7 +72,7 @@ import { loadLogsForRange } from './utils/load_logs_for_range.js';
|
|
|
72
72
|
const logs = [];
|
|
73
73
|
while(true){
|
|
74
74
|
// Get private logs with their block timestamps and corresponding tagging indexes
|
|
75
|
-
const privateLogsWithIndexes = await loadLogsForRange(secret,
|
|
75
|
+
const privateLogsWithIndexes = await loadLogsForRange(secret, aztecNode, start, end, anchorBlockNumber, anchorBlockHash);
|
|
76
76
|
if (privateLogsWithIndexes.length === 0) {
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
4
3
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
6
5
|
/**
|
|
7
|
-
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range
|
|
8
|
-
* `
|
|
9
|
-
* exclusive.
|
|
6
|
+
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
|
|
7
|
+
* `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
|
|
8
|
+
* `end` is exclusive.
|
|
10
9
|
*/
|
|
11
|
-
export declare function loadLogsForRange(
|
|
10
|
+
export declare function loadLogsForRange(extendedSecret: ExtendedDirectionalAppTaggingSecret, aztecNode: AztecNode, start: number, end: number, anchorBlockNumber: BlockNumber, anchorBlockHash: BlockHash): Promise<Array<{
|
|
12
11
|
log: TxScopedL2Log;
|
|
13
12
|
taggingIndex: number;
|
|
14
13
|
}>>;
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9sb2dzX2Zvcl9yYW5nZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvdXRpbHMvbG9hZF9sb2dzX2Zvcl9yYW5nZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxtQ0FBbUMsRUFBRSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUs3Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxjQUFjLEVBQUUsbUNBQW1DLEVBQ25ELFNBQVMsRUFBRSxTQUFTLEVBQ3BCLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxpQkFBaUIsRUFBRSxXQUFXLEVBQzlCLGVBQWUsRUFBRSxTQUFTLEdBQ3pCLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FBQyxDQXVCOUQifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,mCAAmC,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK7F;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,mCAAmC,EACnD,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAuB9D"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { SiloedTag
|
|
1
|
+
import { SiloedTag } from '@aztec/stdlib/logs';
|
|
2
2
|
import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
3
3
|
/**
|
|
4
|
-
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range
|
|
5
|
-
* `
|
|
6
|
-
* exclusive.
|
|
7
|
-
*/ export async function loadLogsForRange(
|
|
8
|
-
// Derive tags for the window
|
|
9
|
-
const
|
|
10
|
-
|
|
4
|
+
* Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
|
|
5
|
+
* `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
|
|
6
|
+
* `end` is exclusive.
|
|
7
|
+
*/ export async function loadLogsForRange(extendedSecret, aztecNode, start, end, anchorBlockNumber, anchorBlockHash) {
|
|
8
|
+
// Derive siloed tags for the window
|
|
9
|
+
const siloedTags = await Promise.all(Array.from({
|
|
10
|
+
length: end - start
|
|
11
|
+
}, (_, i)=>SiloedTag.compute({
|
|
12
|
+
extendedSecret,
|
|
11
13
|
index: start + i
|
|
12
|
-
}));
|
|
13
|
-
const siloedTags = await Promise.all(preTags.map((preTag)=>Tag.compute(preTag))).then((tags)=>Promise.all(tags.map((tag)=>SiloedTag.compute(tag, app))));
|
|
14
|
+
})));
|
|
14
15
|
// We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
|
|
15
16
|
// pagination here.
|
|
16
17
|
const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
|
|
@@ -18,7 +19,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
|
|
|
18
19
|
const logsWithIndexes = [];
|
|
19
20
|
for(let i = 0; i < logs.length; i++){
|
|
20
21
|
const logsForTag = logs[i];
|
|
21
|
-
const taggingIndex =
|
|
22
|
+
const taggingIndex = start + i;
|
|
22
23
|
for (const log of logsForTag){
|
|
23
24
|
if (log.blockNumber <= anchorBlockNumber) {
|
|
24
25
|
logsWithIndexes.push({
|