@aztec/p2p 3.0.0-nightly.20251202 → 3.0.0-nightly.20251204
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/client/p2p_client.d.ts +6 -6
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +13 -12
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +4 -3
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +4 -3
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +1 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +4 -3
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +5 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +3 -2
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.d.ts +1 -1
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +5 -5
- package/dest/services/reqresp/protocols/block.d.ts +1 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +2 -1
- package/dest/services/reqresp/protocols/status.d.ts +5 -4
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +4 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +4 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.d.ts +4 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +9 -8
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +1 -1
- package/dest/services/tx_provider.d.ts +5 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/p2p_client.ts +26 -24
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +7 -6
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +8 -6
- package/src/mem_pools/tx_pool/tx_pool.ts +3 -2
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +5 -4
- package/src/msg_validators/tx_validator/factory.ts +2 -1
- package/src/msg_validators/tx_validator/timestamp_validator.ts +2 -1
- package/src/services/libp2p/libp2p_service.ts +9 -9
- package/src/services/reqresp/protocols/block.ts +2 -1
- package/src/services/reqresp/protocols/status.ts +9 -8
- package/src/services/tx_collection/fast_tx_collection.ts +3 -2
- package/src/services/tx_collection/slow_tx_collection.ts +3 -3
- package/src/services/tx_collection/tx_collection.ts +9 -8
- package/src/services/tx_provider.ts +4 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { unfreeze } from '@aztec/foundation/types';
|
|
2
3
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
3
4
|
import { mockTx } from '@aztec/stdlib/testing';
|
|
@@ -13,7 +14,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
13
14
|
let pool: TxPool;
|
|
14
15
|
|
|
15
16
|
const minedBlockHeader = BlockHeader.empty({
|
|
16
|
-
globalVariables: GlobalVariables.empty({ blockNumber: 1, timestamp: 0n }),
|
|
17
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(1), timestamp: 0n }),
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
beforeEach(() => {
|
|
@@ -261,7 +262,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
261
262
|
await pool.deleteTxs([txs[0].getTxHash(), txs[1].getTxHash()]);
|
|
262
263
|
|
|
263
264
|
// Clean up deleted mined txs from block 1 and earlier
|
|
264
|
-
const deletedCount = await pool.cleanupDeletedMinedTxs(1);
|
|
265
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
265
266
|
|
|
266
267
|
// Verify old transactions are permanently deleted
|
|
267
268
|
expect(deletedCount).toBe(2);
|
|
@@ -276,7 +277,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
276
277
|
|
|
277
278
|
// Mark as mined in block 2
|
|
278
279
|
const laterBlockHeader = BlockHeader.empty({
|
|
279
|
-
globalVariables: GlobalVariables.empty({ blockNumber: 2, timestamp: 0n }),
|
|
280
|
+
globalVariables: GlobalVariables.empty({ blockNumber: BlockNumber(2), timestamp: 0n }),
|
|
280
281
|
});
|
|
281
282
|
await pool.markAsMined([txs[0].getTxHash()], laterBlockHeader);
|
|
282
283
|
|
|
@@ -284,7 +285,7 @@ export function describeTxPool(getTxPool: () => TxPool) {
|
|
|
284
285
|
await pool.deleteTxs([txs[0].getTxHash()]);
|
|
285
286
|
|
|
286
287
|
// Try to clean up with block 1 (before the mined block)
|
|
287
|
-
const deletedCount = await pool.cleanupDeletedMinedTxs(1);
|
|
288
|
+
const deletedCount = await pool.cleanupDeletedMinedTxs(BlockNumber(1));
|
|
288
289
|
|
|
289
290
|
// Verify no transactions were cleaned up
|
|
290
291
|
expect(deletedCount).toBe(0);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
3
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -33,7 +34,7 @@ export interface MessageValidator {
|
|
|
33
34
|
|
|
34
35
|
export function createTxMessageValidators(
|
|
35
36
|
timestamp: UInt64,
|
|
36
|
-
blockNumber:
|
|
37
|
+
blockNumber: BlockNumber,
|
|
37
38
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
38
39
|
gasFees: GasFees,
|
|
39
40
|
l1ChainId: number,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import {
|
|
3
4
|
type AnyTx,
|
|
@@ -17,7 +18,7 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
17
18
|
// being built.
|
|
18
19
|
timestamp: UInt64;
|
|
19
20
|
// Block number in which the tx is considered to be included.
|
|
20
|
-
blockNumber:
|
|
21
|
+
blockNumber: BlockNumber;
|
|
21
22
|
},
|
|
22
23
|
) {}
|
|
23
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
@@ -131,7 +131,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
131
131
|
private protocolVersion = '';
|
|
132
132
|
private topicStrings: Record<TopicType, string> = {} as Record<TopicType, string>;
|
|
133
133
|
|
|
134
|
-
private feesCache: { blockNumber:
|
|
134
|
+
private feesCache: { blockNumber: BlockNumber; gasFees: GasFees } | undefined;
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* Callback for when a block is received from a peer.
|
|
@@ -1148,7 +1148,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1148
1148
|
return false;
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
|
-
const local = await this.archiver.getBlock(reqNum);
|
|
1151
|
+
const local = await this.archiver.getBlock(BlockNumber(reqNum));
|
|
1152
1152
|
if (!local) {
|
|
1153
1153
|
// We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
|
|
1154
1154
|
// TODO: Consider extending this validator to accept an expected hash or
|
|
@@ -1223,7 +1223,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1223
1223
|
|
|
1224
1224
|
// Double spend validator has a special case handler
|
|
1225
1225
|
if (name === 'doubleSpendValidator') {
|
|
1226
|
-
const txBlockNumber = currentBlockNumber + 1; // tx is expected to be in the next block
|
|
1226
|
+
const txBlockNumber = BlockNumber(currentBlockNumber + 1); // tx is expected to be in the next block
|
|
1227
1227
|
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
@@ -1233,7 +1233,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1233
1233
|
return true;
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
|
-
private async getGasFees(blockNumber:
|
|
1236
|
+
private async getGasFees(blockNumber: BlockNumber): Promise<GasFees> {
|
|
1237
1237
|
if (blockNumber === this.feesCache?.blockNumber) {
|
|
1238
1238
|
return this.feesCache.gasFees;
|
|
1239
1239
|
}
|
|
@@ -1274,13 +1274,13 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1274
1274
|
* @returns The message validators.
|
|
1275
1275
|
*/
|
|
1276
1276
|
private async createMessageValidators(
|
|
1277
|
-
currentBlockNumber:
|
|
1277
|
+
currentBlockNumber: BlockNumber,
|
|
1278
1278
|
nextSlotTimestamp: UInt64,
|
|
1279
1279
|
): Promise<Record<string, MessageValidator>[]> {
|
|
1280
1280
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1281
1281
|
const allowedInSetup = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
1282
1282
|
|
|
1283
|
-
const blockNumberInWhichTheTxIsConsideredToBeIncluded = currentBlockNumber + 1;
|
|
1283
|
+
const blockNumberInWhichTheTxIsConsideredToBeIncluded = BlockNumber(currentBlockNumber + 1);
|
|
1284
1284
|
|
|
1285
1285
|
return createTxMessageValidators(
|
|
1286
1286
|
nextSlotTimestamp,
|
|
@@ -1342,7 +1342,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1342
1342
|
* @param peerId - The peer ID of the peer that sent the tx.
|
|
1343
1343
|
* @returns Severity
|
|
1344
1344
|
*/
|
|
1345
|
-
private async handleDoubleSpendFailure(tx: Tx, blockNumber:
|
|
1345
|
+
private async handleDoubleSpendFailure(tx: Tx, blockNumber: BlockNumber): Promise<PeerErrorSeverity> {
|
|
1346
1346
|
if (blockNumber <= this.config.doubleSpendSeverePeerPenaltyWindow) {
|
|
1347
1347
|
return PeerErrorSeverity.HighToleranceError;
|
|
1348
1348
|
}
|
|
@@ -1350,7 +1350,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1350
1350
|
const snapshotValidator = new DoubleSpendTxValidator({
|
|
1351
1351
|
nullifiersExist: async (nullifiers: Buffer[]) => {
|
|
1352
1352
|
const merkleTree = this.worldStateSynchronizer.getSnapshot(
|
|
1353
|
-
blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow,
|
|
1353
|
+
BlockNumber(blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow),
|
|
1354
1354
|
);
|
|
1355
1355
|
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
1356
1356
|
return indices.map(index => index !== undefined);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
4
|
|
|
@@ -27,7 +28,7 @@ export function reqRespBlockHandler(l2BlockSource: L2BlockSource): ReqRespSubPro
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
try {
|
|
30
|
-
const foundBlock = await l2BlockSource.getBlock(Number(blockNumber));
|
|
31
|
+
const foundBlock = await l2BlockSource.getBlock(BlockNumber(Number(blockNumber)));
|
|
31
32
|
return foundBlock ? foundBlock.toBuffer() : Buffer.alloc(0);
|
|
32
33
|
} catch (err: any) {
|
|
33
34
|
throw new ReqRespStatusError(ReqRespStatus.INTERNAL_ERROR, { cause: err });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -15,9 +16,9 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
15
16
|
export class StatusMessage {
|
|
16
17
|
constructor(
|
|
17
18
|
readonly compressedComponentsVersion: string,
|
|
18
|
-
readonly latestBlockNumber:
|
|
19
|
+
readonly latestBlockNumber: BlockNumber,
|
|
19
20
|
readonly latestBlockHash: string,
|
|
20
|
-
readonly finalizedBlockNumber:
|
|
21
|
+
readonly finalizedBlockNumber: BlockNumber,
|
|
21
22
|
//TODO: add finalizedBlockHash
|
|
22
23
|
//readonly finalizedBlockHash: string,
|
|
23
24
|
) {}
|
|
@@ -31,9 +32,9 @@ export class StatusMessage {
|
|
|
31
32
|
const reader = BufferReader.asReader(buffer);
|
|
32
33
|
return new StatusMessage(
|
|
33
34
|
reader.readString(), // compressedComponentsVersion
|
|
34
|
-
reader.readNumber(), // latestBlockNumber
|
|
35
|
+
BlockNumber(reader.readNumber()), // latestBlockNumber
|
|
35
36
|
reader.readString(), // latestBlockHash
|
|
36
|
-
reader.readNumber(), // finalizedBlockNumber
|
|
37
|
+
BlockNumber(reader.readNumber()), // finalizedBlockNumber
|
|
37
38
|
//TODO: add finalizedBlockHash
|
|
38
39
|
//reader.readString(), // finalizedBlockHash
|
|
39
40
|
);
|
|
@@ -63,9 +64,9 @@ export class StatusMessage {
|
|
|
63
64
|
static fromWorldStateSyncStatus(version: string, syncStatus: WorldStateSyncStatus): StatusMessage {
|
|
64
65
|
return new StatusMessage(
|
|
65
66
|
version,
|
|
66
|
-
syncStatus.latestBlockNumber,
|
|
67
|
+
BlockNumber(syncStatus.latestBlockNumber),
|
|
67
68
|
syncStatus.latestBlockHash,
|
|
68
|
-
syncStatus.finalizedBlockNumber,
|
|
69
|
+
BlockNumber(syncStatus.finalizedBlockNumber),
|
|
69
70
|
//TODO: add finalizedBlockHash
|
|
70
71
|
);
|
|
71
72
|
}
|
|
@@ -73,9 +74,9 @@ export class StatusMessage {
|
|
|
73
74
|
static random(): StatusMessage {
|
|
74
75
|
return new StatusMessage(
|
|
75
76
|
'1.0.0',
|
|
76
|
-
Math.floor(Math.random() * 100),
|
|
77
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
77
78
|
Buffer32.random().toString(),
|
|
78
|
-
Math.floor(Math.random() * 100),
|
|
79
|
+
BlockNumber(Math.floor(Math.random() * 100)),
|
|
79
80
|
//TODO: add finalizedBlockHash
|
|
80
81
|
);
|
|
81
82
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { times } from '@aztec/foundation/collection';
|
|
2
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
3
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
@@ -316,7 +317,7 @@ export class FastTxCollection {
|
|
|
316
317
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
317
318
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
318
319
|
*/
|
|
319
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
320
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
320
321
|
for (const request of this.requests) {
|
|
321
322
|
if (request.blockInfo.blockNumber <= blockNumber) {
|
|
322
323
|
request.promise.reject(new AbortError(`Stopped collecting txs up to block ${blockNumber}`));
|
|
@@ -329,7 +330,7 @@ export class FastTxCollection {
|
|
|
329
330
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
330
331
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
331
332
|
*/
|
|
332
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
333
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
333
334
|
for (const request of this.requests) {
|
|
334
335
|
if (request.blockInfo.blockNumber > blockNumber) {
|
|
335
336
|
request.promise.reject(new AbortError(`Stopped collecting txs after block ${blockNumber}`));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { chunk } from '@aztec/foundation/collection';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { boundInclusive } from '@aztec/foundation/number';
|
|
@@ -203,7 +203,7 @@ export class SlowTxCollection {
|
|
|
203
203
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
204
204
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
205
205
|
*/
|
|
206
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
206
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
207
207
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
208
208
|
if (info.blockNumber <= blockNumber) {
|
|
209
209
|
this.missingTxs.delete(txHash);
|
|
@@ -215,7 +215,7 @@ export class SlowTxCollection {
|
|
|
215
215
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
216
216
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
217
217
|
*/
|
|
218
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
218
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
219
219
|
for (const [txHash, info] of this.missingTxs.entries()) {
|
|
220
220
|
if (info.blockNumber > blockNumber) {
|
|
221
221
|
this.missingTxs.delete(txHash);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { type PromiseWithResolvers, RunningPromise } from '@aztec/foundation/promise';
|
|
4
5
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
|
|
6
|
+
import type { L2Block, L2BlockInfo, L2BlockNew } from '@aztec/stdlib/block';
|
|
6
7
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
7
8
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
8
9
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -21,11 +22,11 @@ import type { TxSource } from './tx_source.js';
|
|
|
21
22
|
|
|
22
23
|
export type CollectionMethod = 'fast-req-resp' | 'fast-node-rpc' | 'slow-req-resp' | 'slow-node-rpc';
|
|
23
24
|
|
|
24
|
-
export type MissingTxInfo = { blockNumber:
|
|
25
|
+
export type MissingTxInfo = { blockNumber: BlockNumber; deadline: Date; readyForReqResp: boolean };
|
|
25
26
|
|
|
26
27
|
export type FastCollectionRequestInput =
|
|
27
|
-
| { type: 'block'; block:
|
|
28
|
-
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber:
|
|
28
|
+
| { type: 'block'; block: L2BlockNew }
|
|
29
|
+
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
|
|
29
30
|
|
|
30
31
|
export type FastCollectionRequest = FastCollectionRequestInput & {
|
|
31
32
|
missingTxHashes: Set<string>;
|
|
@@ -152,7 +153,7 @@ export class TxCollection {
|
|
|
152
153
|
/** Collects the set of txs for the given block proposal as fast as possible */
|
|
153
154
|
public collectFastForProposal(
|
|
154
155
|
blockProposal: BlockProposal,
|
|
155
|
-
blockNumber:
|
|
156
|
+
blockNumber: BlockNumber,
|
|
156
157
|
txHashes: TxHash[] | string[],
|
|
157
158
|
opts: { deadline: Date; pinnedPeer?: PeerId },
|
|
158
159
|
) {
|
|
@@ -165,7 +166,7 @@ export class TxCollection {
|
|
|
165
166
|
txHashes: TxHash[] | string[],
|
|
166
167
|
opts: { deadline: Date; pinnedPeer?: PeerId },
|
|
167
168
|
) {
|
|
168
|
-
return this.collectFastFor({ type: 'block', block }, txHashes, opts);
|
|
169
|
+
return this.collectFastFor({ type: 'block', block: block.toL2Block() }, txHashes, opts);
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
/** Collects the set of txs for the given proposal or block as fast as possible */
|
|
@@ -187,7 +188,7 @@ export class TxCollection {
|
|
|
187
188
|
* Stop collecting all txs for blocks less than or requal to the block number specified.
|
|
188
189
|
* To be called when we no longer care about gathering txs up to a certain block, eg when they become proven or finalized.
|
|
189
190
|
*/
|
|
190
|
-
public stopCollectingForBlocksUpTo(blockNumber:
|
|
191
|
+
public stopCollectingForBlocksUpTo(blockNumber: BlockNumber): void {
|
|
191
192
|
this.slowCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
192
193
|
this.fastCollection.stopCollectingForBlocksUpTo(blockNumber);
|
|
193
194
|
}
|
|
@@ -196,7 +197,7 @@ export class TxCollection {
|
|
|
196
197
|
* Stop collecting all txs for blocks greater than the block number specified.
|
|
197
198
|
* To be called when there is a chain prune and previously mined txs are no longer relevant.
|
|
198
199
|
*/
|
|
199
|
-
public stopCollectingForBlocksAfter(blockNumber:
|
|
200
|
+
public stopCollectingForBlocksAfter(blockNumber: BlockNumber): void {
|
|
200
201
|
this.slowCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
201
202
|
this.fastCollection.stopCollectingForBlocksAfter(blockNumber);
|
|
202
203
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { elapsed } from '@aztec/foundation/timer';
|
|
4
|
-
import type {
|
|
5
|
+
import type { L2BlockInfo, L2BlockNew } from '@aztec/stdlib/block';
|
|
5
6
|
import type { ITxProvider } from '@aztec/stdlib/interfaces/server';
|
|
6
7
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
7
8
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
@@ -55,7 +56,7 @@ export class TxProvider implements ITxProvider {
|
|
|
55
56
|
/** Gathers txs from the tx pool, proposal body, remote rpc nodes, and reqresp. */
|
|
56
57
|
public getTxsForBlockProposal(
|
|
57
58
|
blockProposal: BlockProposal,
|
|
58
|
-
blockNumber:
|
|
59
|
+
blockNumber: BlockNumber,
|
|
59
60
|
opts: { pinnedPeer: PeerId | undefined; deadline: Date },
|
|
60
61
|
): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
61
62
|
return this.getOrderedTxsFromAllSources(
|
|
@@ -67,7 +68,7 @@ export class TxProvider implements ITxProvider {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/** Gathers txs from the tx pool, remote rpc nodes, and reqresp. */
|
|
70
|
-
public getTxsForBlock(block:
|
|
71
|
+
public getTxsForBlock(block: L2BlockNew, opts: { deadline: Date }): Promise<{ txs: Tx[]; missingTxs: TxHash[] }> {
|
|
71
72
|
return this.getOrderedTxsFromAllSources(
|
|
72
73
|
{ type: 'block', block },
|
|
73
74
|
block.toBlockInfo(),
|