@aztec/p2p 0.0.1-commit.6d63667d → 0.0.1-commit.86469d5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +1 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +1 -3
- package/dest/client/p2p_client.d.ts +2 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +2 -6
- package/dest/config.d.ts +3 -9
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -3
- package/dest/services/index.d.ts +1 -2
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +0 -1
- package/dest/services/libp2p/libp2p_service.d.ts +4 -4
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +8 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +5 -6
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +11 -16
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +10 -15
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +11 -12
- package/dest/services/tx_collection/config.d.ts +3 -3
- package/dest/services/tx_collection/config.js +3 -3
- package/dest/services/tx_collection/fast_tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +14 -10
- package/dest/services/tx_collection/index.d.ts +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/package.json +14 -14
- package/src/client/factory.ts +0 -4
- package/src/client/p2p_client.ts +0 -5
- package/src/config.ts +1 -8
- package/src/services/index.ts +0 -1
- package/src/services/libp2p/libp2p_service.ts +8 -12
- package/src/services/reqresp/batch-tx-requester/README.md +7 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +14 -22
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +15 -21
- package/src/services/tx_collection/config.ts +6 -6
- package/src/services/tx_collection/fast_tx_collection.ts +24 -14
- package/src/services/tx_collection/index.ts +1 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +14 -12
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +0 -2
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/index.js +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +0 -43
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +0 -103
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +0 -47
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +0 -119
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +0 -90
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +0 -89
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +0 -10
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +0 -11
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +0 -131
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +0 -63
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +0 -91
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +0 -70
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +0 -20
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +0 -63
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +0 -15
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +0 -19
- package/dest/mem_pools/tx_pool_v2/index.d.ts +0 -5
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/index.js +0 -4
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +0 -197
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +0 -6
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +0 -71
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +0 -95
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +0 -26
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +0 -70
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +0 -99
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +0 -332
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +0 -55
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +0 -156
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +0 -69
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +0 -748
- package/dest/services/tx_file_store/config.d.ts +0 -18
- package/dest/services/tx_file_store/config.d.ts.map +0 -1
- package/dest/services/tx_file_store/config.js +0 -26
- package/dest/services/tx_file_store/index.d.ts +0 -4
- package/dest/services/tx_file_store/index.d.ts.map +0 -1
- package/dest/services/tx_file_store/index.js +0 -3
- package/dest/services/tx_file_store/instrumentation.d.ts +0 -15
- package/dest/services/tx_file_store/instrumentation.d.ts.map +0 -1
- package/dest/services/tx_file_store/instrumentation.js +0 -29
- package/dest/services/tx_file_store/tx_file_store.d.ts +0 -47
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +0 -1
- package/dest/services/tx_file_store/tx_file_store.js +0 -149
- package/src/mem_pools/tx_pool_v2/README.md +0 -209
- package/src/mem_pools/tx_pool_v2/archive/index.ts +0 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +0 -120
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +0 -147
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +0 -118
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +0 -111
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +0 -23
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +0 -164
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +0 -74
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +0 -101
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +0 -86
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +0 -72
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +0 -31
- package/src/mem_pools/tx_pool_v2/index.ts +0 -11
- package/src/mem_pools/tx_pool_v2/interfaces.ts +0 -227
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +0 -161
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +0 -77
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +0 -417
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +0 -212
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +0 -882
- package/src/services/tx_file_store/config.ts +0 -43
- package/src/services/tx_file_store/index.ts +0 -3
- package/src/services/tx_file_store/instrumentation.ts +0 -36
- package/src/services/tx_file_store/tx_file_store.ts +0 -173
|
@@ -1,18 +0,0 @@
|
|
|
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==
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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=
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
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=
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,149 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# TxPoolV2
|
|
2
|
-
|
|
3
|
-
Transaction pool implementation with explicit state management and pluggable eviction rules.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
TxPoolV2 manages transactions through a state machine with clear transitions:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
addPendingTxs()
|
|
11
|
-
│
|
|
12
|
-
▼
|
|
13
|
-
┌─────────────────────────────────────┐
|
|
14
|
-
│ PENDING │◄──────────────────┐
|
|
15
|
-
│ (awaiting block inclusion) │ │
|
|
16
|
-
└─────────────────────────────────────┘ │
|
|
17
|
-
│ │
|
|
18
|
-
│ protectTxs() / addProtectedTxs() │
|
|
19
|
-
▼ │
|
|
20
|
-
┌─────────────────────────────────────┐ │
|
|
21
|
-
│ PROTECTED │───────────────────┘
|
|
22
|
-
│ (in a block proposal) │ prepareForSlot()
|
|
23
|
-
└─────────────────────────────────────┘ (slot passed without mining)
|
|
24
|
-
│ │
|
|
25
|
-
│ handleMinedBlock() │
|
|
26
|
-
▼ │
|
|
27
|
-
┌─────────────────────────────────────┐ │
|
|
28
|
-
│ MINED │───────────────────┘
|
|
29
|
-
│ (included in a block) │ handlePrunedBlocks()
|
|
30
|
-
└─────────────────────────────────────┘ (reorg)
|
|
31
|
-
│
|
|
32
|
-
│ handleFinalizedBlock()
|
|
33
|
-
▼
|
|
34
|
-
┌─────────────────────────────────────┐
|
|
35
|
-
│ DELETED │
|
|
36
|
-
│ (optionally archived) │
|
|
37
|
-
└─────────────────────────────────────┘
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Key Components
|
|
41
|
-
|
|
42
|
-
### TxPoolV2 (`tx_pool_v2.ts`)
|
|
43
|
-
|
|
44
|
-
The public API wrapper that serializes all operations through a queue to prevent race conditions. Delegates to `TxPoolV2Impl` for actual logic.
|
|
45
|
-
|
|
46
|
-
### TxPoolV2Impl (`tx_pool_v2_impl.ts`)
|
|
47
|
-
|
|
48
|
-
Core implementation containing:
|
|
49
|
-
- KV store persistence for transactions and metadata
|
|
50
|
-
- In-memory indices for fast lookups (by nullifier, fee payer, priority)
|
|
51
|
-
- State transition logic
|
|
52
|
-
- Pre-add rule execution
|
|
53
|
-
- Post-event eviction rule execution
|
|
54
|
-
|
|
55
|
-
### TxMetaData (`tx_metadata.ts`)
|
|
56
|
-
|
|
57
|
-
Lightweight metadata stored alongside each transaction:
|
|
58
|
-
- `txHash`: Transaction identifier
|
|
59
|
-
- `anchorBlockHeaderHash`: Hash of the anchor block header
|
|
60
|
-
- `priorityFee`: For priority ordering and challenges
|
|
61
|
-
- `feePayer`: For balance-based eviction
|
|
62
|
-
- `claimAmount`: Fee payer's claim from bridging
|
|
63
|
-
- `feeLimit`: Maximum fee the tx can pay
|
|
64
|
-
- `nullifiers`: For conflict detection
|
|
65
|
-
- `includeByTimestamp`: Expiration timestamp
|
|
66
|
-
- `minedL2BlockId`: Set when mined (undefined otherwise)
|
|
67
|
-
|
|
68
|
-
State is derived by TxPoolIndices:
|
|
69
|
-
- `mined` if `minedL2BlockId` is set
|
|
70
|
-
- `protected` if in protection map
|
|
71
|
-
- `pending` otherwise
|
|
72
|
-
|
|
73
|
-
## Architecture: Pre-add vs Post-event Rules
|
|
74
|
-
|
|
75
|
-
**Pre-add rules** (run during `addPendingTxs`):
|
|
76
|
-
- Used for external transactions entering the pool
|
|
77
|
-
- Can reject the incoming tx entirely
|
|
78
|
-
- Can evict lower-priority existing txs to make room
|
|
79
|
-
- Rules: NullifierConflictRule, FeePayerBalancePreAddRule, LowPriorityPreAddRule
|
|
80
|
-
|
|
81
|
-
**Post-event rules** (run after state transitions):
|
|
82
|
-
- Used for internal state changes (block mined, reorg, slot change)
|
|
83
|
-
- Only evict txs already in the pool
|
|
84
|
-
- Rules: InvalidTxsAfterMiningRule, InvalidTxsAfterReorgRule, FeePayerBalanceEvictionRule, LowPriorityEvictionRule
|
|
85
|
-
|
|
86
|
-
This design choice means restored txs (from protected/mined states) use post-event rules only, because they were already validated on initial submission.
|
|
87
|
-
|
|
88
|
-
## Eviction Rules
|
|
89
|
-
|
|
90
|
-
The pool uses a pluggable rule system for managing transactions.
|
|
91
|
-
|
|
92
|
-
### Pre-Add Rules
|
|
93
|
-
|
|
94
|
-
Checked before adding a transaction to the pending pool:
|
|
95
|
-
|
|
96
|
-
| Rule | Purpose |
|
|
97
|
-
|------|---------|
|
|
98
|
-
| `NullifierConflictRule` | Handles transactions with conflicting nullifiers. Higher priority tx wins. |
|
|
99
|
-
| `FeePayerBalancePreAddRule` | Ensures fee payer has sufficient balance for all their pending txs. |
|
|
100
|
-
| `LowPriorityPreAddRule` | Rejects txs when pool is full and new tx has lowest priority. |
|
|
101
|
-
|
|
102
|
-
### Post-Event Eviction Rules
|
|
103
|
-
|
|
104
|
-
Run after events to clean up the pool:
|
|
105
|
-
|
|
106
|
-
| Rule | Trigger | Purpose |
|
|
107
|
-
|------|---------|---------|
|
|
108
|
-
| `LowPriorityEvictionRule` | `txs_added` | Evicts lowest priority txs when pool exceeds limit. |
|
|
109
|
-
| `FeePayerBalanceEvictionRule` | `txs_added`, `block_mined`, `chain_pruned` | Evicts txs when fee payer has insufficient balance. |
|
|
110
|
-
| `InvalidTxsAfterMiningRule` | `block_mined` | Evicts pending txs with: (1) nullifiers in mined block, (2) expired timestamp. |
|
|
111
|
-
| `InvalidTxsAfterReorgRule` | `chain_pruned` | Evicts txs with invalid anchor blocks after reorg. |
|
|
112
|
-
|
|
113
|
-
## Usage
|
|
114
|
-
|
|
115
|
-
### Creating a Pool
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import { AztecKVTxPoolV2 } from './tx_pool_v2.js';
|
|
119
|
-
|
|
120
|
-
const pool = new AztecKVTxPoolV2(txStore, archiveStore, {
|
|
121
|
-
l2BlockSource: archiver,
|
|
122
|
-
worldStateSynchronizer: worldState,
|
|
123
|
-
pendingTxValidator: validator,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
await pool.start();
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Adding Transactions
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
// Add to pending pool (validates and runs pre-add rules)
|
|
133
|
-
const result = await pool.addPendingTxs(txs, { source: 'gossip' });
|
|
134
|
-
// result: { accepted: TxHash[], ignored: TxHash[], rejected: TxHash[] }
|
|
135
|
-
|
|
136
|
-
// Check without modifying pool
|
|
137
|
-
const canAdd = await pool.canAddPendingTx(tx);
|
|
138
|
-
// canAdd: 'accepted' | 'ignored' | 'rejected'
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Block Building Flow
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
// 1. Proposer protects txs for their block
|
|
145
|
-
await pool.protectTxs(selectedTxHashes, blockHeader);
|
|
146
|
-
|
|
147
|
-
// 2. On successful mining
|
|
148
|
-
await pool.handleMinedBlock(minedTxHashes, blockHeader);
|
|
149
|
-
|
|
150
|
-
// 3. If slot passes without mining
|
|
151
|
-
await pool.prepareForSlot(nextSlotNumber);
|
|
152
|
-
|
|
153
|
-
// 4. On finalization
|
|
154
|
-
await pool.handleFinalizedBlock(finalizedBlockHeader);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Handling Reorgs
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
// When blocks are pruned, un-mine affected transactions
|
|
161
|
-
await pool.handlePrunedBlocks(latestValidBlockId);
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Configuration
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
await pool.updateConfig({
|
|
168
|
-
maxPendingTxCount: 10000, // 0 = unlimited
|
|
169
|
-
archivedTxLimit: 1000, // 0 = disabled
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Return Values
|
|
174
|
-
|
|
175
|
-
### AddTxsResult
|
|
176
|
-
|
|
177
|
-
When adding pending transactions, each tx is categorized:
|
|
178
|
-
|
|
179
|
-
| Status | Meaning |
|
|
180
|
-
|--------|---------|
|
|
181
|
-
| `accepted` | Successfully added to the pool |
|
|
182
|
-
| `ignored` | Valid but not added (duplicate, lost nullifier conflict, insufficient balance) |
|
|
183
|
-
| `rejected` | Failed validation (invalid proof, expired, etc.) |
|
|
184
|
-
|
|
185
|
-
## Archive
|
|
186
|
-
|
|
187
|
-
Finalized transactions can optionally be archived for historical queries:
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
const archivedTx = await pool.getArchivedTxByHash(txHash);
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
The archive uses FIFO eviction when `archivedTxLimit` is reached.
|
|
194
|
-
|
|
195
|
-
## Testing
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
# Unit tests (131 tests)
|
|
199
|
-
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.test.ts
|
|
200
|
-
|
|
201
|
-
# Compatibility tests (25 tests)
|
|
202
|
-
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2.compat.test.ts
|
|
203
|
-
|
|
204
|
-
# Eviction rule tests
|
|
205
|
-
yarn test src/mem_pools/tx_pool_v2/eviction/
|
|
206
|
-
|
|
207
|
-
# Benchmarks
|
|
208
|
-
yarn test src/mem_pools/tx_pool_v2/tx_pool_v2_bench.test.ts
|
|
209
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { TxArchive } from './tx_archive.js';
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
|
-
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
4
|
-
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Manages archived transactions with FIFO eviction.
|
|
8
|
-
* Archived transactions have their proofs stripped to save space.
|
|
9
|
-
*/
|
|
10
|
-
export class TxArchive {
|
|
11
|
-
#store: AztecAsyncKVStore;
|
|
12
|
-
#txs: AztecAsyncMap<string, Buffer>;
|
|
13
|
-
#indices: AztecAsyncMap<number, string>;
|
|
14
|
-
#limit: number;
|
|
15
|
-
#log: Logger;
|
|
16
|
-
|
|
17
|
-
constructor(store: AztecAsyncKVStore, limit: number, log?: Logger) {
|
|
18
|
-
this.#store = store;
|
|
19
|
-
this.#txs = store.openMap('archivedTxs');
|
|
20
|
-
this.#indices = store.openMap('archivedTxIndices');
|
|
21
|
-
this.#limit = limit;
|
|
22
|
-
this.#log = log ?? createLogger('p2p:tx_pool_v2:archive');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Updates the maximum number of archived transactions.
|
|
27
|
-
*/
|
|
28
|
-
updateLimit(limit: number): void {
|
|
29
|
-
this.#limit = limit;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Gets the current archive limit.
|
|
34
|
-
*/
|
|
35
|
-
getLimit(): number {
|
|
36
|
-
return this.#limit;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Checks if archiving is enabled.
|
|
41
|
-
*/
|
|
42
|
-
isEnabled(): boolean {
|
|
43
|
-
return this.#limit > 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Archives transactions, stripping their proofs.
|
|
48
|
-
* Evicts oldest transactions if the limit is exceeded.
|
|
49
|
-
*/
|
|
50
|
-
async archiveTxs(txs: Tx[]): Promise<void> {
|
|
51
|
-
if (!this.isEnabled() || txs.length === 0) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
await this.#store.transactionAsync(async () => {
|
|
57
|
-
// Get current head and tail indices
|
|
58
|
-
let headIdx = await this.getHeadIndex();
|
|
59
|
-
let tailIdx = await this.getTailIndex();
|
|
60
|
-
|
|
61
|
-
for (const tx of txs) {
|
|
62
|
-
// Evict oldest entries if at capacity
|
|
63
|
-
while (headIdx - tailIdx >= this.#limit) {
|
|
64
|
-
const txHashToEvict = await this.#indices.getAsync(tailIdx);
|
|
65
|
-
if (txHashToEvict) {
|
|
66
|
-
await this.#txs.delete(txHashToEvict);
|
|
67
|
-
await this.#indices.delete(tailIdx);
|
|
68
|
-
}
|
|
69
|
-
tailIdx++;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Archive the transaction with stripped proof
|
|
73
|
-
const archivedTx = this.stripProof(tx);
|
|
74
|
-
const txHash = tx.getTxHash().toString();
|
|
75
|
-
await this.#txs.set(txHash, archivedTx.toBuffer());
|
|
76
|
-
await this.#indices.set(headIdx, txHash);
|
|
77
|
-
headIdx++;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.#log.debug(`Archived ${txs.length} txs, total: ${headIdx - tailIdx}`);
|
|
81
|
-
});
|
|
82
|
-
} catch (error) {
|
|
83
|
-
this.#log.error('Error archiving transactions', { error });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Retrieves an archived transaction by its hash.
|
|
89
|
-
*/
|
|
90
|
-
async getTxByHash(txHash: TxHash): Promise<Tx | undefined> {
|
|
91
|
-
const buffer = await this.#txs.getAsync(txHash.toString());
|
|
92
|
-
return buffer ? Tx.fromBuffer(buffer) : undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Gets the current count of archived transactions.
|
|
97
|
-
*/
|
|
98
|
-
async getCount(): Promise<number> {
|
|
99
|
-
const head = await this.getHeadIndex();
|
|
100
|
-
const tail = await this.getTailIndex();
|
|
101
|
-
return head - tail;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Strips the proof from a transaction for archival.
|
|
106
|
-
*/
|
|
107
|
-
private stripProof(tx: Tx): Tx {
|
|
108
|
-
return new Tx(tx.txHash, tx.data, ChonkProof.empty(), tx.contractClassLogFields, tx.publicFunctionCalldata);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private async getHeadIndex(): Promise<number> {
|
|
112
|
-
const entry = await this.#indices.entriesAsync({ limit: 1, reverse: true }).next();
|
|
113
|
-
return (entry.value?.[0] ?? -1) + 1;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private async getTailIndex(): Promise<number> {
|
|
117
|
-
const entry = await this.#indices.entriesAsync({ limit: 1 }).next();
|
|
118
|
-
return entry.value?.[0] ?? 0;
|
|
119
|
-
}
|
|
120
|
-
}
|