@aztec/txe 0.0.1-commit.993d240 → 0.0.1-commit.9a89641
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/AuthRegistry-QVGDDH5X.js +3 -0
- package/dest/AuthRegistry-QVGDDH5X.js.map +7 -0
- package/dest/ContractClassRegistry-PVNCKGG7.js +3 -0
- package/dest/ContractClassRegistry-PVNCKGG7.js.map +7 -0
- package/dest/ContractInstanceRegistry-WLOZKTR6.js +3 -0
- package/dest/ContractInstanceRegistry-WLOZKTR6.js.map +7 -0
- package/dest/FeeJuice-MAQJU53K.js +3 -0
- package/dest/FeeJuice-MAQJU53K.js.map +7 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js +3 -0
- package/dest/HandshakeRegistry-GY5CPEPS.js.map +7 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js +3 -0
- package/dest/MultiCallEntrypoint-QG5H33ZZ.js.map +7 -0
- package/dest/SchnorrAccount-ADD65DYA.js +3 -0
- package/dest/SchnorrAccount-ADD65DYA.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js +3 -0
- package/dest/SchnorrInitializerlessAccount-TWGKRUSY.js.map +7 -0
- package/dest/bin/check_txe_oracle_version.js +9 -19
- package/dest/bin/index.js +1 -1
- 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-32UHX7YY.js +3 -0
- package/dest/{chunk-DF6RMOC6.js → chunk-RVEPNDEP.js} +2 -2
- package/dest/{chunk-DF6RMOC6.js.map → chunk-RVEPNDEP.js.map} +3 -3
- package/dest/chunk-XWIMXLKD.js +258 -0
- package/dest/chunk-XWIMXLKD.js.map +7 -0
- package/dest/constants.d.ts +3 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +5 -2
- package/dest/dispatcher_pool.d.ts +2 -2
- package/dest/dispatcher_pool.d.ts.map +1 -1
- package/dest/dispatcher_pool.js +5 -3
- package/dest/index.d.ts +6 -143
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +12 -169
- package/dest/metafile.json +10267 -9581
- package/dest/oracle/interfaces.d.ts +38 -11
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/tagging_secret_strategy.d.ts +12 -0
- package/dest/oracle/tagging_secret_strategy.d.ts.map +1 -0
- package/dest/oracle/tagging_secret_strategy.js +12 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts +16 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +200 -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 +32 -0
- package/dest/oracle/test-resolver/resolver.d.ts +48 -0
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -0
- package/dest/oracle/test-resolver/resolver.js +181 -0
- package/dest/oracle/txe_oracle_public_context.d.ts +25 -6
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +34 -1
- package/dest/oracle/txe_oracle_registry.d.ts +172 -0
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -0
- package/dest/oracle/txe_oracle_registry.js +767 -0
- package/dest/oracle/txe_oracle_top_level_context.d.ts +39 -14
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +489 -289
- package/dest/{txe_oracle_version.d.ts → oracle/txe_oracle_version.d.ts} +5 -5
- package/dest/oracle/txe_oracle_version.d.ts.map +1 -0
- package/dest/{txe_oracle_version.js → oracle/txe_oracle_version.js} +4 -4
- package/dest/rpc_translator.d.ts +116 -284
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +809 -860
- package/dest/server.bundle.js +1 -1
- package/dest/state_machine/archiver.d.ts +3 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +9 -3
- package/dest/state_machine/dummy_p2p_client.d.ts +5 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +9 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +0 -3
- package/dest/state_machine/index.d.ts +8 -6
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +41 -19
- package/dest/state_machine/mock_epoch_cache.d.ts +2 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +3 -6
- package/dest/state_machine/synchronizer.d.ts +10 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +18 -5
- package/dest/txe_session.d.ts +43 -28
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +183 -47
- package/dest/utils/block_creation.d.ts +2 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +2 -2
- package/dest/utils/encoding.d.ts +8 -5
- package/dest/utils/encoding.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.d.ts +1 -1
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +0 -1
- 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 +1 -1
- package/dest/utils/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/utils/txe_public_contract_data_source.js +7 -4
- package/dest/worker.bundle.js +1 -1
- package/package.json +18 -17
- package/src/bin/check_txe_oracle_version.ts +11 -17
- package/src/bin/oracle_test_server.ts +51 -0
- package/src/constants.ts +6 -2
- package/src/dispatcher_pool.ts +4 -3
- package/src/index.ts +21 -198
- package/src/oracle/interfaces.ts +35 -9
- package/src/oracle/tagging_secret_strategy.ts +25 -0
- package/src/oracle/test-resolver/default_fixtures.ts +271 -0
- package/src/oracle/test-resolver/index.ts +44 -0
- package/src/oracle/test-resolver/resolver.ts +245 -0
- package/src/oracle/txe_oracle_public_context.ts +36 -4
- package/src/oracle/txe_oracle_registry.ts +556 -0
- package/src/oracle/txe_oracle_top_level_context.ts +249 -66
- package/src/{txe_oracle_version.ts → oracle/txe_oracle_version.ts} +4 -4
- package/src/rpc_translator.ts +850 -1065
- package/src/state_machine/archiver.ts +9 -3
- package/src/state_machine/dummy_p2p_client.ts +13 -0
- package/src/state_machine/global_variable_builder.ts +2 -16
- package/src/state_machine/index.ts +50 -34
- package/src/state_machine/mock_epoch_cache.ts +4 -8
- package/src/state_machine/synchronizer.ts +26 -5
- package/src/txe_session.ts +325 -56
- package/src/utils/block_creation.ts +2 -1
- package/src/utils/tx_effect_creation.ts +0 -2
- package/src/utils/txe_artifact_resolver.ts +217 -0
- package/src/utils/txe_public_contract_data_source.ts +6 -4
- package/dest/ContractClassRegistry-KKNT527R.js +0 -3
- package/dest/ContractClassRegistry-KKNT527R.js.map +0 -7
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js +0 -3
- package/dest/ContractInstanceRegistry-GSKBNL3Q.js.map +0 -7
- package/dest/FeeJuice-GUJ5O6GB.js +0 -3
- package/dest/FeeJuice-GUJ5O6GB.js.map +0 -7
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js +0 -3
- package/dest/MultiCallEntrypoint-ZQPCKVKL.js.map +0 -7
- package/dest/SchnorrAccount-QIXE5DXA.js +0 -3
- package/dest/SchnorrAccount-QIXE5DXA.js.map +0 -7
- package/dest/chunk-BJVAAXNA.js +0 -3
- package/dest/chunk-PPJTNNUG.js +0 -265
- package/dest/chunk-PPJTNNUG.js.map +0 -7
- package/dest/txe_oracle_version.d.ts.map +0 -1
- /package/dest/{chunk-BJVAAXNA.js.map → chunk-32UHX7YY.js.map} +0 -0
|
@@ -6,32 +6,40 @@ import {
|
|
|
6
6
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
7
7
|
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
|
|
8
8
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
9
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
9
10
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
10
11
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
11
12
|
import type { KeyStore } from '@aztec/key-store';
|
|
12
13
|
import {
|
|
13
14
|
AddressStore,
|
|
15
|
+
AnchoredContractData,
|
|
14
16
|
CapsuleService,
|
|
15
17
|
CapsuleStore,
|
|
16
18
|
type ContractStore,
|
|
17
19
|
type ExecutionHooks,
|
|
20
|
+
FactService,
|
|
21
|
+
FactStore,
|
|
18
22
|
NoteStore,
|
|
19
23
|
ORACLE_VERSION_MAJOR,
|
|
20
24
|
PrivateEventStore,
|
|
21
25
|
RecipientTaggingStore,
|
|
22
|
-
SenderAddressBookStore,
|
|
23
26
|
SenderTaggingStore,
|
|
27
|
+
TaggingSecretSourcesStore,
|
|
28
|
+
type TaggingSecretStrategy,
|
|
24
29
|
composeHooks,
|
|
25
30
|
enrichPublicSimulationError,
|
|
26
31
|
} from '@aztec/pxe/server';
|
|
27
32
|
import {
|
|
33
|
+
CONTRACT_INSTANCE,
|
|
28
34
|
ExecutionNoteCache,
|
|
29
35
|
ExecutionTaggingIndexCache,
|
|
30
36
|
HashedValuesCache,
|
|
31
37
|
type IMiscOracle,
|
|
32
|
-
|
|
38
|
+
type Option,
|
|
33
39
|
PrivateExecutionOracle,
|
|
40
|
+
TransientArrayService,
|
|
34
41
|
UtilityExecutionOracle,
|
|
42
|
+
buildACIRCallback,
|
|
35
43
|
executePrivateFunction,
|
|
36
44
|
generateSimulatedProvingResult,
|
|
37
45
|
} from '@aztec/pxe/simulator';
|
|
@@ -45,10 +53,10 @@ import {
|
|
|
45
53
|
witnessMapToFields,
|
|
46
54
|
} from '@aztec/simulator/client';
|
|
47
55
|
import {
|
|
48
|
-
CppPublicTxSimulator,
|
|
49
56
|
GuardedMerkleTreeOperations,
|
|
50
57
|
PublicContractsDB,
|
|
51
58
|
PublicProcessor,
|
|
59
|
+
PublicTxSimulator,
|
|
52
60
|
} from '@aztec/simulator/server';
|
|
53
61
|
import { type ContractArtifact, EventSelector, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
54
62
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
@@ -63,7 +71,10 @@ import {
|
|
|
63
71
|
PrivateToPublicAccumulatedData,
|
|
64
72
|
PublicCallRequest,
|
|
65
73
|
} from '@aztec/stdlib/kernel';
|
|
66
|
-
import { hashPublicKey } from '@aztec/stdlib/keys';
|
|
74
|
+
import { deriveKeys, hashPublicKey } from '@aztec/stdlib/keys';
|
|
75
|
+
import type { PrivateLog } from '@aztec/stdlib/logs';
|
|
76
|
+
import { AppTaggingSecretKind } from '@aztec/stdlib/logs';
|
|
77
|
+
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/stdlib/messaging';
|
|
67
78
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
68
79
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
69
80
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -82,12 +93,14 @@ import {
|
|
|
82
93
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
83
94
|
import { ForkCheckpoint } from '@aztec/world-state/native';
|
|
84
95
|
|
|
85
|
-
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
96
|
+
import { DEFAULT_ADDRESS, MAX_PRIVATE_EVENTS_PER_TXE_QUERY, MAX_PRIVATE_EVENT_LEN } from '../constants.js';
|
|
86
97
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
87
98
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
88
99
|
import type { TXEAccountStore } from '../utils/txe_account_store.js';
|
|
100
|
+
import type { TXEArtifactResolver } from '../utils/txe_artifact_resolver.js';
|
|
89
101
|
import { TXEPublicContractDataSource } from '../utils/txe_public_contract_data_source.js';
|
|
90
102
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
103
|
+
import { type TXETaggingSecretStrategies, makeResolveTaggingSecretStrategyHook } from './tagging_secret_strategy.js';
|
|
91
104
|
|
|
92
105
|
export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
|
|
93
106
|
isMisc = true as const;
|
|
@@ -104,13 +117,19 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
104
117
|
private accountStore: TXEAccountStore,
|
|
105
118
|
private senderTaggingStore: SenderTaggingStore,
|
|
106
119
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
107
|
-
private
|
|
120
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
108
121
|
private capsuleStore: CapsuleStore,
|
|
122
|
+
private factStore: FactStore,
|
|
109
123
|
private privateEventStore: PrivateEventStore,
|
|
110
124
|
private nextBlockTimestamp: bigint,
|
|
111
125
|
private version: Fr,
|
|
112
126
|
private chainId: Fr,
|
|
113
127
|
private authwits: Map<string, AuthWitness>,
|
|
128
|
+
private taggingSecretStrategies: TXETaggingSecretStrategies,
|
|
129
|
+
private authorizeAllUtilityCallTargets: boolean,
|
|
130
|
+
private readonly artifactResolver: TXEArtifactResolver,
|
|
131
|
+
private readonly rootPath: string,
|
|
132
|
+
private readonly packageName: string,
|
|
114
133
|
) {
|
|
115
134
|
this.logger = createLogger('txe:top_level_context');
|
|
116
135
|
this.logger.debug('Entering Top Level Context');
|
|
@@ -143,7 +162,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
143
162
|
}
|
|
144
163
|
|
|
145
164
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
146
|
-
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
165
|
+
log(level: number, message: string, _fieldsSize: number, fields: Fr[]): Promise<void> {
|
|
147
166
|
if (!LogLevels[level]) {
|
|
148
167
|
throw new Error(`Invalid log level: ${level}`);
|
|
149
168
|
}
|
|
@@ -169,7 +188,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
169
188
|
return (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables.timestamp;
|
|
170
189
|
}
|
|
171
190
|
|
|
172
|
-
async getLastTxEffects() {
|
|
191
|
+
async getLastTxEffects(): Promise<{ txHash: TxHash; noteHashes: Fr[]; nullifiers: Fr[]; privateLogs: PrivateLog[] }> {
|
|
173
192
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
174
193
|
const block = await this.stateMachine.archiver.getBlock({ number: latestBlockNumber });
|
|
175
194
|
|
|
@@ -204,7 +223,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
204
223
|
contractAddress,
|
|
205
224
|
null,
|
|
206
225
|
async (call, execScopes) => {
|
|
207
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
226
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
208
227
|
},
|
|
209
228
|
blockHeader,
|
|
210
229
|
jobId,
|
|
@@ -213,7 +232,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
213
232
|
}
|
|
214
233
|
|
|
215
234
|
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
216
|
-
|
|
235
|
+
const events = (
|
|
217
236
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
218
237
|
contractAddress,
|
|
219
238
|
scopes: [scope],
|
|
@@ -221,6 +240,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
221
240
|
toBlock: (await this.getLastBlockNumber()) + 1,
|
|
222
241
|
})
|
|
223
242
|
).map(e => e.packedEvent);
|
|
243
|
+
|
|
244
|
+
if (events.length > MAX_PRIVATE_EVENTS_PER_TXE_QUERY) {
|
|
245
|
+
throw new Error(`Array of length ${events.length} larger than maxLen ${MAX_PRIVATE_EVENTS_PER_TXE_QUERY}`);
|
|
246
|
+
}
|
|
247
|
+
if (events.some(e => e.length > MAX_PRIVATE_EVENT_LEN)) {
|
|
248
|
+
throw new Error(`Some private event has length larger than maxLen ${MAX_PRIVATE_EVENT_LEN}`);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return events;
|
|
224
252
|
}
|
|
225
253
|
|
|
226
254
|
async advanceBlocksBy(blocks: number) {
|
|
@@ -237,22 +265,42 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
237
265
|
}
|
|
238
266
|
|
|
239
267
|
private deploymentNullifier(address: AztecAddress): Promise<Fr> {
|
|
240
|
-
return siloNullifier(AztecAddress.
|
|
268
|
+
return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
|
|
241
269
|
}
|
|
242
270
|
|
|
243
|
-
async deploy(
|
|
271
|
+
async deploy(
|
|
272
|
+
contractPath: string,
|
|
273
|
+
initializer: string,
|
|
274
|
+
args: Fr[],
|
|
275
|
+
secret: Fr,
|
|
276
|
+
salt: Fr,
|
|
277
|
+
deployer: AztecAddress,
|
|
278
|
+
): Promise<Fr[]> {
|
|
279
|
+
const { artifact, instance } = await this.artifactResolver.resolveDeployArtifact({
|
|
280
|
+
rootPath: this.rootPath,
|
|
281
|
+
packageName: this.packageName,
|
|
282
|
+
contractPath,
|
|
283
|
+
initializer,
|
|
284
|
+
args,
|
|
285
|
+
secret,
|
|
286
|
+
salt,
|
|
287
|
+
deployer,
|
|
288
|
+
});
|
|
289
|
+
|
|
244
290
|
// Emit deployment nullifier
|
|
245
291
|
await this.mineBlock({
|
|
246
292
|
nullifiers: [await this.deploymentNullifier(instance.address)],
|
|
247
293
|
});
|
|
248
294
|
|
|
249
295
|
if (!secret.equals(Fr.ZERO)) {
|
|
250
|
-
await this.
|
|
296
|
+
await this.registerContractAndAddAccount(artifact, instance, secret);
|
|
251
297
|
} else {
|
|
252
298
|
await this.contractStore.addContractInstance(instance);
|
|
253
299
|
await this.contractStore.addContractArtifact(artifact);
|
|
254
300
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
255
301
|
}
|
|
302
|
+
|
|
303
|
+
return CONTRACT_INSTANCE.serialization!.fn(instance).flat();
|
|
256
304
|
}
|
|
257
305
|
|
|
258
306
|
/**
|
|
@@ -264,14 +312,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
264
312
|
});
|
|
265
313
|
}
|
|
266
314
|
|
|
267
|
-
async addAccount(
|
|
315
|
+
async addAccount(secret: Fr) {
|
|
316
|
+
const { artifact, instance } = await this.artifactResolver.resolveAccountArtifact(secret);
|
|
317
|
+
return this.registerContractAndAddAccount(artifact, instance, secret);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private async registerContractAndAddAccount(
|
|
321
|
+
artifact: ContractArtifact,
|
|
322
|
+
instance: ContractInstanceWithAddress,
|
|
323
|
+
secret: Fr,
|
|
324
|
+
) {
|
|
268
325
|
const partialAddress = await computePartialAddress(instance);
|
|
269
326
|
|
|
270
327
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
271
328
|
await this.contractStore.addContractInstance(instance);
|
|
272
329
|
await this.contractStore.addContractArtifact(artifact);
|
|
273
330
|
|
|
274
|
-
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
331
|
+
const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
|
|
275
332
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
276
333
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
277
334
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
@@ -279,9 +336,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
279
336
|
return completeAddress;
|
|
280
337
|
}
|
|
281
338
|
|
|
282
|
-
async createAccount(secret: Fr) {
|
|
283
|
-
|
|
284
|
-
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
339
|
+
async createAccount(secret: Fr, partialAddress: Fr) {
|
|
340
|
+
const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
|
|
285
341
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
286
342
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
287
343
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
@@ -302,7 +358,46 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
302
358
|
this.authwits.set(authWitness.requestHash.toString(), authWitness);
|
|
303
359
|
}
|
|
304
360
|
|
|
305
|
-
|
|
361
|
+
setTaggingSecretStrategies(
|
|
362
|
+
unconstrainedStrategy: Option<TaggingSecretStrategy>,
|
|
363
|
+
constrainedStrategy: Option<TaggingSecretStrategy>,
|
|
364
|
+
): void {
|
|
365
|
+
const apply = (mode: AppTaggingSecretKind, strategy: Option<TaggingSecretStrategy>) => {
|
|
366
|
+
if (strategy.isSome()) {
|
|
367
|
+
this.taggingSecretStrategies.set(mode, strategy.value);
|
|
368
|
+
} else {
|
|
369
|
+
this.taggingSecretStrategies.delete(mode);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
apply(AppTaggingSecretKind.UNCONSTRAINED, unconstrainedStrategy);
|
|
373
|
+
apply(AppTaggingSecretKind.CONSTRAINED, constrainedStrategy);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
setAuthorizeAllUtilityCallTargets(authorizeAll: boolean): void {
|
|
377
|
+
this.authorizeAllUtilityCallTargets = authorizeAll;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
|
|
381
|
+
// Messages are appended to the tree, so the next free slot is simply the current tree size.
|
|
382
|
+
const { size } = await this.stateMachine.synchronizer
|
|
383
|
+
.getCommitted()
|
|
384
|
+
.getTreeInfo(MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
385
|
+
const leafIndex = new Fr(size);
|
|
386
|
+
|
|
387
|
+
const message = new L1ToL2Message(
|
|
388
|
+
new L1Actor(sender, this.chainId.toNumber()),
|
|
389
|
+
new L2Actor(recipient, this.version.toNumber()),
|
|
390
|
+
content,
|
|
391
|
+
secretHash,
|
|
392
|
+
leafIndex,
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
await this.mineBlock({ l1ToL2Messages: [message.hash()] });
|
|
396
|
+
|
|
397
|
+
return leafIndex;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async mineBlock(options: { nullifiers?: Fr[]; l1ToL2Messages?: Fr[] } = {}) {
|
|
306
401
|
const blockNumber = await this.getNextBlockNumber();
|
|
307
402
|
|
|
308
403
|
const txEffect = TxEffect.empty();
|
|
@@ -310,7 +405,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
310
405
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
311
406
|
|
|
312
407
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
313
|
-
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
408
|
+
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees, options.l1ToL2Messages ?? []);
|
|
314
409
|
|
|
315
410
|
const globals = makeGlobalVariables(undefined, {
|
|
316
411
|
blockNumber,
|
|
@@ -324,7 +419,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
324
419
|
|
|
325
420
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
326
421
|
|
|
327
|
-
await this.stateMachine.handleL2Block(block);
|
|
422
|
+
await this.stateMachine.handleL2Block(block, options.l1ToL2Messages ?? []);
|
|
328
423
|
}
|
|
329
424
|
|
|
330
425
|
async privateCallNewFlow(
|
|
@@ -339,11 +434,18 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
339
434
|
authorizedUtilityCallTargets: AztecAddress[],
|
|
340
435
|
gasSettings: GasSettings,
|
|
341
436
|
) {
|
|
437
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
438
|
+
const anchoredContractData = new AnchoredContractData(
|
|
439
|
+
this.contractStore,
|
|
440
|
+
this.stateMachine.contractClassService,
|
|
441
|
+
blockHeader,
|
|
442
|
+
);
|
|
443
|
+
|
|
342
444
|
this.logger.verbose(
|
|
343
|
-
`Executing external function ${await
|
|
445
|
+
`Executing external function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
344
446
|
);
|
|
345
447
|
|
|
346
|
-
const artifact = await
|
|
448
|
+
const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
347
449
|
if (!artifact) {
|
|
348
450
|
const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
|
|
349
451
|
? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
|
|
@@ -355,10 +457,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
355
457
|
|
|
356
458
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
357
459
|
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
358
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
460
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
359
461
|
};
|
|
360
462
|
|
|
361
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
362
463
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
363
464
|
targetContractAddress,
|
|
364
465
|
functionSelector,
|
|
@@ -386,9 +487,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
386
487
|
|
|
387
488
|
const simulator = new WASMSimulator();
|
|
388
489
|
|
|
490
|
+
const transientArrayService = new TransientArrayService();
|
|
389
491
|
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
390
492
|
argsHash,
|
|
391
493
|
txContext,
|
|
494
|
+
txRequestSalt: Fr.ZERO,
|
|
392
495
|
callContext,
|
|
393
496
|
anchorBlockHeader: blockHeader,
|
|
394
497
|
utilityExecutor,
|
|
@@ -397,15 +500,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
397
500
|
executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
398
501
|
noteCache,
|
|
399
502
|
taggingIndexCache,
|
|
400
|
-
|
|
503
|
+
anchoredContractData,
|
|
401
504
|
noteStore: this.noteStore,
|
|
402
505
|
keyStore: this.keyStore,
|
|
403
506
|
addressStore: this.addressStore,
|
|
404
507
|
aztecNode: this.stateMachine.node,
|
|
405
508
|
senderTaggingStore: this.senderTaggingStore,
|
|
406
509
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
407
|
-
|
|
510
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
408
511
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
512
|
+
factService: new FactService(this.factStore, scopes),
|
|
409
513
|
privateEventStore: this.privateEventStore,
|
|
410
514
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
411
515
|
jobId,
|
|
@@ -416,14 +520,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
416
520
|
// contract would perform, including setting senderForTags.
|
|
417
521
|
senderForTags: from,
|
|
418
522
|
simulator,
|
|
419
|
-
|
|
523
|
+
txResolver: this.stateMachine.txResolver,
|
|
420
524
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
421
525
|
hooks: composeHooks({
|
|
422
526
|
authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(
|
|
423
527
|
isStaticCall ? 'private view' : 'private',
|
|
424
528
|
authorizedUtilityCallTargets,
|
|
425
529
|
),
|
|
530
|
+
resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
|
|
426
531
|
}),
|
|
532
|
+
transientArrayService,
|
|
427
533
|
});
|
|
428
534
|
|
|
429
535
|
// Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
|
|
@@ -451,7 +557,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
451
557
|
}),
|
|
452
558
|
);
|
|
453
559
|
|
|
454
|
-
noteCache.finish();
|
|
455
560
|
const nonceGenerator = noteCache.getNonceGenerator();
|
|
456
561
|
result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
|
|
457
562
|
} catch (err) {
|
|
@@ -463,7 +568,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
463
568
|
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
464
569
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
465
570
|
result,
|
|
466
|
-
(addr, sel) =>
|
|
571
|
+
(addr, sel) => anchoredContractData.getDebugFunctionName(addr, sel),
|
|
467
572
|
this.stateMachine.node,
|
|
468
573
|
minRevertibleSideEffectCounter,
|
|
469
574
|
);
|
|
@@ -475,7 +580,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
475
580
|
globals.version = this.version;
|
|
476
581
|
globals.gasFees = GasFees.empty();
|
|
477
582
|
|
|
478
|
-
|
|
583
|
+
await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
479
584
|
|
|
480
585
|
const bindings = this.logger.getBindings();
|
|
481
586
|
const contractsDB = new PublicContractsDB(
|
|
@@ -490,11 +595,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
490
595
|
collectStatistics: false,
|
|
491
596
|
collectCallMetadata: true,
|
|
492
597
|
});
|
|
598
|
+
// The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
|
|
599
|
+
const forkId = forkedWorldTrees.getRevision().forkId;
|
|
493
600
|
const processor = new PublicProcessor(
|
|
494
601
|
globals,
|
|
495
602
|
guardedMerkleTrees,
|
|
496
603
|
contractsDB,
|
|
497
|
-
new
|
|
604
|
+
new PublicTxSimulator(
|
|
605
|
+
this.stateMachine.synchronizer.avmSimulator,
|
|
606
|
+
globals,
|
|
607
|
+
contractsDB,
|
|
608
|
+
forkId,
|
|
609
|
+
config,
|
|
610
|
+
bindings,
|
|
611
|
+
),
|
|
498
612
|
new TestDateProvider(),
|
|
499
613
|
undefined,
|
|
500
614
|
createLogger('simulator:public-processor', bindings),
|
|
@@ -522,7 +636,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
522
636
|
} else if (!processedTx.revertCode.isOK()) {
|
|
523
637
|
if (processedTx.revertReason) {
|
|
524
638
|
try {
|
|
525
|
-
await enrichPublicSimulationError(
|
|
639
|
+
await enrichPublicSimulationError(
|
|
640
|
+
processedTx.revertReason,
|
|
641
|
+
this.contractStore,
|
|
642
|
+
this.stateMachine.contractClassService,
|
|
643
|
+
await this.stateMachine.anchorBlockStore.getBlockHeader(),
|
|
644
|
+
this.logger,
|
|
645
|
+
);
|
|
526
646
|
// eslint-disable-next-line no-empty
|
|
527
647
|
} catch {}
|
|
528
648
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -539,8 +659,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
539
659
|
|
|
540
660
|
if (isStaticCall) {
|
|
541
661
|
await checkpoint!.revert();
|
|
542
|
-
|
|
543
|
-
await forkedWorldTrees.close();
|
|
544
662
|
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
545
663
|
}
|
|
546
664
|
|
|
@@ -561,8 +679,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
561
679
|
|
|
562
680
|
await this.stateMachine.handleL2Block(l2Block);
|
|
563
681
|
|
|
564
|
-
await forkedWorldTrees.close();
|
|
565
|
-
|
|
566
682
|
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
567
683
|
}
|
|
568
684
|
|
|
@@ -573,16 +689,21 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
573
689
|
isStaticCall: boolean,
|
|
574
690
|
gasSettings: GasSettings,
|
|
575
691
|
) {
|
|
692
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
693
|
+
const anchoredContractData = new AnchoredContractData(
|
|
694
|
+
this.contractStore,
|
|
695
|
+
this.stateMachine.contractClassService,
|
|
696
|
+
anchorBlockHeader,
|
|
697
|
+
);
|
|
698
|
+
|
|
576
699
|
this.logger.verbose(
|
|
577
|
-
`Executing public function ${await
|
|
700
|
+
`Executing public function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
578
701
|
);
|
|
579
702
|
|
|
580
703
|
const blockNumber = await this.getNextBlockNumber();
|
|
581
704
|
|
|
582
705
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
583
706
|
|
|
584
|
-
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
585
|
-
|
|
586
707
|
const calldataHash = await computeCalldataHash(calldata);
|
|
587
708
|
const calldataHashedValues = new HashedValues(calldata, calldataHash);
|
|
588
709
|
|
|
@@ -593,7 +714,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
593
714
|
globals.version = this.version;
|
|
594
715
|
globals.gasFees = GasFees.empty();
|
|
595
716
|
|
|
596
|
-
|
|
717
|
+
await using forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
597
718
|
|
|
598
719
|
const bindings2 = this.logger.getBindings();
|
|
599
720
|
const contractsDB = new PublicContractsDB(
|
|
@@ -608,7 +729,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
608
729
|
collectStatistics: false,
|
|
609
730
|
collectCallMetadata: true,
|
|
610
731
|
});
|
|
611
|
-
|
|
732
|
+
// The AVM simulator reads this fork's contracts DB, scoped by fork id, for each simulation.
|
|
733
|
+
const forkId2 = forkedWorldTrees.getRevision().forkId;
|
|
734
|
+
const simulator = new PublicTxSimulator(
|
|
735
|
+
this.stateMachine.synchronizer.avmSimulator,
|
|
736
|
+
globals,
|
|
737
|
+
contractsDB,
|
|
738
|
+
forkId2,
|
|
739
|
+
config,
|
|
740
|
+
bindings2,
|
|
741
|
+
);
|
|
612
742
|
const processor = new PublicProcessor(
|
|
613
743
|
globals,
|
|
614
744
|
guardedMerkleTrees,
|
|
@@ -675,7 +805,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
675
805
|
} else if (!processedTx.revertCode.isOK()) {
|
|
676
806
|
if (processedTx.revertReason) {
|
|
677
807
|
try {
|
|
678
|
-
await enrichPublicSimulationError(
|
|
808
|
+
await enrichPublicSimulationError(
|
|
809
|
+
processedTx.revertReason,
|
|
810
|
+
this.contractStore,
|
|
811
|
+
this.stateMachine.contractClassService,
|
|
812
|
+
anchorBlockHeader,
|
|
813
|
+
this.logger,
|
|
814
|
+
);
|
|
679
815
|
// eslint-disable-next-line no-empty
|
|
680
816
|
} catch {}
|
|
681
817
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -688,9 +824,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
688
824
|
|
|
689
825
|
if (isStaticCall) {
|
|
690
826
|
await checkpoint!.revert();
|
|
691
|
-
|
|
692
|
-
await forkedWorldTrees.close();
|
|
693
|
-
|
|
694
827
|
return returnValues ?? [];
|
|
695
828
|
}
|
|
696
829
|
|
|
@@ -711,30 +844,35 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
711
844
|
|
|
712
845
|
await this.stateMachine.handleL2Block(l2Block);
|
|
713
846
|
|
|
714
|
-
await forkedWorldTrees.close();
|
|
715
|
-
|
|
716
847
|
return returnValues ?? [];
|
|
717
848
|
}
|
|
718
849
|
|
|
719
850
|
async executeUtilityFunction(
|
|
851
|
+
from: AztecAddress | undefined,
|
|
720
852
|
targetContractAddress: AztecAddress,
|
|
721
853
|
functionSelector: FunctionSelector,
|
|
722
854
|
args: Fr[],
|
|
723
855
|
jobId: string,
|
|
724
856
|
authorizedUtilityCallTargets: AztecAddress[],
|
|
725
857
|
) {
|
|
726
|
-
const
|
|
858
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
859
|
+
const anchoredContractData = new AnchoredContractData(
|
|
860
|
+
this.contractStore,
|
|
861
|
+
this.stateMachine.contractClassService,
|
|
862
|
+
blockHeader,
|
|
863
|
+
);
|
|
864
|
+
|
|
865
|
+
const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
727
866
|
if (!artifact) {
|
|
728
867
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
729
868
|
}
|
|
730
869
|
|
|
731
870
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
732
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
733
871
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
734
872
|
targetContractAddress,
|
|
735
873
|
functionSelector,
|
|
736
874
|
async (call, execScopes) => {
|
|
737
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
875
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
738
876
|
},
|
|
739
877
|
blockHeader,
|
|
740
878
|
jobId,
|
|
@@ -749,19 +887,36 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
749
887
|
hideMsgSender: false,
|
|
750
888
|
isStatic: false,
|
|
751
889
|
args,
|
|
752
|
-
returnTypes: [],
|
|
753
890
|
});
|
|
754
891
|
|
|
755
|
-
return this.executeUtilityCall(call,
|
|
892
|
+
return this.executeUtilityCall(call, {
|
|
893
|
+
from,
|
|
894
|
+
scopes: await this.keyStore.getAccounts(),
|
|
895
|
+
jobId,
|
|
896
|
+
authorizedUtilityCallTargets,
|
|
897
|
+
});
|
|
756
898
|
}
|
|
757
899
|
|
|
758
900
|
private async executeUtilityCall(
|
|
759
901
|
call: FunctionCall,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
902
|
+
{
|
|
903
|
+
from = AztecAddress.NULL_MSG_SENDER,
|
|
904
|
+
scopes,
|
|
905
|
+
jobId,
|
|
906
|
+
authorizedUtilityCallTargets = [],
|
|
907
|
+
}: { from?: AztecAddress; scopes: AztecAddress[]; jobId: string; authorizedUtilityCallTargets?: AztecAddress[] },
|
|
763
908
|
): Promise<Fr[]> {
|
|
764
|
-
const
|
|
909
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
910
|
+
const anchoredContractData = new AnchoredContractData(
|
|
911
|
+
this.contractStore,
|
|
912
|
+
this.stateMachine.contractClassService,
|
|
913
|
+
anchorBlockHeader,
|
|
914
|
+
);
|
|
915
|
+
|
|
916
|
+
const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
917
|
+
if (!entryPointArtifact) {
|
|
918
|
+
throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
|
|
919
|
+
}
|
|
765
920
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
766
921
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
767
922
|
}
|
|
@@ -772,26 +927,31 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
772
927
|
});
|
|
773
928
|
|
|
774
929
|
try {
|
|
775
|
-
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
776
930
|
const simulator = new WASMSimulator();
|
|
777
931
|
const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
|
|
778
|
-
await this.executeUtilityCall(syncCall, execScopes, jobId);
|
|
932
|
+
await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId });
|
|
779
933
|
};
|
|
780
934
|
const oracle = new UtilityExecutionOracle({
|
|
781
|
-
|
|
935
|
+
callContext: CallContext.from({
|
|
936
|
+
msgSender: from,
|
|
937
|
+
contractAddress: call.to,
|
|
938
|
+
functionSelector: call.selector,
|
|
939
|
+
isStaticCall: true,
|
|
940
|
+
}),
|
|
782
941
|
authWitnesses: [],
|
|
783
942
|
capsules: [],
|
|
784
943
|
anchorBlockHeader,
|
|
785
|
-
|
|
944
|
+
anchoredContractData,
|
|
786
945
|
noteStore: this.noteStore,
|
|
787
946
|
keyStore: this.keyStore,
|
|
788
947
|
addressStore: this.addressStore,
|
|
789
948
|
aztecNode: this.stateMachine.node,
|
|
790
949
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
791
|
-
|
|
950
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
792
951
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
952
|
+
factService: new FactService(this.factStore, scopes),
|
|
793
953
|
privateEventStore: this.privateEventStore,
|
|
794
|
-
|
|
954
|
+
txResolver: this.stateMachine.txResolver,
|
|
795
955
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
796
956
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
797
957
|
jobId,
|
|
@@ -801,9 +961,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
801
961
|
authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets),
|
|
802
962
|
}),
|
|
803
963
|
utilityExecutor,
|
|
964
|
+
// Execution-tree root (top-level utility run or contract sync): own store; nested frames inherit it.
|
|
965
|
+
transientArrayService: new TransientArrayService(),
|
|
804
966
|
});
|
|
805
967
|
const acirExecutionResult = await simulator
|
|
806
|
-
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact,
|
|
968
|
+
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle))
|
|
807
969
|
.catch((err: Error) => {
|
|
808
970
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
809
971
|
throw new ExecutionError(
|
|
@@ -824,9 +986,19 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
824
986
|
}
|
|
825
987
|
}
|
|
826
988
|
|
|
827
|
-
close():
|
|
989
|
+
close(): {
|
|
990
|
+
nextBlockTimestamp: bigint;
|
|
991
|
+
authwits: Map<string, AuthWitness>;
|
|
992
|
+
taggingSecretStrategies: TXETaggingSecretStrategies;
|
|
993
|
+
authorizeAllUtilityCallTargets: boolean;
|
|
994
|
+
} {
|
|
828
995
|
this.logger.debug('Exiting Top Level Context');
|
|
829
|
-
return
|
|
996
|
+
return {
|
|
997
|
+
nextBlockTimestamp: this.nextBlockTimestamp,
|
|
998
|
+
authwits: this.authwits,
|
|
999
|
+
taggingSecretStrategies: this.taggingSecretStrategies,
|
|
1000
|
+
authorizeAllUtilityCallTargets: this.authorizeAllUtilityCallTargets,
|
|
1001
|
+
};
|
|
830
1002
|
}
|
|
831
1003
|
|
|
832
1004
|
private async getLastBlockNumber(): Promise<BlockNumber> {
|
|
@@ -838,6 +1010,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
838
1010
|
callerContext: 'private' | 'private view' | 'utility',
|
|
839
1011
|
authorizedTargets: AztecAddress[],
|
|
840
1012
|
): ExecutionHooks['authorizeUtilityCall'] | undefined {
|
|
1013
|
+
if (this.authorizeAllUtilityCallTargets) {
|
|
1014
|
+
return authorizeAllUtilityCallsHook;
|
|
1015
|
+
}
|
|
841
1016
|
if (authorizedTargets.length === 0) {
|
|
842
1017
|
return undefined;
|
|
843
1018
|
}
|
|
@@ -847,3 +1022,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
847
1022
|
});
|
|
848
1023
|
}
|
|
849
1024
|
}
|
|
1025
|
+
|
|
1026
|
+
/**
|
|
1027
|
+
* An `authorizeUtilityCall` hook that authorizes every cross-contract utility call.
|
|
1028
|
+
*
|
|
1029
|
+
* Backs the `aztec_txe_setAuthorizeAllUtilityCallTargets` oracle.
|
|
1030
|
+
*/
|
|
1031
|
+
export const authorizeAllUtilityCallsHook: NonNullable<ExecutionHooks['authorizeUtilityCall']> = () =>
|
|
1032
|
+
Promise.resolve({ authorized: true });
|