@aztec/pxe 0.0.1-commit.fffb133c → 0.0.1-dev
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 +5 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -6
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -31
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +214 -75
- 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_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
- 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 +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- 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 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- 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 +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +66 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +78 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +363 -114
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -86
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +123 -98
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +145 -70
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +435 -145
- 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 +3 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +45 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +150 -0
- package/dest/contract_sync/helpers.d.ts +27 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +16 -17
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -18
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- 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 +24 -9
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +25 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +8 -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 +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +31 -11
- package/dest/events/event_service.d.ts +16 -8
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +46 -14
- 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 +37 -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 +42 -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/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +10 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +50 -85
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +38 -0
- package/dest/notes/note_service.d.ts +29 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +89 -65
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- 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/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -19
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +26 -20
- package/dest/pxe.d.ts +87 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +178 -119
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- 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 -2
- 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 +588 -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 +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +42 -36
- 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 +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -73
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +147 -107
- package/dest/storage/open_pxe_stores.d.ts +31 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +26 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +87 -61
- package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
- package/dest/storage/private_event_store/stored_private_event.js +2 -2
- 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/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
- package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +20 -3
- package/dest/tagging/index.d.ts +6 -5
- 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 +56 -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 +158 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- 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 +5 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +30 -13
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
- 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 +41 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -8
- 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 +36 -24
- package/package.json +26 -16
- package/src/bin/check_oracle_version.ts +5 -5
- package/src/block_synchronizer/block_synchronizer.ts +45 -21
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +389 -134
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +101 -62
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +464 -151
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +152 -191
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +709 -200
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +208 -0
- package/src/contract_sync/{index.ts → helpers.ts} +17 -29
- package/src/debug/pxe_debug_utils.ts +63 -19
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +19 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +20 -18
- package/src/entrypoints/pxe_creation_options.ts +13 -1
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +25 -29
- package/src/events/event_service.ts +70 -24
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +40 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +88 -141
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +124 -91
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +53 -22
- package/src/private_kernel/private_kernel_oracle.ts +36 -26
- package/src/pxe.ts +351 -168
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
- 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__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +42 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -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__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +707 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +52 -34
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -81
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +166 -132
- package/src/storage/open_pxe_stores.ts +47 -0
- package/src/storage/private_event_store/private_event_store.ts +106 -81
- package/src/storage/private_event_store/stored_private_event.ts +3 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
- package/src/tagging/get_all_logs_by_tags.ts +35 -7
- package/src/tagging/index.ts +5 -4
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +236 -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 +54 -18
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +30 -29
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
- 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 -15
- 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 -32
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_CALL, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_CALL, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_CALL, MAX_PRIVATE_LOGS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
5
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { ClaimedLengthArray, KeyValidationRequest, KeyValidationRequestAndSeparator, NoteHash, Nullifier, PrivateCircuitPublicInputs, PrivateKernelCircuitPublicInputs, ReadRequest, ScopedKeyValidationRequestAndSeparator, ScopedNoteHash, ScopedNullifier, ScopedReadRequest } from '@aztec/stdlib/kernel';
|
|
7
|
+
import { PrivateLogData, ScopedPrivateLogData } from '@aztec/stdlib/kernel';
|
|
8
|
+
import { PrivateLog } from '@aztec/stdlib/logs';
|
|
9
|
+
import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
10
|
+
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
11
|
+
const DEFAULT_CONTRACT_ADDRESS = AztecAddress.fromBigInt(987654n);
|
|
12
|
+
/**
|
|
13
|
+
* Builds a ClaimedLengthArray from a list of items, padding to the required size.
|
|
14
|
+
*/ function makeClaimed(items, emptyFactory, maxSize) {
|
|
15
|
+
const padded = makeTuple(maxSize, (i)=>items[i] ?? emptyFactory.empty());
|
|
16
|
+
return new ClaimedLengthArray(padded, items.length);
|
|
17
|
+
}
|
|
18
|
+
/** Builder for PrivateKernelCircuitPublicInputs with fluent API for adding side effects. */ export class PrivateKernelCircuitPublicInputsBuilder {
|
|
19
|
+
contractAddress;
|
|
20
|
+
noteHashes;
|
|
21
|
+
nullifiers;
|
|
22
|
+
noteHashReadRequests;
|
|
23
|
+
nullifierReadRequests;
|
|
24
|
+
keyValidationRequests;
|
|
25
|
+
privateLogs;
|
|
26
|
+
nextCounter;
|
|
27
|
+
constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
|
|
28
|
+
this.contractAddress = contractAddress;
|
|
29
|
+
this.noteHashes = [];
|
|
30
|
+
this.nullifiers = [];
|
|
31
|
+
this.noteHashReadRequests = [];
|
|
32
|
+
this.nullifierReadRequests = [];
|
|
33
|
+
this.keyValidationRequests = [];
|
|
34
|
+
this.privateLogs = [];
|
|
35
|
+
this.nextCounter = startCounter;
|
|
36
|
+
}
|
|
37
|
+
getCounter(sideEffectCounter) {
|
|
38
|
+
if (sideEffectCounter !== undefined) {
|
|
39
|
+
this.nextCounter = sideEffectCounter + 1;
|
|
40
|
+
return sideEffectCounter;
|
|
41
|
+
}
|
|
42
|
+
return this.nextCounter++;
|
|
43
|
+
}
|
|
44
|
+
/** Adds a note hash to the accumulated data. Defaults are generated randomly. */ addNoteHash(opts) {
|
|
45
|
+
const value = opts?.value ?? Fr.random();
|
|
46
|
+
const counter = this.getCounter(opts?.counter);
|
|
47
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
48
|
+
this.noteHashes.push(new NoteHash(value, counter).scope(addr));
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
/** Adds a nullifier to the accumulated data. Defaults are generated randomly. */ addNullifier(opts) {
|
|
52
|
+
const value = opts?.value ?? Fr.random();
|
|
53
|
+
const noteHash = opts?.noteHash ?? Fr.ZERO;
|
|
54
|
+
const counter = this.getCounter(opts?.counter);
|
|
55
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
56
|
+
this.nullifiers.push(new Nullifier(value, noteHash, counter).scope(addr));
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
|
|
60
|
+
const value = opts?.value ?? Fr.random();
|
|
61
|
+
const counter = this.getCounter(opts?.counter);
|
|
62
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
63
|
+
this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
/** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
|
|
67
|
+
const value = opts?.value ?? Fr.random();
|
|
68
|
+
const counter = this.getCounter(opts?.counter);
|
|
69
|
+
this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
|
|
73
|
+
const value = opts?.value ?? Fr.random();
|
|
74
|
+
const counter = this.getCounter(opts?.counter);
|
|
75
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
76
|
+
this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), addr));
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
|
|
80
|
+
const value = opts?.value ?? Fr.random();
|
|
81
|
+
const counter = this.getCounter(opts?.counter);
|
|
82
|
+
this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/** Adds a key validation request to validation requests. */ addKeyValidationRequest(opts) {
|
|
86
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
87
|
+
this.keyValidationRequests.push(new ScopedKeyValidationRequestAndSeparator(new KeyValidationRequestAndSeparator(new KeyValidationRequest(new Point(Fr.random(), Fr.random(), false), Fr.random()), Fr.random()), addr));
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/** Adds a private log to the accumulated data. Defaults are generated randomly. */ addPrivateLog(opts) {
|
|
91
|
+
const noteHashCounter = opts?.noteHashCounter ?? 0;
|
|
92
|
+
const counter = this.getCounter(opts?.counter);
|
|
93
|
+
const addr = opts?.contractAddress ?? this.contractAddress;
|
|
94
|
+
this.privateLogs.push(new ScopedPrivateLogData(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter), addr));
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/** Builds the PrivateKernelCircuitPublicInputs with all added side effects. */ build() {
|
|
98
|
+
const publicInputs = PrivateKernelCircuitPublicInputs.empty();
|
|
99
|
+
publicInputs.end.noteHashes = makeClaimed(this.noteHashes, ScopedNoteHash, MAX_NOTE_HASHES_PER_TX);
|
|
100
|
+
publicInputs.end.nullifiers = makeClaimed(this.nullifiers, ScopedNullifier, MAX_NULLIFIERS_PER_TX);
|
|
101
|
+
publicInputs.end.privateLogs = makeClaimed(this.privateLogs, ScopedPrivateLogData, MAX_PRIVATE_LOGS_PER_TX);
|
|
102
|
+
publicInputs.validationRequests.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
103
|
+
publicInputs.validationRequests.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
104
|
+
publicInputs.validationRequests.scopedKeyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, ScopedKeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_TX);
|
|
105
|
+
return publicInputs;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Builder for PrivateCircuitPublicInputs (call-level) with fluent API for adding side effects. */ export class PrivateCircuitPublicInputsBuilder {
|
|
109
|
+
contractAddress;
|
|
110
|
+
noteHashes;
|
|
111
|
+
nullifiers;
|
|
112
|
+
noteHashReadRequests;
|
|
113
|
+
nullifierReadRequests;
|
|
114
|
+
keyValidationRequests;
|
|
115
|
+
privateLogs;
|
|
116
|
+
nextCounter;
|
|
117
|
+
constructor(contractAddress = DEFAULT_CONTRACT_ADDRESS, startCounter = 1){
|
|
118
|
+
this.contractAddress = contractAddress;
|
|
119
|
+
this.noteHashes = [];
|
|
120
|
+
this.nullifiers = [];
|
|
121
|
+
this.noteHashReadRequests = [];
|
|
122
|
+
this.nullifierReadRequests = [];
|
|
123
|
+
this.keyValidationRequests = [];
|
|
124
|
+
this.privateLogs = [];
|
|
125
|
+
this.nextCounter = startCounter;
|
|
126
|
+
}
|
|
127
|
+
getCounter(sideEffectCounter) {
|
|
128
|
+
if (sideEffectCounter !== undefined) {
|
|
129
|
+
this.nextCounter = sideEffectCounter + 1;
|
|
130
|
+
return sideEffectCounter;
|
|
131
|
+
}
|
|
132
|
+
return this.nextCounter++;
|
|
133
|
+
}
|
|
134
|
+
/** Adds a note hash. Defaults are generated randomly. */ addNoteHash(opts) {
|
|
135
|
+
const value = opts?.value ?? Fr.random();
|
|
136
|
+
const counter = this.getCounter(opts?.counter);
|
|
137
|
+
this.noteHashes.push(new NoteHash(value, counter));
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
/** Adds a nullifier. Defaults are generated randomly. */ addNullifier(opts) {
|
|
141
|
+
const value = opts?.value ?? Fr.random();
|
|
142
|
+
const noteHash = opts?.noteHash ?? Fr.ZERO;
|
|
143
|
+
const counter = this.getCounter(opts?.counter);
|
|
144
|
+
this.nullifiers.push(new Nullifier(value, noteHash, counter));
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
/** Adds a pending note hash read request (non-empty contract address, can match a pending note hash). */ addPendingNoteHashReadRequest(opts) {
|
|
148
|
+
const value = opts?.value ?? Fr.random();
|
|
149
|
+
const counter = this.getCounter(opts?.counter);
|
|
150
|
+
this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
/** Adds a settled note hash read request (empty contract address, resolved against the note hash tree). */ addSettledNoteHashReadRequest(opts) {
|
|
154
|
+
const value = opts?.value ?? Fr.random();
|
|
155
|
+
const counter = this.getCounter(opts?.counter);
|
|
156
|
+
this.noteHashReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
/** Adds a pending nullifier read request (non-empty contract address, can match a pending nullifier). */ addPendingNullifierReadRequest(opts) {
|
|
160
|
+
const value = opts?.value ?? Fr.random();
|
|
161
|
+
const counter = this.getCounter(opts?.counter);
|
|
162
|
+
this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), this.contractAddress));
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
/** Adds a settled nullifier read request (empty contract address, resolved against the nullifier tree). */ addSettledNullifierReadRequest(opts) {
|
|
166
|
+
const value = opts?.value ?? Fr.random();
|
|
167
|
+
const counter = this.getCounter(opts?.counter);
|
|
168
|
+
this.nullifierReadRequests.push(new ScopedReadRequest(new ReadRequest(value, counter), AztecAddress.ZERO));
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
/** Adds a key validation request. */ addKeyValidationRequest() {
|
|
172
|
+
this.keyValidationRequests.push(new KeyValidationRequestAndSeparator(new KeyValidationRequest(new Point(Fr.random(), Fr.random(), false), Fr.random()), Fr.random()));
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
/** Adds a private log. Defaults are generated randomly. */ addPrivateLog(opts) {
|
|
176
|
+
const noteHashCounter = opts?.noteHashCounter ?? 0;
|
|
177
|
+
const counter = this.getCounter(opts?.counter);
|
|
178
|
+
this.privateLogs.push(new PrivateLogData(PrivateLog.empty(), noteHashCounter, counter));
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
/** Builds the PrivateCircuitPublicInputs with all added side effects. */ build() {
|
|
182
|
+
const publicInputs = PrivateCircuitPublicInputs.empty();
|
|
183
|
+
publicInputs.callContext.contractAddress = this.contractAddress;
|
|
184
|
+
publicInputs.noteHashes = makeClaimed(this.noteHashes, NoteHash, MAX_NOTE_HASHES_PER_CALL);
|
|
185
|
+
publicInputs.nullifiers = makeClaimed(this.nullifiers, Nullifier, MAX_NULLIFIERS_PER_CALL);
|
|
186
|
+
publicInputs.privateLogs = makeClaimed(this.privateLogs, PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL);
|
|
187
|
+
publicInputs.noteHashReadRequests = makeClaimed(this.noteHashReadRequests, ScopedReadRequest, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL);
|
|
188
|
+
publicInputs.nullifierReadRequests = makeClaimed(this.nullifierReadRequests, ScopedReadRequest, MAX_NULLIFIER_READ_REQUESTS_PER_CALL);
|
|
189
|
+
publicInputs.keyValidationRequestsAndSeparators = makeClaimed(this.keyValidationRequests, KeyValidationRequestAndSeparator, MAX_KEY_VALIDATION_REQUESTS_PER_CALL);
|
|
190
|
+
return publicInputs;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/** Wraps a PrivateKernelCircuitPublicInputs in a PrivateKernelSimulateOutput. */ export function makeKernelOutput(publicInputs) {
|
|
194
|
+
return {
|
|
195
|
+
publicInputs: publicInputs ?? PrivateKernelCircuitPublicInputs.empty(),
|
|
196
|
+
verificationKey: VerificationKeyData.empty(),
|
|
197
|
+
outputWitness: new Map(),
|
|
198
|
+
bytecode: Buffer.from([])
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** Wraps a PrivateCircuitPublicInputs in a PrivateCallExecutionResult. */ export function makeExecutionResult(publicInputs) {
|
|
202
|
+
return new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs ?? PrivateCircuitPublicInputs.empty(), [], new Map(), [], [], [], [], []);
|
|
203
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
2
3
|
import { type PrivateKernelExecutionProofOutput, type PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
4
|
import { type PrivateExecutionResult, TxRequest } from '@aztec/stdlib/tx';
|
|
@@ -18,7 +19,7 @@ export declare class PrivateKernelExecutionProver {
|
|
|
18
19
|
private proofCreator;
|
|
19
20
|
private fakeProofs;
|
|
20
21
|
private log;
|
|
21
|
-
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean);
|
|
22
|
+
constructor(oracle: PrivateKernelOracle, proofCreator: PrivateKernelProver, fakeProofs?: boolean, bindings?: LoggerBindings);
|
|
22
23
|
/**
|
|
23
24
|
* Generate a proof for a given transaction request and execution result.
|
|
24
25
|
* The function iterates through the nested executions in the execution result, creates private call data,
|
|
@@ -39,6 +40,7 @@ export declare class PrivateKernelExecutionProver {
|
|
|
39
40
|
*/
|
|
40
41
|
private ensurePublicInputsMatch;
|
|
41
42
|
private getVkData;
|
|
43
|
+
private prefetchUpdatedClassIdHints;
|
|
42
44
|
private createPrivateCallData;
|
|
43
45
|
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfZXhlY3V0aW9uX3Byb3Zlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL3ByaXZhdGVfa2VybmVsX2V4ZWN1dGlvbl9wcm92ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFlLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBTXZGLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDM0UsT0FBTyxFQVFMLEtBQUssaUNBQWlDLEVBS3RDLEtBQUssb0NBQW9DLEVBRzFDLE1BQU0sc0JBQXNCLENBQUM7QUFFOUIsT0FBTyxFQUVMLEtBQUssc0JBQXNCLEVBQzNCLFNBQVMsRUFJVixNQUFNLGtCQUFrQixDQUFDO0FBSzFCLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sNEJBQTRCLENBQUM7QUFTdEUsTUFBTSxXQUFXLGtDQUFrQztJQUNqRCxRQUFRLEVBQUUsT0FBTyxDQUFDO0lBQ2xCLGtCQUFrQixFQUFFLE9BQU8sQ0FBQztJQUM1QixXQUFXLEVBQUUsT0FBTyxHQUFHLGlCQUFpQixHQUFHLE1BQU0sR0FBRyxNQUFNLENBQUM7Q0FDNUQ7QUFFRDs7Ozs7R0FLRztBQUNILHFCQUFhLDRCQUE0QjtJQUlyQyxPQUFPLENBQUMsTUFBTTtJQUNkLE9BQU8sQ0FBQyxZQUFZO0lBQ3BCLE9BQU8sQ0FBQyxVQUFVO0lBTHBCLE9BQU8sQ0FBQyxHQUFHLENBQVM7SUFFcEIsWUFDVSxNQUFNLEVBQUUsbUJBQW1CLEVBQzNCLFlBQVksRUFBRSxtQkFBbUIsRUFDakMsVUFBVSxVQUFRLEVBQzFCLFFBQVEsQ0FBQyxFQUFFLGNBQWMsRUFHMUI7SUFFRDs7Ozs7Ozs7OztPQVVHO0lBQ0csZ0JBQWdCLENBQ3BCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGVBQWUsRUFBRSxzQkFBc0IsRUFDdkMsRUFBRSxRQUFRLEVBQUUsa0JBQWtCLEVBQUUsV0FBVyxFQUFFLEdBQUUsa0NBSTlDLEdBQ0EsT0FBTyxDQUFDLGlDQUFpQyxDQUFDLG9DQUFvQyxDQUFDLENBQUMsQ0F1UmxGO0lBRUQ7Ozs7O09BS0c7SUFDSCxPQUFPLENBQUMsdUJBQXVCO1lBb0JqQixTQUFTO1lBVVQsMkJBQTJCO1lBaUIzQixxQkFBcUI7Q0FrQ3BDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private_kernel_execution_prover.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_execution_prover.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAMvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAQL,KAAK,iCAAiC,EAKtC,KAAK,oCAAoC,EAG1C,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,KAAK,sBAAsB,EAC3B,SAAS,EAIV,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAStE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5D;AAED;;;;;GAKG;AACH,qBAAa,4BAA4B;IAIrC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,UAAU;IALpB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,mBAAmB,EACjC,UAAU,UAAQ,EAC1B,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAED;;;;;;;;;;OAUG;IACG,gBAAgB,CACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,sBAAsB,EACvC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,GAAE,kCAI9C,GACA,OAAO,CAAC,iCAAiC,CAAC,oCAAoC,CAAC,CAAC,CAuRlF;IAED;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;YAoBjB,SAAS;YAUT,2BAA2B;YAiB3B,qBAAqB;CAkCpC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { uniqueBy } from '@aztec/foundation/collection';
|
|
1
2
|
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
|
|
2
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -8,8 +9,9 @@ import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
|
8
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
10
|
import { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PaddedSideEffectAmounts, PrivateCallData, PrivateKernelCircuitPublicInputs, PrivateKernelData, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelTailCircuitPrivateInputs, PrivateVerificationKeyHints } from '@aztec/stdlib/kernel';
|
|
10
11
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
11
|
-
import { collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
12
|
+
import { collectNested, collectNoteHashNullifierCounterMap, getFinalMinRevertibleSideEffectCounter } from '@aztec/stdlib/tx';
|
|
12
13
|
import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
|
|
14
|
+
import { computeTxExpirationTimestamp } from './hints/compute_tx_expiration_timestamp.js';
|
|
13
15
|
import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
|
|
14
16
|
const NULL_SIMULATE_OUTPUT = {
|
|
15
17
|
publicInputs: PrivateKernelCircuitPublicInputs.empty(),
|
|
@@ -27,11 +29,11 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
27
29
|
proofCreator;
|
|
28
30
|
fakeProofs;
|
|
29
31
|
log;
|
|
30
|
-
constructor(oracle, proofCreator, fakeProofs = false){
|
|
32
|
+
constructor(oracle, proofCreator, fakeProofs = false, bindings){
|
|
31
33
|
this.oracle = oracle;
|
|
32
34
|
this.proofCreator = proofCreator;
|
|
33
35
|
this.fakeProofs = fakeProofs;
|
|
34
|
-
this.log = createLogger('pxe:private-kernel-execution-prover');
|
|
36
|
+
this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Generate a proof for a given transaction request and execution result.
|
|
@@ -63,10 +65,12 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
63
65
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
64
66
|
const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
|
|
65
67
|
const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
|
|
68
|
+
const updatedClassIdHintsMap = await this.prefetchUpdatedClassIdHints(executionResult);
|
|
66
69
|
while(executionStack.length){
|
|
67
70
|
if (!firstIteration) {
|
|
68
71
|
let resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, executionStack, noteHashNullifierCounterMap, splitCounter);
|
|
69
72
|
while(resetBuilder.needsReset()){
|
|
73
|
+
// Inner reset: without siloing.
|
|
70
74
|
const witgenTimer = new Timer();
|
|
71
75
|
const privateInputs = await resetBuilder.build(this.oracle);
|
|
72
76
|
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
@@ -97,7 +101,7 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
97
101
|
oracles: currentExecution.profileResult?.timings.oracles
|
|
98
102
|
}
|
|
99
103
|
});
|
|
100
|
-
const privateCallData = await this.createPrivateCallData(currentExecution);
|
|
104
|
+
const privateCallData = await this.createPrivateCallData(currentExecution, updatedClassIdHintsMap);
|
|
101
105
|
if (firstIteration) {
|
|
102
106
|
const witgenTimer = new Timer();
|
|
103
107
|
const proofInput = new PrivateKernelInitCircuitPrivateInputs(txRequest, getVKTreeRoot(), ProtocolContractsList, privateCallData, isPrivateOnlyTx, executionResult.firstNullifier, minRevertibleSideEffectCounter);
|
|
@@ -132,11 +136,19 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
132
136
|
}
|
|
133
137
|
firstIteration = false;
|
|
134
138
|
}
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
// Final reset: include siloing of note hashes, nullifiers and private logs.
|
|
140
|
+
const finalResetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
141
|
+
if (!finalResetBuilder.needsReset()) {
|
|
142
|
+
// The final reset must be performed exactly once, because each tx has at least one nullifier that requires
|
|
143
|
+
// siloing, and siloing cannot be done multiple times.
|
|
144
|
+
// While, in theory, it might be possible to silo note hashes first and then run another reset to silo nullifiers
|
|
145
|
+
// and/or private logs, we currently don't have standalone dimensions for the arrays that require siloing. As a
|
|
146
|
+
// result, all necessary siloing must be done together in a single reset.
|
|
147
|
+
// Refer to the possible combinations of dimensions in private_kernel_reset_config.json.
|
|
148
|
+
throw new Error('Nothing to reset for the final reset.');
|
|
149
|
+
} else {
|
|
138
150
|
const witgenTimer = new Timer();
|
|
139
|
-
const privateInputs = await
|
|
151
|
+
const privateInputs = await finalResetBuilder.build(this.oracle);
|
|
140
152
|
output = generateWitnesses ? await this.proofCreator.generateResetOutput(privateInputs) : await this.proofCreator.simulateReset(privateInputs);
|
|
141
153
|
executionSteps.push({
|
|
142
154
|
functionName: 'private_kernel_reset',
|
|
@@ -147,7 +159,6 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
147
159
|
witgen: witgenTimer.ms()
|
|
148
160
|
}
|
|
149
161
|
});
|
|
150
|
-
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
|
|
151
162
|
}
|
|
152
163
|
if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
|
|
153
164
|
if (!skipProofGeneration) {
|
|
@@ -161,14 +172,10 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
161
172
|
this.log.debug(`Calling private kernel tail with hwm ${previousKernelData.publicInputs.minRevertibleSideEffectCounter}`);
|
|
162
173
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
163
174
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
if (includeByTimestampUpperBound <= anchorBlockTimestamp) {
|
|
169
|
-
throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestampUpperBound}.`);
|
|
170
|
-
}
|
|
171
|
-
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, includeByTimestampUpperBound);
|
|
175
|
+
// Round the aggregated expirationTimestamp down to reduce precision and avoid leaking which private
|
|
176
|
+
// functions were called via their exact expiration offsets.
|
|
177
|
+
const expirationTimestampUpperBound = computeTxExpirationTimestamp(previousKernelData.publicInputs);
|
|
178
|
+
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData, paddedSideEffectAmounts, expirationTimestampUpperBound);
|
|
172
179
|
const witgenTimer = new Timer();
|
|
173
180
|
const tailOutput = generateWitnesses ? await this.proofCreator.generateTailOutput(privateInputs) : await this.proofCreator.simulateTail(privateInputs);
|
|
174
181
|
executionSteps.push({
|
|
@@ -261,14 +268,26 @@ const NULL_SIMULATE_OUTPUT = {
|
|
|
261
268
|
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(verificationKey.keyAsFields);
|
|
262
269
|
return new VkData(verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
263
270
|
}
|
|
264
|
-
|
|
271
|
+
/** Prefetches updated class id hints for all unique contracts in the execution tree in parallel. */ async prefetchUpdatedClassIdHints(executionResult) {
|
|
272
|
+
const allAddresses = collectNested([
|
|
273
|
+
executionResult.entrypoint
|
|
274
|
+
], (exec)=>[
|
|
275
|
+
exec.publicInputs.callContext.contractAddress
|
|
276
|
+
]);
|
|
277
|
+
const uniqueAddresses = uniqueBy(allAddresses, (a)=>a.toString());
|
|
278
|
+
return new Map(await Promise.all(uniqueAddresses.map(async (addr)=>[
|
|
279
|
+
addr.toString(),
|
|
280
|
+
await this.oracle.getUpdatedClassIdHints(addr)
|
|
281
|
+
])));
|
|
282
|
+
}
|
|
283
|
+
async createPrivateCallData({ publicInputs, vk: vkAsBuffer }, updatedClassIdHintsMap) {
|
|
265
284
|
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
266
285
|
const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
|
|
267
286
|
const vk = await VerificationKeyAsFields.fromKey(vkAsFields);
|
|
268
287
|
const { currentContractClassId, publicKeys, saltedInitializationHash } = await this.oracle.getContractAddressPreimage(contractAddress);
|
|
269
288
|
const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(currentContractClassId, functionSelector);
|
|
270
289
|
const { artifactHash: contractClassArtifactHash, publicBytecodeCommitment: contractClassPublicBytecodeCommitment } = await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
271
|
-
const updatedClassIdHints =
|
|
290
|
+
const updatedClassIdHints = updatedClassIdHintsMap.get(contractAddress.toString());
|
|
272
291
|
return PrivateCallData.from({
|
|
273
292
|
publicInputs,
|
|
274
293
|
vk,
|
|
@@ -5,11 +5,11 @@ import { MembershipWitness } from '@aztec/foundation/trees';
|
|
|
5
5
|
import type { KeyStore } from '@aztec/key-store';
|
|
6
6
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
9
8
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
10
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
12
11
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
12
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
13
13
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
14
14
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
15
15
|
/**
|
|
@@ -19,14 +19,18 @@ export declare class PrivateKernelOracle {
|
|
|
19
19
|
private contractStore;
|
|
20
20
|
private keyStore;
|
|
21
21
|
private node;
|
|
22
|
-
private
|
|
23
|
-
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode,
|
|
22
|
+
private blockHeader;
|
|
23
|
+
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockHeader: BlockHeader);
|
|
24
24
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
|
25
25
|
getContractAddressPreimage(address: AztecAddress): Promise<ContractInstanceWithAddress & {
|
|
26
26
|
saltedInitializationHash: Fr;
|
|
27
27
|
}>;
|
|
28
28
|
/** Retrieves the preimage of a contract class id from the contract classes db. */
|
|
29
|
-
getContractClassIdPreimage(contractClassId: Fr): Promise<
|
|
29
|
+
getContractClassIdPreimage(contractClassId: Fr): Promise<{
|
|
30
|
+
artifactHash: Fr;
|
|
31
|
+
privateFunctionsRoot: Fr;
|
|
32
|
+
publicBytecodeCommitment: Fr;
|
|
33
|
+
}>;
|
|
30
34
|
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
|
|
31
35
|
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
|
|
32
36
|
/**
|
|
@@ -39,7 +43,7 @@ export declare class PrivateKernelOracle {
|
|
|
39
43
|
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
|
|
40
44
|
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
41
45
|
/** Returns the root of our note hash merkle tree. */
|
|
42
|
-
getNoteHashTreeRoot():
|
|
46
|
+
getNoteHashTreeRoot(): Fr;
|
|
43
47
|
/**
|
|
44
48
|
* Retrieves the sk_m corresponding to the pk_m.
|
|
45
49
|
* @throws If the provided public key is not associated with any of the registered accounts.
|
|
@@ -56,4 +60,4 @@ export declare class PrivateKernelOracle {
|
|
|
56
60
|
*/
|
|
57
61
|
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
58
62
|
}
|
|
59
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJpdmF0ZV9rZXJuZWwvcHJpdmF0ZV9rZXJuZWxfb3JhY2xlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxvQkFBb0IsRUFDcEIscUJBQXFCLEVBR3JCLGNBQWMsRUFDZixNQUFNLGtCQUFrQixDQUFDO0FBQzFCLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxLQUFLLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUdqRCxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBRSxLQUFLLDJCQUEyQixFQUFtQyxNQUFNLHdCQUF3QixDQUFDO0FBRzNHLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQzNELE9BQU8sS0FBSyxFQUFFLDBCQUEwQixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDdEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxhQUFhLEVBQUUsTUFBTSw2Q0FBNkMsQ0FBQztBQUVqRjs7R0FFRztBQUNILHFCQUFhLG1CQUFtQjtJQUU1QixPQUFPLENBQUMsYUFBYTtJQUNyQixPQUFPLENBQUMsUUFBUTtJQUNoQixPQUFPLENBQUMsSUFBSTtJQUNaLE9BQU8sQ0FBQyxXQUFXO0lBSnJCLFlBQ1UsYUFBYSxFQUFFLGFBQWEsRUFDNUIsUUFBUSxFQUFFLFFBQVEsRUFDbEIsSUFBSSxFQUFFLFNBQVMsRUFDZixXQUFXLEVBQUUsV0FBVyxFQUM5QjtJQUVKLDhGQUE4RjtJQUNqRiwwQkFBMEIsQ0FDckMsT0FBTyxFQUFFLFlBQVksR0FDcEIsT0FBTyxDQUFDLDJCQUEyQixHQUFHO1FBQUUsd0JBQXdCLEVBQUUsRUFBRSxDQUFBO0tBQUUsQ0FBQyxDQVN6RTtJQUVELGtGQUFrRjtJQUNyRSwwQkFBMEIsQ0FBQyxlQUFlLEVBQUUsRUFBRTs7OztPQVUxRDtJQUVELHVHQUF1RztJQUMxRiw0QkFBNEIsQ0FDdkMsZUFBZSxFQUFFLEVBQUUsRUFDbkIsUUFBUSxFQUFFLGdCQUFnQixHQUN6QixPQUFPLENBQUMsaUJBQWlCLENBQUMsT0FBTyxvQkFBb0IsQ0FBQyxDQUFDLENBUXpEO0lBRUQ7OztPQUdHO0lBQ0ksc0JBQXNCLENBQUMsRUFBRSxFQUFFLHVCQUF1QixHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxPQUFPLGNBQWMsQ0FBQyxDQUFDLENBRzVHO0lBRUQsK0ZBQStGO0lBQ3pGLDRCQUE0QixDQUNoQyxRQUFRLEVBQUUsRUFBRSxHQUNYLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxPQUFPLHFCQUFxQixDQUFDLEdBQUcsU0FBUyxDQUFDLENBRXRFO0lBRUQsOEdBQThHO0lBQ3hHLDZCQUE2QixDQUFDLFNBQVMsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLDBCQUEwQixHQUFHLFNBQVMsQ0FBQyxDQUVsRztJQUVELHFEQUFxRDtJQUNyRCxtQkFBbUIsSUFBSSxFQUFFLENBRXhCO0lBRUQ7Ozs7OztPQU1HO0lBQ0ksa0JBQWtCLENBQUMsZUFBZSxFQUFFLEtBQUssR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLENBRXpFO0lBRUQsMkVBQTJFO0lBQ3BFLG9CQUFvQixDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLGdCQUFnQixHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRWxIO0lBRUQ7OztPQUdHO0lBQ1Usc0JBQXNCLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsbUJBQW1CLENBQUMsQ0FvQy9GO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_oracle.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"private_kernel_oracle.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EAGrB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,2BAA2B,EAAmC,MAAM,wBAAwB,CAAC;AAG3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;GAEG;AACH,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,WAAW;IAJrB,YACU,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,WAAW,EAC9B;IAEJ,8FAA8F;IACjF,0BAA0B,CACrC,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,2BAA2B,GAAG;QAAE,wBAAwB,EAAE,EAAE,CAAA;KAAE,CAAC,CASzE;IAED,kFAAkF;IACrE,0BAA0B,CAAC,eAAe,EAAE,EAAE;;;;OAU1D;IAED,uGAAuG;IAC1F,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAQzD;IAED;;;OAGG;IACI,sBAAsB,CAAC,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,cAAc,CAAC,CAAC,CAG5G;IAED,+FAA+F;IACzF,4BAA4B,CAChC,QAAQ,EAAE,EAAE,GACX,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,GAAG,SAAS,CAAC,CAEtE;IAED,8GAA8G;IACxG,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAElG;IAED,qDAAqD;IACrD,mBAAmB,IAAI,EAAE,CAExB;IAED;;;;;;OAMG;IACI,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAEzE;IAED,2EAA2E;IACpE,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAElH;IAED;;;OAGG;IACU,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoC/F;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
1
|
+
import { PUBLIC_DATA_TREE_HEIGHT, UPDATES_VALUE_SIZE, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
3
3
|
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
-
import {
|
|
5
|
+
import { computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
6
6
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
7
7
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
8
8
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
@@ -12,12 +12,12 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
12
12
|
contractStore;
|
|
13
13
|
keyStore;
|
|
14
14
|
node;
|
|
15
|
-
|
|
16
|
-
constructor(contractStore, keyStore, node,
|
|
15
|
+
blockHeader;
|
|
16
|
+
constructor(contractStore, keyStore, node, blockHeader){
|
|
17
17
|
this.contractStore = contractStore;
|
|
18
18
|
this.keyStore = keyStore;
|
|
19
19
|
this.node = node;
|
|
20
|
-
this.
|
|
20
|
+
this.blockHeader = blockHeader;
|
|
21
21
|
}
|
|
22
22
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */ async getContractAddressPreimage(address) {
|
|
23
23
|
const instance = await this.contractStore.getContractInstance(address);
|
|
@@ -30,11 +30,15 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
/** Retrieves the preimage of a contract class id from the contract classes db. */ async getContractClassIdPreimage(contractClassId) {
|
|
33
|
-
const contractClass = await this.contractStore.
|
|
33
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(contractClassId);
|
|
34
34
|
if (!contractClass) {
|
|
35
35
|
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return {
|
|
38
|
+
artifactHash: contractClass.artifactHash,
|
|
39
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
40
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment
|
|
41
|
+
};
|
|
38
42
|
}
|
|
39
43
|
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */ async getFunctionMembershipWitness(contractClassId, selector) {
|
|
40
44
|
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
@@ -50,18 +54,14 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
50
54
|
const leafIndex = getVKIndex(vk);
|
|
51
55
|
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
52
56
|
}
|
|
53
|
-
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */ getNoteHashMembershipWitness(noteHash) {
|
|
54
|
-
return this.node.getNoteHashMembershipWitness(this.
|
|
57
|
+
/** Returns a membership witness with the sibling path and leaf index in our note hash tree. */ async getNoteHashMembershipWitness(noteHash) {
|
|
58
|
+
return this.node.getNoteHashMembershipWitness(await this.blockHeader.hash(), noteHash);
|
|
55
59
|
}
|
|
56
|
-
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */ getNullifierMembershipWitness(nullifier) {
|
|
57
|
-
return this.node.getNullifierMembershipWitness(this.
|
|
60
|
+
/** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */ async getNullifierMembershipWitness(nullifier) {
|
|
61
|
+
return this.node.getNullifierMembershipWitness(await this.blockHeader.hash(), nullifier);
|
|
58
62
|
}
|
|
59
|
-
/** Returns the root of our note hash merkle tree. */
|
|
60
|
-
|
|
61
|
-
if (!header) {
|
|
62
|
-
throw new Error(`No block header found for block hash ${this.blockHash}`);
|
|
63
|
-
}
|
|
64
|
-
return header.state.partial.noteHashTree.root;
|
|
63
|
+
/** Returns the root of our note hash merkle tree. */ getNoteHashTreeRoot() {
|
|
64
|
+
return this.blockHeader.state.partial.noteHashTree.root;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Retrieves the sk_m corresponding to the pk_m.
|
|
@@ -81,12 +81,18 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
81
81
|
*/ async getUpdatedClassIdHints(contractAddress) {
|
|
82
82
|
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
83
83
|
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
|
|
84
|
-
const
|
|
84
|
+
const blockHash = await this.blockHeader.hash();
|
|
85
|
+
const updatedClassIdWitness = await this.node.getPublicDataWitness(blockHash, hashLeafSlot);
|
|
85
86
|
if (!updatedClassIdWitness) {
|
|
86
87
|
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
// In an indexed merkle tree, getPublicDataWitness returns a leaf whose slot matches our query
|
|
90
|
+
// only if the slot has been written to. Otherwise, it returns the "low leaf" predecessor, whose
|
|
91
|
+
// slot will differ. Most contracts are never updated, so we can skip the readFromTree call
|
|
92
|
+
// (which triggers multiple RPC calls) and return empty values directly.
|
|
93
|
+
const readStorage = (storageSlot)=>this.node.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
94
|
+
const slotExists = updatedClassIdWitness.leafPreimage.leaf.slot.equals(hashLeafSlot);
|
|
95
|
+
const delayedPublicMutableValues = slotExists ? await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage) : DelayedPublicMutableValues.empty(UPDATES_VALUE_SIZE);
|
|
90
96
|
return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
|
|
91
97
|
}
|
|
92
98
|
}
|