@aztec/txe 5.0.0-rc.1 → 5.0.0-rc.2
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-URXCCPYF.js +3 -0
- package/dest/AuthRegistry-URXCCPYF.js.map +7 -0
- package/dest/{ContractClassRegistry-EHVIHGEK.js → ContractClassRegistry-5RDBM6TC.js} +1 -1
- package/dest/{ContractClassRegistry-EHVIHGEK.js.map → ContractClassRegistry-5RDBM6TC.js.map} +2 -2
- package/dest/{ContractInstanceRegistry-DWZDXHRG.js → ContractInstanceRegistry-GCR4G4D7.js} +1 -1
- package/dest/{ContractInstanceRegistry-DWZDXHRG.js.map → ContractInstanceRegistry-GCR4G4D7.js.map} +1 -1
- package/dest/{FeeJuice-MI32ZO7B.js → FeeJuice-O3KOSZO5.js} +1 -1
- package/dest/{FeeJuice-MI32ZO7B.js.map → FeeJuice-O3KOSZO5.js.map} +1 -1
- package/dest/HandshakeRegistry-TXSMHMNY.js +3 -0
- package/dest/HandshakeRegistry-TXSMHMNY.js.map +7 -0
- package/dest/MultiCallEntrypoint-P4FSRXAD.js +3 -0
- package/dest/MultiCallEntrypoint-P4FSRXAD.js.map +7 -0
- package/dest/SchnorrAccount-AQZX7ROU.js +3 -0
- package/dest/SchnorrAccount-AQZX7ROU.js.map +7 -0
- package/dest/SchnorrInitializerlessAccount-KMX2H3J6.js +3 -0
- package/dest/SchnorrInitializerlessAccount-KMX2H3J6.js.map +7 -0
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_test_server.js +2 -2
- package/dest/{chunk-UPW55EJX.js → chunk-I6DL4FT2.js} +2 -2
- package/dest/chunk-IAO54JS2.js +266 -0
- package/dest/{chunk-5U25VAFR.js.map → chunk-IAO54JS2.js.map} +4 -4
- package/dest/constants.d.ts +1 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +1 -1
- package/dest/metafile.json +7241 -6706
- package/dest/oracle/interfaces.d.ts +10 -5
- package/dest/oracle/interfaces.d.ts.map +1 -1
- 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 +164 -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 +22 -8
- package/dest/oracle/test-resolver/resolver.d.ts.map +1 -1
- package/dest/oracle/test-resolver/resolver.js +62 -32
- package/dest/oracle/txe_oracle_public_context.d.ts +4 -4
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_registry.d.ts +156 -3
- package/dest/oracle/txe_oracle_registry.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_registry.js +179 -26
- package/dest/oracle/txe_oracle_top_level_context.d.ts +20 -8
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +72 -30
- package/dest/oracle/txe_oracle_version.d.ts +2 -2
- package/dest/oracle/txe_oracle_version.js +2 -2
- package/dest/rpc_translator.d.ts +10 -2
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +69 -5
- 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 +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +3 -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 +6 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +35 -10
- package/dest/state_machine/synchronizer.d.ts +3 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -2
- package/dest/txe_session.d.ts +8 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +53 -27
- 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/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/oracle/interfaces.ts +9 -3
- package/src/oracle/test-resolver/default_fixtures.ts +226 -0
- package/src/oracle/test-resolver/index.ts +1 -2
- package/src/oracle/test-resolver/resolver.ts +74 -41
- package/src/oracle/txe_oracle_public_context.ts +3 -3
- package/src/oracle/txe_oracle_registry.ts +106 -13
- package/src/oracle/txe_oracle_top_level_context.ts +76 -30
- package/src/oracle/txe_oracle_version.ts +2 -2
- package/src/rpc_translator.ts +93 -5
- package/src/state_machine/archiver.ts +0 -1
- package/src/state_machine/dummy_p2p_client.ts +5 -0
- package/src/state_machine/global_variable_builder.ts +2 -16
- package/src/state_machine/index.ts +31 -29
- package/src/state_machine/synchronizer.ts +3 -2
- package/src/txe_session.ts +62 -23
- package/src/utils/block_creation.ts +2 -1
- package/dest/AuthRegistry-CPGFQR26.js +0 -3
- package/dest/AuthRegistry-CPGFQR26.js.map +0 -7
- package/dest/HandshakeRegistry-3KSP3ITH.js +0 -3
- package/dest/HandshakeRegistry-3KSP3ITH.js.map +0 -7
- package/dest/MultiCallEntrypoint-IU7HYFYE.js +0 -3
- package/dest/MultiCallEntrypoint-IU7HYFYE.js.map +0 -7
- package/dest/SchnorrAccount-6TUE7JX4.js +0 -3
- package/dest/SchnorrAccount-6TUE7JX4.js.map +0 -7
- package/dest/SchnorrInitializerlessAccount-S3DU2DJK.js +0 -3
- package/dest/SchnorrInitializerlessAccount-S3DU2DJK.js.map +0 -7
- package/dest/chunk-5U25VAFR.js +0 -265
- 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
- /package/dest/{chunk-UPW55EJX.js.map → chunk-I6DL4FT2.js.map} +0 -0
|
@@ -6,6 +6,7 @@ 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';
|
|
@@ -15,20 +16,25 @@ import {
|
|
|
15
16
|
CapsuleStore,
|
|
16
17
|
type ContractStore,
|
|
17
18
|
type ExecutionHooks,
|
|
19
|
+
FactService,
|
|
20
|
+
FactStore,
|
|
18
21
|
NoteStore,
|
|
19
22
|
ORACLE_VERSION_MAJOR,
|
|
20
23
|
PrivateEventStore,
|
|
21
24
|
RecipientTaggingStore,
|
|
22
|
-
SenderAddressBookStore,
|
|
23
25
|
SenderTaggingStore,
|
|
26
|
+
TaggingSecretSourcesStore,
|
|
27
|
+
type TaggingSecretStrategy,
|
|
24
28
|
composeHooks,
|
|
25
29
|
enrichPublicSimulationError,
|
|
26
30
|
} from '@aztec/pxe/server';
|
|
27
31
|
import {
|
|
32
|
+
CONTRACT_INSTANCE,
|
|
28
33
|
ExecutionNoteCache,
|
|
29
34
|
ExecutionTaggingIndexCache,
|
|
30
35
|
HashedValuesCache,
|
|
31
36
|
type IMiscOracle,
|
|
37
|
+
type Option,
|
|
32
38
|
PrivateExecutionOracle,
|
|
33
39
|
TransientArrayService,
|
|
34
40
|
UtilityExecutionOracle,
|
|
@@ -65,6 +71,7 @@ import {
|
|
|
65
71
|
PublicCallRequest,
|
|
66
72
|
} from '@aztec/stdlib/kernel';
|
|
67
73
|
import { hashPublicKey } from '@aztec/stdlib/keys';
|
|
74
|
+
import { L1Actor, L1ToL2Message, L2Actor } from '@aztec/stdlib/messaging';
|
|
68
75
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
69
76
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
70
77
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -106,13 +113,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
106
113
|
private accountStore: TXEAccountStore,
|
|
107
114
|
private senderTaggingStore: SenderTaggingStore,
|
|
108
115
|
private recipientTaggingStore: RecipientTaggingStore,
|
|
109
|
-
private
|
|
116
|
+
private taggingSecretSourcesStore: TaggingSecretSourcesStore,
|
|
110
117
|
private capsuleStore: CapsuleStore,
|
|
118
|
+
private factStore: FactStore,
|
|
111
119
|
private privateEventStore: PrivateEventStore,
|
|
112
120
|
private nextBlockTimestamp: bigint,
|
|
113
121
|
private version: Fr,
|
|
114
122
|
private chainId: Fr,
|
|
115
123
|
private authwits: Map<string, AuthWitness>,
|
|
124
|
+
private taggingSecretStrategy: TaggingSecretStrategy | undefined,
|
|
116
125
|
private readonly artifactResolver: TXEArtifactResolver,
|
|
117
126
|
private readonly rootPath: string,
|
|
118
127
|
private readonly packageName: string,
|
|
@@ -174,7 +183,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
174
183
|
return (await this.stateMachine.node.getBlockData('latest'))!.header.globalVariables.timestamp;
|
|
175
184
|
}
|
|
176
185
|
|
|
177
|
-
async getLastTxEffects()
|
|
186
|
+
async getLastTxEffects() {
|
|
178
187
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
179
188
|
const block = await this.stateMachine.archiver.getBlock({ number: latestBlockNumber });
|
|
180
189
|
|
|
@@ -209,7 +218,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
209
218
|
contractAddress,
|
|
210
219
|
null,
|
|
211
220
|
async (call, execScopes) => {
|
|
212
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
221
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
213
222
|
},
|
|
214
223
|
blockHeader,
|
|
215
224
|
jobId,
|
|
@@ -251,7 +260,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
private deploymentNullifier(address: AztecAddress): Promise<Fr> {
|
|
254
|
-
return siloNullifier(AztecAddress.
|
|
263
|
+
return siloNullifier(AztecAddress.fromNumberUnsafe(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), address.toField());
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
async deploy(
|
|
@@ -286,14 +295,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
286
295
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
287
296
|
}
|
|
288
297
|
|
|
289
|
-
return
|
|
290
|
-
instance.salt,
|
|
291
|
-
instance.deployer.toField(),
|
|
292
|
-
instance.currentContractClassId,
|
|
293
|
-
instance.initializationHash,
|
|
294
|
-
instance.immutablesHash,
|
|
295
|
-
...instance.publicKeys.toFields(),
|
|
296
|
-
];
|
|
298
|
+
return CONTRACT_INSTANCE.serialization!.fn(instance).flat();
|
|
297
299
|
}
|
|
298
300
|
|
|
299
301
|
/**
|
|
@@ -352,7 +354,31 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
352
354
|
this.authwits.set(authWitness.requestHash.toString(), authWitness);
|
|
353
355
|
}
|
|
354
356
|
|
|
355
|
-
|
|
357
|
+
setTaggingSecretStrategy(strategy: Option<TaggingSecretStrategy>): void {
|
|
358
|
+
this.taggingSecretStrategy = strategy.value;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async sendL1ToL2Message(content: Fr, secretHash: Fr, sender: EthAddress, recipient: AztecAddress): Promise<Fr> {
|
|
362
|
+
// Messages are appended to the tree, so the next free slot is simply the current tree size.
|
|
363
|
+
const { size } = await this.stateMachine.synchronizer
|
|
364
|
+
.getCommitted()
|
|
365
|
+
.getTreeInfo(MerkleTreeId.L1_TO_L2_MESSAGE_TREE);
|
|
366
|
+
const leafIndex = new Fr(size);
|
|
367
|
+
|
|
368
|
+
const message = new L1ToL2Message(
|
|
369
|
+
new L1Actor(sender, this.chainId.toNumber()),
|
|
370
|
+
new L2Actor(recipient, this.version.toNumber()),
|
|
371
|
+
content,
|
|
372
|
+
secretHash,
|
|
373
|
+
leafIndex,
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
await this.mineBlock({ l1ToL2Messages: [message.hash()] });
|
|
377
|
+
|
|
378
|
+
return leafIndex;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
async mineBlock(options: { nullifiers?: Fr[]; l1ToL2Messages?: Fr[] } = {}) {
|
|
356
382
|
const blockNumber = await this.getNextBlockNumber();
|
|
357
383
|
|
|
358
384
|
const txEffect = TxEffect.empty();
|
|
@@ -360,7 +386,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
360
386
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
361
387
|
|
|
362
388
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
363
|
-
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
389
|
+
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees, options.l1ToL2Messages ?? []);
|
|
364
390
|
|
|
365
391
|
const globals = makeGlobalVariables(undefined, {
|
|
366
392
|
blockNumber,
|
|
@@ -374,7 +400,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
374
400
|
|
|
375
401
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
376
402
|
|
|
377
|
-
await this.stateMachine.handleL2Block(block);
|
|
403
|
+
await this.stateMachine.handleL2Block(block, options.l1ToL2Messages ?? []);
|
|
378
404
|
}
|
|
379
405
|
|
|
380
406
|
async privateCallNewFlow(
|
|
@@ -405,7 +431,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
405
431
|
|
|
406
432
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
407
433
|
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
408
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
434
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
409
435
|
};
|
|
410
436
|
|
|
411
437
|
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -437,6 +463,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
437
463
|
const simulator = new WASMSimulator();
|
|
438
464
|
|
|
439
465
|
const transientArrayService = new TransientArrayService();
|
|
466
|
+
const taggingSecretStrategy = this.taggingSecretStrategy;
|
|
440
467
|
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
441
468
|
argsHash,
|
|
442
469
|
txContext,
|
|
@@ -455,8 +482,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
455
482
|
aztecNode: this.stateMachine.node,
|
|
456
483
|
senderTaggingStore: this.senderTaggingStore,
|
|
457
484
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
458
|
-
|
|
485
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
459
486
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
487
|
+
factService: new FactService(this.factStore, scopes),
|
|
460
488
|
privateEventStore: this.privateEventStore,
|
|
461
489
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
462
490
|
jobId,
|
|
@@ -467,13 +495,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
467
495
|
// contract would perform, including setting senderForTags.
|
|
468
496
|
senderForTags: from,
|
|
469
497
|
simulator,
|
|
470
|
-
|
|
498
|
+
txResolver: this.stateMachine.txResolver,
|
|
471
499
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
472
500
|
hooks: composeHooks({
|
|
473
501
|
authorizeUtilityCall: this.buildAuthorizeUtilityCallHook(
|
|
474
502
|
isStaticCall ? 'private view' : 'private',
|
|
475
503
|
authorizedUtilityCallTargets,
|
|
476
504
|
),
|
|
505
|
+
// Only configure the hook when a strategy was explicitly set, so that otherwise the default tagging secret
|
|
506
|
+
// strategy is exercised.
|
|
507
|
+
resolveTaggingSecretStrategy: taggingSecretStrategy ? () => Promise.resolve(taggingSecretStrategy) : undefined,
|
|
477
508
|
}),
|
|
478
509
|
transientArrayService,
|
|
479
510
|
});
|
|
@@ -769,6 +800,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
769
800
|
}
|
|
770
801
|
|
|
771
802
|
async executeUtilityFunction(
|
|
803
|
+
from: AztecAddress | undefined,
|
|
772
804
|
targetContractAddress: AztecAddress,
|
|
773
805
|
functionSelector: FunctionSelector,
|
|
774
806
|
args: Fr[],
|
|
@@ -786,7 +818,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
786
818
|
targetContractAddress,
|
|
787
819
|
functionSelector,
|
|
788
820
|
async (call, execScopes) => {
|
|
789
|
-
await this.executeUtilityCall(call, execScopes, jobId);
|
|
821
|
+
await this.executeUtilityCall(call, { scopes: execScopes, jobId });
|
|
790
822
|
},
|
|
791
823
|
blockHeader,
|
|
792
824
|
jobId,
|
|
@@ -804,14 +836,22 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
804
836
|
returnTypes: [],
|
|
805
837
|
});
|
|
806
838
|
|
|
807
|
-
return this.executeUtilityCall(call,
|
|
839
|
+
return this.executeUtilityCall(call, {
|
|
840
|
+
from,
|
|
841
|
+
scopes: await this.keyStore.getAccounts(),
|
|
842
|
+
jobId,
|
|
843
|
+
authorizedUtilityCallTargets,
|
|
844
|
+
});
|
|
808
845
|
}
|
|
809
846
|
|
|
810
847
|
private async executeUtilityCall(
|
|
811
848
|
call: FunctionCall,
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
849
|
+
{
|
|
850
|
+
from = AztecAddress.NULL_MSG_SENDER,
|
|
851
|
+
scopes,
|
|
852
|
+
jobId,
|
|
853
|
+
authorizedUtilityCallTargets = [],
|
|
854
|
+
}: { from?: AztecAddress; scopes: AztecAddress[]; jobId: string; authorizedUtilityCallTargets?: AztecAddress[] },
|
|
815
855
|
): Promise<Fr[]> {
|
|
816
856
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
817
857
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
@@ -827,10 +867,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
827
867
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
828
868
|
const simulator = new WASMSimulator();
|
|
829
869
|
const utilityExecutor = async (syncCall: FunctionCall, execScopes: AztecAddress[]) => {
|
|
830
|
-
await this.executeUtilityCall(syncCall, execScopes, jobId);
|
|
870
|
+
await this.executeUtilityCall(syncCall, { scopes: execScopes, jobId });
|
|
831
871
|
};
|
|
832
872
|
const oracle = new UtilityExecutionOracle({
|
|
833
|
-
|
|
873
|
+
callContext: CallContext.from({
|
|
874
|
+
msgSender: from,
|
|
875
|
+
contractAddress: call.to,
|
|
876
|
+
functionSelector: call.selector,
|
|
877
|
+
isStaticCall: true,
|
|
878
|
+
}),
|
|
834
879
|
authWitnesses: [],
|
|
835
880
|
capsules: [],
|
|
836
881
|
anchorBlockHeader,
|
|
@@ -840,10 +885,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
840
885
|
addressStore: this.addressStore,
|
|
841
886
|
aztecNode: this.stateMachine.node,
|
|
842
887
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
843
|
-
|
|
888
|
+
taggingSecretSourcesStore: this.taggingSecretSourcesStore,
|
|
844
889
|
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
890
|
+
factService: new FactService(this.factStore, scopes),
|
|
845
891
|
privateEventStore: this.privateEventStore,
|
|
846
|
-
|
|
892
|
+
txResolver: this.stateMachine.txResolver,
|
|
847
893
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
848
894
|
l2TipsStore: this.stateMachine.l2TipsProvider,
|
|
849
895
|
jobId,
|
|
@@ -878,9 +924,9 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
878
924
|
}
|
|
879
925
|
}
|
|
880
926
|
|
|
881
|
-
close(): [bigint, Map<string, AuthWitness
|
|
927
|
+
close(): [bigint, Map<string, AuthWitness>, TaggingSecretStrategy | undefined] {
|
|
882
928
|
this.logger.debug('Exiting Top Level Context');
|
|
883
|
-
return [this.nextBlockTimestamp, this.authwits];
|
|
929
|
+
return [this.nextBlockTimestamp, this.authwits, this.taggingSecretStrategy];
|
|
884
930
|
}
|
|
885
931
|
|
|
886
932
|
private async getLastBlockNumber(): Promise<BlockNumber> {
|
|
@@ -5,7 +5,7 @@
|
|
|
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 =
|
|
8
|
+
export const TXE_ORACLE_VERSION_MAJOR = 2;
|
|
9
9
|
export const TXE_ORACLE_VERSION_MINOR = 2;
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -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 = '118698345ea9d368ca82ea574a051e72f4df0b85454539ade14838a934976b62';
|
package/src/rpc_translator.ts
CHANGED
|
@@ -210,6 +210,25 @@ export class RPCTranslator {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
// eslint-disable-next-line camelcase
|
|
214
|
+
aztec_txe_sendL1ToL2Message(...inputs: ForeignCallArgs) {
|
|
215
|
+
return callTxeHandler({
|
|
216
|
+
oracle: 'aztec_txe_sendL1ToL2Message',
|
|
217
|
+
inputs,
|
|
218
|
+
handler: ([content, secretHash, sender, recipient]) =>
|
|
219
|
+
this.handlerAsTxe().sendL1ToL2Message(content, secretHash, sender, recipient),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// eslint-disable-next-line camelcase
|
|
224
|
+
aztec_txe_setTaggingSecretStrategy(...inputs: ForeignCallArgs) {
|
|
225
|
+
return callTxeHandler({
|
|
226
|
+
oracle: 'aztec_txe_setTaggingSecretStrategy',
|
|
227
|
+
inputs,
|
|
228
|
+
handler: ([strategy]) => this.handlerAsTxe().setTaggingSecretStrategy(strategy),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
213
232
|
// PXE oracles
|
|
214
233
|
|
|
215
234
|
// eslint-disable-next-line camelcase
|
|
@@ -439,7 +458,7 @@ export class RPCTranslator {
|
|
|
439
458
|
return callTxeHandler({
|
|
440
459
|
oracle: 'aztec_utl_getKeyValidationRequest',
|
|
441
460
|
inputs,
|
|
442
|
-
handler: ([pkMHash]) => this.handlerAsUtility().getKeyValidationRequest(pkMHash),
|
|
461
|
+
handler: ([pkMHash, keyIndex]) => this.handlerAsUtility().getKeyValidationRequest(pkMHash, keyIndex),
|
|
443
462
|
});
|
|
444
463
|
}
|
|
445
464
|
|
|
@@ -468,6 +487,16 @@ export class RPCTranslator {
|
|
|
468
487
|
});
|
|
469
488
|
}
|
|
470
489
|
|
|
490
|
+
// eslint-disable-next-line camelcase
|
|
491
|
+
aztec_utl_getL1ToL2MembershipWitness(...inputs: ForeignCallArgs) {
|
|
492
|
+
return callTxeHandler({
|
|
493
|
+
oracle: 'aztec_utl_getL1ToL2MembershipWitness',
|
|
494
|
+
inputs,
|
|
495
|
+
handler: ([contractAddress, messageHash, secret]) =>
|
|
496
|
+
this.handlerAsUtility().getL1ToL2MembershipWitness(contractAddress, messageHash, secret),
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
|
|
471
500
|
// eslint-disable-next-line camelcase
|
|
472
501
|
aztec_utl_getAuthWitness(...inputs: ForeignCallArgs) {
|
|
473
502
|
return callTxeHandler({
|
|
@@ -585,11 +614,11 @@ export class RPCTranslator {
|
|
|
585
614
|
}
|
|
586
615
|
|
|
587
616
|
// eslint-disable-next-line camelcase
|
|
588
|
-
|
|
617
|
+
aztec_utl_getResolvedTxs(...inputs: ForeignCallArgs) {
|
|
589
618
|
return callTxeHandler({
|
|
590
|
-
oracle: '
|
|
619
|
+
oracle: 'aztec_utl_getResolvedTxs',
|
|
591
620
|
inputs,
|
|
592
|
-
handler: ([requestArrayBaseSlot]) => this.handlerAsUtility().
|
|
621
|
+
handler: ([requestArrayBaseSlot]) => this.handlerAsUtility().getResolvedTxs(requestArrayBaseSlot),
|
|
593
622
|
});
|
|
594
623
|
}
|
|
595
624
|
|
|
@@ -806,6 +835,54 @@ export class RPCTranslator {
|
|
|
806
835
|
});
|
|
807
836
|
}
|
|
808
837
|
|
|
838
|
+
// eslint-disable-next-line camelcase
|
|
839
|
+
aztec_utl_recordFact(...inputs: ForeignCallArgs) {
|
|
840
|
+
return callTxeHandler({
|
|
841
|
+
oracle: 'aztec_utl_recordFact',
|
|
842
|
+
inputs,
|
|
843
|
+
handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId, factTypeId, payload, originBlock]) =>
|
|
844
|
+
this.handlerAsUtility().recordFact(
|
|
845
|
+
contractAddress,
|
|
846
|
+
scope,
|
|
847
|
+
factCollectionTypeId,
|
|
848
|
+
factCollectionId,
|
|
849
|
+
factTypeId,
|
|
850
|
+
payload,
|
|
851
|
+
originBlock,
|
|
852
|
+
),
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// eslint-disable-next-line camelcase
|
|
857
|
+
aztec_utl_deleteFactCollection(...inputs: ForeignCallArgs) {
|
|
858
|
+
return callTxeHandler({
|
|
859
|
+
oracle: 'aztec_utl_deleteFactCollection',
|
|
860
|
+
inputs,
|
|
861
|
+
handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId]) =>
|
|
862
|
+
this.handlerAsUtility().deleteFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId),
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// eslint-disable-next-line camelcase
|
|
867
|
+
aztec_utl_getFactCollection(...inputs: ForeignCallArgs) {
|
|
868
|
+
return callTxeHandler({
|
|
869
|
+
oracle: 'aztec_utl_getFactCollection',
|
|
870
|
+
inputs,
|
|
871
|
+
handler: ([contractAddress, scope, factCollectionTypeId, factCollectionId]) =>
|
|
872
|
+
this.handlerAsUtility().getFactCollection(contractAddress, scope, factCollectionTypeId, factCollectionId),
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// eslint-disable-next-line camelcase
|
|
877
|
+
aztec_utl_getFactCollectionsByType(...inputs: ForeignCallArgs) {
|
|
878
|
+
return callTxeHandler({
|
|
879
|
+
oracle: 'aztec_utl_getFactCollectionsByType',
|
|
880
|
+
inputs,
|
|
881
|
+
handler: ([contractAddress, scope, factCollectionTypeId]) =>
|
|
882
|
+
this.handlerAsUtility().getFactCollectionsByType(contractAddress, scope, factCollectionTypeId),
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
|
|
809
886
|
// AVM opcodes
|
|
810
887
|
|
|
811
888
|
// eslint-disable-next-line camelcase
|
|
@@ -1044,8 +1121,9 @@ export class RPCTranslator {
|
|
|
1044
1121
|
return callTxeHandler({
|
|
1045
1122
|
oracle: 'aztec_txe_executeUtilityFunction',
|
|
1046
1123
|
inputs,
|
|
1047
|
-
handler: ([targetContractAddress, functionSelector, args, authorizedUtilityCallTargets]) =>
|
|
1124
|
+
handler: ([from, targetContractAddress, functionSelector, args, authorizedUtilityCallTargets]) =>
|
|
1048
1125
|
this.stateHandler.executeUtilityFunction(
|
|
1126
|
+
from,
|
|
1049
1127
|
targetContractAddress,
|
|
1050
1128
|
functionSelector,
|
|
1051
1129
|
args,
|
|
@@ -1073,6 +1151,16 @@ export class RPCTranslator {
|
|
|
1073
1151
|
});
|
|
1074
1152
|
}
|
|
1075
1153
|
|
|
1154
|
+
// eslint-disable-next-line camelcase
|
|
1155
|
+
aztec_prv_resolveTaggingStrategy(...inputs: ForeignCallArgs) {
|
|
1156
|
+
return callTxeHandler({
|
|
1157
|
+
oracle: 'aztec_prv_resolveTaggingStrategy',
|
|
1158
|
+
inputs,
|
|
1159
|
+
handler: ([sender, recipient, deliveryMode]) =>
|
|
1160
|
+
this.handlerAsPrivate().resolveTaggingStrategy(sender, recipient, deliveryMode),
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1076
1164
|
// eslint-disable-next-line camelcase
|
|
1077
1165
|
aztec_prv_getAppTaggingSecret(...inputs: ForeignCallArgs) {
|
|
1078
1166
|
return callTxeHandler({
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
P2PConfig,
|
|
10
10
|
P2PDuplicateAttestationCallback,
|
|
11
11
|
P2PDuplicateProposalCallback,
|
|
12
|
+
P2POversizedProposalCallback,
|
|
12
13
|
P2PSyncState,
|
|
13
14
|
PeerId,
|
|
14
15
|
ReqRespSubProtocol,
|
|
@@ -237,6 +238,10 @@ export class DummyP2P implements P2P {
|
|
|
237
238
|
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
public registerOversizedProposalCallback(_callback: P2POversizedProposalCallback): void {
|
|
242
|
+
throw new Error('DummyP2P does not implement "registerOversizedProposalCallback"');
|
|
243
|
+
}
|
|
244
|
+
|
|
240
245
|
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
|
|
241
246
|
throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
|
|
242
247
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { SimulationOverridesPlan } from '@aztec/ethereum/contracts';
|
|
2
|
-
import {
|
|
2
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
6
|
import { FEE_ORACLE_LAG, GasFees } from '@aztec/stdlib/gas';
|
|
7
7
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
8
|
-
import {
|
|
9
|
-
type CheckpointGlobalVariables,
|
|
10
|
-
type FeeProvider,
|
|
11
|
-
type GlobalVariableBuilder,
|
|
12
|
-
GlobalVariables,
|
|
13
|
-
} from '@aztec/stdlib/tx';
|
|
8
|
+
import type { CheckpointGlobalVariables, FeeProvider, GlobalVariableBuilder } from '@aztec/stdlib/tx';
|
|
14
9
|
|
|
15
10
|
/** Simple FeeProvider for TXE that returns zero fees. */
|
|
16
11
|
export class TXEFeeProvider implements FeeProvider {
|
|
@@ -24,15 +19,6 @@ export class TXEFeeProvider implements FeeProvider {
|
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
27
|
-
public buildGlobalVariables(
|
|
28
|
-
_blockNumber: BlockNumber,
|
|
29
|
-
_coinbase: EthAddress,
|
|
30
|
-
_feeRecipient: AztecAddress,
|
|
31
|
-
_slotNumber?: SlotNumber,
|
|
32
|
-
): Promise<GlobalVariables> {
|
|
33
|
-
return Promise.resolve(makeGlobalVariables());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
22
|
public buildCheckpointGlobalVariables(
|
|
37
23
|
_coinbase: EthAddress,
|
|
38
24
|
_feeRecipient: AztecAddress,
|
|
@@ -4,7 +4,7 @@ import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
7
|
-
import {
|
|
7
|
+
import { TxResolverService } from '@aztec/pxe/simulator';
|
|
8
8
|
import { L2Block, type L2TipsProvider } from '@aztec/stdlib/block';
|
|
9
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -29,7 +29,7 @@ export class TXEStateMachine {
|
|
|
29
29
|
public archiver: TXEArchiver,
|
|
30
30
|
public anchorBlockStore: AnchorBlockStore,
|
|
31
31
|
public contractSyncService: ContractSyncService,
|
|
32
|
-
public
|
|
32
|
+
public txResolver: TxResolverService,
|
|
33
33
|
) {}
|
|
34
34
|
|
|
35
35
|
public static async create(
|
|
@@ -42,30 +42,31 @@ export class TXEStateMachine {
|
|
|
42
42
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
43
43
|
|
|
44
44
|
const log = createLogger('txe_node');
|
|
45
|
-
const node = new AztecNodeService(
|
|
46
|
-
aztecNodeConfig,
|
|
47
|
-
new DummyP2P(),
|
|
48
|
-
archiver,
|
|
49
|
-
archiver,
|
|
50
|
-
archiver,
|
|
51
|
-
archiver,
|
|
52
|
-
synchronizer,
|
|
53
|
-
undefined,
|
|
54
|
-
undefined,
|
|
55
|
-
undefined,
|
|
56
|
-
undefined,
|
|
57
|
-
async () => {},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
new TXEGlobalVariablesBuilder(),
|
|
61
|
-
|
|
62
|
-
new
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
new TestCircuitVerifier(),
|
|
66
|
-
|
|
45
|
+
const node = new AztecNodeService({
|
|
46
|
+
config: aztecNodeConfig,
|
|
47
|
+
p2pClient: new DummyP2P(),
|
|
48
|
+
blockSource: archiver,
|
|
49
|
+
logsSource: archiver,
|
|
50
|
+
contractDataSource: archiver,
|
|
51
|
+
l1ToL2MessageSource: archiver,
|
|
52
|
+
worldStateSynchronizer: synchronizer,
|
|
53
|
+
sequencer: undefined,
|
|
54
|
+
proverNode: undefined,
|
|
55
|
+
slasherClient: undefined,
|
|
56
|
+
validatorsSentinel: undefined,
|
|
57
|
+
stopStartedWatchers: async () => {},
|
|
58
|
+
l1ChainId: CHAIN_ID,
|
|
59
|
+
version: VERSION,
|
|
60
|
+
globalVariableBuilder: new TXEGlobalVariablesBuilder(),
|
|
61
|
+
rollupContract: undefined,
|
|
62
|
+
feeProvider: new TXEFeeProvider(),
|
|
63
|
+
epochCache: new MockEpochCache(),
|
|
64
|
+
packageVersion: PACKAGE_VERSION,
|
|
65
|
+
peerProofVerifier: new TestCircuitVerifier(),
|
|
66
|
+
rpcProofVerifier: new TestCircuitVerifier(),
|
|
67
|
+
telemetry: undefined,
|
|
67
68
|
log,
|
|
68
|
-
);
|
|
69
|
+
});
|
|
69
70
|
|
|
70
71
|
const contractSyncService = new ContractSyncService(
|
|
71
72
|
node,
|
|
@@ -74,9 +75,9 @@ export class TXEStateMachine {
|
|
|
74
75
|
createLogger('txe:contract_sync'),
|
|
75
76
|
);
|
|
76
77
|
|
|
77
|
-
const
|
|
78
|
+
const txResolver = new TxResolverService(node);
|
|
78
79
|
|
|
79
|
-
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService,
|
|
80
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService, txResolver);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
/** Returns an {@link L2TipsProvider} backed by this node's chain tips. */
|
|
@@ -87,7 +88,7 @@ export class TXEStateMachine {
|
|
|
87
88
|
};
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
public async handleL2Block(block: L2Block) {
|
|
91
|
+
public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
|
|
91
92
|
// Create a checkpoint from the block manually.
|
|
92
93
|
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
93
94
|
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
@@ -106,6 +107,7 @@ export class TXEStateMachine {
|
|
|
106
107
|
feeRecipient: block.header.globalVariables.feeRecipient,
|
|
107
108
|
gasFees: block.header.globalVariables.gasFees,
|
|
108
109
|
totalManaUsed: block.header.totalManaUsed,
|
|
110
|
+
accumulatedFees: block.header.totalFees,
|
|
109
111
|
}),
|
|
110
112
|
[block],
|
|
111
113
|
checkpointNumber,
|
|
@@ -124,7 +126,7 @@ export class TXEStateMachine {
|
|
|
124
126
|
this.contractSyncService.wipe();
|
|
125
127
|
|
|
126
128
|
await Promise.all([
|
|
127
|
-
this.synchronizer.handleL2Block(block),
|
|
129
|
+
this.synchronizer.handleL2Block(block, l1ToL2Messages),
|
|
128
130
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
129
131
|
this.anchorBlockStore.setHeader(block.header),
|
|
130
132
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import type { BlockHash, L2Block } from '@aztec/stdlib/block';
|
|
5
6
|
import type {
|
|
@@ -23,10 +24,10 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
23
24
|
return new this(nativeWorldStateService);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
public async handleL2Block(block: L2Block) {
|
|
27
|
+
public async handleL2Block(block: L2Block, l1ToL2Messages: Fr[] = []) {
|
|
27
28
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
28
29
|
block,
|
|
29
|
-
|
|
30
|
+
padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP),
|
|
30
31
|
);
|
|
31
32
|
|
|
32
33
|
this.blockNumber = block.header.globalVariables.blockNumber;
|