@aztec/p2p 0.87.7 → 0.87.8
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/interface.d.ts +1 -1
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +2 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +3 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +0 -9
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +1 -0
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +13 -8
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +1 -0
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +7 -6
- package/dest/mem_pools/instrumentation.d.ts +7 -11
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +25 -37
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +2 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +22 -38
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +1 -0
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +13 -21
- package/dest/services/encoding.d.ts +2 -0
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +9 -1
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +9 -5
- package/dest/services/tx_collect_instrumentation.d.ts +13 -0
- package/dest/services/tx_collect_instrumentation.d.ts.map +1 -0
- package/dest/services/tx_collect_instrumentation.js +34 -0
- package/dest/services/tx_collector.d.ts +6 -2
- package/dest/services/tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collector.js +61 -49
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -0
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +6 -0
- package/package.json +12 -12
- package/src/client/interface.ts +1 -1
- package/src/client/p2p_client.ts +3 -3
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +0 -14
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +17 -12
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +8 -7
- package/src/mem_pools/instrumentation.ts +32 -46
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +23 -58
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +14 -26
- package/src/services/encoding.ts +9 -1
- package/src/services/reqresp/reqresp.ts +6 -6
- package/src/services/tx_collect_instrumentation.ts +44 -0
- package/src/services/tx_collector.ts +87 -66
- package/src/test-helpers/reqresp-nodes.ts +6 -0
|
@@ -18,6 +18,7 @@ export declare class InMemoryTxPool implements TxPool {
|
|
|
18
18
|
* @param log - A logger.
|
|
19
19
|
*/
|
|
20
20
|
constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
21
|
+
private countTx;
|
|
21
22
|
isEmpty(): Promise<boolean>;
|
|
22
23
|
markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
|
|
23
24
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/memory_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAA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AQ7C,gBAAgB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAM/C,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAW5E;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAK3D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IAG7D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,mBAAmB,IAAI,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAIrD;;;;OAIG;IACU,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB7C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD;;;OAGG;IACI,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAIjC;;;OAGG;IACI,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1C,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAE1C,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
|
|
@@ -18,11 +18,20 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
18
18
|
* @param log - A logger.
|
|
19
19
|
*/ constructor(telemetry = getTelemetryClient(), log = createLogger('p2p:tx_pool')){
|
|
20
20
|
this.log = log;
|
|
21
|
+
this.countTx = ()=>{
|
|
22
|
+
return Promise.resolve({
|
|
23
|
+
itemCount: {
|
|
24
|
+
mined: this.minedTxs.size,
|
|
25
|
+
pending: this.pendingTxs.size
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
21
29
|
this.txs = new Map();
|
|
22
30
|
this.minedTxs = new Map();
|
|
23
31
|
this.pendingTxs = new Set();
|
|
24
|
-
this.metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL);
|
|
32
|
+
this.metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, this.countTx);
|
|
25
33
|
}
|
|
34
|
+
countTx;
|
|
26
35
|
isEmpty() {
|
|
27
36
|
return Promise.resolve(this.txs.size === 0);
|
|
28
37
|
}
|
|
@@ -32,8 +41,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
32
41
|
this.minedTxs.set(key, blockNumber);
|
|
33
42
|
this.pendingTxs.delete(key);
|
|
34
43
|
}
|
|
35
|
-
this.metrics.recordRemovedObjects(txHashes.length, 'pending');
|
|
36
|
-
this.metrics.recordAddedObjects(txHashes.length, 'mined');
|
|
37
44
|
return Promise.resolve();
|
|
38
45
|
}
|
|
39
46
|
markMinedAsPending(txHashes) {
|
|
@@ -41,20 +48,13 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
41
48
|
return Promise.resolve();
|
|
42
49
|
}
|
|
43
50
|
const keys = txHashes.map((x)=>x.toBigInt());
|
|
44
|
-
let deleted = 0;
|
|
45
|
-
let added = 0;
|
|
46
51
|
for (const key of keys){
|
|
47
|
-
|
|
48
|
-
deleted++;
|
|
49
|
-
}
|
|
52
|
+
this.minedTxs.delete(key);
|
|
50
53
|
// only add back to the pending set if we have the tx object
|
|
51
54
|
if (this.txs.has(key)) {
|
|
52
|
-
added++;
|
|
53
55
|
this.pendingTxs.add(key);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
|
-
this.metrics.recordRemovedObjects(deleted, 'mined');
|
|
57
|
-
this.metrics.recordAddedObjects(added, 'pending');
|
|
58
58
|
return Promise.resolve();
|
|
59
59
|
}
|
|
60
60
|
async getPendingTxHashes() {
|
|
@@ -103,7 +103,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
103
103
|
* @param txs - An array of txs to be added to the pool.
|
|
104
104
|
* @returns Empty promise.
|
|
105
105
|
*/ async addTxs(txs) {
|
|
106
|
-
let pending = 0;
|
|
107
106
|
for (const tx of txs){
|
|
108
107
|
const txHash = await tx.getTxHash();
|
|
109
108
|
this.log.verbose(`Adding tx ${txHash.toString()} to pool`, {
|
|
@@ -113,29 +112,22 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
113
112
|
const key = txHash.toBigInt();
|
|
114
113
|
this.txs.set(key, tx);
|
|
115
114
|
if (!this.minedTxs.has(key)) {
|
|
116
|
-
pending++;
|
|
117
115
|
this.metrics.recordSize(tx);
|
|
118
116
|
this.pendingTxs.add(key);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
this.metrics.recordAddedObjects(pending, 'pending');
|
|
122
|
-
return;
|
|
123
119
|
}
|
|
124
120
|
/**
|
|
125
121
|
* Deletes transactions from the pool. Tx hashes that are not present are ignored.
|
|
126
122
|
* @param txHashes - An array of tx hashes to be removed from the tx pool.
|
|
127
123
|
* @returns The number of transactions that was deleted from the pool.
|
|
128
124
|
*/ deleteTxs(txHashes) {
|
|
129
|
-
let deletedMined = 0;
|
|
130
|
-
let deletedPending = 0;
|
|
131
125
|
for (const txHash of txHashes){
|
|
132
126
|
const key = txHash.toBigInt();
|
|
133
127
|
this.txs.delete(key);
|
|
134
|
-
|
|
135
|
-
|
|
128
|
+
this.pendingTxs.delete(key);
|
|
129
|
+
this.minedTxs.delete(key);
|
|
136
130
|
}
|
|
137
|
-
this.metrics.recordRemovedObjects(deletedPending, 'pending');
|
|
138
|
-
this.metrics.recordRemovedObjects(deletedMined, 'mined');
|
|
139
131
|
return Promise.resolve();
|
|
140
132
|
}
|
|
141
133
|
/**
|
|
@@ -25,5 +25,7 @@ export declare class SnappyTransform implements DataTransform {
|
|
|
25
25
|
inboundTransformNoTopic(data: Buffer): Buffer;
|
|
26
26
|
outboundTransform(_topicStr: string, data: Uint8Array): Uint8Array;
|
|
27
27
|
outboundTransformNoTopic(data: Buffer): Buffer;
|
|
28
|
+
outboundTransformAsync(data: Buffer): Promise<Buffer>;
|
|
29
|
+
inboundTransformAsync(data: Buffer): Promise<Buffer>;
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/services/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAajD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAKvD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAItD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,uBAK1C;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,aAAa;IAEnD,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI1D,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQpD,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI3D,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/services/encoding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAajD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAKvD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAItD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,uBAK1C;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,aAAa;IAEnD,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI1D,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQpD,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU;IAI3D,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAO9C,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrD,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Taken from lodestar: https://github.com/ChainSafe/lodestar
|
|
2
2
|
import { sha256 } from '@aztec/foundation/crypto';
|
|
3
|
-
import { compressSync, uncompressSync } from 'snappy';
|
|
3
|
+
import { compress, compressSync, uncompress, uncompressSync } from 'snappy';
|
|
4
4
|
import xxhashFactory from 'xxhash-wasm';
|
|
5
5
|
// Load WASM
|
|
6
6
|
const xxhash = await xxhashFactory();
|
|
@@ -63,4 +63,12 @@ export function msgIdToStrFn(msgId) {
|
|
|
63
63
|
}
|
|
64
64
|
return Buffer.from(compressSync(data));
|
|
65
65
|
}
|
|
66
|
+
outboundTransformAsync(data) {
|
|
67
|
+
return compress(data);
|
|
68
|
+
}
|
|
69
|
+
inboundTransformAsync(data) {
|
|
70
|
+
return uncompress(data, {
|
|
71
|
+
asBuffer: true
|
|
72
|
+
});
|
|
73
|
+
}
|
|
66
74
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
|
-
import type
|
|
3
|
+
import { type PeerId } from '@libp2p/interface';
|
|
4
4
|
import type { Libp2p } from 'libp2p';
|
|
5
5
|
import type { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
6
6
|
import type { P2PReqRespConfig } from './config.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqresp.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/reqresp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAc,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAE1G,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reqresp.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/reqresp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAc,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAE1G,OAAO,EAAsC,KAAK,MAAM,EAAe,MAAM,mBAAmB,CAAC;AAEjG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AASrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAGL,KAAK,eAAe,EACpB,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,cAAc,EAEpB,MAAM,gBAAgB,CAAC;AASxB;;;;;;;;;;;;;GAaG;AACH,qBAAa,OAAO;IAmBhB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AC,CAAC,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC;IA4IjF;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAKU,iBAAiB,CAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,kBAAkB,EAC/B,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IAsC3B;;;;;;;;;OASG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAoDvB;;;;;;OAMG;YACW,WAAW;IAoCzB;;;;;;;;;;;;;;;OAeG;YAKW,aAAa;YA0EZ,cAAc;CAI9B"}
|
|
@@ -10,6 +10,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
10
10
|
import { executeTimeout } from '@aztec/foundation/timer';
|
|
11
11
|
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
13
|
+
import { CodeError } from '@libp2p/interface';
|
|
13
14
|
import { pipe } from 'it-pipe';
|
|
14
15
|
import { CollectiveReqRespTimeoutError, IndividualReqRespTimeoutError, InvalidResponseError } from '../../errors/reqresp.error.js';
|
|
15
16
|
import { SnappyTransform } from '../encoding.js';
|
|
@@ -406,7 +407,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
406
407
|
}
|
|
407
408
|
// Timeout errors are punished with high tolerance, they can be due to a geogrpahically far away peer or an
|
|
408
409
|
// overloaded peer
|
|
409
|
-
if (e instanceof IndividualReqRespTimeoutError) {
|
|
410
|
+
if (e instanceof IndividualReqRespTimeoutError || e instanceof CodeError && e.code === 'ERR_TIMEOUT') {
|
|
410
411
|
this.logger.debug(`Timeout error: ${e.message} | peerId: ${peerId.toString()} | subProtocol: ${subProtocol}`, logTags);
|
|
411
412
|
return PeerErrorSeverity.HighToleranceError;
|
|
412
413
|
}
|
|
@@ -433,7 +434,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
433
434
|
}
|
|
434
435
|
}
|
|
435
436
|
const messageData = Buffer.concat(chunks);
|
|
436
|
-
const message = this.snappyTransform.
|
|
437
|
+
const message = await this.snappyTransform.inboundTransformAsync(messageData);
|
|
437
438
|
return {
|
|
438
439
|
status: statusBuffer ?? ReqRespStatus.UNKNOWN,
|
|
439
440
|
data: message
|
|
@@ -491,11 +492,14 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
491
492
|
ReqRespStatus.SUCCESS
|
|
492
493
|
]);
|
|
493
494
|
yield new Uint8Array(successChunk);
|
|
494
|
-
yield new Uint8Array(transform.
|
|
495
|
+
yield new Uint8Array(await transform.outboundTransformAsync(response));
|
|
495
496
|
}
|
|
496
497
|
}, stream);
|
|
497
498
|
} catch (e) {
|
|
498
|
-
this.logger.warn(
|
|
499
|
+
this.logger.warn(`Reqresp Response error: ${e?.name} ${e?.code} ${e?.message}`, {
|
|
500
|
+
err: e,
|
|
501
|
+
protocol
|
|
502
|
+
});
|
|
499
503
|
this.metrics.recordResponseError(protocol);
|
|
500
504
|
// If we receive a known error, we use the error status in the response chunk, otherwise we categorize as unknown
|
|
501
505
|
let errorStatus = ReqRespStatus.UNKNOWN;
|
|
@@ -509,7 +513,7 @@ import { ReqRespStatus, ReqRespStatusError, parseStatusChunk, prettyPrintReqResp
|
|
|
509
513
|
yield* sendErrorChunk;
|
|
510
514
|
}, stream);
|
|
511
515
|
} else {
|
|
512
|
-
this.logger.
|
|
516
|
+
this.logger.trace('Stream already closed, not sending error response', {
|
|
513
517
|
protocol,
|
|
514
518
|
err: e,
|
|
515
519
|
errorStatus
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
|
+
export declare class TxCollectorInstrumentation {
|
|
3
|
+
private txFromProposalCount;
|
|
4
|
+
private txFromMempoolCount;
|
|
5
|
+
private txFromP2PCount;
|
|
6
|
+
private missingTxsCount;
|
|
7
|
+
constructor(client: TelemetryClient, name: string);
|
|
8
|
+
incTxsFromProposals(count: number): void;
|
|
9
|
+
incTxsFromMempool(count: number): void;
|
|
10
|
+
incTxsFromP2P(count: number): void;
|
|
11
|
+
incMissingTxs(count: number): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=tx_collect_instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx_collect_instrumentation.d.ts","sourceRoot":"","sources":["../../src/services/tx_collect_instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAE5F,qBAAa,0BAA0B;IACrC,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,kBAAkB,CAAgB;IAC1C,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,eAAe,CAAgB;gBAE3B,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAoBjD,mBAAmB,CAAC,KAAK,EAAE,MAAM;IAIjC,iBAAiB,CAAC,KAAK,EAAE,MAAM;IAI/B,aAAa,CAAC,KAAK,EAAE,MAAM;IAI3B,aAAa,CAAC,KAAK,EAAE,MAAM;CAG5B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Metrics } from '@aztec/telemetry-client';
|
|
2
|
+
export class TxCollectorInstrumentation {
|
|
3
|
+
txFromProposalCount;
|
|
4
|
+
txFromMempoolCount;
|
|
5
|
+
txFromP2PCount;
|
|
6
|
+
missingTxsCount;
|
|
7
|
+
constructor(client, name){
|
|
8
|
+
const meter = client.getMeter(name);
|
|
9
|
+
this.txFromProposalCount = meter.createUpDownCounter(Metrics.TX_COLLECTOR_TXS_FROM_PROPOSALS_COUNT, {
|
|
10
|
+
description: 'The number of txs taken from block proposals'
|
|
11
|
+
});
|
|
12
|
+
this.txFromMempoolCount = meter.createUpDownCounter(Metrics.TX_COLLECTOR_TXS_FROM_MEMPOOL_COUNT, {
|
|
13
|
+
description: 'The number of txs taken from the local mempool'
|
|
14
|
+
});
|
|
15
|
+
this.txFromP2PCount = meter.createUpDownCounter(Metrics.TX_COLLECTOR_TXS_FROM_P2P_COUNT, {
|
|
16
|
+
description: 'The number of txs taken from the p2p network'
|
|
17
|
+
});
|
|
18
|
+
this.missingTxsCount = meter.createUpDownCounter(Metrics.TX_COLLECTOR_MISSING_TXS_COUNT, {
|
|
19
|
+
description: 'The number of txs not found anywhere'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
incTxsFromProposals(count) {
|
|
23
|
+
this.txFromProposalCount.add(count);
|
|
24
|
+
}
|
|
25
|
+
incTxsFromMempool(count) {
|
|
26
|
+
this.txFromMempoolCount.add(count);
|
|
27
|
+
}
|
|
28
|
+
incTxsFromP2P(count) {
|
|
29
|
+
this.txFromP2PCount.add(count);
|
|
30
|
+
}
|
|
31
|
+
incMissingTxs(count) {
|
|
32
|
+
this.missingTxsCount.add(count);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
3
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
5
|
+
import type { PeerId } from '@libp2p/interface';
|
|
4
6
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
5
7
|
export declare class TxCollector {
|
|
6
8
|
private p2pClient;
|
|
7
9
|
private log;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
private instrumentation;
|
|
11
|
+
constructor(p2pClient: Pick<P2PClient, 'getTxsByHashFromPool' | 'hasTxsInPool' | 'getTxsByHash' | 'validate' | 'requestTxsByHash' | 'addTxsToPool'>, log?: Logger, client?: TelemetryClient);
|
|
12
|
+
private collectFromProposal;
|
|
13
|
+
collectForBlockProposal(proposal: BlockProposal, peerWhoSentTheProposal: PeerId | undefined): Promise<{
|
|
10
14
|
txs: Tx[];
|
|
11
15
|
missing?: TxHash[];
|
|
12
16
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_collector.d.ts","sourceRoot":"","sources":["../../src/services/tx_collector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tx_collector.d.ts","sourceRoot":"","sources":["../../src/services/tx_collector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,qBAAa,WAAW;IAIpB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,GAAG;IAPb,OAAO,CAAC,eAAe,CAA6B;gBAG1C,SAAS,EAAE,IAAI,CACrB,SAAS,EACT,sBAAsB,GAAG,cAAc,GAAG,cAAc,GAAG,UAAU,GAAG,kBAAkB,GAAG,cAAc,CAC5G,EACO,GAAG,GAAE,MAAyC,EACtD,MAAM,GAAE,eAAsC;YAMlC,mBAAmB;IAmD3B,uBAAuB,CAC3B,QAAQ,EAAE,aAAa,EACvB,sBAAsB,EAAE,MAAM,GAAG,SAAS,GACzC,OAAO,CAAC;QAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CA2C9C"}
|
|
@@ -1,11 +1,51 @@
|
|
|
1
1
|
import { compactArray } from '@aztec/foundation/collection';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import { TxCollectorInstrumentation } from './tx_collect_instrumentation.js';
|
|
3
5
|
export class TxCollector {
|
|
4
6
|
p2pClient;
|
|
5
7
|
log;
|
|
6
|
-
|
|
8
|
+
instrumentation;
|
|
9
|
+
constructor(p2pClient, log = createLogger('p2p:tx-collector'), client = getTelemetryClient()){
|
|
7
10
|
this.p2pClient = p2pClient;
|
|
8
11
|
this.log = log;
|
|
12
|
+
this.instrumentation = new TxCollectorInstrumentation(client, 'TxCollector');
|
|
13
|
+
}
|
|
14
|
+
// Checks the proposal for transactions we don't already have, validates them and adds them to our pool
|
|
15
|
+
async collectFromProposal(proposal) {
|
|
16
|
+
// Does this proposal have any transactions?
|
|
17
|
+
if (!proposal.txs || proposal.txs.length === 0) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
const proposalHashes = new Set((proposal.payload.txHashes ?? []).map((txHash)=>txHash.toString()));
|
|
21
|
+
// Get the transactions from the proposal and their hashes
|
|
22
|
+
// also, we are only interested in txs that are part of the proposal
|
|
23
|
+
const txsFromProposal = compactArray(await Promise.all(proposal.txs.map((tx)=>tx === undefined ? Promise.resolve(undefined) : tx.getTxHash().then((hash)=>({
|
|
24
|
+
txHash: hash,
|
|
25
|
+
tx
|
|
26
|
+
}))))).filter((tx)=>proposalHashes.has(tx.txHash.toString()));
|
|
27
|
+
// Of the transactions from the proposal, retrieve those that we have in the pool already
|
|
28
|
+
const txsToValidate = [];
|
|
29
|
+
const txsWeAlreadyHave = await this.p2pClient.getTxsByHashFromPool(txsFromProposal.map((tx)=>tx.txHash));
|
|
30
|
+
// Txs we already have will have holes where we did not find them
|
|
31
|
+
// Where that is the case we need to validate the tx in the proposal
|
|
32
|
+
for(let i = 0; i < txsWeAlreadyHave.length; i++){
|
|
33
|
+
if (txsWeAlreadyHave[i] === undefined) {
|
|
34
|
+
txsToValidate.push(txsFromProposal[i].tx);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Now validate all the transactions from the proposal that we don't have
|
|
38
|
+
// This will throw if any of the transactions are invalid, this is probably correct, if someone sends us a proposal with invalid
|
|
39
|
+
// transactions we probably shouldn't spend any more effort on it
|
|
40
|
+
try {
|
|
41
|
+
await this.p2pClient.validate(txsToValidate);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
this.log.error(`Received proposal with invalid transactions, skipping`);
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
// Now store these transactions in our pool, provided these are the txs in proposal.payload.txHashes they will be pinned already
|
|
47
|
+
await this.p2pClient.addTxsToPool(txsToValidate);
|
|
48
|
+
return txsToValidate.length;
|
|
9
49
|
}
|
|
10
50
|
async collectForBlockProposal(proposal, peerWhoSentTheProposal) {
|
|
11
51
|
if (proposal.payload.txHashes.length === 0) {
|
|
@@ -14,60 +54,32 @@ export class TxCollector {
|
|
|
14
54
|
txs: []
|
|
15
55
|
};
|
|
16
56
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const txsToUse = await this.p2pClient.getTxsByHashFromPool(hashesFromPayload);
|
|
24
|
-
const missingTxs = txsToUse.filter((tx)=>tx === undefined).length;
|
|
25
|
-
if (missingTxs > 0) {
|
|
26
|
-
this.log.verbose(`Missing ${missingTxs}/${hashesFromPayload.length} transactions in the tx pool, will attempt to take from the proposal`);
|
|
27
|
-
}
|
|
28
|
-
let usedFromProposal = 0;
|
|
29
|
-
// Fill any holes with txs in the proposal, provided their hash matches the hash in the payload
|
|
30
|
-
for(let i = 0; i < txsToUse.length; i++){
|
|
31
|
-
if (txsToUse[i] === undefined) {
|
|
32
|
-
// We don't have the transaction, take from the proposal, provided the hash is the same
|
|
33
|
-
const hashOfTxInProposal = await proposal.txs[i].getTxHash();
|
|
34
|
-
if (hashOfTxInProposal.equals(hashesFromPayload[i])) {
|
|
35
|
-
// Hash is equal, we can use the tx from the proposal
|
|
36
|
-
txsToUse[i] = proposal.txs[i];
|
|
37
|
-
usedFromProposal++;
|
|
38
|
-
} else {
|
|
39
|
-
this.log.warn(`Unable to take tx: ${hashOfTxInProposal.toString()} from the proposal, it does not match payload hash: ${hashesFromPayload[i].toString()}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// See if we still have any holes, if there are then we were not successful and will try the old method
|
|
44
|
-
if (txsToUse.some((tx)=>tx === undefined)) {
|
|
45
|
-
this.log.warn(`Failed to use transactions from proposal. Falling back to old proposal logic`);
|
|
46
|
-
} else {
|
|
47
|
-
this.log.info(`Successfully used ${usedFromProposal}/${hashesFromPayload.length} transactions from the proposal`);
|
|
48
|
-
await this.p2pClient.validate(txsToUse);
|
|
49
|
-
return {
|
|
50
|
-
txs: txsToUse
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
this.log.info(`Using old style proposal with ${proposal.payload.txHashes.length} transactions`);
|
|
55
|
-
// Old style proposal, we will perform a request by hash from pool
|
|
56
|
-
// This will request from network any txs that are missing
|
|
57
|
+
const txsInMempool = (await this.p2pClient.hasTxsInPool(proposal.payload.txHashes)).filter(Boolean).length;
|
|
58
|
+
this.instrumentation.incTxsFromMempool(txsInMempool);
|
|
59
|
+
// Take txs from the proposal if there are any
|
|
60
|
+
const txTakenFromProposal = await this.collectFromProposal(proposal);
|
|
61
|
+
this.instrumentation.incTxsFromProposals(txTakenFromProposal);
|
|
62
|
+
// Now get the txs we need, either from the pool or the p2p network
|
|
57
63
|
const txHashes = proposal.payload.txHashes;
|
|
58
|
-
// This part is just for logging that we are requesting from the network
|
|
59
|
-
const availability = await this.p2pClient.hasTxsInPool(txHashes);
|
|
60
|
-
const notAvailable = availability.filter((availability)=>availability === false);
|
|
61
|
-
if (notAvailable.length) {
|
|
62
|
-
this.log.verbose(`Missing ${notAvailable.length} transactions in the tx pool, will need to request from the network`);
|
|
63
|
-
}
|
|
64
64
|
// This will request from the network any txs that are missing
|
|
65
65
|
// NOTE: this could still return missing txs so we need to (1) be careful to handle undefined and (2) keep the txs in the correct order for re-execution
|
|
66
66
|
const maybeRetrievedTxs = await this.p2pClient.getTxsByHash(txHashes, peerWhoSentTheProposal);
|
|
67
|
+
// Get the txs that we didn't get from the network, if any. This will be empty if we got them al
|
|
67
68
|
const missingTxs = compactArray(maybeRetrievedTxs.map((tx, index)=>tx === undefined ? txHashes[index] : undefined));
|
|
68
|
-
|
|
69
|
+
this.instrumentation.incMissingTxs(missingTxs.length);
|
|
70
|
+
const txsFromP2P = txHashes.length - txTakenFromProposal - txsInMempool - missingTxs.length;
|
|
71
|
+
this.instrumentation.incTxsFromP2P(txsFromP2P);
|
|
72
|
+
// if we found all txs, this is a noop. If we didn't find all txs then tell the validator to skip attestations because missingTxs.length > 0
|
|
69
73
|
const retrievedTxs = compactArray(maybeRetrievedTxs);
|
|
70
|
-
|
|
74
|
+
this.log.info(`Retrieved ${retrievedTxs.length}/${txHashes.length} txs for block proposal`, {
|
|
75
|
+
blockNumber: proposal.blockNumber.toNumber(),
|
|
76
|
+
slotNumber: proposal.slotNumber.toNumber(),
|
|
77
|
+
totalTxsInProposal: txHashes.length,
|
|
78
|
+
txsFromProposal: txTakenFromProposal,
|
|
79
|
+
txsFromMempool: txsInMempool,
|
|
80
|
+
txsFromP2P,
|
|
81
|
+
missingTxs: missingTxs.length
|
|
82
|
+
});
|
|
71
83
|
return {
|
|
72
84
|
txs: retrievedTxs,
|
|
73
85
|
missing: missingTxs
|
|
@@ -49,9 +49,11 @@ export declare const stopNodes: (nodes: ReqRespNode[]) => Promise<void>;
|
|
|
49
49
|
export declare const createReqResp: (peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>) => Promise<ReqRespNode>;
|
|
50
50
|
export declare const connectToPeers: (nodes: ReqRespNode[]) => Promise<void>;
|
|
51
51
|
export declare class AlwaysTrueCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
52
|
+
stop(): Promise<void>;
|
|
52
53
|
verifyProof(_tx: Tx): Promise<boolean>;
|
|
53
54
|
}
|
|
54
55
|
export declare class AlwaysFalseCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
56
|
+
stop(): Promise<void>;
|
|
55
57
|
verifyProof(_tx: Tx): Promise<boolean>;
|
|
56
58
|
}
|
|
57
59
|
export declare function createBootstrapNodeConfig(privateKey: string, port: number, chainConfig: ChainConfig): BootnodeConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqresp-nodes.d.ts","sourceRoot":"","sources":["../../src/test-helpers/reqresp-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,K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ACxB,aAAY,OAAO,CAAC,4BAA4B,CAAM,KACrD,OAAO,CAAC,WAAW,CAQrB,CAAC;AAGF,eAAO,MAAM,cAAc,GAAU,OAAO,WAAW,EAAE,KAAG,OAAO,CAAC,IAAI,CAUvE,CAAC;AAGF,qBAAa,yBAA0B,YAAW,6BAA6B;IAC7E,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAGrB,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGvC;AACD,qBAAa,0BAA2B,YAAW,6BAA6B;IAC9E,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAGrB,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGvC;AAGD,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,cAAc,CAWpH;AAED,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,eAAsC,EACjD,WAAW,GAAE,WAA8B,GAC1C,OAAO,CAAC,aAAa,CAAC,CAGxB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAOzE;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,eAAsC,EACjD,WAAW,GAAE,WAA8B,GAC1C,OAAO,CAAC,aAAa,CAAC,CAKxB"}
|
|
@@ -154,11 +154,17 @@ export const connectToPeers = async (nodes)=>{
|
|
|
154
154
|
};
|
|
155
155
|
// Mock circuit verifier for testing - reimplementation from bb to avoid dependency
|
|
156
156
|
export class AlwaysTrueCircuitVerifier {
|
|
157
|
+
stop() {
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
}
|
|
157
160
|
verifyProof(_tx) {
|
|
158
161
|
return Promise.resolve(true);
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
export class AlwaysFalseCircuitVerifier {
|
|
165
|
+
stop() {
|
|
166
|
+
return Promise.resolve();
|
|
167
|
+
}
|
|
162
168
|
verifyProof(_tx) {
|
|
163
169
|
return Promise.resolve(false);
|
|
164
170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.87.
|
|
3
|
+
"version": "0.87.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -63,16 +63,16 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@aztec/constants": "0.87.
|
|
67
|
-
"@aztec/epoch-cache": "0.87.
|
|
68
|
-
"@aztec/foundation": "0.87.
|
|
69
|
-
"@aztec/kv-store": "0.87.
|
|
70
|
-
"@aztec/noir-contracts.js": "0.87.
|
|
71
|
-
"@aztec/noir-protocol-circuits-types": "0.87.
|
|
72
|
-
"@aztec/protocol-contracts": "0.87.
|
|
73
|
-
"@aztec/simulator": "0.87.
|
|
74
|
-
"@aztec/stdlib": "0.87.
|
|
75
|
-
"@aztec/telemetry-client": "0.87.
|
|
66
|
+
"@aztec/constants": "0.87.8",
|
|
67
|
+
"@aztec/epoch-cache": "0.87.8",
|
|
68
|
+
"@aztec/foundation": "0.87.8",
|
|
69
|
+
"@aztec/kv-store": "0.87.8",
|
|
70
|
+
"@aztec/noir-contracts.js": "0.87.8",
|
|
71
|
+
"@aztec/noir-protocol-circuits-types": "0.87.8",
|
|
72
|
+
"@aztec/protocol-contracts": "0.87.8",
|
|
73
|
+
"@aztec/simulator": "0.87.8",
|
|
74
|
+
"@aztec/stdlib": "0.87.8",
|
|
75
|
+
"@aztec/telemetry-client": "0.87.8",
|
|
76
76
|
"@chainsafe/discv5": "9.0.0",
|
|
77
77
|
"@chainsafe/enr": "3.0.0",
|
|
78
78
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"xxhash-wasm": "^1.1.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@aztec/archiver": "0.87.
|
|
104
|
+
"@aztec/archiver": "0.87.8",
|
|
105
105
|
"@jest/globals": "^29.5.0",
|
|
106
106
|
"@types/jest": "^29.5.0",
|
|
107
107
|
"@types/node": "^22.15.17",
|
package/src/client/interface.ts
CHANGED
|
@@ -78,7 +78,7 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
|
|
|
78
78
|
* Adds transactions to the pool. Does not send to peers or validate the tx.
|
|
79
79
|
* @param txs - The transactions.
|
|
80
80
|
**/
|
|
81
|
-
|
|
81
|
+
addTxsToPool(txs: Tx[]): Promise<void>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Deletes 'txs' from the pool, given hashes.
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -444,7 +444,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
444
444
|
/**
|
|
445
445
|
* Returns transactions in the transaction pool by hash.
|
|
446
446
|
* @param txHashes - Hashes of the transactions to look for.
|
|
447
|
-
* @returns The txs found,
|
|
447
|
+
* @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
|
|
448
448
|
*/
|
|
449
449
|
getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
450
450
|
return this.txPool.getTxsByHash(txHashes);
|
|
@@ -527,7 +527,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
527
527
|
* @returns Empty promise.
|
|
528
528
|
**/
|
|
529
529
|
public async sendTx(tx: Tx): Promise<void> {
|
|
530
|
-
await this.
|
|
530
|
+
await this.addTxsToPool([tx]);
|
|
531
531
|
await this.p2pService.propagate(tx);
|
|
532
532
|
}
|
|
533
533
|
|
|
@@ -535,7 +535,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
535
535
|
* Adds transactions to the pool. Does not send to peers or validate the txs.
|
|
536
536
|
* @param txs - The transactions.
|
|
537
537
|
**/
|
|
538
|
-
public async
|
|
538
|
+
public async addTxsToPool(txs: Tx[]): Promise<void> {
|
|
539
539
|
this.#assertIsReady();
|
|
540
540
|
await this.txPool.addTxs(txs);
|
|
541
541
|
}
|
|
@@ -49,9 +49,6 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
49
49
|
|
|
50
50
|
await ap.addAttestations(attestations);
|
|
51
51
|
|
|
52
|
-
// Check metrics have been updated.
|
|
53
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
54
|
-
|
|
55
52
|
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
56
53
|
expect(retrievedAttestations.length).toBe(attestations.length);
|
|
57
54
|
compareAttestations(retrievedAttestations, attestations);
|
|
@@ -63,7 +60,6 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
63
60
|
// Add another one
|
|
64
61
|
const newAttestation = mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
|
|
65
62
|
await ap.addAttestations([newAttestation]);
|
|
66
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(1);
|
|
67
63
|
const retrievedAttestationsAfterAdd = await ap.getAttestationsForSlotAndProposal(
|
|
68
64
|
BigInt(slotNumber),
|
|
69
65
|
archive.toString(),
|
|
@@ -76,7 +72,6 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
76
72
|
|
|
77
73
|
// Delete by slot
|
|
78
74
|
await ap.deleteAttestationsForSlot(BigInt(slotNumber));
|
|
79
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length + 1);
|
|
80
75
|
|
|
81
76
|
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(
|
|
82
77
|
BigInt(slotNumber),
|
|
@@ -154,16 +149,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
154
149
|
|
|
155
150
|
await ap.addAttestations(attestations);
|
|
156
151
|
|
|
157
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
158
|
-
|
|
159
152
|
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
160
153
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
161
154
|
compareAttestations(retreivedAttestations, attestations);
|
|
162
155
|
|
|
163
156
|
await ap.deleteAttestations(attestations);
|
|
164
157
|
|
|
165
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length);
|
|
166
|
-
|
|
167
158
|
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
168
159
|
expect(gottenAfterDelete.length).toBe(0);
|
|
169
160
|
});
|
|
@@ -200,17 +191,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
200
191
|
await ap.addAttestations(attestations);
|
|
201
192
|
await ap.addAttestations(attestations2);
|
|
202
193
|
|
|
203
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
204
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations2.length);
|
|
205
|
-
|
|
206
194
|
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
207
195
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
208
196
|
compareAttestations(retreivedAttestations, attestations);
|
|
209
197
|
|
|
210
198
|
await ap.deleteAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
211
199
|
|
|
212
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length);
|
|
213
|
-
|
|
214
200
|
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
215
201
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
216
202
|
|