@aztec/txe 0.0.1-commit.6d3c34e → 0.0.1-commit.9372f48
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/constants.d.ts +1 -2
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.js +0 -1
- 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 +3 -3
- 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 +3 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +30 -22
- package/dest/rpc_translator.d.ts +16 -10
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +53 -40
- package/dest/state_machine/archiver.d.ts +20 -69
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +34 -178
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +22 -4
- 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 +7 -7
- 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 +5 -3
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +31 -15
- package/dest/util/encoding.d.ts +17 -17
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +16 -4
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/constants.ts +0 -1
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +6 -8
- package/src/oracle/txe_oracle_top_level_context.ts +50 -24
- package/src/rpc_translator.ts +62 -47
- package/src/state_machine/archiver.ts +35 -234
- package/src/state_machine/index.ts +26 -4
- package/src/state_machine/mock_epoch_cache.ts +6 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +38 -24
- package/src/utils/block_creation.ts +17 -16
- package/src/utils/tx_effect_creation.ts +3 -11
package/dest/rpc_translator.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fr, Point } from '@aztec/aztec.js/fields';
|
|
2
2
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
3
3
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
4
|
-
import {
|
|
4
|
+
import { packAsHintedNote } from '@aztec/pxe/simulator';
|
|
5
5
|
import { EventSelector, FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import {
|
|
7
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
8
8
|
import { addressFromSingle, arrayOfArraysToBoundedVecOfArrays, arrayToBoundedVec, bufferToU8Array, fromArray, fromSingle, fromUintArray, fromUintBoundedVec, toArray, toForeignCallResult, toSingle } from './util/encoding.js';
|
|
9
9
|
const MAX_EVENT_LEN = 12; // This is MAX_MESSAGE_CONTENT_LEN - PRIVATE_EVENT_RESERVED_FIELDS
|
|
10
10
|
const MAX_PRIVATE_EVENTS_PER_TXE_QUERY = 5;
|
|
@@ -216,26 +216,26 @@ export class RPCTranslator {
|
|
|
216
216
|
this.handlerAsMisc().utilityDebugLog(level, message, fields);
|
|
217
217
|
return toForeignCallResult([]);
|
|
218
218
|
}
|
|
219
|
-
async utilityStorageRead(foreignContractAddress, foreignStartStorageSlot,
|
|
219
|
+
async utilityStorageRead(foreignBlockHash, foreignContractAddress, foreignStartStorageSlot, foreignNumberOfElements) {
|
|
220
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
220
221
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
221
222
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
222
|
-
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
223
223
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
224
|
-
const values = await this.handlerAsUtility().utilityStorageRead(contractAddress, startStorageSlot,
|
|
224
|
+
const values = await this.handlerAsUtility().utilityStorageRead(blockHash, contractAddress, startStorageSlot, numberOfElements);
|
|
225
225
|
return toForeignCallResult([
|
|
226
226
|
toArray(values)
|
|
227
227
|
]);
|
|
228
228
|
}
|
|
229
|
-
async utilityGetPublicDataWitness(
|
|
230
|
-
const
|
|
229
|
+
async utilityGetPublicDataWitness(foreignBlockHash, foreignLeafSlot) {
|
|
230
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
231
231
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
232
|
-
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(
|
|
232
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
233
233
|
if (!witness) {
|
|
234
|
-
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${
|
|
234
|
+
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
235
235
|
}
|
|
236
236
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
237
237
|
}
|
|
238
|
-
async utilityGetNotes(foreignOwnerIsSome, foreignOwnerValue, foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes,
|
|
238
|
+
async utilityGetNotes(foreignOwnerIsSome, foreignOwnerValue, foreignStorageSlot, foreignNumSelects, foreignSelectByIndexes, foreignSelectByOffsets, foreignSelectByLengths, foreignSelectValues, foreignSelectComparators, foreignSortByIndexes, foreignSortByOffsets, foreignSortByLengths, foreignSortOrder, foreignLimit, foreignOffset, foreignStatus, foreignMaxNotes, foreignPackedHintedNoteLength) {
|
|
239
239
|
// Parse Option<AztecAddress>: ownerIsSome is 0 for None, 1 for Some
|
|
240
240
|
const owner = fromSingle(foreignOwnerIsSome).toBool() ? AztecAddress.fromField(fromSingle(foreignOwnerValue)) : undefined;
|
|
241
241
|
const storageSlot = fromSingle(foreignStorageSlot);
|
|
@@ -253,21 +253,21 @@ export class RPCTranslator {
|
|
|
253
253
|
const offset = fromSingle(foreignOffset).toNumber();
|
|
254
254
|
const status = fromSingle(foreignStatus).toNumber();
|
|
255
255
|
const maxNotes = fromSingle(foreignMaxNotes).toNumber();
|
|
256
|
-
const
|
|
256
|
+
const packedHintedNoteLength = fromSingle(foreignPackedHintedNoteLength).toNumber();
|
|
257
257
|
const noteDatas = await this.handlerAsUtility().utilityGetNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status);
|
|
258
|
-
const returnDataAsArrayOfArrays = noteDatas.map((noteData)=>
|
|
258
|
+
const returnDataAsArrayOfArrays = noteDatas.map((noteData)=>packAsHintedNote({
|
|
259
259
|
contractAddress: noteData.contractAddress,
|
|
260
260
|
owner: noteData.owner,
|
|
261
261
|
randomness: noteData.randomness,
|
|
262
262
|
storageSlot: noteData.storageSlot,
|
|
263
263
|
noteNonce: noteData.noteNonce,
|
|
264
|
-
|
|
264
|
+
isPending: noteData.isPending,
|
|
265
265
|
note: noteData.note
|
|
266
266
|
}));
|
|
267
267
|
// Now we convert each sub-array to an array of ForeignCallSingles
|
|
268
268
|
const returnDataAsArrayOfForeignCallSingleArrays = returnDataAsArrayOfArrays.map((subArray)=>subArray.map(toSingle));
|
|
269
269
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
270
|
-
return toForeignCallResult(arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes,
|
|
270
|
+
return toForeignCallResult(arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfForeignCallSingleArrays, maxNotes, packedHintedNoteLength));
|
|
271
271
|
}
|
|
272
272
|
privateNotifyCreatedNote(foreignOwner, foreignStorageSlot, foreignRandomness, foreignNoteTypeId, foreignNote, foreignNoteHash, foreignCounter) {
|
|
273
273
|
const owner = addressFromSingle(foreignOwner);
|
|
@@ -292,6 +292,14 @@ export class RPCTranslator {
|
|
|
292
292
|
await this.handlerAsPrivate().privateNotifyCreatedNullifier(innerNullifier);
|
|
293
293
|
return toForeignCallResult([]);
|
|
294
294
|
}
|
|
295
|
+
async privateIsNullifierPending(foreignInnerNullifier, foreignContractAddress) {
|
|
296
|
+
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
297
|
+
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
298
|
+
const isPending = await this.handlerAsPrivate().privateIsNullifierPending(innerNullifier, contractAddress);
|
|
299
|
+
return toForeignCallResult([
|
|
300
|
+
toSingle(new Fr(isPending))
|
|
301
|
+
]);
|
|
302
|
+
}
|
|
295
303
|
async utilityCheckNullifierExists(foreignInnerNullifier) {
|
|
296
304
|
const innerNullifier = fromSingle(foreignInnerNullifier);
|
|
297
305
|
const exists = await this.handlerAsUtility().utilityCheckNullifierExists(innerNullifier);
|
|
@@ -328,12 +336,12 @@ export class RPCTranslator {
|
|
|
328
336
|
privateCallPrivateFunction(_foreignTargetContractAddress, _foreignFunctionSelector, _foreignArgsHash, _foreignSideEffectCounter, _foreignIsStaticCall) {
|
|
329
337
|
throw new Error('Contract calls are forbidden inside a `TestEnvironment::private_context`, use `private_call` instead');
|
|
330
338
|
}
|
|
331
|
-
async utilityGetNullifierMembershipWitness(
|
|
332
|
-
const
|
|
339
|
+
async utilityGetNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
|
|
340
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
333
341
|
const nullifier = fromSingle(foreignNullifier);
|
|
334
|
-
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
|
|
342
|
+
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
335
343
|
if (!witness) {
|
|
336
|
-
throw new Error(`Nullifier membership witness not found at block ${
|
|
344
|
+
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
337
345
|
}
|
|
338
346
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
339
347
|
}
|
|
@@ -375,25 +383,30 @@ export class RPCTranslator {
|
|
|
375
383
|
}
|
|
376
384
|
return toForeignCallResult(header.toFields().map(toSingle));
|
|
377
385
|
}
|
|
378
|
-
async
|
|
379
|
-
const
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
386
|
+
async utilityGetNoteHashMembershipWitness(foreignAnchorBlockHash, foreignNoteHash) {
|
|
387
|
+
const blockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
388
|
+
const noteHash = fromSingle(foreignNoteHash);
|
|
389
|
+
const witness = await this.handlerAsUtility().utilityGetNoteHashMembershipWitness(blockHash, noteHash);
|
|
383
390
|
if (!witness) {
|
|
384
|
-
throw new Error(`
|
|
391
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
385
392
|
}
|
|
386
|
-
return toForeignCallResult(
|
|
387
|
-
toSingle(witness[0]),
|
|
388
|
-
toArray(witness.slice(1))
|
|
389
|
-
]);
|
|
393
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
390
394
|
}
|
|
391
|
-
async
|
|
392
|
-
const
|
|
395
|
+
async utilityGetBlockHashMembershipWitness(foreignAnchorBlockHash, foreignBlockHash) {
|
|
396
|
+
const anchorBlockHash = new BlockHash(fromSingle(foreignAnchorBlockHash));
|
|
397
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
398
|
+
const witness = await this.handlerAsUtility().utilityGetBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
399
|
+
if (!witness) {
|
|
400
|
+
throw new Error(`Block hash ${blockHash.toString()} not found in the archive tree at anchor block ${anchorBlockHash.toString()}.`);
|
|
401
|
+
}
|
|
402
|
+
return toForeignCallResult(witness.toNoirRepresentation());
|
|
403
|
+
}
|
|
404
|
+
async utilityGetLowNullifierMembershipWitness(foreignBlockHash, foreignNullifier) {
|
|
405
|
+
const blockHash = new BlockHash(fromSingle(foreignBlockHash));
|
|
393
406
|
const nullifier = fromSingle(foreignNullifier);
|
|
394
|
-
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
|
|
407
|
+
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
395
408
|
if (!witness) {
|
|
396
|
-
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${
|
|
409
|
+
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
397
410
|
}
|
|
398
411
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
399
412
|
}
|
|
@@ -402,11 +415,11 @@ export class RPCTranslator {
|
|
|
402
415
|
await this.handlerAsUtility().utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot);
|
|
403
416
|
return toForeignCallResult([]);
|
|
404
417
|
}
|
|
405
|
-
async
|
|
418
|
+
async utilityValidateAndStoreEnqueuedNotesAndEvents(foreignContractAddress, foreignNoteValidationRequestsArrayBaseSlot, foreignEventValidationRequestsArrayBaseSlot) {
|
|
406
419
|
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
407
420
|
const noteValidationRequestsArrayBaseSlot = fromSingle(foreignNoteValidationRequestsArrayBaseSlot);
|
|
408
421
|
const eventValidationRequestsArrayBaseSlot = fromSingle(foreignEventValidationRequestsArrayBaseSlot);
|
|
409
|
-
await this.handlerAsUtility().
|
|
422
|
+
await this.handlerAsUtility().utilityValidateAndStoreEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot);
|
|
410
423
|
return toForeignCallResult([]);
|
|
411
424
|
}
|
|
412
425
|
async utilityBulkRetrieveLogs(foreignContractAddress, foreignLogRetrievalRequestsArrayBaseSlot, foreignLogRetrievalResponsesArrayBaseSlot) {
|
|
@@ -487,9 +500,10 @@ export class RPCTranslator {
|
|
|
487
500
|
// TODO(#8811): Implement
|
|
488
501
|
return toForeignCallResult([]);
|
|
489
502
|
}
|
|
490
|
-
async avmOpcodeStorageRead(foreignSlot) {
|
|
503
|
+
async avmOpcodeStorageRead(foreignSlot, foreignContractAddress) {
|
|
491
504
|
const slot = fromSingle(foreignSlot);
|
|
492
|
-
const
|
|
505
|
+
const contractAddress = AztecAddress.fromField(fromSingle(foreignContractAddress));
|
|
506
|
+
const value = (await this.handlerAsAvm().avmOpcodeStorageRead(slot, contractAddress)).value;
|
|
493
507
|
return toForeignCallResult([
|
|
494
508
|
toSingle(new Fr(value))
|
|
495
509
|
]);
|
|
@@ -543,10 +557,9 @@ export class RPCTranslator {
|
|
|
543
557
|
await this.handlerAsAvm().avmOpcodeEmitNoteHash(noteHash);
|
|
544
558
|
return toForeignCallResult([]);
|
|
545
559
|
}
|
|
546
|
-
async avmOpcodeNullifierExists(
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(innerNullifier, targetAddress);
|
|
560
|
+
async avmOpcodeNullifierExists(foreignSiloedNullifier) {
|
|
561
|
+
const siloedNullifier = fromSingle(foreignSiloedNullifier);
|
|
562
|
+
const exists = await this.handlerAsAvm().avmOpcodeNullifierExists(siloedNullifier);
|
|
550
563
|
return toForeignCallResult([
|
|
551
564
|
toSingle(new Fr(exists))
|
|
552
565
|
]);
|
|
@@ -1,80 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ArchiverDataSourceBase } from '@aztec/archiver';
|
|
2
|
+
import { type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import type {
|
|
7
|
-
import
|
|
8
|
-
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { L2Tips, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
7
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
10
8
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/**
|
|
10
|
+
* TXE Archiver implementation.
|
|
11
|
+
* Provides most of the endpoints needed by the node for reading from and writing to state,
|
|
12
|
+
* without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
|
|
13
|
+
*/
|
|
14
|
+
export declare class TXEArchiver extends ArchiverDataSourceBase {
|
|
15
|
+
private readonly updater;
|
|
14
16
|
constructor(db: AztecAsyncKVStore);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
20
|
-
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
21
|
-
*/
|
|
22
|
-
getBlockNumber(): Promise<BlockNumber>;
|
|
23
|
-
/**
|
|
24
|
-
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
25
|
-
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
26
|
-
*/
|
|
27
|
-
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
28
|
-
/**
|
|
29
|
-
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
30
|
-
* @param number - The block number to return (inclusive).
|
|
31
|
-
* @returns The requested L2 block.
|
|
32
|
-
*/
|
|
33
|
-
getPublishedBlock(number: number): Promise<PublishedL2Block | undefined>;
|
|
34
|
-
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
35
|
-
getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
|
|
36
|
-
private retrievePublishedBlocks;
|
|
37
|
-
/**
|
|
38
|
-
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
39
|
-
* @param number - The block number to return (inclusive).
|
|
40
|
-
* @returns The requested L2 block.
|
|
41
|
-
*/
|
|
42
|
-
getL2Block(number: BlockNumber | 'latest'): Promise<L2Block | undefined>;
|
|
43
|
-
/**
|
|
44
|
-
* Gets an L2 block (new format).
|
|
45
|
-
* @param number - The block number to return.
|
|
46
|
-
* @returns The requested L2 block.
|
|
47
|
-
*/
|
|
48
|
-
getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
49
|
-
/**
|
|
50
|
-
* Gets an l2 block header.
|
|
51
|
-
* @param number - The block number to return or 'latest' for the most recent one.
|
|
52
|
-
* @returns The requested L2 block header.
|
|
53
|
-
*/
|
|
54
|
-
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
55
|
-
getBlockRange(from: number, limit: number, _proven?: boolean): Promise<L2Block[]>;
|
|
56
|
-
getPublishedCheckpoints(_from: CheckpointNumber, _limit: number): Promise<PublishedCheckpoint[]>;
|
|
57
|
-
getCheckpointByArchive(_archive: Fr): Promise<Checkpoint | undefined>;
|
|
58
|
-
getL2SlotNumber(): Promise<SlotNumber | undefined>;
|
|
59
|
-
getL2EpochNumber(): Promise<EpochNumber>;
|
|
60
|
-
getCheckpointsForEpoch(_epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
61
|
-
getBlocksForEpoch(_epochNumber: EpochNumber): Promise<L2Block[]>;
|
|
62
|
-
getBlockHeadersForEpoch(_epochNumber: EpochNumber): Promise<BlockHeader[]>;
|
|
63
|
-
isEpochComplete(_epochNumber: EpochNumber): Promise<boolean>;
|
|
64
|
-
getL2Tips(): Promise<L2Tips>;
|
|
17
|
+
addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void>;
|
|
18
|
+
getRollupAddress(): Promise<EthAddress>;
|
|
19
|
+
getRegistryAddress(): Promise<EthAddress>;
|
|
65
20
|
getL1Constants(): Promise<L1RollupConstants>;
|
|
66
21
|
getGenesisValues(): Promise<{
|
|
67
22
|
genesisArchiveRoot: Fr;
|
|
68
23
|
}>;
|
|
24
|
+
getL1Timestamp(): Promise<bigint | undefined>;
|
|
25
|
+
getL2Tips(): Promise<L2Tips>;
|
|
26
|
+
getL2SlotNumber(): Promise<SlotNumber | undefined>;
|
|
27
|
+
getL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
28
|
+
isEpochComplete(_epochNumber: EpochNumber): Promise<boolean>;
|
|
69
29
|
syncImmediate(): Promise<void>;
|
|
70
|
-
getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
71
|
-
getRollupAddress(): Promise<EthAddress>;
|
|
72
|
-
getRegistryAddress(): Promise<EthAddress>;
|
|
73
|
-
getL1Timestamp(): Promise<bigint>;
|
|
74
|
-
isPendingChainInvalid(): Promise<boolean>;
|
|
75
|
-
getPendingChainValidationStatus(): Promise<ValidateCheckpointResult>;
|
|
76
|
-
getPublishedBlockByHash(_blockHash: Fr): Promise<PublishedL2Block | undefined>;
|
|
77
|
-
getPublishedBlockByArchive(_archive: Fr): Promise<PublishedL2Block | undefined>;
|
|
78
|
-
getCheckpointedBlocks(_from: BlockNumber, _limit: number, _proven?: boolean): Promise<never[]>;
|
|
79
30
|
}
|
|
80
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXJjaGl2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdGF0ZV9tYWNoaW5lL2FyY2hpdmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxzQkFBc0IsRUFBaUQsTUFBTSxpQkFBaUIsQ0FBQztBQUV4RyxPQUFPLEVBQW9CLEtBQUssV0FBVyxFQUFFLEtBQUssVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDdEcsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQW9DLE1BQU0sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQzlHLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDcEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVyRTs7OztHQUlHO0FBQ0gscUJBQWEsV0FBWSxTQUFRLHNCQUFzQjtJQUNyRCxPQUFPLENBQUMsUUFBUSxDQUFDLE9BQU8sQ0FBNEM7SUFFcEUsWUFBWSxFQUFFLEVBQUUsaUJBQWlCLEVBR2hDO0lBRVksY0FBYyxDQUFDLFdBQVcsRUFBRSxtQkFBbUIsRUFBRSxFQUFFLE1BQU0sQ0FBQyxFQUFFLHdCQUF3QixHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFaEg7SUFFTSxnQkFBZ0IsSUFBSSxPQUFPLENBQUMsVUFBVSxDQUFDLENBRTdDO0lBRU0sa0JBQWtCLElBQUksT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUUvQztJQUVNLGNBQWMsSUFBSSxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FFbEQ7SUFFTSxnQkFBZ0IsSUFBSSxPQUFPLENBQUM7UUFBRSxrQkFBa0IsRUFBRSxFQUFFLENBQUE7S0FBRSxDQUFDLENBRTdEO0lBRU0sY0FBYyxJQUFJLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRW5EO0lBRVksU0FBUyxJQUFJLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0E4QnhDO0lBRU0sZUFBZSxJQUFJLE9BQU8sQ0FBQyxVQUFVLEdBQUcsU0FBUyxDQUFDLENBRXhEO0lBRU0sZ0JBQWdCLElBQUksT0FBTyxDQUFDLFdBQVcsR0FBRyxTQUFTLENBQUMsQ0FFMUQ7SUFFTSxlQUFlLENBQUMsWUFBWSxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBRWxFO0lBRU0sYUFBYSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/state_machine/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/state_machine/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAiD,MAAM,iBAAiB,CAAC;AAExG,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAoC,MAAM,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,sBAAsB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4C;IAEpE,YAAY,EAAE,EAAE,iBAAiB,EAGhC;IAEY,cAAc,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhH;IAEM,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC,CAE7C;IAEM,kBAAkB,IAAI,OAAO,CAAC,UAAU,CAAC,CAE/C;IAEM,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAElD;IAEM,gBAAgB,IAAI,OAAO,CAAC;QAAE,kBAAkB,EAAE,EAAE,CAAA;KAAE,CAAC,CAE7D;IAEM,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEnD;IAEY,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CA8BxC;IAEM,eAAe,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAExD;IAEM,gBAAgB,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAE1D;IAEM,eAAe,CAAC,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAElE;IAEM,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpC;CACF"}
|
|
@@ -1,154 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, KVArchiverDataStore } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export class TXEArchiver extends ArchiverStoreHelper {
|
|
5
|
+
/**
|
|
6
|
+
* TXE Archiver implementation.
|
|
7
|
+
* Provides most of the endpoints needed by the node for reading from and writing to state,
|
|
8
|
+
* without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
|
|
9
|
+
*/ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
10
|
+
updater = new ArchiverDataStoreUpdater(this.store);
|
|
12
11
|
constructor(db){
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const publishedBlocks = await this.getPublishedBlocks(number, 1);
|
|
20
|
-
if (publishedBlocks.length === 0) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
return publishedBlocks[0].block;
|
|
24
|
-
}
|
|
25
|
-
async getBlocks(from, limit, proven) {
|
|
26
|
-
const publishedBlocks = await this.getPublishedBlocks(from, limit, proven);
|
|
27
|
-
return publishedBlocks.map((x)=>x.block);
|
|
28
|
-
}
|
|
29
|
-
async addCheckpoints(checkpoints, _result) {
|
|
30
|
-
const allBlocks = checkpoints.flatMap((ch)=>ch.checkpoint.blocks);
|
|
31
|
-
const opResults = await Promise.all([
|
|
32
|
-
this.store.addLogs(allBlocks),
|
|
33
|
-
this.store.addCheckpoints(checkpoints)
|
|
34
|
-
]);
|
|
35
|
-
return opResults.every(Boolean);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
39
|
-
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
40
|
-
*/ getBlockNumber() {
|
|
41
|
-
return this.store.getLatestBlockNumber();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
45
|
-
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
46
|
-
*/ getProvenBlockNumber() {
|
|
47
|
-
return this.store.getProvenBlockNumber();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
51
|
-
* @param number - The block number to return (inclusive).
|
|
52
|
-
* @returns The requested L2 block.
|
|
53
|
-
*/ async getPublishedBlock(number) {
|
|
54
|
-
// If the number provided is -ve, then return the latest block.
|
|
55
|
-
if (number < 0) {
|
|
56
|
-
number = await this.store.getLatestBlockNumber();
|
|
57
|
-
}
|
|
58
|
-
if (number == 0) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const publishedBlocks = await this.retrievePublishedBlocks(BlockNumber(number), 1);
|
|
62
|
-
return publishedBlocks.length === 0 ? undefined : publishedBlocks[0];
|
|
63
|
-
}
|
|
64
|
-
getPublishedBlocks(from, limit, proven) {
|
|
65
|
-
return this.retrievePublishedBlocks(from, limit, proven);
|
|
66
|
-
}
|
|
67
|
-
async getL2BlocksNew(from, limit, proven) {
|
|
68
|
-
const blocks = await this.store.getBlocks(from, limit);
|
|
69
|
-
if (proven === true) {
|
|
70
|
-
const provenBlockNumber = await this.store.getProvenBlockNumber();
|
|
71
|
-
return blocks.filter((b)=>b.number <= provenBlockNumber);
|
|
72
|
-
}
|
|
73
|
-
return blocks;
|
|
74
|
-
}
|
|
75
|
-
async retrievePublishedBlocks(from, limit, proven) {
|
|
76
|
-
const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
|
|
77
|
-
const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
78
|
-
const blocks = (await Promise.all(checkpoints.map((ch)=>this.store.getBlocksForCheckpoint(ch.checkpointNumber)))).filter(isDefined);
|
|
79
|
-
const olbBlocks = [];
|
|
80
|
-
for(let i = 0; i < checkpoints.length; i++){
|
|
81
|
-
const blockForCheckpoint = blocks[i][0];
|
|
82
|
-
const checkpoint = checkpoints[i];
|
|
83
|
-
if (proven === true && checkpoint.checkpointNumber > provenCheckpointNumber) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const oldCheckpoint = new Checkpoint(blockForCheckpoint.archive, checkpoint.header, [
|
|
87
|
-
blockForCheckpoint
|
|
88
|
-
], checkpoint.checkpointNumber);
|
|
89
|
-
const oldBlock = L2Block.fromCheckpoint(oldCheckpoint);
|
|
90
|
-
const publishedBlock = new PublishedL2Block(oldBlock, checkpoint.l1, checkpoint.attestations.map((x)=>CommitteeAttestation.fromBuffer(x)));
|
|
91
|
-
olbBlocks.push(publishedBlock);
|
|
92
|
-
}
|
|
93
|
-
return olbBlocks;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
97
|
-
* @param number - The block number to return (inclusive).
|
|
98
|
-
* @returns The requested L2 block.
|
|
99
|
-
*/ getL2Block(number) {
|
|
100
|
-
return this.getPublishedBlock(number != 'latest' ? number : -1).then((b)=>b?.block);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Gets an L2 block (new format).
|
|
104
|
-
* @param number - The block number to return.
|
|
105
|
-
* @returns The requested L2 block.
|
|
106
|
-
*/ getL2BlockNew(number) {
|
|
107
|
-
if (number === 0) {
|
|
108
|
-
return Promise.resolve(undefined);
|
|
109
|
-
}
|
|
110
|
-
return this.store.getBlock(number);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Gets an l2 block header.
|
|
114
|
-
* @param number - The block number to return or 'latest' for the most recent one.
|
|
115
|
-
* @returns The requested L2 block header.
|
|
116
|
-
*/ async getBlockHeader(number) {
|
|
117
|
-
if (number === 'latest') {
|
|
118
|
-
number = await this.store.getLatestBlockNumber();
|
|
119
|
-
}
|
|
120
|
-
if (number === 0) {
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
const headers = await this.store.getBlockHeaders(BlockNumber(number), 1);
|
|
124
|
-
return headers.length === 0 ? undefined : headers[0];
|
|
125
|
-
}
|
|
126
|
-
getBlockRange(from, limit, _proven) {
|
|
127
|
-
return this.getPublishedBlocks(BlockNumber(from), limit).then((blocks)=>blocks.map((b)=>b.block));
|
|
128
|
-
}
|
|
129
|
-
getPublishedCheckpoints(_from, _limit) {
|
|
130
|
-
throw new Error('TXE Archiver does not implement "getPublishedCheckpoints"');
|
|
131
|
-
}
|
|
132
|
-
getCheckpointByArchive(_archive) {
|
|
133
|
-
throw new Error('TXE Archiver does not implement "getCheckpointByArchive"');
|
|
12
|
+
const store = new KVArchiverDataStore(db, 9999, {
|
|
13
|
+
epochDuration: 32
|
|
14
|
+
});
|
|
15
|
+
super(store);
|
|
134
16
|
}
|
|
135
|
-
|
|
136
|
-
|
|
17
|
+
async addCheckpoints(checkpoints, result) {
|
|
18
|
+
await this.updater.addCheckpoints(checkpoints, result);
|
|
137
19
|
}
|
|
138
|
-
|
|
139
|
-
throw new Error('TXE Archiver does not implement "
|
|
20
|
+
getRollupAddress() {
|
|
21
|
+
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
140
22
|
}
|
|
141
|
-
|
|
142
|
-
throw new Error('TXE Archiver does not implement "
|
|
23
|
+
getRegistryAddress() {
|
|
24
|
+
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
143
25
|
}
|
|
144
|
-
|
|
145
|
-
throw new Error('TXE Archiver does not implement "
|
|
26
|
+
getL1Constants() {
|
|
27
|
+
throw new Error('TXE Archiver does not implement "getL1Constants"');
|
|
146
28
|
}
|
|
147
|
-
|
|
148
|
-
|
|
29
|
+
getGenesisValues() {
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
32
|
+
});
|
|
149
33
|
}
|
|
150
|
-
|
|
151
|
-
throw new Error('TXE Archiver does not implement "
|
|
34
|
+
getL1Timestamp() {
|
|
35
|
+
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
152
36
|
}
|
|
153
37
|
async getL2Tips() {
|
|
154
38
|
// In TXE there is no possibility of reorgs and no blocks are ever getting proven so we just set 'latest', 'proven'
|
|
@@ -163,7 +47,7 @@ export class TXEArchiver extends ArchiverStoreHelper {
|
|
|
163
47
|
if (!checkpointedBlock) {
|
|
164
48
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
165
49
|
}
|
|
166
|
-
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber(number), 1);
|
|
50
|
+
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
167
51
|
if (checkpoint.length === 0) {
|
|
168
52
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
169
53
|
}
|
|
@@ -186,44 +70,16 @@ export class TXEArchiver extends ArchiverStoreHelper {
|
|
|
186
70
|
checkpointed: tipId
|
|
187
71
|
};
|
|
188
72
|
}
|
|
189
|
-
|
|
190
|
-
throw new Error('TXE Archiver does not implement "
|
|
73
|
+
getL2SlotNumber() {
|
|
74
|
+
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
191
75
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
76
|
+
getL2EpochNumber() {
|
|
77
|
+
throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
|
|
78
|
+
}
|
|
79
|
+
isEpochComplete(_epochNumber) {
|
|
80
|
+
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
196
81
|
}
|
|
197
82
|
syncImmediate() {
|
|
198
83
|
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
199
84
|
}
|
|
200
|
-
getContract(_address, _timestamp) {
|
|
201
|
-
throw new Error('TXE Archiver does not implement "getContract"');
|
|
202
|
-
}
|
|
203
|
-
getRollupAddress() {
|
|
204
|
-
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
205
|
-
}
|
|
206
|
-
getRegistryAddress() {
|
|
207
|
-
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
208
|
-
}
|
|
209
|
-
getL1Timestamp() {
|
|
210
|
-
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
211
|
-
}
|
|
212
|
-
isPendingChainInvalid() {
|
|
213
|
-
return Promise.resolve(false);
|
|
214
|
-
}
|
|
215
|
-
getPendingChainValidationStatus() {
|
|
216
|
-
return Promise.resolve({
|
|
217
|
-
valid: true
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
getPublishedBlockByHash(_blockHash) {
|
|
221
|
-
throw new Error('Method not implemented.');
|
|
222
|
-
}
|
|
223
|
-
getPublishedBlockByArchive(_archive) {
|
|
224
|
-
throw new Error('Method not implemented.');
|
|
225
|
-
}
|
|
226
|
-
getCheckpointedBlocks(_from, _limit, _proven) {
|
|
227
|
-
throw new Error('TXE Archiver does not implement "getCheckpointedBlocks"');
|
|
228
|
-
}
|
|
229
85
|
}
|
|
@@ -13,4 +13,4 @@ export declare class TXEStateMachine {
|
|
|
13
13
|
static create(db: AztecAsyncKVStore): Promise<TXEStateMachine>;
|
|
14
14
|
handleL2Block(block: L2Block): Promise<void>;
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdGF0ZV9tYWNoaW5lL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFDekQsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDckQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTlDLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBSWpFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFJNUMsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBS3BELHFCQUFhLGVBQWU7SUFFakIsSUFBSSxFQUFFLFNBQVM7SUFDZixZQUFZLEVBQUUsZUFBZTtJQUM3QixRQUFRLEVBQUUsV0FBVztJQUNyQixnQkFBZ0IsRUFBRSxnQkFBZ0I7SUFKM0MsWUFDUyxJQUFJLEVBQUUsU0FBUyxFQUNmLFlBQVksRUFBRSxlQUFlLEVBQzdCLFFBQVEsRUFBRSxXQUFXLEVBQ3JCLGdCQUFnQixFQUFFLGdCQUFnQixFQUN2QztJQUVKLE9BQW9CLE1BQU0sQ0FBQyxFQUFFLEVBQUUsaUJBQWlCLDRCQStCL0M7SUFFWSxhQUFhLENBQUMsS0FBSyxFQUFFLE9BQU8saUJBbUN4QztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state_machine/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state_machine/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAIjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,eAAe;IAEjB,IAAI,EAAE,SAAS;IACf,YAAY,EAAE,eAAe;IAC7B,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,gBAAgB;IAJ3C,YACS,IAAI,EAAE,SAAS,EACf,YAAY,EAAE,eAAe,EAC7B,QAAQ,EAAE,WAAW,EACrB,gBAAgB,EAAE,gBAAgB,EACvC;IAEJ,OAAoB,MAAM,CAAC,EAAE,EAAE,iBAAiB,4BA+B/C;IAEY,aAAa,CAAC,KAAK,EAAE,OAAO,iBAmCxC;CACF"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { 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 { AnchorBlockStore } from '@aztec/pxe/server';
|
|
5
|
-
import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
6
9
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
7
10
|
import { TXEArchiver } from './archiver.js';
|
|
8
11
|
import { DummyP2P } from './dummy_p2p_client.js';
|
|
@@ -32,14 +35,29 @@ export class TXEStateMachine {
|
|
|
32
35
|
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
33
36
|
}
|
|
34
37
|
async handleL2Block(block) {
|
|
35
|
-
|
|
38
|
+
// Create a checkpoint from the block manually
|
|
39
|
+
const checkpoint = new Checkpoint(block.archive, CheckpointHeader.from({
|
|
40
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
41
|
+
inHash: Fr.ZERO,
|
|
42
|
+
blobsHash: Fr.ZERO,
|
|
43
|
+
blockHeadersHash: Fr.ZERO,
|
|
44
|
+
epochOutHash: Fr.ZERO,
|
|
45
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
46
|
+
timestamp: block.header.globalVariables.timestamp,
|
|
47
|
+
coinbase: block.header.globalVariables.coinbase,
|
|
48
|
+
feeRecipient: block.header.globalVariables.feeRecipient,
|
|
49
|
+
gasFees: block.header.globalVariables.gasFees,
|
|
50
|
+
totalManaUsed: block.header.totalManaUsed
|
|
51
|
+
}), [
|
|
52
|
+
block
|
|
53
|
+
], CheckpointNumber.fromBlockNumber(block.number));
|
|
36
54
|
const publishedCheckpoint = new PublishedCheckpoint(checkpoint, new L1PublishedData(BigInt(block.header.globalVariables.blockNumber), block.header.globalVariables.timestamp, block.header.globalVariables.blockNumber.toString()), []);
|
|
37
55
|
await Promise.all([
|
|
38
|
-
this.synchronizer.handleL2Block(block
|
|
56
|
+
this.synchronizer.handleL2Block(block),
|
|
39
57
|
this.archiver.addCheckpoints([
|
|
40
58
|
publishedCheckpoint
|
|
41
59
|
], undefined),
|
|
42
|
-
this.anchorBlockStore.setHeader(block.
|
|
60
|
+
this.anchorBlockStore.setHeader(block.header)
|
|
43
61
|
]);
|
|
44
62
|
}
|
|
45
63
|
}
|