@aztec/p2p 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +4 -3
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +4 -4
- package/dest/client/factory.d.ts +10 -10
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +45 -18
- package/dest/client/interface.d.ts +46 -33
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +41 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +156 -200
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +2 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +304 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +73 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +1 -0
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +8 -0
- package/dest/config.d.ts +35 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -7
- 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 +104 -88
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
- 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 +353 -87
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -2
- 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 +3 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/index.js +1 -1
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +2 -2
- package/dest/mem_pools/interface.d.ts +5 -5
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -3
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +3 -2
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +3 -3
- 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 +8 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts +2 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +43 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +103 -0
- package/dest/mem_pools/tx_pool_v2/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 +47 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +128 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +19 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +97 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +10 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +11 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +174 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +25 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +65 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts +17 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +93 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +16 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +78 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +20 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +73 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +19 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts +6 -0
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/index.js +5 -0
- 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 +211 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.js +9 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +119 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +193 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts +26 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_bench_metrics.js +70 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +108 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +354 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +60 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +161 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +77 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +905 -0
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +3 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +40 -9
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -5
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +18 -6
- package/dest/msg_validators/clock_tolerance.d.ts +21 -0
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -0
- package/dest/msg_validators/clock_tolerance.js +37 -0
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +46 -15
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +3 -3
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +66 -11
- 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/archive_cache.d.ts +3 -3
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +20 -6
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +4 -3
- package/dest/msg_validators/tx_validator/data_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +4 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +15 -4
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +7 -6
- package/dest/msg_validators/tx_validator/factory.d.ts +118 -5
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +228 -57
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +59 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +76 -38
- 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 +3 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +2 -2
- 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 +3 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +3 -3
- package/dest/msg_validators/tx_validator/size_validator.d.ts +3 -1
- package/dest/msg_validators/tx_validator/size_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/size_validator.js +4 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +22 -5
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +8 -8
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +2 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +3 -2
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -2
- 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 +10 -6
- package/dest/services/discv5/discV5_service.js +1 -1
- package/dest/services/dummy_service.d.ts +24 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +46 -1
- 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/index.d.ts +2 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +1 -0
- package/dest/services/libp2p/instrumentation.d.ts +1 -1
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -1
- package/dest/services/libp2p/instrumentation.js +14 -3
- package/dest/services/libp2p/libp2p_service.d.ts +101 -43
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +455 -363
- package/dest/services/peer-manager/metrics.d.ts +2 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +20 -5
- 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 +33 -4
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +48 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +539 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts +17 -0
- package/dest/services/reqresp/batch-tx-requester/config.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/config.js +27 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +46 -0
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/interface.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +34 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +130 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +60 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +173 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +20 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -0
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +21 -0
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +22 -3
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +63 -4
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +12 -0
- package/dest/services/reqresp/interface.d.ts +14 -3
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +17 -3
- package/dest/services/reqresp/metrics.d.ts +6 -5
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +17 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +5 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +5 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +27 -9
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +29 -6
- 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 +59 -13
- 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 +6 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +71 -27
- package/dest/services/service.d.ts +42 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +22 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +55 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +7 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +71 -44
- 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 +3 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +2 -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 +10 -2
- 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 +49 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -0
- package/dest/services/tx_collection/proposal_tx_collector.js +50 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +9 -5
- 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 +29 -16
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +79 -7
- 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 +16 -0
- package/dest/services/tx_file_store/config.d.ts.map +1 -0
- package/dest/services/tx_file_store/config.js +22 -0
- package/dest/services/tx_file_store/index.d.ts +4 -0
- package/dest/services/tx_file_store/index.d.ts.map +1 -0
- package/dest/services/tx_file_store/index.js +3 -0
- package/dest/services/tx_file_store/instrumentation.d.ts +15 -0
- package/dest/services/tx_file_store/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_file_store/instrumentation.js +29 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts +48 -0
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -0
- package/dest/services/tx_file_store/tx_file_store.js +152 -0
- package/dest/services/tx_provider.d.ts +6 -6
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -1
- package/dest/services/tx_provider_instrumentation.js +5 -5
- package/dest/test-helpers/index.d.ts +3 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +2 -0
- 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/test_tx_provider.d.ts +40 -0
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -0
- package/dest/test-helpers/test_tx_provider.js +41 -0
- package/dest/test-helpers/testbench-utils.d.ts +163 -0
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -0
- package/dest/test-helpers/testbench-utils.js +366 -0
- package/dest/testbench/p2p_client_testbench_worker.d.ts +28 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +219 -137
- package/dest/testbench/worker_client_manager.d.ts +51 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +226 -44
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/bootstrap/bootstrap.ts +7 -4
- package/src/client/factory.ts +83 -36
- package/src/client/interface.ts +56 -34
- package/src/client/p2p_client.ts +196 -251
- package/src/client/test/tx_proposal_collector/README.md +227 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +345 -0
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +43 -0
- package/src/config.ts +47 -11
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
- package/src/mem_pools/attestation_pool/index.ts +9 -2
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +4 -1
- package/src/mem_pools/instrumentation.ts +2 -1
- package/src/mem_pools/interface.ts +4 -4
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +2 -2
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +2 -1
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +10 -7
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +4 -2
- package/src/mem_pools/tx_pool_v2/README.md +275 -0
- package/src/mem_pools/tx_pool_v2/archive/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +120 -0
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +160 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +121 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +125 -0
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +27 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +209 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +74 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +101 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +91 -0
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +90 -0
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +31 -0
- package/src/mem_pools/tx_pool_v2/index.ts +12 -0
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +242 -0
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +297 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_bench_metrics.ts +77 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +444 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +223 -0
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +1083 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +25 -13
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +16 -10
- package/src/msg_validators/clock_tolerance.ts +51 -0
- package/src/msg_validators/proposal_validator/proposal_validator.ts +21 -14
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +53 -14
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/archive_cache.ts +3 -3
- package/src/msg_validators/tx_validator/block_header_validator.ts +21 -8
- package/src/msg_validators/tx_validator/data_validator.ts +6 -2
- package/src/msg_validators/tx_validator/double_spend_validator.ts +15 -9
- package/src/msg_validators/tx_validator/factory.ts +372 -55
- package/src/msg_validators/tx_validator/gas_validator.ts +98 -29
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +6 -3
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +5 -3
- package/src/msg_validators/tx_validator/size_validator.ts +6 -2
- package/src/msg_validators/tx_validator/timestamp_validator.ts +29 -21
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +8 -3
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +8 -3
- package/src/services/data_store.ts +10 -7
- package/src/services/discv5/discV5_service.ts +1 -1
- package/src/services/dummy_service.ts +59 -2
- 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/index.ts +1 -0
- package/src/services/libp2p/instrumentation.ts +15 -2
- package/src/services/libp2p/libp2p_service.ts +505 -396
- package/src/services/peer-manager/metrics.ts +21 -4
- package/src/services/peer-manager/peer_scoring.ts +29 -1
- package/src/services/reqresp/batch-tx-requester/README.md +305 -0
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +678 -0
- package/src/services/reqresp/batch-tx-requester/config.ts +40 -0
- package/src/services/reqresp/batch-tx-requester/interface.ts +53 -0
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +161 -0
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +244 -0
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +37 -0
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +65 -4
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +16 -0
- package/src/services/reqresp/interface.ts +31 -3
- package/src/services/reqresp/metrics.ts +34 -9
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +7 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +35 -12
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +74 -9
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +82 -23
- package/src/services/service.ts +55 -2
- package/src/services/tx_collection/config.ts +83 -1
- package/src/services/tx_collection/fast_tx_collection.ts +93 -47
- 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 +6 -0
- package/src/services/tx_collection/instrumentation.ts +17 -2
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +113 -0
- package/src/services/tx_collection/slow_tx_collection.ts +68 -35
- package/src/services/tx_collection/tx_collection.ts +121 -24
- 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 +37 -0
- package/src/services/tx_file_store/index.ts +3 -0
- package/src/services/tx_file_store/instrumentation.ts +36 -0
- package/src/services/tx_file_store/tx_file_store.ts +175 -0
- package/src/services/tx_provider.ts +12 -11
- package/src/services/tx_provider_instrumentation.ts +11 -5
- package/src/test-helpers/index.ts +2 -0
- package/src/test-helpers/make-test-p2p-clients.ts +3 -5
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +4 -6
- package/src/test-helpers/test_tx_provider.ts +64 -0
- package/src/test-helpers/testbench-utils.ts +430 -0
- package/src/testbench/p2p_client_testbench_worker.ts +333 -131
- package/src/testbench/worker_client_manager.ts +304 -47
- package/src/util.ts +7 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type CheckpointAttestation,
|
|
6
|
+
type P2PValidator,
|
|
7
|
+
PeerErrorSeverity,
|
|
8
|
+
type ValidationResult,
|
|
9
|
+
} from '@aztec/stdlib/p2p';
|
|
10
|
+
|
|
11
|
+
import { isWithinClockTolerance } from '../clock_tolerance.js';
|
|
5
12
|
|
|
6
13
|
export class CheckpointAttestationValidator implements P2PValidator<CheckpointAttestation> {
|
|
7
14
|
protected epochCache: EpochCacheInterface;
|
|
@@ -12,30 +19,35 @@ export class CheckpointAttestationValidator implements P2PValidator<CheckpointAt
|
|
|
12
19
|
this.logger = createLogger('p2p:checkpoint-attestation-validator');
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
async validate(message: CheckpointAttestation): Promise<
|
|
22
|
+
async validate(message: CheckpointAttestation): Promise<ValidationResult> {
|
|
16
23
|
const slotNumber = message.payload.header.slotNumber;
|
|
17
24
|
|
|
18
25
|
try {
|
|
19
26
|
const { currentSlot, nextSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
20
27
|
|
|
21
28
|
if (slotNumber !== currentSlot && slotNumber !== nextSlot) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
// Check if message is for previous slot and within clock tolerance
|
|
30
|
+
if (!isWithinClockTolerance(slotNumber, currentSlot, this.epochCache)) {
|
|
31
|
+
this.logger.warn(
|
|
32
|
+
`Checkpoint attestation slot ${slotNumber} is not current (${currentSlot}) or next (${nextSlot}) slot`,
|
|
33
|
+
);
|
|
34
|
+
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
35
|
+
}
|
|
36
|
+
this.logger.debug(`Ignoring checkpoint attestation for previous slot ${slotNumber} within clock tolerance`);
|
|
37
|
+
return { result: 'ignore' };
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
// Verify the signature is valid
|
|
29
41
|
const attester = message.getSender();
|
|
30
42
|
if (attester === undefined) {
|
|
31
43
|
this.logger.warn(`Invalid signature in checkpoint attestation for slot ${slotNumber}`);
|
|
32
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
44
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
// Verify the attester is in the committee for this slot
|
|
36
48
|
if (!(await this.epochCache.isInCommittee(slotNumber, attester))) {
|
|
37
49
|
this.logger.warn(`Attester ${attester.toString()} is not in committee for slot ${slotNumber}`);
|
|
38
|
-
return PeerErrorSeverity.HighToleranceError;
|
|
50
|
+
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
// Verify the proposer signature matches the expected proposer for the attestation's slot
|
|
@@ -45,26 +57,26 @@ export class CheckpointAttestationValidator implements P2PValidator<CheckpointAt
|
|
|
45
57
|
const expectedProposer = await this.epochCache.getProposerAttesterAddressInSlot(slotNumber);
|
|
46
58
|
if (!expectedProposer) {
|
|
47
59
|
this.logger.warn(`No proposer defined for slot ${slotNumber}`);
|
|
48
|
-
return PeerErrorSeverity.HighToleranceError;
|
|
60
|
+
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
49
61
|
}
|
|
50
62
|
if (!proposer) {
|
|
51
63
|
this.logger.warn(`Invalid proposer signature in checkpoint attestation for slot ${slotNumber}`);
|
|
52
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
64
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
53
65
|
}
|
|
54
66
|
if (!proposer.equals(expectedProposer)) {
|
|
55
67
|
this.logger.warn(
|
|
56
68
|
`Proposer signature mismatch in checkpoint attestation. ` +
|
|
57
69
|
`Expected ${expectedProposer?.toString() ?? 'none'} but got ${proposer.toString()} for slot ${slotNumber}`,
|
|
58
70
|
);
|
|
59
|
-
return PeerErrorSeverity.HighToleranceError;
|
|
71
|
+
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
60
72
|
}
|
|
61
73
|
|
|
62
|
-
return
|
|
74
|
+
return { result: 'accept' };
|
|
63
75
|
} catch (e) {
|
|
64
76
|
// People shouldn't be sending us attestations if the committee doesn't exist
|
|
65
77
|
if (e instanceof NoCommitteeError) {
|
|
66
78
|
this.logger.warn(`No committee exists for checkpoint attestation for slot ${slotNumber}`);
|
|
67
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
79
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
68
80
|
}
|
|
69
81
|
throw e;
|
|
70
82
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import { type CheckpointAttestation, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
|
-
import { Attributes, Metrics, type TelemetryClient } from '@aztec/telemetry-client';
|
|
2
|
+
import { type CheckpointAttestation, PeerErrorSeverity, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { Attributes, Metrics, type TelemetryClient, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { AttestationPoolApi } from '../../mem_pools/attestation_pool/attestation_pool.js';
|
|
6
6
|
import { CheckpointAttestationValidator } from './attestation_validator.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -18,20 +18,26 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
|
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
epochCache: EpochCacheInterface,
|
|
21
|
-
private attestationPool:
|
|
21
|
+
private attestationPool: AttestationPoolApi,
|
|
22
22
|
telemetryClient: TelemetryClient,
|
|
23
23
|
) {
|
|
24
24
|
super(epochCache);
|
|
25
25
|
this.logger = this.logger.createChild('[FISHERMAN]');
|
|
26
26
|
|
|
27
27
|
const meter = telemetryClient.getMeter('FishermanAttestationValidator');
|
|
28
|
-
this.invalidAttestationCounter =
|
|
28
|
+
this.invalidAttestationCounter = createUpDownCounterWithDefault(
|
|
29
|
+
meter,
|
|
30
|
+
Metrics.VALIDATOR_INVALID_ATTESTATION_RECEIVED_COUNT,
|
|
31
|
+
{
|
|
32
|
+
[Attributes.ERROR_TYPE]: ['base_validation_failed', 'payload_mismatch'],
|
|
33
|
+
},
|
|
34
|
+
);
|
|
29
35
|
}
|
|
30
36
|
|
|
31
|
-
override async validate(message: CheckpointAttestation): Promise<
|
|
37
|
+
override async validate(message: CheckpointAttestation): Promise<ValidationResult> {
|
|
32
38
|
// First run the standard validation
|
|
33
39
|
const baseValidationResult = await super.validate(message);
|
|
34
|
-
if (baseValidationResult !==
|
|
40
|
+
if (baseValidationResult.result !== 'accept') {
|
|
35
41
|
// Track base validation failures (invalid signature, wrong committee, etc.)
|
|
36
42
|
this.invalidAttestationCounter.add(1, {
|
|
37
43
|
[Attributes.ERROR_TYPE]: 'base_validation_failed',
|
|
@@ -45,7 +51,7 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
|
|
|
45
51
|
const proposer = message.getProposer();
|
|
46
52
|
|
|
47
53
|
if (!attester || !proposer) {
|
|
48
|
-
return
|
|
54
|
+
return { result: 'accept' };
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
const proposalId = message.archive.toString();
|
|
@@ -74,7 +80,7 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
|
|
|
74
80
|
});
|
|
75
81
|
|
|
76
82
|
// Return error to reject the message, but LibP2PService won't penalize in fisherman mode
|
|
77
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
83
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
78
84
|
}
|
|
79
85
|
} else {
|
|
80
86
|
// We might receive attestations before proposals in some cases
|
|
@@ -83,6 +89,6 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
|
|
|
83
89
|
);
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
return
|
|
92
|
+
return { result: 'accept' };
|
|
87
93
|
}
|
|
88
94
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Maximum clock disparity tolerance for P2P message validation (in milliseconds).
|
|
6
|
+
* Messages for the previous slot are accepted if we're within this many milliseconds
|
|
7
|
+
* of the current slot start. This prevents penalizing peers for messages that
|
|
8
|
+
* were valid when sent but arrived slightly late due to network latency.
|
|
9
|
+
*
|
|
10
|
+
* This follows Ethereum's MAXIMUM_GOSSIP_CLOCK_DISPARITY approach.
|
|
11
|
+
*/
|
|
12
|
+
export const MAXIMUM_GOSSIP_CLOCK_DISPARITY_MS = 500;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a message for the previous slot should be accepted due to clock tolerance.
|
|
16
|
+
*
|
|
17
|
+
* @param messageSlot - The slot number from the received message
|
|
18
|
+
* @param currentSlot - The current slot number
|
|
19
|
+
* @param epochCache - EpochCache to get timing information
|
|
20
|
+
* @returns true if the message is for the previous slot AND we're within the clock tolerance window
|
|
21
|
+
*/
|
|
22
|
+
export function isWithinClockTolerance(
|
|
23
|
+
messageSlot: SlotNumber,
|
|
24
|
+
currentSlot: SlotNumber,
|
|
25
|
+
epochCache: EpochCacheInterface,
|
|
26
|
+
): boolean {
|
|
27
|
+
// Guard against slot 0 edge case (genesis)
|
|
28
|
+
if (currentSlot === SlotNumber.ZERO) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Only apply tolerance to messages for the previous slot
|
|
33
|
+
const previousSlot = SlotNumber(currentSlot - 1);
|
|
34
|
+
if (messageSlot !== previousSlot) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check how far we are into the current slot (in milliseconds)
|
|
39
|
+
const { ts: slotStartTs, nowMs, slot } = epochCache.getEpochAndSlotNow();
|
|
40
|
+
|
|
41
|
+
// Sanity check: ensure the epoch cache's current slot matches the expected current slot
|
|
42
|
+
if (slot !== currentSlot) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ts is in seconds, convert to ms; nowMs is already in milliseconds
|
|
47
|
+
const slotStartMs = slotStartTs * 1000n;
|
|
48
|
+
const elapsedMs = Number(nowMs - slotStartMs);
|
|
49
|
+
|
|
50
|
+
return elapsedMs < MAXIMUM_GOSSIP_CLOCK_DISPARITY_MS;
|
|
51
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { NoCommitteeError } from '@aztec/ethereum/contracts';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { BlockProposal, CheckpointProposal, PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { BlockProposal, CheckpointProposal, PeerErrorSeverity, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
5
|
+
|
|
6
|
+
import { isWithinClockTolerance } from '../clock_tolerance.js';
|
|
5
7
|
|
|
6
8
|
export abstract class ProposalValidator<TProposal extends BlockProposal | CheckpointProposal> {
|
|
7
9
|
protected epochCache: EpochCacheInterface;
|
|
@@ -14,30 +16,35 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
14
16
|
this.logger = createLogger(loggerName);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
public async validate(proposal: TProposal): Promise<
|
|
19
|
+
public async validate(proposal: TProposal): Promise<ValidationResult> {
|
|
18
20
|
try {
|
|
19
21
|
// Slot check
|
|
20
22
|
const { currentSlot, nextSlot } = this.epochCache.getCurrentAndNextSlot();
|
|
21
23
|
const slotNumber = proposal.slotNumber;
|
|
22
24
|
if (slotNumber !== currentSlot && slotNumber !== nextSlot) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// Check if message is for previous slot and within clock tolerance
|
|
26
|
+
if (!isWithinClockTolerance(slotNumber, currentSlot, this.epochCache)) {
|
|
27
|
+
this.logger.warn(`Penalizing peer for invalid slot number ${slotNumber}`, { currentSlot, nextSlot });
|
|
28
|
+
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
29
|
+
}
|
|
30
|
+
this.logger.verbose(`Ignoring proposal for previous slot ${slotNumber} within clock tolerance`);
|
|
31
|
+
return { result: 'ignore' };
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
// Signature validity
|
|
28
35
|
const proposer = proposal.getSender();
|
|
29
36
|
if (!proposer) {
|
|
30
|
-
this.logger.
|
|
31
|
-
return PeerErrorSeverity.MidToleranceError;
|
|
37
|
+
this.logger.warn(`Penalizing peer for proposal with invalid signature`);
|
|
38
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
// Transactions permitted check
|
|
35
42
|
const embeddedTxCount = proposal.txs?.length ?? 0;
|
|
36
43
|
if (!this.txsPermitted && (proposal.txHashes.length > 0 || embeddedTxCount > 0)) {
|
|
37
|
-
this.logger.
|
|
44
|
+
this.logger.warn(
|
|
38
45
|
`Penalizing peer for proposal with ${proposal.txHashes.length} transaction(s) when transactions are not permitted`,
|
|
39
46
|
);
|
|
40
|
-
return PeerErrorSeverity.MidToleranceError;
|
|
47
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
// Embedded txs must be listed in txHashes
|
|
@@ -52,17 +59,17 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
52
59
|
txHashesLength: proposal.txHashes.length,
|
|
53
60
|
missingTxHashes,
|
|
54
61
|
});
|
|
55
|
-
return PeerErrorSeverity.MidToleranceError;
|
|
62
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
// Proposer check
|
|
59
66
|
const expectedProposer = await this.epochCache.getProposerAttesterAddressInSlot(slotNumber);
|
|
60
67
|
if (expectedProposer !== undefined && !proposer.equals(expectedProposer)) {
|
|
61
|
-
this.logger.
|
|
68
|
+
this.logger.warn(`Penalizing peer for invalid proposer for current slot ${slotNumber}`, {
|
|
62
69
|
expectedProposer,
|
|
63
70
|
proposer: proposer.toString(),
|
|
64
71
|
});
|
|
65
|
-
return PeerErrorSeverity.MidToleranceError;
|
|
72
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
// Validate tx hashes for all txs embedded in the proposal
|
|
@@ -71,13 +78,13 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
71
78
|
proposer,
|
|
72
79
|
slotNumber,
|
|
73
80
|
});
|
|
74
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
81
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
return
|
|
84
|
+
return { result: 'accept' };
|
|
78
85
|
} catch (e) {
|
|
79
86
|
if (e instanceof NoCommitteeError) {
|
|
80
|
-
return PeerErrorSeverity.LowToleranceError;
|
|
87
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
81
88
|
}
|
|
82
89
|
throw e;
|
|
83
90
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
type BlockProposal,
|
|
6
|
+
type CheckpointProposal,
|
|
7
|
+
PeerErrorSeverity,
|
|
8
|
+
type ValidationResult,
|
|
9
|
+
} from '@aztec/stdlib/p2p';
|
|
5
10
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
11
|
|
|
7
12
|
import type { MockProxy } from 'jest-mock-extended';
|
|
@@ -10,7 +15,7 @@ export interface ProposalValidatorTestParams<TProposal extends BlockProposal | C
|
|
|
10
15
|
validatorFactory: (
|
|
11
16
|
epochCache: EpochCacheInterface,
|
|
12
17
|
opts: { txsPermitted: boolean },
|
|
13
|
-
) => { validate: (proposal: TProposal) => Promise<
|
|
18
|
+
) => { validate: (proposal: TProposal) => Promise<ValidationResult> };
|
|
14
19
|
makeProposal: (options?: any) => Promise<TProposal>;
|
|
15
20
|
makeHeader: (epochNumber: number | bigint, slotNumber: number | bigint, blockNumber: number | bigint) => any;
|
|
16
21
|
getSigner: () => Secp256k1Signer;
|
|
@@ -29,11 +34,12 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
29
34
|
|
|
30
35
|
describe('shared proposal validation logic', () => {
|
|
31
36
|
let epochCache: MockProxy<EpochCacheInterface>;
|
|
32
|
-
let validator: { validate: (proposal: TProposal) => Promise<
|
|
37
|
+
let validator: { validate: (proposal: TProposal) => Promise<ValidationResult> };
|
|
38
|
+
const previousSlot = getSlot(99);
|
|
33
39
|
const currentSlot = getSlot(100);
|
|
34
40
|
const nextSlot = getSlot(101);
|
|
35
41
|
|
|
36
|
-
function mockGetProposer(currentProposer: EthAddress, nextProposer: EthAddress) {
|
|
42
|
+
function mockGetProposer(currentProposer: EthAddress, nextProposer: EthAddress, previousProposer?: EthAddress) {
|
|
37
43
|
epochCache.getProposerAttesterAddressInSlot.mockImplementation(slot => {
|
|
38
44
|
if (slot === currentSlot) {
|
|
39
45
|
return Promise.resolve(currentProposer);
|
|
@@ -41,6 +47,9 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
41
47
|
if (slot === nextSlot) {
|
|
42
48
|
return Promise.resolve(nextProposer);
|
|
43
49
|
}
|
|
50
|
+
if (slot === previousSlot && previousProposer) {
|
|
51
|
+
return Promise.resolve(previousProposer);
|
|
52
|
+
}
|
|
44
53
|
throw new Error('Unexpected argument');
|
|
45
54
|
});
|
|
46
55
|
}
|
|
@@ -54,18 +63,48 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
54
63
|
});
|
|
55
64
|
});
|
|
56
65
|
|
|
57
|
-
it('returns high tolerance error if slot number is not current or next slot', async () => {
|
|
66
|
+
it('returns high tolerance error if slot number is not current or next slot (outside clock tolerance)', async () => {
|
|
58
67
|
const header = makeHeader(1, 99, 99);
|
|
59
68
|
const mockProposal = await makeProposal({ blockHeader: header, lastBlockHeader: header });
|
|
60
69
|
|
|
70
|
+
// Mock getEpochAndSlotNow to return time OUTSIDE clock tolerance (1000ms elapsed)
|
|
71
|
+
epochCache.getEpochAndSlotNow.mockReturnValue({
|
|
72
|
+
epoch: 1 as any,
|
|
73
|
+
slot: currentSlot,
|
|
74
|
+
ts: 1000n, // slot started at 1000 seconds
|
|
75
|
+
nowMs: 1001000n, // 1000ms elapsed, outside 500ms tolerance
|
|
76
|
+
});
|
|
77
|
+
|
|
61
78
|
epochCache.getProposerAttesterAddressInSlot.mockResolvedValue(getAddress());
|
|
62
79
|
const result = await validator.validate(mockProposal);
|
|
63
|
-
expect(result).
|
|
80
|
+
expect(result).toEqual({ result: 'reject', severity: PeerErrorSeverity.HighToleranceError });
|
|
64
81
|
|
|
65
82
|
// Should not try to resolve proposers if base validation fails
|
|
66
83
|
expect(epochCache.getProposerAttesterAddressInSlot).not.toHaveBeenCalled();
|
|
67
84
|
});
|
|
68
85
|
|
|
86
|
+
it('returns ignore if previous slot proposal is within clock tolerance', async () => {
|
|
87
|
+
const previousProposer = getSigner();
|
|
88
|
+
const header = makeHeader(1, 99, 99);
|
|
89
|
+
const mockProposal = await makeProposal({
|
|
90
|
+
blockHeader: header,
|
|
91
|
+
lastBlockHeader: header,
|
|
92
|
+
signer: previousProposer,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Mock getEpochAndSlotNow to return time WITHIN clock tolerance (100ms elapsed)
|
|
96
|
+
epochCache.getEpochAndSlotNow.mockReturnValue({
|
|
97
|
+
epoch: 1 as any,
|
|
98
|
+
slot: currentSlot,
|
|
99
|
+
ts: 1000n, // slot started at 1000 seconds
|
|
100
|
+
nowMs: 1000100n, // 100ms elapsed, within 500ms tolerance
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
mockGetProposer(getAddress(), getAddress(), getAddress(previousProposer));
|
|
104
|
+
const result = await validator.validate(mockProposal);
|
|
105
|
+
expect(result).toEqual({ result: 'ignore' });
|
|
106
|
+
});
|
|
107
|
+
|
|
69
108
|
it('returns mid tolerance error if proposer is not current proposer for current slot', async () => {
|
|
70
109
|
const currentProposer = getSigner();
|
|
71
110
|
const nextProposer = getSigner();
|
|
@@ -79,7 +118,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
79
118
|
|
|
80
119
|
mockGetProposer(getAddress(currentProposer), getAddress(nextProposer));
|
|
81
120
|
const result = await validator.validate(mockProposal);
|
|
82
|
-
expect(result).
|
|
121
|
+
expect(result).toEqual({ result: 'reject', severity: PeerErrorSeverity.MidToleranceError });
|
|
83
122
|
});
|
|
84
123
|
|
|
85
124
|
it('returns mid tolerance error if proposer is not next proposer for next slot', async () => {
|
|
@@ -95,7 +134,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
95
134
|
|
|
96
135
|
mockGetProposer(getAddress(currentProposer), getAddress(nextProposer));
|
|
97
136
|
const result = await validator.validate(mockProposal);
|
|
98
|
-
expect(result).
|
|
137
|
+
expect(result).toEqual({ result: 'reject', severity: PeerErrorSeverity.MidToleranceError });
|
|
99
138
|
});
|
|
100
139
|
|
|
101
140
|
it('returns mid tolerance error if proposer is current proposer but proposal is for next slot', async () => {
|
|
@@ -110,7 +149,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
110
149
|
|
|
111
150
|
mockGetProposer(getAddress(currentProposer), getAddress(nextProposer));
|
|
112
151
|
const result = await validator.validate(mockProposal);
|
|
113
|
-
expect(result).
|
|
152
|
+
expect(result).toEqual({ result: 'reject', severity: PeerErrorSeverity.MidToleranceError });
|
|
114
153
|
});
|
|
115
154
|
|
|
116
155
|
it('returns undefined if proposal is valid for current slot and proposer', async () => {
|
|
@@ -125,7 +164,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
125
164
|
|
|
126
165
|
mockGetProposer(getAddress(currentProposer), getAddress(nextProposer));
|
|
127
166
|
const result = await validator.validate(mockProposal);
|
|
128
|
-
expect(result).
|
|
167
|
+
expect(result).toEqual({ result: 'accept' });
|
|
129
168
|
});
|
|
130
169
|
|
|
131
170
|
it('returns undefined if proposal is valid for next slot and proposer', async () => {
|
|
@@ -136,7 +175,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
136
175
|
|
|
137
176
|
mockGetProposer(getAddress(currentProposer), getAddress(nextProposer));
|
|
138
177
|
const result = await validator.validate(mockProposal);
|
|
139
|
-
expect(result).
|
|
178
|
+
expect(result).toEqual({ result: 'accept' });
|
|
140
179
|
});
|
|
141
180
|
|
|
142
181
|
describe('transaction permission validation', () => {
|
|
@@ -153,7 +192,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
153
192
|
|
|
154
193
|
mockGetProposer(getAddress(currentProposer), getAddress());
|
|
155
194
|
const result = await validatorWithTxsDisabled.validate(mockProposal);
|
|
156
|
-
expect(result).
|
|
195
|
+
expect(result).toEqual({ result: 'reject', severity: PeerErrorSeverity.MidToleranceError });
|
|
157
196
|
});
|
|
158
197
|
|
|
159
198
|
it('returns undefined if txs not permitted but proposal has no txHashes', async () => {
|
|
@@ -169,7 +208,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
169
208
|
|
|
170
209
|
mockGetProposer(getAddress(currentProposer), getAddress());
|
|
171
210
|
const result = await validatorWithTxsDisabled.validate(mockProposal);
|
|
172
|
-
expect(result).
|
|
211
|
+
expect(result).toEqual({ result: 'accept' });
|
|
173
212
|
});
|
|
174
213
|
|
|
175
214
|
it('returns undefined if txs permitted and proposal contains txHashes', async () => {
|
|
@@ -184,7 +223,7 @@ export function sharedProposalValidatorTests<TProposal extends BlockProposal | C
|
|
|
184
223
|
|
|
185
224
|
mockGetProposer(getAddress(currentProposer), getAddress());
|
|
186
225
|
const result = await validator.validate(mockProposal);
|
|
187
|
-
expect(result).
|
|
226
|
+
expect(result).toEqual({ result: 'accept' });
|
|
188
227
|
});
|
|
189
228
|
});
|
|
190
229
|
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Transaction Validation
|
|
2
|
+
|
|
3
|
+
This module defines the transaction validators and the factory functions that assemble them for each entry point into the system.
|
|
4
|
+
|
|
5
|
+
## Validation Strategy
|
|
6
|
+
|
|
7
|
+
Transactions enter the system through different paths. **Unsolicited** transactions (gossip and RPC) are fully validated before acceptance. **Solicited** transactions (req/resp and block proposals) are only checked for well-formedness because we must store them for block re-execution — they may ultimately be invalid, which is caught during block building and reported as part of block validation/attestation.
|
|
8
|
+
|
|
9
|
+
When solicited transactions fail to be mined, they may be migrated to the pending pool. At that point, the pool runs the state-dependent checks that were skipped on initial receipt.
|
|
10
|
+
|
|
11
|
+
## Entry Points
|
|
12
|
+
|
|
13
|
+
### 1. Gossip (libp2p pubsub)
|
|
14
|
+
|
|
15
|
+
**Factory**: `createFirstStageTxValidationsForGossipedTransactions` + `createSecondStageTxValidationsForGossipedTransactions`
|
|
16
|
+
**Called from**: `LibP2PService.handleGossipedTx()` in `libp2p_service.ts`
|
|
17
|
+
|
|
18
|
+
Unsolicited transactions from any peer. Fully validated in two stages with a pool pre-check in between to avoid wasting CPU on proof verification for transactions the pool would reject:
|
|
19
|
+
|
|
20
|
+
| Step | What runs | On failure |
|
|
21
|
+
|------|-----------|------------|
|
|
22
|
+
| **Stage 1** (fast) | TxPermitted, Data, Metadata, Timestamp, DoubleSpend, Gas, Phases, BlockHeader | Penalize peer, reject tx |
|
|
23
|
+
| **Pool pre-check** | `canAddPendingTx` — checks for duplicates, pool capacity | Ignore tx (no penalty) |
|
|
24
|
+
| **Stage 2** (slow) | Proof verification | Penalize peer, reject tx |
|
|
25
|
+
| **Pool add** | `addPendingTxs` | Accept, ignore, or reject |
|
|
26
|
+
|
|
27
|
+
Each stage-1 and stage-2 validator is paired with a `PeerErrorSeverity`. If a validator fails, the sending peer is penalized with that severity. The `doubleSpendValidator` has special handling: its severity is determined by how recently the nullifier appeared (recent = high tolerance, old = low tolerance).
|
|
28
|
+
|
|
29
|
+
### 2. JSON-RPC
|
|
30
|
+
|
|
31
|
+
**Factory**: `createTxValidatorForAcceptingTxsOverRPC`
|
|
32
|
+
**Called from**: `AztecNodeService.isValidTx()` in `aztec-node/server.ts`
|
|
33
|
+
|
|
34
|
+
Unsolicited transactions from a local wallet/PXE. Runs the full set of checks as a single aggregate validator:
|
|
35
|
+
|
|
36
|
+
- TxPermitted, Size, Data, Metadata, Timestamp, DoubleSpend, Phases, BlockHeader
|
|
37
|
+
- Gas (optional — skipped when `skipFeeEnforcement` is set)
|
|
38
|
+
- Proof verification (optional — skipped for simulations when no verifier is provided)
|
|
39
|
+
|
|
40
|
+
### 3. Req/resp and block proposals
|
|
41
|
+
|
|
42
|
+
**Factories**: `createTxValidatorForReqResponseReceivedTxs`, `createTxValidatorForBlockProposalReceivedTxs`
|
|
43
|
+
**Called from**: `LibP2PService.validateRequestedTx()`, `LibP2PService.validateTxsReceivedInBlockProposal()`, and `BatchRequestTxValidator` in `batch-tx-requester/tx_validator.ts`
|
|
44
|
+
|
|
45
|
+
Solicited transactions — we requested these from peers or received them as part of a block proposal we need to validate. We must accept them for re-execution even if they are invalid against the current state. Only well-formedness is checked:
|
|
46
|
+
|
|
47
|
+
- Metadata, Size, Data, Proof
|
|
48
|
+
|
|
49
|
+
State-dependent checks are deferred to either the block building validator (for txs included in blocks) or the pending pool migration validator (for unmined txs migrating to pending).
|
|
50
|
+
|
|
51
|
+
### 4. Block building
|
|
52
|
+
|
|
53
|
+
**Factory**: `createTxValidatorForBlockBuilding`
|
|
54
|
+
**Called from**: `CheckpointBuilder.makeBlockBuilderDeps()` in `validator-client/checkpoint_builder.ts`
|
|
55
|
+
|
|
56
|
+
Transactions already in the pool, about to be sequenced into a block. Re-validates against the current state of the block being built. **This is where invalid txs that entered via req/resp or block proposals are caught** — their invalidity is reported as part of block validation/attestation.
|
|
57
|
+
|
|
58
|
+
Runs:
|
|
59
|
+
- Timestamp, DoubleSpend, Phases, Gas, BlockHeader
|
|
60
|
+
|
|
61
|
+
Does **not** run:
|
|
62
|
+
- Proof, Data — already verified on entry (by gossip, RPC, or req/resp validators)
|
|
63
|
+
|
|
64
|
+
### 5. Pending pool migration
|
|
65
|
+
|
|
66
|
+
**Factory**: `createTxValidatorForTransactionsEnteringPendingTxPool`
|
|
67
|
+
**Called from**: `TxPoolV2Impl` (injected as the `createTxValidator` factory via `TxPoolV2Dependencies`)
|
|
68
|
+
|
|
69
|
+
When transactions that arrived via req/resp or block proposals fail to be mined, they may need to be included in our pending pool. These txs only had well-formedness checks on receipt, so the pool runs the state-dependent checks they missed before accepting them.
|
|
70
|
+
|
|
71
|
+
This validator is invoked on **every** transaction potentially entering the pending pool:
|
|
72
|
+
- `addPendingTxs` — validating each tx before adding
|
|
73
|
+
- `prepareForSlot` — unprotecting txs back to pending after a slot ends
|
|
74
|
+
- `handlePrunedBlocks` — unmining txs from pruned blocks back to pending
|
|
75
|
+
- Startup hydration — revalidating persisted non-mined txs on node restart
|
|
76
|
+
|
|
77
|
+
Runs:
|
|
78
|
+
- DoubleSpend, BlockHeader, GasLimits, Timestamp
|
|
79
|
+
|
|
80
|
+
Operates on `TxMetaData` (pre-built by the pool) rather than full `Tx` objects.
|
|
81
|
+
|
|
82
|
+
## Individual Validators
|
|
83
|
+
|
|
84
|
+
| Validator | What it checks | Benchmarked verification duration |
|
|
85
|
+
|-----------|---------------|---------------|
|
|
86
|
+
| `TxPermittedValidator` | Whether the system is accepting transactions (controlled by config flag) | 1.56 us |
|
|
87
|
+
| `DataTxValidator` | Transaction data integrity — correct structure, non-empty fields | 4.10–18.18 ms |
|
|
88
|
+
| `SizeTxValidator` | Transaction does not exceed maximum size limits | 2.28 us |
|
|
89
|
+
| `MetadataTxValidator` | Chain ID, rollup version, protocol contracts hash, VK tree root | 4.18 us |
|
|
90
|
+
| `TimestampTxValidator` | Transaction has not expired (expiration timestamp vs next slot) | 1.56 us |
|
|
91
|
+
| `DoubleSpendTxValidator` | Nullifiers do not already exist in the nullifier tree | 106.08 us |
|
|
92
|
+
| `GasTxValidator` | Gas limits are within bounds (delegates to `GasLimitsValidator`), max fee per gas meets current block fees, and fee payer has sufficient FeeJuice balance | 1.02 ms |
|
|
93
|
+
| `GasLimitsValidator` | Gas limits are >= fixed minimums and <= AVM max processable L2 gas. Used standalone in pool migration; also called internally by `GasTxValidator` | 3–10 us |
|
|
94
|
+
| `PhasesTxValidator` | Public function calls in setup phase are on the allow list | 10.12–13.12 us |
|
|
95
|
+
| `BlockHeaderTxValidator` | Transaction's anchor block hash exists in the archive tree | 98.88 us |
|
|
96
|
+
| `TxProofValidator` | Client proof verifies correctly | ~250ms |
|
|
97
|
+
|
|
98
|
+
## Validator Coverage by Entry Point
|
|
99
|
+
|
|
100
|
+
| Validator | Gossip | RPC | Req/resp | Block building | Pool migration |
|
|
101
|
+
|-----------|--------|-----|----------|----------------|----------------|
|
|
102
|
+
| TxPermitted | Stage 1 | Yes | — | — | — |
|
|
103
|
+
| Data | Stage 1 | Yes | Yes | — | — |
|
|
104
|
+
| Size | — | Yes | Yes | — | — |
|
|
105
|
+
| Metadata | Stage 1 | Yes | Yes | — | — |
|
|
106
|
+
| Timestamp | Stage 1 | Yes | — | Yes | Yes |
|
|
107
|
+
| DoubleSpend | Stage 1 | Yes | — | Yes | Yes |
|
|
108
|
+
| Gas (balance + limits) | Stage 1 | Optional* | — | Yes | — |
|
|
109
|
+
| GasLimits (standalone) | — | — | — | — | Yes |
|
|
110
|
+
| Phases | Stage 1 | Yes | — | Yes | — |
|
|
111
|
+
| BlockHeader | Stage 1 | Yes | — | Yes | Yes |
|
|
112
|
+
| Proof | Stage 2 | Optional** | Yes | — | — |
|
|
113
|
+
|
|
114
|
+
\* Gas balance check is skipped when `skipFeeEnforcement` is set (testing/dev). `GasTxValidator` internally delegates to `GasLimitsValidator` as its first step, so gas limits are checked wherever `GasTxValidator` runs. Pool migration uses `GasLimitsValidator` standalone because it doesn't need the balance or fee-per-gas checks.
|
|
115
|
+
\** Proof verification is skipped for simulations (no verifier provided).
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
|
|
2
2
|
|
|
3
|
-
export class AggregateTxValidator<T
|
|
4
|
-
|
|
3
|
+
export class AggregateTxValidator<T> implements TxValidator<T> {
|
|
4
|
+
readonly validators: TxValidator<T>[];
|
|
5
5
|
constructor(...validators: TxValidator<T>[]) {
|
|
6
6
|
if (validators.length === 0) {
|
|
7
7
|
throw new Error('At least one validator must be provided');
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
this
|
|
10
|
+
this.validators = validators;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async validateTx(tx: T): Promise<TxValidationResult> {
|
|
14
14
|
const aggregate: { result: string; reason?: string[] } = { result: 'valid', reason: [] };
|
|
15
|
-
for (const validator of this
|
|
15
|
+
for (const validator of this.validators) {
|
|
16
16
|
const result = await validator.validateTx(tx);
|
|
17
17
|
if (result.result === 'invalid') {
|
|
18
18
|
aggregate.result = 'invalid';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import type { ArchiveSource } from '@aztec/p2p';
|
|
2
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
3
|
import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
5
|
|
|
@@ -14,8 +14,8 @@ export class ArchiveCache implements ArchiveSource {
|
|
|
14
14
|
this.archives = new Map<string, bigint>();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public async getArchiveIndices(archives:
|
|
18
|
-
const toCheckDb = archives.filter(n => !this.archives.has(n.toString()));
|
|
17
|
+
public async getArchiveIndices(archives: BlockHash[]): Promise<(bigint | undefined)[]> {
|
|
18
|
+
const toCheckDb = archives.filter(n => !this.archives.has(n.toString())).map(n => n.toFr());
|
|
19
19
|
const dbHits = await this.db.findLeafIndices(MerkleTreeId.ARCHIVE, toCheckDb);
|
|
20
20
|
dbHits.forEach((x, index) => {
|
|
21
21
|
if (x !== undefined) {
|