@aztec/txe 0.0.1-commit.f295ac2 → 0.0.1-commit.fc805bf
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 +3 -3
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +6 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +12 -10
- package/dest/rpc_translator.d.ts +12 -6
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +41 -29
- package/dest/state_machine/archiver.d.ts +2 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +5 -6
- package/dest/state_machine/index.d.ts +3 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +18 -9
- package/dest/state_machine/mock_epoch_cache.d.ts +6 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +5 -6
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +9 -8
- package/dest/utils/block_creation.d.ts +5 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +5 -5
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +8 -10
- package/src/oracle/txe_oracle_top_level_context.ts +26 -9
- package/src/rpc_translator.ts +49 -32
- package/src/state_machine/archiver.ts +4 -8
- package/src/state_machine/index.ts +26 -12
- package/src/state_machine/mock_epoch_cache.ts +5 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +16 -14
- package/src/utils/block_creation.ts +6 -6
package/src/rpc_translator.ts
CHANGED
|
@@ -6,12 +6,11 @@ import {
|
|
|
6
6
|
type IMiscOracle,
|
|
7
7
|
type IPrivateExecutionOracle,
|
|
8
8
|
type IUtilityExecutionOracle,
|
|
9
|
-
|
|
9
|
+
packAsHintedNote,
|
|
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 {
|
|
14
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
15
14
|
|
|
16
15
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
17
16
|
import type { TXESessionStateHandler } from './txe_session.js';
|
|
@@ -352,7 +351,7 @@ export class RPCTranslator {
|
|
|
352
351
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
353
352
|
foreignNumberOfElements: ForeignCallSingle,
|
|
354
353
|
) {
|
|
355
|
-
const blockHash =
|
|
354
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
356
355
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
357
356
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
358
357
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
@@ -368,7 +367,7 @@ export class RPCTranslator {
|
|
|
368
367
|
}
|
|
369
368
|
|
|
370
369
|
async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
371
|
-
const blockHash =
|
|
370
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
372
371
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
373
372
|
|
|
374
373
|
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
@@ -397,7 +396,7 @@ export class RPCTranslator {
|
|
|
397
396
|
foreignOffset: ForeignCallSingle,
|
|
398
397
|
foreignStatus: ForeignCallSingle,
|
|
399
398
|
foreignMaxNotes: ForeignCallSingle,
|
|
400
|
-
|
|
399
|
+
foreignPackedHintedNoteLength: ForeignCallSingle,
|
|
401
400
|
) {
|
|
402
401
|
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
403
402
|
const owner = fromSingle(foreignOwnerIsSome).toBool()
|
|
@@ -418,7 +417,7 @@ export class RPCTranslator {
|
|
|
418
417
|
const offset = fromSingle(foreignOffset).toNumber();
|
|
419
418
|
const status = fromSingle(foreignStatus).toNumber();
|
|
420
419
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
421
|
-
const
|
|
420
|
+
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
422
421
|
|
|
423
422
|
const noteDatas = await this.handlerAsUtility().utilityGetNotes(
|
|
424
423
|
owner,
|
|
@@ -439,7 +438,7 @@ export class RPCTranslator {
|
|
|
439
438
|
);
|
|
440
439
|
|
|
441
440
|
const returnDataAsArrayOfArrays = noteDatas.map(noteData =>
|
|
442
|
-
|
|
441
|
+
packAsHintedNote({
|
|
443
442
|
contractAddress: noteData.contractAddress,
|
|
444
443
|
owner: noteData.owner,
|
|
445
444
|
randomness: noteData.randomness,
|
|
@@ -457,11 +456,7 @@ export class RPCTranslator {
|
|
|
457
456
|
|
|
458
457
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
459
458
|
return toForeignCallResult(
|
|
460
|
-
arrayOfArraysToBoundedVecOfArrays(
|
|
461
|
-
returnDataAsArrayOfForeignCallSingleArrays,
|
|
462
|
-
maxNotes,
|
|
463
|
-
packedRetrievedNoteLength,
|
|
464
|
-
),
|
|
459
|
+
arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength),
|
|
465
460
|
);
|
|
466
461
|
}
|
|
467
462
|
|
|
@@ -517,6 +512,15 @@ export class RPCTranslator {
|
|
|
517
512
|
return toForeignCallResult([]);
|
|
518
513
|
}
|
|
519
514
|
|
|
515
|
+
async privateIsNullifierPending(foreignInnerNullifier: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
|
|
516
|
+
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
517
|
+
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
518
|
+
|
|
519
|
+
const isPending = await this.handlerAsPrivate().privateIsNullifierPending(innerNullifier, contractAddress);
|
|
520
|
+
|
|
521
|
+
return toForeignCallResult([toSingle(new Fr(isPending))]);
|
|
522
|
+
}
|
|
523
|
+
|
|
520
524
|
async utilityCheckNullifierExists(foreignInnerNullifier: ForeignCallSingle) {
|
|
521
525
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
522
526
|
|
|
@@ -570,7 +574,7 @@ export class RPCTranslator {
|
|
|
570
574
|
}
|
|
571
575
|
|
|
572
576
|
async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
|
|
573
|
-
const blockHash =
|
|
577
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
574
578
|
const nullifier = fromSingle(foreignNullifier);
|
|
575
579
|
|
|
576
580
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -637,30 +641,43 @@ export class RPCTranslator {
|
|
|
637
641
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
638
642
|
}
|
|
639
643
|
|
|
640
|
-
async
|
|
644
|
+
async utilityGetNoteHashMembershipWitness(
|
|
645
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
646
|
+
foreignNoteHash: ForeignCallSingle,
|
|
647
|
+
) {
|
|
648
|
+
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
649
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
650
|
+
|
|
651
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
|
|
652
|
+
|
|
653
|
+
if (!witness) {
|
|
654
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
655
|
+
}
|
|
656
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
async utilityGetBlockHashMembershipWitness(
|
|
660
|
+
foreignAnchorBlockHash: ForeignCallSingle,
|
|
641
661
|
foreignBlockHash: ForeignCallSingle,
|
|
642
|
-
foreignTreeId: ForeignCallSingle,
|
|
643
|
-
foreignLeafValue: ForeignCallSingle,
|
|
644
662
|
) {
|
|
645
|
-
const
|
|
646
|
-
const
|
|
647
|
-
const leafValue = fromSingle(foreignLeafValue);
|
|
663
|
+
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
664
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
648
665
|
|
|
649
|
-
const witness = await this.handlerAsUtility().
|
|
666
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
650
667
|
|
|
651
668
|
if (!witness) {
|
|
652
669
|
throw new Error(
|
|
653
|
-
`
|
|
670
|
+
`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`,
|
|
654
671
|
);
|
|
655
672
|
}
|
|
656
|
-
return toForeignCallResult(
|
|
673
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
657
674
|
}
|
|
658
675
|
|
|
659
676
|
async utilityGetLowNullifierMembershipWitness(
|
|
660
677
|
foreignBlockHash: ForeignCallSingle,
|
|
661
678
|
foreignNullifier: ForeignCallSingle,
|
|
662
679
|
) {
|
|
663
|
-
const blockHash =
|
|
680
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
664
681
|
const nullifier = fromSingle(foreignNullifier);
|
|
665
682
|
|
|
666
683
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
@@ -679,7 +696,7 @@ export class RPCTranslator {
|
|
|
679
696
|
return toForeignCallResult([]);
|
|
680
697
|
}
|
|
681
698
|
|
|
682
|
-
public async
|
|
699
|
+
public async utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
683
700
|
foreignContractAddress: ForeignCallSingle,
|
|
684
701
|
foreignNoteValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
685
702
|
foreignEventValidationRequestsArrayBaseSlot: ForeignCallSingle,
|
|
@@ -688,7 +705,7 @@ export class RPCTranslator {
|
|
|
688
705
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
689
706
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
690
707
|
|
|
691
|
-
await this.handlerAsUtility().
|
|
708
|
+
await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(
|
|
692
709
|
contractAddress,
|
|
693
710
|
noteValidationRequestsArrayBaseSlot,
|
|
694
711
|
eventValidationRequestsArrayBaseSlot,
|
|
@@ -826,10 +843,11 @@ export class RPCTranslator {
|
|
|
826
843
|
return toForeignCallResult([]);
|
|
827
844
|
}
|
|
828
845
|
|
|
829
|
-
async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle) {
|
|
846
|
+
async avmOpcodeStorageRead(foreignSlot: ForeignCallSingle, foreignContractAddress: ForeignCallSingle) {
|
|
830
847
|
const slot = fromSingle(foreignSlot);
|
|
848
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
831
849
|
|
|
832
|
-
const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot)).value;
|
|
850
|
+
const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot, contractAddress)).value;
|
|
833
851
|
|
|
834
852
|
return toForeignCallResult([toSingle(new Fr(value))]);
|
|
835
853
|
}
|
|
@@ -901,11 +919,10 @@ export class RPCTranslator {
|
|
|
901
919
|
return toForeignCallResult([]);
|
|
902
920
|
}
|
|
903
921
|
|
|
904
|
-
async avmOpcodeNullifierExists(
|
|
905
|
-
const
|
|
906
|
-
const targetAddress = AztecAddress.fromField(fromSingle(foreignTargetAddress));
|
|
922
|
+
async avmOpcodeNullifierExists(foreignSiloedNullifier: ForeignCallSingle) {
|
|
923
|
+
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
907
924
|
|
|
908
|
-
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(
|
|
925
|
+
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
|
|
909
926
|
|
|
910
927
|
return toForeignCallResult([toSingle(new Fr(exists))]);
|
|
911
928
|
}
|
|
@@ -17,18 +17,14 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
17
17
|
private readonly updater = new ArchiverDataStoreUpdater(this.store);
|
|
18
18
|
|
|
19
19
|
constructor(db: AztecAsyncKVStore) {
|
|
20
|
-
const store = new KVArchiverDataStore(db, 9999);
|
|
20
|
+
const store = new KVArchiverDataStore(db, 9999, { epochDuration: 32 });
|
|
21
21
|
super(store);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await this.updater.setNewCheckpointData(checkpoints, result);
|
|
27
|
-
return true;
|
|
24
|
+
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
|
|
25
|
+
await this.updater.addCheckpoints(checkpoints, result);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
// Abstract method implementations
|
|
31
|
-
|
|
32
28
|
public getRollupAddress(): Promise<EthAddress> {
|
|
33
29
|
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
34
30
|
}
|
|
@@ -63,7 +59,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
63
59
|
if (!checkpointedBlock) {
|
|
64
60
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
65
61
|
}
|
|
66
|
-
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber(number), 1);
|
|
62
|
+
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
67
63
|
if (checkpoint.length === 0) {
|
|
68
64
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
69
65
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
7
|
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
-
import {
|
|
8
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
9
12
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
13
|
|
|
11
14
|
import { TXEArchiver } from './archiver.js';
|
|
@@ -58,15 +61,26 @@ export class TXEStateMachine {
|
|
|
58
61
|
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
public async handleL2Block(block:
|
|
62
|
-
// Create a checkpoint from the block
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
public async handleL2Block(block: L2Block) {
|
|
65
|
+
// Create a checkpoint from the block manually
|
|
66
|
+
const checkpoint = new Checkpoint(
|
|
67
|
+
block.archive,
|
|
68
|
+
CheckpointHeader.from({
|
|
69
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
70
|
+
inHash: Fr.ZERO,
|
|
71
|
+
blobsHash: Fr.ZERO,
|
|
72
|
+
blockHeadersHash: Fr.ZERO,
|
|
73
|
+
epochOutHash: Fr.ZERO,
|
|
74
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
75
|
+
timestamp: block.header.globalVariables.timestamp,
|
|
76
|
+
coinbase: block.header.globalVariables.coinbase,
|
|
77
|
+
feeRecipient: block.header.globalVariables.feeRecipient,
|
|
78
|
+
gasFees: block.header.globalVariables.gasFees,
|
|
79
|
+
totalManaUsed: block.header.totalManaUsed,
|
|
80
|
+
}),
|
|
81
|
+
[block],
|
|
82
|
+
CheckpointNumber.fromBlockNumber(block.number),
|
|
83
|
+
);
|
|
70
84
|
|
|
71
85
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
72
86
|
checkpoint,
|
|
@@ -78,9 +92,9 @@ export class TXEStateMachine {
|
|
|
78
92
|
[],
|
|
79
93
|
);
|
|
80
94
|
await Promise.all([
|
|
81
|
-
this.synchronizer.handleL2Block(block),
|
|
95
|
+
this.synchronizer.handleL2Block(block),
|
|
82
96
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
83
|
-
this.anchorBlockStore.setHeader(block.header),
|
|
97
|
+
this.anchorBlockStore.setHeader(block.header),
|
|
84
98
|
]);
|
|
85
99
|
}
|
|
86
100
|
}
|
|
@@ -16,11 +16,12 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getEpochAndSlotNow(): EpochAndSlot {
|
|
19
|
+
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
20
20
|
return {
|
|
21
21
|
epoch: EpochNumber.ZERO,
|
|
22
22
|
slot: SlotNumber(0),
|
|
23
23
|
ts: 0n,
|
|
24
|
+
nowMs: 0n,
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -41,18 +42,11 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
41
42
|
return 0n;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
nextProposer: EthAddress | undefined;
|
|
47
|
-
currentSlot: SlotNumber;
|
|
48
|
-
nextSlot: SlotNumber;
|
|
49
|
-
}> {
|
|
50
|
-
return Promise.resolve({
|
|
51
|
-
currentProposer: undefined,
|
|
52
|
-
nextProposer: undefined,
|
|
45
|
+
getCurrentAndNextSlot(): { currentSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
46
|
+
return {
|
|
53
47
|
currentSlot: SlotNumber(0),
|
|
54
48
|
nextSlot: SlotNumber(0),
|
|
55
|
-
}
|
|
49
|
+
};
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type {
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -23,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
23
23
|
return new this(nativeWorldStateService);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
public async handleL2Block(block:
|
|
26
|
+
public async handleL2Block(block: L2Block) {
|
|
27
27
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
28
28
|
block,
|
|
29
29
|
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
|
package/src/txe_session.ts
CHANGED
|
@@ -152,7 +152,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
152
152
|
const addressStore = new AddressStore(store);
|
|
153
153
|
const privateEventStore = new PrivateEventStore(store);
|
|
154
154
|
const contractStore = new TXEContractStore(store);
|
|
155
|
-
const noteStore =
|
|
155
|
+
const noteStore = new NoteStore(store);
|
|
156
156
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
157
157
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
158
158
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -162,7 +162,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
162
162
|
|
|
163
163
|
// Create job coordinator and register staged stores
|
|
164
164
|
const jobCoordinator = new JobCoordinator(store);
|
|
165
|
-
jobCoordinator.registerStores([
|
|
165
|
+
jobCoordinator.registerStores([
|
|
166
|
+
capsuleStore,
|
|
167
|
+
senderTaggingStore,
|
|
168
|
+
recipientTaggingStore,
|
|
169
|
+
privateEventStore,
|
|
170
|
+
noteStore,
|
|
171
|
+
]);
|
|
166
172
|
|
|
167
173
|
// Register protocol contracts.
|
|
168
174
|
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
@@ -306,16 +312,14 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
306
312
|
): Promise<PrivateContextInputs> {
|
|
307
313
|
this.exitTopLevelState();
|
|
308
314
|
|
|
309
|
-
await new NoteService(
|
|
310
|
-
this.noteStore,
|
|
311
|
-
this.stateMachine.node,
|
|
312
|
-
this.stateMachine.anchorBlockStore,
|
|
313
|
-
).syncNoteNullifiers(contractAddress);
|
|
314
|
-
|
|
315
315
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
316
316
|
// build the proof), and the *next* block, i.e. the one we'll create once the execution ends, and which will contain
|
|
317
317
|
// a single transaction with the effects of what was done in the test.
|
|
318
318
|
const anchorBlock = await this.stateMachine.node.getBlockHeader(anchorBlockNumber ?? 'latest');
|
|
319
|
+
|
|
320
|
+
await new NoteService(this.noteStore, this.stateMachine.node, anchorBlock!, this.currentJobId).syncNoteNullifiers(
|
|
321
|
+
contractAddress,
|
|
322
|
+
);
|
|
319
323
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
320
324
|
|
|
321
325
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
@@ -347,7 +351,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
347
351
|
this.keyStore,
|
|
348
352
|
this.addressStore,
|
|
349
353
|
this.stateMachine.node,
|
|
350
|
-
this.stateMachine.anchorBlockStore,
|
|
351
354
|
this.senderTaggingStore,
|
|
352
355
|
this.recipientTaggingStore,
|
|
353
356
|
this.senderAddressBookStore,
|
|
@@ -394,6 +397,8 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
394
397
|
async enterUtilityState(contractAddress: AztecAddress = DEFAULT_ADDRESS) {
|
|
395
398
|
this.exitTopLevelState();
|
|
396
399
|
|
|
400
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
401
|
+
|
|
397
402
|
// There is no automatic message discovery and contract-driven syncing process in inlined private or utility
|
|
398
403
|
// contexts, which means that known nullifiers are also not searched for, since it is during the tagging sync that
|
|
399
404
|
// we perform this. We therefore search for known nullifiers now, as otherwise notes that were nullified would not
|
|
@@ -402,11 +407,10 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
402
407
|
await new NoteService(
|
|
403
408
|
this.noteStore,
|
|
404
409
|
this.stateMachine.node,
|
|
405
|
-
|
|
410
|
+
anchorBlockHeader,
|
|
411
|
+
this.currentJobId,
|
|
406
412
|
).syncNoteNullifiers(contractAddress);
|
|
407
413
|
|
|
408
|
-
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
409
|
-
|
|
410
414
|
this.oracleHandler = new UtilityExecutionOracle(
|
|
411
415
|
contractAddress,
|
|
412
416
|
[],
|
|
@@ -417,7 +421,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
417
421
|
this.keyStore,
|
|
418
422
|
this.addressStore,
|
|
419
423
|
this.stateMachine.node,
|
|
420
|
-
this.stateMachine.anchorBlockStore,
|
|
421
424
|
this.recipientTaggingStore,
|
|
422
425
|
this.senderAddressBookStore,
|
|
423
426
|
this.capsuleStore,
|
|
@@ -508,7 +511,6 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
508
511
|
this.keyStore,
|
|
509
512
|
this.addressStore,
|
|
510
513
|
this.stateMachine.node,
|
|
511
|
-
this.stateMachine.anchorBlockStore,
|
|
512
514
|
this.recipientTaggingStore,
|
|
513
515
|
this.senderAddressBookStore,
|
|
514
516
|
this.capsuleStore,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { Body,
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
12
12
|
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
@@ -61,7 +61,7 @@ export async function makeTXEBlockHeader(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Creates an
|
|
64
|
+
* Creates an L2Block with proper archive chaining.
|
|
65
65
|
* This function:
|
|
66
66
|
* 1. Gets the current archive state as lastArchive for the header
|
|
67
67
|
* 2. Creates the block header
|
|
@@ -71,13 +71,13 @@ export async function makeTXEBlockHeader(
|
|
|
71
71
|
* @param worldTrees - The world trees to read/write from
|
|
72
72
|
* @param globalVariables - Global variables for the block
|
|
73
73
|
* @param txEffects - Transaction effects to include in the block
|
|
74
|
-
* @returns The created
|
|
74
|
+
* @returns The created L2Block with proper archive chaining
|
|
75
75
|
*/
|
|
76
76
|
export async function makeTXEBlock(
|
|
77
77
|
worldTrees: MerkleTreeWriteOperations,
|
|
78
78
|
globalVariables: GlobalVariables,
|
|
79
79
|
txEffects: TxEffect[],
|
|
80
|
-
): Promise<
|
|
80
|
+
): Promise<L2Block> {
|
|
81
81
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
82
82
|
|
|
83
83
|
// Update the archive tree with this block's header hash
|
|
@@ -87,9 +87,9 @@ export async function makeTXEBlock(
|
|
|
87
87
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
88
88
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
89
89
|
|
|
90
|
-
//
|
|
90
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint
|
|
91
91
|
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
92
92
|
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
93
93
|
|
|
94
|
-
return new
|
|
94
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
95
95
|
}
|