@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
|
@@ -66,7 +66,7 @@ export type P2P<T extends P2PClientType = P2PClientType.Full> = P2PApi<T> & {
|
|
|
66
66
|
* Adds transactions to the pool. Does not send to peers or validate the tx.
|
|
67
67
|
* @param txs - The transactions.
|
|
68
68
|
**/
|
|
69
|
-
|
|
69
|
+
addTxsToPool(txs: Tx[]): Promise<void>;
|
|
70
70
|
/**
|
|
71
71
|
* Deletes 'txs' from the pool, given hashes.
|
|
72
72
|
* NOT used if we use sendTx as reconcileTxPool will handle this.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/client/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AA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BAAiB,IAAI,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAE/C,wDAAwD;IACxD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAErC;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEnC;;OAEG;IACH,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC;IAE1B,+BAA+B;IAC/B,WAAW,IAAI,IAAI,CAAC;IAEpB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,8BAA8B;IAC9B,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC,qBAAqB;IACrB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
|
|
@@ -103,7 +103,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
103
103
|
/**
|
|
104
104
|
* Returns transactions in the transaction pool by hash.
|
|
105
105
|
* @param txHashes - Hashes of the transactions to look for.
|
|
106
|
-
* @returns The txs found,
|
|
106
|
+
* @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
|
|
107
107
|
*/
|
|
108
108
|
getTxsByHashFromPool(txHashes: TxHash[]): Promise<(Tx | undefined)[]>;
|
|
109
109
|
hasTxsInPool(txHashes: TxHash[]): Promise<boolean[]>;
|
|
@@ -137,7 +137,7 @@ export declare class P2PClient<T extends P2PClientType = P2PClientType.Full> ext
|
|
|
137
137
|
* Adds transactions to the pool. Does not send to peers or validate the txs.
|
|
138
138
|
* @param txs - The transactions.
|
|
139
139
|
**/
|
|
140
|
-
|
|
140
|
+
addTxsToPool(txs: Tx[]): Promise<void>;
|
|
141
141
|
/**
|
|
142
142
|
* Returns whether the given tx hash is flagged as pending or mined.
|
|
143
143
|
* @param txHash - Hash of the tx to query.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p_client.d.ts","sourceRoot":"","sources":["../../src/client/p2p_client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAsC,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAGV,aAAa,EAEb,kBAAkB,EAClB,MAAM,EAEP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAEL,KAAK,eAAe,EAEpB,UAAU,EAGX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,KAAK,GAAG,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;GAEG;AACH,qBAAa,SAAS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
344
|
* Returns transactions in the transaction pool by hash.
|
|
345
345
|
* @param txHashes - Hashes of the transactions to look for.
|
|
346
|
-
* @returns The txs found,
|
|
346
|
+
* @returns The txs found, in the same order as the requested hashes. If a tx is not found, it will be undefined.
|
|
347
347
|
*/ getTxsByHashFromPool(txHashes) {
|
|
348
348
|
return this.txPool.getTxsByHash(txHashes);
|
|
349
349
|
}
|
|
@@ -410,7 +410,7 @@ import { P2PClientState } from './interface.js';
|
|
|
410
410
|
* @param tx - The tx to verify.
|
|
411
411
|
* @returns Empty promise.
|
|
412
412
|
**/ async sendTx(tx) {
|
|
413
|
-
await this.
|
|
413
|
+
await this.addTxsToPool([
|
|
414
414
|
tx
|
|
415
415
|
]);
|
|
416
416
|
await this.p2pService.propagate(tx);
|
|
@@ -418,7 +418,7 @@ import { P2PClientState } from './interface.js';
|
|
|
418
418
|
/**
|
|
419
419
|
* Adds transactions to the pool. Does not send to peers or validate the txs.
|
|
420
420
|
* @param txs - The transactions.
|
|
421
|
-
**/ async
|
|
421
|
+
**/ async addTxsToPool(txs) {
|
|
422
422
|
this.#assertIsReady();
|
|
423
423
|
await this.txPool.addTxs(txs);
|
|
424
424
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,eAAe,QA8NhF"}
|
|
@@ -36,8 +36,6 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
36
36
|
const archive = Fr.random();
|
|
37
37
|
const attestations = signers.slice(0, -1).map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
38
38
|
await ap.addAttestations(attestations);
|
|
39
|
-
// Check metrics have been updated.
|
|
40
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
41
39
|
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
42
40
|
expect(retrievedAttestations.length).toBe(attestations.length);
|
|
43
41
|
compareAttestations(retrievedAttestations, attestations);
|
|
@@ -49,7 +47,6 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
49
47
|
await ap.addAttestations([
|
|
50
48
|
newAttestation
|
|
51
49
|
]);
|
|
52
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(1);
|
|
53
50
|
const retrievedAttestationsAfterAdd = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
54
51
|
expect(retrievedAttestationsAfterAdd.length).toBe(attestations.length + 1);
|
|
55
52
|
compareAttestations(retrievedAttestationsAfterAdd, [
|
|
@@ -64,7 +61,6 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
64
61
|
]);
|
|
65
62
|
// Delete by slot
|
|
66
63
|
await ap.deleteAttestationsForSlot(BigInt(slotNumber));
|
|
67
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length + 1);
|
|
68
64
|
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
69
65
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
70
66
|
});
|
|
@@ -146,12 +142,10 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
146
142
|
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
147
143
|
const proposalId = attestations[0].archive.toString();
|
|
148
144
|
await ap.addAttestations(attestations);
|
|
149
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
150
145
|
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
151
146
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
152
147
|
compareAttestations(retreivedAttestations, attestations);
|
|
153
148
|
await ap.deleteAttestations(attestations);
|
|
154
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length);
|
|
155
149
|
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
156
150
|
expect(gottenAfterDelete.length).toBe(0);
|
|
157
151
|
});
|
|
@@ -179,13 +173,10 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
179
173
|
const proposalId2 = attestations2[0].archive.toString();
|
|
180
174
|
await ap.addAttestations(attestations);
|
|
181
175
|
await ap.addAttestations(attestations2);
|
|
182
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations.length);
|
|
183
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations2.length);
|
|
184
176
|
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
185
177
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
186
178
|
compareAttestations(retreivedAttestations, attestations);
|
|
187
179
|
await ap.deleteAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
188
|
-
expect(metricsMock.recordRemovedObjects).toHaveBeenCalledWith(attestations.length);
|
|
189
180
|
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
190
181
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
191
182
|
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId2);
|
|
@@ -10,6 +10,7 @@ export declare class KvAttestationPool implements AttestationPool {
|
|
|
10
10
|
private proposalsForSlot;
|
|
11
11
|
private attestationsForProposal;
|
|
12
12
|
constructor(store: AztecAsyncKVStore, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
13
|
+
private poolStats;
|
|
13
14
|
isEmpty(): Promise<boolean>;
|
|
14
15
|
private getProposalKey;
|
|
15
16
|
private getAttestationKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,eAAe;IAQrD,OAAO,CAAC,KAAK;IAEb,OAAO,CAAC,GAAG;IATb,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,uBAAuB,CAAqC;gBAG1D,KAAK,EAAE,iBAAiB,EAChC,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAyC;
|
|
1
|
+
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,eAAe;IAQrD,OAAO,CAAC,KAAK;IAEb,OAAO,CAAC,GAAG;IATb,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,uBAAuB,CAAqC;gBAG1D,KAAK,EAAE,iBAAiB,EAChC,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAyC;IAStD,OAAO,CAAC,SAAS,CAIf;IAEW,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAOxC,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,iBAAiB;IAIZ,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBhE,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAsBhG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBrF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBjF"}
|
|
@@ -14,11 +14,17 @@ export class KvAttestationPool {
|
|
|
14
14
|
constructor(store, telemetry = getTelemetryClient(), log = createLogger('aztec:attestation_pool')){
|
|
15
15
|
this.store = store;
|
|
16
16
|
this.log = log;
|
|
17
|
+
this.poolStats = async ()=>{
|
|
18
|
+
return {
|
|
19
|
+
itemCount: await this.attestations.sizeAsync()
|
|
20
|
+
};
|
|
21
|
+
};
|
|
17
22
|
this.attestations = store.openMap('attestations');
|
|
18
23
|
this.proposalsForSlot = store.openMultiMap('proposals_for_slot');
|
|
19
24
|
this.attestationsForProposal = store.openMultiMap('attestations_for_proposal');
|
|
20
|
-
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
|
|
25
|
+
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL, this.poolStats);
|
|
21
26
|
}
|
|
27
|
+
poolStats;
|
|
22
28
|
async isEmpty() {
|
|
23
29
|
for await (const _ of this.attestations.entriesAsync()){
|
|
24
30
|
return false;
|
|
@@ -50,7 +56,6 @@ export class KvAttestationPool {
|
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
});
|
|
53
|
-
this.metrics.recordAddedObjects(attestations.length);
|
|
54
59
|
}
|
|
55
60
|
async getAttestationsForSlot(slot) {
|
|
56
61
|
const slotFr = new Fr(slot);
|
|
@@ -97,9 +102,8 @@ export class KvAttestationPool {
|
|
|
97
102
|
}
|
|
98
103
|
await this.attestationsForProposal.delete(this.getProposalKey(slotFr, proposalId));
|
|
99
104
|
}
|
|
105
|
+
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
100
106
|
});
|
|
101
|
-
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
102
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
103
107
|
}
|
|
104
108
|
async deleteAttestationsForSlotAndProposal(slot, proposalId) {
|
|
105
109
|
let numberOfAttestations = 0;
|
|
@@ -112,9 +116,8 @@ export class KvAttestationPool {
|
|
|
112
116
|
}
|
|
113
117
|
await this.proposalsForSlot.deleteValue(slotString, proposalId);
|
|
114
118
|
await this.attestationsForProposal.delete(this.getProposalKey(slotString, proposalId));
|
|
119
|
+
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
115
120
|
});
|
|
116
|
-
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
117
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
118
121
|
}
|
|
119
122
|
async deleteAttestations(attestations) {
|
|
120
123
|
await this.store.transactionAsync(async ()=>{
|
|
@@ -122,11 +125,13 @@ export class KvAttestationPool {
|
|
|
122
125
|
const slotNumber = attestation.payload.header.slotNumber;
|
|
123
126
|
const proposalId = attestation.archive;
|
|
124
127
|
const address = attestation.getSender().toString();
|
|
125
|
-
|
|
128
|
+
const key = this.getAttestationKey(slotNumber, proposalId, address);
|
|
129
|
+
if (await this.attestations.hasAsync(key)) {
|
|
130
|
+
await this.attestations.delete(key);
|
|
131
|
+
}
|
|
126
132
|
await this.attestationsForProposal.deleteValue(this.getProposalKey(slotNumber, proposalId), this.getAttestationKey(slotNumber, proposalId, address));
|
|
127
133
|
this.log.debug(`Deleted attestation for slot ${slotNumber} from ${address}`);
|
|
128
134
|
}
|
|
129
135
|
});
|
|
130
|
-
this.metrics.recordRemovedObjects(attestations.length);
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -7,6 +7,7 @@ export declare class InMemoryAttestationPool implements AttestationPool {
|
|
|
7
7
|
private metrics;
|
|
8
8
|
private attestations;
|
|
9
9
|
constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
10
|
+
private poolStats;
|
|
10
11
|
isEmpty(): Promise<boolean>;
|
|
11
12
|
getAttestationsForSlot(slot: bigint): Promise<BlockAttestation[]>;
|
|
12
13
|
getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/memory_attestation_pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAA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E,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcrF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB3E"}
|
|
@@ -7,9 +7,15 @@ export class InMemoryAttestationPool {
|
|
|
7
7
|
attestations;
|
|
8
8
|
constructor(telemetry = getTelemetryClient(), log = createLogger('p2p:attestation_pool')){
|
|
9
9
|
this.log = log;
|
|
10
|
+
this.poolStats = ()=>{
|
|
11
|
+
return Promise.resolve({
|
|
12
|
+
itemCount: this.attestations.size
|
|
13
|
+
});
|
|
14
|
+
};
|
|
10
15
|
this.attestations = new Map();
|
|
11
|
-
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
|
|
16
|
+
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL, this.poolStats);
|
|
12
17
|
}
|
|
18
|
+
poolStats;
|
|
13
19
|
isEmpty() {
|
|
14
20
|
return Promise.resolve(this.attestations.size === 0);
|
|
15
21
|
}
|
|
@@ -42,8 +48,6 @@ export class InMemoryAttestationPool {
|
|
|
42
48
|
proposalId
|
|
43
49
|
});
|
|
44
50
|
}
|
|
45
|
-
// TODO: set these to pending or something ????
|
|
46
|
-
this.metrics.recordAddedObjects(attestations.length);
|
|
47
51
|
return Promise.resolve();
|
|
48
52
|
}
|
|
49
53
|
#getNumberOfAttestationsInSlot(slot) {
|
|
@@ -79,7 +83,6 @@ export class InMemoryAttestationPool {
|
|
|
79
83
|
const numberOfAttestations = this.#getNumberOfAttestationsInSlot(slot);
|
|
80
84
|
this.attestations.delete(slot);
|
|
81
85
|
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
82
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
83
86
|
return Promise.resolve();
|
|
84
87
|
}
|
|
85
88
|
deleteAttestationsForSlotAndProposal(slot, proposalId) {
|
|
@@ -89,7 +92,6 @@ export class InMemoryAttestationPool {
|
|
|
89
92
|
const numberOfAttestations = slotAttestationMap.get(proposalId)?.size ?? 0;
|
|
90
93
|
slotAttestationMap.delete(proposalId);
|
|
91
94
|
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
92
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
return Promise.resolve();
|
|
@@ -108,7 +110,6 @@ export class InMemoryAttestationPool {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
this.metrics.recordRemovedObjects(attestations.length);
|
|
112
113
|
return Promise.resolve();
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -4,27 +4,23 @@ export declare enum PoolName {
|
|
|
4
4
|
TX_POOL = "TxPool",
|
|
5
5
|
ATTESTATION_POOL = "AttestationPool"
|
|
6
6
|
}
|
|
7
|
+
export type PoolStatsCallback = () => Promise<{
|
|
8
|
+
itemCount: number | Record<string, number>;
|
|
9
|
+
}>;
|
|
7
10
|
/**
|
|
8
11
|
* Instrumentation class for the Pools (TxPool, AttestationPool, etc).
|
|
9
12
|
*/
|
|
10
13
|
export declare class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
14
|
+
private poolStats;
|
|
11
15
|
/** The number of txs in the mempool */
|
|
12
16
|
private objectsInMempool;
|
|
13
17
|
/** Tracks tx size */
|
|
14
18
|
private objectSize;
|
|
15
19
|
private dbMetrics;
|
|
16
20
|
private defaultAttributes;
|
|
17
|
-
|
|
21
|
+
private meter;
|
|
22
|
+
constructor(telemetry: TelemetryClient, name: PoolName, poolStats: PoolStatsCallback, dbStats?: LmdbStatsCallback);
|
|
18
23
|
recordSize(poolObject: PoolObject): void;
|
|
19
|
-
|
|
20
|
-
* Updates the metrics with the new objects.
|
|
21
|
-
* @param txs - The objects to record
|
|
22
|
-
*/
|
|
23
|
-
recordAddedObjects(count?: number, status?: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Updates the metrics by removing objects from the mempool.
|
|
26
|
-
* @param count - The number of objects to remove from the mempool
|
|
27
|
-
*/
|
|
28
|
-
recordRemovedObjects(count?: number, status?: string): void;
|
|
24
|
+
private observeStats;
|
|
29
25
|
}
|
|
30
26
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAKtB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,QAAQ;IAClB,OAAO,WAAW;IAClB,gBAAgB,oBAAoB;CACrC;AA4BD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC;IAC5C,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC,CAAC;AAEH;;GAEG;AACH,qBAAa,mBAAmB,CAAC,UAAU,SAAS,UAAU;IAc1D,OAAO,CAAC,SAAS;IAbnB,uCAAuC;IACvC,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,qBAAqB;IACrB,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,SAAS,CAAc;IAE/B,OAAO,CAAC,iBAAiB,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAQ;gBAGnB,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,QAAQ,EACN,SAAS,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,iBAAiB;IA2BtB,UAAU,CAAC,UAAU,EAAE,UAAU;IAIxC,OAAO,CAAC,YAAY,CAYlB;CACH"}
|
|
@@ -25,60 +25,48 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Instrumentation class for the Pools (TxPool, AttestationPool, etc).
|
|
27
27
|
*/ export class PoolInstrumentation {
|
|
28
|
+
poolStats;
|
|
28
29
|
/** The number of txs in the mempool */ objectsInMempool;
|
|
29
30
|
/** Tracks tx size */ objectSize;
|
|
30
31
|
dbMetrics;
|
|
31
32
|
defaultAttributes;
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
meter;
|
|
34
|
+
constructor(telemetry, name, poolStats, dbStats){
|
|
35
|
+
this.poolStats = poolStats;
|
|
36
|
+
this.observeStats = async (observer)=>{
|
|
37
|
+
const { itemCount } = await this.poolStats();
|
|
38
|
+
if (typeof itemCount === 'number') {
|
|
39
|
+
observer.observe(this.objectsInMempool, itemCount, this.defaultAttributes);
|
|
40
|
+
} else {
|
|
41
|
+
for (const [status, count] of Object.entries(itemCount)){
|
|
42
|
+
observer.observe(this.objectsInMempool, count, {
|
|
43
|
+
...this.defaultAttributes,
|
|
44
|
+
[Attributes.STATUS]: status
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.meter = telemetry.getMeter(name);
|
|
34
50
|
this.defaultAttributes = {
|
|
35
51
|
[Attributes.POOL_NAME]: name
|
|
36
52
|
};
|
|
37
53
|
const metricsLabels = getMetricsLabels(name);
|
|
38
|
-
this.objectsInMempool = meter.
|
|
54
|
+
this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool, {
|
|
39
55
|
description: 'The current number of transactions in the mempool'
|
|
40
56
|
});
|
|
41
|
-
this.objectSize = meter.createHistogram(metricsLabels.objectSize, {
|
|
57
|
+
this.objectSize = this.meter.createHistogram(metricsLabels.objectSize, {
|
|
42
58
|
unit: 'By',
|
|
43
59
|
description: 'The size of transactions in the mempool'
|
|
44
60
|
});
|
|
45
|
-
this.dbMetrics = new LmdbMetrics(meter, {
|
|
61
|
+
this.dbMetrics = new LmdbMetrics(this.meter, {
|
|
46
62
|
[Attributes.DB_DATA_TYPE]: 'tx-pool'
|
|
47
63
|
}, dbStats);
|
|
64
|
+
this.meter.addBatchObservableCallback(this.observeStats, [
|
|
65
|
+
this.objectsInMempool
|
|
66
|
+
]);
|
|
48
67
|
}
|
|
49
68
|
recordSize(poolObject) {
|
|
50
69
|
this.objectSize.record(poolObject.getSize());
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
* Updates the metrics with the new objects.
|
|
54
|
-
* @param txs - The objects to record
|
|
55
|
-
*/ recordAddedObjects(count = 1, status) {
|
|
56
|
-
if (count < 0) {
|
|
57
|
-
throw new Error('Count must be positive');
|
|
58
|
-
}
|
|
59
|
-
if (count === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const attributes = status ? {
|
|
63
|
-
...this.defaultAttributes,
|
|
64
|
-
[Attributes.STATUS]: status
|
|
65
|
-
} : this.defaultAttributes;
|
|
66
|
-
this.objectsInMempool.add(count, attributes);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Updates the metrics by removing objects from the mempool.
|
|
70
|
-
* @param count - The number of objects to remove from the mempool
|
|
71
|
-
*/ recordRemovedObjects(count = 1, status) {
|
|
72
|
-
if (count < 0) {
|
|
73
|
-
throw new Error('Count must be positive');
|
|
74
|
-
}
|
|
75
|
-
if (count === 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const attributes = status ? {
|
|
79
|
-
...this.defaultAttributes,
|
|
80
|
-
[Attributes.STATUS]: status
|
|
81
|
-
} : this.defaultAttributes;
|
|
82
|
-
this.objectsInMempool.add(-1 * count, attributes);
|
|
83
|
-
}
|
|
71
|
+
observeStats;
|
|
84
72
|
}
|
|
@@ -22,12 +22,14 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
22
22
|
* @param log - A logger.
|
|
23
23
|
*/
|
|
24
24
|
constructor(store: AztecAsyncKVStore, archive: AztecAsyncKVStore, worldStateSynchronizer: WorldStateSynchronizer, telemetry?: TelemetryClient, config?: TxPoolOptions, log?: Logger);
|
|
25
|
+
private countTxs;
|
|
25
26
|
isEmpty(): Promise<boolean>;
|
|
26
27
|
markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
|
|
27
28
|
markMinedAsPending(txHashes: TxHash[]): Promise<void>;
|
|
28
29
|
getPendingTxHashes(): Promise<TxHash[]>;
|
|
29
30
|
getMinedTxHashes(): Promise<[TxHash, number][]>;
|
|
30
31
|
getPendingTxCount(): Promise<number>;
|
|
32
|
+
getMinedTxCount(): Promise<number>;
|
|
31
33
|
getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
|
|
32
34
|
/**
|
|
33
35
|
* Checks if a transaction exists in the pool and returns it.
|
|
@@ -121,6 +123,5 @@ export declare class AztecKVTxPool implements TxPool {
|
|
|
121
123
|
private evictInvalidTxsAfterReorg;
|
|
122
124
|
private addPendingTxIndices;
|
|
123
125
|
private removePendingTxIndices;
|
|
124
|
-
private increasePendingTxCount;
|
|
125
126
|
}
|
|
126
127
|
//# sourceMappingURL=aztec_kv_tx_pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAA0D,MAAM,iBAAiB,CAAC;AAGjH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAIxG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB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,EAAE,aAAa,GAAG,IAAI;IAwB3F,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D;;;;OAIG;IACH,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,wBAAwB,GAAG,cAAc;IAI5E;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,wBAAwB,GAAG,YAAY;IAIxE;;;;;OAKG;YACW,kBAAkB;IAoBhC;;;;OAIG;YACW,UAAU;IA4BxB;;;;;;OAMG;YACW,mBAAmB;IA8CjC;;;;;;;;;;OAUG;YACW,0BAA0B;IAwDxC;;;;;OAKG;YACW,yBAAyB;YAqCzB,mBAAmB;YAMnB,sBAAsB;CAMrC"}
|
|
@@ -24,7 +24,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
24
24
|
/** Index from tx hash to its tx size (in bytes), filtered by pending txs. */ #pendingTxHashToSize;
|
|
25
25
|
/** Index from tx hash to its header hash, filtered by pending txs. */ #pendingTxHashToHeaderHash;
|
|
26
26
|
/** The cumulative tx size in bytes that the pending txs in the pool take up. */ #pendingTxSize;
|
|
27
|
-
/** Count of total pending txs. */ #pendingTxCount;
|
|
28
27
|
/** In-memory mapping of pending tx hashes to the hydrated pending tx in the pool. */ #pendingTxs;
|
|
29
28
|
/** In-memory set of txs that should not be evicted from the pool. */ #nonEvictableTxs;
|
|
30
29
|
/** KV store for archived txs. */ #archive;
|
|
@@ -50,7 +49,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
50
49
|
this.#pendingTxHashToSize = store.openMap('pendingTxHashToSize');
|
|
51
50
|
this.#pendingTxHashToHeaderHash = store.openMap('pendingTxHashToHeaderHash');
|
|
52
51
|
this.#pendingTxSize = store.openSingleton('pendingTxSize');
|
|
53
|
-
this.#pendingTxCount = store.openSingleton('pendingTxCount');
|
|
54
52
|
this.#pendingTxs = new Map();
|
|
55
53
|
this.#nonEvictableTxs = new Set();
|
|
56
54
|
this.#archivedTxs = archive.openMap('archivedTxs');
|
|
@@ -58,8 +56,20 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
58
56
|
this.#store = store;
|
|
59
57
|
this.#archive = archive;
|
|
60
58
|
this.#worldStateSynchronizer = worldStateSynchronizer;
|
|
61
|
-
this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, ()=>store.estimateSize());
|
|
59
|
+
this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, this.countTxs, ()=>store.estimateSize());
|
|
62
60
|
}
|
|
61
|
+
countTxs = async ()=>{
|
|
62
|
+
const [pending = 0, mined = 0] = await Promise.all([
|
|
63
|
+
this.getPendingTxCount(),
|
|
64
|
+
this.getMinedTxCount()
|
|
65
|
+
]);
|
|
66
|
+
return Promise.resolve({
|
|
67
|
+
itemCount: {
|
|
68
|
+
pending,
|
|
69
|
+
mined
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
63
73
|
async isEmpty() {
|
|
64
74
|
for await (const _ of this.#txs.entriesAsync()){
|
|
65
75
|
return false;
|
|
@@ -70,7 +80,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
70
80
|
if (txHashes.length === 0) {
|
|
71
81
|
return Promise.resolve();
|
|
72
82
|
}
|
|
73
|
-
let deletedPending = 0;
|
|
74
83
|
const minedNullifiers = new Set();
|
|
75
84
|
const minedFeePayers = new Set();
|
|
76
85
|
await this.#store.transactionAsync(async ()=>{
|
|
@@ -83,16 +92,12 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
83
92
|
const nullifiers = tx.data.getNonEmptyNullifiers();
|
|
84
93
|
nullifiers.forEach((nullifier)=>minedNullifiers.add(nullifier.toString()));
|
|
85
94
|
minedFeePayers.add(tx.data.feePayer.toString());
|
|
86
|
-
deletedPending++;
|
|
87
95
|
pendingTxSize -= tx.getSize();
|
|
88
96
|
await this.removePendingTxIndices(tx, key);
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
this.#metrics.recordAddedObjects(txHashes.length, 'mined');
|
|
92
99
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
93
|
-
await this.
|
|
94
|
-
const numTxsEvicted = await this.evictInvalidTxsAfterMining(txHashes, blockNumber, minedNullifiers, minedFeePayers);
|
|
95
|
-
this.#metrics.recordRemovedObjects(deletedPending + numTxsEvicted, 'pending');
|
|
100
|
+
await this.evictInvalidTxsAfterMining(txHashes, blockNumber, minedNullifiers, minedFeePayers);
|
|
96
101
|
});
|
|
97
102
|
// We update this after the transaction above. This ensures that the non-evictable transactions are not evicted
|
|
98
103
|
// until any that have been mined are marked as such.
|
|
@@ -103,7 +108,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
103
108
|
if (txHashes.length === 0) {
|
|
104
109
|
return Promise.resolve();
|
|
105
110
|
}
|
|
106
|
-
let markedAsPending = 0;
|
|
107
111
|
await this.#store.transactionAsync(async ()=>{
|
|
108
112
|
let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
|
|
109
113
|
for (const hash of txHashes){
|
|
@@ -114,17 +118,12 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
114
118
|
if (tx) {
|
|
115
119
|
await this.addPendingTxIndices(tx, key);
|
|
116
120
|
pendingTxSize += tx.getSize();
|
|
117
|
-
markedAsPending++;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
121
124
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
await this.increasePendingTxCount(markedAsPending);
|
|
125
|
-
this.#metrics.recordAddedObjects(markedAsPending - numNewTxsEvicted, 'pending');
|
|
126
|
-
this.#metrics.recordRemovedObjects(numInvalidTxsEvicted + numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
|
|
127
|
-
this.#metrics.recordRemovedObjects(markedAsPending, 'mined');
|
|
125
|
+
await this.evictInvalidTxsAfterReorg(txHashes);
|
|
126
|
+
await this.evictLowPriorityTxs(txHashes);
|
|
128
127
|
}
|
|
129
128
|
async getPendingTxHashes() {
|
|
130
129
|
const vals = await toArray(this.#pendingTxPriorityToHash.valuesAsync({
|
|
@@ -140,7 +139,10 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
140
139
|
]);
|
|
141
140
|
}
|
|
142
141
|
async getPendingTxCount() {
|
|
143
|
-
return await this.#
|
|
142
|
+
return await this.#pendingTxHashToHeaderHash.sizeAsync() ?? 0;
|
|
143
|
+
}
|
|
144
|
+
async getMinedTxCount() {
|
|
145
|
+
return await this.#minedTxHashToBlock.sizeAsync() ?? 0;
|
|
144
146
|
}
|
|
145
147
|
async getTxStatus(txHash) {
|
|
146
148
|
const key = txHash.toString();
|
|
@@ -206,7 +208,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
206
208
|
txStats: await tx.getStats()
|
|
207
209
|
})));
|
|
208
210
|
await this.#store.transactionAsync(async ()=>{
|
|
209
|
-
let addedCount = 0;
|
|
210
211
|
let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
|
|
211
212
|
await Promise.all(txs.map(async (tx, i)=>{
|
|
212
213
|
const { txHash, txStats } = hashesAndStats[i];
|
|
@@ -221,17 +222,13 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
221
222
|
});
|
|
222
223
|
await this.#txs.set(key, tx.toBuffer());
|
|
223
224
|
if (!await this.#minedTxHashToBlock.hasAsync(key)) {
|
|
224
|
-
addedCount++;
|
|
225
225
|
pendingTxSize += tx.getSize();
|
|
226
226
|
await this.addPendingTxIndices(tx, key);
|
|
227
227
|
this.#metrics.recordSize(tx);
|
|
228
228
|
}
|
|
229
229
|
}));
|
|
230
|
-
await this.increasePendingTxCount(addedCount);
|
|
231
230
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
232
|
-
|
|
233
|
-
this.#metrics.recordAddedObjects(addedCount - numNewTxsEvicted, 'pending');
|
|
234
|
-
this.#metrics.recordRemovedObjects(numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
|
|
231
|
+
await this.evictLowPriorityTxs(hashesAndStats.map(({ txHash })=>txHash));
|
|
235
232
|
});
|
|
236
233
|
}
|
|
237
234
|
/**
|
|
@@ -239,8 +236,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
239
236
|
* @param txHashes - An array of tx hashes to be removed from the tx pool.
|
|
240
237
|
* @returns Empty promise.
|
|
241
238
|
*/ deleteTxs(txHashes, eviction = false) {
|
|
242
|
-
let pendingDeleted = 0;
|
|
243
|
-
let minedDeleted = 0;
|
|
244
239
|
const deletedTxs = [];
|
|
245
240
|
const poolDbTx = this.#store.transactionAsync(async ()=>{
|
|
246
241
|
let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
|
|
@@ -249,10 +244,7 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
249
244
|
const tx = await this.getTxByHash(hash);
|
|
250
245
|
if (tx) {
|
|
251
246
|
const isMined = await this.#minedTxHashToBlock.hasAsync(key);
|
|
252
|
-
if (isMined) {
|
|
253
|
-
minedDeleted++;
|
|
254
|
-
} else {
|
|
255
|
-
pendingDeleted++;
|
|
247
|
+
if (!isMined) {
|
|
256
248
|
pendingTxSize -= tx.getSize();
|
|
257
249
|
await this.removePendingTxIndices(tx, key);
|
|
258
250
|
}
|
|
@@ -264,9 +256,6 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
264
256
|
}
|
|
265
257
|
}
|
|
266
258
|
await this.#pendingTxSize.set(pendingTxSize);
|
|
267
|
-
await this.increasePendingTxCount(-pendingDeleted);
|
|
268
|
-
this.#metrics.recordRemovedObjects(pendingDeleted, 'pending');
|
|
269
|
-
this.#metrics.recordRemovedObjects(minedDeleted, 'mined');
|
|
270
259
|
});
|
|
271
260
|
return this.#archivedTxLimit ? poolDbTx.then(()=>this.archiveTxs(deletedTxs)) : poolDbTx;
|
|
272
261
|
}
|
|
@@ -529,9 +518,4 @@ import { getPendingTxPriority } from './priority.js';
|
|
|
529
518
|
await this.#pendingTxHashToHeaderHash.delete(txHash);
|
|
530
519
|
this.#pendingTxs.delete(txHash);
|
|
531
520
|
}
|
|
532
|
-
async increasePendingTxCount(count) {
|
|
533
|
-
const pendingTxCount = await this.#pendingTxCount.getAsync() ?? 0;
|
|
534
|
-
this.#log.debug(`Increasing pending tx count: current ${pendingTxCount} + count ${count} = ${pendingTxCount + count}`);
|
|
535
|
-
await this.#pendingTxCount.set(pendingTxCount + count);
|
|
536
|
-
}
|
|
537
521
|
}
|