@aztec/p2p 0.0.1-commit.a072138 → 0.0.1-commit.aada20e3
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 +3 -1
- package/dest/client/p2p_client.d.ts +4 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +6 -2
- package/dest/config.d.ts +8 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +3 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +119 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +90 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +89 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +131 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +91 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +70 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +63 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +5 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +4 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +193 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +71 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +94 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +55 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +150 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +69 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +1041 -0
- package/dest/services/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/tx_file_store/config.d.ts +18 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +26 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +47 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +149 -0
- package/package.json +14 -14
- package/src/client/factory.ts +4 -0
- package/src/client/p2p_client.ts +5 -0
- package/src/config.ts +8 -1
- package/src/mem_pools/tx_pool_v2/README.md +188 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +147 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +118 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +111 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +23 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +164 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +86 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +72 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +11 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +225 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +160 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +209 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1265 -0
- package/src/services/index.ts +1 -0
- package/src/services/tx_file_store/config.ts +43 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +173 -0
package/dest/services/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export * from './libp2p/libp2p_service.js';
|
|
|
3
3
|
export * from './tx_provider.js';
|
|
4
4
|
export * from './dummy_service.js';
|
|
5
5
|
export * from './reqresp/index.js';
|
|
6
|
+
export * from './tx_file_store/index.js';
|
|
6
7
|
export * from './tx_collection/index.js';
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXJ2aWNlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLDRCQUE0QixDQUFDO0FBQzNDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMsMEJBQTBCLENBQUM7QUFDekMsY0FBYywwQkFBMEIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
|
package/dest/services/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for the TxFileStore service.
|
|
4
|
+
*/
|
|
5
|
+
export type TxFileStoreConfig = {
|
|
6
|
+
/** URL for uploading txs to file storage (s3://, gs://, file://) */
|
|
7
|
+
txFileStoreUrl?: string;
|
|
8
|
+
/** URL for downloading txs from file storage */
|
|
9
|
+
txFileStoreDownloadUrl?: string;
|
|
10
|
+
/** Max concurrent uploads */
|
|
11
|
+
txFileStoreUploadConcurrency: number;
|
|
12
|
+
/** Max queue size to prevent unbounded memory growth */
|
|
13
|
+
txFileStoreMaxQueueSize: number;
|
|
14
|
+
/** Enable tx file store upload */
|
|
15
|
+
txFileStoreEnabled: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const txFileStoreConfigMappings: ConfigMappingsType<TxFileStoreConfig>;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfZmlsZV9zdG9yZS9jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssa0JBQWtCLEVBQTJDLE1BQU0sMEJBQTBCLENBQUM7QUFFNUc7O0dBRUc7QUFDSCxNQUFNLE1BQU0saUJBQWlCLEdBQUc7SUFDOUIsb0VBQW9FO0lBQ3BFLGNBQWMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN4QixnREFBZ0Q7SUFDaEQsc0JBQXNCLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDaEMsNkJBQTZCO0lBQzdCLDRCQUE0QixFQUFFLE1BQU0sQ0FBQztJQUNyQyx3REFBd0Q7SUFDeEQsdUJBQXVCLEVBQUUsTUFBTSxDQUFDO0lBQ2hDLGtDQUFrQztJQUNsQyxrQkFBa0IsRUFBRSxPQUFPLENBQUM7Q0FDN0IsQ0FBQztBQUVGLGVBQU8sTUFBTSx5QkFBeUIsRUFBRSxrQkFBa0IsQ0FBQyxpQkFBaUIsQ0F3QjNFLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/services/tx_file_store/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAA2C,MAAM,0BAA0B,CAAC;AAE5G;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,6BAA6B;IAC7B,4BAA4B,EAAE,MAAM,CAAC;IACrC,wDAAwD;IACxD,uBAAuB,EAAE,MAAM,CAAC;IAChC,kCAAkC;IAClC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,iBAAiB,CAwB3E,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { booleanConfigHelper, numberConfigHelper } from '@aztec/foundation/config';
|
|
2
|
+
export const txFileStoreConfigMappings = {
|
|
3
|
+
txFileStoreUrl: {
|
|
4
|
+
env: 'TX_FILE_STORE_URL',
|
|
5
|
+
description: 'URL for uploading txs to file storage (s3://, gs://, file://)'
|
|
6
|
+
},
|
|
7
|
+
txFileStoreDownloadUrl: {
|
|
8
|
+
env: 'TX_FILE_STORE_DOWNLOAD_URL',
|
|
9
|
+
description: 'URL for downloading txs from file storage'
|
|
10
|
+
},
|
|
11
|
+
txFileStoreUploadConcurrency: {
|
|
12
|
+
env: 'TX_FILE_STORE_UPLOAD_CONCURRENCY',
|
|
13
|
+
description: 'Maximum number of concurrent tx uploads',
|
|
14
|
+
...numberConfigHelper(10)
|
|
15
|
+
},
|
|
16
|
+
txFileStoreMaxQueueSize: {
|
|
17
|
+
env: 'TX_FILE_STORE_MAX_QUEUE_SIZE',
|
|
18
|
+
description: 'Maximum queue size for pending uploads (oldest dropped when exceeded)',
|
|
19
|
+
...numberConfigHelper(1000)
|
|
20
|
+
},
|
|
21
|
+
txFileStoreEnabled: {
|
|
22
|
+
env: 'TX_FILE_STORE_ENABLED',
|
|
23
|
+
description: 'Enable uploading transactions to file storage',
|
|
24
|
+
...booleanConfigHelper(false)
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { TxFileStore } from './tx_file_store.js';
|
|
2
|
+
export { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
3
|
+
export { type TxFileStoreConfig, txFileStoreConfigMappings } from './config.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zZXJ2aWNlcy90eF9maWxlX3N0b3JlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNqRCxPQUFPLEVBQUUsMEJBQTBCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRSxPQUFPLEVBQUUsS0FBSyxpQkFBaUIsRUFBRSx5QkFBeUIsRUFBRSxNQUFNLGFBQWEsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/tx_file_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,KAAK,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
|
+
/** Instrumentation for the TxFileStore service. */
|
|
3
|
+
export declare class TxFileStoreInstrumentation {
|
|
4
|
+
private uploadsSuccess;
|
|
5
|
+
private uploadsFailed;
|
|
6
|
+
private uploadsSkipped;
|
|
7
|
+
private uploadDuration;
|
|
8
|
+
private queueSize;
|
|
9
|
+
constructor(client: TelemetryClient, name: string);
|
|
10
|
+
recordUploadSuccess(durationMs: number): void;
|
|
11
|
+
recordUploadFailed(): void;
|
|
12
|
+
recordUploadSkipped(): void;
|
|
13
|
+
recordQueueSize(size: number): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5zdHJ1bWVudGF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvdHhfZmlsZV9zdG9yZS9pbnN0cnVtZW50YXRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUF1QyxLQUFLLGVBQWUsRUFBc0IsTUFBTSx5QkFBeUIsQ0FBQztBQUV4SCxtREFBbUQ7QUFDbkQscUJBQWEsMEJBQTBCO0lBQ3JDLE9BQU8sQ0FBQyxjQUFjLENBQWdCO0lBQ3RDLE9BQU8sQ0FBQyxhQUFhLENBQWdCO0lBQ3JDLE9BQU8sQ0FBQyxjQUFjLENBQWdCO0lBQ3RDLE9BQU8sQ0FBQyxjQUFjLENBQVk7SUFDbEMsT0FBTyxDQUFDLFNBQVMsQ0FBUTtJQUV6QixZQUFZLE1BQU0sRUFBRSxlQUFlLEVBQUUsSUFBSSxFQUFFLE1BQU0sRUFPaEQ7SUFFRCxtQkFBbUIsQ0FBQyxVQUFVLEVBQUUsTUFBTSxRQUdyQztJQUVELGtCQUFrQixTQUVqQjtJQUVELG1CQUFtQixTQUVsQjtJQUVELGVBQWUsQ0FBQyxJQUFJLEVBQUUsTUFBTSxRQUUzQjtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/tx_file_store/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAExH,mDAAmD;AACnD,qBAAa,0BAA0B;IACrC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,cAAc,CAAY;IAClC,OAAO,CAAC,SAAS,CAAQ;IAEzB,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAOhD;IAED,mBAAmB,CAAC,UAAU,EAAE,MAAM,QAGrC;IAED,kBAAkB,SAEjB;IAED,mBAAmB,SAElB;IAED,eAAe,CAAC,IAAI,EAAE,MAAM,QAE3B;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Metrics } from '@aztec/telemetry-client';
|
|
2
|
+
/** Instrumentation for the TxFileStore service. */ export class TxFileStoreInstrumentation {
|
|
3
|
+
uploadsSuccess;
|
|
4
|
+
uploadsFailed;
|
|
5
|
+
uploadsSkipped;
|
|
6
|
+
uploadDuration;
|
|
7
|
+
queueSize;
|
|
8
|
+
constructor(client, name){
|
|
9
|
+
const meter = client.getMeter(name);
|
|
10
|
+
this.uploadsSuccess = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SUCCESS);
|
|
11
|
+
this.uploadsFailed = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_FAILED);
|
|
12
|
+
this.uploadsSkipped = meter.createUpDownCounter(Metrics.TX_FILE_STORE_UPLOADS_SKIPPED);
|
|
13
|
+
this.uploadDuration = meter.createHistogram(Metrics.TX_FILE_STORE_UPLOAD_DURATION);
|
|
14
|
+
this.queueSize = meter.createGauge(Metrics.TX_FILE_STORE_QUEUE_SIZE);
|
|
15
|
+
}
|
|
16
|
+
recordUploadSuccess(durationMs) {
|
|
17
|
+
this.uploadsSuccess.add(1);
|
|
18
|
+
this.uploadDuration.record(durationMs);
|
|
19
|
+
}
|
|
20
|
+
recordUploadFailed() {
|
|
21
|
+
this.uploadsFailed.add(1);
|
|
22
|
+
}
|
|
23
|
+
recordUploadSkipped() {
|
|
24
|
+
this.uploadsSkipped.add(1);
|
|
25
|
+
}
|
|
26
|
+
recordQueueSize(size) {
|
|
27
|
+
this.queueSize.record(size);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { type FileStore } from '@aztec/stdlib/file-store';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import type { TxPool } from '../../mem_pools/tx_pool/index.js';
|
|
5
|
+
import type { TxFileStoreConfig } from './config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Uploads validated transactions to a file store as a fallback retrieval mechanism.
|
|
8
|
+
* Listens to TxPool txs-added events and uploads txs asynchronously with bounded concurrency.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TxFileStore {
|
|
11
|
+
private readonly fileStore;
|
|
12
|
+
private readonly txPool;
|
|
13
|
+
private readonly config;
|
|
14
|
+
private readonly instrumentation;
|
|
15
|
+
private readonly log;
|
|
16
|
+
private uploadQueue;
|
|
17
|
+
private activeUploads;
|
|
18
|
+
private readonly queueProcessor;
|
|
19
|
+
private readonly handleTxsAdded;
|
|
20
|
+
/** Recently uploaded tx hashes for deduplication. */
|
|
21
|
+
private recentUploads;
|
|
22
|
+
private recentUploadsOrder;
|
|
23
|
+
private readonly maxRecentUploads;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Creates and initializes the file store.
|
|
27
|
+
* @param txPool - The transaction pool to listen to.
|
|
28
|
+
* @param config - The file store configuration.
|
|
29
|
+
* @param log - Optional logger.
|
|
30
|
+
* @param telemetry - Optional telemetry client.
|
|
31
|
+
* @param fileStoreOverride - Optional FileStore for testing (bypasses createFileStore).
|
|
32
|
+
* @returns The file store instance, or undefined if not configured/enabled.
|
|
33
|
+
*/
|
|
34
|
+
static create(txPool: TxPool, config: TxFileStoreConfig, log?: Logger, telemetry?: TelemetryClient, fileStoreOverride?: FileStore): Promise<TxFileStore | undefined>;
|
|
35
|
+
/** Starts listening to TxPool events and uploading txs. */
|
|
36
|
+
start(): void;
|
|
37
|
+
/** Stops listening and waits for pending uploads to complete. */
|
|
38
|
+
stop(): Promise<void>;
|
|
39
|
+
private enqueueTxs;
|
|
40
|
+
private processQueueBatch;
|
|
41
|
+
private uploadTx;
|
|
42
|
+
/** Waits for all queued and in-flight uploads to complete. For testing. */
|
|
43
|
+
flush(): Promise<void>;
|
|
44
|
+
/** Returns the number of pending uploads (queued + in-flight). */
|
|
45
|
+
getPendingUploadCount(): number;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZmlsZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NlcnZpY2VzL3R4X2ZpbGVfc3RvcmUvdHhfZmlsZV9zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFJbEUsT0FBTyxFQUFFLEtBQUssU0FBUyxFQUFtQixNQUFNLDBCQUEwQixDQUFDO0FBRTNFLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBc0IsTUFBTSx5QkFBeUIsQ0FBQztBQUVuRixPQUFPLEtBQUssRUFBRSxNQUFNLEVBQWdCLE1BQU0sa0NBQWtDLENBQUM7QUFDN0UsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFHckQ7OztHQUdHO0FBQ0gscUJBQWEsV0FBVztJQVlwQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxNQUFNO0lBQ3ZCLE9BQU8sQ0FBQyxRQUFRLENBQUMsTUFBTTtJQUN2QixPQUFPLENBQUMsUUFBUSxDQUFDLGVBQWU7SUFDaEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBZnRCLE9BQU8sQ0FBQyxXQUFXLENBQVk7SUFDL0IsT0FBTyxDQUFDLGFBQWEsQ0FBSztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGNBQWMsQ0FBaUI7SUFDaEQsT0FBTyxDQUFDLFFBQVEsQ0FBQyxjQUFjLENBQTRCO0lBRTNELHFEQUFxRDtJQUNyRCxPQUFPLENBQUMsYUFBYSxDQUEwQjtJQUMvQyxPQUFPLENBQUMsa0JBQWtCLENBQWdCO0lBQzFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsZ0JBQWdCLENBQVE7SUFFekMsT0FBTyxlQVdOO0lBRUQ7Ozs7Ozs7O09BUUc7SUFDSCxPQUFhLE1BQU0sQ0FDakIsTUFBTSxFQUFFLE1BQU0sRUFDZCxNQUFNLEVBQUUsaUJBQWlCLEVBQ3pCLEdBQUcsR0FBRSxNQUEwQyxFQUMvQyxTQUFTLEdBQUUsZUFBc0MsRUFDakQsaUJBQWlCLENBQUMsRUFBRSxTQUFTLEdBQzVCLE9BQU8sQ0FBQyxXQUFXLEdBQUcsU0FBUyxDQUFDLENBb0JsQztJQUVELDJEQUEyRDtJQUNwRCxLQUFLLElBQUksSUFBSSxDQU9uQjtJQUVELGlFQUFpRTtJQUNwRCxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUlqQztJQUVELE9BQU8sQ0FBQyxVQUFVO1lBZ0JKLGlCQUFpQjtZQVlqQixRQUFRO0lBdUN0QiwyRUFBMkU7SUFDOUQsS0FBSyxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FJbEM7SUFFRCxrRUFBa0U7SUFDM0QscUJBQXFCLElBQUksTUFBTSxDQUVyQztDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tx_file_store.d.ts","sourceRoot":"","sources":["../../../src/services/tx_file_store/tx_file_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD;;;GAGG;AACH,qBAAa,WAAW;IAYpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG;IAftB,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAE3D,qDAAqD;IACrD,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,kBAAkB,CAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IAEzC,OAAO,eAWN;IAED;;;;;;;;OAQG;IACH,OAAa,MAAM,CACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,iBAAiB,EACzB,GAAG,GAAE,MAA0C,EAC/C,SAAS,GAAE,eAAsC,EACjD,iBAAiB,CAAC,EAAE,SAAS,GAC5B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAoBlC;IAED,2DAA2D;IACpD,KAAK,IAAI,IAAI,CAOnB;IAED,iEAAiE;IACpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAIjC;IAED,OAAO,CAAC,UAAU;YAgBJ,iBAAiB;YAYjB,QAAQ;IAuCtB,2EAA2E;IAC9D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAIlC;IAED,kEAAkE;IAC3D,qBAAqB,IAAI,MAAM,CAErC;CACF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/promise';
|
|
3
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
4
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import { createFileStore } from '@aztec/stdlib/file-store';
|
|
6
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
7
|
+
import { TxFileStoreInstrumentation } from './instrumentation.js';
|
|
8
|
+
/**
|
|
9
|
+
* Uploads validated transactions to a file store as a fallback retrieval mechanism.
|
|
10
|
+
* Listens to TxPool txs-added events and uploads txs asynchronously with bounded concurrency.
|
|
11
|
+
*/ export class TxFileStore {
|
|
12
|
+
fileStore;
|
|
13
|
+
txPool;
|
|
14
|
+
config;
|
|
15
|
+
instrumentation;
|
|
16
|
+
log;
|
|
17
|
+
uploadQueue;
|
|
18
|
+
activeUploads;
|
|
19
|
+
queueProcessor;
|
|
20
|
+
handleTxsAdded;
|
|
21
|
+
/** Recently uploaded tx hashes for deduplication. */ recentUploads;
|
|
22
|
+
recentUploadsOrder;
|
|
23
|
+
maxRecentUploads;
|
|
24
|
+
constructor(fileStore, txPool, config, instrumentation, log){
|
|
25
|
+
this.fileStore = fileStore;
|
|
26
|
+
this.txPool = txPool;
|
|
27
|
+
this.config = config;
|
|
28
|
+
this.instrumentation = instrumentation;
|
|
29
|
+
this.log = log;
|
|
30
|
+
this.uploadQueue = [];
|
|
31
|
+
this.activeUploads = 0;
|
|
32
|
+
this.recentUploads = new Set();
|
|
33
|
+
this.recentUploadsOrder = [];
|
|
34
|
+
this.maxRecentUploads = 1000;
|
|
35
|
+
this.handleTxsAdded = (args)=>{
|
|
36
|
+
this.enqueueTxs(args.txs);
|
|
37
|
+
};
|
|
38
|
+
this.queueProcessor = new RunningPromise(()=>this.processQueueBatch(), this.log, 100);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates and initializes the file store.
|
|
42
|
+
* @param txPool - The transaction pool to listen to.
|
|
43
|
+
* @param config - The file store configuration.
|
|
44
|
+
* @param log - Optional logger.
|
|
45
|
+
* @param telemetry - Optional telemetry client.
|
|
46
|
+
* @param fileStoreOverride - Optional FileStore for testing (bypasses createFileStore).
|
|
47
|
+
* @returns The file store instance, or undefined if not configured/enabled.
|
|
48
|
+
*/ static async create(txPool, config, log = createLogger('p2p:tx_file_store'), telemetry = getTelemetryClient(), fileStoreOverride) {
|
|
49
|
+
if (!config.txFileStoreEnabled) {
|
|
50
|
+
log.debug('Tx file store is disabled');
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
if (!config.txFileStoreUrl) {
|
|
54
|
+
log.warn('Tx file store is enabled but URL is not configured');
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const fileStore = fileStoreOverride ?? await createFileStore(config.txFileStoreUrl, log);
|
|
58
|
+
if (!fileStore) {
|
|
59
|
+
log.warn('Failed to create file store for tx file store');
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const instrumentation = new TxFileStoreInstrumentation(telemetry, 'TxFileStore');
|
|
63
|
+
log.info('Created tx file store', {
|
|
64
|
+
url: config.txFileStoreUrl
|
|
65
|
+
});
|
|
66
|
+
return new TxFileStore(fileStore, txPool, config, instrumentation, log);
|
|
67
|
+
}
|
|
68
|
+
/** Starts listening to TxPool events and uploading txs. */ start() {
|
|
69
|
+
this.queueProcessor.start();
|
|
70
|
+
this.txPool.on('txs-added', this.handleTxsAdded);
|
|
71
|
+
this.log.info('Started tx file store', {
|
|
72
|
+
concurrency: this.config.txFileStoreUploadConcurrency,
|
|
73
|
+
maxQueueSize: this.config.txFileStoreMaxQueueSize
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Stops listening and waits for pending uploads to complete. */ async stop() {
|
|
77
|
+
this.txPool.removeListener('txs-added', this.handleTxsAdded);
|
|
78
|
+
await this.queueProcessor.stop();
|
|
79
|
+
this.log.info('Stopped tx file store');
|
|
80
|
+
}
|
|
81
|
+
enqueueTxs(txs) {
|
|
82
|
+
this.uploadQueue.push(...txs);
|
|
83
|
+
// Enforce max queue size by dropping oldest entries
|
|
84
|
+
const overflow = this.uploadQueue.length - this.config.txFileStoreMaxQueueSize;
|
|
85
|
+
if (overflow > 0) {
|
|
86
|
+
this.log.warn(`Upload queue overflow, dropping ${overflow} oldest txs`);
|
|
87
|
+
this.uploadQueue.splice(0, overflow);
|
|
88
|
+
}
|
|
89
|
+
this.instrumentation.recordQueueSize(this.uploadQueue.length);
|
|
90
|
+
// Immediately start uploading txs
|
|
91
|
+
void this.queueProcessor.trigger();
|
|
92
|
+
}
|
|
93
|
+
async processQueueBatch() {
|
|
94
|
+
const batch = this.uploadQueue.splice(0, this.config.txFileStoreUploadConcurrency);
|
|
95
|
+
this.instrumentation.recordQueueSize(this.uploadQueue.length);
|
|
96
|
+
this.activeUploads += batch.length;
|
|
97
|
+
try {
|
|
98
|
+
await Promise.all(batch.map((tx)=>this.uploadTx(tx)));
|
|
99
|
+
} finally{
|
|
100
|
+
this.activeUploads -= batch.length;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async uploadTx(tx) {
|
|
104
|
+
const txHash = tx.getTxHash().toString();
|
|
105
|
+
const path = `txs/${txHash}.bin`;
|
|
106
|
+
const timer = new Timer();
|
|
107
|
+
if (this.recentUploads.has(txHash)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
this.recentUploads.add(txHash);
|
|
112
|
+
this.recentUploadsOrder.push(txHash);
|
|
113
|
+
if (this.recentUploadsOrder.length > this.maxRecentUploads) {
|
|
114
|
+
// delete old entries in recentUploads
|
|
115
|
+
for (const txHashToRemove of this.recentUploadsOrder.splice(0, this.recentUploadsOrder.length - this.maxRecentUploads)){
|
|
116
|
+
this.recentUploads.delete(txHashToRemove);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
await retry(()=>this.fileStore.save(path, tx.toBuffer(), {
|
|
120
|
+
compress: false
|
|
121
|
+
}), `Uploading tx ${txHash}`, makeBackoff([
|
|
122
|
+
0.1,
|
|
123
|
+
0.5,
|
|
124
|
+
2
|
|
125
|
+
]), this.log, true);
|
|
126
|
+
const durationMs = Math.trunc(timer.ms());
|
|
127
|
+
this.log.debug(`Uploaded tx to file store`, {
|
|
128
|
+
txHash,
|
|
129
|
+
path,
|
|
130
|
+
durationMs
|
|
131
|
+
});
|
|
132
|
+
this.instrumentation.recordUploadSuccess(durationMs);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
this.log.warn(`Failed to upload tx to file store after retries`, {
|
|
135
|
+
txHash,
|
|
136
|
+
error: err
|
|
137
|
+
});
|
|
138
|
+
this.instrumentation.recordUploadFailed();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Waits for all queued and in-flight uploads to complete. For testing. */ async flush() {
|
|
142
|
+
while(this.uploadQueue.length > 0 || this.activeUploads > 0){
|
|
143
|
+
await this.queueProcessor.trigger();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Returns the number of pending uploads (queued + in-flight). */ getPendingUploadCount() {
|
|
147
|
+
return this.uploadQueue.length + this.activeUploads;
|
|
148
|
+
}
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/p2p",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.aada20e3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
]
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@aztec/constants": "0.0.1-commit.
|
|
71
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
72
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
73
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
74
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
70
|
+
"@aztec/constants": "0.0.1-commit.aada20e3",
|
|
71
|
+
"@aztec/epoch-cache": "0.0.1-commit.aada20e3",
|
|
72
|
+
"@aztec/ethereum": "0.0.1-commit.aada20e3",
|
|
73
|
+
"@aztec/foundation": "0.0.1-commit.aada20e3",
|
|
74
|
+
"@aztec/kv-store": "0.0.1-commit.aada20e3",
|
|
75
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.aada20e3",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.aada20e3",
|
|
77
|
+
"@aztec/protocol-contracts": "0.0.1-commit.aada20e3",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.aada20e3",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.aada20e3",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.aada20e3",
|
|
81
81
|
"@chainsafe/libp2p-gossipsub": "13.0.0",
|
|
82
82
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
83
83
|
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"xxhash-wasm": "^1.1.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
108
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
107
|
+
"@aztec/archiver": "0.0.1-commit.aada20e3",
|
|
108
|
+
"@aztec/world-state": "0.0.1-commit.aada20e3",
|
|
109
109
|
"@jest/globals": "^30.0.0",
|
|
110
110
|
"@types/jest": "^30.0.0",
|
|
111
111
|
"@types/node": "^22.15.17",
|
package/src/client/factory.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { DummyP2PService } from '../services/dummy_service.js';
|
|
|
21
21
|
import { LibP2PService } from '../services/index.js';
|
|
22
22
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
23
23
|
import { type TxSource, createNodeRpcTxSources } from '../services/tx_collection/tx_source.js';
|
|
24
|
+
import { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
24
25
|
import { configureP2PClientAddresses, createLibP2PPeerIdFromPrivateKey, getPeerIdPrivateKey } from '../util.js';
|
|
25
26
|
|
|
26
27
|
export type P2PClientDeps<T extends P2PClientType> = {
|
|
@@ -116,6 +117,8 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
116
117
|
logger.createChild('tx-collection'),
|
|
117
118
|
);
|
|
118
119
|
|
|
120
|
+
const txFileStore = await TxFileStore.create(mempools.txPool, config, logger.createChild('tx-file-store'), telemetry);
|
|
121
|
+
|
|
119
122
|
return new P2PClient(
|
|
120
123
|
clientType,
|
|
121
124
|
store,
|
|
@@ -123,6 +126,7 @@ export async function createP2PClient<T extends P2PClientType>(
|
|
|
123
126
|
mempools,
|
|
124
127
|
p2pService,
|
|
125
128
|
txCollection,
|
|
129
|
+
txFileStore,
|
|
126
130
|
config,
|
|
127
131
|
dateProvider,
|
|
128
132
|
telemetry,
|
package/src/client/p2p_client.ts
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
import { chunkTxHashesRequest } from '../services/reqresp/protocols/tx.js';
|
|
42
42
|
import type { P2PBlockReceivedCallback, P2PCheckpointReceivedCallback, P2PService } from '../services/service.js';
|
|
43
43
|
import { TxCollection } from '../services/tx_collection/tx_collection.js';
|
|
44
|
+
import type { TxFileStore } from '../services/tx_file_store/tx_file_store.js';
|
|
44
45
|
import { TxProvider } from '../services/tx_provider.js';
|
|
45
46
|
import { type P2P, P2PClientState, type P2PSyncState } from './interface.js';
|
|
46
47
|
|
|
@@ -90,6 +91,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
90
91
|
mempools: MemPools,
|
|
91
92
|
private p2pService: P2PService,
|
|
92
93
|
private txCollection: TxCollection,
|
|
94
|
+
private txFileStore: TxFileStore | undefined,
|
|
93
95
|
config: Partial<P2PConfig> = {},
|
|
94
96
|
private _dateProvider: DateProvider = new DateProvider(),
|
|
95
97
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
@@ -274,6 +276,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
274
276
|
|
|
275
277
|
this.blockStream!.start();
|
|
276
278
|
await this.txCollection.start();
|
|
279
|
+
this.txFileStore?.start();
|
|
277
280
|
return this.syncPromise;
|
|
278
281
|
}
|
|
279
282
|
|
|
@@ -306,6 +309,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
306
309
|
this.log.debug('Stopping p2p client...');
|
|
307
310
|
await tryStop(this.txCollection);
|
|
308
311
|
this.log.debug('Stopped tx collection service');
|
|
312
|
+
await this.txFileStore?.stop();
|
|
313
|
+
this.log.debug('Stopped tx file store');
|
|
309
314
|
await this.p2pService.stop();
|
|
310
315
|
this.log.debug('Stopped p2p service');
|
|
311
316
|
await this.blockStream?.stop();
|
package/src/config.ts
CHANGED
|
@@ -21,11 +21,17 @@ import {
|
|
|
21
21
|
} from './services/reqresp/batch-tx-requester/config.js';
|
|
22
22
|
import { type P2PReqRespConfig, p2pReqRespConfigMappings } from './services/reqresp/config.js';
|
|
23
23
|
import { type TxCollectionConfig, txCollectionConfigMappings } from './services/tx_collection/config.js';
|
|
24
|
+
import { type TxFileStoreConfig, txFileStoreConfigMappings } from './services/tx_file_store/config.js';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* P2P client configuration values.
|
|
27
28
|
*/
|
|
28
|
-
export interface P2PConfig
|
|
29
|
+
export interface P2PConfig
|
|
30
|
+
extends P2PReqRespConfig,
|
|
31
|
+
BatchTxRequesterConfig,
|
|
32
|
+
ChainConfig,
|
|
33
|
+
TxCollectionConfig,
|
|
34
|
+
TxFileStoreConfig {
|
|
29
35
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
30
36
|
p2pEnabled: boolean;
|
|
31
37
|
|
|
@@ -439,6 +445,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
439
445
|
...batchTxRequesterConfigMappings,
|
|
440
446
|
...chainConfigMappings,
|
|
441
447
|
...txCollectionConfigMappings,
|
|
448
|
+
...txFileStoreConfigMappings,
|
|
442
449
|
};
|
|
443
450
|
|
|
444
451
|
/**
|