@aztec/pxe 5.0.0-private.20260319 → 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/bin/check_oracle_version.js +45 -111
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +51 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +254 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +20 -14
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +78 -28
- package/dest/config/index.d.ts +8 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +19 -19
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +57 -32
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
- 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 -7
- package/dest/contract_function_simulator/index.d.ts +24 -6
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -4
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +30 -0
- 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/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -5
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -9
- package/dest/contract_function_simulator/noir-structs/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 +19 -10
- 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 +12 -24
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +5 -9
- 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 +2 -61
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -5
- 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 +8 -10
- package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +67 -0
- 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 +8 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +1 -0
- 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/acir_callback.d.ts +16 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/acir_callback.js +71 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -103
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- 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/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +135 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +976 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +183 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +1222 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +3 -4
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -42
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +147 -59
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +143 -71
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +485 -187
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +35 -64
- package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/transient_array_service.js +62 -0
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +11 -9
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +73 -51
- package/dest/contract_sync/helpers.d.ts +8 -9
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +23 -30
- package/dest/debug/pxe_debug_utils.d.ts +3 -8
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +0 -6
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +18 -5
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +18 -5
- package/dest/entrypoints/pxe_creation_options.d.ts +16 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +4 -3
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +20 -6
- package/dest/error_enriching.js +1 -1
- package/dest/events/event_service.d.ts +15 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +44 -11
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +51 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- 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 +12 -12
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +169 -81
- package/dest/messages/tx_resolver_service.d.ts +17 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/tx_resolver_service.js +55 -0
- package/dest/notes/note_service.d.ts +27 -6
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +80 -56
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +3 -4
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +152 -59
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -10
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +24 -22
- package/dest/pxe.d.ts +104 -27
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +229 -130
- 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/anchor_block_store/anchor_block_store.d.ts +9 -6
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -7
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +647 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +47 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +36 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +11 -28
- 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 +3 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -1
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +42 -33
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +199 -170
- package/dest/storage/note_store/stored_note.d.ts +3 -8
- package/dest/storage/note_store/stored_note.d.ts.map +1 -1
- package/dest/storage/note_store/stored_note.js +4 -20
- package/dest/storage/open_pxe_stores.d.ts +35 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +29 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +13 -16
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +43 -43
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- 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/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 +3 -3
- 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/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +36 -37
- package/dest/tagging/index.d.ts +5 -4
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +69 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +203 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
- 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 +2 -2
- package/package.json +20 -17
- package/src/bin/check_oracle_version.ts +51 -133
- package/src/bin/index.ts +5 -0
- package/src/bin/oracle_version_helpers.ts +311 -0
- package/src/block_synchronizer/block_stream_source.ts +42 -0
- package/src/block_synchronizer/block_synchronizer.ts +93 -38
- package/src/config/index.ts +15 -8
- package/src/contract_function_simulator/contract_function_simulator.ts +86 -48
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
- package/src/contract_function_simulator/index.ts +63 -5
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
- 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/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -7
- 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 +27 -20
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -61
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +6 -8
- package/src/contract_function_simulator/noir-structs/option.ts +75 -0
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
- 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/acir_callback.ts +108 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -15
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -176
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +681 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +947 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +3 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +182 -79
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +743 -295
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +41 -64
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +101 -87
- package/src/contract_sync/helpers.ts +24 -43
- package/src/debug/pxe_debug_utils.ts +3 -11
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +17 -5
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +17 -5
- package/src/entrypoints/pxe_creation_options.ts +21 -1
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +24 -7
- package/src/error_enriching.ts +1 -1
- package/src/events/event_service.ts +69 -21
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +57 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +46 -0
- package/src/logs/log_service.ts +204 -146
- package/src/messages/tx_resolver_service.ts +69 -0
- package/src/notes/note_service.ts +119 -85
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +1 -1
- package/src/private_kernel/hints/test_utils.ts +3 -10
- package/src/private_kernel/private_kernel_execution_prover.ts +240 -82
- package/src/private_kernel/private_kernel_oracle.ts +35 -25
- package/src/pxe.ts +369 -138
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -7
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +117 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +769 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +85 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +16 -37
- 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 +2 -1
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +228 -192
- package/src/storage/note_store/stored_note.ts +5 -27
- package/src/storage/open_pxe_stores.ts +52 -0
- package/src/storage/private_event_store/private_event_store.ts +52 -54
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/index.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
- package/src/storage/tagging_store/sender_tagging_store.ts +6 -6
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +117 -0
- package/src/tagging/get_all_logs_by_tags.ts +78 -50
- package/src/tagging/index.ts +4 -3
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +301 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -5
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -61
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -437
- package/dest/messages/message_context_service.d.ts +0 -17
- package/dest/messages/message_context_service.d.ts.map +0 -1
- package/dest/messages/message_context_service.js +0 -36
- 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/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
- package/src/access_scopes.ts +0 -9
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -135
- package/src/contract_function_simulator/oracle/oracle.ts +0 -675
- package/src/messages/message_context_service.ts +0 -45
- package/src/storage/tagging_store/sender_address_book_store.ts +0 -48
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -140
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
|
@@ -0,0 +1,1222 @@
|
|
|
1
|
+
import { CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH, L1_TO_L2_MSG_TREE_HEIGHT, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, PRIVATE_LOG_CIPHERTEXT_LEN, PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
7
|
+
import { fromUintArray } from '@aztec/simulator/client';
|
|
8
|
+
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
9
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
11
|
+
import { Tag, appTaggingSecretKindFromDeliveryMode } from '@aztec/stdlib/logs';
|
|
12
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
13
|
+
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
14
|
+
import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
|
|
15
|
+
import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
|
|
16
|
+
import { logSourceFromField } from '../noir-structs/log_retrieval_request.js';
|
|
17
|
+
import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
|
|
18
|
+
import { Option } from '../noir-structs/option.js';
|
|
19
|
+
import { resolvedTaggingStrategyFromFields, resolvedTaggingStrategyToFields } from '../noir-structs/resolved_tagging_strategy.js';
|
|
20
|
+
import { packAsHintedNote } from './note_packing_utils.js';
|
|
21
|
+
/**
|
|
22
|
+
* Asserts that every reader was fully consumed by a deserialization, throwing on leftover fields.
|
|
23
|
+
*/ export function assertReadersConsumed(readers) {
|
|
24
|
+
readers.forEach((reader, slot)=>{
|
|
25
|
+
if (!reader.isFinished()) {
|
|
26
|
+
throw new Error(`Malformed oracle input: ${reader.remainingFields()} unexpected trailing field(s) in slot ${slot}`);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// ─── Scalar Type Mappings ────────────────────────────────────────────────────
|
|
31
|
+
export const FIELD = {
|
|
32
|
+
serialization: {
|
|
33
|
+
fn: (v)=>[
|
|
34
|
+
v
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
deserialization: {
|
|
38
|
+
fn: ([reader])=>reader.readField()
|
|
39
|
+
},
|
|
40
|
+
shape: [
|
|
41
|
+
'scalar'
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
export const BOOL = {
|
|
45
|
+
serialization: {
|
|
46
|
+
fn: (v)=>[
|
|
47
|
+
new Fr(v ? 1n : 0n)
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
deserialization: {
|
|
51
|
+
fn: ([reader])=>!reader.readField().isZero()
|
|
52
|
+
},
|
|
53
|
+
shape: [
|
|
54
|
+
'scalar'
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
export const U32 = {
|
|
58
|
+
serialization: {
|
|
59
|
+
fn: (v)=>[
|
|
60
|
+
new Fr(v)
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
deserialization: {
|
|
64
|
+
fn: ([reader])=>{
|
|
65
|
+
const value = reader.readField().toBigInt();
|
|
66
|
+
if (value > 0xffffffffn) {
|
|
67
|
+
throw new Error(`U32 overflow: value ${value} exceeds u32 max (${0xffffffffn})`);
|
|
68
|
+
}
|
|
69
|
+
return Number(value);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
shape: [
|
|
73
|
+
'scalar'
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
export const BLOCK_NUMBER = {
|
|
77
|
+
serialization: {
|
|
78
|
+
fn: (v)=>[
|
|
79
|
+
new Fr(v)
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
deserialization: {
|
|
83
|
+
fn: ([reader])=>BlockNumber(reader.readField().toNumber())
|
|
84
|
+
},
|
|
85
|
+
shape: [
|
|
86
|
+
'scalar'
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
/** A u8 byte: serializes to a single Fr; deserializes from a single Fr to a number in [0, 255]. */ export const BYTE = {
|
|
90
|
+
serialization: {
|
|
91
|
+
fn: (byte)=>[
|
|
92
|
+
new Fr(byte)
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
deserialization: {
|
|
96
|
+
fn: ([reader])=>{
|
|
97
|
+
const value = reader.readField().toBigInt();
|
|
98
|
+
if (value > 0xffn) {
|
|
99
|
+
throw new Error(`BYTE overflow: value ${value} exceeds u8 max (255)`);
|
|
100
|
+
}
|
|
101
|
+
return Number(value);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
shape: [
|
|
105
|
+
'scalar'
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
// Noir passes `MessageDelivery` onchain variants here.
|
|
109
|
+
export const DELIVERY_MODE = {
|
|
110
|
+
deserialization: {
|
|
111
|
+
fn: (readers)=>appTaggingSecretKindFromDeliveryMode(BYTE.deserialization.fn(readers))
|
|
112
|
+
},
|
|
113
|
+
shape: BYTE.shape
|
|
114
|
+
};
|
|
115
|
+
export const RESOLVED_TAGGING_STRATEGY = {
|
|
116
|
+
serialization: {
|
|
117
|
+
fn: (resolved)=>resolvedTaggingStrategyToFields(resolved)
|
|
118
|
+
},
|
|
119
|
+
deserialization: {
|
|
120
|
+
fn: ([kindReader, secretReader])=>resolvedTaggingStrategyFromFields(kindReader.readField().toNumber(), secretReader.readField())
|
|
121
|
+
},
|
|
122
|
+
shape: [
|
|
123
|
+
'scalar',
|
|
124
|
+
'scalar'
|
|
125
|
+
]
|
|
126
|
+
};
|
|
127
|
+
export const BIGINT = {
|
|
128
|
+
serialization: {
|
|
129
|
+
fn: (v)=>[
|
|
130
|
+
new Fr(v)
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
deserialization: {
|
|
134
|
+
fn: ([reader])=>reader.readField().toBigInt()
|
|
135
|
+
},
|
|
136
|
+
shape: [
|
|
137
|
+
'scalar'
|
|
138
|
+
]
|
|
139
|
+
};
|
|
140
|
+
/** Reads every field in the slot as a UTF-8 character code. */ export const STR = {
|
|
141
|
+
serialization: {
|
|
142
|
+
fn: (str)=>[
|
|
143
|
+
Array.from(Buffer.from(str, 'utf-8')).map((b)=>new Fr(b))
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
deserialization: {
|
|
147
|
+
fn: ([reader])=>{
|
|
148
|
+
const chars = [];
|
|
149
|
+
while(!reader.isFinished()){
|
|
150
|
+
chars.push(String.fromCharCode(reader.readField().toNumber()));
|
|
151
|
+
}
|
|
152
|
+
return chars.join('');
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
shape: [
|
|
156
|
+
'variable'
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
export const AZTEC_ADDRESS = {
|
|
160
|
+
serialization: {
|
|
161
|
+
fn: (v)=>[
|
|
162
|
+
v.toField()
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
deserialization: {
|
|
166
|
+
fn: ([reader])=>AztecAddress.fromFieldUnsafe(reader.readField())
|
|
167
|
+
},
|
|
168
|
+
shape: [
|
|
169
|
+
'scalar'
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
export const BLOCK_HASH = {
|
|
173
|
+
serialization: {
|
|
174
|
+
fn: (v)=>[
|
|
175
|
+
new Fr(v.toBuffer())
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
deserialization: {
|
|
179
|
+
fn: ([reader])=>new BlockHash(reader.readField())
|
|
180
|
+
},
|
|
181
|
+
shape: [
|
|
182
|
+
'scalar'
|
|
183
|
+
]
|
|
184
|
+
};
|
|
185
|
+
export const FUNCTION_SELECTOR = {
|
|
186
|
+
serialization: {
|
|
187
|
+
fn: (v)=>[
|
|
188
|
+
v.toField()
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
deserialization: {
|
|
192
|
+
fn: ([reader])=>FunctionSelector.fromField(reader.readField())
|
|
193
|
+
},
|
|
194
|
+
shape: [
|
|
195
|
+
'scalar'
|
|
196
|
+
]
|
|
197
|
+
};
|
|
198
|
+
export const NOTE_SELECTOR = {
|
|
199
|
+
serialization: {
|
|
200
|
+
fn: (v)=>[
|
|
201
|
+
v.toField()
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
deserialization: {
|
|
205
|
+
fn: ([reader])=>NoteSelector.fromField(reader.readField())
|
|
206
|
+
},
|
|
207
|
+
shape: [
|
|
208
|
+
'scalar'
|
|
209
|
+
]
|
|
210
|
+
};
|
|
211
|
+
export const TX_HASH = {
|
|
212
|
+
serialization: {
|
|
213
|
+
fn: (v)=>[
|
|
214
|
+
v.hash
|
|
215
|
+
]
|
|
216
|
+
},
|
|
217
|
+
deserialization: {
|
|
218
|
+
fn: ([reader])=>TxHash.fromField(reader.readField())
|
|
219
|
+
},
|
|
220
|
+
shape: [
|
|
221
|
+
'scalar'
|
|
222
|
+
]
|
|
223
|
+
};
|
|
224
|
+
const TAG = {
|
|
225
|
+
serialization: {
|
|
226
|
+
fn: (v)=>[
|
|
227
|
+
v.value
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
deserialization: {
|
|
231
|
+
fn: ([reader])=>new Tag(reader.readField())
|
|
232
|
+
},
|
|
233
|
+
shape: [
|
|
234
|
+
'scalar'
|
|
235
|
+
]
|
|
236
|
+
};
|
|
237
|
+
export const POINT = STRUCT([
|
|
238
|
+
{
|
|
239
|
+
name: 'x',
|
|
240
|
+
type: FIELD
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: 'y',
|
|
244
|
+
type: FIELD
|
|
245
|
+
}
|
|
246
|
+
]);
|
|
247
|
+
const LOG_SOURCE = {
|
|
248
|
+
serialization: {
|
|
249
|
+
fn: (v)=>[
|
|
250
|
+
new Fr(v)
|
|
251
|
+
]
|
|
252
|
+
},
|
|
253
|
+
deserialization: {
|
|
254
|
+
fn: ([reader])=>logSourceFromField(reader.readField())
|
|
255
|
+
},
|
|
256
|
+
shape: [
|
|
257
|
+
'scalar'
|
|
258
|
+
]
|
|
259
|
+
};
|
|
260
|
+
export const ETH_ADDRESS = {
|
|
261
|
+
serialization: {
|
|
262
|
+
fn: (v)=>[
|
|
263
|
+
v.toField()
|
|
264
|
+
]
|
|
265
|
+
},
|
|
266
|
+
deserialization: {
|
|
267
|
+
fn: ([reader])=>EthAddress.fromField(reader.readField())
|
|
268
|
+
},
|
|
269
|
+
shape: [
|
|
270
|
+
'scalar'
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
const SLOT_NUMBER = {
|
|
274
|
+
serialization: {
|
|
275
|
+
fn: (v)=>[
|
|
276
|
+
new Fr(v)
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
shape: [
|
|
280
|
+
'scalar'
|
|
281
|
+
]
|
|
282
|
+
};
|
|
283
|
+
const APPEND_ONLY_TREE_SNAPSHOT = STRUCT([
|
|
284
|
+
{
|
|
285
|
+
name: 'root',
|
|
286
|
+
type: FIELD
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: 'nextAvailableLeafIndex',
|
|
290
|
+
type: U32
|
|
291
|
+
}
|
|
292
|
+
]);
|
|
293
|
+
const PARTIAL_STATE_REFERENCE = STRUCT([
|
|
294
|
+
{
|
|
295
|
+
name: 'noteHashTree',
|
|
296
|
+
type: APPEND_ONLY_TREE_SNAPSHOT
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
name: 'nullifierTree',
|
|
300
|
+
type: APPEND_ONLY_TREE_SNAPSHOT
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: 'publicDataTree',
|
|
304
|
+
type: APPEND_ONLY_TREE_SNAPSHOT
|
|
305
|
+
}
|
|
306
|
+
]);
|
|
307
|
+
const STATE_REFERENCE = STRUCT([
|
|
308
|
+
{
|
|
309
|
+
name: 'l1ToL2MessageTree',
|
|
310
|
+
type: APPEND_ONLY_TREE_SNAPSHOT
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'partial',
|
|
314
|
+
type: PARTIAL_STATE_REFERENCE
|
|
315
|
+
}
|
|
316
|
+
]);
|
|
317
|
+
const GAS_FEES = STRUCT([
|
|
318
|
+
{
|
|
319
|
+
name: 'feePerDaGas',
|
|
320
|
+
type: BIGINT
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: 'feePerL2Gas',
|
|
324
|
+
type: BIGINT
|
|
325
|
+
}
|
|
326
|
+
]);
|
|
327
|
+
const GLOBAL_VARIABLES = STRUCT([
|
|
328
|
+
{
|
|
329
|
+
name: 'chainId',
|
|
330
|
+
type: FIELD
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'version',
|
|
334
|
+
type: FIELD
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: 'blockNumber',
|
|
338
|
+
type: BLOCK_NUMBER
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: 'slotNumber',
|
|
342
|
+
type: SLOT_NUMBER
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: 'timestamp',
|
|
346
|
+
type: BIGINT
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'coinbase',
|
|
350
|
+
type: ETH_ADDRESS
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: 'feeRecipient',
|
|
354
|
+
type: AZTEC_ADDRESS
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: 'gasFees',
|
|
358
|
+
type: GAS_FEES
|
|
359
|
+
}
|
|
360
|
+
]);
|
|
361
|
+
export const BLOCK_HEADER = STRUCT([
|
|
362
|
+
{
|
|
363
|
+
name: 'lastArchive',
|
|
364
|
+
type: APPEND_ONLY_TREE_SNAPSHOT
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: 'state',
|
|
368
|
+
type: STATE_REFERENCE
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: 'spongeBlobHash',
|
|
372
|
+
type: FIELD
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: 'globalVariables',
|
|
376
|
+
type: GLOBAL_VARIABLES
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: 'totalFees',
|
|
380
|
+
type: FIELD
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
name: 'totalManaUsed',
|
|
384
|
+
type: FIELD
|
|
385
|
+
}
|
|
386
|
+
]);
|
|
387
|
+
export const KEY_VALIDATION_REQUEST = STRUCT([
|
|
388
|
+
{
|
|
389
|
+
name: 'pkMHash',
|
|
390
|
+
type: FIELD
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: 'skApp',
|
|
394
|
+
type: FIELD
|
|
395
|
+
}
|
|
396
|
+
]);
|
|
397
|
+
const PUBLIC_KEYS = STRUCT([
|
|
398
|
+
{
|
|
399
|
+
name: 'npkMHash',
|
|
400
|
+
type: FIELD
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: 'ivpkM',
|
|
404
|
+
type: POINT
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: 'ovpkMHash',
|
|
408
|
+
type: FIELD
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: 'tpkMHash',
|
|
412
|
+
type: FIELD
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: 'mspkMHash',
|
|
416
|
+
type: FIELD
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: 'fbpkMHash',
|
|
420
|
+
type: FIELD
|
|
421
|
+
}
|
|
422
|
+
]);
|
|
423
|
+
export const CONTRACT_INSTANCE = STRUCT([
|
|
424
|
+
{
|
|
425
|
+
name: 'salt',
|
|
426
|
+
type: FIELD
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: 'deployer',
|
|
430
|
+
type: AZTEC_ADDRESS
|
|
431
|
+
},
|
|
432
|
+
// Note that the nr side of this struct does not contain the current class, only original
|
|
433
|
+
{
|
|
434
|
+
name: 'originalContractClassId',
|
|
435
|
+
type: FIELD
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
name: 'initializationHash',
|
|
439
|
+
type: FIELD
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: 'immutablesHash',
|
|
443
|
+
type: FIELD
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
name: 'publicKeys',
|
|
447
|
+
type: PUBLIC_KEYS
|
|
448
|
+
}
|
|
449
|
+
]);
|
|
450
|
+
const NULLIFIER_LEAF = STRUCT([
|
|
451
|
+
{
|
|
452
|
+
name: 'nullifier',
|
|
453
|
+
type: FIELD
|
|
454
|
+
}
|
|
455
|
+
]);
|
|
456
|
+
const NULLIFIER_LEAF_PREIMAGE = STRUCT([
|
|
457
|
+
{
|
|
458
|
+
name: 'leaf',
|
|
459
|
+
type: NULLIFIER_LEAF
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: 'nextKey',
|
|
463
|
+
type: FIELD
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: 'nextIndex',
|
|
467
|
+
type: BIGINT
|
|
468
|
+
}
|
|
469
|
+
]);
|
|
470
|
+
export const NULLIFIER_MEMBERSHIP_WITNESS = STRUCT([
|
|
471
|
+
{
|
|
472
|
+
name: 'leafPreimage',
|
|
473
|
+
type: NULLIFIER_LEAF_PREIMAGE
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: 'index',
|
|
477
|
+
type: BIGINT
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
name: 'siblingPath',
|
|
481
|
+
type: SIBLING_PATH(NULLIFIER_TREE_HEIGHT)
|
|
482
|
+
}
|
|
483
|
+
]);
|
|
484
|
+
const PUBLIC_DATA_LEAF = STRUCT([
|
|
485
|
+
{
|
|
486
|
+
name: 'slot',
|
|
487
|
+
type: FIELD
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: 'value',
|
|
491
|
+
type: FIELD
|
|
492
|
+
}
|
|
493
|
+
]);
|
|
494
|
+
const PUBLIC_DATA_LEAF_PREIMAGE = STRUCT([
|
|
495
|
+
{
|
|
496
|
+
name: 'leaf',
|
|
497
|
+
type: PUBLIC_DATA_LEAF
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
name: 'nextKey',
|
|
501
|
+
type: FIELD
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: 'nextIndex',
|
|
505
|
+
type: BIGINT
|
|
506
|
+
}
|
|
507
|
+
]);
|
|
508
|
+
export const PUBLIC_DATA_WITNESS = STRUCT([
|
|
509
|
+
{
|
|
510
|
+
name: 'index',
|
|
511
|
+
type: BIGINT
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: 'leafPreimage',
|
|
515
|
+
type: PUBLIC_DATA_LEAF_PREIMAGE
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
name: 'siblingPath',
|
|
519
|
+
type: SIBLING_PATH(PUBLIC_DATA_TREE_HEIGHT)
|
|
520
|
+
}
|
|
521
|
+
]);
|
|
522
|
+
export const MESSAGE_LOAD_ORACLE_INPUTS = STRUCT([
|
|
523
|
+
{
|
|
524
|
+
name: 'index',
|
|
525
|
+
type: BIGINT
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
name: 'siblingPath',
|
|
529
|
+
type: SIBLING_PATH(L1_TO_L2_MSG_TREE_HEIGHT)
|
|
530
|
+
}
|
|
531
|
+
]);
|
|
532
|
+
export const UTILITY_CONTEXT = STRUCT([
|
|
533
|
+
{
|
|
534
|
+
name: 'blockHeader',
|
|
535
|
+
type: BLOCK_HEADER
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: 'contractAddress',
|
|
539
|
+
type: AZTEC_ADDRESS
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
name: 'msgSender',
|
|
543
|
+
type: AZTEC_ADDRESS
|
|
544
|
+
}
|
|
545
|
+
]);
|
|
546
|
+
export const CALL_PRIVATE_RESULT = STRUCT([
|
|
547
|
+
{
|
|
548
|
+
name: 'endSideEffectCounter',
|
|
549
|
+
type: FIELD
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: 'returnsHash',
|
|
553
|
+
type: FIELD
|
|
554
|
+
}
|
|
555
|
+
]);
|
|
556
|
+
export const PUBLIC_KEYS_AND_PARTIAL_ADDRESS = STRUCT([
|
|
557
|
+
{
|
|
558
|
+
name: 'publicKeys',
|
|
559
|
+
type: PUBLIC_KEYS
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: 'partialAddress',
|
|
563
|
+
type: FIELD
|
|
564
|
+
}
|
|
565
|
+
]);
|
|
566
|
+
export const CONTRACT_CLASS_LOG = STRUCT([
|
|
567
|
+
{
|
|
568
|
+
name: 'contractAddress',
|
|
569
|
+
type: AZTEC_ADDRESS
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
name: 'fields',
|
|
573
|
+
type: FIXED_ARRAY(FIELD, CONTRACT_CLASS_LOG_SIZE_IN_FIELDS)
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: 'emittedLength',
|
|
577
|
+
type: U32
|
|
578
|
+
}
|
|
579
|
+
]);
|
|
580
|
+
const REVERT_CODE = {
|
|
581
|
+
serialization: {
|
|
582
|
+
fn: (rc)=>[
|
|
583
|
+
rc.toField()
|
|
584
|
+
]
|
|
585
|
+
},
|
|
586
|
+
shape: [
|
|
587
|
+
'scalar'
|
|
588
|
+
]
|
|
589
|
+
};
|
|
590
|
+
const PUBLIC_DATA_WRITE = STRUCT([
|
|
591
|
+
{
|
|
592
|
+
name: 'leafSlot',
|
|
593
|
+
type: FIELD
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: 'value',
|
|
597
|
+
type: FIELD
|
|
598
|
+
}
|
|
599
|
+
]);
|
|
600
|
+
const PRIVATE_LOG = STRUCT([
|
|
601
|
+
{
|
|
602
|
+
name: 'fields',
|
|
603
|
+
type: FIXED_ARRAY(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS)
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: 'emittedLength',
|
|
607
|
+
type: U32
|
|
608
|
+
}
|
|
609
|
+
]);
|
|
610
|
+
const FLAT_PUBLIC_LOGS = STRUCT([
|
|
611
|
+
{
|
|
612
|
+
name: 'length',
|
|
613
|
+
type: U32
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
name: 'payload',
|
|
617
|
+
type: FIXED_ARRAY(FIELD, FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH)
|
|
618
|
+
}
|
|
619
|
+
]);
|
|
620
|
+
const CONTRACT_CLASS_LOG_ENTRY = STRUCT([
|
|
621
|
+
{
|
|
622
|
+
name: 'fields',
|
|
623
|
+
type: FIXED_ARRAY(FIELD, CONTRACT_CLASS_LOG_SIZE_IN_FIELDS)
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
name: 'emittedLength',
|
|
627
|
+
type: U32
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
name: 'contractAddress',
|
|
631
|
+
type: AZTEC_ADDRESS
|
|
632
|
+
}
|
|
633
|
+
]);
|
|
634
|
+
const CONTRACT_CLASS_LOGS = FIXED_ARRAY(CONTRACT_CLASS_LOG_ENTRY, MAX_CONTRACT_CLASS_LOGS_PER_TX);
|
|
635
|
+
export const TX_EFFECT = STRUCT([
|
|
636
|
+
{
|
|
637
|
+
name: 'revertCode',
|
|
638
|
+
type: REVERT_CODE
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: 'txHash',
|
|
642
|
+
type: TX_HASH
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
name: 'transactionFee',
|
|
646
|
+
type: FIELD
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
name: 'noteHashes',
|
|
650
|
+
type: FIXED_ARRAY(FIELD, MAX_NOTE_HASHES_PER_TX)
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
name: 'nullifiers',
|
|
654
|
+
type: FIXED_ARRAY(FIELD, MAX_NULLIFIERS_PER_TX)
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: 'l2ToL1Msgs',
|
|
658
|
+
type: FIXED_ARRAY(FIELD, MAX_L2_TO_L1_MSGS_PER_TX)
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: 'publicDataWrites',
|
|
662
|
+
type: FIXED_ARRAY(PUBLIC_DATA_WRITE, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX)
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
name: 'privateLogs',
|
|
666
|
+
type: FIXED_ARRAY(PRIVATE_LOG, MAX_PRIVATE_LOGS_PER_TX)
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
name: 'publicLogs',
|
|
670
|
+
type: FLAT_PUBLIC_LOGS
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
name: 'contractClassLogs',
|
|
674
|
+
type: CONTRACT_CLASS_LOGS
|
|
675
|
+
}
|
|
676
|
+
]);
|
|
677
|
+
export const NOTE = {
|
|
678
|
+
serialization: {
|
|
679
|
+
fn: (noteData)=>packAsHintedNote({
|
|
680
|
+
contractAddress: noteData.contractAddress,
|
|
681
|
+
owner: noteData.owner,
|
|
682
|
+
randomness: noteData.randomness,
|
|
683
|
+
storageSlot: noteData.storageSlot,
|
|
684
|
+
noteNonce: noteData.noteNonce,
|
|
685
|
+
isPending: noteData.isPending,
|
|
686
|
+
note: noteData.note
|
|
687
|
+
})
|
|
688
|
+
},
|
|
689
|
+
// A packed note is the note's (variable-count) field items followed by 6 metadata scalars, emitted as one field
|
|
690
|
+
// output per element. Its length depends on the note, so it is described as a single variable-width run.
|
|
691
|
+
shape: [
|
|
692
|
+
'variable'
|
|
693
|
+
]
|
|
694
|
+
};
|
|
695
|
+
export const NOTE_VALIDATION_REQUEST = {
|
|
696
|
+
deserialization: {
|
|
697
|
+
fn: ([reader])=>NoteValidationRequest.fromFields(reader)
|
|
698
|
+
},
|
|
699
|
+
shape: [
|
|
700
|
+
'variable'
|
|
701
|
+
]
|
|
702
|
+
};
|
|
703
|
+
export const EVENT_VALIDATION_REQUEST = {
|
|
704
|
+
deserialization: {
|
|
705
|
+
fn: ([reader])=>EventValidationRequest.fromFields(reader)
|
|
706
|
+
},
|
|
707
|
+
shape: [
|
|
708
|
+
'variable'
|
|
709
|
+
]
|
|
710
|
+
};
|
|
711
|
+
export const LOG_RETRIEVAL_REQUEST = STRUCT([
|
|
712
|
+
{
|
|
713
|
+
name: 'contractAddress',
|
|
714
|
+
type: AZTEC_ADDRESS
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
name: 'tag',
|
|
718
|
+
type: TAG
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
name: 'source',
|
|
722
|
+
type: LOG_SOURCE
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
name: 'fromBlock',
|
|
726
|
+
type: OPTION(BLOCK_NUMBER)
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'toBlock',
|
|
730
|
+
type: OPTION(BLOCK_NUMBER)
|
|
731
|
+
}
|
|
732
|
+
]);
|
|
733
|
+
export const LOG_RETRIEVAL_RESPONSE = STRUCT([
|
|
734
|
+
{
|
|
735
|
+
name: 'logPayload',
|
|
736
|
+
type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_CIPHERTEXT_LEN)
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: 'txHash',
|
|
740
|
+
type: TX_HASH
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
name: 'uniqueNoteHashesInTx',
|
|
744
|
+
type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX)
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: 'firstNullifierInTx',
|
|
748
|
+
type: FIELD
|
|
749
|
+
}
|
|
750
|
+
]);
|
|
751
|
+
export const MESSAGE_CONTEXT = STRUCT([
|
|
752
|
+
{
|
|
753
|
+
name: 'txHash',
|
|
754
|
+
type: TX_HASH
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
name: 'uniqueNoteHashesInTx',
|
|
758
|
+
type: FIXED_BOUNDED_VEC(FIELD, MAX_NOTE_HASHES_PER_TX)
|
|
759
|
+
},
|
|
760
|
+
{
|
|
761
|
+
name: 'firstNullifierInTx',
|
|
762
|
+
type: FIELD
|
|
763
|
+
}
|
|
764
|
+
]);
|
|
765
|
+
export const PENDING_TAGGED_LOG = STRUCT([
|
|
766
|
+
{
|
|
767
|
+
name: 'log',
|
|
768
|
+
type: FIXED_BOUNDED_VEC(FIELD, PRIVATE_LOG_SIZE_IN_FIELDS)
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
name: 'context',
|
|
772
|
+
type: MESSAGE_CONTEXT
|
|
773
|
+
}
|
|
774
|
+
]);
|
|
775
|
+
// `ResolvedTx.toFields()` packs the whole struct into a single slot: txHash, the uniqueNoteHashesInTx BoundedVec
|
|
776
|
+
// (MAX_NOTE_HASHES_PER_TX storage fields + length), firstNullifierInTx, blockNumber and blockHash.
|
|
777
|
+
export const RESOLVED_TX = {
|
|
778
|
+
serialization: {
|
|
779
|
+
fn: (resolved)=>[
|
|
780
|
+
resolved.toFields()
|
|
781
|
+
]
|
|
782
|
+
},
|
|
783
|
+
shape: [
|
|
784
|
+
{
|
|
785
|
+
len: MAX_NOTE_HASHES_PER_TX + 5
|
|
786
|
+
}
|
|
787
|
+
]
|
|
788
|
+
};
|
|
789
|
+
export const ORIGIN_BLOCK = {
|
|
790
|
+
serialization: {
|
|
791
|
+
fn: (ob)=>[
|
|
792
|
+
new Fr(ob.blockNumber),
|
|
793
|
+
ob.blockHash
|
|
794
|
+
]
|
|
795
|
+
},
|
|
796
|
+
deserialization: {
|
|
797
|
+
fn: ([blockNumberReader, blockHashReader])=>({
|
|
798
|
+
blockNumber: blockNumberReader.readField().toNumber(),
|
|
799
|
+
blockHash: blockHashReader.readField()
|
|
800
|
+
})
|
|
801
|
+
},
|
|
802
|
+
shape: [
|
|
803
|
+
'scalar',
|
|
804
|
+
'scalar'
|
|
805
|
+
]
|
|
806
|
+
};
|
|
807
|
+
// `facts` and `payload` each materialize to a single service-slot id, so a Fact occupies: factTypeId, the payload
|
|
808
|
+
// array slot, and `OPTION(ORIGIN_BLOCK)` (its discriminant plus ORIGIN_BLOCK's two slots).
|
|
809
|
+
export const FACT = {
|
|
810
|
+
serialization: {
|
|
811
|
+
fn: (f)=>[
|
|
812
|
+
f.factTypeId,
|
|
813
|
+
f.payload.materializeSlot((v)=>FIELD.serialization.fn(v).flat()),
|
|
814
|
+
...OPTION(ORIGIN_BLOCK).serialization.fn(f.originBlock)
|
|
815
|
+
]
|
|
816
|
+
},
|
|
817
|
+
shape: [
|
|
818
|
+
'scalar',
|
|
819
|
+
'scalar',
|
|
820
|
+
'scalar',
|
|
821
|
+
'scalar',
|
|
822
|
+
'scalar'
|
|
823
|
+
]
|
|
824
|
+
};
|
|
825
|
+
export const FACT_COLLECTION = {
|
|
826
|
+
serialization: {
|
|
827
|
+
fn: (c)=>[
|
|
828
|
+
c.contractAddress.toField(),
|
|
829
|
+
c.scope.toField(),
|
|
830
|
+
c.factCollectionTypeId,
|
|
831
|
+
c.factCollectionId,
|
|
832
|
+
c.facts.materializeSlot((v)=>FACT.serialization.fn(v).flat())
|
|
833
|
+
]
|
|
834
|
+
},
|
|
835
|
+
shape: [
|
|
836
|
+
'scalar',
|
|
837
|
+
'scalar',
|
|
838
|
+
'scalar',
|
|
839
|
+
'scalar',
|
|
840
|
+
'scalar'
|
|
841
|
+
]
|
|
842
|
+
};
|
|
843
|
+
export const PROVIDED_SECRET = {
|
|
844
|
+
deserialization: {
|
|
845
|
+
fn: ([reader])=>({
|
|
846
|
+
secret: reader.readField(),
|
|
847
|
+
mode: appTaggingSecretKindFromDeliveryMode(BYTE.deserialization.fn([
|
|
848
|
+
reader
|
|
849
|
+
]))
|
|
850
|
+
})
|
|
851
|
+
},
|
|
852
|
+
shape: [
|
|
853
|
+
{
|
|
854
|
+
len: 2
|
|
855
|
+
}
|
|
856
|
+
]
|
|
857
|
+
};
|
|
858
|
+
// ─── Combinator Type Mappings ────────────────────────────────────────────────
|
|
859
|
+
function SIBLING_PATH(height) {
|
|
860
|
+
return {
|
|
861
|
+
serialization: {
|
|
862
|
+
fn: (sp)=>[
|
|
863
|
+
sp.toFields()
|
|
864
|
+
]
|
|
865
|
+
},
|
|
866
|
+
shape: [
|
|
867
|
+
{
|
|
868
|
+
len: height
|
|
869
|
+
}
|
|
870
|
+
]
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
export function MEMBERSHIP_WITNESS(height) {
|
|
874
|
+
return STRUCT([
|
|
875
|
+
{
|
|
876
|
+
name: 'leafIndex',
|
|
877
|
+
type: BIGINT
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
name: 'siblingPath',
|
|
881
|
+
type: FIXED_ARRAY(FIELD, height)
|
|
882
|
+
}
|
|
883
|
+
]);
|
|
884
|
+
}
|
|
885
|
+
export function ARRAY(inner) {
|
|
886
|
+
return {
|
|
887
|
+
kind: 'array',
|
|
888
|
+
inner,
|
|
889
|
+
serialization: inner.serialization ? {
|
|
890
|
+
fn: (values)=>[
|
|
891
|
+
packElements(inner, values)
|
|
892
|
+
]
|
|
893
|
+
} : undefined,
|
|
894
|
+
deserialization: inner.deserialization ? {
|
|
895
|
+
// The whole slot is the array, so read as many elements as its fields hold.
|
|
896
|
+
fn: ([reader])=>unpackElements(inner, reader, reader.remainingFields() / fieldWidth(inner.shape))
|
|
897
|
+
} : undefined,
|
|
898
|
+
// One slot of variable length (all elements flattened into it).
|
|
899
|
+
shape: [
|
|
900
|
+
{
|
|
901
|
+
lenFrom: (size)=>size.length * fieldWidth(inner.shape)
|
|
902
|
+
}
|
|
903
|
+
]
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Noir's fixed-length array `[T; maxLength]` in one slot: serializes `values` (each flattened via `element`)
|
|
908
|
+
* zero-padded to exactly `maxLength * elementWidth` fields, and deserializes all `maxLength` elements back. An absent
|
|
909
|
+
* element is the zero encoding, so the padding is derived from the shape.
|
|
910
|
+
*/ function FIXED_ARRAY(element, maxLength) {
|
|
911
|
+
const elementWidth = fieldWidth(element.shape);
|
|
912
|
+
return {
|
|
913
|
+
serialization: element.serialization ? {
|
|
914
|
+
fn: (values)=>[
|
|
915
|
+
padArrayEnd(packElements(element, values), Fr.ZERO, maxLength * elementWidth)
|
|
916
|
+
]
|
|
917
|
+
} : undefined,
|
|
918
|
+
deserialization: element.deserialization ? {
|
|
919
|
+
fn: ([reader])=>unpackElements(element, reader, maxLength)
|
|
920
|
+
} : undefined,
|
|
921
|
+
shape: [
|
|
922
|
+
{
|
|
923
|
+
len: maxLength * elementWidth
|
|
924
|
+
}
|
|
925
|
+
]
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Maps Noir's `BoundedVec<T, MaxLen>` ↔ TS `BoundedVec<T>` over 2 slots:
|
|
930
|
+
* slot 0 — flat storage, padded/parsed as `maxLength * elementSize` fields
|
|
931
|
+
* slot 1 — length scalar (count of actual items)
|
|
932
|
+
*
|
|
933
|
+
* Both directions are derived from `element`: bidirectional iff `element` has both serialization and deserialization.
|
|
934
|
+
*
|
|
935
|
+
* @example Serializing `BoundedVec.from({ data: [0x41, 0x42], maxLength: 4 })` with `BOUNDED_VEC(BYTE)`:
|
|
936
|
+
* ```
|
|
937
|
+
* slot 0: [Fr(0x41), Fr(0x42), Fr(0), Fr(0)] // data padded to maxLength
|
|
938
|
+
* slot 1: Fr(2) // actual length
|
|
939
|
+
* ```
|
|
940
|
+
*/ export function BOUNDED_VEC(inner) {
|
|
941
|
+
return {
|
|
942
|
+
kind: 'bounded-vec',
|
|
943
|
+
inner,
|
|
944
|
+
serialization: inner.serialization ? {
|
|
945
|
+
fn: (bv)=>{
|
|
946
|
+
if (bv.data.length > bv.maxLength) {
|
|
947
|
+
throw new Error(`Got ${bv.data.length} items, but maxLength is ${bv.maxLength}`);
|
|
948
|
+
}
|
|
949
|
+
// Fixed-width elements take their width from the shape (consistent with deserialization); only a
|
|
950
|
+
// variable-width element (e.g. a packed note) falls back to the runtime `elementSize` the value carries.
|
|
951
|
+
const elementWidth = tryFieldWidth(inner.shape) ?? bv.elementSize;
|
|
952
|
+
const flat = padArrayEnd(packElements(inner, bv.data), Fr.ZERO, bv.maxLength * elementWidth);
|
|
953
|
+
return [
|
|
954
|
+
flat,
|
|
955
|
+
new Fr(bv.data.length)
|
|
956
|
+
];
|
|
957
|
+
}
|
|
958
|
+
} : undefined,
|
|
959
|
+
deserialization: inner.deserialization ? {
|
|
960
|
+
fn: ([storageReader, lengthReader])=>{
|
|
961
|
+
// slot 0 is the padded storage, slot 1 the actual length. Parse only the first `length` elements out of
|
|
962
|
+
// storage, then drain the trailing zero-padding so the storage reader is fully consumed.
|
|
963
|
+
const maxLength = storageReader.remainingFields() / fieldWidth(inner.shape);
|
|
964
|
+
const length = lengthReader.readField().toNumber();
|
|
965
|
+
const elements = unpackElements(inner, storageReader, length);
|
|
966
|
+
storageReader.skip(storageReader.remainingFields());
|
|
967
|
+
return BoundedVec.from({
|
|
968
|
+
data: elements,
|
|
969
|
+
maxLength
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
} : undefined,
|
|
973
|
+
// slot 0: variable-length storage; slot 1: the length scalar.
|
|
974
|
+
shape: [
|
|
975
|
+
{
|
|
976
|
+
lenFrom: (size)=>size.maxLength * fieldWidth(inner.shape)
|
|
977
|
+
},
|
|
978
|
+
'scalar'
|
|
979
|
+
]
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Noir's `BoundedVec<T, MaxLen>` in its padded form (one fixed-width slot): `maxLength * elementWidth` storage fields
|
|
984
|
+
* (zero-padded) followed by the actual length, with no length prefix, so the width is statically known. Serialize-only.
|
|
985
|
+
* Throws if the input exceeds `maxLength`.
|
|
986
|
+
*/ function FIXED_BOUNDED_VEC(element, maxLength) {
|
|
987
|
+
const width = fieldWidth(element.shape);
|
|
988
|
+
return {
|
|
989
|
+
serialization: element.serialization ? {
|
|
990
|
+
fn: (values)=>{
|
|
991
|
+
if (values.length > maxLength) {
|
|
992
|
+
throw new Error(`Got ${values.length} items, but maxLength is ${maxLength}`);
|
|
993
|
+
}
|
|
994
|
+
const flat = padArrayEnd(packElements(element, values), Fr.ZERO, maxLength * width);
|
|
995
|
+
return [
|
|
996
|
+
[
|
|
997
|
+
...flat,
|
|
998
|
+
new Fr(values.length)
|
|
999
|
+
]
|
|
1000
|
+
];
|
|
1001
|
+
}
|
|
1002
|
+
} : undefined,
|
|
1003
|
+
shape: [
|
|
1004
|
+
{
|
|
1005
|
+
len: maxLength * width + 1
|
|
1006
|
+
}
|
|
1007
|
+
]
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Wraps an inner TypeMapping in Noir-style `Option<T>`, adding a leading discriminant slot.
|
|
1012
|
+
*
|
|
1013
|
+
* For the `None` case, the inner's slots must still be present on the wire as zero-padding (so `Some` and `None` have
|
|
1014
|
+
* identical size). That padding is derived entirely from `inner.shape`.
|
|
1015
|
+
*
|
|
1016
|
+
* @example Serializing `Option.some(AztecAddress.fromFieldUnsafe(Fr(42)))` with `OPTION(AZTEC_ADDRESS)`:
|
|
1017
|
+
* ```
|
|
1018
|
+
* slot 0: Fr(1) // discriminant: Some
|
|
1019
|
+
* slot 1: Fr(42) // inner value
|
|
1020
|
+
* ```
|
|
1021
|
+
*
|
|
1022
|
+
* @example Serializing `Option.none()` with `OPTION(AZTEC_ADDRESS)`:
|
|
1023
|
+
* ```
|
|
1024
|
+
* slot 0: Fr(0) // discriminant: None
|
|
1025
|
+
* slot 1: Fr(0) // zero-filled from AZTEC_ADDRESS.shape
|
|
1026
|
+
* ```
|
|
1027
|
+
*/ export function OPTION(inner) {
|
|
1028
|
+
return {
|
|
1029
|
+
kind: 'option',
|
|
1030
|
+
inner,
|
|
1031
|
+
serialization: inner.serialization ? {
|
|
1032
|
+
fn: (opt)=>opt.isSome() ? [
|
|
1033
|
+
Fr.ONE,
|
|
1034
|
+
...inner.serialization.fn(opt.value)
|
|
1035
|
+
] : [
|
|
1036
|
+
Fr.ZERO,
|
|
1037
|
+
...zeroSlotsFromShape(inner.shape, opt.size)
|
|
1038
|
+
]
|
|
1039
|
+
} : undefined,
|
|
1040
|
+
deserialization: inner.deserialization ? {
|
|
1041
|
+
fn: ([discriminant, ...innerReaders])=>{
|
|
1042
|
+
if (discriminant.readField().isZero()) {
|
|
1043
|
+
// None still carries the inner's zero-padded slots; consume them without parsing, since an inner that
|
|
1044
|
+
// validates its fields would reject the zeros.
|
|
1045
|
+
innerReaders.forEach((reader)=>reader.skip(reader.remainingFields()));
|
|
1046
|
+
return Option.none();
|
|
1047
|
+
}
|
|
1048
|
+
return Option.some(inner.deserialization.fn(innerReaders));
|
|
1049
|
+
}
|
|
1050
|
+
} : undefined,
|
|
1051
|
+
// A leading discriminant slot followed by the inner's slots.
|
|
1052
|
+
shape: [
|
|
1053
|
+
'scalar',
|
|
1054
|
+
...inner.shape
|
|
1055
|
+
]
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* A fixed packed uint buffer (Noir `[u8; length]` at `bitSize` 8): one slot of `length` packed uint values ↔ `Buffer`.
|
|
1060
|
+
* `length` is the field count, which equals the byte count at `bitSize` 8.
|
|
1061
|
+
*/ export function BUFFER(bitSize, length) {
|
|
1062
|
+
return {
|
|
1063
|
+
serialization: {
|
|
1064
|
+
fn: (buf)=>[
|
|
1065
|
+
Array.from(buf).map((b)=>new Fr(b))
|
|
1066
|
+
]
|
|
1067
|
+
},
|
|
1068
|
+
deserialization: {
|
|
1069
|
+
fn: ([reader])=>fromUintArray(reader.readFieldArray(length).map((f)=>f.toString()), bitSize)
|
|
1070
|
+
},
|
|
1071
|
+
shape: [
|
|
1072
|
+
{
|
|
1073
|
+
len: length
|
|
1074
|
+
}
|
|
1075
|
+
]
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
export function EPHEMERAL_ARRAY(element) {
|
|
1079
|
+
// EphemeralArray.readAll hands each row's flat fields in as a single reader; reconstruct the element's per-slot
|
|
1080
|
+
// readers from its shape, deserialize, and assert the row was fully consumed so a row with trailing fields is
|
|
1081
|
+
// rejected.
|
|
1082
|
+
const rowElement = element.deserialization ? {
|
|
1083
|
+
deserialization: {
|
|
1084
|
+
fn: ([rowReader])=>deserializeElement(element, rowReader.readFieldArray(rowReader.remainingFields()))
|
|
1085
|
+
},
|
|
1086
|
+
// `fn` reads the whole row from one reader, so this is one variable-width slot, not the element's multi-slot
|
|
1087
|
+
// shape.
|
|
1088
|
+
shape: [
|
|
1089
|
+
'variable'
|
|
1090
|
+
]
|
|
1091
|
+
} : undefined;
|
|
1092
|
+
return {
|
|
1093
|
+
serialization: element.serialization ? {
|
|
1094
|
+
fn: (ea)=>[
|
|
1095
|
+
ea.materializeSlot((v)=>serializeElement(element, v))
|
|
1096
|
+
]
|
|
1097
|
+
} : undefined,
|
|
1098
|
+
deserialization: rowElement ? {
|
|
1099
|
+
fn: ([reader])=>EphemeralArray.fromSlot(reader.readField(), rowElement)
|
|
1100
|
+
} : undefined,
|
|
1101
|
+
// A single slot carrying the array's service-slot id.
|
|
1102
|
+
shape: [
|
|
1103
|
+
'scalar'
|
|
1104
|
+
]
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* A Noir struct: its `shape` and (de)serialization are the concatenation of its fields', so callers never hand-write a
|
|
1109
|
+
* `shape`. `T` is the struct's TS value type and must match the field layout — serialization reads each field by name
|
|
1110
|
+
* off the value, deserialization returns the decoded bag as `T`; convert in the handler, not here, when `T` differs.
|
|
1111
|
+
*/ function STRUCT(fields) {
|
|
1112
|
+
return {
|
|
1113
|
+
serialization: fields.every((f)=>f.type.serialization) ? {
|
|
1114
|
+
fn: (value)=>{
|
|
1115
|
+
const props = value;
|
|
1116
|
+
return fields.flatMap((f)=>f.type.serialization.fn(props[f.name]));
|
|
1117
|
+
}
|
|
1118
|
+
} : undefined,
|
|
1119
|
+
deserialization: fields.every((f)=>f.type.deserialization) ? {
|
|
1120
|
+
fn: (readers)=>{
|
|
1121
|
+
const props = {};
|
|
1122
|
+
let slot = 0;
|
|
1123
|
+
for (const f of fields){
|
|
1124
|
+
const slotCount = f.type.shape.length;
|
|
1125
|
+
props[f.name] = f.type.deserialization.fn(readers.slice(slot, slot + slotCount));
|
|
1126
|
+
slot += slotCount;
|
|
1127
|
+
}
|
|
1128
|
+
return props;
|
|
1129
|
+
}
|
|
1130
|
+
} : undefined,
|
|
1131
|
+
shape: fields.flatMap((f)=>f.type.shape)
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
/** Number of InputSlots a deserializable type spans, derived from its {@link TypeMapping.shape}. */ export function slotsOf(mapping) {
|
|
1135
|
+
return mapping.shape.length;
|
|
1136
|
+
}
|
|
1137
|
+
/** Number of fields a fully-static shape occupies, or `undefined` if any slot is variable-width. */ function tryFieldWidth(shape) {
|
|
1138
|
+
let total = 0;
|
|
1139
|
+
for (const slot of shape){
|
|
1140
|
+
if (slot === 'scalar') {
|
|
1141
|
+
total += 1;
|
|
1142
|
+
} else if (typeof slot === 'object' && 'len' in slot) {
|
|
1143
|
+
total += slot.len;
|
|
1144
|
+
} else {
|
|
1145
|
+
return undefined;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return total;
|
|
1149
|
+
}
|
|
1150
|
+
/** Number of fields a fully-static shape occupies. Throws on a variable-width shape, whose field count isn't known. */ function fieldWidth(shape) {
|
|
1151
|
+
const width = tryFieldWidth(shape);
|
|
1152
|
+
if (width === undefined) {
|
|
1153
|
+
throw new Error('Cannot compute a fixed field width for a variable-width shape');
|
|
1154
|
+
}
|
|
1155
|
+
return width;
|
|
1156
|
+
}
|
|
1157
|
+
/** Reconstructs a value's per-slot readers from a flat run of fields, using its shape (inverse of slot-flattening). */ function splitByShape(fields, shape) {
|
|
1158
|
+
const readers = [];
|
|
1159
|
+
let cursor = 0;
|
|
1160
|
+
shape.forEach((slot, i)=>{
|
|
1161
|
+
if (slot === 'scalar' || typeof slot === 'object' && 'len' in slot) {
|
|
1162
|
+
const width = slot === 'scalar' ? 1 : slot.len;
|
|
1163
|
+
if (cursor + width > fields.length) {
|
|
1164
|
+
throw new Error(`Not enough fields to reconstruct shape: needed ${width}, had ${fields.length - cursor}`);
|
|
1165
|
+
}
|
|
1166
|
+
readers.push(new FieldReader(fields.slice(cursor, cursor + width)));
|
|
1167
|
+
cursor += width;
|
|
1168
|
+
} else {
|
|
1169
|
+
// A variable slot (sized or not) takes whatever remains, so it must be last.
|
|
1170
|
+
if (i !== shape.length - 1) {
|
|
1171
|
+
throw new Error('A variable-width slot must be last to be reconstructed from a flat field array');
|
|
1172
|
+
}
|
|
1173
|
+
readers.push(new FieldReader(fields.slice(cursor)));
|
|
1174
|
+
cursor = fields.length;
|
|
1175
|
+
}
|
|
1176
|
+
});
|
|
1177
|
+
if (cursor !== fields.length) {
|
|
1178
|
+
throw new Error(`Malformed flattened value: ${fields.length - cursor} unexpected trailing field(s)`);
|
|
1179
|
+
}
|
|
1180
|
+
return readers;
|
|
1181
|
+
}
|
|
1182
|
+
/** Serializes one element to its flat fields. Element must be serializable. */ function serializeElement(element, value) {
|
|
1183
|
+
return element.serialization.fn(value).flat();
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Deserializes one element from its exact flat fields, reconstructing its per-slot readers from its shape and asserting
|
|
1187
|
+
* they are fully consumed (so trailing fields are rejected). Element must be deserializable.
|
|
1188
|
+
*/ function deserializeElement(element, fields) {
|
|
1189
|
+
const readers = splitByShape(fields, element.shape);
|
|
1190
|
+
const value = element.deserialization.fn(readers);
|
|
1191
|
+
assertReadersConsumed(readers);
|
|
1192
|
+
return value;
|
|
1193
|
+
}
|
|
1194
|
+
/** Flattens `values` into one contiguous run of fields by serializing each element. Element must be serializable. */ function packElements(element, values) {
|
|
1195
|
+
return values.flatMap((v)=>serializeElement(element, v));
|
|
1196
|
+
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Reads `count` fixed-width elements out of a packed run (the inverse of {@link packElements}). Element must be
|
|
1199
|
+
* deserializable.
|
|
1200
|
+
*/ function unpackElements(element, reader, count) {
|
|
1201
|
+
const elementWidth = fieldWidth(element.shape);
|
|
1202
|
+
return Array.from({
|
|
1203
|
+
length: count
|
|
1204
|
+
}, ()=>deserializeElement(element, reader.readFieldArray(elementWidth)));
|
|
1205
|
+
}
|
|
1206
|
+
/** Builds the zero-filled slots for a `None`, matching a `Some`'s wire shape (variable slots sized from `size`). */ function zeroSlotsFromShape(shape, size) {
|
|
1207
|
+
return shape.map((slot)=>{
|
|
1208
|
+
if (slot === 'scalar') {
|
|
1209
|
+
return Fr.ZERO;
|
|
1210
|
+
}
|
|
1211
|
+
if (slot === 'variable') {
|
|
1212
|
+
throw new Error('Cannot zero-fill an unsized variable-width slot');
|
|
1213
|
+
}
|
|
1214
|
+
if ('len' in slot) {
|
|
1215
|
+
return Array(slot.len).fill(Fr.ZERO);
|
|
1216
|
+
}
|
|
1217
|
+
if (size === undefined) {
|
|
1218
|
+
throw new Error('Serializing Option.none() over a variable-size inner needs a size, e.g. Option.none({ length: n })');
|
|
1219
|
+
}
|
|
1220
|
+
return Array(slot.lenFrom(size)).fill(Fr.ZERO);
|
|
1221
|
+
});
|
|
1222
|
+
}
|