@aztec/p2p 0.0.1-commit.858058eac → 0.0.1-commit.85d7d01
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 +6 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +23 -30
- package/dest/client/interface.d.ts +14 -19
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +52 -72
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +13 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +5 -5
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +4 -2
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +5 -0
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +30 -13
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +91 -20
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -2
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +20 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +4 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +34 -8
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +76 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +36 -14
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +11 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +13 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +297 -143
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +4 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +4 -4
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +9 -8
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +16 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +69 -81
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- 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 +19 -46
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- 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 +2 -1
- package/dest/services/service.d.ts +5 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +13 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +30 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +39 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +38 -29
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +126 -77
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +49 -16
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
- 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/dest/services/tx_collection/slow_tx_collection.d.ts +5 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +17 -12
- package/dest/services/tx_collection/tx_collection.d.ts +9 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +26 -10
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +3 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +8 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +8 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +7 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -13
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +39 -48
- package/src/client/interface.ts +17 -20
- package/src/client/p2p_client.ts +60 -104
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
- package/src/config.ts +10 -10
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +8 -0
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +43 -27
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +109 -22
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -2
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +21 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +107 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +43 -16
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +18 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +326 -138
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +7 -7
- package/src/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +7 -7
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +80 -90
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +3 -1
- package/src/services/service.ts +11 -2
- package/src/services/tx_collection/config.ts +42 -0
- package/src/services/tx_collection/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +143 -93
- package/src/services/tx_collection/file_store_tx_source.ts +64 -17
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +17 -13
- package/src/services/tx_collection/tx_collection.ts +45 -14
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/tx_file_store.ts +6 -4
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +13 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +11 -3
- package/src/testbench/p2p_client_testbench_worker.ts +22 -19
- package/src/util.ts +7 -1
|
@@ -1,118 +1,167 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
6
|
/**
|
|
6
7
|
* Collects txs from file stores as a fallback after P2P methods have been tried.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Uses a shared worker pool that pulls entries with priority (fewest attempts first),
|
|
9
|
+
* retries with round-robin across sources, and applies exponential backoff between
|
|
10
|
+
* full cycles through all sources.
|
|
9
11
|
*/ export class FileStoreTxCollection {
|
|
10
|
-
|
|
12
|
+
sources;
|
|
11
13
|
txCollectionSink;
|
|
14
|
+
config;
|
|
15
|
+
dateProvider;
|
|
12
16
|
log;
|
|
13
|
-
/** Map from tx hash to
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** Queue of tx hashes to be downloaded. */ downloadQueue;
|
|
20
|
-
/** Worker promises for concurrent downloads. */ workers;
|
|
21
|
-
/** Whether the collection has been started. */ started;
|
|
22
|
-
constructor(fileStoreSources, txCollectionSink, log = createLogger('p2p:file_store_tx_collection')){
|
|
23
|
-
this.fileStoreSources = fileStoreSources;
|
|
17
|
+
/** Map from tx hash string to entry for all pending downloads. */ entries;
|
|
18
|
+
/** Worker promises for the shared worker pool. */ workers;
|
|
19
|
+
/** Whether the worker pool is running. */ running;
|
|
20
|
+
/** Signal used to wake sleeping workers when new entries arrive or stop is called. */ wakeSignal;
|
|
21
|
+
constructor(sources, txCollectionSink, config, dateProvider = new DateProvider(), log = createLogger('p2p:file_store_tx_collection')){
|
|
22
|
+
this.sources = sources;
|
|
24
23
|
this.txCollectionSink = txCollectionSink;
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.dateProvider = dateProvider;
|
|
25
26
|
this.log = log;
|
|
26
|
-
this.
|
|
27
|
-
this.foundTxHashes = new Set();
|
|
28
|
-
this.downloadQueue = new FifoMemoryQueue();
|
|
27
|
+
this.entries = new Map();
|
|
29
28
|
this.workers = [];
|
|
30
|
-
this.
|
|
29
|
+
this.running = false;
|
|
30
|
+
this.wakeSignal = promiseWithResolvers();
|
|
31
31
|
}
|
|
32
|
-
/** Starts the
|
|
33
|
-
if (this.
|
|
34
|
-
this.log.debug('No file store sources configured
|
|
32
|
+
/** Starts the shared worker pool. */ start() {
|
|
33
|
+
if (this.sources.length === 0) {
|
|
34
|
+
this.log.debug('No file store sources configured');
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
for(let i = 0; i < FILE_STORE_DOWNLOAD_CONCURRENCY; i++){
|
|
41
|
-
this.workers.push(this.downloadQueue.process((txHash)=>this.processDownload(txHash)));
|
|
37
|
+
this.running = true;
|
|
38
|
+
for(let i = 0; i < this.config.workerCount; i++){
|
|
39
|
+
this.workers.push(this.workerLoop());
|
|
42
40
|
}
|
|
43
|
-
this.log.info(`Started file store tx collection with ${this.fileStoreSources.length} sources`, {
|
|
44
|
-
sources: this.fileStoreSources.map((s)=>s.getInfo()),
|
|
45
|
-
concurrency: FILE_STORE_DOWNLOAD_CONCURRENCY
|
|
46
|
-
});
|
|
47
41
|
}
|
|
48
|
-
/** Stops all
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
this.started = false;
|
|
53
|
-
this.downloadQueue.end();
|
|
42
|
+
/** Stops all workers and clears state. */ async stop() {
|
|
43
|
+
this.running = false;
|
|
44
|
+
this.wake();
|
|
54
45
|
await Promise.all(this.workers);
|
|
55
46
|
this.workers = [];
|
|
56
|
-
this.
|
|
57
|
-
this.foundTxHashes.clear();
|
|
47
|
+
this.entries.clear();
|
|
58
48
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
/** Adds entries to the shared map and wakes workers. */ startCollecting(txHashes, context, deadline) {
|
|
50
|
+
if (this.sources.length === 0 || txHashes.length === 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (+deadline <= this.dateProvider.now()) {
|
|
54
|
+
return;
|
|
63
55
|
}
|
|
64
|
-
}
|
|
65
|
-
/** Clears all pending state. Items already in the download queue will still be processed but won't be re-queued. */ clearPending() {
|
|
66
|
-
this.pendingTxs.clear();
|
|
67
|
-
this.foundTxHashes.clear();
|
|
68
|
-
}
|
|
69
|
-
/** Queue the given tx hashes for file store collection. */ startCollecting(txHashes, context) {
|
|
70
56
|
for (const txHash of txHashes){
|
|
71
57
|
const hashStr = txHash.toString();
|
|
72
|
-
if (!this.
|
|
73
|
-
this.
|
|
74
|
-
|
|
58
|
+
if (!this.entries.has(hashStr)) {
|
|
59
|
+
this.entries.set(hashStr, {
|
|
60
|
+
txHash: hashStr,
|
|
61
|
+
context,
|
|
62
|
+
deadline,
|
|
63
|
+
attempts: 0,
|
|
64
|
+
lastAttemptTime: 0,
|
|
65
|
+
nextSourceIndex: Math.floor(Math.random() * this.sources.length)
|
|
66
|
+
});
|
|
75
67
|
}
|
|
76
68
|
}
|
|
69
|
+
this.wake();
|
|
77
70
|
}
|
|
78
|
-
/**
|
|
71
|
+
/** Removes entries for txs that have been found elsewhere. */ foundTxs(txs) {
|
|
79
72
|
for (const tx of txs){
|
|
80
|
-
|
|
81
|
-
this.pendingTxs.delete(hashStr);
|
|
82
|
-
this.foundTxHashes.add(hashStr);
|
|
73
|
+
this.entries.delete(tx.getTxHash().toString());
|
|
83
74
|
}
|
|
84
75
|
}
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
const context = this.pendingTxs.get(hashStr);
|
|
88
|
-
// Skip if already found by another method
|
|
89
|
-
if (!context) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
await this.downloadTx(txHash, context);
|
|
93
|
-
this.pendingTxs.delete(hashStr);
|
|
76
|
+
/** Clears all pending entries. */ clearPending() {
|
|
77
|
+
this.entries.clear();
|
|
94
78
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
async workerLoop() {
|
|
80
|
+
while(this.running){
|
|
81
|
+
const action = this.getNextAction();
|
|
82
|
+
if (action.type === 'sleep') {
|
|
83
|
+
await action.promise;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const entry = action.entry;
|
|
87
|
+
const source = this.sources[entry.nextSourceIndex % this.sources.length];
|
|
88
|
+
entry.nextSourceIndex++;
|
|
89
|
+
entry.attempts++;
|
|
90
|
+
entry.lastAttemptTime = this.dateProvider.now();
|
|
99
91
|
try {
|
|
100
|
-
const result = await this.txCollectionSink.collect((
|
|
101
|
-
|
|
92
|
+
const result = await this.txCollectionSink.collect(()=>source.getTxsByHash([
|
|
93
|
+
TxHash.fromString(entry.txHash)
|
|
94
|
+
]), [
|
|
95
|
+
entry.txHash
|
|
102
96
|
], {
|
|
103
97
|
description: `file-store ${source.getInfo()}`,
|
|
104
98
|
method: 'file-store',
|
|
105
99
|
fileStore: source.getInfo()
|
|
106
|
-
}, context);
|
|
100
|
+
}, entry.context);
|
|
107
101
|
if (result.txs.length > 0) {
|
|
108
|
-
|
|
102
|
+
this.entries.delete(entry.txHash);
|
|
109
103
|
}
|
|
110
104
|
} catch (err) {
|
|
111
|
-
this.log.trace(`
|
|
105
|
+
this.log.trace(`Error downloading tx ${entry.txHash} from ${source.getInfo()}`, {
|
|
112
106
|
err
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
|
|
110
|
+
}
|
|
111
|
+
/** Single-pass scan: removes expired entries, finds the best ready entry, or computes sleep time. */ getNextAction() {
|
|
112
|
+
const now = this.dateProvider.now();
|
|
113
|
+
let best;
|
|
114
|
+
let earliestReadyAt = Infinity;
|
|
115
|
+
for (const [key, entry] of this.entries){
|
|
116
|
+
if (+entry.deadline <= now) {
|
|
117
|
+
this.entries.delete(key);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const backoffMs = this.getBackoffMs(entry);
|
|
121
|
+
const readyAt = entry.lastAttemptTime + backoffMs;
|
|
122
|
+
if (readyAt > now) {
|
|
123
|
+
earliestReadyAt = Math.min(earliestReadyAt, readyAt);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!best || entry.attempts < best.attempts) {
|
|
127
|
+
best = entry;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (best) {
|
|
131
|
+
return {
|
|
132
|
+
type: 'process',
|
|
133
|
+
entry: best
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (earliestReadyAt < Infinity) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'sleep',
|
|
139
|
+
promise: this.sleepOrWake(earliestReadyAt - now)
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
type: 'sleep',
|
|
144
|
+
promise: this.waitForWake()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** Computes backoff for an entry. Backoff applies after a full cycle through all sources. */ getBackoffMs(entry) {
|
|
148
|
+
const fullCycles = Math.floor(entry.attempts / this.sources.length);
|
|
149
|
+
if (fullCycles === 0) {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
return Math.min(this.config.backoffBaseMs * Math.pow(2, fullCycles - 1), this.config.backoffMaxMs);
|
|
153
|
+
}
|
|
154
|
+
/** Resolves the current wake signal and creates a new one. */ wake() {
|
|
155
|
+
this.wakeSignal.resolve();
|
|
156
|
+
this.wakeSignal = promiseWithResolvers();
|
|
157
|
+
}
|
|
158
|
+
/** Waits until the wake signal is resolved. */ async waitForWake() {
|
|
159
|
+
await this.wakeSignal.promise;
|
|
160
|
+
}
|
|
161
|
+
/** Sleeps for the given duration or until the wake signal is resolved. */ async sleepOrWake(ms) {
|
|
162
|
+
await Promise.race([
|
|
163
|
+
sleep(ms),
|
|
164
|
+
this.wakeSignal.promise
|
|
165
|
+
]);
|
|
117
166
|
}
|
|
118
167
|
}
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
2
|
+
import { type TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import type { TxSource, TxSourceCollectionResult } from './tx_source.js';
|
|
4
5
|
/** TxSource implementation that downloads txs from a file store. */
|
|
5
6
|
export declare class FileStoreTxSource implements TxSource {
|
|
6
7
|
private readonly fileStore;
|
|
7
8
|
private readonly baseUrl;
|
|
9
|
+
private readonly basePath;
|
|
8
10
|
private readonly log;
|
|
11
|
+
private downloadsSuccess;
|
|
12
|
+
private downloadsFailed;
|
|
13
|
+
private downloadDuration;
|
|
14
|
+
private downloadSize;
|
|
9
15
|
private constructor();
|
|
10
16
|
/**
|
|
11
17
|
* Creates a FileStoreTxSource from a URL.
|
|
12
18
|
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
19
|
+
* @param basePath - Base path for tx files within the store.
|
|
13
20
|
* @param log - Optional logger.
|
|
21
|
+
* @param telemetry - Optional telemetry client.
|
|
14
22
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
15
23
|
*/
|
|
16
|
-
static create(url: string, log?: Logger): Promise<FileStoreTxSource | undefined>;
|
|
24
|
+
static create(url: string, basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource | undefined>;
|
|
17
25
|
getInfo(): string;
|
|
18
|
-
getTxsByHash(txHashes: TxHash[]): Promise<
|
|
26
|
+
getTxsByHash(txHashes: TxHash[]): Promise<TxSourceCollectionResult>;
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
29
|
* Creates FileStoreTxSource instances from URLs.
|
|
22
30
|
* @param urls - Array of file store URLs.
|
|
31
|
+
* @param basePath - Base path for tx files within each store.
|
|
23
32
|
* @param log - Optional logger.
|
|
33
|
+
* @param telemetry - Optional telemetry client.
|
|
24
34
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
25
35
|
*/
|
|
26
|
-
export declare function createFileStoreTxSources(urls: string[], log?: Logger): Promise<FileStoreTxSource[]>;
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
36
|
+
export declare function createFileStoreTxSources(urls: string[], basePath: string, log?: Logger, telemetry?: TelemetryClient): Promise<FileStoreTxSource[]>;
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9zdG9yZV90eF9zb3VyY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9jb2xsZWN0aW9uL2ZpbGVfc3RvcmVfdHhfc291cmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRSxPQUFPLEVBQU0sS0FBSyxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNuRCxPQUFPLEVBR0wsS0FBSyxlQUFlLEVBR3JCLE1BQU0seUJBQXlCLENBQUM7QUFFakMsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLHdCQUF3QixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFekUsb0VBQW9FO0FBQ3BFLHFCQUFhLGlCQUFrQixZQUFXLFFBQVE7SUFPOUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsT0FBTztJQUN4QixPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVE7SUFDekIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBVHRCLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBZ0I7SUFDeEMsT0FBTyxDQUFDLGVBQWUsQ0FBZ0I7SUFDdkMsT0FBTyxDQUFDLGdCQUFnQixDQUFZO0lBQ3BDLE9BQU8sQ0FBQyxZQUFZLENBQVk7SUFFaEMsT0FBTyxlQVlOO0lBRUQ7Ozs7Ozs7T0FPRztJQUNILE9BQW9CLE1BQU0sQ0FDeEIsR0FBRyxFQUFFLE1BQU0sRUFDWCxRQUFRLEVBQUUsTUFBTSxFQUNoQixHQUFHLEdBQUUsTUFBaUQsRUFDdEQsU0FBUyxHQUFFLGVBQXNDLEdBQ2hELE9BQU8sQ0FBQyxpQkFBaUIsR0FBRyxTQUFTLENBQUMsQ0FZeEM7SUFFTSxPQUFPLElBQUksTUFBTSxDQUV2QjtJQUVZLFlBQVksQ0FBQyxRQUFRLEVBQUUsTUFBTSxFQUFFLEdBQUcsT0FBTyxDQUFDLHdCQUF3QixDQUFDLENBK0IvRTtDQUNGO0FBRUQ7Ozs7Ozs7R0FPRztBQUNILHdCQUFzQix3QkFBd0IsQ0FDNUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxFQUNkLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLEdBQUcsR0FBRSxNQUFpRCxFQUN0RCxTQUFTLEdBQUUsZUFBc0MsR0FDaEQsT0FBTyxDQUFDLGlCQUFpQixFQUFFLENBQUMsQ0FHOUIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file_store_tx_source.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"file_store_tx_source.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/file_store_tx_source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAM,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,oEAAoE;AACpE,qBAAa,iBAAkB,YAAW,QAAQ;IAO9C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATtB,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,eAAe,CAAgB;IACvC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,YAAY,CAAY;IAEhC,OAAO,eAYN;IAED;;;;;;;OAOG;IACH,OAAoB,MAAM,CACxB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,MAAiD,EACtD,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAYxC;IAEM,OAAO,IAAI,MAAM,CAEvB;IAEY,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA+B/E;CACF;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,GAAE,MAAiD,EACtD,SAAS,GAAE,eAAsC,GAChD,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAG9B"}
|
|
@@ -1,28 +1,43 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
3
|
import { createReadOnlyFileStore } from '@aztec/stdlib/file-store';
|
|
3
4
|
import { Tx } from '@aztec/stdlib/tx';
|
|
5
|
+
import { Metrics, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
6
|
/** TxSource implementation that downloads txs from a file store. */ export class FileStoreTxSource {
|
|
5
7
|
fileStore;
|
|
6
8
|
baseUrl;
|
|
9
|
+
basePath;
|
|
7
10
|
log;
|
|
8
|
-
|
|
11
|
+
downloadsSuccess;
|
|
12
|
+
downloadsFailed;
|
|
13
|
+
downloadDuration;
|
|
14
|
+
downloadSize;
|
|
15
|
+
constructor(fileStore, baseUrl, basePath, log, telemetry){
|
|
9
16
|
this.fileStore = fileStore;
|
|
10
17
|
this.baseUrl = baseUrl;
|
|
18
|
+
this.basePath = basePath;
|
|
11
19
|
this.log = log;
|
|
20
|
+
const meter = telemetry.getMeter('file-store-tx-source');
|
|
21
|
+
this.downloadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_SUCCESS);
|
|
22
|
+
this.downloadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_DOWNLOADS_FAILED);
|
|
23
|
+
this.downloadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_DURATION);
|
|
24
|
+
this.downloadSize = meter.createHistogram(Metrics.TX_FILE_STORE_DOWNLOAD_SIZE);
|
|
12
25
|
}
|
|
13
26
|
/**
|
|
14
27
|
* Creates a FileStoreTxSource from a URL.
|
|
15
28
|
* @param url - The file store URL (s3://, gs://, file://, http://, https://).
|
|
29
|
+
* @param basePath - Base path for tx files within the store.
|
|
16
30
|
* @param log - Optional logger.
|
|
31
|
+
* @param telemetry - Optional telemetry client.
|
|
17
32
|
* @returns The FileStoreTxSource instance, or undefined if creation fails.
|
|
18
|
-
*/ static async create(url, log = createLogger('p2p:file_store_tx_source')) {
|
|
33
|
+
*/ static async create(url, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
19
34
|
try {
|
|
20
35
|
const fileStore = await createReadOnlyFileStore(url, log);
|
|
21
36
|
if (!fileStore) {
|
|
22
37
|
log.warn(`Failed to create file store for URL: ${url}`);
|
|
23
38
|
return undefined;
|
|
24
39
|
}
|
|
25
|
-
return new FileStoreTxSource(fileStore, url, log);
|
|
40
|
+
return new FileStoreTxSource(fileStore, url, basePath, log, telemetry);
|
|
26
41
|
} catch (err) {
|
|
27
42
|
log.warn(`Error creating file store for URL: ${url}`, {
|
|
28
43
|
error: err
|
|
@@ -33,25 +48,43 @@ import { Tx } from '@aztec/stdlib/tx';
|
|
|
33
48
|
getInfo() {
|
|
34
49
|
return `file-store:${this.baseUrl}`;
|
|
35
50
|
}
|
|
36
|
-
getTxsByHash(txHashes) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
async getTxsByHash(txHashes) {
|
|
52
|
+
const invalidTxHashes = [];
|
|
53
|
+
return {
|
|
54
|
+
validTxs: (await Promise.all(txHashes.map(async (txHash)=>{
|
|
55
|
+
const path = `${this.basePath}/txs/${txHash.toString()}.bin`;
|
|
56
|
+
const timer = new Timer();
|
|
57
|
+
try {
|
|
58
|
+
const buffer = await this.fileStore.read(path);
|
|
59
|
+
const tx = Tx.fromBuffer(buffer);
|
|
60
|
+
if (await tx.validateTxHash() && txHash.equals(tx.txHash)) {
|
|
61
|
+
this.downloadsSuccess.add(1);
|
|
62
|
+
this.downloadDuration.record(Math.ceil(timer.ms()));
|
|
63
|
+
this.downloadSize.record(buffer.length);
|
|
64
|
+
return tx;
|
|
65
|
+
} else {
|
|
66
|
+
invalidTxHashes.push(tx.txHash.toString());
|
|
67
|
+
this.downloadsFailed.add(1);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
// Tx not found or error reading - return undefined
|
|
72
|
+
this.downloadsFailed.add(1);
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}))).filter((tx)=>tx !== undefined),
|
|
76
|
+
invalidTxHashes: invalidTxHashes
|
|
77
|
+
};
|
|
47
78
|
}
|
|
48
79
|
}
|
|
49
80
|
/**
|
|
50
81
|
* Creates FileStoreTxSource instances from URLs.
|
|
51
82
|
* @param urls - Array of file store URLs.
|
|
83
|
+
* @param basePath - Base path for tx files within each store.
|
|
52
84
|
* @param log - Optional logger.
|
|
85
|
+
* @param telemetry - Optional telemetry client.
|
|
53
86
|
* @returns Array of successfully created FileStoreTxSource instances.
|
|
54
|
-
*/ export async function createFileStoreTxSources(urls, log = createLogger('p2p:file_store_tx_source')) {
|
|
55
|
-
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, log)));
|
|
87
|
+
*/ export async function createFileStoreTxSources(urls, basePath, log = createLogger('p2p:file_store_tx_source'), telemetry = getTelemetryClient()) {
|
|
88
|
+
const sources = await Promise.all(urls.map((url)=>FileStoreTxSource.create(url, basePath, log, telemetry)));
|
|
56
89
|
return sources.filter((s)=>s !== undefined);
|
|
57
90
|
}
|
|
@@ -7,4 +7,4 @@ export declare class TxCollectionInstrumentation {
|
|
|
7
7
|
constructor(client: TelemetryClient, name: string);
|
|
8
8
|
increaseTxsFor(what: CollectionMethod, count: number, duration: number): void;
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9pbnN0cnVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUlMLEtBQUssZUFBZSxFQUdyQixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFM0QscUJBQWEsMkJBQTJCO0lBQ3RDLE9BQU8sQ0FBQyxZQUFZLENBQWdCO0lBQ3BDLE9BQU8sQ0FBQyx1QkFBdUIsQ0FBWTtJQUMzQyxPQUFPLENBQUMsNEJBQTRCLENBQVk7SUFFaEQsWUFBWSxNQUFNLEVBQUUsZUFBZSxFQUFFLElBQUksRUFBRSxNQUFNLEVBZ0JoRDtJQUVELGNBQWMsQ0FBQyxJQUFJLEVBQUUsZ0JBQWdCLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxRQUFRLEVBQUUsTUFBTSxRQUtyRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,uBAAuB,CAAY;IAC3C,OAAO,CAAC,4BAA4B,CAAY;IAEhD,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,qBAAa,2BAA2B;IACtC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,uBAAuB,CAAY;IAC3C,OAAO,CAAC,4BAA4B,CAAY;IAEhD,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAgBhD;IAED,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAKrE;CACF"}
|
|
@@ -10,7 +10,8 @@ export class TxCollectionInstrumentation {
|
|
|
10
10
|
'fast-req-resp',
|
|
11
11
|
'fast-node-rpc',
|
|
12
12
|
'slow-req-resp',
|
|
13
|
-
'slow-node-rpc'
|
|
13
|
+
'slow-node-rpc',
|
|
14
|
+
'file-store'
|
|
14
15
|
]
|
|
15
16
|
});
|
|
16
17
|
this.collectionDurationPerTx = meter.createHistogram(Metrics.TX_COLLECTOR_DURATION_PER_TX);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
/**
|
|
4
|
+
* Tracks which transactions are still missing and need to be fetched.
|
|
5
|
+
* Allows external code to mark transactions as fetched, enabling coordination
|
|
6
|
+
* between multiple fetching mechanisms (e.g., BatchTxRequester and Rpc Node requests).
|
|
7
|
+
*/
|
|
8
|
+
export interface IMissingTxsTracker {
|
|
9
|
+
/** Returns the set of transaction hashes that are still missing. */
|
|
10
|
+
get missingTxHashes(): Set<string>;
|
|
11
|
+
/** Size of this.missingTxHashes */
|
|
12
|
+
get numberOfMissingTxs(): number;
|
|
13
|
+
/** Are all requested txs are fetched */
|
|
14
|
+
allFetched(): boolean;
|
|
15
|
+
/** Checks that transaction is still missing */
|
|
16
|
+
isMissing(txHash: string): boolean;
|
|
17
|
+
/** Marks a transaction as fetched. Returns true if it was previously missing. */
|
|
18
|
+
markFetched(tx: Tx): boolean;
|
|
19
|
+
/** Get list of collected txs */
|
|
20
|
+
get collectedTxs(): Tx[];
|
|
21
|
+
}
|
|
22
|
+
export declare class MissingTxsTracker implements IMissingTxsTracker {
|
|
23
|
+
readonly missingTxHashes: Set<string>;
|
|
24
|
+
readonly collectedTxs: Tx[];
|
|
25
|
+
private constructor();
|
|
26
|
+
static fromArray(hashes: TxHash[] | string[]): MissingTxsTracker;
|
|
27
|
+
markFetched(tx: Tx): boolean;
|
|
28
|
+
get numberOfMissingTxs(): number;
|
|
29
|
+
allFetched(): boolean;
|
|
30
|
+
isMissing(txHash: string): boolean;
|
|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,IAAI,MAAM,CAE/B;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class MissingTxsTracker {
|
|
2
|
+
missingTxHashes;
|
|
3
|
+
collectedTxs;
|
|
4
|
+
constructor(missingTxHashes){
|
|
5
|
+
this.missingTxHashes = missingTxHashes;
|
|
6
|
+
this.collectedTxs = [];
|
|
7
|
+
}
|
|
8
|
+
static fromArray(hashes) {
|
|
9
|
+
return new MissingTxsTracker(new Set(hashes.map((hash)=>hash.toString())));
|
|
10
|
+
}
|
|
11
|
+
markFetched(tx) {
|
|
12
|
+
if (this.missingTxHashes.delete(tx.txHash.toString())) {
|
|
13
|
+
this.collectedTxs.push(tx);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
get numberOfMissingTxs() {
|
|
19
|
+
return this.missingTxHashes.size;
|
|
20
|
+
}
|
|
21
|
+
allFetched() {
|
|
22
|
+
return this.numberOfMissingTxs === 0;
|
|
23
|
+
}
|
|
24
|
+
isMissing(txHash) {
|
|
25
|
+
return this.missingTxHashes.has(txHash.toString());
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import type
|
|
3
|
+
import { type Tx } from '@aztec/stdlib/tx';
|
|
4
4
|
import type { PeerId } from '@libp2p/interface';
|
|
5
5
|
import type { BatchTxRequesterConfig } from '../reqresp/batch-tx-requester/config.js';
|
|
6
6
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
7
7
|
import type { IBatchRequestTxValidator } from '../reqresp/batch-tx-requester/tx_validator.js';
|
|
8
8
|
import { type BlockTxsSource } from '../reqresp/index.js';
|
|
9
|
+
import type { IMissingTxsTracker } from './missing_txs_tracker.js';
|
|
9
10
|
/**
|
|
10
11
|
* Strategy interface for collecting missing transactions for a block or proposal.
|
|
11
12
|
* Allows swapping between different tx collection implementations for benchmarking.
|
|
@@ -13,13 +14,13 @@ import { type BlockTxsSource } from '../reqresp/index.js';
|
|
|
13
14
|
export interface MissingTxsCollector {
|
|
14
15
|
/**
|
|
15
16
|
* Collect missing transactions for a block or proposal.
|
|
16
|
-
* @param
|
|
17
|
+
* @param missingTxsTracker - The missing transactions tracker
|
|
17
18
|
* @param blockTxsSource - The block or proposal containing the transactions
|
|
18
19
|
* @param pinnedPeer - Optional peer expected to have the transactions
|
|
19
20
|
* @param timeoutMs - Timeout in milliseconds
|
|
20
21
|
* @returns The collected transactions
|
|
21
22
|
*/
|
|
22
|
-
collectTxs(
|
|
23
|
+
collectTxs(missingTxsTracker: IMissingTxsTracker, blockTxsSource: BlockTxsSource, pinnedPeer: PeerId | undefined, timeoutMs: number): Promise<Tx[]>;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Collects transactions using the BatchTxRequester implementation.
|
|
@@ -32,7 +33,7 @@ export declare class BatchTxRequesterCollector implements MissingTxsCollector {
|
|
|
32
33
|
private txValidator?;
|
|
33
34
|
private batchTxRequesterConfig?;
|
|
34
35
|
constructor(p2pService: BatchTxRequesterLibP2PService, log: Logger, dateProvider: DateProvider, txValidator?: IBatchRequestTxValidator | undefined, batchTxRequesterConfig?: Partial<BatchTxRequesterConfig> | undefined);
|
|
35
|
-
collectTxs(
|
|
36
|
+
collectTxs(missingTxsTracker: IMissingTxsTracker, blockTxsSource: BlockTxsSource, pinnedPeer: PeerId | undefined, timeoutMs: number): Promise<Tx[]>;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Collects transactions using the sendBatchRequest implementation from ReqResp.
|
|
@@ -43,6 +44,6 @@ export declare class SendBatchRequestCollector implements MissingTxsCollector {
|
|
|
43
44
|
private maxPeers;
|
|
44
45
|
private maxRetryAttempts;
|
|
45
46
|
constructor(p2pService: BatchTxRequesterLibP2PService, maxPeers?: number, maxRetryAttempts?: number);
|
|
46
|
-
collectTxs(
|
|
47
|
+
collectTxs(missingTxsTracker: IMissingTxsTracker, _blockTxsSource: BlockTxsSource, pinnedPeer: PeerId | undefined, timeoutMs: number): Promise<Tx[]>;
|
|
47
48
|
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdHhfY29sbGVjdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9wcm9wb3NhbF90eF9jb2xsZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDNUQsT0FBTyxFQUFFLEtBQUssRUFBRSxFQUFVLE1BQU0sa0JBQWtCLENBQUM7QUFFbkQsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFHaEQsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQUN0RixPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFBRSxNQUFNLDRDQUE0QyxDQUFDO0FBQ2hHLE9BQU8sS0FBSyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sK0NBQStDLENBQUM7QUFDOUYsT0FBTyxFQUFFLEtBQUssY0FBYyxFQUE0QyxNQUFNLHFCQUFxQixDQUFDO0FBQ3BHLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sMEJBQT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JBQTZCLEVBQ3pDLFFBQVEsR0FBRSxNQUEwQixFQUNwQyxnQkFBZ0IsR0FBRSxNQUFtQyxFQUMzRDtJQUVFLFVBQVUsQ0FDZCxpQkFBaUIsRUFBRSxrQkFBa0IsRUFDckMsZUFBZSxFQUFFLGNBQWMsRUFDL0IsVUFBVSxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQzlCLFNBQVMsRUFBRSxNQUFNLEdBQ2hCLE9BQU8sQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQVdmO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_tx_collector.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/proposal_tx_collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"proposal_tx_collector.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/proposal_tx_collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,EAAU,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAChG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,KAAK,cAAc,EAA4C,MAAM,qBAAqB,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;G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ch_tx_requester.js';
|
|
2
3
|
import { ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
|
|
3
4
|
/**
|
|
@@ -16,9 +17,9 @@ import { ReqRespSubProtocol, chunkTxHashesRequest } from '../reqresp/index.js';
|
|
|
16
17
|
this.txValidator = txValidator;
|
|
17
18
|
this.batchTxRequesterConfig = batchTxRequesterConfig;
|
|
18
19
|
}
|
|
19
|
-
async collectTxs(
|
|
20
|
+
async collectTxs(missingTxsTracker, blockTxsSource, pinnedPeer, timeoutMs) {
|
|
20
21
|
const { batchTxRequesterSmartParallelWorkerCount: smartParallelWorkerCount, batchTxRequesterDumbParallelWorkerCount: dumbParallelWorkerCount, batchTxRequesterTxBatchSize: txBatchSize, batchTxRequesterBadPeerThreshold: badPeerThreshold } = this.batchTxRequesterConfig ?? {};
|
|
21
|
-
const batchRequester = new BatchTxRequester(
|
|
22
|
+
const batchRequester = new BatchTxRequester(missingTxsTracker, blockTxsSource, pinnedPeer, timeoutMs, this.p2pService, this.log, this.dateProvider, {
|
|
22
23
|
smartParallelWorkerCount,
|
|
23
24
|
dumbParallelWorkerCount,
|
|
24
25
|
txBatchSize,
|
|
@@ -42,8 +43,8 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 3;
|
|
|
42
43
|
this.maxPeers = maxPeers;
|
|
43
44
|
this.maxRetryAttempts = maxRetryAttempts;
|
|
44
45
|
}
|
|
45
|
-
async collectTxs(
|
|
46
|
-
const txs = await this.p2pService.reqResp.sendBatchRequest(ReqRespSubProtocol.TX, chunkTxHashesRequest(
|
|
46
|
+
async collectTxs(missingTxsTracker, _blockTxsSource, pinnedPeer, timeoutMs) {
|
|
47
|
+
const txs = await this.p2pService.reqResp.sendBatchRequest(ReqRespSubProtocol.TX, chunkTxHashesRequest(Array.from(missingTxsTracker.missingTxHashes).map(TxHash.fromString)), pinnedPeer, timeoutMs, this.maxPeers, this.maxRetryAttempts);
|
|
47
48
|
return txs.flat();
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
4
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
6
6
|
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
7
|
-
import { type ReqRespInterface } from '../reqresp/
|
|
7
|
+
import { type ReqRespInterface } from '../reqresp/index.js';
|
|
8
8
|
import type { TxCollectionConfig } from './config.js';
|
|
9
9
|
import type { FastTxCollection } from './fast_tx_collection.js';
|
|
10
10
|
import type { TxCollectionSink } from './tx_collection_sink.js';
|
|
@@ -52,4 +52,6 @@ export declare class SlowTxCollection {
|
|
|
52
52
|
/** Computes the proof submission deadline for a given slot, a tx mined in this slot is no longer interesting after this deadline */
|
|
53
53
|
private getDeadlineForSlot;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
/** Computes the proof submission deadline for a given slot. A tx mined in this slot is no longer interesting after this deadline. */
|
|
56
|
+
export declare function getProofDeadlineForSlot(slotNumber: SlotNumber, constants: L1RollupConstants): Date;
|
|
57
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xvd190eF9jb2xsZWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfY29sbGVjdGlvbi9zbG93X3R4X2NvbGxlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBZSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUV2RixPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQ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