@aztec/txe 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2
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 +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- 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_top_level_context.d.ts +4 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +36 -22
- package/dest/rpc_translator.d.ts +6 -6
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +21 -20
- package/dest/state_machine/archiver.d.ts +20 -67
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +58 -178
- package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +13 -10
- package/dest/state_machine/global_variable_builder.d.ts +2 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- 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 +13 -4
- package/dest/state_machine/mock_epoch_cache.d.ts +2 -1
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +5 -1
- package/dest/txe_session.d.ts +6 -4
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +51 -17
- package/dest/util/encoding.d.ts +17 -17
- package/dest/utils/block_creation.d.ts +7 -7
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +18 -7
- 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 +3 -0
- package/src/oracle/txe_oracle_public_context.ts +2 -2
- package/src/oracle/txe_oracle_top_level_context.ts +53 -22
- package/src/rpc_translator.ts +21 -23
- package/src/state_machine/archiver.ts +55 -219
- package/src/state_machine/dummy_p2p_client.ts +18 -13
- package/src/state_machine/global_variable_builder.ts +1 -1
- package/src/state_machine/index.ts +14 -6
- package/src/state_machine/mock_epoch_cache.ts +5 -0
- package/src/txe_session.ts +79 -15
- package/src/utils/block_creation.ts +20 -19
- package/src/utils/tx_effect_creation.ts +3 -11
package/src/rpc_translator.ts
CHANGED
|
@@ -10,6 +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 { L2BlockHash } from '@aztec/stdlib/block';
|
|
13
14
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
15
|
|
|
15
16
|
import type { IAvmExecutionOracle, ITxeExecutionOracle } from './oracle/interfaces.js';
|
|
@@ -346,34 +347,34 @@ export class RPCTranslator {
|
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
async utilityStorageRead(
|
|
350
|
+
foreignBlockHash: ForeignCallSingle,
|
|
349
351
|
foreignContractAddress: ForeignCallSingle,
|
|
350
352
|
foreignStartStorageSlot: ForeignCallSingle,
|
|
351
|
-
foreignBlockNumber: ForeignCallSingle,
|
|
352
353
|
foreignNumberOfElements: ForeignCallSingle,
|
|
353
354
|
) {
|
|
355
|
+
const blockHash = L2BlockHash.fromString(foreignBlockHash);
|
|
354
356
|
const contractAddress = addressFromSingle(foreignContractAddress);
|
|
355
357
|
const startStorageSlot = fromSingle(foreignStartStorageSlot);
|
|
356
|
-
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
357
358
|
const numberOfElements = fromSingle(foreignNumberOfElements).toNumber();
|
|
358
359
|
|
|
359
360
|
const values = await this.handlerAsUtility().utilityStorageRead(
|
|
361
|
+
blockHash,
|
|
360
362
|
contractAddress,
|
|
361
363
|
startStorageSlot,
|
|
362
|
-
blockNumber,
|
|
363
364
|
numberOfElements,
|
|
364
365
|
);
|
|
365
366
|
|
|
366
367
|
return toForeignCallResult([toArray(values)]);
|
|
367
368
|
}
|
|
368
369
|
|
|
369
|
-
async utilityGetPublicDataWitness(
|
|
370
|
-
const
|
|
370
|
+
async utilityGetPublicDataWitness(foreignBlockHash: ForeignCallSingle, foreignLeafSlot: ForeignCallSingle) {
|
|
371
|
+
const blockHash = L2BlockHash.fromString(foreignBlockHash);
|
|
371
372
|
const leafSlot = fromSingle(foreignLeafSlot);
|
|
372
373
|
|
|
373
|
-
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(
|
|
374
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(blockHash, leafSlot);
|
|
374
375
|
|
|
375
376
|
if (!witness) {
|
|
376
|
-
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${
|
|
377
|
+
throw new Error(`Public data witness not found for slot ${leafSlot} at block ${blockHash.toString()}.`);
|
|
377
378
|
}
|
|
378
379
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
379
380
|
}
|
|
@@ -444,7 +445,7 @@ export class RPCTranslator {
|
|
|
444
445
|
randomness: noteData.randomness,
|
|
445
446
|
storageSlot: noteData.storageSlot,
|
|
446
447
|
noteNonce: noteData.noteNonce,
|
|
447
|
-
|
|
448
|
+
isPending: noteData.isPending,
|
|
448
449
|
note: noteData.note,
|
|
449
450
|
}),
|
|
450
451
|
);
|
|
@@ -568,17 +569,14 @@ export class RPCTranslator {
|
|
|
568
569
|
);
|
|
569
570
|
}
|
|
570
571
|
|
|
571
|
-
async utilityGetNullifierMembershipWitness(
|
|
572
|
-
|
|
573
|
-
foreignNullifier: ForeignCallSingle,
|
|
574
|
-
) {
|
|
575
|
-
const blockNumber = BlockNumber(fromSingle(foreignBlockNumber).toNumber());
|
|
572
|
+
async utilityGetNullifierMembershipWitness(foreignBlockHash: ForeignCallSingle, foreignNullifier: ForeignCallSingle) {
|
|
573
|
+
const blockHash = L2BlockHash.fromString(foreignBlockHash);
|
|
576
574
|
const nullifier = fromSingle(foreignNullifier);
|
|
577
575
|
|
|
578
|
-
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
|
|
576
|
+
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(blockHash, nullifier);
|
|
579
577
|
|
|
580
578
|
if (!witness) {
|
|
581
|
-
throw new Error(`Nullifier membership witness not found at block ${
|
|
579
|
+
throw new Error(`Nullifier membership witness not found at block ${blockHash}.`);
|
|
582
580
|
}
|
|
583
581
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
584
582
|
}
|
|
@@ -640,35 +638,35 @@ export class RPCTranslator {
|
|
|
640
638
|
}
|
|
641
639
|
|
|
642
640
|
async utilityGetMembershipWitness(
|
|
643
|
-
|
|
641
|
+
foreignBlockHash: ForeignCallSingle,
|
|
644
642
|
foreignTreeId: ForeignCallSingle,
|
|
645
643
|
foreignLeafValue: ForeignCallSingle,
|
|
646
644
|
) {
|
|
647
|
-
const
|
|
645
|
+
const blockHash = L2BlockHash.fromString(foreignBlockHash);
|
|
648
646
|
const treeId = fromSingle(foreignTreeId).toNumber();
|
|
649
647
|
const leafValue = fromSingle(foreignLeafValue);
|
|
650
648
|
|
|
651
|
-
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(
|
|
649
|
+
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(blockHash, treeId, leafValue);
|
|
652
650
|
|
|
653
651
|
if (!witness) {
|
|
654
652
|
throw new Error(
|
|
655
|
-
`Membership witness in tree ${MerkleTreeId[treeId]} not found for value ${leafValue} at block ${
|
|
653
|
+
`Membership witness in tree ${MerkleTreeId[treeId]} not found for value ${leafValue} at block ${blockHash}.`,
|
|
656
654
|
);
|
|
657
655
|
}
|
|
658
656
|
return toForeignCallResult([toSingle(witness[0]), toArray(witness.slice(1))]);
|
|
659
657
|
}
|
|
660
658
|
|
|
661
659
|
async utilityGetLowNullifierMembershipWitness(
|
|
662
|
-
|
|
660
|
+
foreignBlockHash: ForeignCallSingle,
|
|
663
661
|
foreignNullifier: ForeignCallSingle,
|
|
664
662
|
) {
|
|
665
|
-
const
|
|
663
|
+
const blockHash = L2BlockHash.fromString(foreignBlockHash);
|
|
666
664
|
const nullifier = fromSingle(foreignNullifier);
|
|
667
665
|
|
|
668
|
-
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
|
|
666
|
+
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(blockHash, nullifier);
|
|
669
667
|
|
|
670
668
|
if (!witness) {
|
|
671
|
-
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${
|
|
669
|
+
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block ${blockHash}.`);
|
|
672
670
|
}
|
|
673
671
|
return toForeignCallResult(witness.toNoirRepresentation());
|
|
674
672
|
}
|
|
@@ -1,204 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchiverDataSourceBase, ArchiverDataStoreUpdater, KVArchiverDataStore } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
-
import {
|
|
3
|
+
import { CheckpointNumber, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
-
import { isDefined } from '@aztec/foundation/types';
|
|
7
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
8
|
-
import type {
|
|
9
|
-
import {
|
|
10
|
-
CommitteeAttestation,
|
|
11
|
-
L2Block,
|
|
12
|
-
type L2BlockId,
|
|
13
|
-
type L2BlockNew,
|
|
14
|
-
type L2BlockSource,
|
|
15
|
-
type L2Tips,
|
|
16
|
-
PublishedL2Block,
|
|
17
|
-
type ValidateBlockResult,
|
|
18
|
-
} from '@aztec/stdlib/block';
|
|
19
|
-
import { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
20
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
7
|
+
import type { CheckpointId, L2BlockId, L2TipId, L2Tips, ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
8
|
+
import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
21
9
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
22
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
23
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
public async getBlock(number: BlockNumber): Promise<L2Block | undefined> {
|
|
34
|
-
if (number === 0) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
const publishedBlocks = await this.getPublishedBlocks(number, 1);
|
|
38
|
-
if (publishedBlocks.length === 0) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
return publishedBlocks[0].block;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public async getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2Block[]> {
|
|
45
|
-
const publishedBlocks = await this.getPublishedBlocks(from, limit, proven);
|
|
46
|
-
return publishedBlocks.map(x => x.block);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public override async addCheckpoints(
|
|
50
|
-
checkpoints: PublishedCheckpoint[],
|
|
51
|
-
_result?: ValidateBlockResult,
|
|
52
|
-
): Promise<boolean> {
|
|
53
|
-
const allBlocks = checkpoints.flatMap(ch => ch.checkpoint.blocks);
|
|
54
|
-
const opResults = await Promise.all([this.store.addLogs(allBlocks), this.store.addCheckpoints(checkpoints)]);
|
|
55
|
-
|
|
56
|
-
return opResults.every(Boolean);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
61
|
-
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
62
|
-
*/
|
|
63
|
-
public getBlockNumber(): Promise<BlockNumber> {
|
|
64
|
-
return this.store.getLatestBlockNumber();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
69
|
-
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
70
|
-
*/
|
|
71
|
-
public override getProvenBlockNumber(): Promise<BlockNumber> {
|
|
72
|
-
return this.store.getProvenBlockNumber();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Gets a published l2 block. If a negative number is passed, the block returned is the most recent.
|
|
77
|
-
* @param number - The block number to return (inclusive).
|
|
78
|
-
* @returns The requested L2 block.
|
|
79
|
-
*/
|
|
80
|
-
public async getPublishedBlock(number: number): Promise<PublishedL2Block | undefined> {
|
|
81
|
-
// If the number provided is -ve, then return the latest block.
|
|
82
|
-
if (number < 0) {
|
|
83
|
-
number = await this.store.getLatestBlockNumber();
|
|
84
|
-
}
|
|
85
|
-
if (number == 0) {
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
const publishedBlocks = await this.retrievePublishedBlocks(BlockNumber(number), 1);
|
|
89
|
-
return publishedBlocks.length === 0 ? undefined : publishedBlocks[0];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]> {
|
|
93
|
-
return this.retrievePublishedBlocks(from, limit, proven);
|
|
94
|
-
}
|
|
11
|
+
/**
|
|
12
|
+
* TXE Archiver implementation.
|
|
13
|
+
* Provides most of the endpoints needed by the node for reading from and writing to state,
|
|
14
|
+
* without needing any of the extra overhead that the Archiver itself requires (i.e. an L1 client).
|
|
15
|
+
*/
|
|
16
|
+
export class TXEArchiver extends ArchiverDataSourceBase {
|
|
17
|
+
private readonly updater = new ArchiverDataStoreUpdater(this.store);
|
|
95
18
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
proven?: boolean,
|
|
100
|
-
): Promise<PublishedL2Block[]> {
|
|
101
|
-
const checkpoints = await this.store.getRangeOfCheckpoints(CheckpointNumber(from), limit);
|
|
102
|
-
const provenCheckpointNumber = await this.store.getProvenCheckpointNumber();
|
|
103
|
-
const blocks = (
|
|
104
|
-
await Promise.all(checkpoints.map(ch => this.store.getBlocksForCheckpoint(ch.checkpointNumber)))
|
|
105
|
-
).filter(isDefined);
|
|
106
|
-
|
|
107
|
-
const olbBlocks: PublishedL2Block[] = [];
|
|
108
|
-
for (let i = 0; i < checkpoints.length; i++) {
|
|
109
|
-
const blockForCheckpoint = blocks[i][0];
|
|
110
|
-
const checkpoint = checkpoints[i];
|
|
111
|
-
if (proven === true && checkpoint.checkpointNumber > provenCheckpointNumber) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const oldCheckpoint = new Checkpoint(
|
|
115
|
-
blockForCheckpoint.archive,
|
|
116
|
-
checkpoint.header,
|
|
117
|
-
[blockForCheckpoint],
|
|
118
|
-
checkpoint.checkpointNumber,
|
|
119
|
-
);
|
|
120
|
-
const oldBlock = L2Block.fromCheckpoint(oldCheckpoint);
|
|
121
|
-
const publishedBlock = new PublishedL2Block(
|
|
122
|
-
oldBlock,
|
|
123
|
-
checkpoint.l1,
|
|
124
|
-
checkpoint.attestations.map(x => CommitteeAttestation.fromBuffer(x)),
|
|
125
|
-
);
|
|
126
|
-
olbBlocks.push(publishedBlock);
|
|
127
|
-
}
|
|
128
|
-
return olbBlocks;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
133
|
-
* @param number - The block number to return (inclusive).
|
|
134
|
-
* @returns The requested L2 block.
|
|
135
|
-
*/
|
|
136
|
-
public getL2Block(number: BlockNumber | 'latest'): Promise<L2Block | undefined> {
|
|
137
|
-
return this.getPublishedBlock(number != 'latest' ? number : -1).then(b => b?.block);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Gets an L2 block (new format).
|
|
142
|
-
* @param number - The block number to return.
|
|
143
|
-
* @returns The requested L2 block.
|
|
144
|
-
*/
|
|
145
|
-
public getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined> {
|
|
146
|
-
if (number === 0) {
|
|
147
|
-
return Promise.resolve(undefined);
|
|
148
|
-
}
|
|
149
|
-
return this.store.getBlock(number);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Gets an l2 block header.
|
|
154
|
-
* @param number - The block number to return or 'latest' for the most recent one.
|
|
155
|
-
* @returns The requested L2 block header.
|
|
156
|
-
*/
|
|
157
|
-
public async getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined> {
|
|
158
|
-
if (number === 'latest') {
|
|
159
|
-
number = await this.store.getLatestBlockNumber();
|
|
160
|
-
}
|
|
161
|
-
if (number === 0) {
|
|
162
|
-
return undefined;
|
|
163
|
-
}
|
|
164
|
-
const headers = await this.store.getBlockHeaders(BlockNumber(number), 1);
|
|
165
|
-
return headers.length === 0 ? undefined : headers[0];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public getBlockRange(from: number, limit: number, _proven?: boolean): Promise<L2Block[]> {
|
|
169
|
-
return this.getPublishedBlocks(BlockNumber(from), limit).then(blocks => blocks.map(b => b.block));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public getPublishedCheckpoints(_from: CheckpointNumber, _limit: number): Promise<PublishedCheckpoint[]> {
|
|
173
|
-
throw new Error('TXE Archiver does not implement "getPublishedCheckpoints"');
|
|
19
|
+
constructor(db: AztecAsyncKVStore) {
|
|
20
|
+
const store = new KVArchiverDataStore(db, 9999);
|
|
21
|
+
super(store);
|
|
174
22
|
}
|
|
175
23
|
|
|
176
|
-
|
|
177
|
-
|
|
24
|
+
// TXE-specific method for adding checkpoints
|
|
25
|
+
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<boolean> {
|
|
26
|
+
await this.updater.setNewCheckpointData(checkpoints, result);
|
|
27
|
+
return true;
|
|
178
28
|
}
|
|
179
29
|
|
|
180
|
-
|
|
181
|
-
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
182
|
-
}
|
|
30
|
+
// Abstract method implementations
|
|
183
31
|
|
|
184
|
-
public
|
|
185
|
-
throw new Error('TXE Archiver does not implement "
|
|
32
|
+
public getRollupAddress(): Promise<EthAddress> {
|
|
33
|
+
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
186
34
|
}
|
|
187
35
|
|
|
188
|
-
public
|
|
189
|
-
throw new Error('TXE Archiver does not implement "
|
|
36
|
+
public getRegistryAddress(): Promise<EthAddress> {
|
|
37
|
+
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
190
38
|
}
|
|
191
39
|
|
|
192
|
-
public
|
|
193
|
-
throw new Error('TXE Archiver does not implement "
|
|
40
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
41
|
+
throw new Error('TXE Archiver does not implement "getL1Constants"');
|
|
194
42
|
}
|
|
195
43
|
|
|
196
|
-
public
|
|
197
|
-
|
|
44
|
+
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
45
|
+
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
198
46
|
}
|
|
199
47
|
|
|
200
|
-
public
|
|
201
|
-
throw new Error('TXE Archiver does not implement "
|
|
48
|
+
public getL1Timestamp(): Promise<bigint | undefined> {
|
|
49
|
+
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
202
50
|
}
|
|
203
51
|
|
|
204
52
|
public async getL2Tips(): Promise<L2Tips> {
|
|
@@ -211,53 +59,41 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
211
59
|
|
|
212
60
|
const number = blockHeader.globalVariables.blockNumber;
|
|
213
61
|
const hash = (await blockHeader.hash()).toString();
|
|
62
|
+
const checkpointedBlock = await this.getCheckpointedBlock(number);
|
|
63
|
+
if (!checkpointedBlock) {
|
|
64
|
+
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
65
|
+
}
|
|
66
|
+
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber(number), 1);
|
|
67
|
+
if (checkpoint.length === 0) {
|
|
68
|
+
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
69
|
+
}
|
|
70
|
+
const blockId: L2BlockId = { number, hash };
|
|
71
|
+
const checkpointId: CheckpointId = {
|
|
72
|
+
number: checkpoint[0].checkpointNumber,
|
|
73
|
+
hash: checkpoint[0].header.hash().toString(),
|
|
74
|
+
};
|
|
75
|
+
const tipId: L2TipId = { block: blockId, checkpoint: checkpointId };
|
|
214
76
|
return {
|
|
215
|
-
|
|
216
|
-
proven:
|
|
217
|
-
finalized:
|
|
77
|
+
proposed: blockId,
|
|
78
|
+
proven: tipId,
|
|
79
|
+
finalized: tipId,
|
|
80
|
+
checkpointed: tipId,
|
|
218
81
|
};
|
|
219
82
|
}
|
|
220
83
|
|
|
221
|
-
public
|
|
222
|
-
throw new Error('TXE Archiver does not implement "
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
226
|
-
return Promise.resolve({ genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT) });
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
public syncImmediate(): Promise<void> {
|
|
230
|
-
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
public getContract(_address: AztecAddress, _timestamp?: UInt64): Promise<ContractInstanceWithAddress | undefined> {
|
|
234
|
-
throw new Error('TXE Archiver does not implement "getContract"');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public getRollupAddress(): Promise<EthAddress> {
|
|
238
|
-
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
public getRegistryAddress(): Promise<EthAddress> {
|
|
242
|
-
throw new Error('TXE Archiver does not implement "getRegistryAddress"');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public getL1Timestamp(): Promise<bigint> {
|
|
246
|
-
throw new Error('TXE Archiver does not implement "getL1Timestamp"');
|
|
84
|
+
public getL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
85
|
+
throw new Error('TXE Archiver does not implement "getL2SlotNumber"');
|
|
247
86
|
}
|
|
248
87
|
|
|
249
|
-
public
|
|
250
|
-
|
|
88
|
+
public getL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
89
|
+
throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
|
|
251
90
|
}
|
|
252
91
|
|
|
253
|
-
public
|
|
254
|
-
|
|
92
|
+
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
93
|
+
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
255
94
|
}
|
|
256
95
|
|
|
257
|
-
|
|
258
|
-
throw new Error('
|
|
259
|
-
}
|
|
260
|
-
getPublishedBlockByArchive(_archive: Fr): Promise<PublishedL2Block | undefined> {
|
|
261
|
-
throw new Error('Method not implemented.');
|
|
96
|
+
public syncImmediate(): Promise<void> {
|
|
97
|
+
throw new Error('TXE Archiver does not implement "syncImmediate"');
|
|
262
98
|
}
|
|
263
99
|
}
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ENR,
|
|
5
5
|
P2P,
|
|
6
6
|
P2PBlockReceivedCallback,
|
|
7
|
+
P2PCheckpointReceivedCallback,
|
|
7
8
|
P2PConfig,
|
|
8
9
|
P2PSyncState,
|
|
9
10
|
PeerId,
|
|
@@ -14,14 +15,10 @@ import type {
|
|
|
14
15
|
} from '@aztec/p2p';
|
|
15
16
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
16
17
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
17
|
-
import type {
|
|
18
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
18
19
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
19
20
|
|
|
20
21
|
export class DummyP2P implements P2P {
|
|
21
|
-
public broadcastAttestations(_attestations: BlockAttestation[]): Promise<void> {
|
|
22
|
-
return Promise.resolve();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
22
|
public validate(_txs: Tx[]): Promise<void> {
|
|
26
23
|
return Promise.resolve();
|
|
27
24
|
}
|
|
@@ -46,10 +43,22 @@ export class DummyP2P implements P2P {
|
|
|
46
43
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
47
44
|
}
|
|
48
45
|
|
|
46
|
+
public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
|
|
47
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
51
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
|
|
50
55
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
51
56
|
}
|
|
52
57
|
|
|
58
|
+
public registerCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
59
|
+
throw new Error('DummyP2P does not implement "registerCheckpointProposalHandler"');
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
54
63
|
throw new Error('DummyP2P does not implement "requestTxs"');
|
|
55
64
|
}
|
|
@@ -120,16 +129,12 @@ export class DummyP2P implements P2P {
|
|
|
120
129
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
public
|
|
124
|
-
throw new Error('DummyP2P does not implement "
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public deleteAttestation(_attestation: BlockAttestation): Promise<void> {
|
|
128
|
-
return Promise.resolve();
|
|
132
|
+
public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
|
|
133
|
+
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
public
|
|
132
|
-
throw new Error('DummyP2P does not implement "
|
|
136
|
+
public addCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
137
|
+
throw new Error('DummyP2P does not implement "addCheckpointAttestations"');
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -6,7 +6,7 @@ import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
|
6
6
|
import { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
8
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
9
|
-
public
|
|
9
|
+
public getCurrentMinFees(): Promise<GasFees> {
|
|
10
10
|
return Promise.resolve(new GasFees(0, 0));
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -3,8 +3,8 @@ import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
5
|
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
-
import {
|
|
7
|
-
import { L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
6
|
+
import { L2BlockNew } from '@aztec/stdlib/block';
|
|
7
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
9
9
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
10
|
|
|
@@ -58,8 +58,16 @@ export class TXEStateMachine {
|
|
|
58
58
|
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
public async handleL2Block(block:
|
|
62
|
-
|
|
61
|
+
public async handleL2Block(block: L2BlockNew) {
|
|
62
|
+
// Create a checkpoint from the block - L2BlockNew doesn't have toCheckpoint() method
|
|
63
|
+
// We need to construct the Checkpoint manually
|
|
64
|
+
const checkpoint = await Checkpoint.random(block.checkpointNumber, {
|
|
65
|
+
numBlocks: 1,
|
|
66
|
+
startBlockNumber: Number(block.number),
|
|
67
|
+
});
|
|
68
|
+
// Replace the random block with our actual block
|
|
69
|
+
checkpoint.blocks = [block];
|
|
70
|
+
|
|
63
71
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
64
72
|
checkpoint,
|
|
65
73
|
new L1PublishedData(
|
|
@@ -70,9 +78,9 @@ export class TXEStateMachine {
|
|
|
70
78
|
[],
|
|
71
79
|
);
|
|
72
80
|
await Promise.all([
|
|
73
|
-
this.synchronizer.handleL2Block(block
|
|
81
|
+
this.synchronizer.handleL2Block(block), // L2BlockNew doesn't need toL2Block() conversion
|
|
74
82
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
75
|
-
this.anchorBlockStore.setHeader(block.
|
|
83
|
+
this.anchorBlockStore.setHeader(block.header), // Use .header property directly
|
|
76
84
|
]);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
@@ -12,6 +12,7 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
12
12
|
committee: undefined,
|
|
13
13
|
seed: 0n,
|
|
14
14
|
epoch: EpochNumber.ZERO,
|
|
15
|
+
isEscapeHatchOpen: false,
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -54,6 +55,10 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
59
|
+
return Promise.resolve(undefined);
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
|
|
58
63
|
return Promise.resolve(false);
|
|
59
64
|
}
|