@aztec/p2p 0.56.0 → 0.58.0
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/index.d.ts +6 -3
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +12 -6
- package/dest/client/p2p_client.d.ts +30 -12
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +375 -335
- package/dest/config.js +3 -3
- package/dest/index.d.ts +4 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -4
- package/dest/{attestation_pool → mem_pools/attestation_pool}/attestation_pool.d.ts +2 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -0
- package/dest/{attestation_pool → mem_pools/attestation_pool}/attestation_pool.js +1 -1
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -0
- package/dest/{attestation_pool → mem_pools/attestation_pool}/index.js +1 -1
- package/dest/{attestation_pool → mem_pools/attestation_pool}/memory_attestation_pool.d.ts +6 -2
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -0
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +114 -0
- package/dest/{attestation_pool → mem_pools/attestation_pool}/mocks.d.ts +2 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -0
- package/dest/mem_pools/attestation_pool/mocks.js +31 -0
- package/dest/mem_pools/epoch_proof_quote_pool/epoch_proof_quote_pool.d.ts +7 -0
- package/dest/mem_pools/epoch_proof_quote_pool/epoch_proof_quote_pool.d.ts.map +1 -0
- package/dest/mem_pools/epoch_proof_quote_pool/epoch_proof_quote_pool.js +2 -0
- package/dest/mem_pools/epoch_proof_quote_pool/index.d.ts +4 -0
- package/dest/mem_pools/epoch_proof_quote_pool/index.d.ts.map +1 -0
- package/dest/mem_pools/epoch_proof_quote_pool/index.js +4 -0
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.d.ts +12 -0
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.d.ts.map +1 -0
- package/dest/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.js +30 -0
- package/dest/mem_pools/epoch_proof_quote_pool/test_utils.d.ts +8 -0
- package/dest/mem_pools/epoch_proof_quote_pool/test_utils.d.ts.map +1 -0
- package/dest/mem_pools/epoch_proof_quote_pool/test_utils.js +21 -0
- package/dest/mem_pools/index.d.ts +5 -0
- package/dest/mem_pools/index.d.ts.map +1 -0
- package/dest/mem_pools/index.js +2 -0
- package/dest/mem_pools/instrumentation.d.ts +25 -0
- package/dest/mem_pools/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/instrumentation.js +70 -0
- package/dest/mem_pools/interface.d.ts +12 -0
- package/dest/mem_pools/interface.d.ts.map +1 -0
- package/dest/mem_pools/interface.js +2 -0
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -0
- package/dest/{tx_pool → mem_pools/tx_pool}/aztec_kv_tx_pool.js +9 -9
- package/dest/mem_pools/tx_pool/index.d.ts.map +1 -0
- package/dest/{tx_pool → mem_pools/tx_pool}/index.js +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +111 -0
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -0
- package/dest/{tx_pool → mem_pools/tx_pool}/tx_pool.js +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +55 -0
- package/dest/service/libp2p_service.d.ts +12 -7
- package/dest/service/libp2p_service.d.ts.map +1 -1
- package/dest/service/libp2p_service.js +453 -381
- package/dest/service/reqresp/reqresp.d.ts +0 -1
- package/dest/service/reqresp/reqresp.d.ts.map +1 -1
- package/dest/service/reqresp/reqresp.js +7 -4
- package/package.json +10 -6
- package/src/client/index.ts +21 -8
- package/src/client/p2p_client.ts +77 -21
- package/src/config.ts +2 -2
- package/src/index.ts +4 -3
- package/src/{attestation_pool → mem_pools/attestation_pool}/attestation_pool.ts +2 -1
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +141 -0
- package/src/{attestation_pool → mem_pools/attestation_pool}/mocks.ts +5 -2
- package/src/mem_pools/epoch_proof_quote_pool/epoch_proof_quote_pool.ts +7 -0
- package/src/mem_pools/epoch_proof_quote_pool/index.ts +3 -0
- package/src/mem_pools/epoch_proof_quote_pool/memory_epoch_proof_quote_pool.ts +42 -0
- package/src/mem_pools/epoch_proof_quote_pool/test_utils.ts +26 -0
- package/src/mem_pools/index.ts +4 -0
- package/src/mem_pools/instrumentation.ts +85 -0
- package/src/mem_pools/interface.ts +12 -0
- package/src/{tx_pool → mem_pools/tx_pool}/aztec_kv_tx_pool.ts +9 -9
- package/src/{tx_pool → mem_pools/tx_pool}/memory_tx_pool.ts +9 -9
- package/src/service/libp2p_service.ts +78 -20
- package/src/service/reqresp/reqresp.ts +9 -5
- package/dest/attestation_pool/attestation_pool.d.ts.map +0 -1
- package/dest/attestation_pool/index.d.ts.map +0 -1
- package/dest/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/attestation_pool/memory_attestation_pool.js +0 -57
- package/dest/attestation_pool/mocks.d.ts.map +0 -1
- package/dest/attestation_pool/mocks.js +0 -32
- package/dest/client/mocks.d.ts +0 -65
- package/dest/client/mocks.d.ts.map +0 -1
- package/dest/client/mocks.js +0 -106
- package/dest/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/tx_pool/index.d.ts.map +0 -1
- package/dest/tx_pool/instrumentation.d.ts +0 -25
- package/dest/tx_pool/instrumentation.d.ts.map +0 -1
- package/dest/tx_pool/instrumentation.js +0 -61
- package/dest/tx_pool/memory_tx_pool.d.ts.map +0 -1
- package/dest/tx_pool/memory_tx_pool.js +0 -111
- package/dest/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/tx_pool/tx_pool_test_suite.js +0 -55
- package/src/attestation_pool/memory_attestation_pool.ts +0 -71
- package/src/client/mocks.ts +0 -129
- package/src/tx_pool/instrumentation.ts +0 -73
- /package/dest/{attestation_pool → mem_pools/attestation_pool}/index.d.ts +0 -0
- /package/dest/{tx_pool → mem_pools/tx_pool}/aztec_kv_tx_pool.d.ts +0 -0
- /package/dest/{tx_pool → mem_pools/tx_pool}/index.d.ts +0 -0
- /package/dest/{tx_pool → mem_pools/tx_pool}/memory_tx_pool.d.ts +0 -0
- /package/dest/{tx_pool → mem_pools/tx_pool}/tx_pool.d.ts +0 -0
- /package/dest/{tx_pool → mem_pools/tx_pool}/tx_pool_test_suite.d.ts +0 -0
- /package/src/{attestation_pool → mem_pools/attestation_pool}/index.ts +0 -0
- /package/src/{tx_pool → mem_pools/tx_pool}/index.ts +0 -0
- /package/src/{tx_pool → mem_pools/tx_pool}/tx_pool.ts +0 -0
- /package/src/{tx_pool → mem_pools/tx_pool}/tx_pool_test_suite.ts +0 -0
package/src/client/mocks.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { L2Block, type L2BlockSource, type TxEffect, type TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types';
|
|
2
|
-
import { EthAddress } from '@aztec/circuits.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A mocked implementation of L2BlockSource to be used in p2p tests.
|
|
6
|
-
*/
|
|
7
|
-
export class MockBlockSource implements L2BlockSource {
|
|
8
|
-
private l2Blocks: L2Block[] = [];
|
|
9
|
-
private txEffects: TxEffect[] = [];
|
|
10
|
-
|
|
11
|
-
constructor(numBlocks = 100, private provenBlockNumber?: number) {
|
|
12
|
-
this.addBlocks(numBlocks);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public addBlocks(numBlocks: number) {
|
|
16
|
-
for (let i = 0; i < numBlocks; i++) {
|
|
17
|
-
const blockNum = this.l2Blocks.length;
|
|
18
|
-
const block = L2Block.random(blockNum, blockNum);
|
|
19
|
-
this.l2Blocks.push(block);
|
|
20
|
-
this.txEffects.push(...block.body.txEffects);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public setProvenBlockNumber(provenBlockNumber: number) {
|
|
25
|
-
this.provenBlockNumber = provenBlockNumber;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Method to fetch the rollup contract address at the base-layer.
|
|
30
|
-
* @returns The rollup address.
|
|
31
|
-
*/
|
|
32
|
-
getRollupAddress(): Promise<EthAddress> {
|
|
33
|
-
return Promise.resolve(EthAddress.random());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Method to fetch the registry contract address at the base-layer.
|
|
38
|
-
* @returns The registry address.
|
|
39
|
-
*/
|
|
40
|
-
getRegistryAddress(): Promise<EthAddress> {
|
|
41
|
-
return Promise.resolve(EthAddress.random());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
46
|
-
* @returns In this mock instance, returns the number of L2 blocks that we've mocked.
|
|
47
|
-
*/
|
|
48
|
-
public getBlockNumber() {
|
|
49
|
-
return Promise.resolve(this.l2Blocks.length - 1);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public async getProvenBlockNumber(): Promise<number> {
|
|
53
|
-
return this.provenBlockNumber ?? (await this.getBlockNumber());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Gets an l2 block.
|
|
58
|
-
* @param number - The block number to return (inclusive).
|
|
59
|
-
* @returns The requested L2 block.
|
|
60
|
-
*/
|
|
61
|
-
public getBlock(number: number) {
|
|
62
|
-
return Promise.resolve(this.l2Blocks[number]);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
67
|
-
* @param from - Number of the first block to return (inclusive).
|
|
68
|
-
* @param limit - The maximum number of blocks to return.
|
|
69
|
-
* @returns The requested mocked L2 blocks.
|
|
70
|
-
*/
|
|
71
|
-
public getBlocks(from: number, limit: number, proven?: boolean) {
|
|
72
|
-
return Promise.resolve(
|
|
73
|
-
this.l2Blocks
|
|
74
|
-
.slice(from, from + limit)
|
|
75
|
-
.filter(b => !proven || this.provenBlockNumber === undefined || b.number <= this.provenBlockNumber),
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Gets a tx effect.
|
|
81
|
-
* @param txHash - The hash of a transaction which resulted in the returned tx effect.
|
|
82
|
-
* @returns The requested tx effect.
|
|
83
|
-
*/
|
|
84
|
-
public getTxEffect(txHash: TxHash) {
|
|
85
|
-
const txEffect = this.txEffects.find(tx => tx.txHash.equals(txHash));
|
|
86
|
-
return Promise.resolve(txEffect);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Gets a receipt of a settled tx.
|
|
91
|
-
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
92
|
-
* @returns The requested tx receipt (or undefined if not found).
|
|
93
|
-
*/
|
|
94
|
-
public getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
95
|
-
for (const block of this.l2Blocks) {
|
|
96
|
-
for (const txEffect of block.body.txEffects) {
|
|
97
|
-
if (txEffect.txHash.equals(txHash)) {
|
|
98
|
-
return Promise.resolve(
|
|
99
|
-
new TxReceipt(
|
|
100
|
-
txHash,
|
|
101
|
-
TxStatus.SUCCESS,
|
|
102
|
-
'',
|
|
103
|
-
txEffect.transactionFee.toBigInt(),
|
|
104
|
-
block.hash().toBuffer(),
|
|
105
|
-
block.number,
|
|
106
|
-
),
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return Promise.resolve(undefined);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Starts the block source. In this mock implementation, this is a noop.
|
|
116
|
-
* @returns A promise that signals the initialization of the l2 block source on completion.
|
|
117
|
-
*/
|
|
118
|
-
public start(): Promise<void> {
|
|
119
|
-
return Promise.resolve();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Stops the block source. In this mock implementation, this is a noop.
|
|
124
|
-
* @returns A promise that signals the l2 block source is now stopped.
|
|
125
|
-
*/
|
|
126
|
-
public stop(): Promise<void> {
|
|
127
|
-
return Promise.resolve();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { type Tx } from '@aztec/circuit-types';
|
|
2
|
-
import { Attributes, type Histogram, Metrics, type TelemetryClient, type UpDownCounter } from '@aztec/telemetry-client';
|
|
3
|
-
|
|
4
|
-
export type TxStatus = 'pending' | 'mined';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Instrumentation class for the TxPool.
|
|
8
|
-
*/
|
|
9
|
-
export class TxPoolInstrumentation {
|
|
10
|
-
/** The number of txs in the mempool */
|
|
11
|
-
private txInMempool: UpDownCounter;
|
|
12
|
-
/** Tracks tx size */
|
|
13
|
-
private txSize: Histogram;
|
|
14
|
-
|
|
15
|
-
constructor(telemetry: TelemetryClient, name: string) {
|
|
16
|
-
const meter = telemetry.getMeter(name);
|
|
17
|
-
this.txInMempool = meter.createUpDownCounter(Metrics.MEMPOOL_TX_COUNT, {
|
|
18
|
-
description: 'The current number of transactions in the mempool',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
this.txSize = meter.createHistogram(Metrics.MEMPOOL_TX_SIZE, {
|
|
22
|
-
unit: 'By',
|
|
23
|
-
description: 'The size of transactions in the mempool',
|
|
24
|
-
advice: {
|
|
25
|
-
explicitBucketBoundaries: [
|
|
26
|
-
5_000, // 5KB
|
|
27
|
-
10_000,
|
|
28
|
-
20_000,
|
|
29
|
-
50_000,
|
|
30
|
-
75_000,
|
|
31
|
-
100_000, // 100KB
|
|
32
|
-
200_000,
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public recordTxSize(tx: Tx) {
|
|
39
|
-
this.txSize.record(tx.getSize());
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Updates the metrics with the new transactions.
|
|
44
|
-
* @param txs - The transactions to record
|
|
45
|
-
*/
|
|
46
|
-
public recordAddedTxs(status: string, count = 1) {
|
|
47
|
-
if (count < 0) {
|
|
48
|
-
throw new Error('Count must be positive');
|
|
49
|
-
}
|
|
50
|
-
if (count === 0) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this.txInMempool.add(count, {
|
|
54
|
-
[Attributes.STATUS]: status,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Updates the metrics by removing transactions from the mempool.
|
|
60
|
-
* @param count - The number of transactions to remove from the mempool
|
|
61
|
-
*/
|
|
62
|
-
public recordRemovedTxs(status: string, count = 1) {
|
|
63
|
-
if (count < 0) {
|
|
64
|
-
throw new Error('Count must be positive');
|
|
65
|
-
}
|
|
66
|
-
if (count === 0) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.txInMempool.add(-1 * count, {
|
|
70
|
-
[Attributes.STATUS]: status,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|