@aztec/txe 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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-2FGZE6YL.js +265 -0
- package/dest/chunk-2FGZE6YL.js.map +7 -0
- package/dest/chunk-6HRVNWJU.js +304 -0
- package/dest/chunk-6HRVNWJU.js.map +7 -0
- package/dest/chunk-BJVAAXNA.js +3 -0
- package/dest/chunk-BJVAAXNA.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 +38642 -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 +27 -13
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +129 -52
- 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 -266
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +699 -730
- 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 +24 -14
- package/dest/state_machine/dummy_p2p_client.d.ts +11 -6
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +11 -2
- 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 +16 -2
- package/dest/state_machine/mock_epoch_cache.d.ts +1 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +0 -6
- 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 +164 -38
- package/dest/utils/encoding.d.ts +191 -0
- package/dest/utils/encoding.d.ts.map +1 -0
- package/dest/{util → utils}/encoding.js +3 -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/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 +157 -62
- 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 +774 -1043
- package/src/state_machine/archiver.ts +37 -16
- package/src/state_machine/dummy_p2p_client.ts +25 -9
- package/src/state_machine/index.ts +17 -4
- package/src/state_machine/mock_epoch_cache.ts +0 -8
- package/src/state_machine/synchronizer.ts +1 -1
- package/src/txe_session.ts +269 -39
- package/src/{util → utils}/encoding.ts +3 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/worker.ts +98 -0
- package/dest/util/encoding.d.ts +0 -790
- 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/dest/{util → utils}/txe_public_contract_data_source.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/{util → utils}/txe_public_contract_data_source.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';
|
|
1
|
+
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from '@aztec/pxe/simulator';
|
|
13
2
|
|
|
14
3
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
4
|
+
import { callTxeHandler } from './oracle/txe_oracle_registry.js';
|
|
15
5
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
16
|
-
import {
|
|
17
|
-
type ForeignCallArray,
|
|
18
|
-
type ForeignCallSingle,
|
|
19
|
-
addressFromSingle,
|
|
20
|
-
arrayOfArraysToBoundedVecOfArrays,
|
|
21
|
-
arrayToBoundedVec,
|
|
22
|
-
blockHashFromSingle,
|
|
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,842 +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
|
-
|
|
273
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
274
222
|
}
|
|
275
223
|
|
|
276
224
|
// eslint-disable-next-line camelcase
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
225
|
+
aztec_misc_getRandomField() {
|
|
226
|
+
return callTxeHandler({
|
|
227
|
+
oracle: 'aztec_misc_getRandomField',
|
|
228
|
+
inputs: [],
|
|
229
|
+
handler: () => this.handlerAsMisc().getRandomField(),
|
|
230
|
+
});
|
|
281
231
|
}
|
|
282
232
|
|
|
283
233
|
// eslint-disable-next-line camelcase
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
234
|
+
aztec_txe_getLastBlockTimestamp() {
|
|
235
|
+
return callTxeHandler({
|
|
236
|
+
oracle: 'aztec_txe_getLastBlockTimestamp',
|
|
237
|
+
inputs: [],
|
|
238
|
+
handler: () => this.handlerAsTxe().getLastBlockTimestamp(),
|
|
239
|
+
});
|
|
288
240
|
}
|
|
289
241
|
|
|
290
242
|
// eslint-disable-next-line camelcase
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
...arrayToBoundedVec(toArray(nullifiers), MAX_NULLIFIERS_PER_TX),
|
|
298
|
-
]);
|
|
243
|
+
aztec_txe_getLastTxEffects() {
|
|
244
|
+
return callTxeHandler({
|
|
245
|
+
oracle: 'aztec_txe_getLastTxEffects',
|
|
246
|
+
inputs: [],
|
|
247
|
+
handler: () => this.handlerAsTxe().getLastTxEffects(),
|
|
248
|
+
});
|
|
299
249
|
}
|
|
300
250
|
|
|
301
251
|
// eslint-disable-next-line camelcase
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
309
|
-
const scope = addressFromSingle(foreignScope);
|
|
310
|
-
|
|
311
|
-
// TODO(F-335): Avoid doing the following 2 calls here.
|
|
312
|
-
{
|
|
313
|
-
await this.handlerAsTxe().syncContractNonOracleMethod(contractAddress, scope, this.stateHandler.getCurrentJob());
|
|
314
|
-
// We cycle job to commit the stores after the contract sync.
|
|
315
|
-
await this.stateHandler.cycleJob();
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const events = await this.handlerAsTxe().getPrivateEvents(selector, contractAddress, scope);
|
|
319
|
-
|
|
320
|
-
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
321
|
-
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (events.some(e => e.length > MAX_EVENT_LEN)) {
|
|
325
|
-
throw new Error(`Some private event has length larger than maxLen ${MAX_EVENT_LEN}`);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// This is a workaround as Noir does not currently let us return nested structs with arrays. We instead return a raw
|
|
329
|
-
// multidimensional array in get_private_events_oracle and create the BoundedVecs here.
|
|
330
|
-
const rawArrayStorage = events
|
|
331
|
-
.map(e => e.concat(Array(MAX_EVENT_LEN - e.length).fill(new Fr(0))))
|
|
332
|
-
.concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(Array(MAX_EVENT_LEN).fill(new Fr(0))))
|
|
333
|
-
.flat();
|
|
334
|
-
const eventLengths = events
|
|
335
|
-
.map(e => new Fr(e.length))
|
|
336
|
-
.concat(Array(MAX_PRIVATE_EVENTS_PER_TXE_QUERY - events.length).fill(new Fr(0)));
|
|
337
|
-
const queryLength = new Fr(events.length);
|
|
338
|
-
|
|
339
|
-
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
|
+
});
|
|
340
258
|
}
|
|
341
259
|
|
|
342
260
|
// eslint-disable-next-line camelcase
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return toForeignCallResult([]);
|
|
261
|
+
aztec_txe_getLastCallContext() {
|
|
262
|
+
return callTxeHandler({
|
|
263
|
+
oracle: 'aztec_txe_getLastCallContext',
|
|
264
|
+
inputs: [],
|
|
265
|
+
handler: () => this.stateHandler.getLastCallContext(),
|
|
266
|
+
});
|
|
350
267
|
}
|
|
351
268
|
|
|
352
269
|
// eslint-disable-next-line camelcase
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
+
}
|
|
357
308
|
|
|
358
|
-
|
|
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
|
+
});
|
|
359
381
|
}
|
|
360
382
|
|
|
361
|
-
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
362
|
-
// When the argument is an array, we add the field length manually to the signature.
|
|
363
383
|
// eslint-disable-next-line camelcase
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const message = fromArray(foreignMessage)
|
|
372
|
-
.map(field => String.fromCharCode(field.toNumber()))
|
|
373
|
-
.join('');
|
|
374
|
-
const fields = fromArray(foreignFields);
|
|
375
|
-
|
|
376
|
-
await this.handlerAsMisc().log(level, message, fields);
|
|
377
|
-
|
|
378
|
-
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
|
+
});
|
|
379
391
|
}
|
|
380
392
|
|
|
381
393
|
// eslint-disable-next-line camelcase
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
390
|
-
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
391
|
-
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
392
|
-
|
|
393
|
-
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
394
|
-
blockHash,
|
|
395
|
-
contractAddress,
|
|
396
|
-
startStorageSlot,
|
|
397
|
-
numberOfElements,
|
|
398
|
-
);
|
|
399
|
-
|
|
400
|
-
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
|
+
});
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
// eslint-disable-next-line camelcase
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (!witness) {
|
|
411
|
-
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
412
|
-
}
|
|
413
|
-
return toForeignCallResult(witness.toNoirRepresentation());
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// eslint-disable-next-line camelcase
|
|
417
|
-
async aztec_utl_getNotes(
|
|
418
|
-
foreignOwnerIsSome: ForeignCallSingle,
|
|
419
|
-
foreignOwnerValue: ForeignCallSingle,
|
|
420
|
-
foreignStorageSlot: ForeignCallSingle,
|
|
421
|
-
foreignNumSelects: ForeignCallSingle,
|
|
422
|
-
foreignSelectByIndexes: ForeignCallArray,
|
|
423
|
-
foreignSelectByOffsets: ForeignCallArray,
|
|
424
|
-
foreignSelectByLengths: ForeignCallArray,
|
|
425
|
-
foreignSelectValues: ForeignCallArray,
|
|
426
|
-
foreignSelectComparators: ForeignCallArray,
|
|
427
|
-
foreignSortByIndexes: ForeignCallArray,
|
|
428
|
-
foreignSortByOffsets: ForeignCallArray,
|
|
429
|
-
foreignSortByLengths: ForeignCallArray,
|
|
430
|
-
foreignSortOrder: ForeignCallArray,
|
|
431
|
-
foreignLimit: ForeignCallSingle,
|
|
432
|
-
foreignOffset: ForeignCallSingle,
|
|
433
|
-
foreignStatus: ForeignCallSingle,
|
|
434
|
-
foreignMaxNotes: ForeignCallSingle,
|
|
435
|
-
foreignPackedHintedNoteLength: ForeignCallSingle,
|
|
436
|
-
) {
|
|
437
|
-
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
438
|
-
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
439
|
-
? AztecAddress.fromField(fromSingle(foreignOwnerValue))
|
|
440
|
-
: undefined;
|
|
441
|
-
const storageSlot = fromSingle(foreignStorageSlot);
|
|
442
|
-
const numSelects = fromSingle(foreignNumSelects).toNumber();
|
|
443
|
-
const selectByIndexes = fromArray(foreignSelectByIndexes).map(fr => fr.toNumber());
|
|
444
|
-
const selectByOffsets = fromArray(foreignSelectByOffsets).map(fr => fr.toNumber());
|
|
445
|
-
const selectByLengths = fromArray(foreignSelectByLengths).map(fr => fr.toNumber());
|
|
446
|
-
const selectValues = fromArray(foreignSelectValues);
|
|
447
|
-
const selectComparators = fromArray(foreignSelectComparators).map(fr => fr.toNumber());
|
|
448
|
-
const sortByIndexes = fromArray(foreignSortByIndexes).map(fr => fr.toNumber());
|
|
449
|
-
const sortByOffsets = fromArray(foreignSortByOffsets).map(fr => fr.toNumber());
|
|
450
|
-
const sortByLengths = fromArray(foreignSortByLengths).map(fr => fr.toNumber());
|
|
451
|
-
const sortOrder = fromArray(foreignSortOrder).map(fr => fr.toNumber());
|
|
452
|
-
const limit = fromSingle(foreignLimit).toNumber();
|
|
453
|
-
const offset = fromSingle(foreignOffset).toNumber();
|
|
454
|
-
const status = fromSingle(foreignStatus).toNumber();
|
|
455
|
-
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
456
|
-
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
457
|
-
|
|
458
|
-
const noteDatas = await this.handlerAsUtility().getNotes(
|
|
459
|
-
owner,
|
|
460
|
-
storageSlot,
|
|
461
|
-
numSelects,
|
|
462
|
-
selectByIndexes,
|
|
463
|
-
selectByOffsets,
|
|
464
|
-
selectByLengths,
|
|
465
|
-
selectValues,
|
|
466
|
-
selectComparators,
|
|
467
|
-
sortByIndexes,
|
|
468
|
-
sortByOffsets,
|
|
469
|
-
sortByLengths,
|
|
470
|
-
sortOrder,
|
|
471
|
-
limit,
|
|
472
|
-
offset,
|
|
473
|
-
status,
|
|
474
|
-
);
|
|
475
|
-
|
|
476
|
-
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
477
|
-
packAsHintedNote({
|
|
478
|
-
contractAddress: noteData.contractAddress,
|
|
479
|
-
owner: noteData.owner,
|
|
480
|
-
randomness: noteData.randomness,
|
|
481
|
-
storageSlot: noteData.storageSlot,
|
|
482
|
-
noteNonce: noteData.noteNonce,
|
|
483
|
-
isPending: noteData.isPending,
|
|
484
|
-
note: noteData.note,
|
|
485
|
-
}),
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
489
|
-
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map(subArray =>
|
|
490
|
-
subArray.map(toSingle),
|
|
491
|
-
);
|
|
492
|
-
|
|
493
|
-
// At last we convert the array of arrays to a bounded vec of arrays
|
|
494
|
-
return toForeignCallResult(
|
|
495
|
-
arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength),
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// eslint-disable-next-line camelcase
|
|
500
|
-
aztec_prv_notifyCreatedNote(
|
|
501
|
-
foreignOwner: ForeignCallSingle,
|
|
502
|
-
foreignStorageSlot: ForeignCallSingle,
|
|
503
|
-
foreignRandomness: ForeignCallSingle,
|
|
504
|
-
foreignNoteTypeId: ForeignCallSingle,
|
|
505
|
-
foreignNote: ForeignCallArray,
|
|
506
|
-
foreignNoteHash: ForeignCallSingle,
|
|
507
|
-
foreignCounter: ForeignCallSingle,
|
|
508
|
-
) {
|
|
509
|
-
const owner = addressFromSingle(foreignOwner);
|
|
510
|
-
const storageSlot = fromSingle(foreignStorageSlot);
|
|
511
|
-
const randomness = fromSingle(foreignRandomness);
|
|
512
|
-
const noteTypeId = NoteSelector.fromField(fromSingle(foreignNoteTypeId));
|
|
513
|
-
const note = fromArray(foreignNote);
|
|
514
|
-
const noteHash = fromSingle(foreignNoteHash);
|
|
515
|
-
const counter = fromSingle(foreignCounter).toNumber();
|
|
516
|
-
|
|
517
|
-
this.handlerAsPrivate().notifyCreatedNote(owner, storageSlot, randomness, noteTypeId, note, noteHash, counter);
|
|
518
|
-
|
|
519
|
-
return toForeignCallResult([]);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// eslint-disable-next-line camelcase
|
|
523
|
-
async aztec_prv_notifyNullifiedNote(
|
|
524
|
-
foreignInnerNullifier: ForeignCallSingle,
|
|
525
|
-
foreignNoteHash: ForeignCallSingle,
|
|
526
|
-
foreignCounter: ForeignCallSingle,
|
|
527
|
-
) {
|
|
528
|
-
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
529
|
-
const noteHash = fromSingle(foreignNoteHash);
|
|
530
|
-
const counter = fromSingle(foreignCounter).toNumber();
|
|
531
|
-
|
|
532
|
-
await this.handlerAsPrivate().notifyNullifiedNote(innerNullifier, noteHash, counter);
|
|
533
|
-
|
|
534
|
-
return toForeignCallResult([]);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// eslint-disable-next-line camelcase
|
|
538
|
-
async aztec_prv_notifyCreatedNullifier(foreignInnerNullifier: ForeignCallSingle) {
|
|
539
|
-
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
540
|
-
|
|
541
|
-
await this.handlerAsPrivate().notifyCreatedNullifier(innerNullifier);
|
|
542
|
-
|
|
543
|
-
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
|
+
});
|
|
544
410
|
}
|
|
545
411
|
|
|
546
412
|
// eslint-disable-next-line camelcase
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const isPending = await this.handlerAsPrivate().isNullifierPending(innerNullifier, contractAddress);
|
|
555
|
-
|
|
556
|
-
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
|
+
});
|
|
557
420
|
}
|
|
558
421
|
|
|
559
422
|
// eslint-disable-next-line camelcase
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
423
|
+
aztec_utl_doesNullifierExist(...inputs: ForeignCallArgs) {
|
|
424
|
+
return callTxeHandler({
|
|
425
|
+
oracle: 'aztec_utl_doesNullifierExist',
|
|
426
|
+
inputs,
|
|
427
|
+
handler: ([innerNullifier]) => this.handlerAsUtility().doesNullifierExist(innerNullifier),
|
|
428
|
+
});
|
|
566
429
|
}
|
|
567
430
|
|
|
568
431
|
// eslint-disable-next-line camelcase
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
[
|
|
576
|
-
instance.salt,
|
|
577
|
-
instance.deployer.toField(),
|
|
578
|
-
instance.currentContractClassId,
|
|
579
|
-
instance.initializationHash,
|
|
580
|
-
...instance.publicKeys.toFields(),
|
|
581
|
-
].map(toSingle),
|
|
582
|
-
);
|
|
432
|
+
aztec_utl_getContractInstance(...inputs: ForeignCallArgs) {
|
|
433
|
+
return callTxeHandler({
|
|
434
|
+
oracle: 'aztec_utl_getContractInstance',
|
|
435
|
+
inputs,
|
|
436
|
+
handler: ([address]) => this.handlerAsUtility().getContractInstance(address),
|
|
437
|
+
});
|
|
583
438
|
}
|
|
584
439
|
|
|
585
440
|
// eslint-disable-next-line camelcase
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
593
|
-
if (result === undefined) {
|
|
594
|
-
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
595
|
-
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
596
|
-
} else {
|
|
597
|
-
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
598
|
-
return toForeignCallResult([
|
|
599
|
-
toSingle(new Fr(1)),
|
|
600
|
-
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
601
|
-
]);
|
|
602
|
-
}
|
|
441
|
+
aztec_utl_getPublicKeysAndPartialAddress(...inputs: ForeignCallArgs) {
|
|
442
|
+
return callTxeHandler({
|
|
443
|
+
oracle: 'aztec_utl_getPublicKeysAndPartialAddress',
|
|
444
|
+
inputs,
|
|
445
|
+
handler: ([address]) => this.handlerAsUtility().getPublicKeysAndPartialAddress(address),
|
|
446
|
+
});
|
|
603
447
|
}
|
|
604
448
|
|
|
605
449
|
// eslint-disable-next-line camelcase
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
450
|
+
aztec_utl_getKeyValidationRequest(...inputs: ForeignCallArgs) {
|
|
451
|
+
return callTxeHandler({
|
|
452
|
+
oracle: 'aztec_utl_getKeyValidationRequest',
|
|
453
|
+
inputs,
|
|
454
|
+
handler: ([pkMHash]) => this.handlerAsUtility().getKeyValidationRequest(pkMHash),
|
|
455
|
+
});
|
|
612
456
|
}
|
|
613
457
|
|
|
614
458
|
// eslint-disable-next-line camelcase
|
|
615
|
-
aztec_prv_callPrivateFunction(
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
+
});
|
|
625
472
|
}
|
|
626
473
|
|
|
627
474
|
// eslint-disable-next-line camelcase
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(blockHash, nullifier);
|
|
636
|
-
|
|
637
|
-
if (!witness) {
|
|
638
|
-
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
639
|
-
}
|
|
640
|
-
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
|
+
});
|
|
641
481
|
}
|
|
642
482
|
|
|
643
483
|
// eslint-disable-next-line camelcase
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
throw new Error(`Auth witness not found for message hash ${messageHash}.`);
|
|
651
|
-
}
|
|
652
|
-
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
|
+
});
|
|
653
490
|
}
|
|
654
491
|
|
|
655
492
|
// eslint-disable-next-line camelcase
|
|
656
|
-
|
|
657
|
-
|
|
493
|
+
aztec_prv_assertValidPublicCalldata(...inputs: ForeignCallArgs) {
|
|
494
|
+
return callTxeHandler({
|
|
495
|
+
oracle: 'aztec_prv_assertValidPublicCalldata',
|
|
496
|
+
inputs,
|
|
497
|
+
handler: ([calldataHash]) => this.handlerAsPrivate().assertValidPublicCalldata(calldataHash),
|
|
498
|
+
});
|
|
658
499
|
}
|
|
659
500
|
|
|
660
501
|
// eslint-disable-next-line camelcase
|
|
661
|
-
|
|
662
|
-
|
|
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
|
+
});
|
|
663
509
|
}
|
|
664
510
|
|
|
665
511
|
// eslint-disable-next-line camelcase
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
512
|
+
aztec_prv_isExecutionInRevertiblePhase(...inputs: ForeignCallArgs) {
|
|
513
|
+
return callTxeHandler({
|
|
514
|
+
oracle: 'aztec_prv_isExecutionInRevertiblePhase',
|
|
515
|
+
inputs,
|
|
516
|
+
handler: ([sideEffectCounter]) => this.handlerAsPrivate().isExecutionInRevertiblePhase(sideEffectCounter),
|
|
517
|
+
});
|
|
670
518
|
}
|
|
671
519
|
|
|
672
520
|
// eslint-disable-next-line camelcase
|
|
673
521
|
aztec_utl_getUtilityContext() {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
522
|
+
return callTxeHandler({
|
|
523
|
+
oracle: 'aztec_utl_getUtilityContext',
|
|
524
|
+
inputs: [],
|
|
525
|
+
handler: () => this.handlerAsUtility().getUtilityContext(),
|
|
526
|
+
});
|
|
677
527
|
}
|
|
678
528
|
|
|
679
529
|
// eslint-disable-next-line camelcase
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
687
|
-
}
|
|
688
|
-
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
|
+
});
|
|
689
536
|
}
|
|
690
537
|
|
|
691
538
|
// eslint-disable-next-line camelcase
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(blockHash, noteHash);
|
|
700
|
-
|
|
701
|
-
if (!witness) {
|
|
702
|
-
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
703
|
-
}
|
|
704
|
-
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
|
+
});
|
|
705
545
|
}
|
|
706
546
|
|
|
707
547
|
// eslint-disable-next-line camelcase
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
716
|
-
|
|
717
|
-
if (!witness) {
|
|
718
|
-
throw new Error(
|
|
719
|
-
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
720
|
-
);
|
|
721
|
-
}
|
|
722
|
-
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
|
+
});
|
|
723
555
|
}
|
|
724
556
|
|
|
725
557
|
// eslint-disable-next-line camelcase
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
734
|
-
|
|
735
|
-
if (!witness) {
|
|
736
|
-
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
737
|
-
}
|
|
738
|
-
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
|
+
});
|
|
739
565
|
}
|
|
740
566
|
|
|
741
567
|
// eslint-disable-next-line camelcase
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
await this.handlerAsUtility().getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot, scope);
|
|
750
|
-
|
|
751
|
-
return toForeignCallResult([]);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// eslint-disable-next-line camelcase
|
|
755
|
-
async aztec_utl_getPendingTaggedLogs_v2(foreignScope: ForeignCallSingle) {
|
|
756
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
757
|
-
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(scope);
|
|
758
|
-
return toForeignCallResult([toSingle(slot)]);
|
|
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
|
+
});
|
|
759
574
|
}
|
|
760
575
|
|
|
761
576
|
// eslint-disable-next-line camelcase
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
774
|
-
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
775
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
776
|
-
|
|
777
|
-
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
778
|
-
contractAddress,
|
|
779
|
-
noteValidationRequestsArrayBaseSlot,
|
|
780
|
-
eventValidationRequestsArrayBaseSlot,
|
|
781
|
-
maxNotePackedLen,
|
|
782
|
-
maxEventSerializedLen,
|
|
783
|
-
scope,
|
|
784
|
-
);
|
|
785
|
-
|
|
786
|
-
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
|
+
});
|
|
787
588
|
}
|
|
788
589
|
|
|
789
590
|
// eslint-disable-next-line camelcase
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
) {
|
|
797
|
-
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
798
|
-
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
799
|
-
const maxNotePackedLen = fromSingle(foreignMaxNotePackedLen).toNumber();
|
|
800
|
-
const maxEventSerializedLen = fromSingle(foreignMaxEventSerializedLen).toNumber();
|
|
801
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
802
|
-
|
|
803
|
-
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
|
|
804
|
-
noteValidationRequestsArrayBaseSlot,
|
|
805
|
-
eventValidationRequestsArrayBaseSlot,
|
|
806
|
-
maxNotePackedLen,
|
|
807
|
-
maxEventSerializedLen,
|
|
808
|
-
scope,
|
|
809
|
-
);
|
|
810
|
-
|
|
811
|
-
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
|
+
});
|
|
812
597
|
}
|
|
813
598
|
|
|
814
599
|
// eslint-disable-next-line camelcase
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
822
|
-
const logRetrievalRequestsArrayBaseSlot = fromSingle(foreignLogRetrievalRequestsArrayBaseSlot);
|
|
823
|
-
const logRetrievalResponsesArrayBaseSlot = fromSingle(foreignLogRetrievalResponsesArrayBaseSlot);
|
|
824
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
825
|
-
|
|
826
|
-
await this.handlerAsUtility().getLogsByTag(
|
|
827
|
-
contractAddress,
|
|
828
|
-
logRetrievalRequestsArrayBaseSlot,
|
|
829
|
-
logRetrievalResponsesArrayBaseSlot,
|
|
830
|
-
scope,
|
|
831
|
-
);
|
|
832
|
-
|
|
833
|
-
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
|
+
});
|
|
834
606
|
}
|
|
835
607
|
|
|
836
608
|
// eslint-disable-next-line camelcase
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
const messageContextRequestsArrayBaseSlot = fromSingle(foreignMessageContextRequestsArrayBaseSlot);
|
|
845
|
-
const messageContextResponsesArrayBaseSlot = fromSingle(foreignMessageContextResponsesArrayBaseSlot);
|
|
846
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
847
|
-
|
|
848
|
-
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
849
|
-
contractAddress,
|
|
850
|
-
messageContextRequestsArrayBaseSlot,
|
|
851
|
-
messageContextResponsesArrayBaseSlot,
|
|
852
|
-
scope,
|
|
853
|
-
);
|
|
854
|
-
|
|
855
|
-
return toForeignCallResult([]);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
// eslint-disable-next-line camelcase
|
|
859
|
-
async aztec_utl_getLogsByTag_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
860
|
-
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
861
|
-
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(requestArrayBaseSlot);
|
|
862
|
-
return toForeignCallResult([toSingle(responseSlot)]);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
// eslint-disable-next-line camelcase
|
|
866
|
-
async aztec_utl_getMessageContextsByTxHash_v2(foreignRequestArrayBaseSlot: ForeignCallSingle) {
|
|
867
|
-
const requestArrayBaseSlot = fromSingle(foreignRequestArrayBaseSlot);
|
|
868
|
-
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(requestArrayBaseSlot);
|
|
869
|
-
return toForeignCallResult([toSingle(responseSlot)]);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
// eslint-disable-next-line camelcase
|
|
873
|
-
aztec_utl_setCapsule(
|
|
874
|
-
foreignContractAddress: ForeignCallSingle,
|
|
875
|
-
foreignSlot: ForeignCallSingle,
|
|
876
|
-
foreignCapsule: ForeignCallArray,
|
|
877
|
-
foreignScope: ForeignCallSingle,
|
|
878
|
-
) {
|
|
879
|
-
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
880
|
-
const slot = fromSingle(foreignSlot);
|
|
881
|
-
const capsule = fromArray(foreignCapsule);
|
|
882
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
883
|
-
|
|
884
|
-
this.handlerAsUtility().setCapsule(contractAddress, slot, capsule, scope);
|
|
885
|
-
|
|
886
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
887
616
|
}
|
|
888
617
|
|
|
889
|
-
// eslint-disable-next-line camelcase
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
const slot = fromSingle(foreignSlot);
|
|
898
|
-
const tSize = fromSingle(foreignTSize).toNumber();
|
|
899
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
900
|
-
|
|
901
|
-
const values = await this.handlerAsUtility().getCapsule(contractAddress, slot, scope);
|
|
902
|
-
|
|
903
|
-
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
904
|
-
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
905
|
-
if (values === null) {
|
|
906
|
-
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
907
|
-
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(tSize).fill(new Fr(0)))]);
|
|
908
|
-
} else {
|
|
909
|
-
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
910
|
-
return toForeignCallResult([toSingle(new Fr(1)), toArray(values)]);
|
|
911
|
-
}
|
|
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
|
+
});
|
|
912
626
|
}
|
|
913
627
|
|
|
914
628
|
// eslint-disable-next-line camelcase
|
|
915
|
-
aztec_utl_deleteCapsule(
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const slot = fromSingle(foreignSlot);
|
|
922
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
923
|
-
|
|
924
|
-
this.handlerAsUtility().deleteCapsule(contractAddress, slot, scope);
|
|
925
|
-
|
|
926
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
927
635
|
}
|
|
928
636
|
|
|
929
637
|
// eslint-disable-next-line camelcase
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
938
|
-
const srcSlot = fromSingle(foreignSrcSlot);
|
|
939
|
-
const dstSlot = fromSingle(foreignDstSlot);
|
|
940
|
-
const numEntries = fromSingle(foreignNumEntries).toNumber();
|
|
941
|
-
const scope = AztecAddress.fromField(fromSingle(foreignScope));
|
|
942
|
-
|
|
943
|
-
await this.handlerAsUtility().copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, scope);
|
|
944
|
-
|
|
945
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
946
645
|
}
|
|
947
646
|
|
|
948
647
|
// eslint-disable-next-line camelcase
|
|
949
|
-
aztec_utl_pushEphemeral(
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
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
|
+
});
|
|
954
654
|
}
|
|
955
655
|
|
|
956
656
|
// eslint-disable-next-line camelcase
|
|
957
|
-
aztec_utl_popEphemeral(
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
657
|
+
aztec_utl_popEphemeral(...inputs: ForeignCallArgs) {
|
|
658
|
+
return callTxeHandler({
|
|
659
|
+
oracle: 'aztec_utl_popEphemeral',
|
|
660
|
+
inputs,
|
|
661
|
+
handler: ([slot]) => this.handlerAsUtility().popEphemeral(slot),
|
|
662
|
+
});
|
|
961
663
|
}
|
|
962
664
|
|
|
963
665
|
// eslint-disable-next-line camelcase
|
|
964
|
-
aztec_utl_getEphemeral(
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
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
|
+
});
|
|
969
672
|
}
|
|
970
673
|
|
|
971
674
|
// eslint-disable-next-line camelcase
|
|
972
|
-
aztec_utl_setEphemeral(
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
const index = fromSingle(foreignIndex).toNumber();
|
|
979
|
-
const elements = fromArray(foreignElements);
|
|
980
|
-
this.handlerAsUtility().setEphemeral(slot, index, elements);
|
|
981
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
982
681
|
}
|
|
983
682
|
|
|
984
683
|
// eslint-disable-next-line camelcase
|
|
985
|
-
aztec_utl_getEphemeralLen(
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
684
|
+
aztec_utl_getEphemeralLen(...inputs: ForeignCallArgs) {
|
|
685
|
+
return callTxeHandler({
|
|
686
|
+
oracle: 'aztec_utl_getEphemeralLen',
|
|
687
|
+
inputs,
|
|
688
|
+
handler: ([slot]) => this.handlerAsUtility().getEphemeralLen(slot),
|
|
689
|
+
});
|
|
989
690
|
}
|
|
990
691
|
|
|
991
692
|
// eslint-disable-next-line camelcase
|
|
992
|
-
aztec_utl_removeEphemeral(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
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
|
+
});
|
|
997
699
|
}
|
|
998
700
|
|
|
999
701
|
// eslint-disable-next-line camelcase
|
|
1000
|
-
aztec_utl_clearEphemeral(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
702
|
+
aztec_utl_clearEphemeral(...inputs: ForeignCallArgs) {
|
|
703
|
+
return callTxeHandler({
|
|
704
|
+
oracle: 'aztec_utl_clearEphemeral',
|
|
705
|
+
inputs,
|
|
706
|
+
handler: ([slot]) => this.handlerAsUtility().clearEphemeral(slot),
|
|
707
|
+
});
|
|
1004
708
|
}
|
|
1005
709
|
|
|
1006
710
|
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
@@ -1008,365 +712,392 @@ export class RPCTranslator {
|
|
|
1008
712
|
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
1009
713
|
// existence of a txe_oracle method?
|
|
1010
714
|
// eslint-disable-next-line camelcase
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
const ciphertext = fromUintBoundedVec(foreignCiphertextBVecStorage, foreignCiphertextLength, 8);
|
|
1018
|
-
const iv = fromUintArray(foreignIv, 8);
|
|
1019
|
-
const symKey = fromUintArray(foreignSymKey, 8);
|
|
1020
|
-
|
|
1021
|
-
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
1022
|
-
try {
|
|
1023
|
-
const plaintextBuffer = await this.handlerAsUtility().decryptAes128(ciphertext, iv, symKey);
|
|
1024
|
-
const [storage, length] = arrayToBoundedVec(
|
|
1025
|
-
bufferToU8Array(plaintextBuffer),
|
|
1026
|
-
foreignCiphertextBVecStorage.length,
|
|
1027
|
-
);
|
|
1028
|
-
return toForeignCallResult([toSingle(new Fr(1)), storage, length]);
|
|
1029
|
-
} catch {
|
|
1030
|
-
const zeroStorage = toArray(Array(foreignCiphertextBVecStorage.length).fill(new Fr(0)));
|
|
1031
|
-
return toForeignCallResult([toSingle(new Fr(0)), zeroStorage, toSingle(new Fr(0))]);
|
|
1032
|
-
}
|
|
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
|
+
});
|
|
1033
721
|
}
|
|
1034
722
|
|
|
1035
723
|
// eslint-disable-next-line camelcase
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
const address = AztecAddress.fromField(fromSingle(foreignAddress));
|
|
1044
|
-
const ephPK = Point.fromFields([
|
|
1045
|
-
fromSingle(foreignEphPKField0),
|
|
1046
|
-
fromSingle(foreignEphPKField1),
|
|
1047
|
-
fromSingle(foreignEphPKField2),
|
|
1048
|
-
]);
|
|
1049
|
-
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
1050
|
-
|
|
1051
|
-
const secret = await this.handlerAsUtility().getSharedSecret(address, ephPK, contractAddress);
|
|
1052
|
-
|
|
1053
|
-
return toForeignCallResult([toSingle(secret)]);
|
|
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
|
+
});
|
|
1054
731
|
}
|
|
1055
732
|
|
|
1056
733
|
// eslint-disable-next-line camelcase
|
|
1057
|
-
aztec_utl_setContractSyncCacheInvalid(
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const scopes = fromArray(foreignScopes)
|
|
1065
|
-
.slice(0, count)
|
|
1066
|
-
.map(f => new AztecAddress(f));
|
|
1067
|
-
|
|
1068
|
-
this.handlerAsUtility().setContractSyncCacheInvalid(contractAddress, scopes);
|
|
1069
|
-
|
|
1070
|
-
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
|
+
});
|
|
1071
741
|
}
|
|
1072
742
|
|
|
1073
743
|
// eslint-disable-next-line camelcase
|
|
1074
|
-
aztec_utl_emitOffchainEffect(
|
|
1075
|
-
|
|
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
|
+
});
|
|
1076
756
|
}
|
|
1077
757
|
|
|
1078
758
|
// AVM opcodes
|
|
1079
759
|
|
|
1080
760
|
// eslint-disable-next-line camelcase
|
|
1081
|
-
aztec_avm_emitPublicLog(
|
|
1082
|
-
|
|
1083
|
-
|
|
761
|
+
aztec_avm_emitPublicLog() {
|
|
762
|
+
return callTxeHandler({
|
|
763
|
+
oracle: 'aztec_avm_emitPublicLog',
|
|
764
|
+
inputs: [],
|
|
765
|
+
// TODO(#8811): Implement
|
|
766
|
+
handler: () => {},
|
|
767
|
+
});
|
|
1084
768
|
}
|
|
1085
769
|
|
|
1086
770
|
// eslint-disable-next-line camelcase
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
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
|
+
});
|
|
1094
777
|
}
|
|
1095
778
|
|
|
1096
779
|
// eslint-disable-next-line camelcase
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return toForeignCallResult([]);
|
|
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
|
+
});
|
|
1104
786
|
}
|
|
1105
787
|
|
|
1106
788
|
// eslint-disable-next-line camelcase
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
toSingle(instance.deployer),
|
|
1114
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
1115
|
-
toSingle(new Fr(1)),
|
|
1116
|
-
]);
|
|
789
|
+
aztec_avm_getContractInstanceDeployer(...inputs: ForeignCallArgs) {
|
|
790
|
+
return callTxeHandler({
|
|
791
|
+
oracle: 'aztec_avm_getContractInstanceDeployer',
|
|
792
|
+
inputs,
|
|
793
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceDeployer(address),
|
|
794
|
+
});
|
|
1117
795
|
}
|
|
1118
796
|
|
|
1119
797
|
// eslint-disable-next-line camelcase
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
toSingle(instance.currentContractClassId),
|
|
1127
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
1128
|
-
toSingle(new Fr(1)),
|
|
1129
|
-
]);
|
|
798
|
+
aztec_avm_getContractInstanceClassId(...inputs: ForeignCallArgs) {
|
|
799
|
+
return callTxeHandler({
|
|
800
|
+
oracle: 'aztec_avm_getContractInstanceClassId',
|
|
801
|
+
inputs,
|
|
802
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceClassId(address),
|
|
803
|
+
});
|
|
1130
804
|
}
|
|
1131
805
|
|
|
1132
806
|
// eslint-disable-next-line camelcase
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
toSingle(instance.initializationHash),
|
|
1140
|
-
// AVM requires an extra boolean indicating the instance was found
|
|
1141
|
-
toSingle(new Fr(1)),
|
|
1142
|
-
]);
|
|
807
|
+
aztec_avm_getContractInstanceInitializationHash(...inputs: ForeignCallArgs) {
|
|
808
|
+
return callTxeHandler({
|
|
809
|
+
oracle: 'aztec_avm_getContractInstanceInitializationHash',
|
|
810
|
+
inputs,
|
|
811
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceInitializationHash(address),
|
|
812
|
+
});
|
|
1143
813
|
}
|
|
1144
814
|
|
|
1145
815
|
// eslint-disable-next-line camelcase
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
// eslint-disable-next-line camelcase
|
|
1153
|
-
async aztec_avm_emitNullifier(foreignNullifier: ForeignCallSingle) {
|
|
1154
|
-
const nullifier = fromSingle(foreignNullifier);
|
|
1155
|
-
|
|
1156
|
-
await this.handlerAsAvm().emitNullifier(nullifier);
|
|
1157
|
-
|
|
1158
|
-
return toForeignCallResult([]);
|
|
816
|
+
aztec_avm_getContractInstanceImmutablesHash(...inputs: ForeignCallArgs) {
|
|
817
|
+
return callTxeHandler({
|
|
818
|
+
oracle: 'aztec_avm_getContractInstanceImmutablesHash',
|
|
819
|
+
inputs,
|
|
820
|
+
handler: ([address]) => this.handlerAsAvm().getContractInstanceImmutablesHash(address),
|
|
821
|
+
});
|
|
1159
822
|
}
|
|
1160
823
|
|
|
1161
824
|
// eslint-disable-next-line camelcase
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
825
|
+
aztec_avm_sender() {
|
|
826
|
+
return callTxeHandler({
|
|
827
|
+
oracle: 'aztec_avm_sender',
|
|
828
|
+
inputs: [],
|
|
829
|
+
handler: () => this.handlerAsAvm().sender(),
|
|
830
|
+
});
|
|
1168
831
|
}
|
|
1169
832
|
|
|
1170
833
|
// eslint-disable-next-line camelcase
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
834
|
+
aztec_avm_emitNullifier(...inputs: ForeignCallArgs) {
|
|
835
|
+
return callTxeHandler({
|
|
836
|
+
oracle: 'aztec_avm_emitNullifier',
|
|
837
|
+
inputs,
|
|
838
|
+
handler: ([nullifier]) => this.handlerAsAvm().emitNullifier(nullifier),
|
|
839
|
+
});
|
|
1177
840
|
}
|
|
1178
841
|
|
|
1179
842
|
// eslint-disable-next-line camelcase
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
843
|
+
aztec_avm_emitNoteHash(...inputs: ForeignCallArgs) {
|
|
844
|
+
return callTxeHandler({
|
|
845
|
+
oracle: 'aztec_avm_emitNoteHash',
|
|
846
|
+
inputs,
|
|
847
|
+
handler: ([noteHash]) => this.handlerAsAvm().emitNoteHash(noteHash),
|
|
848
|
+
});
|
|
1184
849
|
}
|
|
1185
850
|
|
|
1186
851
|
// eslint-disable-next-line camelcase
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
852
|
+
aztec_avm_nullifierExists(...inputs: ForeignCallArgs) {
|
|
853
|
+
return callTxeHandler({
|
|
854
|
+
oracle: 'aztec_avm_nullifierExists',
|
|
855
|
+
inputs,
|
|
856
|
+
handler: ([siloedNullifier]) => this.handlerAsAvm().nullifierExists(siloedNullifier),
|
|
857
|
+
});
|
|
1191
858
|
}
|
|
1192
859
|
|
|
1193
860
|
// eslint-disable-next-line camelcase
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
861
|
+
aztec_avm_address() {
|
|
862
|
+
return callTxeHandler({
|
|
863
|
+
oracle: 'aztec_avm_address',
|
|
864
|
+
inputs: [],
|
|
865
|
+
handler: () => this.handlerAsAvm().address(),
|
|
866
|
+
});
|
|
1198
867
|
}
|
|
1199
868
|
|
|
1200
869
|
// eslint-disable-next-line camelcase
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
870
|
+
aztec_avm_blockNumber() {
|
|
871
|
+
return callTxeHandler({
|
|
872
|
+
oracle: 'aztec_avm_blockNumber',
|
|
873
|
+
inputs: [],
|
|
874
|
+
handler: () => this.handlerAsAvm().blockNumber(),
|
|
875
|
+
});
|
|
1205
876
|
}
|
|
1206
877
|
|
|
1207
878
|
// eslint-disable-next-line camelcase
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
879
|
+
aztec_avm_timestamp() {
|
|
880
|
+
return callTxeHandler({
|
|
881
|
+
oracle: 'aztec_avm_timestamp',
|
|
882
|
+
inputs: [],
|
|
883
|
+
handler: () => this.handlerAsAvm().timestamp(),
|
|
884
|
+
});
|
|
1212
885
|
}
|
|
1213
886
|
|
|
1214
887
|
// eslint-disable-next-line camelcase
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
888
|
+
aztec_avm_isStaticCall() {
|
|
889
|
+
return callTxeHandler({
|
|
890
|
+
oracle: 'aztec_avm_isStaticCall',
|
|
891
|
+
inputs: [],
|
|
892
|
+
handler: () => this.handlerAsAvm().isStaticCall(),
|
|
893
|
+
});
|
|
1219
894
|
}
|
|
1220
895
|
|
|
1221
896
|
// eslint-disable-next-line camelcase
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
897
|
+
aztec_avm_chainId() {
|
|
898
|
+
return callTxeHandler({
|
|
899
|
+
oracle: 'aztec_avm_chainId',
|
|
900
|
+
inputs: [],
|
|
901
|
+
handler: () => this.handlerAsAvm().chainId(),
|
|
902
|
+
});
|
|
1226
903
|
}
|
|
1227
904
|
|
|
1228
905
|
// eslint-disable-next-line camelcase
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
906
|
+
aztec_avm_version() {
|
|
907
|
+
return callTxeHandler({
|
|
908
|
+
oracle: 'aztec_avm_version',
|
|
909
|
+
inputs: [],
|
|
910
|
+
handler: () => this.handlerAsAvm().version(),
|
|
911
|
+
});
|
|
1233
912
|
}
|
|
1234
913
|
|
|
1235
914
|
// eslint-disable-next-line camelcase
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
) {
|
|
1243
|
-
throw new Error(
|
|
1244
|
-
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
1245
|
-
);
|
|
915
|
+
aztec_avm_returndataSize() {
|
|
916
|
+
return callTxeHandler({
|
|
917
|
+
oracle: 'aztec_avm_returndataSize',
|
|
918
|
+
inputs: [],
|
|
919
|
+
handler: () => this.handlerAsAvm().returndataSize(),
|
|
920
|
+
});
|
|
1246
921
|
}
|
|
1247
922
|
|
|
1248
923
|
// eslint-disable-next-line camelcase
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
) {
|
|
1256
|
-
throw new Error(
|
|
1257
|
-
'Contract calls are forbidden inside a `TestEnvironment::public_context`, use `public_call` instead',
|
|
1258
|
-
);
|
|
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
|
+
});
|
|
1259
930
|
}
|
|
1260
931
|
|
|
1261
932
|
// eslint-disable-next-line camelcase
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
async aztec_txe_privateCallNewFlow(
|
|
1270
|
-
foreignFrom: ForeignCallSingle,
|
|
1271
|
-
foreignTargetContractAddress: ForeignCallSingle,
|
|
1272
|
-
foreignFunctionSelector: ForeignCallSingle,
|
|
1273
|
-
foreignArgs: ForeignCallArray,
|
|
1274
|
-
foreignArgsHash: ForeignCallSingle,
|
|
1275
|
-
foreignIsStaticCall: ForeignCallSingle,
|
|
1276
|
-
) {
|
|
1277
|
-
const from = addressFromSingle(foreignFrom);
|
|
1278
|
-
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
1279
|
-
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1280
|
-
const args = fromArray(foreignArgs);
|
|
1281
|
-
const argsHash = fromSingle(foreignArgsHash);
|
|
1282
|
-
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1283
|
-
|
|
1284
|
-
const returnValues = await this.handlerAsTxe().privateCallNewFlow(
|
|
1285
|
-
from,
|
|
1286
|
-
targetContractAddress,
|
|
1287
|
-
functionSelector,
|
|
1288
|
-
args,
|
|
1289
|
-
argsHash,
|
|
1290
|
-
isStaticCall,
|
|
1291
|
-
this.stateHandler.getCurrentJob(),
|
|
1292
|
-
);
|
|
1293
|
-
|
|
1294
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1295
|
-
await this.stateHandler.cycleJob();
|
|
1296
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
// eslint-disable-next-line camelcase
|
|
1300
|
-
async aztec_txe_executeUtilityFunction(
|
|
1301
|
-
foreignTargetContractAddress: ForeignCallSingle,
|
|
1302
|
-
foreignFunctionSelector: ForeignCallSingle,
|
|
1303
|
-
foreignArgs: ForeignCallArray,
|
|
1304
|
-
) {
|
|
1305
|
-
const targetContractAddress = addressFromSingle(foreignTargetContractAddress);
|
|
1306
|
-
const functionSelector = FunctionSelector.fromField(fromSingle(foreignFunctionSelector));
|
|
1307
|
-
const args = fromArray(foreignArgs);
|
|
1308
|
-
|
|
1309
|
-
const returnValues = await this.handlerAsTxe().executeUtilityFunction(
|
|
1310
|
-
targetContractAddress,
|
|
1311
|
-
functionSelector,
|
|
1312
|
-
args,
|
|
1313
|
-
this.stateHandler.getCurrentJob(),
|
|
1314
|
-
);
|
|
1315
|
-
|
|
1316
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1317
|
-
await this.stateHandler.cycleJob();
|
|
1318
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
// eslint-disable-next-line camelcase
|
|
1322
|
-
async aztec_txe_publicCallNewFlow(
|
|
1323
|
-
foreignFrom: ForeignCallSingle,
|
|
1324
|
-
foreignAddress: ForeignCallSingle,
|
|
1325
|
-
foreignCalldata: ForeignCallArray,
|
|
1326
|
-
foreignIsStaticCall: ForeignCallSingle,
|
|
1327
|
-
) {
|
|
1328
|
-
const from = addressFromSingle(foreignFrom);
|
|
1329
|
-
const address = addressFromSingle(foreignAddress);
|
|
1330
|
-
const calldata = fromArray(foreignCalldata);
|
|
1331
|
-
const isStaticCall = fromSingle(foreignIsStaticCall).toBool();
|
|
1332
|
-
|
|
1333
|
-
const returnValues = await this.handlerAsTxe().publicCallNewFlow(from, address, calldata, isStaticCall);
|
|
1334
|
-
|
|
1335
|
-
// TODO(F-335): Avoid doing the following call here.
|
|
1336
|
-
await this.stateHandler.cycleJob();
|
|
1337
|
-
return toForeignCallResult([toArray(returnValues)]);
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
// eslint-disable-next-line camelcase
|
|
1341
|
-
async aztec_prv_getSenderForTags() {
|
|
1342
|
-
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
1343
|
-
|
|
1344
|
-
// Return a Noir Option struct with `some` and `value` fields
|
|
1345
|
-
if (sender === undefined) {
|
|
1346
|
-
// No sender found, return Option with some=0 and value=0
|
|
1347
|
-
return toForeignCallResult([toSingle(0), toSingle(0)]);
|
|
1348
|
-
} else {
|
|
1349
|
-
// Sender found, return Option with some=1 and value=sender address
|
|
1350
|
-
return toForeignCallResult([toSingle(1), toSingle(sender)]);
|
|
1351
|
-
}
|
|
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
|
+
});
|
|
1352
940
|
}
|
|
1353
941
|
|
|
1354
942
|
// eslint-disable-next-line camelcase
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
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
|
+
});
|
|
1361
950
|
}
|
|
1362
951
|
|
|
1363
952
|
// eslint-disable-next-line camelcase
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
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
|
+
});
|
|
1371
1102
|
}
|
|
1372
1103
|
}
|