@aztec/pxe 5.0.0-rc.2 → 5.0.1
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 +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/contract/contract_class_service.d.ts +31 -0
- package/dest/contract/contract_class_service.d.ts.map +1 -0
- package/dest/contract/contract_class_service.js +68 -0
- package/dest/{contract_sync → contract}/contract_sync_service.d.ts +7 -6
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/{contract_sync → contract}/contract_sync_service.js +10 -30
- package/dest/contract/helpers.d.ts +7 -0
- package/dest/contract/helpers.d.ts.map +1 -0
- package/dest/contract/helpers.js +20 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -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 +31 -14
- package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +8 -28
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact.js +2 -2
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +3 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +7 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +2 -2
- 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 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +8 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +17 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +7 -2
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/acir_callback.js +55 -11
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts +39 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +11 -7
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +50 -10
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +48 -9
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +51 -30
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +10 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +105 -60
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- 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/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -5
- 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/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 +11 -5
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +28 -0
- package/dest/entrypoints/server/index.d.ts +6 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- 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 +8 -2
- package/dest/error_enriching.d.ts +5 -3
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +12 -10
- package/dest/hooks/execution_hooks.d.ts +15 -4
- package/dest/hooks/execution_hooks.d.ts.map +1 -1
- package/dest/hooks/index.d.ts +3 -2
- package/dest/hooks/index.d.ts.map +1 -1
- package/dest/hooks/index.js +1 -0
- package/dest/hooks/resolve_custom_request.d.ts +23 -0
- package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
- package/dest/hooks/resolve_custom_request.js +3 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +10 -1
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -1
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -3
- package/dest/logs/log_service.d.ts +5 -3
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +38 -17
- package/dest/notes/note_service.d.ts +1 -1
- package/dest/notes/note_service.js +1 -1
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +1 -1
- 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 +6 -2
- 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 +17 -36
- package/dest/private_kernel/private_kernel_oracle.d.ts +4 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +17 -5
- package/dest/pxe.d.ts +81 -46
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +138 -104
- 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 +31 -7
- package/dest/storage/contract_store/contract_store.d.ts +27 -24
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +63 -74
- package/dest/storage/fact_store/fact_service.d.ts +6 -4
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_service.js +19 -4
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -1
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -0
- package/dest/storage/fact_store/origin_state.d.ts +57 -0
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
- package/dest/storage/fact_store/origin_state.js +53 -0
- package/dest/storage/metadata.d.ts +2 -2
- package/dest/storage/metadata.d.ts.map +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -3
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +48 -11
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +17 -6
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +24 -11
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +18 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -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 +6 -2
- package/package.json +17 -17
- package/src/block_synchronizer/block_synchronizer.ts +9 -1
- package/src/contract/contract_class_service.ts +83 -0
- package/src/{contract_sync → contract}/contract_sync_service.ts +18 -37
- package/src/contract/helpers.ts +35 -0
- package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
- package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +56 -14
- package/src/contract_function_simulator/execution_note_cache.ts +7 -28
- package/src/contract_function_simulator/index.ts +7 -1
- package/src/contract_function_simulator/noir-structs/fact.ts +4 -4
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +9 -4
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +6 -0
- package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +1 -1
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +21 -0
- package/src/contract_function_simulator/oracle/acir_callback.ts +58 -12
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/oracle_registry.ts +37 -7
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +49 -32
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -41
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +149 -71
- package/src/debug/pxe_debug_utils.ts +1 -1
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -4
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +16 -4
- package/src/entrypoints/client/store.ts +38 -0
- package/src/entrypoints/server/index.ts +6 -1
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- package/src/error_enriching.ts +26 -10
- package/src/hooks/execution_hooks.ts +14 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/resolve_custom_request.ts +24 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +14 -0
- package/src/logs/log_service.ts +35 -11
- package/src/notes/note_service.ts +1 -1
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +11 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +22 -52
- package/src/private_kernel/private_kernel_oracle.ts +23 -4
- package/src/pxe.ts +212 -143
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +6 -6
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +12 -12
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +11 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +12 -4
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +3 -3
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +1 -1
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +38 -4
- package/src/storage/contract_store/contract_store.ts +85 -92
- package/src/storage/fact_store/fact_service.ts +29 -5
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +10 -0
- package/src/storage/fact_store/origin_state.ts +75 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +62 -15
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +36 -15
- package/src/tagging/constants.ts +19 -9
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -1
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +6 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -51
- package/dest/contract_sync/contract_sync_service.d.ts.map +0 -1
- package/dest/contract_sync/helpers.d.ts +0 -28
- package/dest/contract_sync/helpers.d.ts.map +0 -1
- package/dest/contract_sync/helpers.js +0 -48
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -60
- package/src/contract_sync/helpers.ts +0 -79
|
@@ -24,15 +24,13 @@ import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
|
24
24
|
import { PublicDataWrite, RevertCode } from '@aztec/stdlib/avm';
|
|
25
25
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
26
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
27
|
-
import type {
|
|
27
|
+
import type { ContractInstancePreimage, PartialAddress } from '@aztec/stdlib/contract';
|
|
28
28
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
29
29
|
import { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
30
30
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
31
31
|
import {
|
|
32
32
|
type AppTaggingSecretKind,
|
|
33
33
|
type FlatPublicLogs,
|
|
34
|
-
type MessageContext,
|
|
35
|
-
type PendingTaggedLog,
|
|
36
34
|
PrivateLog,
|
|
37
35
|
Tag,
|
|
38
36
|
appTaggingSecretKindFromDeliveryMode,
|
|
@@ -54,7 +52,7 @@ import {
|
|
|
54
52
|
TxHash,
|
|
55
53
|
} from '@aztec/stdlib/tx';
|
|
56
54
|
|
|
57
|
-
import type { OriginBlock } from '../../storage/fact_store/index.js';
|
|
55
|
+
import type { OriginBlock, RetractableFactOrigin } from '../../storage/fact_store/index.js';
|
|
58
56
|
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
59
57
|
import type { ContractClassLogData } from '../noir-structs/contract_class_log_data.js';
|
|
60
58
|
import type { EmbeddedCurvePoint } from '../noir-structs/embedded_curve_point.js';
|
|
@@ -67,6 +65,7 @@ import type { LogRetrievalResponse } from '../noir-structs/log_retrieval_respons
|
|
|
67
65
|
import type { NoteData } from '../noir-structs/note_data.js';
|
|
68
66
|
import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
|
|
69
67
|
import { Option } from '../noir-structs/option.js';
|
|
68
|
+
import type { PendingTaggedLog } from '../noir-structs/pending_tagged_log.js';
|
|
70
69
|
import type { ProvidedSecret } from '../noir-structs/provided_secret.js';
|
|
71
70
|
import {
|
|
72
71
|
type ResolvedTaggingStrategy,
|
|
@@ -86,9 +85,8 @@ export type {
|
|
|
86
85
|
AppTaggingSecretKind,
|
|
87
86
|
BlockHash,
|
|
88
87
|
BlockHeader,
|
|
89
|
-
|
|
88
|
+
ContractInstancePreimage,
|
|
90
89
|
MembershipWitness,
|
|
91
|
-
MessageContext,
|
|
92
90
|
NullifierMembershipWitness,
|
|
93
91
|
PendingTaggedLog,
|
|
94
92
|
PublicDataWitness,
|
|
@@ -294,7 +292,7 @@ export const ETH_ADDRESS: TypeMapping<EthAddress> = {
|
|
|
294
292
|
shape: ['scalar'],
|
|
295
293
|
};
|
|
296
294
|
|
|
297
|
-
const SLOT_NUMBER: TypeMapping<SlotNumber> = {
|
|
295
|
+
export const SLOT_NUMBER: TypeMapping<SlotNumber> = {
|
|
298
296
|
serialization: { fn: v => [new Fr(v)] },
|
|
299
297
|
shape: ['scalar'],
|
|
300
298
|
};
|
|
@@ -354,7 +352,7 @@ const PUBLIC_KEYS: TypeMapping<PublicKeys> = STRUCT<PublicKeys>([
|
|
|
354
352
|
{ name: 'fbpkMHash', type: FIELD },
|
|
355
353
|
]);
|
|
356
354
|
|
|
357
|
-
export const CONTRACT_INSTANCE: TypeMapping<
|
|
355
|
+
export const CONTRACT_INSTANCE: TypeMapping<ContractInstancePreimage> = STRUCT<ContractInstancePreimage>([
|
|
358
356
|
{ name: 'salt', type: FIELD },
|
|
359
357
|
{ name: 'deployer', type: AZTEC_ADDRESS },
|
|
360
358
|
// Note that the nr side of this struct does not contain the current class, only original
|
|
@@ -518,17 +516,9 @@ export const LOG_RETRIEVAL_RESPONSE: TypeMapping<LogRetrievalResponse> = STRUCT<
|
|
|
518
516
|
{ name: 'txHash', type: TX_HASH },
|
|
519
517
|
{ name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
|
|
520
518
|
{ name: 'firstNullifierInTx', type: FIELD },
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
{ name: 'txHash', type: TX_HASH },
|
|
525
|
-
{ name: 'uniqueNoteHashesInTx', type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX) },
|
|
526
|
-
{ name: 'firstNullifierInTx', type: FIELD },
|
|
527
|
-
]);
|
|
528
|
-
|
|
529
|
-
export const PENDING_TAGGED_LOG: TypeMapping<PendingTaggedLog> = STRUCT<PendingTaggedLog>([
|
|
530
|
-
{ name: 'log', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS) },
|
|
531
|
-
{ name: 'context', type: MESSAGE_CONTEXT },
|
|
519
|
+
{ name: 'blockNumber', type: BLOCK_NUMBER },
|
|
520
|
+
{ name: 'blockTimestamp', type: BIGINT },
|
|
521
|
+
{ name: 'blockHash', type: BLOCK_HASH },
|
|
532
522
|
]);
|
|
533
523
|
|
|
534
524
|
// `ResolvedTx.toFields()` packs the whole struct into a single slot: txHash, the uniqueNoteHashesInTx BoundedVec
|
|
@@ -538,6 +528,11 @@ export const RESOLVED_TX: TypeMapping<ResolvedTx> = {
|
|
|
538
528
|
shape: [{ len: MAX_NOTE_HASHES_PER_TX + 5 }],
|
|
539
529
|
};
|
|
540
530
|
|
|
531
|
+
export const PENDING_TAGGED_LOG: TypeMapping<PendingTaggedLog> = STRUCT([
|
|
532
|
+
{ name: 'log', type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS) },
|
|
533
|
+
{ name: 'context', type: RESOLVED_TX },
|
|
534
|
+
]);
|
|
535
|
+
|
|
541
536
|
export const ORIGIN_BLOCK: TypeMapping<OriginBlock> = {
|
|
542
537
|
serialization: { fn: ob => [new Fr(ob.blockNumber), ob.blockHash] },
|
|
543
538
|
deserialization: {
|
|
@@ -549,17 +544,23 @@ export const ORIGIN_BLOCK: TypeMapping<OriginBlock> = {
|
|
|
549
544
|
shape: ['scalar', 'scalar'],
|
|
550
545
|
};
|
|
551
546
|
|
|
547
|
+
/** Read-side origin of a retractable fact, carrying the chain state of its origin block. */
|
|
548
|
+
export const RETRACTABLE_FACT_ORIGIN: TypeMapping<RetractableFactOrigin> = {
|
|
549
|
+
serialization: { fn: o => [new Fr(o.blockNumber), o.blockHash, new Fr(o.blockState)] },
|
|
550
|
+
shape: ['scalar', 'scalar', 'scalar'],
|
|
551
|
+
};
|
|
552
|
+
|
|
552
553
|
// `facts` and `payload` each materialize to a single service-slot id, so a Fact occupies: factTypeId, the payload
|
|
553
|
-
// array slot, and `OPTION(
|
|
554
|
+
// array slot, and `OPTION(RETRACTABLE_FACT_ORIGIN)` (its discriminant plus RETRACTABLE_FACT_ORIGIN's three slots).
|
|
554
555
|
export const FACT: TypeMapping<Fact> = {
|
|
555
556
|
serialization: {
|
|
556
557
|
fn: f => [
|
|
557
558
|
f.factTypeId,
|
|
558
559
|
f.payload.materializeSlot(v => FIELD.serialization!.fn(v).flat() as Fr[]),
|
|
559
|
-
...OPTION(
|
|
560
|
+
...OPTION(RETRACTABLE_FACT_ORIGIN).serialization!.fn(f.originBlock),
|
|
560
561
|
],
|
|
561
562
|
},
|
|
562
|
-
shape: ['scalar', 'scalar', 'scalar', 'scalar', 'scalar'],
|
|
563
|
+
shape: ['scalar', 'scalar', 'scalar', 'scalar', 'scalar', 'scalar'],
|
|
563
564
|
};
|
|
564
565
|
|
|
565
566
|
export const FACT_COLLECTION: TypeMapping<FactCollection> = {
|
|
@@ -618,20 +619,26 @@ export function ARRAY<T>(inner: TypeMapping<T>): TypeMapping<T[]> & { kind: 'arr
|
|
|
618
619
|
}
|
|
619
620
|
|
|
620
621
|
/**
|
|
621
|
-
* Noir's fixed-length array `[T;
|
|
622
|
-
* zero-padded to exactly `
|
|
622
|
+
* Noir's fixed-length array `[T; length]` in one slot: serializes `values` (each flattened via `element`)
|
|
623
|
+
* zero-padded to exactly `length * elementWidth` fields, and deserializes all `length` elements back. An absent
|
|
623
624
|
* element is the zero encoding, so the padding is derived from the shape.
|
|
624
625
|
*/
|
|
625
|
-
function FIXED_ARRAY<T>(
|
|
626
|
+
export function FIXED_ARRAY<T>(
|
|
627
|
+
element: TypeMapping<T>,
|
|
628
|
+
length: number,
|
|
629
|
+
): TypeMapping<T[]> & { kind: 'fixed-array'; inner: TypeMapping<T>; length: number } {
|
|
626
630
|
const elementWidth = fieldWidth(element.shape);
|
|
627
631
|
return {
|
|
632
|
+
kind: 'fixed-array',
|
|
633
|
+
inner: element,
|
|
634
|
+
length,
|
|
628
635
|
serialization: element.serialization
|
|
629
|
-
? { fn: values => [padArrayEnd(packElements(element, values), Fr.ZERO,
|
|
636
|
+
? { fn: values => [padArrayEnd(packElements(element, values), Fr.ZERO, length * elementWidth)] }
|
|
630
637
|
: undefined,
|
|
631
638
|
deserialization: element.deserialization
|
|
632
|
-
? { fn: ([reader]) => unpackElements(element, reader,
|
|
639
|
+
? { fn: ([reader]) => unpackElements(element, reader, length) }
|
|
633
640
|
: undefined,
|
|
634
|
-
shape: [{ len:
|
|
641
|
+
shape: [{ len: length * elementWidth }],
|
|
635
642
|
};
|
|
636
643
|
}
|
|
637
644
|
|
|
@@ -691,9 +698,15 @@ export function BOUNDED_VEC<T>(
|
|
|
691
698
|
* (zero-padded) followed by the actual length, with no length prefix, so the width is statically known. Serialize-only.
|
|
692
699
|
* Throws if the input exceeds `maxLength`.
|
|
693
700
|
*/
|
|
694
|
-
function FIXED_BOUNDED_VEC<T>(
|
|
701
|
+
export function FIXED_BOUNDED_VEC<T>(
|
|
702
|
+
element: TypeMapping<T>,
|
|
703
|
+
maxLength: number,
|
|
704
|
+
): TypeMapping<T[]> & { kind: 'fixed-bounded-vec'; inner: TypeMapping<T>; maxLength: number } {
|
|
695
705
|
const width = fieldWidth(element.shape);
|
|
696
706
|
return {
|
|
707
|
+
kind: 'fixed-bounded-vec',
|
|
708
|
+
inner: element,
|
|
709
|
+
maxLength,
|
|
697
710
|
serialization: element.serialization
|
|
698
711
|
? {
|
|
699
712
|
fn: values => {
|
|
@@ -804,15 +817,19 @@ export function EPHEMERAL_ARRAY<T>(element: TypeMapping<T>): TypeMapping<Ephemer
|
|
|
804
817
|
}
|
|
805
818
|
|
|
806
819
|
/** A named field within a {@link STRUCT}: it owns however many wire slots its {@link TypeMapping} declares. */
|
|
807
|
-
type StructField<TName extends string = string, T = any> = { name: TName; type: TypeMapping<T> };
|
|
820
|
+
export type StructField<TName extends string = string, T = any> = { name: TName; type: TypeMapping<T> };
|
|
808
821
|
|
|
809
822
|
/**
|
|
810
823
|
* A Noir struct: its `shape` and (de)serialization are the concatenation of its fields', so callers never hand-write a
|
|
811
824
|
* `shape`. `T` is the struct's TS value type and must match the field layout — serialization reads each field by name
|
|
812
825
|
* off the value, deserialization returns the decoded bag as `T`; convert in the handler, not here, when `T` differs.
|
|
813
826
|
*/
|
|
814
|
-
function STRUCT<T>(
|
|
827
|
+
export function STRUCT<T>(
|
|
828
|
+
fields: readonly StructField[],
|
|
829
|
+
): TypeMapping<T> & { kind: 'struct'; fields: readonly StructField[] } {
|
|
815
830
|
return {
|
|
831
|
+
kind: 'struct',
|
|
832
|
+
fields,
|
|
816
833
|
serialization: fields.every(f => f.type.serialization)
|
|
817
834
|
? {
|
|
818
835
|
fn: (value: T) => {
|
|
@@ -845,7 +862,7 @@ export function slotsOf(mapping: TypeMapping): number {
|
|
|
845
862
|
}
|
|
846
863
|
|
|
847
864
|
/** Number of fields a fully-static shape occupies, or `undefined` if any slot is variable-width. */
|
|
848
|
-
function tryFieldWidth(shape: SlotShape[]): number | undefined {
|
|
865
|
+
export function tryFieldWidth(shape: SlotShape[]): number | undefined {
|
|
849
866
|
let total = 0;
|
|
850
867
|
for (const slot of shape) {
|
|
851
868
|
if (slot === 'scalar') {
|
|
@@ -29,9 +29,11 @@ import {
|
|
|
29
29
|
type TxContext,
|
|
30
30
|
} from '@aztec/stdlib/tx';
|
|
31
31
|
|
|
32
|
-
import type {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
import type { ResolveCustomRequest } from '../../hooks/resolve_custom_request.js';
|
|
33
|
+
import {
|
|
34
|
+
DEFAULT_TAGGING_SECRET_STRATEGY,
|
|
35
|
+
type ResolveTaggingSecretStrategy,
|
|
36
|
+
type TaggingSecretStrategy,
|
|
35
37
|
} from '../../hooks/resolve_tagging_secret_strategy.js';
|
|
36
38
|
import { NoteService } from '../../notes/note_service.js';
|
|
37
39
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
@@ -53,6 +55,7 @@ import { UtilityExecutionOracle, type UtilityExecutionOracleArgs } from './utili
|
|
|
53
55
|
export type PrivateExecutionOracleArgs = UtilityExecutionOracleArgs & {
|
|
54
56
|
argsHash: Fr;
|
|
55
57
|
txContext: TxContext;
|
|
58
|
+
txRequestSalt: Fr;
|
|
56
59
|
executionCache: HashedValuesCache;
|
|
57
60
|
noteCache: ExecutionNoteCache;
|
|
58
61
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -83,6 +86,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
83
86
|
|
|
84
87
|
private readonly argsHash: Fr;
|
|
85
88
|
private readonly txContext: TxContext;
|
|
89
|
+
private readonly txRequestSalt: Fr;
|
|
86
90
|
private readonly executionCache: HashedValuesCache;
|
|
87
91
|
private readonly noteCache: ExecutionNoteCache;
|
|
88
92
|
private readonly taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -99,6 +103,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
99
103
|
});
|
|
100
104
|
this.argsHash = args.argsHash;
|
|
101
105
|
this.txContext = args.txContext;
|
|
106
|
+
this.txRequestSalt = args.txRequestSalt;
|
|
102
107
|
this.executionCache = args.executionCache;
|
|
103
108
|
this.noteCache = args.noteCache;
|
|
104
109
|
this.taggingIndexCache = args.taggingIndexCache;
|
|
@@ -114,6 +119,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
114
119
|
this.anchorBlockHeader,
|
|
115
120
|
this.txContext,
|
|
116
121
|
this.initialSideEffectCounter,
|
|
122
|
+
this.txRequestSalt,
|
|
117
123
|
);
|
|
118
124
|
}
|
|
119
125
|
|
|
@@ -187,30 +193,81 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
187
193
|
return Promise.resolve(this.defaultSenderForTags ? Option.some(this.defaultSenderForTags) : Option.none());
|
|
188
194
|
}
|
|
189
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Resolves a custom, caller-defined request via the {@link ResolveCustomRequest} hook, which produces the response
|
|
198
|
+
* however it needs to. Throws when no hook is configured, since the request cannot be served.
|
|
199
|
+
*/
|
|
200
|
+
public async resolveCustomRequest(kind: Fr, payload: Fr[]): Promise<Fr[]> {
|
|
201
|
+
const hook: ResolveCustomRequest | undefined = this.hooks?.resolveCustomRequest;
|
|
202
|
+
if (!hook) {
|
|
203
|
+
throw new Error('Cannot serve a request: no resolveCustomRequest hook is configured');
|
|
204
|
+
}
|
|
205
|
+
const contractClassId = await this.#getCurrentContractClassId(this.contractAddress);
|
|
206
|
+
return hook({ contractAddress: this.contractAddress, contractClassId, kind, payload });
|
|
207
|
+
}
|
|
208
|
+
|
|
190
209
|
/**
|
|
191
210
|
* Resolves the tagging strategy for a message via the wallet's {@link ResolveTaggingSecretStrategy} hook. The contract receives a ready-to-use {@link ResolvedTaggingStrategy}.
|
|
192
|
-
* When no hook is configured, applies a
|
|
211
|
+
* When no hook is configured, applies a default: a non-interactive handshake, except for an unconstrained self-send,
|
|
212
|
+
* which uses an address-derived secret.
|
|
193
213
|
*/
|
|
194
214
|
public async resolveTaggingStrategy(
|
|
195
215
|
sender: AztecAddress,
|
|
196
216
|
recipient: AztecAddress,
|
|
197
217
|
deliveryMode: AppTaggingSecretKind,
|
|
198
218
|
): Promise<ResolvedTaggingStrategy> {
|
|
219
|
+
const [isUnconstrainedSelfSend, chosenStrategy] = await Promise.all([
|
|
220
|
+
this.#isUnconstrainedSelfSend(recipient, deliveryMode),
|
|
221
|
+
this.#chooseTaggingSecretStrategy(sender, recipient, deliveryMode),
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
// For unconstrained delivery, a self-send uses a local address-derived secret instead of a non-interactive
|
|
225
|
+
// handshake. A self-send is one where the wallet controls the recipient's keys, so both sides' keys are local: no
|
|
226
|
+
// handshake is needed and nothing is revealed onchain. It also avoids a recursion: a handshake self-delivers its
|
|
227
|
+
// note via unconstrained delivery, which would establish yet another handshake. This guard runs regardless of the
|
|
228
|
+
// resolved strategy (hook or default), to protect wallets from invalid configuration.
|
|
229
|
+
const strategy: TaggingSecretStrategy = isUnconstrainedSelfSend ? { type: 'address-derived' } : chosenStrategy;
|
|
230
|
+
|
|
231
|
+
return this.#resolveTaggingSecretStrategy(strategy, sender, recipient);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
async #chooseTaggingSecretStrategy(
|
|
235
|
+
sender: AztecAddress,
|
|
236
|
+
recipient: AztecAddress,
|
|
237
|
+
deliveryMode: AppTaggingSecretKind,
|
|
238
|
+
): Promise<TaggingSecretStrategy> {
|
|
199
239
|
const hook: ResolveTaggingSecretStrategy | undefined = this.hooks?.resolveTaggingSecretStrategy;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const { currentContractClassId } = await this.getContractInstance(this.contractAddress);
|
|
203
|
-
strategy = await hook({
|
|
204
|
-
contractAddress: this.contractAddress,
|
|
205
|
-
contractClassId: currentContractClassId,
|
|
206
|
-
sender,
|
|
207
|
-
recipient,
|
|
208
|
-
deliveryMode,
|
|
209
|
-
});
|
|
210
|
-
} else {
|
|
211
|
-
strategy = this.#defaultTaggingSecretStrategy(deliveryMode, recipient);
|
|
240
|
+
if (!hook) {
|
|
241
|
+
return DEFAULT_TAGGING_SECRET_STRATEGY;
|
|
212
242
|
}
|
|
213
|
-
|
|
243
|
+
|
|
244
|
+
const contractClassId = await this.#getCurrentContractClassId(this.contractAddress);
|
|
245
|
+
return hook({
|
|
246
|
+
contractAddress: this.contractAddress,
|
|
247
|
+
contractClassId,
|
|
248
|
+
sender,
|
|
249
|
+
recipient,
|
|
250
|
+
deliveryMode,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Resolves the class id the given contract runs at this simulation's anchor block. The instance no longer carries
|
|
256
|
+
* its class id (it is chain-derived), so it is resolved via the anchored contract data instead.
|
|
257
|
+
*/
|
|
258
|
+
async #getCurrentContractClassId(address: AztecAddress): Promise<Fr> {
|
|
259
|
+
const classId = await this.anchoredContractData.getCurrentClassId(address);
|
|
260
|
+
if (classId === undefined) {
|
|
261
|
+
throw new Error(`Cannot resolve the current contract class for ${address}`);
|
|
262
|
+
}
|
|
263
|
+
return classId;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Whether this is an unconstrained delivery to one of the wallet's own accounts (a self-send). */
|
|
267
|
+
#isUnconstrainedSelfSend(recipient: AztecAddress, deliveryMode: AppTaggingSecretKind) {
|
|
268
|
+
return deliveryMode === AppTaggingSecretKind.UNCONSTRAINED
|
|
269
|
+
? this.keyStore.hasAccount(recipient)
|
|
270
|
+
: Promise.resolve(false);
|
|
214
271
|
}
|
|
215
272
|
|
|
216
273
|
/** Resolves a wallet-provided {@link TaggingSecretStrategy} into the app-siloed secret handed to the contract. */
|
|
@@ -225,29 +282,22 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
225
282
|
switch (strategy.type) {
|
|
226
283
|
case 'non-interactive-handshake':
|
|
227
284
|
return { type: 'non-interactive-handshake' };
|
|
285
|
+
case 'interactive-handshake':
|
|
286
|
+
return { type: 'interactive-handshake' };
|
|
228
287
|
case 'address-derived':
|
|
229
288
|
return this.#addressDerivedSecret(sender, recipient);
|
|
230
289
|
case 'arbitrary-secret': {
|
|
231
290
|
// App-silo the raw arbitrary secret point here so wallets never replicate the derivation.
|
|
232
|
-
const appTaggingSecret = await AppTaggingSecret.
|
|
291
|
+
const appTaggingSecret = await AppTaggingSecret.computeDirectional(
|
|
292
|
+
strategy.secret,
|
|
293
|
+
this.contractAddress,
|
|
294
|
+
recipient,
|
|
295
|
+
);
|
|
233
296
|
return { type: 'unconstrained-secret', secret: appTaggingSecret.secret };
|
|
234
297
|
}
|
|
235
298
|
}
|
|
236
299
|
}
|
|
237
300
|
|
|
238
|
-
/** The privacy-safe tagging secret strategy used when no {@link ResolveTaggingSecretStrategy} hook is configured. */
|
|
239
|
-
#defaultTaggingSecretStrategy(deliveryMode: AppTaggingSecretKind, recipient: AztecAddress): TaggingSecretStrategy {
|
|
240
|
-
if (deliveryMode === AppTaggingSecretKind.CONSTRAINED) {
|
|
241
|
-
// Constrained delivery has no "safe" default: a non-interactive handshake would reveal the recipient onchain,
|
|
242
|
-
// and an interactive handshake always needs a wallet interaction (i.e. a configured hook). With no hook there is
|
|
243
|
-
// nothing safe to fall back to, so we always fail.
|
|
244
|
-
throw new Error(`Constrained delivery to ${recipient} requires a configured resolveTaggingSecretStrategy hook.`);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Unconstrained default: an address-derived (Diffie-Hellman) shared secret, which leaves no onchain trace.
|
|
248
|
-
return { type: 'address-derived' };
|
|
249
|
-
}
|
|
250
|
-
|
|
251
301
|
/**
|
|
252
302
|
* The app-siloed, recipient-directional secret derived from the sender's and recipient's address keys via ECDH,
|
|
253
303
|
* ready to hand to the contract. Callers must validate the recipient in-circuit before reaching here, so an invalid one is unexpected.
|
|
@@ -307,13 +357,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
307
357
|
async #calculateAppTaggingSecret(contractAddress: AztecAddress, sender: AztecAddress, recipient: AztecAddress) {
|
|
308
358
|
const senderCompleteAddress = await this.getCompleteAddressOrFail(sender);
|
|
309
359
|
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
|
|
310
|
-
return AppTaggingSecret.
|
|
311
|
-
senderCompleteAddress,
|
|
312
|
-
senderIvsk,
|
|
313
|
-
recipient,
|
|
314
|
-
contractAddress,
|
|
315
|
-
recipient,
|
|
316
|
-
);
|
|
360
|
+
return AppTaggingSecret.computeViaEcdh(senderCompleteAddress, senderIvsk, recipient, contractAddress, recipient);
|
|
317
361
|
}
|
|
318
362
|
|
|
319
363
|
async #getIndexToUseForSecret(secret: AppTaggingSecret): Promise<number> {
|
|
@@ -615,10 +659,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
615
659
|
this.scopes,
|
|
616
660
|
);
|
|
617
661
|
|
|
618
|
-
const targetArtifact = await this.
|
|
662
|
+
const targetArtifact = await this.anchoredContractData.getFunctionArtifactWithDebugMetadata(
|
|
619
663
|
targetContractAddress,
|
|
620
664
|
functionSelector,
|
|
621
665
|
);
|
|
666
|
+
if (!targetArtifact) {
|
|
667
|
+
throw new Error(
|
|
668
|
+
`Cannot call ${targetContractAddress}:${functionSelector}: the contract is not registered. ` +
|
|
669
|
+
`Register it via wallet.registerContract(...).`,
|
|
670
|
+
);
|
|
671
|
+
}
|
|
622
672
|
|
|
623
673
|
const derivedTxContext = this.txContext.clone();
|
|
624
674
|
|
|
@@ -627,6 +677,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
627
677
|
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
628
678
|
argsHash,
|
|
629
679
|
txContext: derivedTxContext,
|
|
680
|
+
txRequestSalt: this.txRequestSalt,
|
|
630
681
|
callContext: derivedCallContext,
|
|
631
682
|
anchorBlockHeader: this.anchorBlockHeader,
|
|
632
683
|
utilityExecutor: this.utilityExecutor,
|
|
@@ -635,7 +686,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
635
686
|
executionCache: this.executionCache,
|
|
636
687
|
noteCache: this.noteCache,
|
|
637
688
|
taggingIndexCache: this.taggingIndexCache,
|
|
638
|
-
|
|
689
|
+
anchoredContractData: this.anchoredContractData,
|
|
639
690
|
noteStore: this.noteStore,
|
|
640
691
|
keyStore: this.keyStore,
|
|
641
692
|
addressStore: this.addressStore,
|
|
@@ -739,7 +790,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
739
790
|
}
|
|
740
791
|
|
|
741
792
|
public getDebugFunctionName() {
|
|
742
|
-
return this.
|
|
793
|
+
return this.anchoredContractData.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
743
794
|
}
|
|
744
795
|
|
|
745
796
|
protected override get callerContext() {
|