@aztec/pxe 0.0.1-commit.e558bd1c → 0.0.1-commit.e5a3663dd
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 +4 -4
- 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 +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -10
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +8 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +62 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +206 -76
- 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 +63 -45
- 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 +76 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +289 -97
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +58 -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 +121 -95
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +124 -64
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +356 -126
- 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 +7 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +69 -35
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +9 -4
- package/dest/debug/pxe_debug_utils.d.ts +5 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -7
- 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 +11 -3
- 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 +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- 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 +3 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- 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 +11 -3
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +26 -5
- 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/logs/log_service.d.ts +7 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +33 -48
- 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 +36 -0
- package/dest/notes/note_service.d.ts +4 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- 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 +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +18 -13
- 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 +19 -18
- package/dest/pxe.d.ts +84 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +153 -83
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- 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 +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 +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +148 -70
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- 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 +3 -0
- package/dest/storage/private_event_store/stored_private_event.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 +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -22
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_stream_source.ts +52 -0
- package/src/block_synchronizer/block_synchronizer.ts +33 -11
- package/src/config/index.ts +3 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +366 -138
- 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 +91 -53
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +378 -140
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +151 -183
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +598 -156
- 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 +102 -55
- package/src/contract_sync/helpers.ts +8 -3
- package/src/debug/pxe_debug_utils.ts +11 -14
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +11 -4
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +11 -4
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +2 -1
- package/src/entrypoints/server/utils.ts +9 -10
- package/src/events/event_service.ts +30 -5
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +63 -91
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- 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 +18 -16
- package/src/private_kernel/private_kernel_oracle.ts +21 -21
- package/src/pxe.ts +278 -131
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -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 +181 -80
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +5 -5
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +12 -25
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
- 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
|
@@ -6,6 +6,8 @@ import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
8
8
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
9
|
+
import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
10
|
+
import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
|
|
9
11
|
import { packAsHintedNote } from './note_packing_utils.js';
|
|
10
12
|
export class UnavailableOracleError extends Error {
|
|
11
13
|
constructor(oracleName){
|
|
@@ -14,6 +16,25 @@ export class UnavailableOracleError extends Error {
|
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* A data source that has all the apis required by Aztec.nr.
|
|
19
|
+
*
|
|
20
|
+
* ## Oracle naming conventions
|
|
21
|
+
*
|
|
22
|
+
* We try to keep oracle naming consistent, please see below the conventions we adhere to.
|
|
23
|
+
*
|
|
24
|
+
* Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
|
|
25
|
+
*
|
|
26
|
+
* - **Scope prefix** indicates the execution context required:
|
|
27
|
+
* - `aztec_prv_` — available only during private function execution.
|
|
28
|
+
* - `aztec_utl_` — available during both utility and private execution.
|
|
29
|
+
*
|
|
30
|
+
* - **Verb** signals the operation's semantics (verb-first, then object):
|
|
31
|
+
* - `get` — read / lookup / get data from oracle into contract.
|
|
32
|
+
* - `does`/`is`/`has` — predicate (returns boolean).
|
|
33
|
+
* - `emit`/`notify` — propagate data from contract to oracle.
|
|
34
|
+
* - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
|
|
35
|
+
* - `call` — trigger nested execution (control flow).
|
|
36
|
+
* - `assert` — validate a condition, throw on failure.
|
|
37
|
+
* - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
|
|
17
38
|
*/ export class Oracle {
|
|
18
39
|
handler;
|
|
19
40
|
constructor(handler){
|
|
@@ -48,11 +69,11 @@ export class UnavailableOracleError extends Error {
|
|
|
48
69
|
];
|
|
49
70
|
// Get all the oracle function names
|
|
50
71
|
const oracleNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name));
|
|
51
|
-
// Validate oracle names - these must be prefixed with either "
|
|
72
|
+
// Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
|
|
52
73
|
// and must correspond to a function on the Oracle class.
|
|
53
74
|
oracleNames.forEach((name)=>{
|
|
54
|
-
if (!name.startsWith('
|
|
55
|
-
throw new Error(`Oracle function "${name}" must be prefixed with either "
|
|
75
|
+
if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
|
|
76
|
+
throw new Error(`Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`);
|
|
56
77
|
}
|
|
57
78
|
const method = this[name];
|
|
58
79
|
if (typeof method !== 'function') {
|
|
@@ -60,42 +81,78 @@ export class UnavailableOracleError extends Error {
|
|
|
60
81
|
}
|
|
61
82
|
});
|
|
62
83
|
// Build callback object and return it
|
|
63
|
-
|
|
84
|
+
const callback = oracleNames.reduce((acc, name)=>{
|
|
64
85
|
const method = this[name];
|
|
65
86
|
acc[name] = method.bind(this);
|
|
66
87
|
return acc;
|
|
67
88
|
}, {});
|
|
89
|
+
const allCallbacks = {
|
|
90
|
+
...callback,
|
|
91
|
+
...buildLegacyOracleCallbacks(this)
|
|
92
|
+
};
|
|
93
|
+
// Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
|
|
94
|
+
// contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
|
|
95
|
+
// minor version).
|
|
96
|
+
const handler = this.handler;
|
|
97
|
+
return new Proxy(allCallbacks, {
|
|
98
|
+
get (target, prop) {
|
|
99
|
+
if (prop in target) {
|
|
100
|
+
return target[prop];
|
|
101
|
+
}
|
|
102
|
+
// Return a function that throws with an enhanced error message if applicable
|
|
103
|
+
return ()=>{
|
|
104
|
+
let contractVersion = undefined;
|
|
105
|
+
if ('nonOracleFunctionGetContractOracleVersion' in handler) {
|
|
106
|
+
contractVersion = handler.nonOracleFunctionGetContractOracleVersion();
|
|
107
|
+
}
|
|
108
|
+
if (!contractVersion) {
|
|
109
|
+
throw new Error(`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` + `was not called before '${prop}'). This usually means the contract was not compiled with the ` + `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` + `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` + `is called before any other oracle calls. See https://docs.aztec.network/errors/8`);
|
|
110
|
+
} else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
|
|
111
|
+
throw new Error(`Oracle '${prop}' not found.` + ` This usually means the contract requires a newer private execution environment than you have.` + ` Upgrade your private execution environment to a compatible version. The contract was compiled with` + ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` + ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` + ` See https://docs.aztec.network/errors/8`);
|
|
112
|
+
} else {
|
|
113
|
+
throw new Error(`Oracle '${prop}' not found.` + ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` + ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` + ` standard oracles should be available. This could mean the contract was compiled against a modified` + ` version of Aztec.nr, or that it references an oracle that does not exist.` + ` See https://docs.aztec.network/errors/8`);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
68
118
|
}
|
|
69
|
-
|
|
70
|
-
|
|
119
|
+
// eslint-disable-next-line camelcase
|
|
120
|
+
aztec_utl_assertCompatibleOracleVersionV2([major], [minor]) {
|
|
121
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(major).toNumber(), Fr.fromString(minor).toNumber());
|
|
71
122
|
return Promise.resolve([]);
|
|
72
123
|
}
|
|
73
|
-
|
|
74
|
-
|
|
124
|
+
// eslint-disable-next-line camelcase
|
|
125
|
+
aztec_utl_getRandomField() {
|
|
126
|
+
const val = this.handlerAsMisc().getRandomField();
|
|
75
127
|
return Promise.resolve([
|
|
76
128
|
toACVMField(val)
|
|
77
129
|
]);
|
|
78
130
|
}
|
|
79
|
-
|
|
80
|
-
|
|
131
|
+
// eslint-disable-next-line camelcase
|
|
132
|
+
aztec_prv_setHashPreimage(values, [hash]) {
|
|
133
|
+
this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
|
|
81
134
|
return Promise.resolve([]);
|
|
82
135
|
}
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
// eslint-disable-next-line camelcase
|
|
137
|
+
async aztec_prv_getHashPreimage([returnsHash]) {
|
|
138
|
+
const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
|
|
85
139
|
return [
|
|
86
140
|
values.map(toACVMField)
|
|
87
141
|
];
|
|
88
142
|
}
|
|
89
|
-
|
|
90
|
-
|
|
143
|
+
// eslint-disable-next-line camelcase
|
|
144
|
+
aztec_utl_getUtilityContext() {
|
|
145
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
91
146
|
return Promise.resolve(context.toNoirRepresentation());
|
|
92
147
|
}
|
|
93
|
-
|
|
94
|
-
|
|
148
|
+
// eslint-disable-next-line camelcase
|
|
149
|
+
async aztec_utl_getKeyValidationRequest([pkMHash]) {
|
|
150
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
|
|
95
151
|
return keyValidationRequest.toFields().map(toACVMField);
|
|
96
152
|
}
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
// eslint-disable-next-line camelcase
|
|
154
|
+
async aztec_utl_getContractInstance([address]) {
|
|
155
|
+
const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
|
|
99
156
|
return [
|
|
100
157
|
instance.salt,
|
|
101
158
|
instance.deployer,
|
|
@@ -104,62 +161,69 @@ export class UnavailableOracleError extends Error {
|
|
|
104
161
|
...instance.publicKeys.toFields()
|
|
105
162
|
].map(toACVMField);
|
|
106
163
|
}
|
|
107
|
-
|
|
164
|
+
// eslint-disable-next-line camelcase
|
|
165
|
+
async aztec_utl_getNoteHashMembershipWitness([anchorBlockHash], [noteHash]) {
|
|
108
166
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
109
167
|
const parsedNoteHash = Fr.fromString(noteHash);
|
|
110
|
-
const witness = await this.handlerAsUtility().
|
|
168
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
111
169
|
if (!witness) {
|
|
112
170
|
throw new Error(`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`);
|
|
113
171
|
}
|
|
114
172
|
return witness.toNoirRepresentation();
|
|
115
173
|
}
|
|
116
|
-
|
|
174
|
+
// eslint-disable-next-line camelcase
|
|
175
|
+
async aztec_utl_getBlockHashMembershipWitness([anchorBlockHash], [blockHash]) {
|
|
117
176
|
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
118
177
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
119
|
-
const witness = await this.handlerAsUtility().
|
|
178
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
120
179
|
if (!witness) {
|
|
121
180
|
throw new Error(`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`);
|
|
122
181
|
}
|
|
123
182
|
return witness.toNoirRepresentation();
|
|
124
183
|
}
|
|
125
|
-
|
|
184
|
+
// eslint-disable-next-line camelcase
|
|
185
|
+
async aztec_utl_getNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
126
186
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
127
187
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
128
|
-
const witness = await this.handlerAsUtility().
|
|
188
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
129
189
|
if (!witness) {
|
|
130
190
|
throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
131
191
|
}
|
|
132
192
|
return witness.toNoirRepresentation();
|
|
133
193
|
}
|
|
134
|
-
|
|
194
|
+
// eslint-disable-next-line camelcase
|
|
195
|
+
async aztec_utl_getLowNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
135
196
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
136
197
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
137
|
-
const witness = await this.handlerAsUtility().
|
|
198
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
138
199
|
if (!witness) {
|
|
139
200
|
throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
140
201
|
}
|
|
141
202
|
return witness.toNoirRepresentation();
|
|
142
203
|
}
|
|
143
|
-
|
|
204
|
+
// eslint-disable-next-line camelcase
|
|
205
|
+
async aztec_utl_getPublicDataWitness([blockHash], [leafSlot]) {
|
|
144
206
|
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
145
207
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
146
|
-
const witness = await this.handlerAsUtility().
|
|
208
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
147
209
|
if (!witness) {
|
|
148
210
|
throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`);
|
|
149
211
|
}
|
|
150
212
|
return witness.toNoirRepresentation();
|
|
151
213
|
}
|
|
152
|
-
|
|
214
|
+
// eslint-disable-next-line camelcase
|
|
215
|
+
async aztec_utl_getBlockHeader([blockNumber]) {
|
|
153
216
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
154
|
-
const header = await this.handlerAsUtility().
|
|
217
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
155
218
|
if (!header) {
|
|
156
219
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
157
220
|
}
|
|
158
221
|
return header.toFields().map(toACVMField);
|
|
159
222
|
}
|
|
160
|
-
|
|
223
|
+
// eslint-disable-next-line camelcase
|
|
224
|
+
async aztec_utl_getAuthWitness([messageHash]) {
|
|
161
225
|
const messageHashField = Fr.fromString(messageHash);
|
|
162
|
-
const witness = await this.handlerAsUtility().
|
|
226
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
163
227
|
if (!witness) {
|
|
164
228
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
165
229
|
}
|
|
@@ -167,9 +231,10 @@ export class UnavailableOracleError extends Error {
|
|
|
167
231
|
witness.map(toACVMField)
|
|
168
232
|
];
|
|
169
233
|
}
|
|
170
|
-
|
|
234
|
+
// eslint-disable-next-line camelcase
|
|
235
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]) {
|
|
171
236
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
172
|
-
const result = await this.handlerAsUtility().
|
|
237
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
173
238
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
174
239
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
175
240
|
if (result === undefined) {
|
|
@@ -189,10 +254,11 @@ export class UnavailableOracleError extends Error {
|
|
|
189
254
|
];
|
|
190
255
|
}
|
|
191
256
|
}
|
|
192
|
-
|
|
257
|
+
// eslint-disable-next-line camelcase
|
|
258
|
+
async aztec_utl_getNotes([ownerSome], [ownerValue], [storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedHintedNoteLength]) {
|
|
193
259
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
194
260
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
195
|
-
const noteDatas = await this.handlerAsUtility().
|
|
261
|
+
const noteDatas = await this.handlerAsUtility().getNotes(owner, Fr.fromString(storageSlot), +numSelects, selectByIndexes.map((s)=>+s), selectByOffsets.map((s)=>+s), selectByLengths.map((s)=>+s), selectValues.map(Fr.fromString), selectComparators.map((s)=>+s), sortByIndexes.map((s)=>+s), sortByOffsets.map((s)=>+s), sortByLengths.map((s)=>+s), sortOrder.map((s)=>+s), +limit, +offset, +status);
|
|
196
262
|
const returnDataAsArrayOfPackedHintedNotes = noteDatas.map((noteData)=>packAsHintedNote({
|
|
197
263
|
contractAddress: noteData.contractAddress,
|
|
198
264
|
owner: noteData.owner,
|
|
@@ -207,57 +273,74 @@ export class UnavailableOracleError extends Error {
|
|
|
207
273
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
208
274
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
209
275
|
}
|
|
210
|
-
|
|
211
|
-
|
|
276
|
+
// eslint-disable-next-line camelcase
|
|
277
|
+
aztec_prv_notifyCreatedNote([owner], [storageSlot], [randomness], [noteTypeId], note, [noteHash], [counter]) {
|
|
278
|
+
this.handlerAsPrivate().notifyCreatedNote(AztecAddress.fromString(owner), Fr.fromString(storageSlot), Fr.fromString(randomness), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
|
|
212
279
|
return Promise.resolve([]);
|
|
213
280
|
}
|
|
214
|
-
|
|
215
|
-
|
|
281
|
+
// eslint-disable-next-line camelcase
|
|
282
|
+
async aztec_prv_notifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
|
|
283
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
216
284
|
return [];
|
|
217
285
|
}
|
|
218
|
-
|
|
219
|
-
|
|
286
|
+
// eslint-disable-next-line camelcase
|
|
287
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]) {
|
|
288
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
220
289
|
return [];
|
|
221
290
|
}
|
|
222
|
-
|
|
223
|
-
|
|
291
|
+
// eslint-disable-next-line camelcase
|
|
292
|
+
async aztec_prv_isNullifierPending([innerNullifier], [contractAddress]) {
|
|
293
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(Fr.fromString(innerNullifier), AztecAddress.fromString(contractAddress));
|
|
224
294
|
return [
|
|
225
295
|
toACVMField(isPending)
|
|
226
296
|
];
|
|
227
297
|
}
|
|
228
|
-
|
|
229
|
-
|
|
298
|
+
// eslint-disable-next-line camelcase
|
|
299
|
+
async aztec_utl_doesNullifierExist([innerNullifier]) {
|
|
300
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
230
301
|
return [
|
|
231
302
|
toACVMField(exists)
|
|
232
303
|
];
|
|
233
304
|
}
|
|
234
|
-
|
|
235
|
-
|
|
305
|
+
// eslint-disable-next-line camelcase
|
|
306
|
+
async aztec_utl_getL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
|
|
307
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
|
|
236
308
|
return message.toNoirRepresentation();
|
|
237
309
|
}
|
|
238
|
-
|
|
239
|
-
|
|
310
|
+
// eslint-disable-next-line camelcase
|
|
311
|
+
async aztec_utl_getFromPublicStorage([blockHash], [contractAddress], [startStorageSlot], [numberOfElements]) {
|
|
312
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(BlockHash.fromString(blockHash), new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +numberOfElements);
|
|
240
313
|
return [
|
|
241
314
|
values.map(toACVMField)
|
|
242
315
|
];
|
|
243
316
|
}
|
|
244
|
-
|
|
317
|
+
// eslint-disable-next-line camelcase
|
|
318
|
+
async aztec_utl_callUtilityFunction([contractAddress], [functionSelector], args) {
|
|
319
|
+
const result = await this.handlerAsUtility().callUtilityFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), args.map(Fr.fromString));
|
|
320
|
+
return [
|
|
321
|
+
result.map(toACVMField)
|
|
322
|
+
];
|
|
323
|
+
}
|
|
324
|
+
// eslint-disable-next-line camelcase
|
|
325
|
+
aztec_prv_notifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
|
|
245
326
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
246
327
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
247
|
-
this.handlerAsPrivate().
|
|
328
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
248
329
|
return Promise.resolve([]);
|
|
249
330
|
}
|
|
250
|
-
|
|
331
|
+
// eslint-disable-next-line camelcase
|
|
332
|
+
async aztec_utl_log(level, message, _ignoredFieldsSize, fields) {
|
|
251
333
|
const levelFr = Fr.fromString(level[0]);
|
|
252
334
|
const messageStr = message.map((acvmField)=>String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
253
335
|
const fieldsFr = fields.map(Fr.fromString);
|
|
254
|
-
this.handlerAsMisc().
|
|
255
|
-
return
|
|
336
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
337
|
+
return [];
|
|
256
338
|
}
|
|
257
339
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
258
340
|
// change the name here.
|
|
259
|
-
|
|
260
|
-
|
|
341
|
+
// eslint-disable-next-line camelcase
|
|
342
|
+
async aztec_prv_callPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
|
|
343
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
261
344
|
return [
|
|
262
345
|
[
|
|
263
346
|
endSideEffectCounter,
|
|
@@ -265,48 +348,84 @@ export class UnavailableOracleError extends Error {
|
|
|
265
348
|
].map(toACVMField)
|
|
266
349
|
];
|
|
267
350
|
}
|
|
268
|
-
|
|
269
|
-
|
|
351
|
+
// eslint-disable-next-line camelcase
|
|
352
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]) {
|
|
353
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
270
354
|
return [];
|
|
271
355
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]) {
|
|
277
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
356
|
+
// eslint-disable-next-line camelcase
|
|
357
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]) {
|
|
358
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
278
359
|
return Promise.resolve([]);
|
|
279
360
|
}
|
|
280
|
-
|
|
281
|
-
|
|
361
|
+
// eslint-disable-next-line camelcase
|
|
362
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]) {
|
|
363
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(Fr.fromString(sideEffectCounter).toNumber());
|
|
282
364
|
return Promise.resolve([
|
|
283
365
|
toACVMField(isRevertible)
|
|
284
366
|
]);
|
|
285
367
|
}
|
|
286
|
-
|
|
287
|
-
|
|
368
|
+
// eslint-disable-next-line camelcase
|
|
369
|
+
async aztec_prv_getNextAppTagAsSender([sender], [recipient]) {
|
|
370
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
|
|
288
371
|
return [
|
|
289
372
|
toACVMField(tag.value)
|
|
290
373
|
];
|
|
291
374
|
}
|
|
292
|
-
|
|
293
|
-
|
|
375
|
+
// eslint-disable-next-line camelcase
|
|
376
|
+
async aztec_utl_getPendingTaggedLogs([pendingTaggedLogArrayBaseSlot], [scope]) {
|
|
377
|
+
await this.handlerAsUtility().getPendingTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot), AztecAddress.fromString(scope));
|
|
378
|
+
return [];
|
|
379
|
+
}
|
|
380
|
+
// eslint-disable-next-line camelcase
|
|
381
|
+
async aztec_utl_getPendingTaggedLogs_v2([scope]) {
|
|
382
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
|
|
383
|
+
return [
|
|
384
|
+
toACVMField(slot)
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
// eslint-disable-next-line camelcase
|
|
388
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
389
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
294
390
|
return [];
|
|
295
391
|
}
|
|
296
|
-
|
|
297
|
-
|
|
392
|
+
// eslint-disable-next-line camelcase
|
|
393
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2([noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
394
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
298
395
|
return [];
|
|
299
396
|
}
|
|
300
|
-
|
|
301
|
-
|
|
397
|
+
// eslint-disable-next-line camelcase
|
|
398
|
+
async aztec_utl_getLogsByTag([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot], [scope]) {
|
|
399
|
+
await this.handlerAsUtility().getLogsByTag(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
302
400
|
return [];
|
|
303
401
|
}
|
|
304
|
-
|
|
305
|
-
|
|
402
|
+
// eslint-disable-next-line camelcase
|
|
403
|
+
async aztec_utl_getMessageContextsByTxHash([contractAddress], [messageContextRequestsArrayBaseSlot], [messageContextResponsesArrayBaseSlot], [scope]) {
|
|
404
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(AztecAddress.fromString(contractAddress), Fr.fromString(messageContextRequestsArrayBaseSlot), Fr.fromString(messageContextResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
306
405
|
return [];
|
|
307
406
|
}
|
|
308
|
-
|
|
309
|
-
|
|
407
|
+
// eslint-disable-next-line camelcase
|
|
408
|
+
async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]) {
|
|
409
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
|
|
410
|
+
return [
|
|
411
|
+
toACVMField(responseSlot)
|
|
412
|
+
];
|
|
413
|
+
}
|
|
414
|
+
// eslint-disable-next-line camelcase
|
|
415
|
+
async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]) {
|
|
416
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(Fr.fromString(requestArrayBaseSlot));
|
|
417
|
+
return [
|
|
418
|
+
toACVMField(responseSlot)
|
|
419
|
+
];
|
|
420
|
+
}
|
|
421
|
+
// eslint-disable-next-line camelcase
|
|
422
|
+
aztec_utl_setCapsule([contractAddress], [slot], capsule, [scope]) {
|
|
423
|
+
this.handlerAsUtility().setCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString), AztecAddress.fromField(Fr.fromString(scope)));
|
|
424
|
+
return Promise.resolve([]);
|
|
425
|
+
}
|
|
426
|
+
// eslint-disable-next-line camelcase
|
|
427
|
+
async aztec_utl_getCapsule([contractAddress], [slot], [tSize], [scope]) {
|
|
428
|
+
const values = await this.handlerAsUtility().getCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
310
429
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
311
430
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
312
431
|
if (values === null) {
|
|
@@ -323,35 +442,107 @@ export class UnavailableOracleError extends Error {
|
|
|
323
442
|
];
|
|
324
443
|
}
|
|
325
444
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
445
|
+
// eslint-disable-next-line camelcase
|
|
446
|
+
aztec_utl_deleteCapsule([contractAddress], [slot], [scope]) {
|
|
447
|
+
this.handlerAsUtility().deleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
448
|
+
return Promise.resolve([]);
|
|
329
449
|
}
|
|
330
|
-
|
|
331
|
-
|
|
450
|
+
// eslint-disable-next-line camelcase
|
|
451
|
+
async aztec_utl_copyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries], [scope]) {
|
|
452
|
+
await this.handlerAsUtility().copyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber(), AztecAddress.fromField(Fr.fromString(scope)));
|
|
332
453
|
return [];
|
|
333
454
|
}
|
|
334
|
-
|
|
455
|
+
// eslint-disable-next-line camelcase
|
|
456
|
+
aztec_utl_pushEphemeral([slot], elements) {
|
|
457
|
+
const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
|
|
458
|
+
return Promise.resolve([
|
|
459
|
+
toACVMField(newLen)
|
|
460
|
+
]);
|
|
461
|
+
}
|
|
462
|
+
// eslint-disable-next-line camelcase
|
|
463
|
+
aztec_utl_popEphemeral([slot]) {
|
|
464
|
+
const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
|
|
465
|
+
return Promise.resolve([
|
|
466
|
+
element.map(toACVMField)
|
|
467
|
+
]);
|
|
468
|
+
}
|
|
469
|
+
// eslint-disable-next-line camelcase
|
|
470
|
+
aztec_utl_getEphemeral([slot], [index]) {
|
|
471
|
+
const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
472
|
+
return Promise.resolve([
|
|
473
|
+
element.map(toACVMField)
|
|
474
|
+
]);
|
|
475
|
+
}
|
|
476
|
+
// eslint-disable-next-line camelcase
|
|
477
|
+
aztec_utl_setEphemeral([slot], [index], elements) {
|
|
478
|
+
this.handlerAsUtility().setEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber(), elements.map(Fr.fromString));
|
|
479
|
+
return Promise.resolve([]);
|
|
480
|
+
}
|
|
481
|
+
// eslint-disable-next-line camelcase
|
|
482
|
+
aztec_utl_getEphemeralLen([slot]) {
|
|
483
|
+
const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
|
|
484
|
+
return Promise.resolve([
|
|
485
|
+
toACVMField(len)
|
|
486
|
+
]);
|
|
487
|
+
}
|
|
488
|
+
// eslint-disable-next-line camelcase
|
|
489
|
+
aztec_utl_removeEphemeral([slot], [index]) {
|
|
490
|
+
this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
491
|
+
return Promise.resolve([]);
|
|
492
|
+
}
|
|
493
|
+
// eslint-disable-next-line camelcase
|
|
494
|
+
aztec_utl_clearEphemeral([slot]) {
|
|
495
|
+
this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
|
|
496
|
+
return Promise.resolve([]);
|
|
497
|
+
}
|
|
498
|
+
// eslint-disable-next-line camelcase
|
|
499
|
+
async aztec_utl_decryptAes128(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
|
|
335
500
|
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
336
501
|
const ivBuffer = fromUintArray(iv, 8);
|
|
337
502
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
338
|
-
|
|
339
|
-
|
|
503
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
504
|
+
try {
|
|
505
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
506
|
+
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
507
|
+
return [
|
|
508
|
+
toACVMField(1),
|
|
509
|
+
storage,
|
|
510
|
+
length
|
|
511
|
+
];
|
|
512
|
+
} catch {
|
|
513
|
+
const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
|
|
514
|
+
return [
|
|
515
|
+
toACVMField(0),
|
|
516
|
+
zeroStorage,
|
|
517
|
+
toACVMField(0)
|
|
518
|
+
];
|
|
519
|
+
}
|
|
340
520
|
}
|
|
341
|
-
|
|
342
|
-
|
|
521
|
+
// eslint-disable-next-line camelcase
|
|
522
|
+
async aztec_utl_getSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2], [contractAddress]) {
|
|
523
|
+
const secret = await this.handlerAsUtility().getSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
|
|
343
524
|
ephPKField0,
|
|
344
525
|
ephPKField1,
|
|
345
526
|
ephPKField2
|
|
346
|
-
].map(Fr.fromString)));
|
|
347
|
-
return
|
|
527
|
+
].map(Fr.fromString)), AztecAddress.fromField(Fr.fromString(contractAddress)));
|
|
528
|
+
return [
|
|
529
|
+
toACVMField(secret)
|
|
530
|
+
];
|
|
531
|
+
}
|
|
532
|
+
// eslint-disable-next-line camelcase
|
|
533
|
+
aztec_utl_setContractSyncCacheInvalid([contractAddress], scopes, [scopeCount]) {
|
|
534
|
+
const scopeAddresses = scopes.slice(0, +scopeCount).map((s)=>AztecAddress.fromField(Fr.fromString(s)));
|
|
535
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(AztecAddress.fromField(Fr.fromString(contractAddress)), scopeAddresses);
|
|
536
|
+
return Promise.resolve([]);
|
|
348
537
|
}
|
|
349
|
-
|
|
350
|
-
|
|
538
|
+
// eslint-disable-next-line camelcase
|
|
539
|
+
async aztec_utl_emitOffchainEffect(data) {
|
|
540
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
351
541
|
return [];
|
|
352
542
|
}
|
|
353
|
-
|
|
354
|
-
|
|
543
|
+
// eslint-disable-next-line camelcase
|
|
544
|
+
async aztec_prv_getSenderForTags() {
|
|
545
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
355
546
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
356
547
|
return sender ? [
|
|
357
548
|
toACVMField(1n),
|
|
@@ -361,8 +552,9 @@ export class UnavailableOracleError extends Error {
|
|
|
361
552
|
toACVMField(0n)
|
|
362
553
|
];
|
|
363
554
|
}
|
|
364
|
-
|
|
365
|
-
|
|
555
|
+
// eslint-disable-next-line camelcase
|
|
556
|
+
async aztec_prv_setSenderForTags([senderForTags]) {
|
|
557
|
+
await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
366
558
|
return [];
|
|
367
559
|
}
|
|
368
560
|
}
|
|
@@ -45,11 +45,11 @@ import { Oracle } from './oracle.js';
|
|
|
45
45
|
appCircuitName: functionName
|
|
46
46
|
});
|
|
47
47
|
const contractClassLogs = privateExecutionOracle.getContractClassLogs();
|
|
48
|
-
const rawReturnValues = await privateExecutionOracle.
|
|
48
|
+
const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
|
|
49
49
|
const newNotes = privateExecutionOracle.getNewNotes();
|
|
50
50
|
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
51
51
|
const offchainEffects = privateExecutionOracle.getOffchainEffects();
|
|
52
|
-
const
|
|
52
|
+
const taggingIndexRanges = privateExecutionOracle.getUsedTaggingIndexRanges();
|
|
53
53
|
const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
|
|
54
54
|
let timerSubtractionList = nestedExecutionResults;
|
|
55
55
|
let witgenTime = duration;
|
|
@@ -59,7 +59,9 @@ import { Oracle } from './oracle.js';
|
|
|
59
59
|
timerSubtractionList = timerSubtractionList.flatMap((nested)=>nested.nestedExecutionResults ?? []);
|
|
60
60
|
}
|
|
61
61
|
log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
62
|
-
return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, newNotes, noteHashNullifierCounterMap, rawReturnValues, offchainEffects
|
|
62
|
+
return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, newNotes, noteHashNullifierCounterMap, rawReturnValues, offchainEffects.map((e)=>({
|
|
63
|
+
data: e.data
|
|
64
|
+
})), taggingIndexRanges, nestedExecutionResults, contractClassLogs, {
|
|
63
65
|
timings: {
|
|
64
66
|
witgen: witgenTime,
|
|
65
67
|
oracles: acirExecutionResult.oracles
|