@aztec/p2p 0.0.1-commit.21ecf947b → 0.0.1-commit.2448fdb
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 +6 -6
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +31 -28
- package/dest/client/interface.d.ts +10 -19
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +7 -18
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +51 -96
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +29 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +80 -31
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/mem_pools/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 +4 -4
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +5 -4
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +12 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +18 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +49 -9
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +102 -14
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +21 -12
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +9 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +9 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +11 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +279 -153
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- 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 +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/services/dummy_service.d.ts +4 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +4 -4
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +16 -9
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +16 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +97 -93
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +5 -9
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- 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 +5 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +39 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
- package/dest/services/tx_collection/file_store_tx_source.d.ts +16 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +50 -9
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts +2 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +10 -8
- package/dest/services/tx_collection/tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- package/dest/services/tx_file_store/tx_file_store.js +1 -1
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +8 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +6 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +3 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -12
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +4 -1
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +53 -46
- package/src/client/interface.ts +11 -20
- package/src/client/p2p_client.ts +55 -126
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -10
- package/src/config.ts +115 -33
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool/priority.ts +4 -4
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +5 -4
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +2 -2
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +12 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +17 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +143 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +25 -14
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +25 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +311 -148
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
- package/src/msg_validators/tx_validator/README.md +119 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- 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 +394 -78
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +16 -8
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +111 -101
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +6 -6
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/reqresp.ts +19 -11
- package/src/services/service.ts +11 -2
- package/src/services/tx_collection/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
- package/src/services/tx_collection/file_store_tx_source.ts +65 -9
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +8 -9
- package/src/services/tx_collection/tx_collection.ts +4 -3
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/tx_file_store.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +13 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +4 -3
- package/src/testbench/p2p_client_testbench_worker.ts +21 -17
- package/src/testbench/worker_client_manager.ts +11 -4
- package/src/util.ts +7 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
|
@@ -2,16 +2,19 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
4
|
import { BlockHash, type L2BlockId } from '@aztec/stdlib/block';
|
|
5
|
-
import
|
|
5
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
6
|
+
import { type Tx, TxHash } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
7
8
|
import { getFeePayerBalanceDelta } from '../../msg_validators/tx_validator/fee_payer_balance.js';
|
|
8
9
|
import { getTxPriorityFee } from '../tx_pool/priority.js';
|
|
9
|
-
import type
|
|
10
|
+
import { type PreAddResult, TxPoolRejectionCode } from './eviction/interfaces.js';
|
|
10
11
|
|
|
11
12
|
/** Validator-compatible data interface, mirroring the subset of PrivateKernelTailCircuitPublicInputs used by validators. */
|
|
12
13
|
export type TxMetaValidationData = {
|
|
13
14
|
getNonEmptyNullifiers(): Fr[];
|
|
14
15
|
expirationTimestamp: bigint;
|
|
16
|
+
/** Whether the tx has public calls. Used to select the correct L2 gas minimum. */
|
|
17
|
+
forPublic?: unknown;
|
|
15
18
|
constants: {
|
|
16
19
|
anchorBlockHeader: {
|
|
17
20
|
hash(): Promise<BlockHash>;
|
|
@@ -19,6 +22,9 @@ export type TxMetaValidationData = {
|
|
|
19
22
|
blockNumber: BlockNumber;
|
|
20
23
|
};
|
|
21
24
|
};
|
|
25
|
+
txContext: {
|
|
26
|
+
gasSettings: { gasLimits: Gas };
|
|
27
|
+
};
|
|
22
28
|
};
|
|
23
29
|
};
|
|
24
30
|
|
|
@@ -34,6 +40,9 @@ export type TxMetaData = {
|
|
|
34
40
|
/** The transaction hash as hex string */
|
|
35
41
|
readonly txHash: string;
|
|
36
42
|
|
|
43
|
+
/** The transaction hash as bigint (for efficient Fr conversion in comparisons) */
|
|
44
|
+
readonly txHashBigInt: bigint;
|
|
45
|
+
|
|
37
46
|
/** Block ID (number and hash) in which the transaction was mined (undefined if not mined) */
|
|
38
47
|
minedL2BlockId?: L2BlockId;
|
|
39
48
|
|
|
@@ -58,11 +67,17 @@ export type TxMetaData = {
|
|
|
58
67
|
/** Timestamp by which the transaction must be included (for expiration checks) */
|
|
59
68
|
readonly expirationTimestamp: bigint;
|
|
60
69
|
|
|
70
|
+
/** Whether the tx's setup-phase calls pass the allow list check. Computed at receipt time. */
|
|
71
|
+
readonly allowedSetupCalls: boolean;
|
|
72
|
+
|
|
61
73
|
/** Validator-compatible data, providing the same access patterns as Tx.data */
|
|
62
74
|
readonly data: TxMetaValidationData;
|
|
63
75
|
|
|
64
76
|
/** Timestamp (ms) when the tx was received into the pool. 0 for hydrated txs (always eligible). */
|
|
65
77
|
receivedAt: number;
|
|
78
|
+
|
|
79
|
+
/** Estimated memory footprint of this metadata object in bytes */
|
|
80
|
+
readonly estimatedSizeBytes: number;
|
|
66
81
|
};
|
|
67
82
|
|
|
68
83
|
/** Transaction state derived from TxMetaData fields and pool protection status */
|
|
@@ -72,9 +87,15 @@ export type TxState = 'pending' | 'protected' | 'mined' | 'deleted';
|
|
|
72
87
|
* Builds TxMetaData from a full Tx object.
|
|
73
88
|
* Extracts all relevant fields for efficient in-memory storage and querying.
|
|
74
89
|
* Fr values are captured in closures for zero-cost re-validation.
|
|
90
|
+
*
|
|
91
|
+
* @param allowedSetupCalls - Whether the tx's setup-phase calls pass the allow list.
|
|
92
|
+
* For gossip/RPC txs this is always `true` (already validated by PhasesTxValidator).
|
|
93
|
+
* For req/resp txs this should be computed by the caller using the phases validator.
|
|
75
94
|
*/
|
|
76
|
-
export async function buildTxMetaData(tx: Tx): Promise<TxMetaData> {
|
|
77
|
-
const
|
|
95
|
+
export async function buildTxMetaData(tx: Tx, allowedSetupCalls: boolean = true): Promise<TxMetaData> {
|
|
96
|
+
const txHashObj = tx.getTxHash();
|
|
97
|
+
const txHash = txHashObj.toString();
|
|
98
|
+
const txHashBigInt = txHashObj.toBigInt();
|
|
78
99
|
const nullifierFrs = tx.data.getNonEmptyNullifiers();
|
|
79
100
|
const nullifiers = nullifierFrs.map(n => n.toString());
|
|
80
101
|
const anchorBlockHeaderHashFr = await tx.data.constants.anchorBlockHeader.hash();
|
|
@@ -86,8 +107,11 @@ export async function buildTxMetaData(tx: Tx): Promise<TxMetaData> {
|
|
|
86
107
|
|
|
87
108
|
const { feeLimit, claimAmount } = await getFeePayerBalanceDelta(tx, ProtocolContractAddress.FeeJuice);
|
|
88
109
|
|
|
110
|
+
const estimatedSizeBytes = estimateTxMetaDataSize(nullifiers.length);
|
|
111
|
+
|
|
89
112
|
return {
|
|
90
113
|
txHash,
|
|
114
|
+
txHashBigInt,
|
|
91
115
|
anchorBlockHeaderHash,
|
|
92
116
|
priorityFee,
|
|
93
117
|
feePayer,
|
|
@@ -95,22 +119,54 @@ export async function buildTxMetaData(tx: Tx): Promise<TxMetaData> {
|
|
|
95
119
|
feeLimit,
|
|
96
120
|
nullifiers,
|
|
97
121
|
expirationTimestamp,
|
|
122
|
+
allowedSetupCalls,
|
|
98
123
|
receivedAt: 0,
|
|
124
|
+
estimatedSizeBytes,
|
|
99
125
|
data: {
|
|
100
126
|
getNonEmptyNullifiers: () => nullifierFrs,
|
|
101
127
|
expirationTimestamp,
|
|
128
|
+
forPublic: !!tx.data.forPublic,
|
|
102
129
|
constants: {
|
|
103
130
|
anchorBlockHeader: {
|
|
104
131
|
hash: () => Promise.resolve(anchorBlockHeaderHashFr),
|
|
105
132
|
globalVariables: { blockNumber: anchorBlockNumber },
|
|
106
133
|
},
|
|
134
|
+
txContext: {
|
|
135
|
+
gasSettings: { gasLimits: tx.data.constants.txContext.gasSettings.gasLimits },
|
|
136
|
+
},
|
|
107
137
|
},
|
|
108
138
|
},
|
|
109
139
|
};
|
|
110
140
|
}
|
|
111
141
|
|
|
142
|
+
// V8 JS object overhead (~64 bytes for a plain object with hidden class).
|
|
143
|
+
// String overhead: ~32 bytes header + 1 byte per ASCII char (V8 one-byte strings).
|
|
144
|
+
// Hex string (0x + 64 hex chars = 66 chars): ~98 bytes per string.
|
|
145
|
+
// bigint: ~32 bytes. number: 8 bytes. Fr: ~80 bytes (32 data + object overhead).
|
|
146
|
+
const OBJECT_OVERHEAD = 64;
|
|
147
|
+
const HEX_STRING_BYTES = 98;
|
|
148
|
+
const BIGINT_BYTES = 32;
|
|
149
|
+
const FR_BYTES = 80;
|
|
150
|
+
// Fixed cost: object shell + txHash + anchorBlockHeaderHash + feePayer (3 hex strings)
|
|
151
|
+
// + txHashBigInt + priorityFee + claimAmount + feeLimit + includeByTimestamp (5 bigints)
|
|
152
|
+
// + receivedAt (number, 8 bytes) + estimatedSizeBytes (number, 8 bytes)
|
|
153
|
+
// + data closure object (~OBJECT_OVERHEAD + anchorBlockHeaderHashFr Fr + anchorBlockNumber number)
|
|
154
|
+
const FIXED_METADATA_BYTES =
|
|
155
|
+
OBJECT_OVERHEAD + 3 * HEX_STRING_BYTES + 5 * BIGINT_BYTES + 8 + 8 + OBJECT_OVERHEAD + FR_BYTES + 8;
|
|
156
|
+
|
|
157
|
+
/** Estimates the in-memory size of a TxMetaData object based on the number of nullifiers. */
|
|
158
|
+
function estimateTxMetaDataSize(nullifierCount: number): number {
|
|
159
|
+
// Per nullifier: one hex string in nullifiers[] + one Fr in the captured nullifierFrs[]
|
|
160
|
+
return FIXED_METADATA_BYTES + nullifierCount * (HEX_STRING_BYTES + FR_BYTES);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Converts a txHash bigint back to the canonical 0x-prefixed 64-char hex string. */
|
|
164
|
+
export function txHashFromBigInt(value: bigint): string {
|
|
165
|
+
return TxHash.fromBigInt(value).toString();
|
|
166
|
+
}
|
|
167
|
+
|
|
112
168
|
/** Minimal fields required for priority comparison. */
|
|
113
|
-
type PriorityComparable = Pick<TxMetaData, '
|
|
169
|
+
type PriorityComparable = Pick<TxMetaData, 'txHashBigInt' | 'priorityFee'>;
|
|
114
170
|
|
|
115
171
|
/**
|
|
116
172
|
* Compares two priority fees in ascending order.
|
|
@@ -125,10 +181,8 @@ export function compareFee(a: bigint, b: bigint): number {
|
|
|
125
181
|
* Uses field element comparison for deterministic ordering.
|
|
126
182
|
* Returns negative if a < b, positive if a > b, 0 if equal.
|
|
127
183
|
*/
|
|
128
|
-
export function compareTxHash(a:
|
|
129
|
-
|
|
130
|
-
const fieldB = Fr.fromHexString(b);
|
|
131
|
-
return fieldA.cmp(fieldB);
|
|
184
|
+
export function compareTxHash(a: bigint, b: bigint): number {
|
|
185
|
+
return Fr.cmpAsBigInt(a, b);
|
|
132
186
|
}
|
|
133
187
|
|
|
134
188
|
/**
|
|
@@ -141,24 +195,41 @@ export function comparePriority(a: PriorityComparable, b: PriorityComparable): n
|
|
|
141
195
|
if (feeComparison !== 0) {
|
|
142
196
|
return feeComparison;
|
|
143
197
|
}
|
|
144
|
-
return compareTxHash(a.
|
|
198
|
+
return compareTxHash(a.txHashBigInt, b.txHashBigInt);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Returns the minimum fee required to replace an existing tx with the given price bump percentage.
|
|
203
|
+
* Uses integer arithmetic: `existingFee + existingFee * priceBumpPercentage / 100`.
|
|
204
|
+
*/
|
|
205
|
+
export function getMinimumPriceBumpFee(existingFee: bigint, priceBumpPercentage: bigint): bigint {
|
|
206
|
+
const bump = (existingFee * priceBumpPercentage) / 100n;
|
|
207
|
+
// Ensure the minimum bump is at least 1, so that replacement always requires
|
|
208
|
+
// paying strictly more — even with 0% bump or zero existing fee.
|
|
209
|
+
const effectiveBump = bump > 0n ? bump : 1n;
|
|
210
|
+
return existingFee + effectiveBump;
|
|
145
211
|
}
|
|
146
212
|
|
|
147
213
|
/**
|
|
148
214
|
* Checks for nullifier conflicts between an incoming transaction and existing pool state.
|
|
149
215
|
*
|
|
150
216
|
* When the incoming tx shares nullifiers with existing pending txs:
|
|
151
|
-
* - If the incoming tx
|
|
152
|
-
* -
|
|
217
|
+
* - If the incoming tx meets or exceeds the required priority, mark conflicting txs for eviction
|
|
218
|
+
* - Otherwise, ignore the incoming tx
|
|
219
|
+
*
|
|
220
|
+
* When `priceBumpPercentage` is provided (RPC path), uses fee-only comparison with the
|
|
221
|
+
* percentage bump instead of `comparePriority`.
|
|
153
222
|
*
|
|
154
223
|
* @param incomingMeta - Metadata for the incoming transaction
|
|
155
224
|
* @param getTxHashByNullifier - Accessor to find which tx uses a nullifier
|
|
156
225
|
* @param getMetadata - Accessor to get metadata for a tx hash
|
|
226
|
+
* @param priceBumpPercentage - Optional percentage bump required for fee-based replacement
|
|
157
227
|
*/
|
|
158
228
|
export function checkNullifierConflict(
|
|
159
229
|
incomingMeta: TxMetaData,
|
|
160
230
|
getTxHashByNullifier: (nullifier: string) => string | undefined,
|
|
161
231
|
getMetadata: (txHash: string) => TxMetaData | undefined,
|
|
232
|
+
priceBumpPercentage?: bigint,
|
|
162
233
|
): PreAddResult {
|
|
163
234
|
const txHashesToEvict: string[] = [];
|
|
164
235
|
|
|
@@ -179,16 +250,33 @@ export function checkNullifierConflict(
|
|
|
179
250
|
continue;
|
|
180
251
|
}
|
|
181
252
|
|
|
182
|
-
//
|
|
183
|
-
// Otherwise,
|
|
184
|
-
|
|
185
|
-
|
|
253
|
+
// When price bump is set (RPC path), require the incoming fee to meet the bumped threshold.
|
|
254
|
+
// Otherwise (P2P path), use full comparePriority with tx hash tiebreaker.
|
|
255
|
+
const isHigherPriority =
|
|
256
|
+
priceBumpPercentage !== undefined
|
|
257
|
+
? incomingMeta.priorityFee >= getMinimumPriceBumpFee(conflictingMeta.priorityFee, priceBumpPercentage)
|
|
258
|
+
: comparePriority(incomingMeta, conflictingMeta) > 0;
|
|
259
|
+
|
|
260
|
+
if (isHigherPriority) {
|
|
186
261
|
txHashesToEvict.push(conflictingHashStr);
|
|
187
262
|
} else {
|
|
263
|
+
const minimumFee =
|
|
264
|
+
priceBumpPercentage !== undefined
|
|
265
|
+
? getMinimumPriceBumpFee(conflictingMeta.priorityFee, priceBumpPercentage)
|
|
266
|
+
: undefined;
|
|
188
267
|
return {
|
|
189
268
|
shouldIgnore: true,
|
|
190
269
|
txHashesToEvict: [],
|
|
191
|
-
reason:
|
|
270
|
+
reason: {
|
|
271
|
+
code: TxPoolRejectionCode.NULLIFIER_CONFLICT,
|
|
272
|
+
message:
|
|
273
|
+
minimumFee !== undefined
|
|
274
|
+
? `Nullifier conflict with existing tx ${conflictingHashStr}. Minimum required fee: ${minimumFee}, got: ${incomingMeta.priorityFee}`
|
|
275
|
+
: `Nullifier conflict with existing tx ${conflictingHashStr}`,
|
|
276
|
+
conflictingTxHash: conflictingHashStr,
|
|
277
|
+
minimumPriceBumpFee: minimumFee,
|
|
278
|
+
txPriorityFee: minimumFee !== undefined ? incomingMeta.priorityFee : undefined,
|
|
279
|
+
},
|
|
192
280
|
};
|
|
193
281
|
}
|
|
194
282
|
}
|
|
@@ -206,6 +294,44 @@ export function stubTxMetaValidationData(overrides: { expirationTimestamp?: bigi
|
|
|
206
294
|
hash: () => Promise.resolve(new BlockHash(Fr.ZERO)),
|
|
207
295
|
globalVariables: { blockNumber: BlockNumber(0) },
|
|
208
296
|
},
|
|
297
|
+
txContext: {
|
|
298
|
+
gasSettings: { gasLimits: Gas.empty() },
|
|
299
|
+
},
|
|
209
300
|
},
|
|
210
301
|
};
|
|
211
302
|
}
|
|
303
|
+
|
|
304
|
+
/** Creates a stub TxMetaData for tests. All fields have sensible defaults and can be overridden. */
|
|
305
|
+
export function stubTxMetaData(
|
|
306
|
+
txHash: string,
|
|
307
|
+
overrides: {
|
|
308
|
+
priorityFee?: bigint;
|
|
309
|
+
feePayer?: string;
|
|
310
|
+
claimAmount?: bigint;
|
|
311
|
+
feeLimit?: bigint;
|
|
312
|
+
nullifiers?: string[];
|
|
313
|
+
expirationTimestamp?: bigint;
|
|
314
|
+
anchorBlockHeaderHash?: string;
|
|
315
|
+
allowedSetupCalls?: boolean;
|
|
316
|
+
} = {},
|
|
317
|
+
): TxMetaData {
|
|
318
|
+
const txHashBigInt = Fr.fromHexString(txHash).toBigInt();
|
|
319
|
+
// Normalize to canonical zero-padded hex so txHashFromBigInt(txHashBigInt) === normalizedTxHash
|
|
320
|
+
const normalizedTxHash = txHashFromBigInt(txHashBigInt);
|
|
321
|
+
const expirationTimestamp = overrides.expirationTimestamp ?? 0n;
|
|
322
|
+
return {
|
|
323
|
+
txHash: normalizedTxHash,
|
|
324
|
+
txHashBigInt,
|
|
325
|
+
anchorBlockHeaderHash: overrides.anchorBlockHeaderHash ?? '0x1234',
|
|
326
|
+
priorityFee: overrides.priorityFee ?? 100n,
|
|
327
|
+
feePayer: overrides.feePayer ?? '0xfeepayer',
|
|
328
|
+
claimAmount: overrides.claimAmount ?? 0n,
|
|
329
|
+
feeLimit: overrides.feeLimit ?? 100n,
|
|
330
|
+
nullifiers: overrides.nullifiers ?? [`0x${normalizedTxHash.slice(2)}null1`],
|
|
331
|
+
expirationTimestamp,
|
|
332
|
+
allowedSetupCalls: overrides.allowedSetupCalls ?? true,
|
|
333
|
+
receivedAt: 0,
|
|
334
|
+
estimatedSizeBytes: 0,
|
|
335
|
+
data: stubTxMetaValidationData({ expirationTimestamp }),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { L2BlockId } from '@aztec/stdlib/block';
|
|
3
3
|
|
|
4
|
-
import { type TxMetaData, type TxState, compareFee, compareTxHash } from './tx_metadata.js';
|
|
4
|
+
import { type TxMetaData, type TxState, compareFee, compareTxHash, txHashFromBigInt } from './tx_metadata.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Manages in-memory indices for the transaction pool.
|
|
@@ -22,8 +22,8 @@ export class TxPoolIndices {
|
|
|
22
22
|
#nullifierToTxHash: Map<string, string> = new Map();
|
|
23
23
|
/** Fee payer to txHashes index (pending txs only) */
|
|
24
24
|
#feePayerToTxHashes: Map<string, Set<string>> = new Map();
|
|
25
|
-
/** Pending
|
|
26
|
-
#pendingByPriority: Map<bigint, Set<
|
|
25
|
+
/** Pending txHash bigints grouped by priority fee */
|
|
26
|
+
#pendingByPriority: Map<bigint, Set<bigint>> = new Map();
|
|
27
27
|
/** Protected transactions: txHash -> slotNumber */
|
|
28
28
|
#protectedTransactions: Map<string, SlotNumber> = new Map();
|
|
29
29
|
|
|
@@ -73,17 +73,17 @@ export class TxPoolIndices {
|
|
|
73
73
|
* @param order - 'desc' for highest priority first, 'asc' for lowest priority first
|
|
74
74
|
*/
|
|
75
75
|
*iteratePendingByPriority(order: 'asc' | 'desc', filter?: (hash: string) => boolean): Generator<string> {
|
|
76
|
-
// Use compareFee from tx_metadata, swap args for descending order
|
|
77
76
|
const feeCompareFn = order === 'desc' ? (a: bigint, b: bigint) => compareFee(b, a) : compareFee;
|
|
78
|
-
const hashCompareFn =
|
|
77
|
+
const hashCompareFn =
|
|
78
|
+
order === 'desc' ? (a: bigint, b: bigint) => compareTxHash(b, a) : (a: bigint, b: bigint) => compareTxHash(a, b);
|
|
79
79
|
|
|
80
80
|
const sortedFees = [...this.#pendingByPriority.keys()].sort(feeCompareFn);
|
|
81
81
|
|
|
82
82
|
for (const fee of sortedFees) {
|
|
83
83
|
const hashesAtFee = this.#pendingByPriority.get(fee)!;
|
|
84
|
-
// Use compareTxHash from tx_metadata, swap args for descending order
|
|
85
84
|
const sortedHashes = [...hashesAtFee].sort(hashCompareFn);
|
|
86
|
-
for (const
|
|
85
|
+
for (const hashBigInt of sortedHashes) {
|
|
86
|
+
const hash = txHashFromBigInt(hashBigInt);
|
|
87
87
|
if (filter === undefined || filter(hash)) {
|
|
88
88
|
yield hash;
|
|
89
89
|
}
|
|
@@ -265,8 +265,8 @@ export class TxPoolIndices {
|
|
|
265
265
|
getPendingTxs(): TxMetaData[] {
|
|
266
266
|
const result: TxMetaData[] = [];
|
|
267
267
|
for (const hashSet of this.#pendingByPriority.values()) {
|
|
268
|
-
for (const
|
|
269
|
-
const meta = this.#metadata.get(
|
|
268
|
+
for (const txHashBigInt of hashSet) {
|
|
269
|
+
const meta = this.#metadata.get(txHashFromBigInt(txHashBigInt));
|
|
270
270
|
if (meta) {
|
|
271
271
|
result.push(meta);
|
|
272
272
|
}
|
|
@@ -348,13 +348,15 @@ export class TxPoolIndices {
|
|
|
348
348
|
// METRICS
|
|
349
349
|
// ============================================================================
|
|
350
350
|
|
|
351
|
-
/** Counts transactions by state */
|
|
352
|
-
countTxs(): { pending: number; protected: number; mined: number } {
|
|
351
|
+
/** Counts transactions by state and estimates total metadata memory usage */
|
|
352
|
+
countTxs(): { pending: number; protected: number; mined: number; totalMetadataBytes: number } {
|
|
353
353
|
let pending = 0;
|
|
354
354
|
let protected_ = 0;
|
|
355
355
|
let mined = 0;
|
|
356
|
+
let totalMetadataBytes = 0;
|
|
356
357
|
|
|
357
358
|
for (const meta of this.#metadata.values()) {
|
|
359
|
+
totalMetadataBytes += meta.estimatedSizeBytes;
|
|
358
360
|
const state = this.getTxState(meta);
|
|
359
361
|
if (state === 'pending') {
|
|
360
362
|
pending++;
|
|
@@ -365,7 +367,16 @@ export class TxPoolIndices {
|
|
|
365
367
|
}
|
|
366
368
|
}
|
|
367
369
|
|
|
368
|
-
return { pending, protected: protected_, mined };
|
|
370
|
+
return { pending, protected: protected_, mined, totalMetadataBytes };
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** Returns the estimated total memory consumed by all metadata objects */
|
|
374
|
+
getTotalMetadataBytes(): number {
|
|
375
|
+
let total = 0;
|
|
376
|
+
for (const meta of this.#metadata.values()) {
|
|
377
|
+
total += meta.estimatedSizeBytes;
|
|
378
|
+
}
|
|
379
|
+
return total;
|
|
369
380
|
}
|
|
370
381
|
|
|
371
382
|
/** Gets all mined transactions with their block IDs */
|
|
@@ -403,7 +414,7 @@ export class TxPoolIndices {
|
|
|
403
414
|
prioritySet = new Set();
|
|
404
415
|
this.#pendingByPriority.set(meta.priorityFee, prioritySet);
|
|
405
416
|
}
|
|
406
|
-
prioritySet.add(meta.
|
|
417
|
+
prioritySet.add(meta.txHashBigInt);
|
|
407
418
|
}
|
|
408
419
|
|
|
409
420
|
#removeFromPendingIndices(meta: TxMetaData): void {
|
|
@@ -424,7 +435,7 @@ export class TxPoolIndices {
|
|
|
424
435
|
// Remove from priority map
|
|
425
436
|
const hashSet = this.#pendingByPriority.get(meta.priorityFee);
|
|
426
437
|
if (hashSet) {
|
|
427
|
-
hashSet.delete(meta.
|
|
438
|
+
hashSet.delete(meta.txHashBigInt);
|
|
428
439
|
if (hashSet.size === 0) {
|
|
429
440
|
this.#pendingByPriority.delete(meta.priorityFee);
|
|
430
441
|
}
|
|
@@ -11,7 +11,14 @@ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-clien
|
|
|
11
11
|
import EventEmitter from 'node:events';
|
|
12
12
|
|
|
13
13
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
AddTxsResult,
|
|
16
|
+
PoolReadAccess,
|
|
17
|
+
TxPoolV2,
|
|
18
|
+
TxPoolV2Config,
|
|
19
|
+
TxPoolV2Dependencies,
|
|
20
|
+
TxPoolV2Events,
|
|
21
|
+
} from './interfaces.js';
|
|
15
22
|
import type { TxState } from './tx_metadata.js';
|
|
16
23
|
import { TxPoolV2Impl } from './tx_pool_v2_impl.js';
|
|
17
24
|
|
|
@@ -61,7 +68,7 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
61
68
|
};
|
|
62
69
|
|
|
63
70
|
// Create the implementation
|
|
64
|
-
this.#impl = new TxPoolV2Impl(store, archiveStore, deps, callbacks, config, dateProvider, log);
|
|
71
|
+
this.#impl = new TxPoolV2Impl(store, archiveStore, deps, callbacks, telemetry, config, dateProvider, log);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
// ============================================================================
|
|
@@ -70,11 +77,11 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
70
77
|
|
|
71
78
|
// === Core Operations ===
|
|
72
79
|
|
|
73
|
-
addPendingTxs(txs: Tx[], opts: { source?: string } = {}): Promise<AddTxsResult> {
|
|
80
|
+
addPendingTxs(txs: Tx[], opts: { source?: string; feeComparisonOnly?: boolean } = {}): Promise<AddTxsResult> {
|
|
74
81
|
return this.#queue.put(() => this.#impl.addPendingTxs(txs, opts));
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'
|
|
84
|
+
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'> {
|
|
78
85
|
return this.#queue.put(() => this.#impl.canAddPendingTx(tx));
|
|
79
86
|
}
|
|
80
87
|
|
|
@@ -83,7 +90,7 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
protectTxs(txHashes: TxHash[], block: BlockHeader): Promise<TxHash[]> {
|
|
86
|
-
return this.#queue.put(() =>
|
|
93
|
+
return this.#queue.put(() => this.#impl.protectTxs(txHashes, block));
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
addMinedTxs(txs: Tx[], block: BlockHeader, opts: { source?: string } = {}): Promise<void> {
|
|
@@ -100,8 +107,8 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
100
107
|
return this.#queue.put(() => this.#impl.prepareForSlot(slotNumber));
|
|
101
108
|
}
|
|
102
109
|
|
|
103
|
-
handlePrunedBlocks(latestBlock: L2BlockId): Promise<void> {
|
|
104
|
-
return this.#queue.put(() => this.#impl.handlePrunedBlocks(latestBlock));
|
|
110
|
+
handlePrunedBlocks(latestBlock: L2BlockId, options?: { deleteAllTxs?: boolean }): Promise<void> {
|
|
111
|
+
return this.#queue.put(() => this.#impl.handlePrunedBlocks(latestBlock, options));
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
handleFailedExecution(txHashes: TxHash[]): Promise<void> {
|
|
@@ -162,6 +169,11 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
162
169
|
return this.#queue.put(() => Promise.resolve(this.#impl.getLowestPriorityPending(limit)));
|
|
163
170
|
}
|
|
164
171
|
|
|
172
|
+
/** Returns read-only access to the pool. Used for testing. */
|
|
173
|
+
getPoolReadAccess(): PoolReadAccess {
|
|
174
|
+
return this.#impl.getPoolReadAccess();
|
|
175
|
+
}
|
|
176
|
+
|
|
165
177
|
// === Configuration ===
|
|
166
178
|
|
|
167
179
|
updateConfig(config: Partial<TxPoolV2Config>): Promise<void> {
|
|
@@ -195,7 +207,12 @@ export class AztecKVTxPoolV2 extends (EventEmitter as new () => TypedEventEmitte
|
|
|
195
207
|
this.#queue.put(() => {
|
|
196
208
|
const counts = this.#impl.countTxs();
|
|
197
209
|
return Promise.resolve({
|
|
198
|
-
itemCount: {
|
|
210
|
+
itemCount: {
|
|
211
|
+
pending: counts.pending,
|
|
212
|
+
protected: counts.protected,
|
|
213
|
+
mined: counts.mined,
|
|
214
|
+
softDeleted: counts.softDeleted,
|
|
215
|
+
},
|
|
199
216
|
});
|
|
200
217
|
}),
|
|
201
218
|
() => this.#store.estimateSize(),
|