@aztec/p2p 0.0.1-commit.87a0206 → 0.0.1-commit.88c5703d4
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 +9 -9
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +50 -13
- package/dest/client/interface.d.ts +39 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +37 -50
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +148 -223
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +6 -7
- package/dest/config.d.ts +48 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +92 -38
- 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/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +21 -12
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +72 -38
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +53 -53
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +2 -1
- 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 +16 -14
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- 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/eviction/invalid_txs_after_mining_rule.js +3 -3
- 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 +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -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 +7 -3
- 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 +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -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 +14 -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 +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -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 +26 -8
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +78 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +139 -18
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- 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 +50 -45
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
- 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 +17 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -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 +364 -189
- 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 +4 -4
- 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/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- 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 +240 -59
- 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/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/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 +71 -23
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +9 -5
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +7 -4
- package/dest/services/encoding.d.ts +3 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +11 -10
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +173 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +346 -0
- package/dest/services/libp2p/libp2p_service.d.ts +25 -14
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +195 -153
- 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 +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +2 -1
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +25 -2
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +45 -55
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -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 +11 -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 +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +3 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +14 -6
- package/dest/services/service.d.ts +22 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +56 -36
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +167 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +37 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +90 -0
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- 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 +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -10
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- 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 +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- 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 +4 -3
- package/dest/test-helpers/testbench-utils.d.ts +35 -24
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +104 -36
- 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 +16 -15
- 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 +6 -2
- package/dest/util.d.ts +3 -3
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +96 -24
- package/src/client/interface.ts +43 -33
- package/src/client/p2p_client.ts +172 -265
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +20 -11
- package/src/config.ts +141 -44
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +100 -48
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +57 -53
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +3 -0
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- 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 +85 -11
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -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 +7 -3
- 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 +5 -5
- 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 +14 -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 +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +28 -8
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +202 -26
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +410 -187
- 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 +5 -5
- 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/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +387 -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/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +81 -26
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +12 -6
- package/src/services/encoding.ts +9 -9
- package/src/services/gossipsub/README.md +641 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +487 -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 +2 -1
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +49 -57
- package/src/services/reqresp/batch-tx-requester/interface.ts +3 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +2 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +17 -5
- package/src/services/service.ts +31 -2
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +65 -32
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +117 -0
- package/src/services/tx_collection/index.ts +1 -0
- 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 +66 -33
- package/src/services/tx_collection/tx_collection.ts +113 -16
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +4 -6
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +5 -7
- package/src/test-helpers/testbench-utils.ts +118 -40
- package/src/testbench/p2p_client_testbench_worker.ts +25 -21
- package/src/testbench/worker_client_manager.ts +13 -5
- package/src/util.ts +8 -2
- 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
|
@@ -3,12 +3,12 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
-
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
7
6
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
8
7
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
9
8
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
10
9
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
11
|
-
import {
|
|
10
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
11
|
+
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
12
12
|
import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
|
|
13
13
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
14
|
|
|
@@ -16,14 +16,12 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
16
16
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
17
17
|
|
|
18
18
|
import type { P2PConfig } from '../../../config.js';
|
|
19
|
+
import { BatchTxRequesterCollector, SendBatchRequestCollector } from '../../../services/index.js';
|
|
19
20
|
import type { IBatchRequestTxValidator } from '../../../services/reqresp/batch-tx-requester/tx_validator.js';
|
|
20
21
|
import { RateLimitStatus } from '../../../services/reqresp/rate-limiter/rate_limiter.js';
|
|
22
|
+
import { MissingTxsTracker } from '../../../services/tx_collection/missing_txs_tracker.js';
|
|
21
23
|
import {
|
|
22
|
-
|
|
23
|
-
SendBatchRequestCollector,
|
|
24
|
-
} from '../../../services/tx_collection/proposal_tx_collector.js';
|
|
25
|
-
import { AlwaysTrueCircuitVerifier } from '../../../test-helpers/reqresp-nodes.js';
|
|
26
|
-
import {
|
|
24
|
+
AlwaysTrueCircuitVerifier,
|
|
27
25
|
BENCHMARK_CONSTANTS,
|
|
28
26
|
InMemoryAttestationPool,
|
|
29
27
|
InMemoryTxPool,
|
|
@@ -31,7 +29,7 @@ import {
|
|
|
31
29
|
calculateInternalTimeout,
|
|
32
30
|
createMockEpochCache,
|
|
33
31
|
createMockWorldStateSynchronizer,
|
|
34
|
-
} from '../../../test-helpers/
|
|
32
|
+
} from '../../../test-helpers/index.js';
|
|
35
33
|
import { createP2PClient } from '../../index.js';
|
|
36
34
|
import type { P2PClient } from '../../p2p_client.js';
|
|
37
35
|
import {
|
|
@@ -116,7 +114,6 @@ async function startClient(config: P2PConfig, clientIndex: number) {
|
|
|
116
114
|
};
|
|
117
115
|
|
|
118
116
|
client = await createP2PClient(
|
|
119
|
-
P2PClientType.Full,
|
|
120
117
|
config as P2PConfig & DataStoreConfig,
|
|
121
118
|
l2BlockSource as L2BlockSource & ContractDataSource,
|
|
122
119
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
@@ -214,7 +211,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
214
211
|
if (collectorType === 'batch-requester') {
|
|
215
212
|
const collector = new BatchTxRequesterCollector(p2pService, logger, new DateProvider(), noopTxValidator);
|
|
216
213
|
const fetched = await executeTimeout(
|
|
217
|
-
(_signal: AbortSignal) =>
|
|
214
|
+
(_signal: AbortSignal) =>
|
|
215
|
+
collector.collectTxs(
|
|
216
|
+
MissingTxsTracker.fromArray(parsedTxHashes),
|
|
217
|
+
parsedProposal,
|
|
218
|
+
pinnedPeer,
|
|
219
|
+
internalTimeoutMs,
|
|
220
|
+
),
|
|
218
221
|
timeoutMs,
|
|
219
222
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
220
223
|
);
|
|
@@ -226,7 +229,13 @@ async function runCollector(cmd: Extract<WorkerCommand, { type: 'RUN_COLLECTOR'
|
|
|
226
229
|
BENCHMARK_CONSTANTS.FIXED_MAX_RETRY_ATTEMPTS,
|
|
227
230
|
);
|
|
228
231
|
const fetched = await executeTimeout(
|
|
229
|
-
(_signal: AbortSignal) =>
|
|
232
|
+
(_signal: AbortSignal) =>
|
|
233
|
+
collector.collectTxs(
|
|
234
|
+
MissingTxsTracker.fromArray(parsedTxHashes),
|
|
235
|
+
parsedProposal,
|
|
236
|
+
pinnedPeer,
|
|
237
|
+
internalTimeoutMs,
|
|
238
|
+
),
|
|
230
239
|
timeoutMs,
|
|
231
240
|
() => new Error(`Collector timed out after ${timeoutMs}ms`),
|
|
232
241
|
);
|
package/src/config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
SecretValue,
|
|
4
|
+
bigintConfigHelper,
|
|
4
5
|
booleanConfigHelper,
|
|
5
6
|
getConfigFromMappings,
|
|
6
7
|
getDefaultConfig,
|
|
@@ -10,10 +11,16 @@ import {
|
|
|
10
11
|
secretStringConfigHelper,
|
|
11
12
|
} from '@aztec/foundation/config';
|
|
12
13
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
14
|
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
type AllowedElement,
|
|
18
|
+
type ChainConfig,
|
|
19
|
+
type SequencerConfig,
|
|
20
|
+
chainConfigMappings,
|
|
21
|
+
sharedSequencerConfigMappings,
|
|
22
|
+
} from '@aztec/stdlib/config';
|
|
23
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
17
24
|
|
|
18
25
|
import {
|
|
19
26
|
type BatchTxRequesterConfig,
|
|
@@ -31,13 +38,26 @@ export interface P2PConfig
|
|
|
31
38
|
BatchTxRequesterConfig,
|
|
32
39
|
ChainConfig,
|
|
33
40
|
TxCollectionConfig,
|
|
34
|
-
TxFileStoreConfig
|
|
41
|
+
TxFileStoreConfig,
|
|
42
|
+
Pick<SequencerConfig, 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock'> {
|
|
43
|
+
/** Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set. */
|
|
44
|
+
validateMaxTxsPerBlock?: number;
|
|
45
|
+
|
|
46
|
+
/** Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
47
|
+
validateMaxL2BlockGas?: number;
|
|
48
|
+
|
|
49
|
+
/** Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected. */
|
|
50
|
+
validateMaxDABlockGas?: number;
|
|
51
|
+
|
|
35
52
|
/** A flag dictating whether the P2P subsystem should be enabled. */
|
|
36
53
|
p2pEnabled: boolean;
|
|
37
54
|
|
|
38
55
|
/** The frequency in which to check for new L2 blocks. */
|
|
39
56
|
blockCheckIntervalMS: number;
|
|
40
57
|
|
|
58
|
+
/** The frequency in which to check for new L2 slots. */
|
|
59
|
+
slotCheckIntervalMS: number;
|
|
60
|
+
|
|
41
61
|
/** The number of blocks to fetch in a single batch. */
|
|
42
62
|
blockRequestBatchSize: number;
|
|
43
63
|
|
|
@@ -140,8 +160,8 @@ export interface P2PConfig
|
|
|
140
160
|
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
141
161
|
p2pStoreMapSizeKb?: number;
|
|
142
162
|
|
|
143
|
-
/**
|
|
144
|
-
|
|
163
|
+
/** Additional entries to extend the default setup allow list. */
|
|
164
|
+
txPublicSetupAllowListExtend: AllowedElement[];
|
|
145
165
|
|
|
146
166
|
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
147
167
|
maxPendingTxCount: number;
|
|
@@ -163,10 +183,7 @@ export interface P2PConfig
|
|
|
163
183
|
/** Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers. */
|
|
164
184
|
disableTransactions: boolean;
|
|
165
185
|
|
|
166
|
-
/**
|
|
167
|
-
dropTransactions: boolean;
|
|
168
|
-
|
|
169
|
-
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
186
|
+
/** The probability that a transaction is discarded (0 = disabled). - For testing purposes only */
|
|
170
187
|
dropTransactionsProbability: number;
|
|
171
188
|
|
|
172
189
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
@@ -177,11 +194,36 @@ export interface P2PConfig
|
|
|
177
194
|
|
|
178
195
|
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
179
196
|
fishermanMode: boolean;
|
|
197
|
+
|
|
198
|
+
/** Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only). */
|
|
199
|
+
broadcastEquivocatedProposals?: boolean;
|
|
200
|
+
|
|
201
|
+
/** Minimum age (ms) a transaction must have been in the pool before it's eligible for block building. */
|
|
202
|
+
minTxPoolAgeMs: number;
|
|
203
|
+
|
|
204
|
+
/** Minimum percentage fee increase required to replace an existing tx via RPC (0 = no bump). */
|
|
205
|
+
priceBumpPercentage: bigint;
|
|
180
206
|
}
|
|
181
207
|
|
|
182
208
|
export const DEFAULT_P2P_PORT = 40400;
|
|
183
209
|
|
|
184
210
|
export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
211
|
+
validateMaxTxsPerBlock: {
|
|
212
|
+
env: 'VALIDATOR_MAX_TX_PER_BLOCK',
|
|
213
|
+
description:
|
|
214
|
+
'Maximum transactions per block for validation. Overrides maxTxsPerBlock for gossip validation when set.',
|
|
215
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
216
|
+
},
|
|
217
|
+
validateMaxL2BlockGas: {
|
|
218
|
+
env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
|
|
219
|
+
description: 'Maximum L2 gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
220
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
221
|
+
},
|
|
222
|
+
validateMaxDABlockGas: {
|
|
223
|
+
env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
|
|
224
|
+
description: 'Maximum DA gas per block for validation. When set, txs exceeding this limit are rejected.',
|
|
225
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
226
|
+
},
|
|
185
227
|
p2pEnabled: {
|
|
186
228
|
env: 'P2P_ENABLED',
|
|
187
229
|
description: 'A flag dictating whether the P2P subsystem should be enabled.',
|
|
@@ -197,6 +239,11 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
197
239
|
description: 'The frequency in which to check for new L2 blocks.',
|
|
198
240
|
...numberConfigHelper(100),
|
|
199
241
|
},
|
|
242
|
+
slotCheckIntervalMS: {
|
|
243
|
+
env: 'P2P_SLOT_CHECK_INTERVAL_MS',
|
|
244
|
+
description: 'The frequency in which to check for new L2 slots.',
|
|
245
|
+
...numberConfigHelper(1000),
|
|
246
|
+
},
|
|
200
247
|
debugDisableColocationPenalty: {
|
|
201
248
|
env: 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY',
|
|
202
249
|
description: 'DEBUG: Disable colocation penalty - NEVER set to true in production',
|
|
@@ -375,12 +422,13 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
375
422
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
376
423
|
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
377
424
|
},
|
|
378
|
-
|
|
425
|
+
txPublicSetupAllowListExtend: {
|
|
379
426
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
380
427
|
parseEnv: (val: string) => parseAllowList(val),
|
|
381
|
-
description:
|
|
428
|
+
description:
|
|
429
|
+
'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 +.',
|
|
382
430
|
printDefault: () =>
|
|
383
|
-
'AuthRegistry
|
|
431
|
+
'Default: AuthRegistry._set_authorized, AuthRegistry.set_authorized, FeeJuice._increase_public_balance',
|
|
384
432
|
},
|
|
385
433
|
maxPendingTxCount: {
|
|
386
434
|
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
@@ -409,11 +457,6 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
409
457
|
description: 'Number of auth attempts to allow before peer is banned. Number is inclusive',
|
|
410
458
|
...numberConfigHelper(3),
|
|
411
459
|
},
|
|
412
|
-
dropTransactions: {
|
|
413
|
-
env: 'P2P_DROP_TX',
|
|
414
|
-
description: 'True to simulate discarding transactions. - For testing purposes only',
|
|
415
|
-
...booleanConfigHelper(false),
|
|
416
|
-
},
|
|
417
460
|
dropTransactionsProbability: {
|
|
418
461
|
env: 'P2P_DROP_TX_CHANCE',
|
|
419
462
|
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
@@ -441,6 +484,23 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
441
484
|
'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
442
485
|
...booleanConfigHelper(false),
|
|
443
486
|
},
|
|
487
|
+
broadcastEquivocatedProposals: {
|
|
488
|
+
description:
|
|
489
|
+
'Broadcast block proposals even when a conflicting proposal for the same slot already exists in the pool (for testing purposes only).',
|
|
490
|
+
...booleanConfigHelper(false),
|
|
491
|
+
},
|
|
492
|
+
minTxPoolAgeMs: {
|
|
493
|
+
env: 'P2P_MIN_TX_POOL_AGE_MS',
|
|
494
|
+
description: 'Minimum age (ms) a transaction must have been in the pool before it is eligible for block building.',
|
|
495
|
+
...numberConfigHelper(2_000),
|
|
496
|
+
},
|
|
497
|
+
priceBumpPercentage: {
|
|
498
|
+
env: 'P2P_RPC_PRICE_BUMP_PERCENTAGE',
|
|
499
|
+
description:
|
|
500
|
+
'Minimum percentage fee increase required to replace an existing tx via RPC. Even at 0%, replacement still requires paying at least 1 unit more.',
|
|
501
|
+
...bigintConfigHelper(10n),
|
|
502
|
+
},
|
|
503
|
+
...sharedSequencerConfigMappings,
|
|
444
504
|
...p2pReqRespConfigMappings,
|
|
445
505
|
...batchTxRequesterConfigMappings,
|
|
446
506
|
...chainConfigMappings,
|
|
@@ -497,13 +557,44 @@ export const bootnodeConfigMappings = pickConfigMappings(
|
|
|
497
557
|
bootnodeConfigKeys,
|
|
498
558
|
);
|
|
499
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Parses a `+`-separated flags string into validation properties for an allow list entry.
|
|
562
|
+
* Supported flags: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
563
|
+
*/
|
|
564
|
+
function parseFlags(
|
|
565
|
+
flags: string,
|
|
566
|
+
entry: string,
|
|
567
|
+
): { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } {
|
|
568
|
+
const result: { onlySelf?: boolean; rejectNullMsgSender?: boolean; calldataLength?: number } = {};
|
|
569
|
+
for (const flag of flags.split('+')) {
|
|
570
|
+
if (flag === 'os') {
|
|
571
|
+
result.onlySelf = true;
|
|
572
|
+
} else if (flag === 'rn') {
|
|
573
|
+
result.rejectNullMsgSender = true;
|
|
574
|
+
} else if (flag.startsWith('cl=')) {
|
|
575
|
+
const n = parseInt(flag.slice(3), 10);
|
|
576
|
+
if (isNaN(n) || n < 0) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
`Invalid allow list entry "${entry}": invalid calldataLength in flag "${flag}". Expected a non-negative integer.`,
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
result.calldataLength = n;
|
|
582
|
+
} else {
|
|
583
|
+
throw new Error(`Invalid allow list entry "${entry}": unknown flag "${flag}". Supported flags: os, rn, cl=N.`);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return result;
|
|
587
|
+
}
|
|
588
|
+
|
|
500
589
|
/**
|
|
501
590
|
* Parses a string to a list of allowed elements.
|
|
502
|
-
* Each
|
|
503
|
-
* `I:${address}`
|
|
504
|
-
* `
|
|
505
|
-
*
|
|
506
|
-
*
|
|
591
|
+
* Each entry is expected to be of one of the following formats:
|
|
592
|
+
* `I:${address}:${selector}` — instance (contract address) with function selector
|
|
593
|
+
* `C:${classId}:${selector}` — class with function selector
|
|
594
|
+
*
|
|
595
|
+
* An optional flags segment can be appended after the selector:
|
|
596
|
+
* `I:${address}:${selector}:${flags}` or `C:${classId}:${selector}:${flags}`
|
|
597
|
+
* where flags is a `+`-separated list of: `os` (onlySelf), `rn` (rejectNullMsgSender), `cl=N` (calldataLength).
|
|
507
598
|
*
|
|
508
599
|
* @param value The string to parse
|
|
509
600
|
* @returns A list of allowed elements
|
|
@@ -516,31 +607,37 @@ export function parseAllowList(value: string): AllowedElement[] {
|
|
|
516
607
|
}
|
|
517
608
|
|
|
518
609
|
for (const val of value.split(',')) {
|
|
519
|
-
const
|
|
520
|
-
|
|
610
|
+
const trimmed = val.trim();
|
|
611
|
+
if (!trimmed) {
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
const [typeString, identifierString, selectorString, flagsString] = trimmed.split(':');
|
|
615
|
+
|
|
616
|
+
if (!selectorString) {
|
|
617
|
+
throw new Error(
|
|
618
|
+
`Invalid allow list entry "${trimmed}": selector is required. Expected format: I:address:selector or C:classId:selector`,
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
const selector = FunctionSelector.fromString(selectorString);
|
|
623
|
+
const flags = flagsString ? parseFlags(flagsString, trimmed) : {};
|
|
521
624
|
|
|
522
625
|
if (typeString === 'I') {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
} else {
|
|
529
|
-
entries.push({
|
|
530
|
-
address: AztecAddress.fromString(identifierString),
|
|
531
|
-
});
|
|
532
|
-
}
|
|
626
|
+
entries.push({
|
|
627
|
+
address: AztecAddress.fromString(identifierString),
|
|
628
|
+
selector,
|
|
629
|
+
...flags,
|
|
630
|
+
});
|
|
533
631
|
} else if (typeString === 'C') {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
632
|
+
entries.push({
|
|
633
|
+
classId: Fr.fromHexString(identifierString),
|
|
634
|
+
selector,
|
|
635
|
+
...flags,
|
|
636
|
+
});
|
|
637
|
+
} else {
|
|
638
|
+
throw new Error(
|
|
639
|
+
`Invalid allow list entry "${trimmed}": unknown type "${typeString}". Expected "I" (instance) or "C" (class).`,
|
|
640
|
+
);
|
|
544
641
|
}
|
|
545
642
|
}
|
|
546
643
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TxPoolRejectionError } from '../mem_pools/tx_pool_v2/eviction/interfaces.js';
|
|
2
|
+
|
|
3
|
+
/** Error thrown when a transaction is not added to the mempool. */
|
|
4
|
+
export class TxPoolError extends Error {
|
|
5
|
+
public readonly data: TxPoolRejectionError;
|
|
6
|
+
|
|
7
|
+
constructor(public readonly reason: TxPoolRejectionError) {
|
|
8
|
+
super(reason.message);
|
|
9
|
+
this.name = 'TxPoolError';
|
|
10
|
+
this.data = reason;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,5 +7,6 @@ export * from './enr/index.js';
|
|
|
7
7
|
export * from './config.js';
|
|
8
8
|
export * from './mem_pools/attestation_pool/index.js';
|
|
9
9
|
export * from './mem_pools/tx_pool/index.js';
|
|
10
|
+
export * from './mem_pools/tx_pool_v2/index.js';
|
|
10
11
|
export * from './msg_validators/index.js';
|
|
11
12
|
export * from './services/index.js';
|
|
@@ -19,13 +19,17 @@ export type TryAddResult = {
|
|
|
19
19
|
added: boolean;
|
|
20
20
|
/** Whether the exact item already existed */
|
|
21
21
|
alreadyExists: boolean;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/** Count of items for the position. Meaning varies by method:
|
|
23
|
+
* - tryAddBlockProposal: proposals at (slot, indexWithinCheckpoint)
|
|
24
|
+
* - tryAddCheckpointProposal: proposals at slot
|
|
25
|
+
* - tryAddCheckpointAttestation: attestations by this signer for this slot */
|
|
26
|
+
count: number;
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
+
export const MAX_CHECKPOINT_PROPOSALS_PER_SLOT = 5;
|
|
30
|
+
export const MAX_BLOCK_PROPOSALS_PER_POSITION = 3;
|
|
31
|
+
/** Maximum attestations a single signer can make per slot before being rejected. */
|
|
32
|
+
export const MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER = 3;
|
|
29
33
|
|
|
30
34
|
/** Public API interface for attestation pools. Used for typing mocks and test implementations. */
|
|
31
35
|
export type AttestationPoolApi = Pick<
|
|
@@ -39,6 +43,7 @@ export type AttestationPoolApi = Pick<
|
|
|
39
43
|
| 'deleteOlderThan'
|
|
40
44
|
| 'getCheckpointAttestationsForSlot'
|
|
41
45
|
| 'getCheckpointAttestationsForSlotAndProposal'
|
|
46
|
+
| 'hasBlockProposalsForSlot'
|
|
42
47
|
| 'isEmpty'
|
|
43
48
|
>;
|
|
44
49
|
|
|
@@ -69,6 +74,10 @@ export class AttestationPool {
|
|
|
69
74
|
// Key: (slot << 10) | indexWithinCheckpoint, Value: archive string
|
|
70
75
|
private blockProposalsForSlotAndIndex: AztecAsyncMultiMap<number, string>;
|
|
71
76
|
|
|
77
|
+
// Checkpoint attestations indexed by (slot, signer) for tracking attestations per (slot, signer) for duplicate detection
|
|
78
|
+
// Key: `${Fr(slot).toString()}-${signerAddress}` string (padded for lexicographic ordering), Value: `proposalId` strings
|
|
79
|
+
private checkpointAttestationsPerSlotAndSigner: AztecAsyncMultiMap<string, string>;
|
|
80
|
+
|
|
72
81
|
constructor(
|
|
73
82
|
private store: AztecAsyncKVStore,
|
|
74
83
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
@@ -80,6 +89,7 @@ export class AttestationPool {
|
|
|
80
89
|
|
|
81
90
|
// Initialize checkpoint attestations storage
|
|
82
91
|
this.checkpointAttestations = store.openMap('checkpoint_attestations');
|
|
92
|
+
this.checkpointAttestationsPerSlotAndSigner = store.openMultiMap('checkpoint_attestations_per_slot_and_signer');
|
|
83
93
|
|
|
84
94
|
// Initialize checkpoint proposal storage
|
|
85
95
|
this.checkpointProposals = store.openMap('checkpoint_proposals');
|
|
@@ -133,6 +143,12 @@ export class AttestationPool {
|
|
|
133
143
|
return { start: `${proposalKey}-`, end: `${proposalKey}-Z` };
|
|
134
144
|
}
|
|
135
145
|
|
|
146
|
+
/** Creates a key for the per-signer-per-slot attestation index. Uses padded slot for lexicographic ordering. */
|
|
147
|
+
private getSlotSignerKey(slot: SlotNumber, signerAddress: string): string {
|
|
148
|
+
const slotStr = new Fr(slot).toString();
|
|
149
|
+
return `${slotStr}-${signerAddress}`;
|
|
150
|
+
}
|
|
151
|
+
|
|
136
152
|
/** Number of bits reserved for indexWithinCheckpoint in position keys. */
|
|
137
153
|
private static readonly INDEX_BITS = 10;
|
|
138
154
|
/** Maximum indexWithinCheckpoint value (2^10 - 1 = 1023). */
|
|
@@ -166,21 +182,21 @@ export class AttestationPool {
|
|
|
166
182
|
// Check if already exists
|
|
167
183
|
const alreadyExists = await this.blockProposals.hasAsync(proposalId);
|
|
168
184
|
if (alreadyExists) {
|
|
169
|
-
const
|
|
185
|
+
const count = await this.getBlockProposalCountForPosition(
|
|
170
186
|
blockProposal.slotNumber,
|
|
171
187
|
blockProposal.indexWithinCheckpoint,
|
|
172
188
|
);
|
|
173
|
-
return { added: false, alreadyExists: true,
|
|
189
|
+
return { added: false, alreadyExists: true, count };
|
|
174
190
|
}
|
|
175
191
|
|
|
176
192
|
// Get current count for position and check cap, do not add if exceeded
|
|
177
|
-
const
|
|
193
|
+
const count = await this.getBlockProposalCountForPosition(
|
|
178
194
|
blockProposal.slotNumber,
|
|
179
195
|
blockProposal.indexWithinCheckpoint,
|
|
180
196
|
);
|
|
181
197
|
|
|
182
|
-
if (
|
|
183
|
-
return { added: false, alreadyExists: false,
|
|
198
|
+
if (count >= MAX_BLOCK_PROPOSALS_PER_POSITION) {
|
|
199
|
+
return { added: false, alreadyExists: false, count };
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
// Add the proposal
|
|
@@ -195,7 +211,7 @@ export class AttestationPool {
|
|
|
195
211
|
},
|
|
196
212
|
);
|
|
197
213
|
|
|
198
|
-
return { added: true, alreadyExists: false,
|
|
214
|
+
return { added: true, alreadyExists: false, count: count + 1 };
|
|
199
215
|
});
|
|
200
216
|
}
|
|
201
217
|
|
|
@@ -239,6 +255,13 @@ export class AttestationPool {
|
|
|
239
255
|
return undefined;
|
|
240
256
|
}
|
|
241
257
|
|
|
258
|
+
/** Checks if any block proposals exist for a given slot (at index 0). */
|
|
259
|
+
public async hasBlockProposalsForSlot(slot: SlotNumber): Promise<boolean> {
|
|
260
|
+
const positionKey = this.getBlockPositionKey(slot, 0);
|
|
261
|
+
const count = await this.blockProposalsForSlotAndIndex.getValueCountAsync(positionKey);
|
|
262
|
+
return count > 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
242
265
|
/**
|
|
243
266
|
* Attempts to add a checkpoint proposal to the pool.
|
|
244
267
|
*
|
|
@@ -261,14 +284,14 @@ export class AttestationPool {
|
|
|
261
284
|
// Check if already exists
|
|
262
285
|
const alreadyExists = await this.checkpointProposals.hasAsync(proposalId);
|
|
263
286
|
if (alreadyExists) {
|
|
264
|
-
const
|
|
265
|
-
return { added: false, alreadyExists: true,
|
|
287
|
+
const count = await this.checkpointProposalsForSlot.getValueCountAsync(proposal.slotNumber);
|
|
288
|
+
return { added: false, alreadyExists: true, count };
|
|
266
289
|
}
|
|
267
290
|
|
|
268
291
|
// Get current count for slot and check cap
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
return { added: false, alreadyExists: false,
|
|
292
|
+
const count = await this.checkpointProposalsForSlot.getValueCountAsync(proposal.slotNumber);
|
|
293
|
+
if (count >= MAX_CHECKPOINT_PROPOSALS_PER_SLOT) {
|
|
294
|
+
return { added: false, alreadyExists: false, count };
|
|
272
295
|
}
|
|
273
296
|
|
|
274
297
|
// Add the proposal if cap not exceeded
|
|
@@ -279,7 +302,7 @@ export class AttestationPool {
|
|
|
279
302
|
slotNumber: proposal.slotNumber,
|
|
280
303
|
});
|
|
281
304
|
|
|
282
|
-
return { added: true, alreadyExists: false,
|
|
305
|
+
return { added: true, alreadyExists: false, count: count + 1 };
|
|
283
306
|
});
|
|
284
307
|
}
|
|
285
308
|
|
|
@@ -336,11 +359,10 @@ export class AttestationPool {
|
|
|
336
359
|
}
|
|
337
360
|
|
|
338
361
|
const address = sender.toString();
|
|
362
|
+
const ownKey = this.getAttestationKey(slotNumber, proposalId, address);
|
|
339
363
|
|
|
340
|
-
await this.checkpointAttestations.set(
|
|
341
|
-
|
|
342
|
-
attestation.toBuffer(),
|
|
343
|
-
);
|
|
364
|
+
await this.checkpointAttestations.set(ownKey, attestation.toBuffer());
|
|
365
|
+
this.metrics.trackMempoolItemAdded(ownKey);
|
|
344
366
|
|
|
345
367
|
this.log.debug(`Added own checkpoint attestation for slot ${slotNumber} from ${address}`, {
|
|
346
368
|
signature: attestation.signature.toString(),
|
|
@@ -406,9 +428,18 @@ export class AttestationPool {
|
|
|
406
428
|
const attestationEndKey = new Fr(oldestSlot).toString();
|
|
407
429
|
for await (const key of this.checkpointAttestations.keysAsync({ end: attestationEndKey })) {
|
|
408
430
|
await this.checkpointAttestations.delete(key);
|
|
431
|
+
this.metrics.trackMempoolItemRemoved(key);
|
|
409
432
|
numberOfAttestations++;
|
|
410
433
|
}
|
|
411
434
|
|
|
435
|
+
// Clean up per-signer-per-slot index. Keys are formatted as `${Fr(slot).toString()}-${signerAddress}`.
|
|
436
|
+
// Since Fr pads to fixed-width hex, Fr(oldestSlot) is lexicographically greater than any key with
|
|
437
|
+
// a smaller slot (even with the signer suffix), so using it as the exclusive end bound is correct.
|
|
438
|
+
const slotSignerEndKey = new Fr(oldestSlot).toString();
|
|
439
|
+
for await (const key of this.checkpointAttestationsPerSlotAndSigner.keysAsync({ end: slotSignerEndKey })) {
|
|
440
|
+
await this.checkpointAttestationsPerSlotAndSigner.delete(key);
|
|
441
|
+
}
|
|
442
|
+
|
|
412
443
|
// Delete checkpoint proposals for slots < oldestSlot, using checkpointProposalsForSlot as index
|
|
413
444
|
for await (const slot of this.checkpointProposalsForSlot.keysAsync({ end: oldestSlot })) {
|
|
414
445
|
const proposalIds = await toArray(this.checkpointProposalsForSlot.getValuesAsync(slot));
|
|
@@ -445,61 +476,82 @@ export class AttestationPool {
|
|
|
445
476
|
*
|
|
446
477
|
* This method performs validation and addition in a single call:
|
|
447
478
|
* - Checks if the attestation already exists (returns alreadyExists: true if so)
|
|
448
|
-
* - Checks if
|
|
479
|
+
* - Checks if this signer has reached the per-signer attestation cap for this slot
|
|
449
480
|
* - Adds the attestation if validation passes
|
|
450
481
|
*
|
|
451
482
|
* @param attestation - The checkpoint attestation to add
|
|
452
|
-
* @
|
|
453
|
-
*
|
|
483
|
+
* @returns Result indicating whether the attestation was added, existence info, and count of
|
|
484
|
+
* attestations by this signer for this slot (for equivocation detection)
|
|
454
485
|
*/
|
|
455
|
-
public async tryAddCheckpointAttestation(
|
|
456
|
-
attestation: CheckpointAttestation,
|
|
457
|
-
committeeSize: number,
|
|
458
|
-
): Promise<TryAddResult> {
|
|
486
|
+
public async tryAddCheckpointAttestation(attestation: CheckpointAttestation): Promise<TryAddResult> {
|
|
459
487
|
const slotNumber = attestation.payload.header.slotNumber;
|
|
460
488
|
const proposalId = attestation.archive.toString();
|
|
461
489
|
const sender = attestation.getSender();
|
|
462
490
|
|
|
463
491
|
if (!sender) {
|
|
464
|
-
return { added: false, alreadyExists: false,
|
|
492
|
+
return { added: false, alreadyExists: false, count: 0 };
|
|
465
493
|
}
|
|
466
494
|
|
|
495
|
+
const signerAddress = sender.toString();
|
|
496
|
+
|
|
467
497
|
return await this.store.transactionAsync(async () => {
|
|
468
|
-
const key = this.getAttestationKey(slotNumber, proposalId,
|
|
498
|
+
const key = this.getAttestationKey(slotNumber, proposalId, signerAddress);
|
|
469
499
|
const alreadyExists = await this.checkpointAttestations.hasAsync(key);
|
|
470
500
|
|
|
501
|
+
// Get count of attestations by this signer for this slot (for duplicate detection)
|
|
502
|
+
const signerAttestationCount = await this.getSignerAttestationCountForSlot(slotNumber, signerAddress);
|
|
503
|
+
|
|
471
504
|
if (alreadyExists) {
|
|
472
|
-
|
|
473
|
-
|
|
505
|
+
return {
|
|
506
|
+
added: false,
|
|
507
|
+
alreadyExists: true,
|
|
508
|
+
count: signerAttestationCount,
|
|
509
|
+
};
|
|
474
510
|
}
|
|
475
511
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
512
|
+
// Check if this signer has exceeded the per-signer cap for this slot
|
|
513
|
+
if (signerAttestationCount >= MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER) {
|
|
514
|
+
this.log.debug(`Rejecting attestation: signer ${signerAddress} exceeded per-slot cap for slot ${slotNumber}`, {
|
|
515
|
+
slotNumber,
|
|
516
|
+
signerAddress,
|
|
517
|
+
proposalId,
|
|
518
|
+
signerAttestationCount,
|
|
519
|
+
});
|
|
520
|
+
return {
|
|
521
|
+
added: false,
|
|
522
|
+
alreadyExists: false,
|
|
523
|
+
count: signerAttestationCount,
|
|
524
|
+
};
|
|
481
525
|
}
|
|
482
526
|
|
|
527
|
+
// Add the attestation
|
|
483
528
|
await this.checkpointAttestations.set(key, attestation.toBuffer());
|
|
529
|
+
this.metrics.trackMempoolItemAdded(key);
|
|
484
530
|
|
|
485
|
-
this
|
|
531
|
+
// Track this attestation in the per-signer-per-slot index for duplicate detection
|
|
532
|
+
const slotSignerKey = this.getSlotSignerKey(slotNumber, signerAddress);
|
|
533
|
+
await this.checkpointAttestationsPerSlotAndSigner.set(slotSignerKey, proposalId);
|
|
534
|
+
|
|
535
|
+
this.log.debug(`Added checkpoint attestation for slot ${slotNumber} from ${signerAddress}`, {
|
|
486
536
|
signature: attestation.signature.toString(),
|
|
487
537
|
slotNumber,
|
|
488
|
-
address:
|
|
538
|
+
address: signerAddress,
|
|
489
539
|
proposalId,
|
|
490
540
|
});
|
|
491
|
-
|
|
541
|
+
|
|
542
|
+
// Return the new count
|
|
543
|
+
return {
|
|
544
|
+
added: true,
|
|
545
|
+
alreadyExists: false,
|
|
546
|
+
count: signerAttestationCount + 1,
|
|
547
|
+
};
|
|
492
548
|
});
|
|
493
549
|
}
|
|
494
550
|
|
|
495
|
-
/** Gets the count of attestations for a given
|
|
496
|
-
private async
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
for await (const _ of this.checkpointAttestations.keysAsync(range)) {
|
|
500
|
-
count++;
|
|
501
|
-
}
|
|
502
|
-
return count;
|
|
551
|
+
/** Gets the count of attestations by a specific signer for a given slot. */
|
|
552
|
+
private async getSignerAttestationCountForSlot(slot: SlotNumber, signerAddress: string): Promise<number> {
|
|
553
|
+
const slotSignerKey = this.getSlotSignerKey(slot, signerAddress);
|
|
554
|
+
return await this.checkpointAttestationsPerSlotAndSigner.getValueCountAsync(slotSignerKey);
|
|
503
555
|
}
|
|
504
556
|
}
|
|
505
557
|
|