@aztec/pxe 5.0.0-rc.1 → 5.0.0-rc.2
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_stream_source.d.ts +5 -5
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -1
- package/dest/block_synchronizer/block_stream_source.js +4 -29
- package/dest/block_synchronizer/block_synchronizer.d.ts +13 -11
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +43 -15
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +11 -16
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +22 -18
- package/dest/contract_function_simulator/index.d.ts +15 -9
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +3 -7
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +8 -27
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +8 -23
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +29 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +11 -12
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +6 -49
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +4 -8
- 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 -60
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/option.d.ts +9 -11
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/option.js +18 -13
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +5 -8
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -14
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +33 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +50 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +14 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +6 -11
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -20
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -14
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +81 -6
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +128 -9
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +80 -36
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +926 -264
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -8
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +80 -11
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +46 -20
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +119 -55
- package/dest/contract_sync/helpers.d.ts +7 -6
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +11 -16
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +1 -0
- package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +1 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +0 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +3 -1
- package/dest/error_enriching.js +1 -1
- package/dest/hooks/execution_hooks.d.ts +16 -7
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/execution_hooks.js +3 -3
- package/dest/hooks/index.d.ts +3 -3
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +41 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +62 -28
- package/dest/messages/tx_resolver_service.d.ts +17 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/{message_context_service.js → tx_resolver_service.js} +8 -8
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/test_utils.js +1 -1
- package/dest/pxe.d.ts +46 -19
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +104 -52
- package/dest/storage/allowed_scopes.d.ts +6 -0
- package/dest/storage/allowed_scopes.d.ts.map +1 -0
- package/dest/storage/allowed_scopes.js +7 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +86 -33
- package/dest/storage/capsule_store/capsule_service.d.ts +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_service.js +6 -9
- package/dest/storage/contract_store/contract_store.js +2 -2
- package/dest/storage/fact_store/fact_service.d.ts +20 -0
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_service.js +30 -0
- package/dest/storage/fact_store/fact_store.d.ts +95 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +408 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store_keys.js +50 -0
- package/dest/storage/fact_store/index.d.ts +5 -0
- package/dest/storage/fact_store/index.d.ts.map +1 -0
- package/dest/storage/fact_store/index.js +3 -0
- package/dest/storage/fact_store/stored_fact.d.ts +32 -0
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
- package/dest/storage/fact_store/stored_fact.js +64 -0
- package/dest/storage/index.d.ts +2 -1
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/open_pxe_stores.d.ts +5 -3
- package/dest/storage/open_pxe_stores.d.ts.map +1 -1
- package/dest/storage/open_pxe_stores.js +5 -3
- package/dest/storage/tagging_store/index.d.ts +2 -2
- package/dest/storage/tagging_store/index.d.ts.map +1 -1
- package/dest/storage/tagging_store/index.js +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +40 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +92 -0
- package/package.json +17 -17
- package/src/block_synchronizer/block_stream_source.ts +6 -45
- package/src/block_synchronizer/block_synchronizer.ts +56 -23
- package/src/config/index.ts +1 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +32 -31
- package/src/contract_function_simulator/index.ts +17 -8
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +12 -24
- package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
- package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +59 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +20 -46
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +7 -60
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/option.ts +17 -11
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +3 -14
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +45 -0
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +53 -0
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +15 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +5 -17
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/oracle_registry.ts +87 -79
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +641 -247
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +94 -14
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +206 -66
- package/src/contract_sync/helpers.ts +11 -18
- package/src/entrypoints/client/bundle/utils.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +1 -0
- package/src/entrypoints/pxe_creation_options.ts +7 -1
- package/src/entrypoints/server/index.ts +0 -1
- package/src/entrypoints/server/utils.ts +3 -1
- package/src/error_enriching.ts +1 -1
- package/src/hooks/execution_hooks.ts +17 -8
- package/src/hooks/index.ts +6 -2
- package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
- package/src/logs/log_service.ts +71 -37
- package/src/messages/{message_context_service.ts → tx_resolver_service.ts} +16 -9
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/test_utils.ts +1 -1
- package/src/pxe.ts +150 -54
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +21 -5
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +88 -33
- package/src/storage/capsule_store/capsule_service.ts +8 -13
- package/src/storage/contract_store/contract_store.ts +2 -2
- package/src/storage/fact_store/fact_service.ts +45 -0
- package/src/storage/fact_store/fact_store.ts +487 -0
- package/src/storage/fact_store/fact_store_keys.ts +75 -0
- package/src/storage/fact_store/index.ts +4 -0
- package/src/storage/fact_store/stored_fact.ts +80 -0
- package/src/storage/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/open_pxe_stores.ts +6 -3
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
- package/dest/messages/message_context_service.d.ts +0 -17
- package/dest/messages/message_context_service.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +0 -14
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +0 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +0 -36
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +0 -16
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
3
3
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
5
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
7
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
7
8
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -39,9 +40,11 @@ import { AddressStore } from '../address_store/address_store.js';
|
|
|
39
40
|
import { AnchorBlockStore } from '../anchor_block_store/index.js';
|
|
40
41
|
import { CapsuleStore } from '../capsule_store/capsule_store.js';
|
|
41
42
|
import { ContractStore } from '../contract_store/contract_store.js';
|
|
43
|
+
import { FactStore } from '../fact_store/fact_store.js';
|
|
44
|
+
import { FactCollectionKey } from '../fact_store/fact_store_keys.js';
|
|
42
45
|
import { NoteStore } from '../note_store/note_store.js';
|
|
43
46
|
import { PrivateEventStore } from '../private_event_store/private_event_store.js';
|
|
44
|
-
import { RecipientTaggingStore,
|
|
47
|
+
import { RecipientTaggingStore, SenderTaggingStore, TaggingSecretSourcesStore } from '../tagging_store/index.js';
|
|
45
48
|
import { snapshotArray, snapshotMap, snapshotSingleton } from './kv_store_snapshot.js';
|
|
46
49
|
|
|
47
50
|
/**
|
|
@@ -106,7 +109,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
106
109
|
SlotNumber(47),
|
|
107
110
|
53n,
|
|
108
111
|
EthAddress.fromField(new Fr(59n)),
|
|
109
|
-
AztecAddress.
|
|
112
|
+
AztecAddress.fromBigIntUnsafe(61n),
|
|
110
113
|
new GasFees(67n, 71n),
|
|
111
114
|
),
|
|
112
115
|
new Fr(73n),
|
|
@@ -125,8 +128,8 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
125
128
|
const capsuleStore = new CapsuleStore(kvStore);
|
|
126
129
|
|
|
127
130
|
const jobId = 'fixture-job';
|
|
128
|
-
const contractAddress = AztecAddress.
|
|
129
|
-
const scope = AztecAddress.
|
|
131
|
+
const contractAddress = AztecAddress.fromBigIntUnsafe(2n);
|
|
132
|
+
const scope = AztecAddress.fromBigIntUnsafe(3n);
|
|
130
133
|
|
|
131
134
|
// Three setCapsule calls (2-element, 1-element, 0-element value vector) pin every value-encoding length case.
|
|
132
135
|
capsuleStore.setCapsule(contractAddress, new Fr(5n), [new Fr(7n), new Fr(11n)], jobId, scope);
|
|
@@ -188,7 +191,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
188
191
|
new SerializableContractInstance({
|
|
189
192
|
version: 2,
|
|
190
193
|
salt: new Fr(73n),
|
|
191
|
-
deployer: AztecAddress.
|
|
194
|
+
deployer: AztecAddress.fromBigIntUnsafe(79n),
|
|
192
195
|
currentContractClassId: new Fr(83n),
|
|
193
196
|
originalContractClassId: new Fr(89n),
|
|
194
197
|
initializationHash: new Fr(97n),
|
|
@@ -204,7 +207,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
204
207
|
new Fr(71n),
|
|
205
208
|
new Fr(73n),
|
|
206
209
|
),
|
|
207
|
-
}).withAddress(AztecAddress.
|
|
210
|
+
}).withAddress(AztecAddress.fromBigIntUnsafe(101n)),
|
|
208
211
|
);
|
|
209
212
|
},
|
|
210
213
|
snapshotStore: async kvStore => ({
|
|
@@ -214,6 +217,40 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
214
217
|
}),
|
|
215
218
|
},
|
|
216
219
|
|
|
220
|
+
{
|
|
221
|
+
name: 'FactStore',
|
|
222
|
+
writeToStore: async kvStore => {
|
|
223
|
+
const factStore = new FactStore(kvStore);
|
|
224
|
+
const jobId = 'fixture-job';
|
|
225
|
+
const contract = AztecAddress.fromBigIntUnsafe(100n);
|
|
226
|
+
const scope = AztecAddress.fromBigIntUnsafe(1n);
|
|
227
|
+
const factCollectionTypeId = new Fr(7n);
|
|
228
|
+
const keyA = FactCollectionKey.from({
|
|
229
|
+
contractAddress: contract,
|
|
230
|
+
scope,
|
|
231
|
+
factCollectionTypeId,
|
|
232
|
+
factCollectionId: new Fr(0xaan),
|
|
233
|
+
});
|
|
234
|
+
const keyB = FactCollectionKey.from({
|
|
235
|
+
contractAddress: contract,
|
|
236
|
+
scope,
|
|
237
|
+
factCollectionTypeId,
|
|
238
|
+
factCollectionId: new Fr(0xbbn),
|
|
239
|
+
});
|
|
240
|
+
// A collection whose only fact is retractable (origin block 6): pruned on a reorg above block 6.
|
|
241
|
+
await factStore.recordFact(keyA, new Fr(3n), [new Fr(5n)], { blockNumber: 6, blockHash: new Fr(2n) }, jobId);
|
|
242
|
+
// A collection with a non-retractable and a retractable fact.
|
|
243
|
+
await factStore.recordFact(keyB, new Fr(1n), [new Fr(9n)], undefined, jobId);
|
|
244
|
+
await factStore.recordFact(keyB, new Fr(2n), [], { blockNumber: 5, blockHash: new Fr(1n) }, jobId);
|
|
245
|
+
await kvStore.transactionAsync(() => factStore.commit(jobId));
|
|
246
|
+
},
|
|
247
|
+
snapshotStore: async kvStore => ({
|
|
248
|
+
facts: await snapshotMap(kvStore.openMap<string, Buffer>('facts')),
|
|
249
|
+
facts_by_collection: await snapshotMap(kvStore.openMultiMap<string, string>('facts_by_collection')),
|
|
250
|
+
facts_by_block: await snapshotMap(kvStore.openMultiMap<number, string>('facts_by_block')),
|
|
251
|
+
}),
|
|
252
|
+
},
|
|
253
|
+
|
|
217
254
|
{
|
|
218
255
|
name: 'KeyStore',
|
|
219
256
|
writeToStore: async kvStore => {
|
|
@@ -243,9 +280,10 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
243
280
|
SlotNumber(19),
|
|
244
281
|
23n,
|
|
245
282
|
EthAddress.fromField(new Fr(29n)),
|
|
246
|
-
AztecAddress.
|
|
283
|
+
AztecAddress.fromBigIntUnsafe(31n),
|
|
247
284
|
new GasFees(37n, 41n),
|
|
248
285
|
new Fr(43n),
|
|
286
|
+
new Fr(47n),
|
|
249
287
|
),
|
|
250
288
|
[block],
|
|
251
289
|
CheckpointNumber(47),
|
|
@@ -261,7 +299,10 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
261
299
|
await l2TipsStore.handleBlockStreamEvent({
|
|
262
300
|
type: 'chain-checkpointed',
|
|
263
301
|
block: { number: BlockNumber(71), hash: new Fr(73n).toString() },
|
|
264
|
-
checkpoint:
|
|
302
|
+
checkpoint: {
|
|
303
|
+
number: publishedCheckpoint.checkpoint.number,
|
|
304
|
+
hash: publishedCheckpoint.checkpoint.hash().toString(),
|
|
305
|
+
},
|
|
265
306
|
});
|
|
266
307
|
// `'chain-proven'` writes the 'proven' tag. `'finalized'` is omitted because its handler runs delete-before
|
|
267
308
|
// logic that would depend on the order of preceding events.
|
|
@@ -289,17 +330,17 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
289
330
|
|
|
290
331
|
// Two contracts so `note_nullifiers_by_contract` exhibits both a multi-value row (contractA → {n1, n2}) and a
|
|
291
332
|
// single-value row (contractB → {n3}).
|
|
292
|
-
const contractA = AztecAddress.
|
|
293
|
-
const contractB = AztecAddress.
|
|
294
|
-
const scopeX = AztecAddress.
|
|
295
|
-
const scopeY = AztecAddress.
|
|
333
|
+
const contractA = AztecAddress.fromBigIntUnsafe(2n);
|
|
334
|
+
const contractB = AztecAddress.fromBigIntUnsafe(3n);
|
|
335
|
+
const scopeX = AztecAddress.fromBigIntUnsafe(5n);
|
|
336
|
+
const scopeY = AztecAddress.fromBigIntUnsafe(7n);
|
|
296
337
|
|
|
297
338
|
// note1: active, will be added under two scopes to exercise the multi-element scopes vector encoding in
|
|
298
339
|
// `StoredNote.toBuffer`.
|
|
299
340
|
const note1 = new NoteDao(
|
|
300
341
|
new Note([new Fr(13n), new Fr(17n), new Fr(19n)]),
|
|
301
342
|
contractA,
|
|
302
|
-
AztecAddress.
|
|
343
|
+
AztecAddress.fromBigIntUnsafe(23n),
|
|
303
344
|
new Fr(29n),
|
|
304
345
|
new Fr(31n),
|
|
305
346
|
new Fr(37n),
|
|
@@ -316,7 +357,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
316
357
|
const note2 = new NoteDao(
|
|
317
358
|
new Note([new Fr(71n), new Fr(73n), new Fr(79n)]),
|
|
318
359
|
contractA,
|
|
319
|
-
AztecAddress.
|
|
360
|
+
AztecAddress.fromBigIntUnsafe(83n),
|
|
320
361
|
new Fr(89n),
|
|
321
362
|
new Fr(97n),
|
|
322
363
|
new Fr(101n),
|
|
@@ -334,7 +375,7 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
334
375
|
const note3 = new NoteDao(
|
|
335
376
|
new Note([new Fr(139n), new Fr(149n), new Fr(151n)]),
|
|
336
377
|
contractB,
|
|
337
|
-
AztecAddress.
|
|
378
|
+
AztecAddress.fromBigIntUnsafe(157n),
|
|
338
379
|
new Fr(163n),
|
|
339
380
|
new Fr(167n),
|
|
340
381
|
new Fr(173n),
|
|
@@ -387,12 +428,12 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
387
428
|
|
|
388
429
|
// Two (contract, selector) pairs and two block numbers so each multimap exhibits both a multi-value row
|
|
389
430
|
// (contractA/selectorA → {e1, e2} and blockN1 → {e1, e2}) and a contrasting single-value row.
|
|
390
|
-
const contractA = AztecAddress.
|
|
391
|
-
const contractB = AztecAddress.
|
|
431
|
+
const contractA = AztecAddress.fromBigIntUnsafe(2n);
|
|
432
|
+
const contractB = AztecAddress.fromBigIntUnsafe(3n);
|
|
392
433
|
const selectorA = EventSelector.fromField(new Fr(5n));
|
|
393
434
|
const selectorB = EventSelector.fromField(new Fr(7n));
|
|
394
|
-
const scopeX = AztecAddress.
|
|
395
|
-
const scopeY = AztecAddress.
|
|
435
|
+
const scopeX = AztecAddress.fromBigIntUnsafe(11n);
|
|
436
|
+
const scopeY = AztecAddress.fromBigIntUnsafe(13n);
|
|
396
437
|
const blockN1 = BlockNumber(17);
|
|
397
438
|
const blockN2 = BlockNumber(19);
|
|
398
439
|
|
|
@@ -487,8 +528,8 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
487
528
|
const recipientTaggingStore = new RecipientTaggingStore(kvStore);
|
|
488
529
|
|
|
489
530
|
const jobId = 'fixture-job';
|
|
490
|
-
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.
|
|
491
|
-
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.
|
|
531
|
+
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
|
|
532
|
+
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
|
|
492
533
|
|
|
493
534
|
await recipientTaggingStore.updateHighestFinalizedIndex(secretA, 11, jobId);
|
|
494
535
|
await recipientTaggingStore.updateHighestAgedIndex(secretA, 13, jobId);
|
|
@@ -502,16 +543,30 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
502
543
|
},
|
|
503
544
|
|
|
504
545
|
{
|
|
505
|
-
name: '
|
|
546
|
+
name: 'TaggingSecretSourcesStore',
|
|
506
547
|
writeToStore: async kvStore => {
|
|
507
|
-
const
|
|
548
|
+
const taggingSecretSourcesStore = new TaggingSecretSourcesStore(kvStore);
|
|
549
|
+
|
|
550
|
+
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(2n));
|
|
551
|
+
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(3n));
|
|
552
|
+
await taggingSecretSourcesStore.addSender(AztecAddress.fromBigIntUnsafe(5n));
|
|
508
553
|
|
|
509
|
-
await
|
|
510
|
-
|
|
511
|
-
|
|
554
|
+
await taggingSecretSourcesStore.addSharedSecret(
|
|
555
|
+
AztecAddress.fromBigIntUnsafe(7n),
|
|
556
|
+
new Point(new Fr(2n), new Fr(3n)),
|
|
557
|
+
);
|
|
558
|
+
await taggingSecretSourcesStore.addSharedSecret(
|
|
559
|
+
AztecAddress.fromBigIntUnsafe(7n),
|
|
560
|
+
new Point(new Fr(5n), new Fr(7n)),
|
|
561
|
+
);
|
|
562
|
+
await taggingSecretSourcesStore.addSharedSecret(
|
|
563
|
+
AztecAddress.fromBigIntUnsafe(11n),
|
|
564
|
+
new Point(new Fr(13n), new Fr(17n)),
|
|
565
|
+
);
|
|
512
566
|
},
|
|
513
567
|
snapshotStore: async kvStore => ({
|
|
514
|
-
|
|
568
|
+
senders: await snapshotMap(kvStore.openMap<string, true>('senders')),
|
|
569
|
+
recipient_shared_secrets: await snapshotMap(kvStore.openMultiMap<string, string>('recipient_shared_secrets')),
|
|
515
570
|
}),
|
|
516
571
|
},
|
|
517
572
|
|
|
@@ -521,9 +576,9 @@ export const SCHEMA_TESTS: readonly SchemaTest[] = [
|
|
|
521
576
|
const senderTaggingStore = new SenderTaggingStore(kvStore);
|
|
522
577
|
|
|
523
578
|
const jobId = 'fixture-job';
|
|
524
|
-
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.
|
|
525
|
-
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.
|
|
526
|
-
const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.
|
|
579
|
+
const secretA = new AppTaggingSecret(new Fr(2n), AztecAddress.fromBigIntUnsafe(3n));
|
|
580
|
+
const secretB = new AppTaggingSecret(new Fr(5n), AztecAddress.fromBigIntUnsafe(7n));
|
|
581
|
+
const secretC = new AppTaggingSecret(new Fr(11n), AztecAddress.fromBigIntUnsafe(13n));
|
|
527
582
|
const txHashA = TxHash.fromBigInt(17n);
|
|
528
583
|
const txHashB = TxHash.fromBigInt(19n);
|
|
529
584
|
const txHashC = TxHash.fromBigInt(23n);
|
|
@@ -617,7 +672,7 @@ function buildL2Block(): L2Block {
|
|
|
617
672
|
SlotNumber(181),
|
|
618
673
|
191n,
|
|
619
674
|
EthAddress.fromField(new Fr(193n)),
|
|
620
|
-
AztecAddress.
|
|
675
|
+
AztecAddress.fromBigIntUnsafe(197n),
|
|
621
676
|
new GasFees(199n, 211n),
|
|
622
677
|
),
|
|
623
678
|
new Fr(223n),
|
|
@@ -638,10 +693,10 @@ function buildL2Block(): L2Block {
|
|
|
638
693
|
3,
|
|
639
694
|
),
|
|
640
695
|
],
|
|
641
|
-
[new PublicLog(AztecAddress.
|
|
696
|
+
[new PublicLog(AztecAddress.fromBigIntUnsafe(281n), [new Fr(283n), new Fr(293n)])],
|
|
642
697
|
[
|
|
643
698
|
new ContractClassLog(
|
|
644
|
-
AztecAddress.
|
|
699
|
+
AztecAddress.fromBigIntUnsafe(307n),
|
|
645
700
|
new ContractClassLogFields(paddedFrs([311n, 313n, 317n], CONTRACT_CLASS_LOG_SIZE_IN_FIELDS)),
|
|
646
701
|
3,
|
|
647
702
|
),
|
|
@@ -2,6 +2,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { Capsule } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
|
+
import { assertAllowedScope } from '../allowed_scopes.js';
|
|
5
6
|
import type { CapsuleStore } from './capsule_store.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -9,10 +10,15 @@ import type { CapsuleStore } from './capsule_store.js';
|
|
|
9
10
|
* allowed scopes list before delegating to the underlying store.
|
|
10
11
|
*/
|
|
11
12
|
export class CapsuleService {
|
|
13
|
+
private readonly allowedScopes: AztecAddress[];
|
|
14
|
+
|
|
12
15
|
constructor(
|
|
13
16
|
private readonly capsuleStore: CapsuleStore,
|
|
14
|
-
|
|
15
|
-
) {
|
|
17
|
+
allowedScopes: AztecAddress[],
|
|
18
|
+
) {
|
|
19
|
+
// The zero address denotes the global capsule scope, which is always permitted.
|
|
20
|
+
this.allowedScopes = [...allowedScopes, AztecAddress.ZERO];
|
|
21
|
+
}
|
|
16
22
|
|
|
17
23
|
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
|
|
18
24
|
assertAllowedScope(scope, this.allowedScopes);
|
|
@@ -77,14 +83,3 @@ export class CapsuleService {
|
|
|
77
83
|
return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
|
-
|
|
81
|
-
function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]) {
|
|
82
|
-
if (scope.equals(AztecAddress.ZERO)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (!allowedScopes.some((allowed: AztecAddress) => allowed.equals(scope))) {
|
|
86
|
-
throw new Error(
|
|
87
|
-
`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s: AztecAddress) => s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -215,7 +215,7 @@ export class ContractStore {
|
|
|
215
215
|
getContractsAddresses(): Promise<AztecAddress[]> {
|
|
216
216
|
return this.#store.transactionAsync(async () => {
|
|
217
217
|
const keys = await toArray(this.#contractInstances.keysAsync());
|
|
218
|
-
return keys.map(AztecAddress.
|
|
218
|
+
return keys.map(AztecAddress.fromStringUnsafe);
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
|
|
@@ -383,7 +383,7 @@ export class ContractStore {
|
|
|
383
383
|
const contract = await this.getContract(to);
|
|
384
384
|
if (!contract) {
|
|
385
385
|
throw new Error(
|
|
386
|
-
`Unknown contract ${to}:
|
|
386
|
+
`Unknown contract ${to}: register it by calling wallet.registerContract(...).\nSee docs for context: https://docs.aztec.network/errors/14`,
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
389
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
|
|
4
|
+
import { assertAllowedScope } from '../allowed_scopes.js';
|
|
5
|
+
import type { FactCollection, FactStore } from './fact_store.js';
|
|
6
|
+
import type { FactCollectionKey, FactCollectionTypeKey, OriginBlock } from './fact_store_keys.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a {@link FactStore} with scope-based access control.
|
|
10
|
+
*
|
|
11
|
+
* Each method asserts scope validity before delegating to FactStore, gating which accounts a contract may record facts
|
|
12
|
+
* under or read facts from.
|
|
13
|
+
*/
|
|
14
|
+
export class FactService {
|
|
15
|
+
constructor(
|
|
16
|
+
private readonly factStore: FactStore,
|
|
17
|
+
private readonly allowedScopes: AztecAddress[],
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
recordFact(
|
|
21
|
+
factCollectionKey: FactCollectionKey,
|
|
22
|
+
factTypeId: Fr,
|
|
23
|
+
payload: Fr[],
|
|
24
|
+
originBlock: OriginBlock | undefined,
|
|
25
|
+
jobId: string,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
assertAllowedScope(factCollectionKey.scope, this.allowedScopes);
|
|
28
|
+
return this.factStore.recordFact(factCollectionKey, factTypeId, payload, originBlock, jobId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
deleteFactCollection(factCollectionKey: FactCollectionKey, jobId: string): Promise<void> {
|
|
32
|
+
assertAllowedScope(factCollectionKey.scope, this.allowedScopes);
|
|
33
|
+
return this.factStore.deleteFactCollection(factCollectionKey, jobId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getFactCollection(factCollectionKey: FactCollectionKey, jobId: string): Promise<FactCollection | undefined> {
|
|
37
|
+
assertAllowedScope(factCollectionKey.scope, this.allowedScopes);
|
|
38
|
+
return this.factStore.getFactCollection(factCollectionKey, jobId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getFactCollectionsByType(factCollectionTypeKey: FactCollectionTypeKey, jobId: string): Promise<FactCollection[]> {
|
|
42
|
+
assertAllowedScope(factCollectionTypeKey.scope, this.allowedScopes);
|
|
43
|
+
return this.factStore.getFactCollectionsByType(factCollectionTypeKey, jobId);
|
|
44
|
+
}
|
|
45
|
+
}
|