@aztec/p2p 0.0.1-commit.6d63667d → 0.0.1-commit.86469d5
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/factory.d.ts +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +1 -3
- package/dest/client/p2p_client.d.ts +2 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +2 -6
- package/dest/config.d.ts +3 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -3
- package/dest/services/index.d.ts +1 -2
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +0 -1
- package/dest/services/libp2p/libp2p_service.d.ts +4 -4
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +8 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +5 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +11 -16
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +10 -15
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +11 -12
- package/dest/services/tx_collection/config.d.ts +3 -3
- package/dest/services/tx_collection/config.js +3 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +14 -10
- package/dest/services/tx_collection/index.d.ts +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/package.json +14 -14
- package/src/client/factory.ts +0 -4
- package/src/client/p2p_client.ts +0 -5
- package/src/config.ts +1 -8
- package/src/services/index.ts +0 -1
- package/src/services/libp2p/libp2p_service.ts +8 -12
- package/src/services/reqresp/batch-tx-requester/README.md +7 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +14 -22
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +15 -21
- package/src/services/tx_collection/config.ts +6 -6
- package/src/services/tx_collection/fast_tx_collection.ts +24 -14
- package/src/services/tx_collection/index.ts +1 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +14 -12
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +0 -2
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.js +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +0 -43
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +0 -103
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +0 -47
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +0 -119
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +0 -90
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +0 -89
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +0 -10
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +0 -11
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +0 -131
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +0 -63
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +0 -91
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +0 -70
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +0 -20
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +0 -63
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +0 -19
- package/dest/mem_pools/tx_pool_v2/index.d.ts +0 -5
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/index.js +0 -4
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +0 -197
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +0 -6
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +0 -71
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +0 -95
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +0 -26
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +0 -70
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +0 -99
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +0 -332
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +0 -55
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +0 -156
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +0 -69
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +0 -748
- package/dest/services/tx_file_store/config.d.ts +0 -18
- package/dest/services/tx_file_store/config.d.ts.map +0 -1
- package/dest/services/tx_file_store/config.js +0 -26
- package/dest/services/tx_file_store/index.d.ts +0 -4
- package/dest/services/tx_file_store/index.d.ts.map +0 -1
- package/dest/services/tx_file_store/index.js +0 -3
- package/dest/services/tx_file_store/instrumentation.d.ts +0 -15
- package/dest/services/tx_file_store/instrumentation.d.ts.map +0 -1
- package/dest/services/tx_file_store/instrumentation.js +0 -29
- package/dest/services/tx_file_store/tx_file_store.d.ts +0 -47
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +0 -1
- package/dest/services/tx_file_store/tx_file_store.js +0 -149
- package/src/mem_pools/tx_pool_v2/README.md +0 -209
- package/src/mem_pools/tx_pool_v2/archive/index.ts +0 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +0 -120
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +0 -147
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +0 -118
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +0 -111
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +0 -23
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +0 -164
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +0 -74
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +0 -101
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +0 -86
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +0 -72
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +0 -31
- package/src/mem_pools/tx_pool_v2/index.ts +0 -11
- package/src/mem_pools/tx_pool_v2/interfaces.ts +0 -227
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +0 -161
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +0 -77
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +0 -417
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +0 -212
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +0 -882
- package/src/services/tx_file_store/config.ts +0 -43
- package/src/services/tx_file_store/index.ts +0 -3
- package/src/services/tx_file_store/instrumentation.ts +0 -36
- package/src/services/tx_file_store/tx_file_store.ts +0 -173
|
@@ -60,21 +60,21 @@ import { createLibp2p } from 'libp2p';
|
|
|
60
60
|
|
|
61
61
|
import type { P2PConfig } from '../../config.js';
|
|
62
62
|
import { ProposalSlotCapExceededError } from '../../errors/attestation-pool.error.js';
|
|
63
|
-
import type { MemPools } from '../../mem_pools/
|
|
63
|
+
import type { MemPools } from '../../mem_pools/interface.js';
|
|
64
64
|
import {
|
|
65
65
|
BlockProposalValidator,
|
|
66
66
|
CheckpointAttestationValidator,
|
|
67
67
|
CheckpointProposalValidator,
|
|
68
|
-
DoubleSpendTxValidator,
|
|
69
68
|
FishermanAttestationValidator,
|
|
70
|
-
getDefaultAllowedSetupFunctions,
|
|
71
69
|
} from '../../msg_validators/index.js';
|
|
72
70
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
71
|
+
import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
|
|
73
72
|
import {
|
|
74
73
|
type MessageValidator,
|
|
75
74
|
createTxMessageValidators,
|
|
76
75
|
createTxReqRespValidator,
|
|
77
76
|
} from '../../msg_validators/tx_validator/factory.js';
|
|
77
|
+
import { DoubleSpendTxValidator } from '../../msg_validators/tx_validator/index.js';
|
|
78
78
|
import { GossipSubEvent } from '../../types/index.js';
|
|
79
79
|
import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
|
|
80
80
|
import { getVersions } from '../../versioning.js';
|
|
@@ -97,19 +97,19 @@ import {
|
|
|
97
97
|
type ReqRespSubProtocolValidators,
|
|
98
98
|
type SubProtocolMap,
|
|
99
99
|
ValidationError,
|
|
100
|
-
} from '../reqresp/
|
|
100
|
+
} from '../reqresp/interface.js';
|
|
101
|
+
import { reqRespBlockTxsHandler } from '../reqresp/protocols/block_txs/block_txs_handler.js';
|
|
102
|
+
import { reqGoodbyeHandler } from '../reqresp/protocols/goodbye.js';
|
|
101
103
|
import {
|
|
102
104
|
AuthRequest,
|
|
103
105
|
BlockTxsRequest,
|
|
104
106
|
BlockTxsResponse,
|
|
105
107
|
StatusMessage,
|
|
106
108
|
pingHandler,
|
|
107
|
-
reqGoodbyeHandler,
|
|
108
109
|
reqRespBlockHandler,
|
|
109
|
-
reqRespBlockTxsHandler,
|
|
110
110
|
reqRespStatusHandler,
|
|
111
111
|
reqRespTxHandler,
|
|
112
|
-
} from '../reqresp/index.js';
|
|
112
|
+
} from '../reqresp/protocols/index.js';
|
|
113
113
|
import { ReqResp } from '../reqresp/reqresp.js';
|
|
114
114
|
import type {
|
|
115
115
|
P2PBlockReceivedCallback,
|
|
@@ -524,11 +524,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
524
524
|
};
|
|
525
525
|
|
|
526
526
|
if (!this.config.disableTransactions) {
|
|
527
|
-
const blockTxsHandler = reqRespBlockTxsHandler(
|
|
528
|
-
this.mempools.attestationPool,
|
|
529
|
-
this.archiver,
|
|
530
|
-
this.mempools.txPool,
|
|
531
|
-
);
|
|
527
|
+
const blockTxsHandler = reqRespBlockTxsHandler(this.mempools.attestationPool, this.mempools.txPool);
|
|
532
528
|
requestResponseHandlers[ReqRespSubProtocol.BLOCK_TXS] = blockTxsHandler.bind(this);
|
|
533
529
|
}
|
|
534
530
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# BatchTxRequester
|
|
2
2
|
|
|
3
|
-
The `BatchTxRequester` is a specialized P2P service that aggressively fetches missing transactions from peers when a node lacks some of the referenced transactions.
|
|
3
|
+
The `BatchTxRequester` is a specialized P2P service that aggressively fetches missing transactions from peers when a node receives a block proposal but lacks some of the referenced transactions. This is critical for validators who need all transactions to attest to a proposal.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
When a validator receives a block proposal
|
|
7
|
+
When a validator receives a block proposal, they must verify all transactions in the block. If some transactions are missing from the local mempool (e.g., due to gossip delays), the `BatchTxRequester` kicks in to fetch them via direct peer-to-peer requests before the attestation deadline.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
10
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
11
|
-
│
|
|
11
|
+
│ Block Proposal Received │
|
|
12
12
|
│ (contains hashes of N transactions) │
|
|
13
13
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
14
14
|
│
|
|
@@ -230,8 +230,8 @@ Request to peer fails
|
|
|
230
230
|
```typescript
|
|
231
231
|
const requester = new BatchTxRequester(
|
|
232
232
|
missingTxHashes, // TxHash[] - what we need
|
|
233
|
-
|
|
234
|
-
pinnedPeer, // PeerId | undefined -
|
|
233
|
+
blockProposal, // BlockProposal - the proposal we're attesting to
|
|
234
|
+
pinnedPeer, // PeerId | undefined - who sent us the proposal
|
|
235
235
|
timeoutMs, // number - how long to try
|
|
236
236
|
p2pService, // BatchTxRequesterLibP2PService
|
|
237
237
|
);
|
|
@@ -268,14 +268,14 @@ const txs = await BatchTxRequester.collectAllTxs(requester.run());
|
|
|
268
268
|
┌───────────────────────────────────┐ ┌─────────────────────────────────────┐
|
|
269
269
|
│ FastTxCollection │ │ SlowTxCollection │
|
|
270
270
|
│ │ │ │
|
|
271
|
-
│ Time-critical:
|
|
271
|
+
│ Time-critical: attestations │ │ Background: unproven blocks │
|
|
272
272
|
│ │ │ │
|
|
273
273
|
│ 1. Try RPC nodes first (fast) │ │ Periodic polling of RPC nodes │
|
|
274
274
|
│ 2. Fall back to BatchTxRequester │ │ and peers for missing txs │
|
|
275
275
|
│ │ │ │
|
|
276
276
|
└───────────────────┬───────────────┘ └─────────────────────────────────────┘
|
|
277
277
|
│
|
|
278
|
-
│ For 'proposal'
|
|
278
|
+
│ For 'proposal' requests
|
|
279
279
|
▼
|
|
280
280
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
281
281
|
│ BatchTxRequester │
|
|
@@ -4,14 +4,14 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
|
4
4
|
import { FifoMemoryQueue, type ISemaphore, Semaphore } from '@aztec/foundation/queue';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider, executeTimeout } from '@aztec/foundation/timer';
|
|
7
|
-
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
7
|
+
import { type BlockProposal, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
8
8
|
import { Tx, TxArray, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
10
|
import type { PeerId } from '@libp2p/interface';
|
|
11
11
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
12
12
|
|
|
13
13
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
14
|
-
import { BlockTxsRequest, BlockTxsResponse
|
|
14
|
+
import { BlockTxsRequest, BlockTxsResponse } from '.././protocols/index.js';
|
|
15
15
|
import { ReqRespStatus } from '.././status.js';
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD,
|
|
@@ -42,7 +42,7 @@ import { BatchRequestTxValidator, type IBatchRequestTxValidator } from './tx_val
|
|
|
42
42
|
* - Is the peer which was unable to send us successful response N times in a row
|
|
43
43
|
* */
|
|
44
44
|
export class BatchTxRequester {
|
|
45
|
-
private readonly
|
|
45
|
+
private readonly blockProposal: BlockProposal;
|
|
46
46
|
private readonly pinnedPeer: PeerId | undefined;
|
|
47
47
|
private readonly timeoutMs: number;
|
|
48
48
|
private readonly p2pService: BatchTxRequesterLibP2PService;
|
|
@@ -61,7 +61,7 @@ export class BatchTxRequester {
|
|
|
61
61
|
|
|
62
62
|
constructor(
|
|
63
63
|
missingTxs: TxHash[],
|
|
64
|
-
|
|
64
|
+
blockProposal: BlockProposal,
|
|
65
65
|
pinnedPeer: PeerId | undefined,
|
|
66
66
|
timeoutMs: number,
|
|
67
67
|
p2pService: BatchTxRequesterLibP2PService,
|
|
@@ -69,7 +69,7 @@ export class BatchTxRequester {
|
|
|
69
69
|
dateProvider?: DateProvider,
|
|
70
70
|
opts?: BatchTxRequesterOptions,
|
|
71
71
|
) {
|
|
72
|
-
this.
|
|
72
|
+
this.blockProposal = blockProposal;
|
|
73
73
|
this.pinnedPeer = pinnedPeer;
|
|
74
74
|
this.timeoutMs = timeoutMs;
|
|
75
75
|
this.p2pService = p2pService;
|
|
@@ -205,7 +205,7 @@ export class BatchTxRequester {
|
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
const request = BlockTxsRequest.
|
|
208
|
+
const request = BlockTxsRequest.fromBlockProposalAndMissingTxs(this.blockProposal, txs);
|
|
209
209
|
if (!request) {
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
@@ -249,8 +249,8 @@ export class BatchTxRequester {
|
|
|
249
249
|
// If peer is dumb peer, we don't know yet if they received full blockProposal
|
|
250
250
|
// there is solid chance that peer didn't receive proposal yet, thus we must send full hashes
|
|
251
251
|
const includeFullHashesInRequestNotJustIndices = true;
|
|
252
|
-
const blockRequest = BlockTxsRequest.
|
|
253
|
-
this.
|
|
252
|
+
const blockRequest = BlockTxsRequest.fromBlockProposalAndMissingTxs(
|
|
253
|
+
this.blockProposal,
|
|
254
254
|
txs,
|
|
255
255
|
includeFullHashesInRequestNotJustIndices,
|
|
256
256
|
);
|
|
@@ -342,7 +342,7 @@ export class BatchTxRequester {
|
|
|
342
342
|
|
|
343
343
|
const makeRequest = (pid: PeerId) => {
|
|
344
344
|
const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
|
|
345
|
-
const blockRequest = BlockTxsRequest.
|
|
345
|
+
const blockRequest = BlockTxsRequest.fromBlockProposalAndMissingTxs(this.blockProposal, txs);
|
|
346
346
|
if (!blockRequest) {
|
|
347
347
|
return undefined;
|
|
348
348
|
}
|
|
@@ -605,7 +605,7 @@ export class BatchTxRequester {
|
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
private isBlockResponseValid(response: BlockTxsResponse): boolean {
|
|
608
|
-
const archiveRootsMatch = this.
|
|
608
|
+
const archiveRootsMatch = this.blockProposal.archive.toString() === response.archiveRoot.toString();
|
|
609
609
|
const peerHasSomeTxsFromProposal = !response.txIndices.isEmpty();
|
|
610
610
|
return archiveRootsMatch && peerHasSomeTxsFromProposal;
|
|
611
611
|
}
|
|
@@ -624,7 +624,7 @@ export class BatchTxRequester {
|
|
|
624
624
|
private extractHashesPeerHasFromResponse(response: BlockTxsResponse): Array<TxHash> {
|
|
625
625
|
const hashes: TxHash[] = [];
|
|
626
626
|
const indicesOfHashesPeerHas = new Set(response.txIndices.getTrueIndices());
|
|
627
|
-
this.
|
|
627
|
+
this.blockProposal.txHashes.forEach((hash, idx) => {
|
|
628
628
|
if (indicesOfHashesPeerHas.has(idx)) {
|
|
629
629
|
hashes.push(hash);
|
|
630
630
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
2
|
import { TxArray } from '@aztec/stdlib/tx';
|
|
4
3
|
|
|
5
4
|
import type { PeerId } from '@libp2p/interface';
|
|
6
5
|
|
|
7
|
-
import type { AttestationPool
|
|
6
|
+
import type { AttestationPool } from '../../../../mem_pools/attestation_pool/attestation_pool.js';
|
|
7
|
+
import type { TxPool } from '../../../../mem_pools/index.js';
|
|
8
8
|
import type { ReqRespSubProtocolHandler } from '../../interface.js';
|
|
9
9
|
import { ReqRespStatus, ReqRespStatusError } from '../../status.js';
|
|
10
10
|
import { BitVector } from './bitvector.js';
|
|
@@ -13,15 +13,10 @@ import { BlockTxsRequest, BlockTxsResponse } from './block_txs_reqresp.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* Handler for block txs requests
|
|
15
15
|
* @param attestationPool - the attestation pool to check for block proposals
|
|
16
|
-
* @param
|
|
17
|
-
* @param txPool - the tx pool to fetch transactions from
|
|
16
|
+
* @param mempools - the mempools containing the tx pool
|
|
18
17
|
* @returns the BlockTxs request handler
|
|
19
18
|
*/
|
|
20
|
-
export function reqRespBlockTxsHandler(
|
|
21
|
-
attestationPool: AttestationPool,
|
|
22
|
-
archiver: L2BlockSource,
|
|
23
|
-
txPool: TxPool,
|
|
24
|
-
): ReqRespSubProtocolHandler {
|
|
19
|
+
export function reqRespBlockTxsHandler(attestationPool: AttestationPool, txPool: TxPool): ReqRespSubProtocolHandler {
|
|
25
20
|
/**
|
|
26
21
|
* Handler for block txs requests
|
|
27
22
|
* @param msg - the block txs request message
|
|
@@ -35,37 +30,34 @@ export function reqRespBlockTxsHandler(
|
|
|
35
30
|
} catch (err: any) {
|
|
36
31
|
throw new ReqRespStatusError(ReqRespStatus.BADLY_FORMED_REQUEST, { cause: err });
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!txHashes) {
|
|
41
|
-
txHashes = (await archiver.getL2BlockByArchive(request.archiveRoot))?.body.txEffects.map(effect => effect.txHash);
|
|
42
|
-
}
|
|
33
|
+
|
|
34
|
+
const blockProposal = await attestationPool.getBlockProposal(request.archiveRoot.toString());
|
|
43
35
|
|
|
44
36
|
let requestedTxsHashes;
|
|
45
37
|
if (request.txHashes.length > 0) {
|
|
46
38
|
requestedTxsHashes = request.txHashes;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
// This is scenario in which we don't have this block the peer is requesting from us
|
|
41
|
+
// This is scenario in which we don't have this block proposal the peer is requesting from us
|
|
50
42
|
// But peer has sent requested tx hashes, so we can send them the transactions
|
|
51
|
-
if (!
|
|
43
|
+
if (!blockProposal && requestedTxsHashes !== undefined) {
|
|
52
44
|
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
53
45
|
const response = new BlockTxsResponse(Fr.zero(), new TxArray(...responseTxs), BitVector.init(0, []));
|
|
54
46
|
return response.toBuffer();
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
// If
|
|
58
|
-
if (!
|
|
49
|
+
// If don't have this block proposal and peer has not sent requested tx hashes
|
|
50
|
+
if (!blockProposal) {
|
|
59
51
|
throw new ReqRespStatusError(ReqRespStatus.NOT_FOUND);
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
const txsAvailableInPool = await txPool.hasTxs(txHashes);
|
|
63
|
-
//
|
|
54
|
+
const txsAvailableInPool = await txPool.hasTxs(blockProposal.txHashes);
|
|
55
|
+
//Map txs in the pool to their indices in the block proposal
|
|
64
56
|
const availableIndices = txsAvailableInPool.map((hasTx, idx) => (hasTx ? idx : -1)).filter(idx => idx !== -1);
|
|
65
|
-
const responseBitVector = BitVector.init(txHashes.length, availableIndices);
|
|
57
|
+
const responseBitVector = BitVector.init(blockProposal.txHashes.length, availableIndices);
|
|
66
58
|
|
|
67
59
|
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
68
|
-
requestedTxsHashes = txHashes.filter((_, idx) => requestedIndices.has(idx));
|
|
60
|
+
requestedTxsHashes = blockProposal.txHashes.filter((_, idx) => requestedIndices.has(idx));
|
|
69
61
|
|
|
70
62
|
const responseTxs = (await txPool.getTxsByHash(requestedTxsHashes)).filter(tx => !!tx);
|
|
71
63
|
const response = new BlockTxsResponse(request.archiveRoot, new TxArray(...responseTxs), responseBitVector);
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import
|
|
3
|
+
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { TxArray, TxHash, TxHashArray } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
5
6
|
import { BitVector } from './bitvector.js';
|
|
6
7
|
|
|
7
|
-
/** Minimal interface for a block source that provides tx hashes and an archive root. */
|
|
8
|
-
export interface BlockTxsSource {
|
|
9
|
-
txHashes: TxHash[];
|
|
10
|
-
archive: Fr;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
/**
|
|
14
9
|
* Request message for requesting specific transactions from a block
|
|
15
10
|
*/
|
|
@@ -27,17 +22,16 @@ export class BlockTxsRequest {
|
|
|
27
22
|
) {}
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
|
-
* Creates new BlockTxsRequest given
|
|
25
|
+
* Creates new BlockTxsRequest given proposal and missing tx hashes
|
|
31
26
|
*
|
|
32
|
-
* @param
|
|
33
|
-
* @param missingTxHashes - Tx hashes from the
|
|
34
|
-
* @param includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
|
|
27
|
+
* @param: blockProposal - The block proposal for which we are making request
|
|
28
|
+
* @param: missingTxHashes - Tx hashes from the proposal we are missing
|
|
29
|
+
* @param: includeFullTxHashes - Whether to include full list of missing tx hashes in the request or just Bitvector indices
|
|
35
30
|
*
|
|
36
|
-
* @returns undefined if there were no missingTxHashes matching
|
|
37
|
-
* returns new BlockTxsRequest
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
blockTxsSource: BlockTxsSource,
|
|
31
|
+
* @returns undefined if there were no missingTxHashes matching BlockProposal hashes, otherwise
|
|
32
|
+
* returns new BlockTxsRequest*/
|
|
33
|
+
static fromBlockProposalAndMissingTxs(
|
|
34
|
+
blockProposal: BlockProposal,
|
|
41
35
|
missingTxHashes: TxHash[],
|
|
42
36
|
includeFullTxHashes = false,
|
|
43
37
|
): BlockTxsRequest | undefined {
|
|
@@ -47,19 +41,19 @@ export class BlockTxsRequest {
|
|
|
47
41
|
|
|
48
42
|
const missingHashesSet = new Set(missingTxHashes.map(t => t.toString()));
|
|
49
43
|
|
|
50
|
-
// We cannot request txs that are not part of the block
|
|
51
|
-
if (!missingHashesSet.isSubsetOf(new Set(
|
|
44
|
+
// We cannot request txs that are not part of the block proposal
|
|
45
|
+
if (!missingHashesSet.isSubsetOf(new Set(blockProposal.txHashes.map(t => t.toString())))) {
|
|
52
46
|
return undefined;
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
const missingIndices =
|
|
49
|
+
const missingIndices = blockProposal.txHashes
|
|
56
50
|
.map((hash, idx) => (missingHashesSet.has(hash.toString()) ? idx : -1))
|
|
57
51
|
.filter(i => i != -1);
|
|
58
52
|
|
|
59
|
-
const requestBitVector = BitVector.init(
|
|
53
|
+
const requestBitVector = BitVector.init(blockProposal.txHashes.length, missingIndices);
|
|
60
54
|
const hashes = includeFullTxHashes ? new TxHashArray(...missingTxHashes) : new TxHashArray();
|
|
61
55
|
|
|
62
|
-
return new BlockTxsRequest(
|
|
56
|
+
return new BlockTxsRequest(blockProposal.archive, hashes, requestBitVector);
|
|
63
57
|
}
|
|
64
58
|
|
|
65
59
|
/**
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from '@aztec/foundation/config';
|
|
7
7
|
import { MAX_RPC_TXS_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type ProposalTxCollectorType = 'new' | 'old';
|
|
10
10
|
|
|
11
11
|
export type TxCollectionConfig = {
|
|
12
12
|
/** How long to wait before starting reqresp for fast collection */
|
|
@@ -29,8 +29,8 @@ export type TxCollectionConfig = {
|
|
|
29
29
|
txCollectionFastMaxParallelRequestsPerNode: number;
|
|
30
30
|
/** Maximum number of transactions to request from a node in a single batch */
|
|
31
31
|
txCollectionNodeRpcMaxBatchSize: number;
|
|
32
|
-
/** Which collector implementation to use for
|
|
33
|
-
|
|
32
|
+
/** Which collector implementation to use for proposal tx collection */
|
|
33
|
+
txCollectionProposalTxCollectorType: ProposalTxCollectorType;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig> = {
|
|
@@ -90,9 +90,9 @@ export const txCollectionConfigMappings: ConfigMappingsType<TxCollectionConfig>
|
|
|
90
90
|
description: 'Maximum number of transactions to request from a node in a single batch',
|
|
91
91
|
...numberConfigHelper(MAX_RPC_TXS_LEN),
|
|
92
92
|
},
|
|
93
|
-
|
|
94
|
-
env: '
|
|
95
|
-
description: 'Which collector implementation to use for
|
|
93
|
+
txCollectionProposalTxCollectorType: {
|
|
94
|
+
env: 'TX_COLLECTION_PROPOSAL_TX_COLLECTOR_TYPE',
|
|
95
|
+
description: 'Which collector implementation to use for proposal tx collection (new or old)',
|
|
96
96
|
...enumConfigHelper(['new', 'old'] as const, 'new'),
|
|
97
97
|
},
|
|
98
98
|
};
|
|
@@ -2,6 +2,7 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { AbortError, TimeoutError } from '@aztec/foundation/error';
|
|
4
4
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { boundInclusive } from '@aztec/foundation/number';
|
|
5
6
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
6
7
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
8
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
@@ -13,10 +14,12 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
13
14
|
|
|
14
15
|
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
15
16
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
17
|
+
import { ReqRespSubProtocol } from '../reqresp/interface.js';
|
|
18
|
+
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
16
19
|
import type { TxCollectionConfig } from './config.js';
|
|
17
20
|
import {
|
|
18
21
|
BatchTxRequesterCollector,
|
|
19
|
-
type
|
|
22
|
+
type ProposalTxCollector,
|
|
20
23
|
SendBatchRequestCollector,
|
|
21
24
|
} from './proposal_tx_collector.js';
|
|
22
25
|
import type { FastCollectionRequest, FastCollectionRequestInput } from './tx_collection.js';
|
|
@@ -26,22 +29,22 @@ import type { TxSource } from './tx_source.js';
|
|
|
26
29
|
export class FastTxCollection {
|
|
27
30
|
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
28
31
|
protected requests: Set<FastCollectionRequest> = new Set();
|
|
29
|
-
private
|
|
32
|
+
private proposalTxCollector: ProposalTxCollector;
|
|
30
33
|
|
|
31
34
|
constructor(
|
|
32
|
-
p2pService: BatchTxRequesterLibP2PService,
|
|
35
|
+
private p2pService: BatchTxRequesterLibP2PService,
|
|
33
36
|
private nodes: TxSource[],
|
|
34
37
|
private txCollectionSink: TxCollectionSink,
|
|
35
38
|
private config: TxCollectionConfig,
|
|
36
39
|
private dateProvider: DateProvider = new DateProvider(),
|
|
37
40
|
private log: Logger = createLogger('p2p:tx_collection_service'),
|
|
38
|
-
|
|
41
|
+
proposalTxCollector?: ProposalTxCollector,
|
|
39
42
|
) {
|
|
40
43
|
const batchTxRequesterConfig = this.config as Partial<BatchTxRequesterConfig>;
|
|
41
|
-
const
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
(
|
|
44
|
+
const proposalCollectorType = this.config.txCollectionProposalTxCollectorType;
|
|
45
|
+
this.proposalTxCollector =
|
|
46
|
+
proposalTxCollector ??
|
|
47
|
+
(proposalCollectorType === 'old'
|
|
45
48
|
? new SendBatchRequestCollector(p2pService)
|
|
46
49
|
: new BatchTxRequesterCollector(p2pService, log, dateProvider, undefined, batchTxRequesterConfig));
|
|
47
50
|
}
|
|
@@ -255,6 +258,8 @@ export class FastTxCollection {
|
|
|
255
258
|
private async collectFastViaReqResp(request: FastCollectionRequest, opts: { pinnedPeer?: PeerId }) {
|
|
256
259
|
const timeoutMs = +request.deadline - this.dateProvider.now();
|
|
257
260
|
const pinnedPeer = opts.pinnedPeer;
|
|
261
|
+
const maxPeers = boundInclusive(Math.ceil(request.missingTxHashes.size / 2), 8, 32);
|
|
262
|
+
const maxRetryAttempts = 5;
|
|
258
263
|
const blockInfo = request.blockInfo;
|
|
259
264
|
const slotNumber = blockInfo.slotNumber;
|
|
260
265
|
if (timeoutMs < 100) {
|
|
@@ -274,13 +279,18 @@ export class FastTxCollection {
|
|
|
274
279
|
await this.txCollectionSink.collect(
|
|
275
280
|
async txHashes => {
|
|
276
281
|
if (request.type === 'proposal') {
|
|
277
|
-
return await this.
|
|
282
|
+
return await this.proposalTxCollector.collectTxs(txHashes, request.blockProposal, pinnedPeer, timeoutMs);
|
|
278
283
|
} else if (request.type === 'block') {
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
const txs = await this.p2pService.reqResp.sendBatchRequest<ReqRespSubProtocol.TX>(
|
|
285
|
+
ReqRespSubProtocol.TX,
|
|
286
|
+
chunkTxHashesRequest(txHashes),
|
|
287
|
+
pinnedPeer,
|
|
288
|
+
timeoutMs,
|
|
289
|
+
maxPeers,
|
|
290
|
+
maxRetryAttempts,
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
return txs.flat();
|
|
284
294
|
} else {
|
|
285
295
|
throw new Error(`Unknown request type: ${(request as any).type}`);
|
|
286
296
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TxCollection, type FastCollectionRequestInput } from './tx_collection.js';
|
|
2
2
|
export { type TxSource, createNodeRpcTxSources, NodeRpcTxSource } from './tx_source.js';
|
|
3
3
|
export {
|
|
4
|
-
type
|
|
4
|
+
type ProposalTxCollector,
|
|
5
5
|
BatchTxRequesterCollector,
|
|
6
6
|
SendBatchRequestCollector,
|
|
7
7
|
} from './proposal_tx_collector.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
4
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
5
|
|
|
5
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -8,24 +9,25 @@ import { BatchTxRequester } from '../reqresp/batch-tx-requester/batch_tx_request
|
|
|
8
9
|
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
9
10
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
10
11
|
import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
|
|
11
|
-
import {
|
|
12
|
+
import { ReqRespSubProtocol } from '../reqresp/interface.js';
|
|
13
|
+
import { chunkTxHashesRequest } from '../reqresp/protocols/tx.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
|
-
* Strategy interface for collecting
|
|
16
|
+
* Strategy interface for collecting transactions for block proposals.
|
|
15
17
|
* Allows swapping between different tx collection implementations for benchmarking.
|
|
16
18
|
*/
|
|
17
|
-
export interface
|
|
19
|
+
export interface ProposalTxCollector {
|
|
18
20
|
/**
|
|
19
|
-
* Collect
|
|
21
|
+
* Collect transactions for a block proposal.
|
|
20
22
|
* @param txHashes - The transaction hashes to collect
|
|
21
|
-
* @param
|
|
22
|
-
* @param pinnedPeer - Optional peer expected to have
|
|
23
|
+
* @param blockProposal - The block proposal containing the transactions
|
|
24
|
+
* @param pinnedPeer - Optional peer that sent the proposal (expected to have all txs)
|
|
23
25
|
* @param timeoutMs - Timeout in milliseconds
|
|
24
26
|
* @returns The collected transactions
|
|
25
27
|
*/
|
|
26
28
|
collectTxs(
|
|
27
29
|
txHashes: TxHash[],
|
|
28
|
-
|
|
30
|
+
blockProposal: BlockProposal,
|
|
29
31
|
pinnedPeer: PeerId | undefined,
|
|
30
32
|
timeoutMs: number,
|
|
31
33
|
): Promise<Tx[]>;
|
|
@@ -35,7 +37,7 @@ export interface MissingTxsCollector {
|
|
|
35
37
|
* Collects transactions using the BatchTxRequester implementation.
|
|
36
38
|
* This uses a smart/dumb peer strategy with parallel workers.
|
|
37
39
|
*/
|
|
38
|
-
export class BatchTxRequesterCollector implements
|
|
40
|
+
export class BatchTxRequesterCollector implements ProposalTxCollector {
|
|
39
41
|
constructor(
|
|
40
42
|
private p2pService: BatchTxRequesterLibP2PService,
|
|
41
43
|
private log: Logger,
|
|
@@ -46,7 +48,7 @@ export class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
|
46
48
|
|
|
47
49
|
async collectTxs(
|
|
48
50
|
txHashes: TxHash[],
|
|
49
|
-
|
|
51
|
+
blockProposal: BlockProposal,
|
|
50
52
|
pinnedPeer: PeerId | undefined,
|
|
51
53
|
timeoutMs: number,
|
|
52
54
|
): Promise<Tx[]> {
|
|
@@ -59,7 +61,7 @@ export class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
|
59
61
|
|
|
60
62
|
const batchRequester = new BatchTxRequester(
|
|
61
63
|
txHashes,
|
|
62
|
-
|
|
64
|
+
blockProposal,
|
|
63
65
|
pinnedPeer,
|
|
64
66
|
timeoutMs,
|
|
65
67
|
this.p2pService,
|
|
@@ -85,7 +87,7 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
|
|
|
85
87
|
* Collects transactions using the sendBatchRequest implementation from ReqResp.
|
|
86
88
|
* This is the original implementation that balances requests across peers.
|
|
87
89
|
*/
|
|
88
|
-
export class SendBatchRequestCollector implements
|
|
90
|
+
export class SendBatchRequestCollector implements ProposalTxCollector {
|
|
89
91
|
constructor(
|
|
90
92
|
private p2pService: BatchTxRequesterLibP2PService,
|
|
91
93
|
private maxPeers: number = DEFAULT_MAX_PEERS,
|
|
@@ -94,7 +96,7 @@ export class SendBatchRequestCollector implements MissingTxsCollector {
|
|
|
94
96
|
|
|
95
97
|
async collectTxs(
|
|
96
98
|
txHashes: TxHash[],
|
|
97
|
-
|
|
99
|
+
_blockProposal: BlockProposal,
|
|
98
100
|
pinnedPeer: PeerId | undefined,
|
|
99
101
|
timeoutMs: number,
|
|
100
102
|
): Promise<Tx[]> {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { TxArchive } from './tx_archive.js';
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvdHhfcG9vbF92Mi9hcmNoaXZlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/archive/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TxArchive } from './tx_archive.js';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
-
/**
|
|
5
|
-
* Manages archived transactions with FIFO eviction.
|
|
6
|
-
* Archived transactions have their proofs stripped to save space.
|
|
7
|
-
*/
|
|
8
|
-
export declare class TxArchive {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(store: AztecAsyncKVStore, limit: number, log?: Logger);
|
|
11
|
-
/**
|
|
12
|
-
* Updates the maximum number of archived transactions.
|
|
13
|
-
*/
|
|
14
|
-
updateLimit(limit: number): void;
|
|
15
|
-
/**
|
|
16
|
-
* Gets the current archive limit.
|
|
17
|
-
*/
|
|
18
|
-
getLimit(): number;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if archiving is enabled.
|
|
21
|
-
*/
|
|
22
|
-
isEnabled(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Archives transactions, stripping their proofs.
|
|
25
|
-
* Evicts oldest transactions if the limit is exceeded.
|
|
26
|
-
*/
|
|
27
|
-
archiveTxs(txs: Tx[]): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Retrieves an archived transaction by its hash.
|
|
30
|
-
*/
|
|
31
|
-
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the current count of archived transactions.
|
|
34
|
-
*/
|
|
35
|
-
getCount(): Promise<number>;
|
|
36
|
-
/**
|
|
37
|
-
* Strips the proof from a transaction for archival.
|
|
38
|
-
*/
|
|
39
|
-
private stripProof;
|
|
40
|
-
private getHeadIndex;
|
|
41
|
-
private getTailIndex;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfYXJjaGl2ZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL21lbV9wb29scy90eF9wb29sX3YyL2FyY2hpdmUvdHhfYXJjaGl2ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFFeEUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU5Qzs7O0dBR0c7QUFDSCxxQkFBYSxTQUFTOztJQU9wQixZQUFZLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLEdBQUcsQ0FBQyxFQUFFLE1BQU0sRUFNaEU7SUFFRDs7T0FFRztJQUNILFdBQVcsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLElBQUksQ0FFL0I7SUFFRDs7T0FFRztJQUNILFFBQVEsSUFBSSxNQUFNLENBRWpCO0lBRUQ7O09BRUc7SUFDSCxTQUFTLElBQUksT0FBTyxDQUVuQjtJQUVEOzs7T0FHRztJQUNHLFVBQVUsQ0FBQyxHQUFHLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQW1DekM7SUFFRDs7T0FFRztJQUNHLFdBQVcsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxFQUFFLEdBQUcsU0FBUyxDQUFDLENBR3pEO0lBRUQ7O09BRUc7SUFDRyxRQUFRLElBQUksT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUloQztJQUVEOztPQUVHO0lBQ0gsT0FBTyxDQUFDLFVBQVU7WUFJSixZQUFZO1lBS1osWUFBWTtDQUkzQiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tx_archive.d.ts","sourceRoot":"","sources":["../../../../src/mem_pools/tx_pool_v2/archive/tx_archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;GAGG;AACH,qBAAa,SAAS;;IAOpB,YAAY,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAMhE;IAED;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/B;IAED;;OAEG;IACH,QAAQ,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,SAAS,IAAI,OAAO,CAEnB;IAED;;;OAGG;IACG,UAAU,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCzC;IAED;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAGzD;IAED;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAIhC;IAED;;OAEG;IACH,OAAO,CAAC,UAAU;YAIJ,YAAY;YAKZ,YAAY;CAI3B"}
|