@aztec/txe 0.0.1-commit.2f68f620 → 0.0.1-commit.3100065
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-FSRZIMX6.js +3 -0
- package/dest/AuthRegistry-FSRZIMX6.js.map +7 -0
- package/dest/ContractClassRegistry-N6NA3SFA.js +3 -0
- package/dest/ContractClassRegistry-N6NA3SFA.js.map +7 -0
- package/dest/ContractInstanceRegistry-NADDSLGL.js +3 -0
- package/dest/ContractInstanceRegistry-NADDSLGL.js.map +7 -0
- package/dest/FeeJuice-QBH5JWJV.js +3 -0
- package/dest/FeeJuice-QBH5JWJV.js.map +7 -0
- package/dest/HandshakeRegistry-KKUEU7XW.js +3 -0
- package/dest/HandshakeRegistry-KKUEU7XW.js.map +7 -0
- package/dest/MultiCallEntrypoint-TGICA67H.js +3 -0
- package/dest/MultiCallEntrypoint-TGICA67H.js.map +7 -0
- package/dest/SchnorrAccount-J5T6OKR3.js +3 -0
- package/dest/SchnorrAccount-J5T6OKR3.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js +3 -0
- package/dest/SchnorrInitializerlessAccount-OOES6Q4F.js.map +7 -0
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_test_server.js +2 -2
- package/dest/{chunk-W2NSX64C.js → chunk-PDOEF22H.js} +2 -2
- package/dest/{chunk-W2NSX64C.js.map → chunk-PDOEF22H.js.map} +3 -3
- package/dest/chunk-YP4ODNMQ.js +268 -0
- package/dest/chunk-YP4ODNMQ.js.map +7 -0
- package/dest/constants.d.ts +1 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +1 -1
- 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 +2 -136
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -3
- package/dest/metafile.json +10346 -7008
- package/dest/oracle/interfaces.d.ts +19 -10
- 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 +9 -0
- package/dest/oracle/test-resolver/default_fixtures.d.ts.map +1 -0
- package/dest/oracle/test-resolver/default_fixtures.js +207 -0
- package/dest/oracle/test-resolver/index.d.ts +1 -1
- package/dest/oracle/test-resolver/index.d.ts.map +1 -1
- package/dest/oracle/test-resolver/index.js +1 -2
- package/dest/oracle/test-resolver/resolver.d.ts +21 -7
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
- package/dest/oracle/test-resolver/resolver.js +100 -33
- package/dest/oracle/txe_oracle_public_context.d.ts +9 -9
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +15 -9
- package/dest/oracle/txe_oracle_registry.d.ts +47 -24
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_registry.js +221 -34
- package/dest/oracle/txe_oracle_top_level_context.d.ts +16 -8
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +116 -54
- package/dest/oracle/txe_oracle_version.d.ts +3 -3
- package/dest/oracle/txe_oracle_version.js +3 -3
- package/dest/rpc_translator.d.ts +21 -4
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +150 -80
- package/dest/server.bundle.js +1 -1
- package/dest/state_machine/archiver.d.ts +1 -1
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +1 -2
- 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/synchronizer.d.ts +5 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +6 -2
- package/dest/txe_session.d.ts +26 -18
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +148 -38
- 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 +4 -3
- 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_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 +17 -17
- package/src/bin/oracle_test_server.ts +2 -2
- package/src/constants.ts +1 -1
- package/src/dispatcher_pool.ts +4 -3
- package/src/index.ts +6 -4
- package/src/oracle/interfaces.ts +21 -8
- package/src/oracle/tagging_secret_strategy.ts +25 -0
- package/src/oracle/test-resolver/default_fixtures.ts +282 -0
- package/src/oracle/test-resolver/index.ts +1 -2
- package/src/oracle/test-resolver/resolver.ts +121 -41
- package/src/oracle/txe_oracle_public_context.ts +16 -14
- package/src/oracle/txe_oracle_registry.ts +154 -16
- package/src/oracle/txe_oracle_top_level_context.ts +157 -55
- package/src/oracle/txe_oracle_version.ts +3 -3
- package/src/rpc_translator.ts +205 -107
- package/src/state_machine/archiver.ts +0 -1
- 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/synchronizer.ts +8 -2
- package/src/txe_session.ts +263 -42
- package/src/utils/block_creation.ts +2 -1
- package/src/utils/tx_effect_creation.ts +0 -2
- package/src/utils/txe_public_contract_data_source.ts +6 -4
- package/dest/ContractClassRegistry-PII7Q556.js +0 -3
- package/dest/ContractClassRegistry-PII7Q556.js.map +0 -7
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js +0 -3
- package/dest/ContractInstanceRegistry-3MHLGFNZ.js.map +0 -7
- package/dest/FeeJuice-TQV5AQK7.js +0 -3
- package/dest/FeeJuice-TQV5AQK7.js.map +0 -7
- package/dest/MultiCallEntrypoint-SBJUIJY7.js +0 -3
- package/dest/MultiCallEntrypoint-SBJUIJY7.js.map +0 -7
- package/dest/SchnorrAccount-MQXPIZ44.js +0 -3
- package/dest/SchnorrAccount-MQXPIZ44.js.map +0 -7
- package/dest/chunk-CDITIZHX.js +0 -257
- package/dest/chunk-CDITIZHX.js.map +0 -7
- package/dest/oracle/test-resolver/fixtures.d.ts +0 -43
- package/dest/oracle/test-resolver/fixtures.d.ts.map +0 -1
- package/dest/oracle/test-resolver/fixtures.js +0 -39
- package/src/oracle/test-resolver/fixtures.ts +0 -84
|
@@ -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 {
|
|
56
|
+
CppPublicTxSimulator,
|
|
48
57
|
GuardedMerkleTreeOperations,
|
|
49
58
|
PublicContractsDB,
|
|
50
59
|
PublicProcessor,
|
|
51
|
-
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';
|
|
@@ -89,6 +100,7 @@ import type { TXEAccountStore } from '../utils/txe_account_store.js';
|
|
|
89
100
|
import type { TXEArtifactResolver } from '../utils/txe_artifact_resolver.js';
|
|
90
101
|
import { TXEPublicContractDataSource } from '../utils/txe_public_contract_data_source.js';
|
|
91
102
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
103
|
+
import { type TXETaggingSecretStrategies, makeResolveTaggingSecretStrategyHook } from './tagging_secret_strategy.js';
|
|
92
104
|
|
|
93
105
|
export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
|
|
94
106
|
isMisc = true as const;
|
|
@@ -105,13 +117,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
105
117
|
private accountStore: TXEAccountStore,
|
|
106
118
|
private senderTaggingStore: SenderTaggingStore,
|
|
107
119
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
108
|
-
private
|
|
120
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
109
121
|
private capsuleStore: CapsuleStore,
|
|
122
|
+
private factStore: FactStore,
|
|
110
123
|
private privateEventStore: PrivateEventStore,
|
|
111
124
|
private nextBlockTimestamp: bigint,
|
|
112
125
|
private version: Fr,
|
|
113
126
|
private chainId: Fr,
|
|
114
127
|
private authwits: Map<string, AuthWitness>,
|
|
128
|
+
private taggingSecretStrategies: TXETaggingSecretStrategies,
|
|
115
129
|
private readonly artifactResolver: TXEArtifactResolver,
|
|
116
130
|
private readonly rootPath: string,
|
|
117
131
|
private readonly packageName: string,
|
|
@@ -173,7 +187,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
173
187
|
return (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables.timestamp;
|
|
174
188
|
}
|
|
175
189
|
|
|
176
|
-
async getLastTxEffects() {
|
|
190
|
+
async getLastTxEffects(): Promise<{ txHash: TxHash; noteHashes: Fr[]; nullifiers: Fr[]; privateLogs: PrivateLog[] }> {
|
|
177
191
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
178
192
|
const block = await this.stateMachine.archiver.getBlock({ number: latestBlockNumber });
|
|
179
193
|
|
|
@@ -208,7 +222,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
208
222
|
contractAddress,
|
|
209
223
|
null,
|
|
210
224
|
async (call, execScopes) => {
|
|
211
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
225
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
212
226
|
},
|
|
213
227
|
blockHeader,
|
|
214
228
|
jobId,
|
|
@@ -250,7 +264,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
250
264
|
}
|
|
251
265
|
|
|
252
266
|
private deploymentNullifier(address: AztecAddress): Promise<Fr> {
|
|
253
|
-
return siloNullifier(AztecAddress.
|
|
267
|
+
return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
|
|
254
268
|
}
|
|
255
269
|
|
|
256
270
|
async deploy(
|
|
@@ -285,14 +299,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
285
299
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
286
300
|
}
|
|
287
301
|
|
|
288
|
-
return
|
|
289
|
-
instance.salt,
|
|
290
|
-
instance.deployer.toField(),
|
|
291
|
-
instance.currentContractClassId,
|
|
292
|
-
instance.initializationHash,
|
|
293
|
-
instance.immutablesHash,
|
|
294
|
-
...instance.publicKeys.toFields(),
|
|
295
|
-
];
|
|
302
|
+
return CONTRACT_INSTANCE.serialization!.fn(instance).flat();
|
|
296
303
|
}
|
|
297
304
|
|
|
298
305
|
/**
|
|
@@ -320,7 +327,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
320
327
|
await this.contractStore.addContractInstance(instance);
|
|
321
328
|
await this.contractStore.addContractArtifact(artifact);
|
|
322
329
|
|
|
323
|
-
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
330
|
+
const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), partialAddress);
|
|
324
331
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
325
332
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
326
333
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
@@ -330,7 +337,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
330
337
|
|
|
331
338
|
async createAccount(secret: Fr) {
|
|
332
339
|
// This is a foot gun !
|
|
333
|
-
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
340
|
+
const completeAddress = await this.keyStore.addAccount(await deriveKeys(secret), secret);
|
|
334
341
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
335
342
|
await this.addressStore.addCompleteAddress(completeAddress);
|
|
336
343
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
@@ -351,7 +358,42 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
351
358
|
this.authwits.set(authWitness.requestHash.toString(), authWitness);
|
|
352
359
|
}
|
|
353
360
|
|
|
354
|
-
|
|
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
|
+
async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
|
|
377
|
+
// Messages are appended to the tree, so the next free slot is simply the current tree size.
|
|
378
|
+
const { size } = await this.stateMachine.synchronizer
|
|
379
|
+
.getCommitted()
|
|
380
|
+
.getTreeInfo(MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
381
|
+
const leafIndex = new Fr(size);
|
|
382
|
+
|
|
383
|
+
const message = new L1ToL2Message(
|
|
384
|
+
new L1Actor(sender, this.chainId.toNumber()),
|
|
385
|
+
new L2Actor(recipient, this.version.toNumber()),
|
|
386
|
+
content,
|
|
387
|
+
secretHash,
|
|
388
|
+
leafIndex,
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
await this.mineBlock({ l1ToL2Messages: [message.hash()] });
|
|
392
|
+
|
|
393
|
+
return leafIndex;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
async mineBlock(options: { nullifiers?: Fr[]; l1ToL2Messages?: Fr[] } = {}) {
|
|
355
397
|
const blockNumber = await this.getNextBlockNumber();
|
|
356
398
|
|
|
357
399
|
const txEffect = TxEffect.empty();
|
|
@@ -359,7 +401,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
359
401
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
360
402
|
|
|
361
403
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
362
|
-
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
404
|
+
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees, options.l1ToL2Messages ?? []);
|
|
363
405
|
|
|
364
406
|
const globals = makeGlobalVariables(undefined, {
|
|
365
407
|
blockNumber,
|
|
@@ -373,7 +415,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
373
415
|
|
|
374
416
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
375
417
|
|
|
376
|
-
await this.stateMachine.handleL2Block(block);
|
|
418
|
+
await this.stateMachine.handleL2Block(block, options.l1ToL2Messages ?? []);
|
|
377
419
|
}
|
|
378
420
|
|
|
379
421
|
async privateCallNewFlow(
|
|
@@ -388,11 +430,18 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
388
430
|
authorizedUtilityCallTargets: AztecAddress[],
|
|
389
431
|
gasSettings: GasSettings,
|
|
390
432
|
) {
|
|
433
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
434
|
+
const anchoredContractData = new AnchoredContractData(
|
|
435
|
+
this.contractStore,
|
|
436
|
+
this.stateMachine.contractClassService,
|
|
437
|
+
blockHeader,
|
|
438
|
+
);
|
|
439
|
+
|
|
391
440
|
this.logger.verbose(
|
|
392
|
-
`Executing external function ${await
|
|
441
|
+
`Executing external function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
393
442
|
);
|
|
394
443
|
|
|
395
|
-
const artifact = await
|
|
444
|
+
const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
396
445
|
if (!artifact) {
|
|
397
446
|
const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
|
|
398
447
|
? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
|
|
@@ -404,10 +453,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
404
453
|
|
|
405
454
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
406
455
|
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
407
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
456
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
408
457
|
};
|
|
409
458
|
|
|
410
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
411
459
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
412
460
|
targetContractAddress,
|
|
413
461
|
functionSelector,
|
|
@@ -435,9 +483,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
435
483
|
|
|
436
484
|
const simulator = new WASMSimulator();
|
|
437
485
|
|
|
486
|
+
const transientArrayService = new TransientArrayService();
|
|
438
487
|
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
439
488
|
argsHash,
|
|
440
489
|
txContext,
|
|
490
|
+
// The TXE does not run the init kernel's salt binding, so no tx-request salt is in scope.
|
|
491
|
+
txRequestSalt: Fr.ZERO,
|
|
441
492
|
callContext,
|
|
442
493
|
anchorBlockHeader: blockHeader,
|
|
443
494
|
utilityExecutor,
|
|
@@ -446,15 +497,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
446
497
|
executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
447
498
|
noteCache,
|
|
448
499
|
taggingIndexCache,
|
|
449
|
-
|
|
500
|
+
anchoredContractData,
|
|
450
501
|
noteStore: this.noteStore,
|
|
451
502
|
keyStore: this.keyStore,
|
|
452
503
|
addressStore: this.addressStore,
|
|
453
504
|
aztecNode: this.stateMachine.node,
|
|
454
505
|
senderTaggingStore: this.senderTaggingStore,
|
|
455
506
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
456
|
-
|
|
507
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
457
508
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
509
|
+
factService: new FactService(this.factStore, scopes),
|
|
458
510
|
privateEventStore: this.privateEventStore,
|
|
459
511
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
460
512
|
jobId,
|
|
@@ -465,14 +517,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
465
517
|
// contract would perform, including setting senderForTags.
|
|
466
518
|
senderForTags: from,
|
|
467
519
|
simulator,
|
|
468
|
-
|
|
520
|
+
txResolver: this.stateMachine.txResolver,
|
|
469
521
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
470
522
|
hooks: composeHooks({
|
|
471
523
|
authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(
|
|
472
524
|
isStaticCall ? 'private view' : 'private',
|
|
473
525
|
authorizedUtilityCallTargets,
|
|
474
526
|
),
|
|
527
|
+
resolveTaggingSecretStrategy: makeResolveTaggingSecretStrategyHook(this.taggingSecretStrategies),
|
|
475
528
|
}),
|
|
529
|
+
transientArrayService,
|
|
476
530
|
});
|
|
477
531
|
|
|
478
532
|
// 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.
|
|
@@ -500,7 +554,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
500
554
|
}),
|
|
501
555
|
);
|
|
502
556
|
|
|
503
|
-
noteCache.finish();
|
|
504
557
|
const nonceGenerator = noteCache.getNonceGenerator();
|
|
505
558
|
result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
|
|
506
559
|
} catch (err) {
|
|
@@ -512,7 +565,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
512
565
|
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
513
566
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
514
567
|
result,
|
|
515
|
-
(addr, sel) =>
|
|
568
|
+
(addr, sel) => anchoredContractData.getDebugFunctionName(addr, sel),
|
|
516
569
|
this.stateMachine.node,
|
|
517
570
|
minRevertibleSideEffectCounter,
|
|
518
571
|
);
|
|
@@ -543,7 +596,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
543
596
|
globals,
|
|
544
597
|
guardedMerkleTrees,
|
|
545
598
|
contractsDB,
|
|
546
|
-
new
|
|
599
|
+
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
|
|
547
600
|
new TestDateProvider(),
|
|
548
601
|
undefined,
|
|
549
602
|
createLogger('simulator:public-processor', bindings),
|
|
@@ -571,7 +624,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
571
624
|
} else if (!processedTx.revertCode.isOK()) {
|
|
572
625
|
if (processedTx.revertReason) {
|
|
573
626
|
try {
|
|
574
|
-
await enrichPublicSimulationError(
|
|
627
|
+
await enrichPublicSimulationError(
|
|
628
|
+
processedTx.revertReason,
|
|
629
|
+
this.contractStore,
|
|
630
|
+
this.stateMachine.contractClassService,
|
|
631
|
+
await this.stateMachine.anchorBlockStore.getBlockHeader(),
|
|
632
|
+
this.logger,
|
|
633
|
+
);
|
|
575
634
|
// eslint-disable-next-line no-empty
|
|
576
635
|
} catch {}
|
|
577
636
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -622,16 +681,21 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
622
681
|
isStaticCall: boolean,
|
|
623
682
|
gasSettings: GasSettings,
|
|
624
683
|
) {
|
|
684
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
685
|
+
const anchoredContractData = new AnchoredContractData(
|
|
686
|
+
this.contractStore,
|
|
687
|
+
this.stateMachine.contractClassService,
|
|
688
|
+
anchorBlockHeader,
|
|
689
|
+
);
|
|
690
|
+
|
|
625
691
|
this.logger.verbose(
|
|
626
|
-
`Executing public function ${await
|
|
692
|
+
`Executing public function ${await anchoredContractData.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
627
693
|
);
|
|
628
694
|
|
|
629
695
|
const blockNumber = await this.getNextBlockNumber();
|
|
630
696
|
|
|
631
697
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
632
698
|
|
|
633
|
-
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
634
|
-
|
|
635
699
|
const calldataHash = await computeCalldataHash(calldata);
|
|
636
700
|
const calldataHashedValues = new HashedValues(calldata, calldataHash);
|
|
637
701
|
|
|
@@ -657,7 +721,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
657
721
|
collectStatistics: false,
|
|
658
722
|
collectCallMetadata: true,
|
|
659
723
|
});
|
|
660
|
-
const simulator = new
|
|
724
|
+
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
|
|
661
725
|
const processor = new PublicProcessor(
|
|
662
726
|
globals,
|
|
663
727
|
guardedMerkleTrees,
|
|
@@ -724,7 +788,13 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
724
788
|
} else if (!processedTx.revertCode.isOK()) {
|
|
725
789
|
if (processedTx.revertReason) {
|
|
726
790
|
try {
|
|
727
|
-
await enrichPublicSimulationError(
|
|
791
|
+
await enrichPublicSimulationError(
|
|
792
|
+
processedTx.revertReason,
|
|
793
|
+
this.contractStore,
|
|
794
|
+
this.stateMachine.contractClassService,
|
|
795
|
+
anchorBlockHeader,
|
|
796
|
+
this.logger,
|
|
797
|
+
);
|
|
728
798
|
// eslint-disable-next-line no-empty
|
|
729
799
|
} catch {}
|
|
730
800
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -766,24 +836,31 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
766
836
|
}
|
|
767
837
|
|
|
768
838
|
async executeUtilityFunction(
|
|
839
|
+
from: AztecAddress | undefined,
|
|
769
840
|
targetContractAddress: AztecAddress,
|
|
770
841
|
functionSelector: FunctionSelector,
|
|
771
842
|
args: Fr[],
|
|
772
843
|
jobId: string,
|
|
773
844
|
authorizedUtilityCallTargets: AztecAddress[],
|
|
774
845
|
) {
|
|
775
|
-
const
|
|
846
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
847
|
+
const anchoredContractData = new AnchoredContractData(
|
|
848
|
+
this.contractStore,
|
|
849
|
+
this.stateMachine.contractClassService,
|
|
850
|
+
blockHeader,
|
|
851
|
+
);
|
|
852
|
+
|
|
853
|
+
const artifact = await anchoredContractData.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
776
854
|
if (!artifact) {
|
|
777
855
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
778
856
|
}
|
|
779
857
|
|
|
780
858
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
781
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
782
859
|
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
783
860
|
targetContractAddress,
|
|
784
861
|
functionSelector,
|
|
785
862
|
async (call, execScopes) => {
|
|
786
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
863
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
787
864
|
},
|
|
788
865
|
blockHeader,
|
|
789
866
|
jobId,
|
|
@@ -801,16 +878,34 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
801
878
|
returnTypes: [],
|
|
802
879
|
});
|
|
803
880
|
|
|
804
|
-
return this.executeUtilityCall(call,
|
|
881
|
+
return this.executeUtilityCall(call, {
|
|
882
|
+
from,
|
|
883
|
+
scopes: await this.keyStore.getAccounts(),
|
|
884
|
+
jobId,
|
|
885
|
+
authorizedUtilityCallTargets,
|
|
886
|
+
});
|
|
805
887
|
}
|
|
806
888
|
|
|
807
889
|
private async executeUtilityCall(
|
|
808
890
|
call: FunctionCall,
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
891
|
+
{
|
|
892
|
+
from = AztecAddress.NULL_MSG_SENDER,
|
|
893
|
+
scopes,
|
|
894
|
+
jobId,
|
|
895
|
+
authorizedUtilityCallTargets = [],
|
|
896
|
+
}: { from?: AztecAddress; scopes: AztecAddress[]; jobId: string; authorizedUtilityCallTargets?: AztecAddress[] },
|
|
812
897
|
): Promise<Fr[]> {
|
|
813
|
-
const
|
|
898
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
899
|
+
const anchoredContractData = new AnchoredContractData(
|
|
900
|
+
this.contractStore,
|
|
901
|
+
this.stateMachine.contractClassService,
|
|
902
|
+
anchorBlockHeader,
|
|
903
|
+
);
|
|
904
|
+
|
|
905
|
+
const entryPointArtifact = await anchoredContractData.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
906
|
+
if (!entryPointArtifact) {
|
|
907
|
+
throw new Error(`Cannot run function ${call.selector} on ${call.to}: the contract is not registered.`);
|
|
908
|
+
}
|
|
814
909
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
815
910
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
816
911
|
}
|
|
@@ -821,38 +916,45 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
821
916
|
});
|
|
822
917
|
|
|
823
918
|
try {
|
|
824
|
-
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
825
919
|
const simulator = new WASMSimulator();
|
|
826
920
|
const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
|
|
827
|
-
await this.executeUtilityCall(syncCall, execScopes, jobId);
|
|
921
|
+
await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId, authorizedUtilityCallTargets });
|
|
828
922
|
};
|
|
829
923
|
const oracle = new UtilityExecutionOracle({
|
|
830
|
-
|
|
924
|
+
callContext: CallContext.from({
|
|
925
|
+
msgSender: from,
|
|
926
|
+
contractAddress: call.to,
|
|
927
|
+
functionSelector: call.selector,
|
|
928
|
+
isStaticCall: true,
|
|
929
|
+
}),
|
|
831
930
|
authWitnesses: [],
|
|
832
931
|
capsules: [],
|
|
833
932
|
anchorBlockHeader,
|
|
834
|
-
|
|
933
|
+
anchoredContractData,
|
|
835
934
|
noteStore: this.noteStore,
|
|
836
935
|
keyStore: this.keyStore,
|
|
837
936
|
addressStore: this.addressStore,
|
|
838
937
|
aztecNode: this.stateMachine.node,
|
|
839
938
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
840
|
-
|
|
939
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
841
940
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
941
|
+
factService: new FactService(this.factStore, scopes),
|
|
842
942
|
privateEventStore: this.privateEventStore,
|
|
843
|
-
|
|
943
|
+
txResolver: this.stateMachine.txResolver,
|
|
844
944
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
845
945
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
846
946
|
jobId,
|
|
847
947
|
scopes,
|
|
848
948
|
simulator,
|
|
949
|
+
utilityExecutor,
|
|
849
950
|
hooks: composeHooks({
|
|
850
951
|
authorizeUtilityCall: this.buildAuthorizeUtilityCallHook('utility', authorizedUtilityCallTargets),
|
|
851
952
|
}),
|
|
852
|
-
|
|
953
|
+
// Execution-tree root (top-level utility run or contract sync): own store; nested frames inherit it.
|
|
954
|
+
transientArrayService: new TransientArrayService(),
|
|
853
955
|
});
|
|
854
956
|
const acirExecutionResult = await simulator
|
|
855
|
-
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact,
|
|
957
|
+
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, buildACIRCallback(oracle))
|
|
856
958
|
.catch((err: Error) => {
|
|
857
959
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
858
960
|
throw new ExecutionError(
|
|
@@ -873,9 +975,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
873
975
|
}
|
|
874
976
|
}
|
|
875
977
|
|
|
876
|
-
close(): [bigint, Map<string, AuthWitness
|
|
978
|
+
close(): [bigint, Map<string, AuthWitness>, TXETaggingSecretStrategies] {
|
|
877
979
|
this.logger.debug('Exiting Top Level Context');
|
|
878
|
-
return [this.nextBlockTimestamp, this.authwits];
|
|
980
|
+
return [this.nextBlockTimestamp, this.authwits, this.taggingSecretStrategies];
|
|
879
981
|
}
|
|
880
982
|
|
|
881
983
|
private async getLastBlockNumber(): Promise<BlockNumber> {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The Noir counterparts are in `noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr`.
|
|
7
7
|
*/
|
|
8
|
-
export const TXE_ORACLE_VERSION_MAJOR =
|
|
9
|
-
export const TXE_ORACLE_VERSION_MINOR =
|
|
8
|
+
export const TXE_ORACLE_VERSION_MAJOR = 3;
|
|
9
|
+
export const TXE_ORACLE_VERSION_MINOR = 0;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* This hash is computed from the TXE oracle interfaces (IAvmExecutionOracle and ITxeExecutionOracle) and is used to
|
|
@@ -14,4 +14,4 @@ export const TXE_ORACLE_VERSION_MINOR = 2;
|
|
|
14
14
|
* - TXE_ORACLE_VERSION_MAJOR (and reset MINOR to 0) for breaking changes, or
|
|
15
15
|
* - TXE_ORACLE_VERSION_MINOR for additive changes (new oracle method added).
|
|
16
16
|
*/
|
|
17
|
-
export const TXE_ORACLE_INTERFACE_HASH = '
|
|
17
|
+
export const TXE_ORACLE_INTERFACE_HASH = 'bea75bd85baebd7aa1438efb1defab496d27540bc805a8d854bb74b8d45fd859';
|