@aztec/p2p 0.0.1-commit.343b43af6 → 0.0.1-commit.35158ae7e
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/README.md +129 -3
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +20 -13
- package/dest/client/p2p_client.d.ts +1 -1
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +16 -10
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +3 -3
- package/dest/config.d.ts +7 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +10 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +3 -3
- package/dest/mem_pools/attestation_pool/attestation_pool.js +3 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +2 -1
- package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +2 -3
- 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 +2 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +7 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +9 -2
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +7 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- 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 +3 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- 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 +11 -4
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +4 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +5 -5
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +9 -1
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +23 -4
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +21 -1
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +28 -1
- package/dest/services/discv5/discV5_service.d.ts +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +4 -2
- package/dest/services/encoding.d.ts +5 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -1
- package/dest/services/libp2p/libp2p_service.d.ts +7 -9
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +121 -57
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +4 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
- 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 +69 -65
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- 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 +17 -9
- package/dest/services/service.d.ts +7 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +6 -1
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +9 -1
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +20 -2
- package/dest/testbench/p2p_client_testbench_worker.js +3 -3
- package/dest/util.d.ts +8 -3
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +2 -9
- package/package.json +14 -14
- package/src/client/factory.ts +35 -18
- package/src/client/p2p_client.ts +19 -10
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +3 -5
- package/src/config.ts +17 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +3 -3
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool/priority.ts +2 -5
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +6 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +11 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +13 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +12 -4
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
- package/src/msg_validators/clock_tolerance.ts +4 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +6 -5
- package/src/msg_validators/tx_validator/README.md +5 -1
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +28 -1
- package/src/msg_validators/tx_validator/phases_validator.ts +31 -1
- package/src/services/discv5/discV5_service.ts +4 -2
- package/src/services/encoding.ts +9 -1
- package/src/services/libp2p/libp2p_service.ts +122 -69
- package/src/services/peer-manager/peer_manager.ts +5 -2
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
- package/src/services/reqresp/reqresp.ts +19 -11
- package/src/services/service.ts +7 -0
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +9 -0
- package/src/test-helpers/testbench-utils.ts +28 -3
- package/src/testbench/p2p_client_testbench_worker.ts +3 -5
- package/src/util.ts +8 -12
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
|
@@ -196,7 +196,7 @@ export class SlowTxCollection {
|
|
|
196
196
|
// from mined unproven blocks it has seen in the past.
|
|
197
197
|
const fastRequests = this.fastCollection.getFastCollectionRequests();
|
|
198
198
|
const fastCollectionTxs: Set<string> = new Set(
|
|
199
|
-
fastRequests.values().flatMap(r => Array.from(r.
|
|
199
|
+
fastRequests.values().flatMap(r => Array.from(r.requestTracker.missingTxHashes)),
|
|
200
200
|
);
|
|
201
201
|
|
|
202
202
|
// Return all missing txs that are not in fastCollectionTxs and are ready for reqresp if requested
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { compactArray } from '@aztec/foundation/collection';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
4
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
7
7
|
import type { L2Block, L2BlockInfo } from '@aztec/stdlib/block';
|
|
@@ -19,7 +19,7 @@ import type { TxCollectionConfig } from './config.js';
|
|
|
19
19
|
import { FastTxCollection } from './fast_tx_collection.js';
|
|
20
20
|
import { FileStoreTxCollection } from './file_store_tx_collection.js';
|
|
21
21
|
import type { FileStoreTxSource } from './file_store_tx_source.js';
|
|
22
|
-
import type {
|
|
22
|
+
import type { IRequestTracker } from './request_tracker.js';
|
|
23
23
|
import { SlowTxCollection, getProofDeadlineForSlot } from './slow_tx_collection.js';
|
|
24
24
|
import { type TxAddContext, TxCollectionSink } from './tx_collection_sink.js';
|
|
25
25
|
import type { TxSource } from './tx_source.js';
|
|
@@ -33,10 +33,8 @@ export type FastCollectionRequestInput =
|
|
|
33
33
|
| { type: 'proposal'; blockProposal: BlockProposal; blockNumber: BlockNumber };
|
|
34
34
|
|
|
35
35
|
export type FastCollectionRequest = FastCollectionRequestInput & {
|
|
36
|
-
|
|
37
|
-
deadline: Date;
|
|
36
|
+
requestTracker: IRequestTracker;
|
|
38
37
|
blockInfo: L2BlockInfo;
|
|
39
|
-
promise: PromiseWithResolvers<void>;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
/**
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type TopicValidatorResult,
|
|
16
16
|
TypedEventEmitter,
|
|
17
17
|
} from '@libp2p/interface';
|
|
18
|
+
import type { AddressManager, ConnectionManager } from '@libp2p/interface-internal';
|
|
18
19
|
|
|
19
20
|
import type { P2PConfig } from '../config.js';
|
|
20
21
|
import type { MemPools } from '../mem_pools/interface.js';
|
|
@@ -212,6 +213,14 @@ export class MockPubSub implements PubSubLibp2p {
|
|
|
212
213
|
get services() {
|
|
213
214
|
return {
|
|
214
215
|
pubsub: this.gossipSub,
|
|
216
|
+
components: {
|
|
217
|
+
addressManager: {
|
|
218
|
+
removeObservedAddr: () => {},
|
|
219
|
+
addObservedAddr: () => {},
|
|
220
|
+
confirmObservedAddr: () => {},
|
|
221
|
+
} as unknown as AddressManager,
|
|
222
|
+
connectionManager: {} as unknown as ConnectionManager,
|
|
223
|
+
},
|
|
215
224
|
};
|
|
216
225
|
}
|
|
217
226
|
|
|
@@ -273,17 +273,41 @@ export class InMemoryAttestationPool {
|
|
|
273
273
|
* Creates a mock EpochCache for testing.
|
|
274
274
|
*/
|
|
275
275
|
export function createMockEpochCache(): EpochCacheInterface {
|
|
276
|
-
|
|
276
|
+
const cache: EpochCacheInterface = {
|
|
277
277
|
getCommittee: () => Promise.resolve({ committee: [], seed: 1n, epoch: EpochNumber.ZERO, isEscapeHatchOpen: false }),
|
|
278
278
|
getProposerIndexEncoding: () => '0x' as `0x${string}`,
|
|
279
|
-
|
|
279
|
+
getSlotNow: () => SlotNumber.ZERO,
|
|
280
|
+
getTargetSlot: () => SlotNumber.ZERO,
|
|
281
|
+
getEpochNow: () => EpochNumber.ZERO,
|
|
282
|
+
getTargetEpoch: () => EpochNumber.ZERO,
|
|
283
|
+
getEpochAndSlotNow: () => ({
|
|
284
|
+
epoch: EpochNumber.ZERO,
|
|
285
|
+
slot: SlotNumber.ZERO,
|
|
286
|
+
ts: 0n,
|
|
287
|
+
nowMs: 0n,
|
|
288
|
+
}),
|
|
289
|
+
isProposerPipeliningEnabled: () => false,
|
|
280
290
|
computeProposerIndex: () => 0n,
|
|
281
291
|
getCurrentAndNextSlot: () => ({ currentSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
292
|
+
getTargetAndNextSlot: () => ({ targetSlot: SlotNumber.ZERO, nextSlot: SlotNumber.ZERO }),
|
|
282
293
|
getProposerAttesterAddressInSlot: () => Promise.resolve(undefined),
|
|
283
|
-
getEpochAndSlotInNextL1Slot: () => ({
|
|
294
|
+
getEpochAndSlotInNextL1Slot: () => ({
|
|
295
|
+
epoch: EpochNumber.ZERO,
|
|
296
|
+
slot: SlotNumber.ZERO,
|
|
297
|
+
ts: 0n,
|
|
298
|
+
nowSeconds: 0n,
|
|
299
|
+
}),
|
|
300
|
+
getTargetEpochAndSlotInNextL1Slot: () => ({
|
|
301
|
+
epoch: EpochNumber.ZERO,
|
|
302
|
+
slot: SlotNumber.ZERO,
|
|
303
|
+
ts: 0n,
|
|
304
|
+
nowSeconds: 0n,
|
|
305
|
+
}),
|
|
284
306
|
isInCommittee: () => Promise.resolve(false),
|
|
285
307
|
getRegisteredValidators: () => Promise.resolve([]),
|
|
286
308
|
filterInCommittee: () => Promise.resolve([]),
|
|
309
|
+
isEscapeHatchOpen: () => Promise.resolve(false),
|
|
310
|
+
isEscapeHatchOpenAtSlot: () => Promise.resolve(false),
|
|
287
311
|
getL1Constants: () => ({
|
|
288
312
|
l1StartBlock: 0n,
|
|
289
313
|
l1GenesisTime: 0n,
|
|
@@ -295,6 +319,7 @@ export function createMockEpochCache(): EpochCacheInterface {
|
|
|
295
319
|
rollupManaLimit: Number.MAX_SAFE_INTEGER,
|
|
296
320
|
}),
|
|
297
321
|
};
|
|
322
|
+
return cache;
|
|
298
323
|
}
|
|
299
324
|
|
|
300
325
|
/**
|
|
@@ -40,7 +40,7 @@ import type { IBatchRequestTxValidator } from '../services/reqresp/batch-tx-requ
|
|
|
40
40
|
import { RateLimitStatus } from '../services/reqresp/rate-limiter/rate_limiter.js';
|
|
41
41
|
import type { ReqResp } from '../services/reqresp/reqresp.js';
|
|
42
42
|
import type { PeerDiscoveryService } from '../services/service.js';
|
|
43
|
-
import {
|
|
43
|
+
import { RequestTracker } from '../services/tx_collection/request_tracker.js';
|
|
44
44
|
import { AlwaysTrueCircuitVerifier } from '../test-helpers/index.js';
|
|
45
45
|
import {
|
|
46
46
|
BENCHMARK_CONSTANTS,
|
|
@@ -273,10 +273,9 @@ async function runAggregatorBenchmark(
|
|
|
273
273
|
noopTxValidator,
|
|
274
274
|
);
|
|
275
275
|
const fetchedTxs = await collector.collectTxs(
|
|
276
|
-
|
|
276
|
+
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
277
277
|
blockProposal,
|
|
278
278
|
pinnedPeer,
|
|
279
|
-
timeoutMs,
|
|
280
279
|
);
|
|
281
280
|
const durationMs = timer.ms();
|
|
282
281
|
return {
|
|
@@ -293,10 +292,9 @@ async function runAggregatorBenchmark(
|
|
|
293
292
|
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
294
293
|
);
|
|
295
294
|
const fetchedTxs = await collector.collectTxs(
|
|
296
|
-
|
|
295
|
+
RequestTracker.create(txHashes, new Date(Date.now() + timeoutMs)),
|
|
297
296
|
blockProposal,
|
|
298
297
|
pinnedPeer,
|
|
299
|
-
timeoutMs,
|
|
300
298
|
);
|
|
301
299
|
const durationMs = timer.ms();
|
|
302
300
|
return {
|
package/src/util.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { GossipSub } from '@chainsafe/libp2p-gossipsub';
|
|
|
7
7
|
import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey } from '@libp2p/crypto/keys';
|
|
8
8
|
import type { Identify } from '@libp2p/identify';
|
|
9
9
|
import type { PeerId, PrivateKey } from '@libp2p/interface';
|
|
10
|
-
import type { ConnectionManager } from '@libp2p/interface-internal';
|
|
10
|
+
import type { AddressManager, ConnectionManager } from '@libp2p/interface-internal';
|
|
11
11
|
import { createFromPrivKey } from '@libp2p/peer-id-factory';
|
|
12
12
|
import { resolve } from 'dns/promises';
|
|
13
13
|
import { promises as fs } from 'fs';
|
|
@@ -31,6 +31,10 @@ export interface PubSubLibp2p extends Pick<Libp2p, 'status' | 'start' | 'stop' |
|
|
|
31
31
|
| 'direct'
|
|
32
32
|
| 'getMeshPeers'
|
|
33
33
|
> & { score: Pick<GossipSub['score'], 'score'> };
|
|
34
|
+
components: {
|
|
35
|
+
connectionManager: ConnectionManager;
|
|
36
|
+
addressManager: AddressManager;
|
|
37
|
+
};
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -39,6 +43,7 @@ export type FullLibp2p = Libp2p<{
|
|
|
39
43
|
pubsub: GossipSub;
|
|
40
44
|
components: {
|
|
41
45
|
connectionManager: ConnectionManager;
|
|
46
|
+
addressManager: AddressManager;
|
|
42
47
|
};
|
|
43
48
|
}>;
|
|
44
49
|
|
|
@@ -102,24 +107,15 @@ function addressToMultiAddressType(address: string): 'ip4' | 'ip6' | 'dns' {
|
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
export
|
|
106
|
-
_config: P2PConfig & DataStoreConfig,
|
|
107
|
-
): Promise<P2PConfig & DataStoreConfig> {
|
|
110
|
+
export function configureP2PClientAddresses(_config: P2PConfig & DataStoreConfig): P2PConfig & DataStoreConfig {
|
|
108
111
|
const config = { ..._config };
|
|
109
|
-
const {
|
|
112
|
+
const { p2pBroadcastPort, p2pPort } = config;
|
|
110
113
|
|
|
111
114
|
// If no broadcast port is provided, use the given p2p port as the broadcast port
|
|
112
115
|
if (!p2pBroadcastPort) {
|
|
113
116
|
config.p2pBroadcastPort = p2pPort;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
// check if no announce IP was provided
|
|
117
|
-
if (!p2pIp) {
|
|
118
|
-
if (queryForIp) {
|
|
119
|
-
const publicIp = await getPublicIp();
|
|
120
|
-
config.p2pIp = publicIp;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
119
|
// TODO(md): guard against setting a local ip address as the announce ip
|
|
124
120
|
|
|
125
121
|
return config;
|
|
@@ -1,32 +0,0 @@
|
|
|
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;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlzc2luZ190eHNfdHJhY2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3R4X2NvbGxlY3Rpb24vbWlzc2luZ190eHNfdHJhY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDMUMsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFM0M7Ozs7R0FJRztBQUNILE1BQU0sV0FBVyxrQkFBa0I7SUFDakMsb0VBQW9FO0lBQ3BFLElBQUksZUFBZSxJQUFJLEdBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNuQyxtQ0FBbUM7SUFDbkMsSUFBSSxrQkFBa0IsSUFBSSxNQUFNLENBQUM7SUFDakMsd0NBQXdDO0lBQ3hDLFVBQVUsSUFBSSxPQUFPLENBQUM7SUFDdEIsK0NBQStDO0lBQy9DLFNBQVMsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQztJQUNuQyxpRkFBaUY7SUFDakYsV0FBVyxDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDO0lBQzdCLGdDQUFnQztJQUNoQyxJQUFJLFlBQVksSUFBSSxFQUFFLEVBQUUsQ0FBQztDQUMxQjtBQUVELHFCQUFhLGlCQUFrQixZQUFXLGtCQUFrQjthQUd0QixlQUFlLEVBQUUsR0FBRyxDQUFDLE1BQU0sQ0FBQztJQUZoRSxTQUFnQixZQUFZLEVBQUUsRUFBRSxFQUFFLENBQU07SUFFeEMsT0FBTyxlQUE2RDtJQUVwRSxPQUFjLFNBQVMsQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLEdBQUcsTUFBTSxFQUFFLHFCQUVsRDtJQUVELFdBQVcsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FNM0I7SUFFRCxJQUFJLGtCQUFrQixJQUFJLE1BQU0sQ0FFL0I7SUFFRCxVQUFVLElBQUksT0FBTyxDQUVwQjtJQUVELFNBQVMsQ0FBQyxNQUFNLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FFakM7Q0FDRiJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"missing_txs_tracker.d.ts","sourceRoot":"","sources":["../../../src/services/tx_collection/missing_txs_tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,IAAI,eAAe,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,mCAAmC;IACnC,IAAI,kBAAkB,IAAI,MAAM,CAAC;IACjC,wCAAwC;IACxC,UAAU,IAAI,OAAO,CAAC;IACtB,+CAA+C;IAC/C,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,iFAAiF;IACjF,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC;IAC7B,gCAAgC;IAChC,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;CAC1B;AAED,qBAAa,iBAAkB,YAAW,kBAAkB;aAGtB,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC;IAFhE,SAAgB,YAAY,EAAE,EAAE,EAAE,CAAM;IAExC,OAAO,eAA6D;IAEpE,OAAc,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,qBAElD;IAED,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAM3B;IAED,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED,UAAU,IAAI,OAAO,CAEpB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjC;CACF"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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,52 +0,0 @@
|
|
|
1
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
2
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Tracks which transactions are still missing and need to be fetched.
|
|
6
|
-
* Allows external code to mark transactions as fetched, enabling coordination
|
|
7
|
-
* between multiple fetching mechanisms (e.g., BatchTxRequester and Rpc Node requests).
|
|
8
|
-
*/
|
|
9
|
-
export interface IMissingTxsTracker {
|
|
10
|
-
/** Returns the set of transaction hashes that are still missing. */
|
|
11
|
-
get missingTxHashes(): Set<string>;
|
|
12
|
-
/** Size of this.missingTxHashes */
|
|
13
|
-
get numberOfMissingTxs(): number;
|
|
14
|
-
/** Are all requested txs are fetched */
|
|
15
|
-
allFetched(): boolean;
|
|
16
|
-
/** Checks that transaction is still missing */
|
|
17
|
-
isMissing(txHash: string): boolean;
|
|
18
|
-
/** Marks a transaction as fetched. Returns true if it was previously missing. */
|
|
19
|
-
markFetched(tx: Tx): boolean;
|
|
20
|
-
/** Get list of collected txs */
|
|
21
|
-
get collectedTxs(): Tx[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class MissingTxsTracker implements IMissingTxsTracker {
|
|
25
|
-
public readonly collectedTxs: Tx[] = [];
|
|
26
|
-
|
|
27
|
-
private constructor(public readonly missingTxHashes: Set<string>) {}
|
|
28
|
-
|
|
29
|
-
public static fromArray(hashes: TxHash[] | string[]) {
|
|
30
|
-
return new MissingTxsTracker(new Set(hashes.map(hash => hash.toString())));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
markFetched(tx: Tx): boolean {
|
|
34
|
-
if (this.missingTxHashes.delete(tx.txHash.toString())) {
|
|
35
|
-
this.collectedTxs.push(tx);
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get numberOfMissingTxs(): number {
|
|
42
|
-
return this.missingTxHashes.size;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
allFetched(): boolean {
|
|
46
|
-
return this.numberOfMissingTxs === 0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
isMissing(txHash: string): boolean {
|
|
50
|
-
return this.missingTxHashes.has(txHash.toString());
|
|
51
|
-
}
|
|
52
|
-
}
|