@aztec/txe 0.0.1-commit.b6e433891 → 0.0.1-commit.b9865e97
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/ContractClassRegistry-PII7Q556.js +3 -0
- package/dest/ContractClassRegistry-PII7Q556.js.map +7 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +3 -0
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +7 -0
- package/dest/FeeJuice-TQV5AQK7.js +3 -0
- package/dest/FeeJuice-TQV5AQK7.js.map +7 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +3 -0
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +7 -0
- package/dest/SchnorrAccount-MQXPIZ44.js +3 -0
- package/dest/SchnorrAccount-MQXPIZ44.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.d.ts +2 -0
- package/dest/bin/check_txe_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_txe_oracle_version.js +61 -0
- package/dest/bin/index.js +3 -30
- package/dest/bin/index.js.map +7 -0
- package/dest/bin/oracle_test_server.d.ts +3 -0
- package/dest/bin/oracle_test_server.d.ts.map +1 -0
- package/dest/bin/oracle_test_server.js +41 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.js.map +7 -0
- package/dest/chunk-CUSVOJA4.js +304 -0
- package/dest/chunk-CUSVOJA4.js.map +7 -0
- package/dest/chunk-OYLIPWI6.js +260 -0
- package/dest/chunk-OYLIPWI6.js.map +7 -0
- package/dest/constants.d.ts +5 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +8 -0
- package/dest/dispatcher_pool.d.ts +67 -0
- package/dest/dispatcher_pool.d.ts.map +1 -0
- package/dest/dispatcher_pool.js +284 -0
- package/dest/index.d.ts +185 -7
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +70 -190
- package/dest/metafile.json +36863 -0
- package/dest/msgpackr_fr_extension.d.ts +2 -0
- package/dest/msgpackr_fr_extension.d.ts.map +1 -0
- package/dest/msgpackr_fr_extension.js +21 -0
- package/dest/oracle/interfaces.d.ts +33 -8
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/test-resolver/fixtures.d.ts +43 -0
- package/dest/oracle/test-resolver/fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/fixtures.js +39 -0
- package/dest/oracle/test-resolver/index.d.ts +9 -0
- package/dest/oracle/test-resolver/index.d.ts.map +1 -0
- package/dest/oracle/test-resolver/index.js +33 -0
- package/dest/oracle/test-resolver/resolver.d.ts +34 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +114 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +26 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +43 -1
- package/dest/oracle/txe_oracle_registry.d.ts +147 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +562 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +33 -14
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +149 -60
- package/dest/oracle/txe_oracle_version.d.ts +17 -0
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_version.js +14 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts +17 -0
- package/dest/oracle/txe_private_execution_oracle.d.ts.map +1 -0
- package/dest/oracle/txe_private_execution_oracle.js +15 -0
- package/dest/rpc_server.d.ts +14 -0
- package/dest/rpc_server.d.ts.map +1 -0
- package/dest/rpc_server.js +78 -0
- package/dest/rpc_translator.d.ts +96 -233
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +706 -637
- package/dest/server.bundle.js +3 -0
- package/dest/server.bundle.js.map +7 -0
- package/dest/state_machine/archiver.d.ts +4 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +26 -15
- package/dest/state_machine/dummy_p2p_client.d.ts +13 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +16 -4
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +17 -3
- package/dest/state_machine/mock_epoch_cache.d.ts +1 -2
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +0 -3
- package/dest/state_machine/synchronizer.js +1 -1
- package/dest/txe_session.d.ts +75 -14
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +170 -41
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +7 -2
- package/dest/{util → utils}/expected_failure_error.d.ts +1 -1
- package/dest/utils/expected_failure_error.d.ts.map +1 -0
- package/dest/{util → utils}/txe_account_store.d.ts +1 -1
- package/dest/utils/txe_account_store.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.d.ts +37 -0
- package/dest/utils/txe_artifact_resolver.d.ts.map +1 -0
- package/dest/utils/txe_artifact_resolver.js +161 -0
- package/dest/utils/txe_public_contract_data_source.d.ts +20 -0
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -0
- package/dest/{util → utils}/txe_public_contract_data_source.js +1 -3
- package/dest/worker.bundle.js +3 -0
- package/dest/worker.bundle.js.map +7 -0
- package/dest/worker.d.ts +2 -0
- package/dest/worker.d.ts.map +1 -0
- package/dest/worker.js +92 -0
- package/package.json +38 -21
- package/src/bin/check_txe_oracle_version.ts +70 -0
- package/src/bin/index.ts +11 -2
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +10 -0
- package/src/dispatcher_pool.ts +316 -0
- package/src/index.ts +97 -227
- package/src/msgpackr_fr_extension.ts +23 -0
- package/src/oracle/interfaces.ts +29 -7
- package/src/oracle/test-resolver/fixtures.ts +84 -0
- package/src/oracle/test-resolver/index.ts +45 -0
- package/src/oracle/test-resolver/resolver.ts +165 -0
- package/src/oracle/txe_oracle_public_context.ts +60 -0
- package/src/oracle/txe_oracle_registry.ts +401 -0
- package/src/oracle/txe_oracle_top_level_context.ts +180 -67
- package/src/oracle/txe_oracle_version.ts +17 -0
- package/src/oracle/txe_private_execution_oracle.ts +30 -0
- package/src/rpc_server.ts +87 -0
- package/src/rpc_translator.ts +787 -925
- package/src/state_machine/archiver.ts +38 -16
- package/src/state_machine/dummy_p2p_client.ts +31 -11
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +20 -5
- package/src/state_machine/mock_epoch_cache.ts +0 -4
- package/src/state_machine/synchronizer.ts +1 -1
- package/src/txe_session.ts +278 -45
- package/src/{util → utils}/encoding.ts +8 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/{util → utils}/txe_public_contract_data_source.ts +0 -2
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -720
- package/dest/util/encoding.d.ts.map +0 -1
- package/dest/util/expected_failure_error.d.ts.map +0 -1
- package/dest/util/txe_account_store.d.ts.map +0 -1
- package/dest/util/txe_public_contract_data_source.d.ts +0 -20
- package/dest/util/txe_public_contract_data_source.d.ts.map +0 -1
- /package/dest/{util → utils}/expected_failure_error.js +0 -0
- /package/dest/{util → utils}/txe_account_store.js +0 -0
- /package/src/{util → utils}/expected_failure_error.ts +0 -0
- /package/src/{util → utils}/txe_account_store.ts +0 -0
package/src/rpc_translator.ts
CHANGED
|
@@ -1,37 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
4
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
5
|
-
import {
|
|
6
|
-
type IMiscOracle,
|
|
7
|
-
type IPrivateExecutionOracle,
|
|
8
|
-
type IUtilityExecutionOracle,
|
|
9
|
-
packAsHintedNote,
|
|
10
|
-
} from '@aztec/pxe/simulator';
|
|
11
|
-
import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
12
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import { BlockHash } from '@aztec/stdlib/block';
|
|
1
|
+
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
14
2
|
|
|
15
3
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
4
|
+
import { callTxeHandler } from './oracle/txe_oracle_registry.js';
|
|
16
5
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
17
|
-
import {
|
|
18
|
-
type ForeignCallArray,
|
|
19
|
-
type ForeignCallSingle,
|
|
20
|
-
addressFromSingle,
|
|
21
|
-
arrayOfArraysToBoundedVecOfArrays,
|
|
22
|
-
arrayToBoundedVec,
|
|
23
|
-
bufferToU8Array,
|
|
24
|
-
fromArray,
|
|
25
|
-
fromSingle,
|
|
26
|
-
fromUintArray,
|
|
27
|
-
fromUintBoundedVec,
|
|
28
|
-
toArray,
|
|
29
|
-
toForeignCallResult,
|
|
30
|
-
toSingle,
|
|
31
|
-
} from './util/encoding.js';
|
|
32
|
-
|
|
33
|
-
const MAX_EVENT_LEN = 10; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_MSG_PLAINTEXT_RESERVED_FIELDS_LEN
|
|
34
|
-
const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
|
|
6
|
+
import type { ForeignCallArgs } from './utils/encoding.js';
|
|
35
7
|
|
|
36
8
|
export class UnavailableOracleError extends Error {
|
|
37
9
|
constructor(oracleName: string) {
|
|
@@ -102,61 +74,54 @@ export class RPCTranslator {
|
|
|
102
74
|
return this.oracleHandler;
|
|
103
75
|
}
|
|
104
76
|
|
|
77
|
+
// eslint-disable-next-line camelcase
|
|
78
|
+
aztec_txe_assertCompatibleOracleVersion(...inputs: ForeignCallArgs) {
|
|
79
|
+
return callTxeHandler({
|
|
80
|
+
oracle: 'aztec_txe_assertCompatibleOracleVersion',
|
|
81
|
+
inputs,
|
|
82
|
+
handler: ([major, minor]) => {
|
|
83
|
+
this.stateHandler.setTxeOracleVersion(major, minor);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
105
88
|
// TXE session state transition functions - these get handled by the state handler
|
|
106
89
|
|
|
107
90
|
// eslint-disable-next-line camelcase
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
91
|
+
aztec_txe_setTopLevelTXEContext() {
|
|
92
|
+
return callTxeHandler({
|
|
93
|
+
oracle: 'aztec_txe_setTopLevelTXEContext',
|
|
94
|
+
inputs: [],
|
|
95
|
+
handler: () => this.stateHandler.enterTopLevelState(),
|
|
96
|
+
});
|
|
112
97
|
}
|
|
113
98
|
|
|
114
99
|
// eslint-disable-next-line camelcase
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
? AztecAddress.fromField(fromSingle(foreignContractAddressValue))
|
|
123
|
-
: undefined;
|
|
124
|
-
|
|
125
|
-
const anchorBlockNumber = fromSingle(foreignAnchorBlockNumberIsSome).toBool()
|
|
126
|
-
? BlockNumber(fromSingle(foreignAnchorBlockNumberValue).toNumber())
|
|
127
|
-
: undefined;
|
|
128
|
-
|
|
129
|
-
const privateContextInputs = await this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber);
|
|
130
|
-
|
|
131
|
-
return toForeignCallResult(privateContextInputs.toFields().map(toSingle));
|
|
100
|
+
aztec_txe_setPrivateTXEContext(...inputs: ForeignCallArgs) {
|
|
101
|
+
return callTxeHandler({
|
|
102
|
+
oracle: 'aztec_txe_setPrivateTXEContext',
|
|
103
|
+
inputs,
|
|
104
|
+
handler: ([contractAddress, anchorBlockNumber, gasSettings]) =>
|
|
105
|
+
this.stateHandler.enterPrivateState(contractAddress, anchorBlockNumber, gasSettings),
|
|
106
|
+
});
|
|
132
107
|
}
|
|
133
108
|
|
|
134
109
|
// eslint-disable-next-line camelcase
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
: undefined;
|
|
142
|
-
|
|
143
|
-
await this.stateHandler.enterPublicState(contractAddress);
|
|
144
|
-
|
|
145
|
-
return toForeignCallResult([]);
|
|
110
|
+
aztec_txe_setPublicTXEContext(...inputs: ForeignCallArgs) {
|
|
111
|
+
return callTxeHandler({
|
|
112
|
+
oracle: 'aztec_txe_setPublicTXEContext',
|
|
113
|
+
inputs,
|
|
114
|
+
handler: ([contractAddress]) => this.stateHandler.enterPublicState(contractAddress),
|
|
115
|
+
});
|
|
146
116
|
}
|
|
147
117
|
|
|
148
118
|
// eslint-disable-next-line camelcase
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
: undefined;
|
|
156
|
-
|
|
157
|
-
await this.stateHandler.enterUtilityState(contractAddress);
|
|
158
|
-
|
|
159
|
-
return toForeignCallResult([]);
|
|
119
|
+
aztec_txe_setUtilityTXEContext(...inputs: ForeignCallArgs) {
|
|
120
|
+
return callTxeHandler({
|
|
121
|
+
oracle: 'aztec_txe_setUtilityTXEContext',
|
|
122
|
+
inputs,
|
|
123
|
+
handler: ([contractAddress]) => this.stateHandler.enterUtilityState(contractAddress),
|
|
124
|
+
});
|
|
160
125
|
}
|
|
161
126
|
|
|
162
127
|
// Other oracles - these get handled by the oracle handler
|
|
@@ -165,713 +130,581 @@ export class RPCTranslator {
|
|
|
165
130
|
|
|
166
131
|
// eslint-disable-next-line camelcase
|
|
167
132
|
aztec_txe_getDefaultAddress() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
return callTxeHandler({
|
|
134
|
+
oracle: 'aztec_txe_getDefaultAddress',
|
|
135
|
+
inputs: [],
|
|
136
|
+
handler: () => this.handlerAsTxe().getDefaultAddress(),
|
|
137
|
+
});
|
|
171
138
|
}
|
|
172
139
|
|
|
173
140
|
// eslint-disable-next-line camelcase
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
141
|
+
aztec_txe_getNextBlockNumber() {
|
|
142
|
+
return callTxeHandler({
|
|
143
|
+
oracle: 'aztec_txe_getNextBlockNumber',
|
|
144
|
+
inputs: [],
|
|
145
|
+
handler: () => this.handlerAsTxe().getNextBlockNumber(),
|
|
146
|
+
});
|
|
178
147
|
}
|
|
179
148
|
|
|
180
149
|
// eslint-disable-next-line camelcase
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
150
|
+
aztec_txe_getNextBlockTimestamp() {
|
|
151
|
+
return callTxeHandler({
|
|
152
|
+
oracle: 'aztec_txe_getNextBlockTimestamp',
|
|
153
|
+
inputs: [],
|
|
154
|
+
handler: () => this.handlerAsTxe().getNextBlockTimestamp(),
|
|
155
|
+
});
|
|
185
156
|
}
|
|
186
157
|
|
|
187
158
|
// eslint-disable-next-line camelcase
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
159
|
+
aztec_txe_advanceBlocksBy(...inputs: ForeignCallArgs) {
|
|
160
|
+
return callTxeHandler({
|
|
161
|
+
oracle: 'aztec_txe_advanceBlocksBy',
|
|
162
|
+
inputs,
|
|
163
|
+
handler: ([blocks]) => this.handlerAsTxe().advanceBlocksBy(blocks),
|
|
164
|
+
});
|
|
194
165
|
}
|
|
195
166
|
|
|
196
167
|
// eslint-disable-next-line camelcase
|
|
197
|
-
aztec_txe_advanceTimestampBy(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
168
|
+
aztec_txe_advanceTimestampBy(...inputs: ForeignCallArgs) {
|
|
169
|
+
return callTxeHandler({
|
|
170
|
+
oracle: 'aztec_txe_advanceTimestampBy',
|
|
171
|
+
inputs,
|
|
172
|
+
handler: ([duration]) => this.handlerAsTxe().advanceTimestampBy(duration),
|
|
173
|
+
});
|
|
203
174
|
}
|
|
204
175
|
|
|
205
176
|
// eslint-disable-next-line camelcase
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
await this.handlerAsTxe().deploy(artifact, instance, secret);
|
|
214
|
-
|
|
215
|
-
return toForeignCallResult([
|
|
216
|
-
toArray([
|
|
217
|
-
instance.salt,
|
|
218
|
-
instance.deployer.toField(),
|
|
219
|
-
instance.currentContractClassId,
|
|
220
|
-
instance.initializationHash,
|
|
221
|
-
...instance.publicKeys.toFields(),
|
|
222
|
-
]),
|
|
223
|
-
]);
|
|
177
|
+
aztec_txe_deploy(...inputs: ForeignCallArgs) {
|
|
178
|
+
return callTxeHandler({
|
|
179
|
+
oracle: 'aztec_txe_deploy',
|
|
180
|
+
inputs,
|
|
181
|
+
handler: ([contractPath, initializer, _, args, secret, salt, deployer]) =>
|
|
182
|
+
this.handlerAsTxe().deploy(contractPath, initializer, args, secret, salt, deployer),
|
|
183
|
+
});
|
|
224
184
|
}
|
|
225
185
|
|
|
226
186
|
// eslint-disable-next-line camelcase
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
toSingle(completeAddress.address),
|
|
234
|
-
...completeAddress.publicKeys.toFields().map(toSingle),
|
|
235
|
-
]);
|
|
187
|
+
aztec_txe_createAccount(...inputs: ForeignCallArgs) {
|
|
188
|
+
return callTxeHandler({
|
|
189
|
+
oracle: 'aztec_txe_createAccount',
|
|
190
|
+
inputs,
|
|
191
|
+
handler: ([secret]) => this.handlerAsTxe().createAccount(secret),
|
|
192
|
+
});
|
|
236
193
|
}
|
|
237
194
|
|
|
238
195
|
// eslint-disable-next-line camelcase
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const completeAddress = await this.handlerAsTxe().addAccount(artifact, instance, secret);
|
|
247
|
-
|
|
248
|
-
return toForeignCallResult([
|
|
249
|
-
toSingle(completeAddress.address),
|
|
250
|
-
...completeAddress.publicKeys.toFields().map(toSingle),
|
|
251
|
-
]);
|
|
196
|
+
aztec_txe_addAccount(...inputs: ForeignCallArgs) {
|
|
197
|
+
return callTxeHandler({
|
|
198
|
+
oracle: 'aztec_txe_addAccount',
|
|
199
|
+
inputs,
|
|
200
|
+
handler: ([secret]) => this.handlerAsTxe().addAccount(secret),
|
|
201
|
+
});
|
|
252
202
|
}
|
|
253
203
|
|
|
254
204
|
// eslint-disable-next-line camelcase
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return toForeignCallResult([]);
|
|
205
|
+
aztec_txe_addAuthWitness(...inputs: ForeignCallArgs) {
|
|
206
|
+
return callTxeHandler({
|
|
207
|
+
oracle: 'aztec_txe_addAuthWitness',
|
|
208
|
+
inputs,
|
|
209
|
+
handler: ([address, messageHash]) => this.handlerAsTxe().addAuthWitness(address, messageHash),
|
|
210
|
+
});
|
|
262
211
|
}
|
|
263
212
|
|
|
264
213
|
// PXE oracles
|
|
265
214
|
|
|
266
215
|
// eslint-disable-next-line camelcase
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
216
|
+
aztec_misc_assertCompatibleOracleVersion(...inputs: ForeignCallArgs) {
|
|
217
|
+
return callTxeHandler({
|
|
218
|
+
oracle: 'aztec_misc_assertCompatibleOracleVersion',
|
|
219
|
+
inputs,
|
|
220
|
+
handler: ([major, minor]) => this.handlerAsMisc().assertCompatibleOracleVersion(major, minor),
|
|
221
|
+
});
|
|
273
222
|
}
|
|
274
223
|
|
|
275
224
|
// eslint-disable-next-line camelcase
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
225
|
+
aztec_misc_getRandomField() {
|
|
226
|
+
return callTxeHandler({
|
|
227
|
+
oracle: 'aztec_misc_getRandomField',
|
|
228
|
+
inputs: [],
|
|
229
|
+
handler: () => this.handlerAsMisc().getRandomField(),
|
|
230
|
+
});
|
|
280
231
|
}
|
|
281
232
|
|
|
282
233
|
// eslint-disable-next-line camelcase
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
234
|
+
aztec_txe_getLastBlockTimestamp() {
|
|
235
|
+
return callTxeHandler({
|
|
236
|
+
oracle: 'aztec_txe_getLastBlockTimestamp',
|
|
237
|
+
inputs: [],
|
|
238
|
+
handler: () => this.handlerAsTxe().getLastBlockTimestamp(),
|
|
239
|
+
});
|
|
287
240
|
}
|
|
288
241
|
|
|
289
242
|
// eslint-disable-next-line camelcase
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX),
|
|
297
|
-
]);
|
|
243
|
+
aztec_txe_getLastTxEffects() {
|
|
244
|
+
return callTxeHandler({
|
|
245
|
+
oracle: 'aztec_txe_getLastTxEffects',
|
|
246
|
+
inputs: [],
|
|
247
|
+
handler: () => this.handlerAsTxe().getLastTxEffects(),
|
|
248
|
+
});
|
|
298
249
|
}
|
|
299
250
|
|
|
300
251
|
// eslint-disable-next-line camelcase
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
308
|
-
const scope = addressFromSingle(foreignScope);
|
|
309
|
-
|
|
310
|
-
// TODO(F-335): Avoid doing the following 2 calls here.
|
|
311
|
-
{
|
|
312
|
-
await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
|
|
313
|
-
// We cycle job to commit the stores after the contract sync.
|
|
314
|
-
await this.stateHandler.cycleJob();
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
318
|
-
|
|
319
|
-
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
320
|
-
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (events.some(e => e.length > MAX_EVENT_LEN)) {
|
|
324
|
-
throw new Error(`Some private event has length larger than maxLen ${MAX_EVENT_LEN}`);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// This is a workaround as Noir does not currently let us return nested structs with arrays. We instead return a raw
|
|
328
|
-
// multidimensional array in get_private_events_oracle and create the BoundedVecs here.
|
|
329
|
-
const rawArrayStorage = events
|
|
330
|
-
.map(e => e.concat(Array(MAX_EVENT_LEN - e.length).fill(new Fr(0))))
|
|
331
|
-
.concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(Array(MAX_EVENT_LEN).fill(new Fr(0))))
|
|
332
|
-
.flat();
|
|
333
|
-
const eventLengths = events
|
|
334
|
-
.map(e => new Fr(e.length))
|
|
335
|
-
.concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(new Fr(0)));
|
|
336
|
-
const queryLength = new Fr(events.length);
|
|
337
|
-
|
|
338
|
-
return toForeignCallResult([toArray(rawArrayStorage), toArray(eventLengths), toSingle(queryLength)]);
|
|
252
|
+
aztec_txe_getLastCallOffchainEffects() {
|
|
253
|
+
return callTxeHandler({
|
|
254
|
+
oracle: 'aztec_txe_getLastCallOffchainEffects',
|
|
255
|
+
inputs: [],
|
|
256
|
+
handler: () => this.stateHandler.getLastCallOffchainEffects(),
|
|
257
|
+
});
|
|
339
258
|
}
|
|
340
259
|
|
|
341
260
|
// eslint-disable-next-line camelcase
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return toForeignCallResult([]);
|
|
261
|
+
aztec_txe_getLastCallContext() {
|
|
262
|
+
return callTxeHandler({
|
|
263
|
+
oracle: 'aztec_txe_getLastCallContext',
|
|
264
|
+
inputs: [],
|
|
265
|
+
handler: () => this.stateHandler.getLastCallContext(),
|
|
266
|
+
});
|
|
349
267
|
}
|
|
350
268
|
|
|
351
269
|
// eslint-disable-next-line camelcase
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
270
|
+
aztec_txe_getPrivateEvents(...inputs: ForeignCallArgs) {
|
|
271
|
+
return callTxeHandler({
|
|
272
|
+
oracle: 'aztec_txe_getPrivateEvents',
|
|
273
|
+
inputs,
|
|
274
|
+
handler: async ([selector, contractAddress, scope]) => {
|
|
275
|
+
// TODO(F-335): Avoid doing the following 2 calls here.
|
|
276
|
+
{
|
|
277
|
+
await this.handlerAsTxe().syncContractNonOracleMethod(
|
|
278
|
+
contractAddress,
|
|
279
|
+
scope,
|
|
280
|
+
this.stateHandler.getCurrentJob(),
|
|
281
|
+
);
|
|
282
|
+
// We cycle job to commit the stores after the contract sync.
|
|
283
|
+
await this.stateHandler.cycleJob();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// eslint-disable-next-line camelcase
|
|
292
|
+
aztec_prv_setHashPreimage(...inputs: ForeignCallArgs) {
|
|
293
|
+
return callTxeHandler({
|
|
294
|
+
oracle: 'aztec_prv_setHashPreimage',
|
|
295
|
+
inputs,
|
|
296
|
+
handler: ([values, hash]) => this.handlerAsPrivate().setHashPreimage(values, hash),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// eslint-disable-next-line camelcase
|
|
301
|
+
aztec_prv_getHashPreimage(...inputs: ForeignCallArgs) {
|
|
302
|
+
return callTxeHandler({
|
|
303
|
+
oracle: 'aztec_prv_getHashPreimage',
|
|
304
|
+
inputs,
|
|
305
|
+
handler: ([hash]) => this.handlerAsPrivate().getHashPreimage(hash),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
356
308
|
|
|
357
|
-
|
|
309
|
+
// eslint-disable-next-line camelcase
|
|
310
|
+
aztec_misc_log(...inputs: ForeignCallArgs) {
|
|
311
|
+
return callTxeHandler({
|
|
312
|
+
oracle: 'aztec_misc_log',
|
|
313
|
+
inputs,
|
|
314
|
+
handler: ([level, message, fieldsSize, fields]) => this.handlerAsMisc().log(level, message, fieldsSize, fields),
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// eslint-disable-next-line camelcase
|
|
319
|
+
aztec_utl_getFromPublicStorage(...inputs: ForeignCallArgs) {
|
|
320
|
+
return callTxeHandler({
|
|
321
|
+
oracle: 'aztec_utl_getFromPublicStorage',
|
|
322
|
+
inputs,
|
|
323
|
+
handler: ([blockHash, contractAddress, startStorageSlot, numberOfElements]) =>
|
|
324
|
+
this.handlerAsUtility().getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// eslint-disable-next-line camelcase
|
|
329
|
+
aztec_utl_getPublicDataWitness(...inputs: ForeignCallArgs) {
|
|
330
|
+
return callTxeHandler({
|
|
331
|
+
oracle: 'aztec_utl_getPublicDataWitness',
|
|
332
|
+
inputs,
|
|
333
|
+
handler: ([blockHash, leafSlot]) => this.handlerAsUtility().getPublicDataWitness(blockHash, leafSlot),
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// eslint-disable-next-line camelcase
|
|
338
|
+
aztec_utl_getNotes(...inputs: ForeignCallArgs) {
|
|
339
|
+
return callTxeHandler({
|
|
340
|
+
oracle: 'aztec_utl_getNotes',
|
|
341
|
+
inputs,
|
|
342
|
+
handler: ([
|
|
343
|
+
owner,
|
|
344
|
+
storageSlot,
|
|
345
|
+
numSelects,
|
|
346
|
+
selectByIndexes,
|
|
347
|
+
selectByOffsets,
|
|
348
|
+
selectByLengths,
|
|
349
|
+
selectValues,
|
|
350
|
+
selectComparators,
|
|
351
|
+
sortByIndexes,
|
|
352
|
+
sortByOffsets,
|
|
353
|
+
sortByLengths,
|
|
354
|
+
sortOrder,
|
|
355
|
+
limit,
|
|
356
|
+
offset,
|
|
357
|
+
status,
|
|
358
|
+
maxNotes,
|
|
359
|
+
packedHintedNoteLength,
|
|
360
|
+
]) =>
|
|
361
|
+
this.handlerAsUtility().getNotes(
|
|
362
|
+
owner,
|
|
363
|
+
storageSlot,
|
|
364
|
+
numSelects,
|
|
365
|
+
selectByIndexes,
|
|
366
|
+
selectByOffsets,
|
|
367
|
+
selectByLengths,
|
|
368
|
+
selectValues,
|
|
369
|
+
selectComparators,
|
|
370
|
+
sortByIndexes,
|
|
371
|
+
sortByOffsets,
|
|
372
|
+
sortByLengths,
|
|
373
|
+
sortOrder,
|
|
374
|
+
limit,
|
|
375
|
+
offset,
|
|
376
|
+
status,
|
|
377
|
+
maxNotes,
|
|
378
|
+
packedHintedNoteLength,
|
|
379
|
+
),
|
|
380
|
+
});
|
|
358
381
|
}
|
|
359
382
|
|
|
360
|
-
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
361
|
-
// When the argument is an array, we add the field length manually to the signature.
|
|
362
383
|
// eslint-disable-next-line camelcase
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const message = fromArray(foreignMessage)
|
|
371
|
-
.map(field => String.fromCharCode(field.toNumber()))
|
|
372
|
-
.join('');
|
|
373
|
-
const fields = fromArray(foreignFields);
|
|
374
|
-
|
|
375
|
-
await this.handlerAsMisc().log(level, message, fields);
|
|
376
|
-
|
|
377
|
-
return toForeignCallResult([]);
|
|
384
|
+
aztec_prv_notifyCreatedNote(...inputs: ForeignCallArgs) {
|
|
385
|
+
return callTxeHandler({
|
|
386
|
+
oracle: 'aztec_prv_notifyCreatedNote',
|
|
387
|
+
inputs,
|
|
388
|
+
handler: ([owner, storageSlot, randomness, noteTypeId, note, noteHash, counter]) =>
|
|
389
|
+
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter),
|
|
390
|
+
});
|
|
378
391
|
}
|
|
379
392
|
|
|
380
393
|
// eslint-disable-next-line camelcase
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
389
|
-
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
390
|
-
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
391
|
-
|
|
392
|
-
const values = await this.handlerAsUtility().storageRead(
|
|
393
|
-
blockHash,
|
|
394
|
-
contractAddress,
|
|
395
|
-
startStorageSlot,
|
|
396
|
-
numberOfElements,
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
return toForeignCallResult([toArray(values)]);
|
|
394
|
+
aztec_prv_notifyNullifiedNote(...inputs: ForeignCallArgs) {
|
|
395
|
+
return callTxeHandler({
|
|
396
|
+
oracle: 'aztec_prv_notifyNullifiedNote',
|
|
397
|
+
inputs,
|
|
398
|
+
handler: ([innerNullifier, noteHash, counter]) =>
|
|
399
|
+
this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter),
|
|
400
|
+
});
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
// eslint-disable-next-line camelcase
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (!witness) {
|
|
410
|
-
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
411
|
-
}
|
|
412
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// eslint-disable-next-line camelcase
|
|
416
|
-
async aztec_utl_getNotes(
|
|
417
|
-
foreignOwnerIsSome: ForeignCallSingle,
|
|
418
|
-
foreignOwnerValue: ForeignCallSingle,
|
|
419
|
-
foreignStorageSlot: ForeignCallSingle,
|
|
420
|
-
foreignNumSelects: ForeignCallSingle,
|
|
421
|
-
foreignSelectByIndexes: ForeignCallArray,
|
|
422
|
-
foreignSelectByOffsets: ForeignCallArray,
|
|
423
|
-
foreignSelectByLengths: ForeignCallArray,
|
|
424
|
-
foreignSelectValues: ForeignCallArray,
|
|
425
|
-
foreignSelectComparators: ForeignCallArray,
|
|
426
|
-
foreignSortByIndexes: ForeignCallArray,
|
|
427
|
-
foreignSortByOffsets: ForeignCallArray,
|
|
428
|
-
foreignSortByLengths: ForeignCallArray,
|
|
429
|
-
foreignSortOrder: ForeignCallArray,
|
|
430
|
-
foreignLimit: ForeignCallSingle,
|
|
431
|
-
foreignOffset: ForeignCallSingle,
|
|
432
|
-
foreignStatus: ForeignCallSingle,
|
|
433
|
-
foreignMaxNotes: ForeignCallSingle,
|
|
434
|
-
foreignPackedHintedNoteLength: ForeignCallSingle,
|
|
435
|
-
) {
|
|
436
|
-
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
437
|
-
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
438
|
-
? AztecAddress.fromField(fromSingle(foreignOwnerValue))
|
|
439
|
-
: undefined;
|
|
440
|
-
const storageSlot = fromSingle(foreignStorageSlot);
|
|
441
|
-
const numSelects = fromSingle(foreignNumSelects).toNumber();
|
|
442
|
-
const selectByIndexes = fromArray(foreignSelectByIndexes).map(fr => fr.toNumber());
|
|
443
|
-
const selectByOffsets = fromArray(foreignSelectByOffsets).map(fr => fr.toNumber());
|
|
444
|
-
const selectByLengths = fromArray(foreignSelectByLengths).map(fr => fr.toNumber());
|
|
445
|
-
const selectValues = fromArray(foreignSelectValues);
|
|
446
|
-
const selectComparators = fromArray(foreignSelectComparators).map(fr => fr.toNumber());
|
|
447
|
-
const sortByIndexes = fromArray(foreignSortByIndexes).map(fr => fr.toNumber());
|
|
448
|
-
const sortByOffsets = fromArray(foreignSortByOffsets).map(fr => fr.toNumber());
|
|
449
|
-
const sortByLengths = fromArray(foreignSortByLengths).map(fr => fr.toNumber());
|
|
450
|
-
const sortOrder = fromArray(foreignSortOrder).map(fr => fr.toNumber());
|
|
451
|
-
const limit = fromSingle(foreignLimit).toNumber();
|
|
452
|
-
const offset = fromSingle(foreignOffset).toNumber();
|
|
453
|
-
const status = fromSingle(foreignStatus).toNumber();
|
|
454
|
-
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
455
|
-
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
456
|
-
|
|
457
|
-
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
458
|
-
owner,
|
|
459
|
-
storageSlot,
|
|
460
|
-
numSelects,
|
|
461
|
-
selectByIndexes,
|
|
462
|
-
selectByOffsets,
|
|
463
|
-
selectByLengths,
|
|
464
|
-
selectValues,
|
|
465
|
-
selectComparators,
|
|
466
|
-
sortByIndexes,
|
|
467
|
-
sortByOffsets,
|
|
468
|
-
sortByLengths,
|
|
469
|
-
sortOrder,
|
|
470
|
-
limit,
|
|
471
|
-
offset,
|
|
472
|
-
status,
|
|
473
|
-
);
|
|
474
|
-
|
|
475
|
-
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
476
|
-
packAsHintedNote({
|
|
477
|
-
contractAddress: noteData.contractAddress,
|
|
478
|
-
owner: noteData.owner,
|
|
479
|
-
randomness: noteData.randomness,
|
|
480
|
-
storageSlot: noteData.storageSlot,
|
|
481
|
-
noteNonce: noteData.noteNonce,
|
|
482
|
-
isPending: noteData.isPending,
|
|
483
|
-
note: noteData.note,
|
|
484
|
-
}),
|
|
485
|
-
);
|
|
486
|
-
|
|
487
|
-
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
488
|
-
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map(subArray =>
|
|
489
|
-
subArray.map(toSingle),
|
|
490
|
-
);
|
|
491
|
-
|
|
492
|
-
// At last we convert the array of arrays to a bounded vec of arrays
|
|
493
|
-
return toForeignCallResult(
|
|
494
|
-
arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength),
|
|
495
|
-
);
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// eslint-disable-next-line camelcase
|
|
499
|
-
aztec_prv_notifyCreatedNote(
|
|
500
|
-
foreignOwner: ForeignCallSingle,
|
|
501
|
-
foreignStorageSlot: ForeignCallSingle,
|
|
502
|
-
foreignRandomness: ForeignCallSingle,
|
|
503
|
-
foreignNoteTypeId: ForeignCallSingle,
|
|
504
|
-
foreignNote: ForeignCallArray,
|
|
505
|
-
foreignNoteHash: ForeignCallSingle,
|
|
506
|
-
foreignCounter: ForeignCallSingle,
|
|
507
|
-
) {
|
|
508
|
-
const owner = addressFromSingle(foreignOwner);
|
|
509
|
-
const storageSlot = fromSingle(foreignStorageSlot);
|
|
510
|
-
const randomness = fromSingle(foreignRandomness);
|
|
511
|
-
const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
|
|
512
|
-
const note = fromArray(foreignNote);
|
|
513
|
-
const noteHash = fromSingle(foreignNoteHash);
|
|
514
|
-
const counter = fromSingle(foreignCounter).toNumber();
|
|
515
|
-
|
|
516
|
-
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
517
|
-
|
|
518
|
-
return toForeignCallResult([]);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// eslint-disable-next-line camelcase
|
|
522
|
-
async aztec_prv_notifyNullifiedNote(
|
|
523
|
-
foreignInnerNullifier: ForeignCallSingle,
|
|
524
|
-
foreignNoteHash: ForeignCallSingle,
|
|
525
|
-
foreignCounter: ForeignCallSingle,
|
|
526
|
-
) {
|
|
527
|
-
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
528
|
-
const noteHash = fromSingle(foreignNoteHash);
|
|
529
|
-
const counter = fromSingle(foreignCounter).toNumber();
|
|
530
|
-
|
|
531
|
-
await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
532
|
-
|
|
533
|
-
return toForeignCallResult([]);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// eslint-disable-next-line camelcase
|
|
537
|
-
async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
|
|
538
|
-
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
539
|
-
|
|
540
|
-
await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
|
|
541
|
-
|
|
542
|
-
return toForeignCallResult([]);
|
|
404
|
+
aztec_prv_notifyCreatedNullifier(...inputs: ForeignCallArgs) {
|
|
405
|
+
return callTxeHandler({
|
|
406
|
+
oracle: 'aztec_prv_notifyCreatedNullifier',
|
|
407
|
+
inputs,
|
|
408
|
+
handler: ([innerNullifier]) => this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier),
|
|
409
|
+
});
|
|
543
410
|
}
|
|
544
411
|
|
|
545
412
|
// eslint-disable-next-line camelcase
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
|
|
554
|
-
|
|
555
|
-
return toForeignCallResult([toSingle(new Fr(isPending))]);
|
|
413
|
+
aztec_prv_isNullifierPending(...inputs: ForeignCallArgs) {
|
|
414
|
+
return callTxeHandler({
|
|
415
|
+
oracle: 'aztec_prv_isNullifierPending',
|
|
416
|
+
inputs,
|
|
417
|
+
handler: ([innerNullifier, contractAddress]) =>
|
|
418
|
+
this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress),
|
|
419
|
+
});
|
|
556
420
|
}
|
|
557
421
|
|
|
558
422
|
// eslint-disable-next-line camelcase
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
423
|
+
aztec_utl_doesNullifierExist(...inputs: ForeignCallArgs) {
|
|
424
|
+
return callTxeHandler({
|
|
425
|
+
oracle: 'aztec_utl_doesNullifierExist',
|
|
426
|
+
inputs,
|
|
427
|
+
handler: ([innerNullifier]) => this.handlerAsUtility().doesNullifierExist(innerNullifier),
|
|
428
|
+
});
|
|
565
429
|
}
|
|
566
430
|
|
|
567
431
|
// eslint-disable-next-line camelcase
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
[
|
|
575
|
-
instance.salt,
|
|
576
|
-
instance.deployer.toField(),
|
|
577
|
-
instance.currentContractClassId,
|
|
578
|
-
instance.initializationHash,
|
|
579
|
-
...instance.publicKeys.toFields(),
|
|
580
|
-
].map(toSingle),
|
|
581
|
-
);
|
|
432
|
+
aztec_utl_getContractInstance(...inputs: ForeignCallArgs) {
|
|
433
|
+
return callTxeHandler({
|
|
434
|
+
oracle: 'aztec_utl_getContractInstance',
|
|
435
|
+
inputs,
|
|
436
|
+
handler: ([address]) => this.handlerAsUtility().getContractInstance(address),
|
|
437
|
+
});
|
|
582
438
|
}
|
|
583
439
|
|
|
584
440
|
// eslint-disable-next-line camelcase
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
592
|
-
if (result === undefined) {
|
|
593
|
-
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
594
|
-
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
595
|
-
} else {
|
|
596
|
-
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
597
|
-
return toForeignCallResult([
|
|
598
|
-
toSingle(new Fr(1)),
|
|
599
|
-
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
600
|
-
]);
|
|
601
|
-
}
|
|
441
|
+
aztec_utl_getPublicKeysAndPartialAddress(...inputs: ForeignCallArgs) {
|
|
442
|
+
return callTxeHandler({
|
|
443
|
+
oracle: 'aztec_utl_getPublicKeysAndPartialAddress',
|
|
444
|
+
inputs,
|
|
445
|
+
handler: ([address]) => this.handlerAsUtility().getPublicKeysAndPartialAddress(address),
|
|
446
|
+
});
|
|
602
447
|
}
|
|
603
448
|
|
|
604
449
|
// eslint-disable-next-line camelcase
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
450
|
+
aztec_utl_getKeyValidationRequest(...inputs: ForeignCallArgs) {
|
|
451
|
+
return callTxeHandler({
|
|
452
|
+
oracle: 'aztec_utl_getKeyValidationRequest',
|
|
453
|
+
inputs,
|
|
454
|
+
handler: ([pkMHash]) => this.handlerAsUtility().getKeyValidationRequest(pkMHash),
|
|
455
|
+
});
|
|
611
456
|
}
|
|
612
457
|
|
|
613
458
|
// eslint-disable-next-line camelcase
|
|
614
|
-
aztec_prv_callPrivateFunction(
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
459
|
+
aztec_prv_callPrivateFunction(...inputs: ForeignCallArgs) {
|
|
460
|
+
return callTxeHandler({
|
|
461
|
+
oracle: 'aztec_prv_callPrivateFunction',
|
|
462
|
+
inputs,
|
|
463
|
+
handler: ([contractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall]) =>
|
|
464
|
+
this.handlerAsPrivate().callPrivateFunction(
|
|
465
|
+
contractAddress,
|
|
466
|
+
functionSelector,
|
|
467
|
+
argsHash,
|
|
468
|
+
sideEffectCounter,
|
|
469
|
+
isStaticCall,
|
|
470
|
+
),
|
|
471
|
+
});
|
|
624
472
|
}
|
|
625
473
|
|
|
626
474
|
// eslint-disable-next-line camelcase
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
635
|
-
|
|
636
|
-
if (!witness) {
|
|
637
|
-
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
638
|
-
}
|
|
639
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
475
|
+
aztec_utl_getNullifierMembershipWitness(...inputs: ForeignCallArgs) {
|
|
476
|
+
return callTxeHandler({
|
|
477
|
+
oracle: 'aztec_utl_getNullifierMembershipWitness',
|
|
478
|
+
inputs,
|
|
479
|
+
handler: ([blockHash, nullifier]) => this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier),
|
|
480
|
+
});
|
|
640
481
|
}
|
|
641
482
|
|
|
642
483
|
// eslint-disable-next-line camelcase
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
650
|
-
}
|
|
651
|
-
return toForeignCallResult([toArray(authWitness)]);
|
|
484
|
+
aztec_utl_getAuthWitness(...inputs: ForeignCallArgs) {
|
|
485
|
+
return callTxeHandler({
|
|
486
|
+
oracle: 'aztec_utl_getAuthWitness',
|
|
487
|
+
inputs,
|
|
488
|
+
handler: ([messageHash]) => this.handlerAsUtility().getAuthWitness(messageHash),
|
|
489
|
+
});
|
|
652
490
|
}
|
|
653
491
|
|
|
654
492
|
// eslint-disable-next-line camelcase
|
|
655
|
-
|
|
656
|
-
|
|
493
|
+
aztec_prv_assertValidPublicCalldata(...inputs: ForeignCallArgs) {
|
|
494
|
+
return callTxeHandler({
|
|
495
|
+
oracle: 'aztec_prv_assertValidPublicCalldata',
|
|
496
|
+
inputs,
|
|
497
|
+
handler: ([calldataHash]) => this.handlerAsPrivate().assertValidPublicCalldata(calldataHash),
|
|
498
|
+
});
|
|
657
499
|
}
|
|
658
500
|
|
|
659
501
|
// eslint-disable-next-line camelcase
|
|
660
|
-
|
|
661
|
-
|
|
502
|
+
aztec_prv_notifyRevertiblePhaseStart(...inputs: ForeignCallArgs) {
|
|
503
|
+
return callTxeHandler({
|
|
504
|
+
oracle: 'aztec_prv_notifyRevertiblePhaseStart',
|
|
505
|
+
inputs,
|
|
506
|
+
handler: ([minRevertibleSideEffectCounter]) =>
|
|
507
|
+
this.handlerAsPrivate().notifyRevertiblePhaseStart(minRevertibleSideEffectCounter),
|
|
508
|
+
});
|
|
662
509
|
}
|
|
663
510
|
|
|
664
511
|
// eslint-disable-next-line camelcase
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
512
|
+
aztec_prv_isExecutionInRevertiblePhase(...inputs: ForeignCallArgs) {
|
|
513
|
+
return callTxeHandler({
|
|
514
|
+
oracle: 'aztec_prv_isExecutionInRevertiblePhase',
|
|
515
|
+
inputs,
|
|
516
|
+
handler: ([sideEffectCounter]) => this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter),
|
|
517
|
+
});
|
|
669
518
|
}
|
|
670
519
|
|
|
671
520
|
// eslint-disable-next-line camelcase
|
|
672
521
|
aztec_utl_getUtilityContext() {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
522
|
+
return callTxeHandler({
|
|
523
|
+
oracle: 'aztec_utl_getUtilityContext',
|
|
524
|
+
inputs: [],
|
|
525
|
+
handler: () => this.handlerAsUtility().getUtilityContext(),
|
|
526
|
+
});
|
|
676
527
|
}
|
|
677
528
|
|
|
678
529
|
// eslint-disable-next-line camelcase
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
686
|
-
}
|
|
687
|
-
return toForeignCallResult(header.toFields().map(toSingle));
|
|
530
|
+
aztec_utl_getBlockHeader(...inputs: ForeignCallArgs) {
|
|
531
|
+
return callTxeHandler({
|
|
532
|
+
oracle: 'aztec_utl_getBlockHeader',
|
|
533
|
+
inputs,
|
|
534
|
+
handler: ([blockNumber]) => this.handlerAsUtility().getBlockHeader(blockNumber),
|
|
535
|
+
});
|
|
688
536
|
}
|
|
689
537
|
|
|
690
538
|
// eslint-disable-next-line camelcase
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
699
|
-
|
|
700
|
-
if (!witness) {
|
|
701
|
-
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
702
|
-
}
|
|
703
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
539
|
+
aztec_utl_getNoteHashMembershipWitness(...inputs: ForeignCallArgs) {
|
|
540
|
+
return callTxeHandler({
|
|
541
|
+
oracle: 'aztec_utl_getNoteHashMembershipWitness',
|
|
542
|
+
inputs,
|
|
543
|
+
handler: ([blockHash, noteHash]) => this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash),
|
|
544
|
+
});
|
|
704
545
|
}
|
|
705
546
|
|
|
706
547
|
// eslint-disable-next-line camelcase
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
715
|
-
|
|
716
|
-
if (!witness) {
|
|
717
|
-
throw new Error(
|
|
718
|
-
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
719
|
-
);
|
|
720
|
-
}
|
|
721
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
548
|
+
aztec_utl_getBlockHashMembershipWitness(...inputs: ForeignCallArgs) {
|
|
549
|
+
return callTxeHandler({
|
|
550
|
+
oracle: 'aztec_utl_getBlockHashMembershipWitness',
|
|
551
|
+
inputs,
|
|
552
|
+
handler: ([anchorBlockHash, blockHash]) =>
|
|
553
|
+
this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash),
|
|
554
|
+
});
|
|
722
555
|
}
|
|
723
556
|
|
|
724
557
|
// eslint-disable-next-line camelcase
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
733
|
-
|
|
734
|
-
if (!witness) {
|
|
735
|
-
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
736
|
-
}
|
|
737
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
558
|
+
aztec_utl_getLowNullifierMembershipWitness(...inputs: ForeignCallArgs) {
|
|
559
|
+
return callTxeHandler({
|
|
560
|
+
oracle: 'aztec_utl_getLowNullifierMembershipWitness',
|
|
561
|
+
inputs,
|
|
562
|
+
handler: ([blockHash, nullifier]) =>
|
|
563
|
+
this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier),
|
|
564
|
+
});
|
|
738
565
|
}
|
|
739
566
|
|
|
740
567
|
// eslint-disable-next-line camelcase
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
568
|
+
aztec_utl_getPendingTaggedLogs(...inputs: ForeignCallArgs) {
|
|
569
|
+
return callTxeHandler({
|
|
570
|
+
oracle: 'aztec_utl_getPendingTaggedLogs',
|
|
571
|
+
inputs,
|
|
572
|
+
handler: ([scope, providedSecrets]) => this.handlerAsUtility().getPendingTaggedLogs(scope, providedSecrets),
|
|
573
|
+
});
|
|
747
574
|
}
|
|
748
575
|
|
|
749
576
|
// eslint-disable-next-line camelcase
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
762
|
-
|
|
763
|
-
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
764
|
-
contractAddress,
|
|
765
|
-
noteValidationRequestsArrayBaseSlot,
|
|
766
|
-
eventValidationRequestsArrayBaseSlot,
|
|
767
|
-
maxNotePackedLen,
|
|
768
|
-
maxEventSerializedLen,
|
|
769
|
-
);
|
|
770
|
-
|
|
771
|
-
return toForeignCallResult([]);
|
|
577
|
+
aztec_utl_validateAndStoreEnqueuedNotesAndEvents(...inputs: ForeignCallArgs) {
|
|
578
|
+
return callTxeHandler({
|
|
579
|
+
oracle: 'aztec_utl_validateAndStoreEnqueuedNotesAndEvents',
|
|
580
|
+
inputs,
|
|
581
|
+
handler: ([noteValidationRequests, eventValidationRequests, scope]) =>
|
|
582
|
+
this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
583
|
+
noteValidationRequests,
|
|
584
|
+
eventValidationRequests,
|
|
585
|
+
scope,
|
|
586
|
+
),
|
|
587
|
+
});
|
|
772
588
|
}
|
|
773
589
|
|
|
774
590
|
// eslint-disable-next-line camelcase
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
782
|
-
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
783
|
-
|
|
784
|
-
await this.handlerAsUtility().bulkRetrieveLogs(
|
|
785
|
-
contractAddress,
|
|
786
|
-
logRetrievalRequestsArrayBaseSlot,
|
|
787
|
-
logRetrievalResponsesArrayBaseSlot,
|
|
788
|
-
);
|
|
789
|
-
|
|
790
|
-
return toForeignCallResult([]);
|
|
591
|
+
aztec_utl_getLogsByTag(...inputs: ForeignCallArgs) {
|
|
592
|
+
return callTxeHandler({
|
|
593
|
+
oracle: 'aztec_utl_getLogsByTag',
|
|
594
|
+
inputs,
|
|
595
|
+
handler: ([requestArrayBaseSlot]) => this.handlerAsUtility().getLogsByTag(requestArrayBaseSlot),
|
|
596
|
+
});
|
|
791
597
|
}
|
|
792
598
|
|
|
793
599
|
// eslint-disable-next-line camelcase
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
|
|
801
|
-
const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
|
|
802
|
-
|
|
803
|
-
await this.handlerAsUtility().utilityResolveMessageContexts(
|
|
804
|
-
contractAddress,
|
|
805
|
-
messageContextRequestsArrayBaseSlot,
|
|
806
|
-
messageContextResponsesArrayBaseSlot,
|
|
807
|
-
);
|
|
808
|
-
|
|
809
|
-
return toForeignCallResult([]);
|
|
600
|
+
aztec_utl_getMessageContextsByTxHash(...inputs: ForeignCallArgs) {
|
|
601
|
+
return callTxeHandler({
|
|
602
|
+
oracle: 'aztec_utl_getMessageContextsByTxHash',
|
|
603
|
+
inputs,
|
|
604
|
+
handler: ([requestArrayBaseSlot]) => this.handlerAsUtility().getMessageContextsByTxHash(requestArrayBaseSlot),
|
|
605
|
+
});
|
|
810
606
|
}
|
|
811
607
|
|
|
812
608
|
// eslint-disable-next-line camelcase
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
await this.handlerAsUtility().storeCapsule(contractAddress, slot, capsule);
|
|
609
|
+
aztec_utl_setCapsule(...inputs: ForeignCallArgs) {
|
|
610
|
+
return callTxeHandler({
|
|
611
|
+
oracle: 'aztec_utl_setCapsule',
|
|
612
|
+
inputs,
|
|
613
|
+
handler: ([contractAddress, slot, capsule, scope]) =>
|
|
614
|
+
this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope),
|
|
615
|
+
});
|
|
616
|
+
}
|
|
823
617
|
|
|
824
|
-
|
|
618
|
+
// eslint-disable-next-line camelcase
|
|
619
|
+
aztec_utl_getCapsule(...inputs: ForeignCallArgs) {
|
|
620
|
+
return callTxeHandler({
|
|
621
|
+
oracle: 'aztec_utl_getCapsule',
|
|
622
|
+
inputs,
|
|
623
|
+
handler: ([contractAddress, slot, tSize, scope]) =>
|
|
624
|
+
this.handlerAsUtility().getCapsule(contractAddress, slot, tSize, scope),
|
|
625
|
+
});
|
|
825
626
|
}
|
|
826
627
|
|
|
827
628
|
// eslint-disable-next-line camelcase
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
const tSize = fromSingle(foreignTSize).toNumber();
|
|
629
|
+
aztec_utl_deleteCapsule(...inputs: ForeignCallArgs) {
|
|
630
|
+
return callTxeHandler({
|
|
631
|
+
oracle: 'aztec_utl_deleteCapsule',
|
|
632
|
+
inputs,
|
|
633
|
+
handler: ([contractAddress, slot, scope]) => this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope),
|
|
634
|
+
});
|
|
635
|
+
}
|
|
836
636
|
|
|
837
|
-
|
|
637
|
+
// eslint-disable-next-line camelcase
|
|
638
|
+
aztec_utl_copyCapsule(...inputs: ForeignCallArgs) {
|
|
639
|
+
return callTxeHandler({
|
|
640
|
+
oracle: 'aztec_utl_copyCapsule',
|
|
641
|
+
inputs,
|
|
642
|
+
handler: ([contractAddress, srcSlot, dstSlot, numEntries, scope]) =>
|
|
643
|
+
this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope),
|
|
644
|
+
});
|
|
645
|
+
}
|
|
838
646
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
return toForeignCallResult([toSingle(new Fr(1)), toArray(values)]);
|
|
847
|
-
}
|
|
647
|
+
// eslint-disable-next-line camelcase
|
|
648
|
+
aztec_utl_pushEphemeral(...inputs: ForeignCallArgs) {
|
|
649
|
+
return callTxeHandler({
|
|
650
|
+
oracle: 'aztec_utl_pushEphemeral',
|
|
651
|
+
inputs,
|
|
652
|
+
handler: ([slot, elements]) => this.handlerAsUtility().pushEphemeral(slot, elements),
|
|
653
|
+
});
|
|
848
654
|
}
|
|
849
655
|
|
|
850
656
|
// eslint-disable-next-line camelcase
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
657
|
+
aztec_utl_popEphemeral(...inputs: ForeignCallArgs) {
|
|
658
|
+
return callTxeHandler({
|
|
659
|
+
oracle: 'aztec_utl_popEphemeral',
|
|
660
|
+
inputs,
|
|
661
|
+
handler: ([slot]) => this.handlerAsUtility().popEphemeral(slot),
|
|
662
|
+
});
|
|
663
|
+
}
|
|
854
664
|
|
|
855
|
-
|
|
665
|
+
// eslint-disable-next-line camelcase
|
|
666
|
+
aztec_utl_getEphemeral(...inputs: ForeignCallArgs) {
|
|
667
|
+
return callTxeHandler({
|
|
668
|
+
oracle: 'aztec_utl_getEphemeral',
|
|
669
|
+
inputs,
|
|
670
|
+
handler: ([slot, index]) => this.handlerAsUtility().getEphemeral(slot, index),
|
|
671
|
+
});
|
|
672
|
+
}
|
|
856
673
|
|
|
857
|
-
|
|
674
|
+
// eslint-disable-next-line camelcase
|
|
675
|
+
aztec_utl_setEphemeral(...inputs: ForeignCallArgs) {
|
|
676
|
+
return callTxeHandler({
|
|
677
|
+
oracle: 'aztec_utl_setEphemeral',
|
|
678
|
+
inputs,
|
|
679
|
+
handler: ([slot, index, elements]) => this.handlerAsUtility().setEphemeral(slot, index, elements),
|
|
680
|
+
});
|
|
858
681
|
}
|
|
859
682
|
|
|
860
683
|
// eslint-disable-next-line camelcase
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
const srcSlot = fromSingle(foreignSrcSlot);
|
|
869
|
-
const dstSlot = fromSingle(foreignDstSlot);
|
|
870
|
-
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
684
|
+
aztec_utl_getEphemeralLen(...inputs: ForeignCallArgs) {
|
|
685
|
+
return callTxeHandler({
|
|
686
|
+
oracle: 'aztec_utl_getEphemeralLen',
|
|
687
|
+
inputs,
|
|
688
|
+
handler: ([slot]) => this.handlerAsUtility().getEphemeralLen(slot),
|
|
689
|
+
});
|
|
690
|
+
}
|
|
871
691
|
|
|
872
|
-
|
|
692
|
+
// eslint-disable-next-line camelcase
|
|
693
|
+
aztec_utl_removeEphemeral(...inputs: ForeignCallArgs) {
|
|
694
|
+
return callTxeHandler({
|
|
695
|
+
oracle: 'aztec_utl_removeEphemeral',
|
|
696
|
+
inputs,
|
|
697
|
+
handler: ([slot, index]) => this.handlerAsUtility().removeEphemeral(slot, index),
|
|
698
|
+
});
|
|
699
|
+
}
|
|
873
700
|
|
|
874
|
-
|
|
701
|
+
// eslint-disable-next-line camelcase
|
|
702
|
+
aztec_utl_clearEphemeral(...inputs: ForeignCallArgs) {
|
|
703
|
+
return callTxeHandler({
|
|
704
|
+
oracle: 'aztec_utl_clearEphemeral',
|
|
705
|
+
inputs,
|
|
706
|
+
handler: ([slot]) => this.handlerAsUtility().clearEphemeral(slot),
|
|
707
|
+
});
|
|
875
708
|
}
|
|
876
709
|
|
|
877
710
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
@@ -879,363 +712,392 @@ export class RPCTranslator {
|
|
|
879
712
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
880
713
|
// existence of a txe_oracle method?
|
|
881
714
|
// eslint-disable-next-line camelcase
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
const ciphertext = fromUintBoundedVec(foreignCiphertextBVecStorage, foreignCiphertextLength, 8);
|
|
889
|
-
const iv = fromUintArray(foreignIv, 8);
|
|
890
|
-
const symKey = fromUintArray(foreignSymKey, 8);
|
|
891
|
-
|
|
892
|
-
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
893
|
-
try {
|
|
894
|
-
const plaintextBuffer = await this.handlerAsUtility().aes128Decrypt(ciphertext, iv, symKey);
|
|
895
|
-
const [storage, length] = arrayToBoundedVec(
|
|
896
|
-
bufferToU8Array(plaintextBuffer),
|
|
897
|
-
foreignCiphertextBVecStorage.length,
|
|
898
|
-
);
|
|
899
|
-
return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
|
|
900
|
-
} catch {
|
|
901
|
-
const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
|
|
902
|
-
return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
|
|
903
|
-
}
|
|
715
|
+
aztec_utl_decryptAes128(...inputs: ForeignCallArgs) {
|
|
716
|
+
return callTxeHandler({
|
|
717
|
+
oracle: 'aztec_utl_decryptAes128',
|
|
718
|
+
inputs,
|
|
719
|
+
handler: ([ciphertext, iv, symKey]) => this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey),
|
|
720
|
+
});
|
|
904
721
|
}
|
|
905
722
|
|
|
906
723
|
// eslint-disable-next-line camelcase
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const ephPK = Point.fromFields([
|
|
915
|
-
fromSingle(foreignEphPKField0),
|
|
916
|
-
fromSingle(foreignEphPKField1),
|
|
917
|
-
fromSingle(foreignEphPKField2),
|
|
918
|
-
]);
|
|
919
|
-
|
|
920
|
-
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK);
|
|
921
|
-
|
|
922
|
-
return toForeignCallResult(secret.toFields().map(toSingle));
|
|
724
|
+
aztec_utl_getSharedSecrets(...inputs: ForeignCallArgs) {
|
|
725
|
+
return callTxeHandler({
|
|
726
|
+
oracle: 'aztec_utl_getSharedSecrets',
|
|
727
|
+
inputs,
|
|
728
|
+
handler: ([address, ephPksSlot, contractAddress]) =>
|
|
729
|
+
this.handlerAsUtility().getSharedSecrets(address, ephPksSlot, contractAddress),
|
|
730
|
+
});
|
|
923
731
|
}
|
|
924
732
|
|
|
925
733
|
// eslint-disable-next-line camelcase
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
const scopes = fromArray(foreignScopes)
|
|
934
|
-
.slice(0, count)
|
|
935
|
-
.map(f => new AztecAddress(f));
|
|
936
|
-
|
|
937
|
-
this.handlerAsUtility().invalidateContractSyncCache(contractAddress, scopes);
|
|
938
|
-
|
|
939
|
-
return Promise.resolve(toForeignCallResult([]));
|
|
734
|
+
aztec_utl_setContractSyncCacheInvalid(...inputs: ForeignCallArgs) {
|
|
735
|
+
return callTxeHandler({
|
|
736
|
+
oracle: 'aztec_utl_setContractSyncCacheInvalid',
|
|
737
|
+
inputs,
|
|
738
|
+
handler: ([contractAddress, scopes]) =>
|
|
739
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes),
|
|
740
|
+
});
|
|
940
741
|
}
|
|
941
742
|
|
|
942
743
|
// eslint-disable-next-line camelcase
|
|
943
|
-
aztec_utl_emitOffchainEffect(
|
|
944
|
-
|
|
744
|
+
aztec_utl_emitOffchainEffect(...inputs: ForeignCallArgs) {
|
|
745
|
+
return callTxeHandler({
|
|
746
|
+
oracle: 'aztec_utl_emitOffchainEffect',
|
|
747
|
+
inputs,
|
|
748
|
+
handler: ([data]) => {
|
|
749
|
+
// Record the raw payload against the currently-executing top-level call. The Noir side
|
|
750
|
+
// (via `env.offchain_messages()`) is responsible for decoding the protocol-reserved prefix
|
|
751
|
+
// (`OFFCHAIN_MESSAGE_IDENTIFIER`, recipient) and turning each payload into an `OffchainMessage` struct suitable
|
|
752
|
+
// for `offchain_receive`.
|
|
753
|
+
this.stateHandler.recordOffchainEffect(data);
|
|
754
|
+
},
|
|
755
|
+
});
|
|
945
756
|
}
|
|
946
757
|
|
|
947
758
|
// AVM opcodes
|
|
948
759
|
|
|
949
760
|
// eslint-disable-next-line camelcase
|
|
950
|
-
aztec_avm_emitPublicLog(
|
|
951
|
-
|
|
952
|
-
|
|
761
|
+
aztec_avm_emitPublicLog() {
|
|
762
|
+
return callTxeHandler({
|
|
763
|
+
oracle: 'aztec_avm_emitPublicLog',
|
|
764
|
+
inputs: [],
|
|
765
|
+
// TODO(#8811): Implement
|
|
766
|
+
handler: () => {},
|
|
767
|
+
});
|
|
953
768
|
}
|
|
954
769
|
|
|
955
770
|
// eslint-disable-next-line camelcase
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
return toForeignCallResult([toSingle(new Fr(value))]);
|
|
771
|
+
aztec_avm_storageRead(...inputs: ForeignCallArgs) {
|
|
772
|
+
return callTxeHandler({
|
|
773
|
+
oracle: 'aztec_avm_storageRead',
|
|
774
|
+
inputs,
|
|
775
|
+
handler: ([slot, contractAddress]) => this.handlerAsAvm().storageRead(slot, contractAddress),
|
|
776
|
+
});
|
|
963
777
|
}
|
|
964
778
|
|
|
965
779
|
// eslint-disable-next-line camelcase
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
return toForeignCallResult([]);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
// eslint-disable-next-line camelcase
|
|
976
|
-
async aztec_avm_getContractInstanceDeployer(foreignAddress: ForeignCallSingle) {
|
|
977
|
-
const address = addressFromSingle(foreignAddress);
|
|
978
|
-
|
|
979
|
-
const instance = await this.handlerAsUtility().getContractInstance(address);
|
|
980
|
-
|
|
981
|
-
return toForeignCallResult([
|
|
982
|
-
toSingle(instance.deployer),
|
|
983
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
984
|
-
toSingle(new Fr(1)),
|
|
985
|
-
]);
|
|
780
|
+
aztec_avm_storageWrite(...inputs: ForeignCallArgs) {
|
|
781
|
+
return callTxeHandler({
|
|
782
|
+
oracle: 'aztec_avm_storageWrite',
|
|
783
|
+
inputs,
|
|
784
|
+
handler: ([slot, value]) => this.handlerAsAvm().storageWrite(slot, value),
|
|
785
|
+
});
|
|
986
786
|
}
|
|
987
787
|
|
|
988
788
|
// eslint-disable-next-line camelcase
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
toSingle(instance.currentContractClassId),
|
|
996
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
997
|
-
toSingle(new Fr(1)),
|
|
998
|
-
]);
|
|
789
|
+
aztec_avm_getContractInstanceDeployer(...inputs: ForeignCallArgs) {
|
|
790
|
+
return callTxeHandler({
|
|
791
|
+
oracle: 'aztec_avm_getContractInstanceDeployer',
|
|
792
|
+
inputs,
|
|
793
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceDeployer(address),
|
|
794
|
+
});
|
|
999
795
|
}
|
|
1000
796
|
|
|
1001
797
|
// eslint-disable-next-line camelcase
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
toSingle(instance.initializationHash),
|
|
1009
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
1010
|
-
toSingle(new Fr(1)),
|
|
1011
|
-
]);
|
|
798
|
+
aztec_avm_getContractInstanceClassId(...inputs: ForeignCallArgs) {
|
|
799
|
+
return callTxeHandler({
|
|
800
|
+
oracle: 'aztec_avm_getContractInstanceClassId',
|
|
801
|
+
inputs,
|
|
802
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceClassId(address),
|
|
803
|
+
});
|
|
1012
804
|
}
|
|
1013
805
|
|
|
1014
806
|
// eslint-disable-next-line camelcase
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
807
|
+
aztec_avm_getContractInstanceInitializationHash(...inputs: ForeignCallArgs) {
|
|
808
|
+
return callTxeHandler({
|
|
809
|
+
oracle: 'aztec_avm_getContractInstanceInitializationHash',
|
|
810
|
+
inputs,
|
|
811
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceInitializationHash(address),
|
|
812
|
+
});
|
|
1019
813
|
}
|
|
1020
814
|
|
|
1021
815
|
// eslint-disable-next-line camelcase
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
816
|
+
aztec_avm_getContractInstanceImmutablesHash(...inputs: ForeignCallArgs) {
|
|
817
|
+
return callTxeHandler({
|
|
818
|
+
oracle: 'aztec_avm_getContractInstanceImmutablesHash',
|
|
819
|
+
inputs,
|
|
820
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceImmutablesHash(address),
|
|
821
|
+
});
|
|
1028
822
|
}
|
|
1029
823
|
|
|
1030
824
|
// eslint-disable-next-line camelcase
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
825
|
+
aztec_avm_sender() {
|
|
826
|
+
return callTxeHandler({
|
|
827
|
+
oracle: 'aztec_avm_sender',
|
|
828
|
+
inputs: [],
|
|
829
|
+
handler: () => this.handlerAsAvm().sender(),
|
|
830
|
+
});
|
|
1037
831
|
}
|
|
1038
832
|
|
|
1039
833
|
// eslint-disable-next-line camelcase
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
834
|
+
aztec_avm_emitNullifier(...inputs: ForeignCallArgs) {
|
|
835
|
+
return callTxeHandler({
|
|
836
|
+
oracle: 'aztec_avm_emitNullifier',
|
|
837
|
+
inputs,
|
|
838
|
+
handler: ([nullifier]) => this.handlerAsAvm().emitNullifier(nullifier),
|
|
839
|
+
});
|
|
1046
840
|
}
|
|
1047
841
|
|
|
1048
842
|
// eslint-disable-next-line camelcase
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
843
|
+
aztec_avm_emitNoteHash(...inputs: ForeignCallArgs) {
|
|
844
|
+
return callTxeHandler({
|
|
845
|
+
oracle: 'aztec_avm_emitNoteHash',
|
|
846
|
+
inputs,
|
|
847
|
+
handler: ([noteHash]) => this.handlerAsAvm().emitNoteHash(noteHash),
|
|
848
|
+
});
|
|
1053
849
|
}
|
|
1054
850
|
|
|
1055
851
|
// eslint-disable-next-line camelcase
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
852
|
+
aztec_avm_nullifierExists(...inputs: ForeignCallArgs) {
|
|
853
|
+
return callTxeHandler({
|
|
854
|
+
oracle: 'aztec_avm_nullifierExists',
|
|
855
|
+
inputs,
|
|
856
|
+
handler: ([siloedNullifier]) => this.handlerAsAvm().nullifierExists(siloedNullifier),
|
|
857
|
+
});
|
|
1060
858
|
}
|
|
1061
859
|
|
|
1062
860
|
// eslint-disable-next-line camelcase
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
861
|
+
aztec_avm_address() {
|
|
862
|
+
return callTxeHandler({
|
|
863
|
+
oracle: 'aztec_avm_address',
|
|
864
|
+
inputs: [],
|
|
865
|
+
handler: () => this.handlerAsAvm().address(),
|
|
866
|
+
});
|
|
1067
867
|
}
|
|
1068
868
|
|
|
1069
869
|
// eslint-disable-next-line camelcase
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
870
|
+
aztec_avm_blockNumber() {
|
|
871
|
+
return callTxeHandler({
|
|
872
|
+
oracle: 'aztec_avm_blockNumber',
|
|
873
|
+
inputs: [],
|
|
874
|
+
handler: () => this.handlerAsAvm().blockNumber(),
|
|
875
|
+
});
|
|
1074
876
|
}
|
|
1075
877
|
|
|
1076
878
|
// eslint-disable-next-line camelcase
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
879
|
+
aztec_avm_timestamp() {
|
|
880
|
+
return callTxeHandler({
|
|
881
|
+
oracle: 'aztec_avm_timestamp',
|
|
882
|
+
inputs: [],
|
|
883
|
+
handler: () => this.handlerAsAvm().timestamp(),
|
|
884
|
+
});
|
|
1081
885
|
}
|
|
1082
886
|
|
|
1083
887
|
// eslint-disable-next-line camelcase
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
888
|
+
aztec_avm_isStaticCall() {
|
|
889
|
+
return callTxeHandler({
|
|
890
|
+
oracle: 'aztec_avm_isStaticCall',
|
|
891
|
+
inputs: [],
|
|
892
|
+
handler: () => this.handlerAsAvm().isStaticCall(),
|
|
893
|
+
});
|
|
1088
894
|
}
|
|
1089
895
|
|
|
1090
896
|
// eslint-disable-next-line camelcase
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
897
|
+
aztec_avm_chainId() {
|
|
898
|
+
return callTxeHandler({
|
|
899
|
+
oracle: 'aztec_avm_chainId',
|
|
900
|
+
inputs: [],
|
|
901
|
+
handler: () => this.handlerAsAvm().chainId(),
|
|
902
|
+
});
|
|
1095
903
|
}
|
|
1096
904
|
|
|
1097
905
|
// eslint-disable-next-line camelcase
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
906
|
+
aztec_avm_version() {
|
|
907
|
+
return callTxeHandler({
|
|
908
|
+
oracle: 'aztec_avm_version',
|
|
909
|
+
inputs: [],
|
|
910
|
+
handler: () => this.handlerAsAvm().version(),
|
|
911
|
+
});
|
|
1102
912
|
}
|
|
1103
913
|
|
|
1104
914
|
// eslint-disable-next-line camelcase
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
) {
|
|
1112
|
-
throw new Error(
|
|
1113
|
-
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
1114
|
-
);
|
|
915
|
+
aztec_avm_returndataSize() {
|
|
916
|
+
return callTxeHandler({
|
|
917
|
+
oracle: 'aztec_avm_returndataSize',
|
|
918
|
+
inputs: [],
|
|
919
|
+
handler: () => this.handlerAsAvm().returndataSize(),
|
|
920
|
+
});
|
|
1115
921
|
}
|
|
1116
922
|
|
|
1117
923
|
// eslint-disable-next-line camelcase
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
) {
|
|
1125
|
-
throw new Error(
|
|
1126
|
-
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
1127
|
-
);
|
|
924
|
+
aztec_avm_returndataCopy(...inputs: ForeignCallArgs) {
|
|
925
|
+
return callTxeHandler({
|
|
926
|
+
oracle: 'aztec_avm_returndataCopy',
|
|
927
|
+
inputs,
|
|
928
|
+
handler: ([rdOffset, copySize]) => this.handlerAsAvm().returndataCopy(rdOffset, copySize),
|
|
929
|
+
});
|
|
1128
930
|
}
|
|
1129
931
|
|
|
1130
932
|
// eslint-disable-next-line camelcase
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
async aztec_txe_privateCallNewFlow(
|
|
1139
|
-
foreignFrom: ForeignCallSingle,
|
|
1140
|
-
foreignTargetContractAddress: ForeignCallSingle,
|
|
1141
|
-
foreignFunctionSelector: ForeignCallSingle,
|
|
1142
|
-
foreignArgs: ForeignCallArray,
|
|
1143
|
-
foreignArgsHash: ForeignCallSingle,
|
|
1144
|
-
foreignIsStaticCall: ForeignCallSingle,
|
|
1145
|
-
) {
|
|
1146
|
-
const from = addressFromSingle(foreignFrom);
|
|
1147
|
-
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
1148
|
-
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1149
|
-
const args = fromArray(foreignArgs);
|
|
1150
|
-
const argsHash = fromSingle(foreignArgsHash);
|
|
1151
|
-
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1152
|
-
|
|
1153
|
-
const returnValues = await this.handlerAsTxe().privateCallNewFlow(
|
|
1154
|
-
from,
|
|
1155
|
-
targetContractAddress,
|
|
1156
|
-
functionSelector,
|
|
1157
|
-
args,
|
|
1158
|
-
argsHash,
|
|
1159
|
-
isStaticCall,
|
|
1160
|
-
this.stateHandler.getCurrentJob(),
|
|
1161
|
-
);
|
|
1162
|
-
|
|
1163
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1164
|
-
await this.stateHandler.cycleJob();
|
|
1165
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
// eslint-disable-next-line camelcase
|
|
1169
|
-
async aztec_txe_executeUtilityFunction(
|
|
1170
|
-
foreignTargetContractAddress: ForeignCallSingle,
|
|
1171
|
-
foreignFunctionSelector: ForeignCallSingle,
|
|
1172
|
-
foreignArgs: ForeignCallArray,
|
|
1173
|
-
) {
|
|
1174
|
-
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
1175
|
-
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1176
|
-
const args = fromArray(foreignArgs);
|
|
1177
|
-
|
|
1178
|
-
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1179
|
-
targetContractAddress,
|
|
1180
|
-
functionSelector,
|
|
1181
|
-
args,
|
|
1182
|
-
this.stateHandler.getCurrentJob(),
|
|
1183
|
-
);
|
|
1184
|
-
|
|
1185
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1186
|
-
await this.stateHandler.cycleJob();
|
|
1187
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
// eslint-disable-next-line camelcase
|
|
1191
|
-
async aztec_txe_publicCallNewFlow(
|
|
1192
|
-
foreignFrom: ForeignCallSingle,
|
|
1193
|
-
foreignAddress: ForeignCallSingle,
|
|
1194
|
-
foreignCalldata: ForeignCallArray,
|
|
1195
|
-
foreignIsStaticCall: ForeignCallSingle,
|
|
1196
|
-
) {
|
|
1197
|
-
const from = addressFromSingle(foreignFrom);
|
|
1198
|
-
const address = addressFromSingle(foreignAddress);
|
|
1199
|
-
const calldata = fromArray(foreignCalldata);
|
|
1200
|
-
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1201
|
-
|
|
1202
|
-
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1203
|
-
|
|
1204
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1205
|
-
await this.stateHandler.cycleJob();
|
|
1206
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
// eslint-disable-next-line camelcase
|
|
1210
|
-
async aztec_prv_getSenderForTags() {
|
|
1211
|
-
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
1212
|
-
|
|
1213
|
-
// Return a Noir Option struct with `some` and `value` fields
|
|
1214
|
-
if (sender === undefined) {
|
|
1215
|
-
// No sender found, return Option with some=0 and value=0
|
|
1216
|
-
return toForeignCallResult([toSingle(0), toSingle(0)]);
|
|
1217
|
-
} else {
|
|
1218
|
-
// Sender found, return Option with some=1 and value=sender address
|
|
1219
|
-
return toForeignCallResult([toSingle(1), toSingle(sender)]);
|
|
1220
|
-
}
|
|
933
|
+
aztec_avm_call(...inputs: ForeignCallArgs) {
|
|
934
|
+
return callTxeHandler({
|
|
935
|
+
oracle: 'aztec_avm_call',
|
|
936
|
+
inputs,
|
|
937
|
+
handler: ([l2Gas, daGas, address, argsLength, args]) =>
|
|
938
|
+
this.handlerAsAvm().call(l2Gas, daGas, address, argsLength, args),
|
|
939
|
+
});
|
|
1221
940
|
}
|
|
1222
941
|
|
|
1223
942
|
// eslint-disable-next-line camelcase
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
943
|
+
aztec_avm_staticCall(...inputs: ForeignCallArgs) {
|
|
944
|
+
return callTxeHandler({
|
|
945
|
+
oracle: 'aztec_avm_staticCall',
|
|
946
|
+
inputs,
|
|
947
|
+
handler: ([l2Gas, daGas, address, argsLength, args]) =>
|
|
948
|
+
this.handlerAsAvm().staticCall(l2Gas, daGas, address, argsLength, args),
|
|
949
|
+
});
|
|
1230
950
|
}
|
|
1231
951
|
|
|
1232
952
|
// eslint-disable-next-line camelcase
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
953
|
+
aztec_avm_successCopy() {
|
|
954
|
+
return callTxeHandler({
|
|
955
|
+
oracle: 'aztec_avm_successCopy',
|
|
956
|
+
inputs: [],
|
|
957
|
+
handler: () => this.handlerAsAvm().successCopy(),
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize->delegate->deserialize.
|
|
962
|
+
// eslint-disable-next-line camelcase
|
|
963
|
+
aztec_txe_privateCallNewFlow(...inputs: ForeignCallArgs) {
|
|
964
|
+
return callTxeHandler({
|
|
965
|
+
oracle: 'aztec_txe_privateCallNewFlow',
|
|
966
|
+
inputs,
|
|
967
|
+
handler: async ([
|
|
968
|
+
from,
|
|
969
|
+
targetContractAddress,
|
|
970
|
+
functionSelector,
|
|
971
|
+
args,
|
|
972
|
+
argsHash,
|
|
973
|
+
isStaticCall,
|
|
974
|
+
additionalScopes,
|
|
975
|
+
authorizedUtilityCallTargets,
|
|
976
|
+
gasSettings,
|
|
977
|
+
]) => {
|
|
978
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
979
|
+
const { returnValues, offchainEffects } = await this.handlerAsTxe().privateCallNewFlow(
|
|
980
|
+
from?.value,
|
|
981
|
+
targetContractAddress,
|
|
982
|
+
functionSelector,
|
|
983
|
+
args,
|
|
984
|
+
argsHash,
|
|
985
|
+
isStaticCall,
|
|
986
|
+
additionalScopes,
|
|
987
|
+
this.stateHandler.getCurrentJob(),
|
|
988
|
+
authorizedUtilityCallTargets,
|
|
989
|
+
gasSettings,
|
|
990
|
+
);
|
|
991
|
+
|
|
992
|
+
// Private execution collects offchain effects inside PXE's PrivateExecutionOracle rather than
|
|
993
|
+
// round-tripping them through `aztec_utl_emitOffchainEffect`, so the session buffer is empty
|
|
994
|
+
// at this point. Drain the effects from the execution tree into the session buffer so the
|
|
995
|
+
// next `env.offchain_messages()` call in the test sees them.
|
|
996
|
+
for (const data of offchainEffects) {
|
|
997
|
+
this.stateHandler.recordOffchainEffect(data);
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1001
|
+
await this.stateHandler.cycleJob();
|
|
1002
|
+
|
|
1003
|
+
if (isStaticCall) {
|
|
1004
|
+
// Static calls revert their checkpoint and mine no block, so there is no tx hash to tag
|
|
1005
|
+
// offchain effects with. Querying `getLastTxEffects()` here would return an unrelated
|
|
1006
|
+
// predecessor tx.
|
|
1007
|
+
return { result: returnValues };
|
|
1008
|
+
}
|
|
1009
|
+
const { txHash } = await this.handlerAsTxe().getLastTxEffects();
|
|
1010
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
return returnValues;
|
|
1014
|
+
},
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize->delegate->deserialize.
|
|
1019
|
+
// eslint-disable-next-line camelcase
|
|
1020
|
+
aztec_txe_executeUtilityFunction(...inputs: ForeignCallArgs) {
|
|
1021
|
+
return callTxeHandler({
|
|
1022
|
+
oracle: 'aztec_txe_executeUtilityFunction',
|
|
1023
|
+
inputs,
|
|
1024
|
+
handler: async ([targetContractAddress, functionSelector, args, authorizedUtilityCallTargets]) => {
|
|
1025
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
1026
|
+
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1027
|
+
targetContractAddress,
|
|
1028
|
+
functionSelector,
|
|
1029
|
+
args,
|
|
1030
|
+
this.stateHandler.getCurrentJob(),
|
|
1031
|
+
authorizedUtilityCallTargets,
|
|
1032
|
+
);
|
|
1033
|
+
|
|
1034
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1035
|
+
await this.stateHandler.cycleJob();
|
|
1036
|
+
|
|
1037
|
+
return { result: returnValues };
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
return returnValues;
|
|
1041
|
+
},
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// TODO(F-674): Move orchestration logic into the handler so the transport layer is pure serialize->delegate->deserialize.
|
|
1046
|
+
// eslint-disable-next-line camelcase
|
|
1047
|
+
aztec_txe_publicCallNewFlow(...inputs: ForeignCallArgs) {
|
|
1048
|
+
return callTxeHandler({
|
|
1049
|
+
oracle: 'aztec_txe_publicCallNewFlow',
|
|
1050
|
+
inputs,
|
|
1051
|
+
handler: async ([from, address, calldata, isStaticCall, gasSettings]) => {
|
|
1052
|
+
const returnValues = await this.stateHandler.withTopLevelCallTracking(async () => {
|
|
1053
|
+
const returnValues = await this.handlerAsTxe().publicCallNewFlow(
|
|
1054
|
+
from?.value,
|
|
1055
|
+
address,
|
|
1056
|
+
calldata,
|
|
1057
|
+
isStaticCall,
|
|
1058
|
+
gasSettings,
|
|
1059
|
+
);
|
|
1060
|
+
|
|
1061
|
+
// TODO(F-335): Avoid doing the following call here.
|
|
1062
|
+
await this.stateHandler.cycleJob();
|
|
1063
|
+
|
|
1064
|
+
if (isStaticCall) {
|
|
1065
|
+
// See equivalent branch in `aztec_txe_privateCallNewFlow`.
|
|
1066
|
+
return { result: returnValues };
|
|
1067
|
+
}
|
|
1068
|
+
const { txHash } = await this.handlerAsTxe().getLastTxEffects();
|
|
1069
|
+
return { result: returnValues, txHash: txHash.hash };
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
return returnValues;
|
|
1073
|
+
},
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// eslint-disable-next-line camelcase
|
|
1078
|
+
aztec_prv_getSenderForTags() {
|
|
1079
|
+
return callTxeHandler({
|
|
1080
|
+
oracle: 'aztec_prv_getSenderForTags',
|
|
1081
|
+
inputs: [],
|
|
1082
|
+
handler: () => this.handlerAsPrivate().getSenderForTags(),
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// eslint-disable-next-line camelcase
|
|
1087
|
+
aztec_prv_getAppTaggingSecret(...inputs: ForeignCallArgs) {
|
|
1088
|
+
return callTxeHandler({
|
|
1089
|
+
oracle: 'aztec_prv_getAppTaggingSecret',
|
|
1090
|
+
inputs,
|
|
1091
|
+
handler: ([sender, recipient]) => this.handlerAsPrivate().getAppTaggingSecret(sender, recipient),
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// eslint-disable-next-line camelcase
|
|
1096
|
+
aztec_prv_getNextTaggingIndex(...inputs: ForeignCallArgs) {
|
|
1097
|
+
return callTxeHandler({
|
|
1098
|
+
oracle: 'aztec_prv_getNextTaggingIndex',
|
|
1099
|
+
inputs,
|
|
1100
|
+
handler: ([secret, deliveryMode]) => this.handlerAsPrivate().getNextTaggingIndex(secret, deliveryMode),
|
|
1101
|
+
});
|
|
1240
1102
|
}
|
|
1241
1103
|
}
|