@aztec/txe 0.0.1-commit.0b941701 → 0.0.1-commit.134ed76
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/oracle/interfaces.d.ts +2 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +3 -4
- package/dest/oracle/txe_oracle_top_level_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +84 -22
- package/dest/rpc_translator.d.ts +7 -7
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +40 -29
- 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 +2 -0
- package/dest/state_machine/dummy_p2p_client.d.ts +9 -8
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +15 -12
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +14 -9
- package/dest/state_machine/mock_epoch_cache.d.ts +3 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +4 -0
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +64 -8
- package/dest/utils/block_creation.d.ts +1 -1
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +3 -1
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_public_context.ts +3 -5
- package/src/oracle/txe_oracle_top_level_context.ts +100 -71
- package/src/rpc_translator.ts +42 -24
- package/src/state_machine/archiver.ts +2 -0
- package/src/state_machine/dummy_p2p_client.ts +21 -15
- package/src/state_machine/index.ts +24 -9
- package/src/state_machine/mock_epoch_cache.ts +5 -0
- package/src/txe_session.ts +63 -64
- package/src/utils/block_creation.ts +3 -1
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
SenderAddressBookStore,
|
|
23
23
|
SenderTaggingStore,
|
|
24
24
|
enrichPublicSimulationError,
|
|
25
|
-
syncState,
|
|
26
25
|
} from '@aztec/pxe/server';
|
|
27
26
|
import {
|
|
28
27
|
ExecutionNoteCache,
|
|
@@ -132,13 +131,14 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
135
|
-
|
|
134
|
+
utilityLog(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
136
135
|
if (!LogLevels[level]) {
|
|
137
|
-
throw new Error(`Invalid
|
|
136
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
138
137
|
}
|
|
139
138
|
const levelName = LogLevels[level];
|
|
140
139
|
|
|
141
140
|
this.logger[levelName](`${applyStringFormatting(message, fields)}`, { module: `${this.logger.module}:debug_log` });
|
|
141
|
+
return Promise.resolve();
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
txeGetDefaultAddress(): AztecAddress {
|
|
@@ -297,12 +297,24 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
297
297
|
throw new Error(message);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
// When `from` is the zero address (used when creating a new contract account for example),
|
|
301
|
+
// we disable scope filtering by setting effectiveScopes to undefined. This allows these operations
|
|
302
|
+
// to proceed without requiring keys registered for the zero address.
|
|
303
|
+
const effectiveScopes = from.isZero() ? undefined : [from];
|
|
304
|
+
|
|
300
305
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
301
306
|
const utilityExecutor = async (call: FunctionCall) => {
|
|
302
|
-
await this.executeUtilityCall(call);
|
|
307
|
+
await this.executeUtilityCall(call, effectiveScopes);
|
|
303
308
|
};
|
|
304
309
|
|
|
305
|
-
await
|
|
310
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
311
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
312
|
+
targetContractAddress,
|
|
313
|
+
functionSelector,
|
|
314
|
+
utilityExecutor,
|
|
315
|
+
blockHeader,
|
|
316
|
+
this.jobId,
|
|
317
|
+
);
|
|
306
318
|
|
|
307
319
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
308
320
|
|
|
@@ -314,8 +326,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
314
326
|
|
|
315
327
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
316
328
|
|
|
317
|
-
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
318
|
-
|
|
319
329
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
320
330
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
321
331
|
// In production, the account contract sets the min revertible counter before calling the app function.
|
|
@@ -327,43 +337,37 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
327
337
|
|
|
328
338
|
const simulator = new WASMSimulator();
|
|
329
339
|
|
|
330
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
340
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
331
341
|
argsHash,
|
|
332
342
|
txContext,
|
|
333
343
|
callContext,
|
|
334
|
-
|
|
335
|
-
blockHeader,
|
|
344
|
+
anchorBlockHeader: blockHeader,
|
|
336
345
|
utilityExecutor,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
[],
|
|
341
|
-
HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
346
|
+
authWitnesses: Array.from(this.authwits.values()),
|
|
347
|
+
capsules: [],
|
|
348
|
+
executionCache: HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
342
349
|
noteCache,
|
|
343
350
|
taggingIndexCache,
|
|
344
|
-
this.contractStore,
|
|
345
|
-
this.noteStore,
|
|
346
|
-
this.keyStore,
|
|
347
|
-
this.addressStore,
|
|
348
|
-
this.stateMachine.node,
|
|
349
|
-
this.
|
|
350
|
-
this.
|
|
351
|
-
this.
|
|
352
|
-
this.
|
|
353
|
-
this.
|
|
354
|
-
this.
|
|
355
|
-
this.jobId,
|
|
356
|
-
0,
|
|
357
|
-
minRevertibleSideEffectCounter,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
* contract would perform, including setting senderForTags.
|
|
363
|
-
*/
|
|
364
|
-
from,
|
|
351
|
+
contractStore: this.contractStore,
|
|
352
|
+
noteStore: this.noteStore,
|
|
353
|
+
keyStore: this.keyStore,
|
|
354
|
+
addressStore: this.addressStore,
|
|
355
|
+
aztecNode: this.stateMachine.node,
|
|
356
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
357
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
358
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
359
|
+
capsuleStore: this.capsuleStore,
|
|
360
|
+
privateEventStore: this.privateEventStore,
|
|
361
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
362
|
+
jobId: this.jobId,
|
|
363
|
+
totalPublicCalldataCount: 0,
|
|
364
|
+
sideEffectCounter: minRevertibleSideEffectCounter,
|
|
365
|
+
scopes: effectiveScopes,
|
|
366
|
+
// In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
367
|
+
// contract would perform, including setting senderForTags.
|
|
368
|
+
senderForTags: from,
|
|
365
369
|
simulator,
|
|
366
|
-
);
|
|
370
|
+
});
|
|
367
371
|
|
|
368
372
|
// 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.
|
|
369
373
|
let result: PrivateExecutionResult;
|
|
@@ -402,7 +406,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
402
406
|
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
403
407
|
const { publicInputs } = await generateSimulatedProvingResult(
|
|
404
408
|
result,
|
|
405
|
-
this.contractStore,
|
|
409
|
+
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
406
410
|
minRevertibleSideEffectCounter,
|
|
407
411
|
);
|
|
408
412
|
|
|
@@ -415,7 +419,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
415
419
|
|
|
416
420
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
417
421
|
|
|
418
|
-
const
|
|
422
|
+
const bindings = this.logger.getBindings();
|
|
423
|
+
const contractsDB = new PublicContractsDB(
|
|
424
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
425
|
+
bindings,
|
|
426
|
+
);
|
|
419
427
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
420
428
|
const config = PublicSimulatorConfig.from({
|
|
421
429
|
skipFeeEnforcement: true,
|
|
@@ -428,8 +436,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
428
436
|
globals,
|
|
429
437
|
guardedMerkleTrees,
|
|
430
438
|
contractsDB,
|
|
431
|
-
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config),
|
|
439
|
+
new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings),
|
|
432
440
|
new TestDateProvider(),
|
|
441
|
+
undefined,
|
|
442
|
+
createLogger('simulator:public-processor', bindings),
|
|
433
443
|
);
|
|
434
444
|
|
|
435
445
|
const tx = await Tx.create({
|
|
@@ -526,7 +536,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
526
536
|
|
|
527
537
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
528
538
|
|
|
529
|
-
const
|
|
539
|
+
const bindings2 = this.logger.getBindings();
|
|
540
|
+
const contractsDB = new PublicContractsDB(
|
|
541
|
+
new TXEPublicContractDataSource(blockNumber, this.contractStore),
|
|
542
|
+
bindings2,
|
|
543
|
+
);
|
|
530
544
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
531
545
|
const config = PublicSimulatorConfig.from({
|
|
532
546
|
skipFeeEnforcement: true,
|
|
@@ -535,8 +549,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
535
549
|
collectStatistics: false,
|
|
536
550
|
collectCallMetadata: true,
|
|
537
551
|
});
|
|
538
|
-
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config);
|
|
539
|
-
const processor = new PublicProcessor(
|
|
552
|
+
const simulator = new CppPublicTxSimulator(guardedMerkleTrees, contractsDB, globals, config, bindings2);
|
|
553
|
+
const processor = new PublicProcessor(
|
|
554
|
+
globals,
|
|
555
|
+
guardedMerkleTrees,
|
|
556
|
+
contractsDB,
|
|
557
|
+
simulator,
|
|
558
|
+
new TestDateProvider(),
|
|
559
|
+
undefined,
|
|
560
|
+
createLogger('simulator:public-processor', bindings2),
|
|
561
|
+
);
|
|
540
562
|
|
|
541
563
|
// We're simulating a scenario in which private execution immediately enqueues a public call and halts. The private
|
|
542
564
|
// kernel init would in this case inject a nullifier with the transaction request hash as a non-revertible
|
|
@@ -646,25 +668,32 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
646
668
|
}
|
|
647
669
|
|
|
648
670
|
// Sync notes before executing utility function to discover notes from previous transactions
|
|
649
|
-
await
|
|
650
|
-
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
const call = new FunctionCall(
|
|
654
|
-
artifact.name,
|
|
671
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
672
|
+
await this.stateMachine.contractSyncService.ensureContractSynced(
|
|
655
673
|
targetContractAddress,
|
|
656
674
|
functionSelector,
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
675
|
+
async call => {
|
|
676
|
+
await this.executeUtilityCall(call);
|
|
677
|
+
},
|
|
678
|
+
blockHeader,
|
|
679
|
+
this.jobId,
|
|
662
680
|
);
|
|
663
681
|
|
|
682
|
+
const call = FunctionCall.from({
|
|
683
|
+
name: artifact.name,
|
|
684
|
+
to: targetContractAddress,
|
|
685
|
+
selector: functionSelector,
|
|
686
|
+
type: FunctionType.UTILITY,
|
|
687
|
+
hideMsgSender: false,
|
|
688
|
+
isStatic: false,
|
|
689
|
+
args,
|
|
690
|
+
returnTypes: [],
|
|
691
|
+
});
|
|
692
|
+
|
|
664
693
|
return this.executeUtilityCall(call);
|
|
665
694
|
}
|
|
666
695
|
|
|
667
|
-
private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
|
|
696
|
+
private async executeUtilityCall(call: FunctionCall, scopes?: AztecAddress[]): Promise<Fr[]> {
|
|
668
697
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
669
698
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
670
699
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -677,23 +706,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
677
706
|
|
|
678
707
|
try {
|
|
679
708
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
680
|
-
const oracle = new UtilityExecutionOracle(
|
|
681
|
-
call.to,
|
|
682
|
-
[],
|
|
683
|
-
[],
|
|
709
|
+
const oracle = new UtilityExecutionOracle({
|
|
710
|
+
contractAddress: call.to,
|
|
711
|
+
authWitnesses: [],
|
|
712
|
+
capsules: [],
|
|
684
713
|
anchorBlockHeader,
|
|
685
|
-
this.contractStore,
|
|
686
|
-
this.noteStore,
|
|
687
|
-
this.keyStore,
|
|
688
|
-
this.addressStore,
|
|
689
|
-
this.stateMachine.node,
|
|
690
|
-
this.
|
|
691
|
-
this.
|
|
692
|
-
this.
|
|
693
|
-
this.
|
|
694
|
-
this.
|
|
695
|
-
|
|
696
|
-
);
|
|
714
|
+
contractStore: this.contractStore,
|
|
715
|
+
noteStore: this.noteStore,
|
|
716
|
+
keyStore: this.keyStore,
|
|
717
|
+
addressStore: this.addressStore,
|
|
718
|
+
aztecNode: this.stateMachine.node,
|
|
719
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
720
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
721
|
+
capsuleStore: this.capsuleStore,
|
|
722
|
+
privateEventStore: this.privateEventStore,
|
|
723
|
+
jobId: this.jobId,
|
|
724
|
+
scopes,
|
|
725
|
+
});
|
|
697
726
|
const acirExecutionResult = await new WASMSimulator()
|
|
698
727
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
699
728
|
.catch((err: Error) => {
|
package/src/rpc_translator.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@aztec/pxe/simulator';
|
|
11
11
|
import { type ContractArtifact, EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
12
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import {
|
|
13
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
14
14
|
|
|
15
15
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
16
16
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
@@ -328,7 +328,7 @@ export class RPCTranslator {
|
|
|
328
328
|
|
|
329
329
|
// When the argument is a slice, noir automatically adds a length field to oracle call.
|
|
330
330
|
// When the argument is an array, we add the field length manually to the signature.
|
|
331
|
-
|
|
331
|
+
async utilityLog(
|
|
332
332
|
foreignLevel: ForeignCallSingle,
|
|
333
333
|
foreignMessage: ForeignCallArray,
|
|
334
334
|
_foreignLength: ForeignCallSingle,
|
|
@@ -340,7 +340,7 @@ export class RPCTranslator {
|
|
|
340
340
|
.join('');
|
|
341
341
|
const fields = fromArray(foreignFields);
|
|
342
342
|
|
|
343
|
-
this.handlerAsMisc().
|
|
343
|
+
await this.handlerAsMisc().utilityLog(level, message, fields);
|
|
344
344
|
|
|
345
345
|
return toForeignCallResult([]);
|
|
346
346
|
}
|
|
@@ -351,7 +351,7 @@ export class RPCTranslator {
|
|
|
351
351
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
352
352
|
foreignNumberOfElements: ForeignCallSingle,
|
|
353
353
|
) {
|
|
354
|
-
const blockHash =
|
|
354
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
355
355
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
356
356
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
357
357
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
@@ -367,7 +367,7 @@ export class RPCTranslator {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
370
|
-
const blockHash =
|
|
370
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
371
371
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
372
372
|
|
|
373
373
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
@@ -545,12 +545,23 @@ export class RPCTranslator {
|
|
|
545
545
|
);
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
-
async
|
|
548
|
+
async utilityTryGetPublicKeysAndPartialAddress(foreignAddress: ForeignCallSingle) {
|
|
549
549
|
const address = addressFromSingle(foreignAddress);
|
|
550
550
|
|
|
551
|
-
const
|
|
551
|
+
const result = await this.handlerAsUtility().utilityTryGetPublicKeysAndPartialAddress(address);
|
|
552
552
|
|
|
553
|
-
return
|
|
553
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
554
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
555
|
+
if (result === undefined) {
|
|
556
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
557
|
+
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(13).fill(new Fr(0)))]);
|
|
558
|
+
} else {
|
|
559
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
560
|
+
return toForeignCallResult([
|
|
561
|
+
toSingle(new Fr(1)),
|
|
562
|
+
toArray([...result.publicKeys.toFields(), result.partialAddress]),
|
|
563
|
+
]);
|
|
564
|
+
}
|
|
554
565
|
}
|
|
555
566
|
|
|
556
567
|
async utilityGetKeyValidationRequest(foreignPkMHash: ForeignCallSingle) {
|
|
@@ -574,7 +585,7 @@ export class RPCTranslator {
|
|
|
574
585
|
}
|
|
575
586
|
|
|
576
587
|
async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
|
|
577
|
-
const blockHash =
|
|
588
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
578
589
|
const nullifier = fromSingle(foreignNullifier);
|
|
579
590
|
|
|
580
591
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -641,26 +652,34 @@ export class RPCTranslator {
|
|
|
641
652
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
642
653
|
}
|
|
643
654
|
|
|
644
|
-
async utilityGetNoteHashMembershipWitness(
|
|
645
|
-
|
|
646
|
-
|
|
655
|
+
async utilityGetNoteHashMembershipWitness(
|
|
656
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
657
|
+
foreignNoteHash: ForeignCallSingle,
|
|
658
|
+
) {
|
|
659
|
+
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
660
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
647
661
|
|
|
648
|
-
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash,
|
|
662
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
|
|
649
663
|
|
|
650
664
|
if (!witness) {
|
|
651
|
-
throw new Error(`Note hash ${
|
|
665
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
652
666
|
}
|
|
653
667
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
654
668
|
}
|
|
655
669
|
|
|
656
|
-
async
|
|
657
|
-
|
|
658
|
-
|
|
670
|
+
async utilityGetBlockHashMembershipWitness(
|
|
671
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
672
|
+
foreignBlockHash: ForeignCallSingle,
|
|
673
|
+
) {
|
|
674
|
+
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
675
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
659
676
|
|
|
660
|
-
const witness = await this.handlerAsUtility().
|
|
677
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
661
678
|
|
|
662
679
|
if (!witness) {
|
|
663
|
-
throw new Error(
|
|
680
|
+
throw new Error(
|
|
681
|
+
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
682
|
+
);
|
|
664
683
|
}
|
|
665
684
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
666
685
|
}
|
|
@@ -669,7 +688,7 @@ export class RPCTranslator {
|
|
|
669
688
|
foreignBlockHash: ForeignCallSingle,
|
|
670
689
|
foreignNullifier: ForeignCallSingle,
|
|
671
690
|
) {
|
|
672
|
-
const blockHash =
|
|
691
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
673
692
|
const nullifier = fromSingle(foreignNullifier);
|
|
674
693
|
|
|
675
694
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -911,11 +930,10 @@ export class RPCTranslator {
|
|
|
911
930
|
return toForeignCallResult([]);
|
|
912
931
|
}
|
|
913
932
|
|
|
914
|
-
async avmOpcodeNullifierExists(
|
|
915
|
-
const
|
|
916
|
-
const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
|
|
933
|
+
async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
|
|
934
|
+
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
917
935
|
|
|
918
|
-
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(
|
|
936
|
+
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
|
|
919
937
|
|
|
920
938
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
921
939
|
}
|
|
@@ -59,6 +59,8 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
59
59
|
if (!checkpointedBlock) {
|
|
60
60
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
61
61
|
}
|
|
62
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
63
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
62
64
|
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
63
65
|
if (checkpoint.length === 0) {
|
|
64
66
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
P2PBlockReceivedCallback,
|
|
7
7
|
P2PCheckpointReceivedCallback,
|
|
8
8
|
P2PConfig,
|
|
9
|
+
P2PDuplicateAttestationCallback,
|
|
10
|
+
P2PDuplicateProposalCallback,
|
|
9
11
|
P2PSyncState,
|
|
10
12
|
PeerId,
|
|
11
13
|
ReqRespSubProtocol,
|
|
@@ -16,7 +18,7 @@ import type {
|
|
|
16
18
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
17
19
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
18
20
|
import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
19
|
-
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
21
|
+
import type { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
20
22
|
|
|
21
23
|
export class DummyP2P implements P2P {
|
|
22
24
|
public validate(_txs: Tx[]): Promise<void> {
|
|
@@ -71,8 +73,8 @@ export class DummyP2P implements P2P {
|
|
|
71
73
|
throw new Error('DummyP2P does not implement "sendTx"');
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
public
|
|
75
|
-
throw new Error('DummyP2P does not implement "
|
|
76
|
+
public handleFailedExecution(_txHashes: TxHash[]): Promise<void> {
|
|
77
|
+
throw new Error('DummyP2P does not implement "handleFailedExecution"');
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
public getTxByHashFromPool(_txHash: TxHash): Promise<Tx | undefined> {
|
|
@@ -133,8 +135,8 @@ export class DummyP2P implements P2P {
|
|
|
133
135
|
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
134
136
|
}
|
|
135
137
|
|
|
136
|
-
public
|
|
137
|
-
throw new Error('DummyP2P does not implement "
|
|
138
|
+
public addOwnCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
139
|
+
throw new Error('DummyP2P does not implement "addOwnCheckpointAttestations"');
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -157,14 +159,6 @@ export class DummyP2P implements P2P {
|
|
|
157
159
|
throw new Error('DummyP2P does not implement "sync"');
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
public requestTxsByHash(_txHashes: TxHash[]): Promise<Tx[]> {
|
|
161
|
-
throw new Error('DummyP2P does not implement "requestTxsByHash"');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
public getTxs(_filter: 'all' | 'pending' | 'mined'): Promise<Tx[]> {
|
|
165
|
-
throw new Error('DummyP2P does not implement "getTxs"');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
162
|
public getTxsByHashFromPool(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
169
163
|
throw new Error('DummyP2P does not implement "getTxsByHashFromPool"');
|
|
170
164
|
}
|
|
@@ -189,8 +183,12 @@ export class DummyP2P implements P2P {
|
|
|
189
183
|
throw new Error('DummyP2P does not implement "getSyncedLatestSlot"');
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
|
|
193
|
-
throw new Error('DummyP2P does not implement "
|
|
186
|
+
protectTxs(_txHashes: TxHash[], _blockHeader: BlockHeader): Promise<TxHash[]> {
|
|
187
|
+
throw new Error('DummyP2P does not implement "protectTxs".');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
prepareForSlot(_slotNumber: SlotNumber): Promise<void> {
|
|
191
|
+
return Promise.resolve();
|
|
194
192
|
}
|
|
195
193
|
|
|
196
194
|
addReqRespSubProtocol(
|
|
@@ -206,4 +204,12 @@ export class DummyP2P implements P2P {
|
|
|
206
204
|
|
|
207
205
|
//This is no-op
|
|
208
206
|
public registerThisValidatorAddresses(_address: EthAddress[]): void {}
|
|
207
|
+
|
|
208
|
+
public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {
|
|
209
|
+
throw new Error('DummyP2P does not implement "registerDuplicateProposalCallback"');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {
|
|
213
|
+
throw new Error('DummyP2P does not implement "registerDuplicateAttestationCallback"');
|
|
214
|
+
}
|
|
209
215
|
}
|
|
@@ -3,8 +3,7 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
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
|
-
import type
|
|
7
|
-
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
+
import { type AnchorBlockStore, type ContractStore, ContractSyncService, type NoteStore } from '@aztec/pxe/server';
|
|
8
7
|
import { L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
9
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -26,13 +25,16 @@ export class TXEStateMachine {
|
|
|
26
25
|
public synchronizer: TXESynchronizer,
|
|
27
26
|
public archiver: TXEArchiver,
|
|
28
27
|
public anchorBlockStore: AnchorBlockStore,
|
|
28
|
+
public contractSyncService: ContractSyncService,
|
|
29
29
|
) {}
|
|
30
30
|
|
|
31
|
-
public static async create(
|
|
32
|
-
|
|
31
|
+
public static async create(
|
|
32
|
+
archiver: TXEArchiver,
|
|
33
|
+
anchorBlockStore: AnchorBlockStore,
|
|
34
|
+
contractStore: ContractStore,
|
|
35
|
+
noteStore: NoteStore,
|
|
36
|
+
) {
|
|
33
37
|
const synchronizer = await TXESynchronizer.create();
|
|
34
|
-
const anchorBlockStore = new AnchorBlockStore(db);
|
|
35
|
-
|
|
36
38
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
37
39
|
|
|
38
40
|
const log = createLogger('txe_node');
|
|
@@ -58,11 +60,21 @@ export class TXEStateMachine {
|
|
|
58
60
|
log,
|
|
59
61
|
);
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
const contractSyncService = new ContractSyncService(
|
|
64
|
+
node,
|
|
65
|
+
contractStore,
|
|
66
|
+
noteStore,
|
|
67
|
+
createLogger('txe:contract_sync'),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return new this(node, synchronizer, archiver, anchorBlockStore, contractSyncService);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
public async handleL2Block(block: L2Block) {
|
|
65
|
-
// Create a checkpoint from the block manually
|
|
74
|
+
// Create a checkpoint from the block manually.
|
|
75
|
+
// TXE uses 1-block-per-checkpoint for testing simplicity, so we can use block number as checkpoint number.
|
|
76
|
+
// This uses the deprecated fromBlockNumber method intentionally for the TXE testing environment.
|
|
77
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(block.number);
|
|
66
78
|
const checkpoint = new Checkpoint(
|
|
67
79
|
block.archive,
|
|
68
80
|
CheckpointHeader.from({
|
|
@@ -79,7 +91,7 @@ export class TXEStateMachine {
|
|
|
79
91
|
totalManaUsed: block.header.totalManaUsed,
|
|
80
92
|
}),
|
|
81
93
|
[block],
|
|
82
|
-
|
|
94
|
+
checkpointNumber,
|
|
83
95
|
);
|
|
84
96
|
|
|
85
97
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
@@ -91,6 +103,9 @@ export class TXEStateMachine {
|
|
|
91
103
|
),
|
|
92
104
|
[],
|
|
93
105
|
);
|
|
106
|
+
// Wipe contract sync cache when anchor block changes (mirrors BlockSynchronizer behavior)
|
|
107
|
+
this.contractSyncService.wipe();
|
|
108
|
+
|
|
94
109
|
await Promise.all([
|
|
95
110
|
this.synchronizer.handleL2Block(block),
|
|
96
111
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
2
|
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { EmptyL1RollupConstants, type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Mock implementation of the EpochCacheInterface used to satisfy dependencies of AztecNodeService.
|
|
@@ -64,4 +65,8 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
64
65
|
filterInCommittee(_slot: SlotTag, _validators: EthAddress[]): Promise<EthAddress[]> {
|
|
65
66
|
return Promise.resolve([]);
|
|
66
67
|
}
|
|
68
|
+
|
|
69
|
+
getL1Constants(): L1RollupConstants {
|
|
70
|
+
return EmptyL1RollupConstants;
|
|
71
|
+
}
|
|
67
72
|
}
|