@aztec/p2p 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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 +29 -14
- package/dest/client/interface.d.ts +12 -5
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +6 -5
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +47 -39
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +21 -8
- package/dest/config.d.ts +128 -100
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +97 -34
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +7 -5
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +16 -9
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +33 -15
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- 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 +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -1
- 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 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.js +62 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- 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 +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +12 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +44 -12
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +81 -22
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- 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 +26 -44
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +62 -29
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +9 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +37 -12
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +7 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +61 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +8 -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 +8 -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 +17 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +83 -48
- 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/archive_cache.js +1 -1
- 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 +23 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +37 -11
- 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 +48 -7
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +88 -41
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- 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/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/dummy_service.d.ts +6 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- package/dest/services/encoding.d.ts +6 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +14 -8
- package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +21 -4
- package/dest/services/libp2p/instrumentation.d.ts +3 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -0
- package/dest/services/libp2p/libp2p_service.d.ts +23 -32
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +202 -151
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +39 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +69 -65
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- 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/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +30 -12
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- 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 +4 -2
- package/dest/test-helpers/mock-pubsub.d.ts +12 -5
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +37 -12
- 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 +6 -4
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -3
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +78 -21
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +48 -19
- package/src/client/interface.ts +12 -10
- package/src/client/p2p_client.ts +52 -51
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +22 -11
- package/src/config.ts +146 -36
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +17 -12
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +22 -14
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/eviction/insufficient_fee_per_gas_eviction_rule.ts +65 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +12 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +121 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +16 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +70 -26
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +41 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +12 -2
- package/src/msg_validators/clock_tolerance.ts +79 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +22 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +33 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +99 -49
- package/src/msg_validators/tx_validator/README.md +15 -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/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +46 -4
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +121 -39
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +8 -2
- package/src/services/encoding.ts +14 -7
- package/src/services/gossipsub/topic_score_params.ts +36 -4
- package/src/services/libp2p/instrumentation.ts +14 -0
- package/src/services/libp2p/libp2p_service.ts +206 -164
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +40 -13
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +37 -11
- package/src/test-helpers/reqresp-nodes.ts +7 -8
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +77 -21
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- 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/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
package/src/config.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
|
+
bigintConfigHelper,
|
|
4
5
|
booleanConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
7
8
|
numberConfigHelper,
|
|
9
|
+
optionalNumberConfigHelper,
|
|
8
10
|
percentageConfigHelper,
|
|
9
11
|
pickConfigMappings,
|
|
10
12
|
secretStringConfigHelper,
|
|
11
13
|
} from '@aztec/foundation/config';
|
|
12
14
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
15
|
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
16
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
17
|
import {
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
chainConfigMappings,
|
|
21
22
|
sharedSequencerConfigMappings,
|
|
22
23
|
} from '@aztec/stdlib/config';
|
|
24
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
23
25
|
|
|
24
26
|
import {
|
|
25
27
|
type BatchTxRequesterConfig,
|
|
@@ -38,7 +40,26 @@ export interface P2PConfig
|
|
|
38
40
|
ChainConfig,
|
|
39
41
|
TxCollectionConfig,
|
|
40
42
|
TxFileStoreConfig,
|
|
41
|
-
Pick<
|
|
43
|
+
Pick<
|
|
44
|
+
SequencerConfig,
|
|
45
|
+
| 'blockDurationMs'
|
|
46
|
+
| 'expectedBlockProposalsPerSlot'
|
|
47
|
+
| 'l1PublishingTime'
|
|
48
|
+
| 'maxTxsPerBlock'
|
|
49
|
+
| 'attestationPropagationTime'
|
|
50
|
+
> {
|
|
51
|
+
/** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
|
|
52
|
+
validateMaxTxsPerBlock?: number;
|
|
53
|
+
|
|
54
|
+
/** Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set. */
|
|
55
|
+
validateMaxTxsPerCheckpoint?: number;
|
|
56
|
+
|
|
57
|
+
/** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
58
|
+
validateMaxL2BlockGas?: number;
|
|
59
|
+
|
|
60
|
+
/** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
61
|
+
validateMaxDABlockGas?: number;
|
|
62
|
+
|
|
42
63
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
43
64
|
p2pEnabled: boolean;
|
|
44
65
|
|
|
@@ -57,6 +78,9 @@ export interface P2PConfig
|
|
|
57
78
|
/** The frequency in which to check for new peers. */
|
|
58
79
|
peerCheckIntervalMS: number;
|
|
59
80
|
|
|
81
|
+
/** How long to ban a peer after it fails MAX_DIAL_ATTEMPTS dials. */
|
|
82
|
+
peerFailedBanTimeMs: number;
|
|
83
|
+
|
|
60
84
|
/** Size of queue of L2 blocks to store. */
|
|
61
85
|
l2QueueSize: number;
|
|
62
86
|
|
|
@@ -150,8 +174,8 @@ export interface P2PConfig
|
|
|
150
174
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
151
175
|
p2pStoreMapSizeKb?: number;
|
|
152
176
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
177
|
+
/** Additional entries to extend the default setup allow list. */
|
|
178
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
155
179
|
|
|
156
180
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
157
181
|
maxPendingTxCount: number;
|
|
@@ -190,11 +214,39 @@ export interface P2PConfig
|
|
|
190
214
|
|
|
191
215
|
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
|
|
192
216
|
minTxPoolAgeMs: number;
|
|
217
|
+
|
|
218
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
219
|
+
priceBumpPercentage: bigint;
|
|
220
|
+
|
|
221
|
+
/** Drop incoming block and checkpoint proposals at the libp2p dispatch layer (for testing only) */
|
|
222
|
+
skipIncomingProposals?: boolean;
|
|
193
223
|
}
|
|
194
224
|
|
|
195
225
|
export const DEFAULT_P2P_PORT = 40400;
|
|
196
226
|
|
|
197
227
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
228
|
+
validateMaxTxsPerBlock: {
|
|
229
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
230
|
+
description:
|
|
231
|
+
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
232
|
+
...optionalNumberConfigHelper(),
|
|
233
|
+
},
|
|
234
|
+
validateMaxTxsPerCheckpoint: {
|
|
235
|
+
env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
|
|
236
|
+
description:
|
|
237
|
+
'Maximum transactions per checkpoint for validation. Used as fallback for maxTxsPerBlock when that is not set.',
|
|
238
|
+
...optionalNumberConfigHelper(),
|
|
239
|
+
},
|
|
240
|
+
validateMaxL2BlockGas: {
|
|
241
|
+
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
242
|
+
description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
243
|
+
...optionalNumberConfigHelper(),
|
|
244
|
+
},
|
|
245
|
+
validateMaxDABlockGas: {
|
|
246
|
+
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
247
|
+
description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
248
|
+
...optionalNumberConfigHelper(),
|
|
249
|
+
},
|
|
198
250
|
p2pEnabled: {
|
|
199
251
|
env: 'P2P_ENABLED',
|
|
200
252
|
description: 'A flag dictating whether the P2P subsystem should be enabled.',
|
|
@@ -225,6 +277,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
225
277
|
description: 'The frequency in which to check for new peers.',
|
|
226
278
|
...numberConfigHelper(30_000),
|
|
227
279
|
},
|
|
280
|
+
peerFailedBanTimeMs: {
|
|
281
|
+
env: 'P2P_PEER_FAILED_BAN_TIME_MS',
|
|
282
|
+
description: 'How long to ban a peer after it fails maximum dial attempts.',
|
|
283
|
+
...numberConfigHelper(5 * 60 * 1000),
|
|
284
|
+
},
|
|
228
285
|
l2QueueSize: {
|
|
229
286
|
env: 'P2P_L2_QUEUE_SIZE',
|
|
230
287
|
description: 'Size of queue of L2 blocks to store.',
|
|
@@ -318,7 +375,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
318
375
|
gossipsubMcacheLength: {
|
|
319
376
|
env: 'P2P_GOSSIPSUB_MCACHE_LENGTH',
|
|
320
377
|
description: 'The number of gossipsub interval message cache windows to keep.',
|
|
321
|
-
...numberConfigHelper(
|
|
378
|
+
...numberConfigHelper(12),
|
|
322
379
|
},
|
|
323
380
|
gossipsubMcacheGossip: {
|
|
324
381
|
env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
|
|
@@ -390,15 +447,16 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
390
447
|
},
|
|
391
448
|
p2pStoreMapSizeKb: {
|
|
392
449
|
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
393
|
-
|
|
450
|
+
...optionalNumberConfigHelper(),
|
|
394
451
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
395
452
|
},
|
|
396
|
-
|
|
453
|
+
txPublicSetupAllowListExtend: {
|
|
397
454
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
398
455
|
parseEnv: (val: string) => parseAllowList(val),
|
|
399
|
-
description:
|
|
456
|
+
description:
|
|
457
|
+
'Additional entries to extend the default setup allow list. Format: I:address:selector[:flags],C:classId:selector[:flags]. Flags: os (onlySelf), rn (rejectNullMsgSender), cl=N (calldataLength), joined with +.',
|
|
400
458
|
printDefault: () =>
|
|
401
|
-
'AuthRegistry
|
|
459
|
+
'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
|
|
402
460
|
},
|
|
403
461
|
maxPendingTxCount: {
|
|
404
462
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -448,6 +506,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
448
506
|
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
449
507
|
...booleanConfigHelper(false),
|
|
450
508
|
},
|
|
509
|
+
l1PublishingTime: {
|
|
510
|
+
env: 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT',
|
|
511
|
+
description: 'How much time (in seconds) we allow in the slot for publishing the L1 tx (defaults to 1 L1 slot).',
|
|
512
|
+
...optionalNumberConfigHelper(),
|
|
513
|
+
},
|
|
451
514
|
fishermanMode: {
|
|
452
515
|
env: 'FISHERMAN_MODE',
|
|
453
516
|
description:
|
|
@@ -459,11 +522,21 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
459
522
|
'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
|
|
460
523
|
...booleanConfigHelper(false),
|
|
461
524
|
},
|
|
525
|
+
skipIncomingProposals: {
|
|
526
|
+
description: 'Drop incoming block and checkpoint proposals at the libp2p dispatch layer (for testing only)',
|
|
527
|
+
...booleanConfigHelper(false),
|
|
528
|
+
},
|
|
462
529
|
minTxPoolAgeMs: {
|
|
463
530
|
env: 'P2P_MIN_TX_POOL_AGE_MS',
|
|
464
531
|
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
465
532
|
...numberConfigHelper(2_000),
|
|
466
533
|
},
|
|
534
|
+
priceBumpPercentage: {
|
|
535
|
+
env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
|
|
536
|
+
description:
|
|
537
|
+
'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
|
|
538
|
+
...bigintConfigHelper(10n),
|
|
539
|
+
},
|
|
467
540
|
...sharedSequencerConfigMappings,
|
|
468
541
|
...p2pReqRespConfigMappings,
|
|
469
542
|
...batchTxRequesterConfigMappings,
|
|
@@ -521,13 +594,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
521
594
|
bootnodeConfigKeys,
|
|
522
595
|
);
|
|
523
596
|
|
|
597
|
+
/**
|
|
598
|
+
* Parses a `+`-separated flags string into validation properties for an allow list entry.
|
|
599
|
+
* Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
600
|
+
*/
|
|
601
|
+
function parseFlags(
|
|
602
|
+
flags: string,
|
|
603
|
+
entry: string,
|
|
604
|
+
): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
|
|
605
|
+
const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
|
|
606
|
+
for (const flag of flags.split('+')) {
|
|
607
|
+
if (flag === 'os') {
|
|
608
|
+
result.onlySelf = true;
|
|
609
|
+
} else if (flag === 'rn') {
|
|
610
|
+
result.rejectNullMsgSender = true;
|
|
611
|
+
} else if (flag.startsWith('cl=')) {
|
|
612
|
+
const n = parseInt(flag.slice(3), 10);
|
|
613
|
+
if (isNaN(n) || n < 0) {
|
|
614
|
+
throw new Error(
|
|
615
|
+
`Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
result.calldataLength = n;
|
|
619
|
+
} else {
|
|
620
|
+
throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
|
|
524
626
|
/**
|
|
525
627
|
* Parses a string to a list of allowed elements.
|
|
526
|
-
* Each
|
|
527
|
-
* `I:${address}`
|
|
528
|
-
* `
|
|
529
|
-
*
|
|
530
|
-
*
|
|
628
|
+
* Each entry is expected to be of one of the following formats:
|
|
629
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
630
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
631
|
+
*
|
|
632
|
+
* An optional flags segment can be appended after the selector:
|
|
633
|
+
* `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
|
|
634
|
+
* where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
531
635
|
*
|
|
532
636
|
* @param value The string to parse
|
|
533
637
|
* @returns A list of allowed elements
|
|
@@ -540,31 +644,37 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
540
644
|
}
|
|
541
645
|
|
|
542
646
|
for (const val of value.split(',')) {
|
|
543
|
-
const
|
|
544
|
-
|
|
647
|
+
const trimmed = val.trim();
|
|
648
|
+
if (!trimmed) {
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
|
|
652
|
+
|
|
653
|
+
if (!selectorString) {
|
|
654
|
+
throw new Error(
|
|
655
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
660
|
+
const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
|
|
545
661
|
|
|
546
662
|
if (typeString === 'I') {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
} else {
|
|
553
|
-
entries.push({
|
|
554
|
-
address: AztecAddress.fromString(identifierString),
|
|
555
|
-
});
|
|
556
|
-
}
|
|
663
|
+
entries.push({
|
|
664
|
+
address: AztecAddress.fromString(identifierString),
|
|
665
|
+
selector,
|
|
666
|
+
...flags,
|
|
667
|
+
});
|
|
557
668
|
} else if (typeString === 'C') {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
669
|
+
entries.push({
|
|
670
|
+
classId: Fr.fromHexString(identifierString),
|
|
671
|
+
selector,
|
|
672
|
+
...flags,
|
|
673
|
+
});
|
|
674
|
+
} else {
|
|
675
|
+
throw new Error(
|
|
676
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
677
|
+
);
|
|
568
678
|
}
|
|
569
679
|
}
|
|
570
680
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Checkpoint Proposal Received Callback Not Registered Error
|
|
2
|
+
*
|
|
3
|
+
* Error triggered if the allNodesCheckpointReceivedCallback is not registered
|
|
4
|
+
* @category Errors
|
|
5
|
+
*/
|
|
6
|
+
export class CheckpointProposalReceivedCallbackNotRegisteredError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('FATAL (allNodesCheckpointReceivedCallback): All nodes should register a checkpoint proposal handler');
|
|
9
|
+
this.name = 'CheckpointProposalReceivedCallbackNotRegisteredError';
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './client/index.js';
|
|
|
6
6
|
export * from './enr/index.js';
|
|
7
7
|
export * from './config.js';
|
|
8
8
|
export * from './mem_pools/attestation_pool/index.js';
|
|
9
|
-
export * from './mem_pools/tx_pool/index.js';
|
|
10
9
|
export * from './mem_pools/tx_pool_v2/index.js';
|
|
11
10
|
export * from './msg_validators/index.js';
|
|
12
11
|
export * from './services/index.js';
|
|
@@ -26,10 +26,10 @@ export type TryAddResult = {
|
|
|
26
26
|
count: number;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const MAX_CHECKPOINT_PROPOSALS_PER_SLOT =
|
|
30
|
-
export const MAX_BLOCK_PROPOSALS_PER_POSITION =
|
|
29
|
+
export const MAX_CHECKPOINT_PROPOSALS_PER_SLOT = 2;
|
|
30
|
+
export const MAX_BLOCK_PROPOSALS_PER_POSITION = 2;
|
|
31
31
|
/** Maximum attestations a single signer can make per slot before being rejected. */
|
|
32
|
-
export const MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER =
|
|
32
|
+
export const MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER = 2;
|
|
33
33
|
|
|
34
34
|
/** Public API interface for attestation pools. Used for typing mocks and test implementations. */
|
|
35
35
|
export type AttestationPoolApi = Pick<
|
|
@@ -154,14 +154,16 @@ export class AttestationPool {
|
|
|
154
154
|
/** Maximum indexWithinCheckpoint value (2^10 - 1 = 1023). */
|
|
155
155
|
private static readonly MAX_INDEX = (1 << AttestationPool.INDEX_BITS) - 1;
|
|
156
156
|
|
|
157
|
-
/** Creates a position key for block proposals:
|
|
157
|
+
/** Creates a position key for block proposals: slot * 1024 + indexWithinCheckpoint.
|
|
158
|
+
* Uses multiplication instead of bit-shift to avoid 32-bit signed integer overflow
|
|
159
|
+
* (bit-shift overflows after slot ~2^21, roughly 278 days of uptime). */
|
|
158
160
|
private getBlockPositionKey(slot: number, indexWithinCheckpoint: number): number {
|
|
159
161
|
if (indexWithinCheckpoint > AttestationPool.MAX_INDEX) {
|
|
160
162
|
throw new Error(
|
|
161
163
|
`Value for indexWithinCheckpoint ${indexWithinCheckpoint} exceeds maximum ${AttestationPool.MAX_INDEX}`,
|
|
162
164
|
);
|
|
163
165
|
}
|
|
164
|
-
return
|
|
166
|
+
return slot * (1 << AttestationPool.INDEX_BITS) + indexWithinCheckpoint;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
/**
|
|
@@ -278,7 +280,7 @@ export class AttestationPool {
|
|
|
278
280
|
* @returns Result indicating whether the proposal was added and duplicate detection info
|
|
279
281
|
*/
|
|
280
282
|
public async tryAddCheckpointProposal(proposal: CheckpointProposalCore): Promise<TryAddResult> {
|
|
281
|
-
|
|
283
|
+
const result = await this.store.transactionAsync(async () => {
|
|
282
284
|
const proposalId = proposal.archive.toString();
|
|
283
285
|
|
|
284
286
|
// Check if already exists
|
|
@@ -304,6 +306,8 @@ export class AttestationPool {
|
|
|
304
306
|
|
|
305
307
|
return { added: true, alreadyExists: false, count: count + 1 };
|
|
306
308
|
});
|
|
309
|
+
|
|
310
|
+
return result;
|
|
307
311
|
}
|
|
308
312
|
|
|
309
313
|
/** Internal method - must be called within a transaction. */
|
|
@@ -345,7 +349,7 @@ export class AttestationPool {
|
|
|
345
349
|
await this.store.transactionAsync(async () => {
|
|
346
350
|
for (const attestation of attestations) {
|
|
347
351
|
const slotNumber = attestation.payload.header.slotNumber;
|
|
348
|
-
const proposalId = attestation.archive;
|
|
352
|
+
const proposalId = attestation.archive.toString();
|
|
349
353
|
const sender = attestation.getSender();
|
|
350
354
|
|
|
351
355
|
// Skip attestations with invalid signatures
|
|
@@ -359,11 +363,10 @@ export class AttestationPool {
|
|
|
359
363
|
}
|
|
360
364
|
|
|
361
365
|
const address = sender.toString();
|
|
366
|
+
const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
|
|
362
367
|
|
|
363
|
-
await this.checkpointAttestations.set(
|
|
364
|
-
|
|
365
|
-
attestation.toBuffer(),
|
|
366
|
-
);
|
|
368
|
+
await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
|
|
369
|
+
this.metrics.trackMempoolItemAdded(ownKey);
|
|
367
370
|
|
|
368
371
|
this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
|
|
369
372
|
signature: attestation.signature.toString(),
|
|
@@ -429,6 +432,7 @@ export class AttestationPool {
|
|
|
429
432
|
const attestationEndKey = new Fr(oldestSlot).toString();
|
|
430
433
|
for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
|
|
431
434
|
await this.checkpointAttestations.delete(key);
|
|
435
|
+
this.metrics.trackMempoolItemRemoved(key);
|
|
432
436
|
numberOfAttestations++;
|
|
433
437
|
}
|
|
434
438
|
|
|
@@ -452,7 +456,7 @@ export class AttestationPool {
|
|
|
452
456
|
|
|
453
457
|
// Delete block proposals for slots < oldestSlot, using blockProposalsForSlotAndIndex as index
|
|
454
458
|
// Key format: (slot << INDEX_BITS) | indexWithinCheckpoint
|
|
455
|
-
const blockPositionEndKey = oldestSlot << AttestationPool.INDEX_BITS;
|
|
459
|
+
const blockPositionEndKey = oldestSlot * (1 << AttestationPool.INDEX_BITS);
|
|
456
460
|
for await (const positionKey of this.blockProposalsForSlotAndIndex.keysAsync({ end: blockPositionEndKey })) {
|
|
457
461
|
const proposalIds = await toArray(this.blockProposalsForSlotAndIndex.getValuesAsync(positionKey));
|
|
458
462
|
for (const proposalId of proposalIds) {
|
|
@@ -526,6 +530,7 @@ export class AttestationPool {
|
|
|
526
530
|
|
|
527
531
|
// Add the attestation
|
|
528
532
|
await this.checkpointAttestations.set(key, attestation.toBuffer());
|
|
533
|
+
this.metrics.trackMempoolItemAdded(key);
|
|
529
534
|
|
|
530
535
|
// Track this attestation in the per-signer-per-slot index for duplicate detection
|
|
531
536
|
const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
|
|
@@ -446,12 +446,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
446
446
|
const result2 = await ap.tryAddBlockProposal(proposal2);
|
|
447
447
|
expect(result2.count).toBe(2);
|
|
448
448
|
|
|
449
|
-
//
|
|
449
|
+
// Third proposal for same position should be rejected (cap is 2)
|
|
450
450
|
const proposal3 = await mockBlockProposalWithIndex(signers[2], slotNumber, indexWithinCheckpoint);
|
|
451
451
|
const result3 = await ap.tryAddBlockProposal(proposal3);
|
|
452
452
|
|
|
453
|
-
expect(result3.added).toBe(
|
|
454
|
-
expect(result3.count).toBe(
|
|
453
|
+
expect(result3.added).toBe(false);
|
|
454
|
+
expect(result3.count).toBe(2);
|
|
455
455
|
});
|
|
456
456
|
|
|
457
457
|
it('should return added=false when exceeding capacity', async () => {
|
|
@@ -666,12 +666,12 @@ export function describeAttestationPool(getAttestationPool: () => AttestationPoo
|
|
|
666
666
|
const result2 = await ap.tryAddCheckpointProposal(proposal2);
|
|
667
667
|
expect(result2.count).toBe(2);
|
|
668
668
|
|
|
669
|
-
//
|
|
669
|
+
// Third proposal for same slot should be rejected (cap is 2)
|
|
670
670
|
const proposal3 = await mockCheckpointProposalCoreForPool(signers[2], slotNumber);
|
|
671
671
|
const result3 = await ap.tryAddCheckpointProposal(proposal3);
|
|
672
672
|
|
|
673
|
-
expect(result3.added).toBe(
|
|
674
|
-
expect(result3.count).toBe(
|
|
673
|
+
expect(result3.added).toBe(false);
|
|
674
|
+
expect(result3.count).toBe(2);
|
|
675
675
|
});
|
|
676
676
|
|
|
677
677
|
it('should not count attestations as proposals for duplicate detection', async () => {
|
|
@@ -3,11 +3,12 @@ import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer'
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import {
|
|
5
5
|
CheckpointAttestation,
|
|
6
|
+
CheckpointProposal,
|
|
6
7
|
ConsensusPayload,
|
|
7
|
-
|
|
8
|
-
getHashedSignaturePayloadEthSignedMessage,
|
|
8
|
+
getHashedSignaturePayloadTypedData,
|
|
9
9
|
} from '@aztec/stdlib/p2p';
|
|
10
10
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
11
|
+
import { TEST_COORDINATION_SIGNATURE_CONTEXT } from '@aztec/stdlib/testing';
|
|
11
12
|
|
|
12
13
|
import { type LocalAccount, generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
13
14
|
|
|
@@ -37,15 +38,19 @@ export const mockCheckpointAttestation = (
|
|
|
37
38
|
feeAssetPriceModifier: bigint = 0n,
|
|
38
39
|
): CheckpointAttestation => {
|
|
39
40
|
header = header ?? CheckpointHeader.random({ slotNumber: SlotNumber(slot) });
|
|
40
|
-
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
|
|
41
|
+
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier, TEST_COORDINATION_SIGNATURE_CONTEXT);
|
|
41
42
|
|
|
42
|
-
const attestationHash =
|
|
43
|
-
payload,
|
|
44
|
-
SignatureDomainSeparator.checkpointAttestation,
|
|
45
|
-
);
|
|
43
|
+
const attestationHash = getHashedSignaturePayloadTypedData(payload);
|
|
46
44
|
const attestationSignature = signer.sign(attestationHash);
|
|
47
45
|
|
|
48
|
-
const
|
|
46
|
+
const proposal = new CheckpointProposal(
|
|
47
|
+
header,
|
|
48
|
+
archive,
|
|
49
|
+
feeAssetPriceModifier,
|
|
50
|
+
attestationSignature,
|
|
51
|
+
TEST_COORDINATION_SIGNATURE_CONTEXT,
|
|
52
|
+
);
|
|
53
|
+
const proposalHash = getHashedSignaturePayloadTypedData(proposal);
|
|
49
54
|
const proposerSignature = signer.sign(proposalHash);
|
|
50
55
|
|
|
51
56
|
return new CheckpointAttestation(payload, attestationSignature, proposerSignature);
|
package/src/mem_pools/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
|
-
// Old TxPool exports - kept temporarily for external consumers
|
|
4
|
-
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
5
|
-
// New TxPoolV2 exports
|
|
6
3
|
export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
|
|
@@ -73,7 +73,7 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
73
73
|
private defaultAttributes;
|
|
74
74
|
private meter: Meter;
|
|
75
75
|
|
|
76
|
-
private
|
|
76
|
+
private mempoolItemAddedTimestamp: Map<bigint | string, number> = new Map<bigint | string, number>();
|
|
77
77
|
|
|
78
78
|
constructor(
|
|
79
79
|
telemetry: TelemetryClient,
|
|
@@ -100,7 +100,11 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
100
100
|
|
|
101
101
|
this.addObjectCounter = createUpDownCounterWithDefault(this.meter, metricsLabels.itemsAdded);
|
|
102
102
|
|
|
103
|
-
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay
|
|
103
|
+
this.minedDelay = this.meter.createHistogram(metricsLabels.itemMinedDelay, {
|
|
104
|
+
advice: {
|
|
105
|
+
explicitBucketBoundaries: [100, 500, 1000, 5000, 10000, 30000, 60000, 300000, 600000, 1800000, 3600000],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
104
108
|
|
|
105
109
|
this.meter.addBatchObservableCallback(this.observeStats, [this.objectsInMempool]);
|
|
106
110
|
}
|
|
@@ -114,22 +118,26 @@ export class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
public transactionsAdded(transactions: Tx[]) {
|
|
117
|
-
|
|
118
|
-
for (const transaction of transactions) {
|
|
119
|
-
this.txAddedTimestamp.set(transaction.txHash.toBigInt(), timestamp);
|
|
120
|
-
}
|
|
121
|
+
transactions.forEach(tx => this.trackMempoolItemAdded(tx.txHash.toBigInt()));
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
public transactionsRemoved(hashes: Iterable<bigint> | Iterable<string>) {
|
|
124
|
-
const timestamp = Date.now();
|
|
125
125
|
for (const hash of hashes) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
this.trackMempoolItemRemoved(BigInt(hash));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public trackMempoolItemAdded(key: bigint | string): void {
|
|
131
|
+
this.mempoolItemAddedTimestamp.set(key, Date.now());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public trackMempoolItemRemoved(key: bigint | string): void {
|
|
135
|
+
const timestamp = Date.now();
|
|
136
|
+
const addedAt = this.mempoolItemAddedTimestamp.get(key);
|
|
137
|
+
if (addedAt !== undefined) {
|
|
138
|
+
this.mempoolItemAddedTimestamp.delete(key);
|
|
139
|
+
if (addedAt < timestamp) {
|
|
140
|
+
this.minedDelay.record(timestamp - addedAt);
|
|
133
141
|
}
|
|
134
142
|
}
|
|
135
143
|
}
|
|
@@ -158,7 +158,7 @@ Checked before adding a transaction to the pending pool:
|
|
|
158
158
|
|
|
159
159
|
| Rule | Purpose |
|
|
160
160
|
|------|---------|
|
|
161
|
-
| `NullifierConflictRule` | Handles transactions with conflicting nullifiers. Higher priority tx wins. |
|
|
161
|
+
| `NullifierConflictRule` | Handles transactions with conflicting nullifiers. Higher priority tx wins. For RPC submissions, a configurable price bump percentage is required. |
|
|
162
162
|
| `FeePayerBalancePreAddRule` | Ensures fee payer has sufficient balance for all their pending txs. |
|
|
163
163
|
| `LowPriorityPreAddRule` | Rejects txs when pool is full and new tx has lowest priority. |
|
|
164
164
|
|
|
@@ -233,6 +233,14 @@ await pool.updateConfig({
|
|
|
233
233
|
});
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
+
### Price Bump (RPC Transaction Replacement)
|
|
237
|
+
|
|
238
|
+
When a transaction is submitted via RPC and clashes on nullifiers with an existing pool transaction, the incoming tx must pay at least `priceBumpPercentage`% more in priority fee (i.e. `>= existingFee + existingFee * bump / 100`) to replace it. This prevents spam via small fee increments. The same bump applies when the pool is full and the incoming tx needs to evict the lowest-priority tx.
|
|
239
|
+
|
|
240
|
+
- **Env var**: `P2P_RPC_PRICE_BUMP_PERCENTAGE` (default: 10)
|
|
241
|
+
- **Scope**: RPC submissions only. P2P gossip uses `comparePriority` (fee + hash tiebreaker) with no bump.
|
|
242
|
+
- Even with a 0% bump, a replacement tx must pay at least 1 unit more than the existing fee.
|
|
243
|
+
|
|
236
244
|
## Return Values
|
|
237
245
|
|
|
238
246
|
### AddTxsResult
|
|
@@ -29,7 +29,8 @@ export class FeePayerBalanceEvictionRule implements EvictionRule {
|
|
|
29
29
|
|
|
30
30
|
if (context.event === EvictionEvent.BLOCK_MINED) {
|
|
31
31
|
const blockNumber = context.block.getBlockNumber();
|
|
32
|
-
await
|
|
32
|
+
const blockHash = await context.block.hash();
|
|
33
|
+
await this.worldState.syncImmediate(blockNumber, blockHash);
|
|
33
34
|
return await this.evictForFeePayers(context.feePayers, this.worldState.getSnapshot(blockNumber), pool);
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -35,6 +35,7 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
|
|
|
35
35
|
// Create combined list with incoming tx
|
|
36
36
|
const allTxs: Array<{
|
|
37
37
|
txHash: string;
|
|
38
|
+
txHashBigInt: bigint;
|
|
38
39
|
priorityFee: bigint;
|
|
39
40
|
feeLimit: bigint;
|
|
40
41
|
claimAmount: bigint;
|
|
@@ -42,6 +43,7 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
|
|
|
42
43
|
}> = [
|
|
43
44
|
...existingTxs.map(t => ({
|
|
44
45
|
txHash: t.txHash,
|
|
46
|
+
txHashBigInt: t.txHashBigInt,
|
|
45
47
|
priorityFee: t.priorityFee,
|
|
46
48
|
feeLimit: t.feeLimit,
|
|
47
49
|
claimAmount: t.claimAmount,
|
|
@@ -49,6 +51,7 @@ export class FeePayerBalancePreAddRule implements PreAddRule {
|
|
|
49
51
|
})),
|
|
50
52
|
{
|
|
51
53
|
txHash: incomingMeta.txHash,
|
|
54
|
+
txHashBigInt: incomingMeta.txHashBigInt,
|
|
52
55
|
priorityFee: incomingMeta.priorityFee,
|
|
53
56
|
feeLimit: incomingMeta.feeLimit,
|
|
54
57
|
claimAmount: incomingMeta.claimAmount,
|
|
@@ -21,6 +21,7 @@ export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
|
|
|
21
21
|
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';
|
|
22
22
|
|
|
23
23
|
// Post-event eviction rules
|
|
24
|
+
export { InsufficientFeePerGasEvictionRule } from './insufficient_fee_per_gas_eviction_rule.js';
|
|
24
25
|
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
|
|
25
26
|
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
|
|
26
27
|
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
|