@aztec/p2p 0.0.1-commit.dbf9cec → 0.0.1-commit.ddcf04837
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 +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +25 -11
- package/dest/client/interface.d.ts +9 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +3 -2
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +46 -38
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +17 -6
- package/dest/config.d.ts +125 -100
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +92 -33
- package/dest/errors/p2p-service.error.d.ts +9 -0
- package/dest/errors/p2p-service.error.d.ts.map +1 -0
- package/dest/errors/p2p-service.error.js +10 -0
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +7 -5
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +16 -9
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +6 -6
- package/dest/mem_pools/index.d.ts +1 -2
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.d.ts +4 -2
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +16 -14
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +2 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +9 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +25 -10
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +39 -12
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +26 -43
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -0
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +24 -6
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +20 -11
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +2 -2
- package/dest/msg_validators/clock_tolerance.d.ts +12 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +54 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +7 -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 +7 -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 +15 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +67 -47
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +1 -1
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +35 -2
- package/dest/msg_validators/tx_validator/factory.d.ts +23 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +36 -10
- 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 +13 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +49 -17
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/data_store.js +5 -5
- package/dest/services/dummy_service.d.ts +6 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +6 -1
- package/dest/services/encoding.d.ts +5 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -1
- package/dest/services/gossipsub/topic_score_params.d.ts +13 -2
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +21 -4
- package/dest/services/libp2p/libp2p_service.d.ts +15 -25
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +165 -126
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +6 -0
- package/dest/services/peer-manager/peer_manager.d.ts +6 -2
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +39 -11
- package/dest/services/peer-manager/peer_scoring.d.ts +7 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +32 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +11 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +69 -65
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +3 -2
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +5 -4
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +13 -7
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +3 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +3 -0
- package/dest/services/reqresp/config.d.ts +3 -3
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/interface.d.ts +14 -9
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +10 -11
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/metrics.js +0 -1
- package/dest/services/reqresp/protocols/index.d.ts +1 -2
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +0 -1
- package/dest/services/reqresp/protocols/tx.d.ts +1 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +1 -3
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +0 -10
- package/dest/services/reqresp/reqresp.d.ts +4 -2
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +28 -11
- package/dest/services/service.d.ts +5 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +57 -73
- package/dest/services/tx_collection/file_store_tx_source.d.ts +5 -4
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +39 -29
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +6 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +4 -4
- package/dest/services/tx_collection/request_tracker.d.ts +53 -0
- package/dest/services/tx_collection/request_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/request_tracker.js +84 -0
- package/dest/services/tx_collection/slow_tx_collection.js +1 -1
- package/dest/services/tx_collection/tx_collection.d.ts +3 -6
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.d.ts +6 -5
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +9 -7
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +11 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +35 -10
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +1 -2
- package/dest/test-helpers/testbench-utils.d.ts +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +23 -3
- package/dest/testbench/p2p_client_testbench_worker.js +68 -16
- package/dest/testbench/worker_client_manager.d.ts +10 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +55 -3
- package/dest/util.d.ts +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +43 -14
- package/src/client/interface.ts +9 -1
- package/src/client/p2p_client.ts +50 -39
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +19 -9
- package/src/config.ts +137 -35
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/index.ts +0 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +17 -12
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +6 -6
- package/src/mem_pools/index.ts +0 -3
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/tx_pool_v2/README.md +9 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +9 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +60 -14
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +29 -43
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +16 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +28 -6
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -9
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +4 -1
- package/src/msg_validators/clock_tolerance.ts +72 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +17 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +23 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +79 -49
- package/src/msg_validators/tx_validator/README.md +5 -1
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/factory.ts +43 -3
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +65 -16
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/services/data_store.ts +5 -13
- package/src/services/dummy_service.ts +8 -2
- package/src/services/encoding.ts +9 -1
- package/src/services/gossipsub/topic_score_params.ts +36 -4
- package/src/services/libp2p/libp2p_service.ts +164 -139
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +45 -11
- package/src/services/peer-manager/peer_scoring.ts +27 -5
- package/src/services/reqresp/README.md +229 -0
- package/src/services/reqresp/batch-tx-requester/README.md +46 -7
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +64 -69
- package/src/services/reqresp/batch-tx-requester/interface.ts +2 -1
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +13 -6
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +5 -0
- package/src/services/reqresp/config.ts +2 -2
- package/src/services/reqresp/interface.ts +21 -11
- package/src/services/reqresp/metrics.ts +0 -1
- package/src/services/reqresp/protocols/index.ts +0 -1
- package/src/services/reqresp/protocols/tx.ts +1 -3
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/rate-limiter/rate_limits.ts +0 -10
- package/src/services/reqresp/reqresp.ts +37 -12
- package/src/services/service.ts +6 -1
- package/src/services/tx_collection/fast_tx_collection.ts +57 -83
- package/src/services/tx_collection/file_store_tx_source.ts +43 -31
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +1 -1
- package/src/services/tx_collection/tx_collection.ts +3 -5
- package/src/services/tx_collection/tx_source.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +1 -1
- package/src/test-helpers/mock-pubsub.ts +31 -5
- package/src/test-helpers/reqresp-nodes.ts +3 -3
- package/src/test-helpers/testbench-utils.ts +30 -3
- package/src/testbench/p2p_client_testbench_worker.ts +72 -15
- package/src/testbench/worker_client_manager.ts +68 -6
- package/src/util.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +0 -125
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +0 -596
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts +0 -32
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_manager.js +0 -112
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts +0 -157
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/eviction_strategy.js +0 -52
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts +0 -16
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.js +0 -122
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts +0 -17
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts +0 -19
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.js +0 -78
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts +0 -26
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/low_priority_eviction_rule.js +0 -84
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts +0 -25
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.js +0 -57
- package/dest/mem_pools/tx_pool/index.d.ts +0 -3
- package/dest/mem_pools/tx_pool/index.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/index.js +0 -2
- package/dest/mem_pools/tx_pool/priority.d.ts +0 -12
- package/dest/mem_pools/tx_pool/priority.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/priority.js +0 -15
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +0 -127
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool.js +0 -3
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +0 -7
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +0 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +0 -400
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/dest/services/reqresp/protocols/block.d.ts +0 -9
- package/dest/services/reqresp/protocols/block.d.ts.map +0 -1
- package/dest/services/reqresp/protocols/block.js +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +0 -32
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +0 -1
- package/dest/services/tx_collection/missing_txs_tracker.js +0 -27
- package/src/mem_pools/tx_pool/README.md +0 -270
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +0 -746
- package/src/mem_pools/tx_pool/eviction/eviction_manager.ts +0 -132
- package/src/mem_pools/tx_pool/eviction/eviction_strategy.ts +0 -208
- package/src/mem_pools/tx_pool/eviction/fee_payer_balance_eviction_rule.ts +0 -162
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +0 -104
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts +0 -93
- package/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts +0 -106
- package/src/mem_pools/tx_pool/eviction/nullifier_conflict_pre_add_rule.ts +0 -75
- package/src/mem_pools/tx_pool/index.ts +0 -2
- package/src/mem_pools/tx_pool/priority.ts +0 -20
- package/src/mem_pools/tx_pool/tx_pool.ts +0 -141
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +0 -319
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
- package/src/services/reqresp/protocols/block.ts +0 -37
- package/src/services/tx_collection/missing_txs_tracker.ts +0 -52
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
2
3
|
MAX_PROCESSABLE_L2_GAS,
|
|
3
4
|
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
4
5
|
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
@@ -49,16 +50,31 @@ export interface HasGasLimitData {
|
|
|
49
50
|
*/
|
|
50
51
|
export class GasLimitsValidator<T extends HasGasLimitData> implements TxValidator<T> {
|
|
51
52
|
#log: Logger;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
#effectiveMaxL2Gas: number;
|
|
54
|
+
#effectiveMaxDAGas: number;
|
|
55
|
+
#rollupManaLimit: number;
|
|
56
|
+
#maxBlockL2Gas: number;
|
|
57
|
+
#maxBlockDAGas: number;
|
|
58
|
+
|
|
59
|
+
constructor(opts?: {
|
|
60
|
+
rollupManaLimit?: number;
|
|
61
|
+
maxBlockL2Gas?: number;
|
|
62
|
+
maxBlockDAGas?: number;
|
|
63
|
+
bindings?: LoggerBindings;
|
|
64
|
+
}) {
|
|
65
|
+
this.#log = createLogger('sequencer:tx_validator:tx_gas', opts?.bindings);
|
|
66
|
+
this.#rollupManaLimit = opts?.rollupManaLimit ?? Infinity;
|
|
67
|
+
this.#maxBlockL2Gas = opts?.maxBlockL2Gas ?? Infinity;
|
|
68
|
+
this.#maxBlockDAGas = opts?.maxBlockDAGas ?? Infinity;
|
|
69
|
+
this.#effectiveMaxL2Gas = Math.min(MAX_PROCESSABLE_L2_GAS, this.#rollupManaLimit, this.#maxBlockL2Gas);
|
|
70
|
+
this.#effectiveMaxDAGas = Math.min(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, this.#maxBlockDAGas);
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
validateTx(tx: T): Promise<TxValidationResult> {
|
|
58
74
|
return Promise.resolve(this.validateGasLimit(tx));
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
/** Checks gas limits are >= fixed minimums and <=
|
|
77
|
+
/** Checks gas limits are >= fixed minimums and <= effective max gas (L2 and DA). */
|
|
62
78
|
validateGasLimit(tx: T): TxValidationResult {
|
|
63
79
|
const gasLimits = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
64
80
|
const minGasLimits = new Gas(
|
|
@@ -71,15 +87,37 @@ export class GasLimitsValidator<T extends HasGasLimitData> implements TxValidato
|
|
|
71
87
|
gasLimits,
|
|
72
88
|
minGasLimits,
|
|
73
89
|
});
|
|
74
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
result: 'invalid',
|
|
92
|
+
reason: [
|
|
93
|
+
`${TX_ERROR_INSUFFICIENT_GAS_LIMIT} (required=da:${minGasLimits.daGas},l2:${minGasLimits.l2Gas} got=da:${gasLimits.daGas},l2:${gasLimits.l2Gas})`,
|
|
94
|
+
],
|
|
95
|
+
};
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
if (gasLimits.l2Gas >
|
|
78
|
-
this.#log.verbose(`Rejecting transaction due to the gas limit
|
|
98
|
+
if (gasLimits.l2Gas > this.#effectiveMaxL2Gas) {
|
|
99
|
+
this.#log.verbose(`Rejecting transaction due to the L2 gas limit being higher than the effective maximum`, {
|
|
79
100
|
gasLimits,
|
|
80
|
-
|
|
101
|
+
effectiveMaxL2Gas: this.#effectiveMaxL2Gas,
|
|
102
|
+
rollupManaLimit: this.#rollupManaLimit,
|
|
103
|
+
maxBlockL2Gas: this.#maxBlockL2Gas,
|
|
81
104
|
});
|
|
82
|
-
return {
|
|
105
|
+
return {
|
|
106
|
+
result: 'invalid',
|
|
107
|
+
reason: [`${TX_ERROR_GAS_LIMIT_TOO_HIGH} (l2Gas=${gasLimits.l2Gas}, max=${this.#effectiveMaxL2Gas})`],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (gasLimits.daGas > this.#effectiveMaxDAGas) {
|
|
112
|
+
this.#log.verbose(`Rejecting transaction due to the DA gas limit being higher than the effective maximum`, {
|
|
113
|
+
gasLimits,
|
|
114
|
+
effectiveMaxDAGas: this.#effectiveMaxDAGas,
|
|
115
|
+
maxBlockDAGas: this.#maxBlockDAGas,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
result: 'invalid',
|
|
119
|
+
reason: [`${TX_ERROR_GAS_LIMIT_TOO_HIGH} (daGas=${gasLimits.daGas}, max=${this.#effectiveMaxDAGas})`],
|
|
120
|
+
};
|
|
83
121
|
}
|
|
84
122
|
|
|
85
123
|
return { result: 'valid' };
|
|
@@ -106,37 +144,44 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
106
144
|
#publicDataSource: PublicStateSource;
|
|
107
145
|
#feeJuiceAddress: AztecAddress;
|
|
108
146
|
#gasFees: GasFees;
|
|
147
|
+
#gasLimitOpts?: { rollupManaLimit?: number; maxBlockL2Gas?: number; maxBlockDAGas?: number };
|
|
109
148
|
|
|
110
149
|
constructor(
|
|
111
150
|
publicDataSource: PublicStateSource,
|
|
112
151
|
feeJuiceAddress: AztecAddress,
|
|
113
152
|
gasFees: GasFees,
|
|
114
153
|
private bindings?: LoggerBindings,
|
|
154
|
+
opts?: { rollupManaLimit?: number; maxBlockL2Gas?: number; maxBlockDAGas?: number },
|
|
115
155
|
) {
|
|
116
156
|
this.#log = createLogger('sequencer:tx_validator:tx_gas', bindings);
|
|
117
157
|
this.#publicDataSource = publicDataSource;
|
|
118
158
|
this.#feeJuiceAddress = feeJuiceAddress;
|
|
119
159
|
this.#gasFees = gasFees;
|
|
160
|
+
this.#gasLimitOpts = opts;
|
|
120
161
|
}
|
|
121
162
|
|
|
122
163
|
async validateTx(tx: Tx): Promise<TxValidationResult> {
|
|
123
|
-
const gasLimitValidation = new GasLimitsValidator(
|
|
164
|
+
const gasLimitValidation = new GasLimitsValidator({
|
|
165
|
+
...this.#gasLimitOpts,
|
|
166
|
+
bindings: this.bindings,
|
|
167
|
+
}).validateGasLimit(tx);
|
|
124
168
|
if (gasLimitValidation.result === 'invalid') {
|
|
125
169
|
return Promise.resolve(gasLimitValidation);
|
|
126
170
|
}
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
const skipReason = this.#getSkipReason(tx);
|
|
172
|
+
if (skipReason) {
|
|
173
|
+
return Promise.resolve({ result: 'skipped', reason: [skipReason] });
|
|
129
174
|
}
|
|
130
175
|
return await this.validateTxFee(tx);
|
|
131
176
|
}
|
|
132
177
|
|
|
133
178
|
/**
|
|
134
|
-
* Check whether the tx's max fees are valid for the current block, and skip if not.
|
|
179
|
+
* Check whether the tx's max fees are valid for the current block, and return a skip reason if not.
|
|
135
180
|
* We skip instead of invalidating since the tx may become eligible later.
|
|
136
181
|
* Note that circuits check max fees even if fee payer is unset, so we
|
|
137
182
|
* keep this validation even if the tx does not pay fees.
|
|
138
183
|
*/
|
|
139
|
-
#
|
|
184
|
+
#getSkipReason(tx: Tx): string | undefined {
|
|
140
185
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
141
186
|
|
|
142
187
|
// Skip the tx if its max fees are not enough for the current block's gas fees.
|
|
@@ -149,8 +194,9 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
149
194
|
txMaxFeesPerGas: maxFeesPerGas.toInspect(),
|
|
150
195
|
currentGasFees: this.#gasFees.toInspect(),
|
|
151
196
|
});
|
|
197
|
+
return `${TX_ERROR_INSUFFICIENT_FEE_PER_GAS} (maxFee=da:${maxFeesPerGas.feePerDaGas},l2:${maxFeesPerGas.feePerL2Gas} required=da:${this.#gasFees.feePerDaGas},l2:${this.#gasFees.feePerL2Gas})`;
|
|
152
198
|
}
|
|
153
|
-
return
|
|
199
|
+
return undefined;
|
|
154
200
|
}
|
|
155
201
|
|
|
156
202
|
/**
|
|
@@ -179,7 +225,10 @@ export class GasTxValidator implements TxValidator<Tx> {
|
|
|
179
225
|
balance,
|
|
180
226
|
feeLimit,
|
|
181
227
|
});
|
|
182
|
-
return {
|
|
228
|
+
return {
|
|
229
|
+
result: 'invalid',
|
|
230
|
+
reason: [`${TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE} (required=${feeLimit}, available=${balance})`],
|
|
231
|
+
};
|
|
183
232
|
}
|
|
184
233
|
return { result: 'valid' };
|
|
185
234
|
}
|
|
@@ -8,6 +8,7 @@ export * from './gas_validator.js';
|
|
|
8
8
|
export * from './phases_validator.js';
|
|
9
9
|
export * from './test_utils.js';
|
|
10
10
|
export * from './allowed_public_setup.js';
|
|
11
|
+
export * from './allowed_setup_helpers.js';
|
|
11
12
|
export * from './archive_cache.js';
|
|
12
13
|
export * from './tx_permitted_validator.js';
|
|
13
14
|
export * from './timestamp_validator.js';
|
|
@@ -28,16 +28,24 @@ export class MetadataTxValidator<T extends AnyTx> implements TxValidator<T> {
|
|
|
28
28
|
validateTx(tx: T): Promise<TxValidationResult> {
|
|
29
29
|
const errors = [];
|
|
30
30
|
if (!this.#hasCorrectL1ChainId(tx)) {
|
|
31
|
-
errors.push(
|
|
31
|
+
errors.push(
|
|
32
|
+
`${TX_ERROR_INCORRECT_L1_CHAIN_ID} (tx: ${tx.data.constants.txContext.chainId.toNumber()}, expected: ${this.values.l1ChainId.toNumber()})`,
|
|
33
|
+
);
|
|
32
34
|
}
|
|
33
35
|
if (!this.#hasCorrectRollupVersion(tx)) {
|
|
34
|
-
errors.push(
|
|
36
|
+
errors.push(
|
|
37
|
+
`${TX_ERROR_INCORRECT_ROLLUP_VERSION} (tx: ${tx.data.constants.txContext.version.toNumber()}, expected: ${this.values.rollupVersion.toNumber()})`,
|
|
38
|
+
);
|
|
35
39
|
}
|
|
36
40
|
if (!this.#hasCorrectVkTreeRoot(tx)) {
|
|
37
|
-
errors.push(
|
|
41
|
+
errors.push(
|
|
42
|
+
`${TX_ERROR_INCORRECT_VK_TREE_ROOT} (tx: ${tx.data.constants.vkTreeRoot.toString()}, expected: ${this.values.vkTreeRoot.toString()})`,
|
|
43
|
+
);
|
|
38
44
|
}
|
|
39
45
|
if (!this.#hasCorrectprotocolContractsHash(tx)) {
|
|
40
|
-
errors.push(
|
|
46
|
+
errors.push(
|
|
47
|
+
`${TX_ERROR_INCORRECT_PROTOCOL_CONTRACTS_HASH} (tx: ${tx.data.constants.protocolContractsHash.toString()}, expected: ${this.values.protocolContractsHash.toString()})`,
|
|
48
|
+
);
|
|
41
49
|
}
|
|
42
50
|
return Promise.resolve(errors.length > 0 ? { result: 'invalid', reason: errors } : { result: 'valid' });
|
|
43
51
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { NULL_MSG_SENDER_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
1
2
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { PublicContractsDB, getCallRequestsWithCalldataByPhase } from '@aztec/simulator/server';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
5
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
4
6
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
5
7
|
import {
|
|
6
8
|
type PublicCallRequestWithCalldata,
|
|
7
9
|
TX_ERROR_DURING_VALIDATION,
|
|
8
10
|
TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED,
|
|
11
|
+
TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT,
|
|
12
|
+
TX_ERROR_SETUP_NULL_MSG_SENDER,
|
|
13
|
+
TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER,
|
|
14
|
+
TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH,
|
|
9
15
|
Tx,
|
|
10
16
|
TxExecutionPhase,
|
|
11
17
|
type TxValidationResult,
|
|
@@ -34,7 +40,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
34
40
|
// which are needed for public FPC flows, but fail if the account contract hasnt been deployed yet,
|
|
35
41
|
// which is what we're trying to do as part of the current txs.
|
|
36
42
|
// We only need to create/revert checkpoint here because of this addNewContracts call.
|
|
37
|
-
|
|
43
|
+
this.contractsDB.addNewContracts(tx);
|
|
38
44
|
|
|
39
45
|
if (!tx.data.forPublic) {
|
|
40
46
|
this.#log.debug(
|
|
@@ -45,7 +51,8 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
45
51
|
|
|
46
52
|
const setupFns = getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP);
|
|
47
53
|
for (const setupFn of setupFns) {
|
|
48
|
-
|
|
54
|
+
const rejectionReason = await this.checkAllowList(setupFn, this.setupAllowList);
|
|
55
|
+
if (rejectionReason) {
|
|
49
56
|
this.#log.verbose(
|
|
50
57
|
`Rejecting tx ${tx.getTxHash().toString()} because it calls setup function not on allow list: ${
|
|
51
58
|
setupFn.request.contractAddress
|
|
@@ -53,7 +60,7 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
53
60
|
{ allowList: this.setupAllowList },
|
|
54
61
|
);
|
|
55
62
|
|
|
56
|
-
return { result: 'invalid', reason: [
|
|
63
|
+
return { result: 'invalid', reason: [rejectionReason] };
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -66,53 +73,101 @@ export class PhasesTxValidator implements TxValidator<Tx> {
|
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
/** Returns a rejection reason if the call is not on the allow list, or undefined if it is allowed. */
|
|
77
|
+
private async checkAllowList(
|
|
70
78
|
publicCall: PublicCallRequestWithCalldata,
|
|
71
79
|
allowList: AllowedElement[],
|
|
72
|
-
): Promise<
|
|
80
|
+
): Promise<string | undefined> {
|
|
73
81
|
if (publicCall.isEmpty()) {
|
|
74
|
-
return
|
|
82
|
+
return undefined;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
const contractAddress = publicCall.request.contractAddress;
|
|
78
86
|
const functionSelector = publicCall.functionSelector;
|
|
79
87
|
|
|
80
|
-
//
|
|
88
|
+
// Check address-based entries first since they don't require the contract class.
|
|
81
89
|
for (const entry of allowList) {
|
|
82
|
-
if ('address' in entry
|
|
83
|
-
if (contractAddress.equals(entry.address)) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if ('address' in entry && 'selector' in entry) {
|
|
90
|
+
if ('address' in entry) {
|
|
89
91
|
if (contractAddress.equals(entry.address) && entry.selector.equals(functionSelector)) {
|
|
90
|
-
|
|
92
|
+
if (entry.calldataLength !== undefined && publicCall.calldata.length !== entry.calldataLength) {
|
|
93
|
+
return TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH;
|
|
94
|
+
}
|
|
95
|
+
if (entry.onlySelf && !publicCall.request.msgSender.equals(contractAddress)) {
|
|
96
|
+
return TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER;
|
|
97
|
+
}
|
|
98
|
+
if (
|
|
99
|
+
entry.rejectNullMsgSender &&
|
|
100
|
+
publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS))
|
|
101
|
+
) {
|
|
102
|
+
return TX_ERROR_SETUP_NULL_MSG_SENDER;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
91
105
|
}
|
|
92
106
|
}
|
|
107
|
+
}
|
|
93
108
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
// Check class-based entries. Fetch the contract instance lazily (only once).
|
|
110
|
+
let contractClassId: undefined | { value: string | undefined };
|
|
111
|
+
for (const entry of allowList) {
|
|
112
|
+
if (!('classId' in entry)) {
|
|
113
|
+
continue;
|
|
98
114
|
}
|
|
99
115
|
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
if (contractClassId === undefined) {
|
|
117
|
+
const instance = await this.contractsDB.getContractInstance(contractAddress, this.timestamp);
|
|
118
|
+
contractClassId = { value: instance?.currentContractClassId.toString() };
|
|
119
|
+
if (!contractClassId.value) {
|
|
120
|
+
return TX_ERROR_SETUP_FUNCTION_UNKNOWN_CONTRACT;
|
|
103
121
|
}
|
|
104
122
|
}
|
|
105
123
|
|
|
106
|
-
if (
|
|
124
|
+
if (contractClassId.value === entry.classId.toString() && entry.selector.equals(functionSelector)) {
|
|
125
|
+
if (entry.calldataLength !== undefined && publicCall.calldata.length !== entry.calldataLength) {
|
|
126
|
+
return TX_ERROR_SETUP_WRONG_CALLDATA_LENGTH;
|
|
127
|
+
}
|
|
128
|
+
if (entry.onlySelf && !publicCall.request.msgSender.equals(contractAddress)) {
|
|
129
|
+
return TX_ERROR_SETUP_ONLY_SELF_WRONG_SENDER;
|
|
130
|
+
}
|
|
107
131
|
if (
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
entry.rejectNullMsgSender &&
|
|
133
|
+
publicCall.request.msgSender.equals(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS))
|
|
110
134
|
) {
|
|
111
|
-
return
|
|
135
|
+
return TX_ERROR_SETUP_NULL_MSG_SENDER;
|
|
112
136
|
}
|
|
137
|
+
return undefined;
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
|
|
116
|
-
return
|
|
141
|
+
return TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Structural interface for the allowed-setup-calls flag check. */
|
|
146
|
+
export interface HasAllowedSetupCallsData {
|
|
147
|
+
txHash: { toString(): string };
|
|
148
|
+
allowedSetupCalls: boolean;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Validates that a transaction's setup-phase calls were allowed at receipt time.
|
|
153
|
+
*
|
|
154
|
+
* Checks the precomputed `allowedSetupCalls` flag on TxMetaData. The flag is
|
|
155
|
+
* computed by running the PhasesTxValidator on the full Tx when it first enters
|
|
156
|
+
* the pool. This lightweight validator is used during pending pool migration to
|
|
157
|
+
* reject txs whose setup calls are not on the allow list.
|
|
158
|
+
*/
|
|
159
|
+
export class AllowedSetupCallsMetaValidator<T extends HasAllowedSetupCallsData> implements TxValidator<T> {
|
|
160
|
+
#log: Logger;
|
|
161
|
+
|
|
162
|
+
constructor(bindings?: LoggerBindings) {
|
|
163
|
+
this.#log = createLogger('sequencer:tx_validator:tx_phases_meta', bindings);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
validateTx(tx: T): Promise<TxValidationResult> {
|
|
167
|
+
if (!tx.allowedSetupCalls) {
|
|
168
|
+
this.#log.verbose(`Rejecting tx ${tx.txHash} because its setup calls are not on the allow list`);
|
|
169
|
+
return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED] });
|
|
170
|
+
}
|
|
171
|
+
return Promise.resolve({ result: 'valid' });
|
|
117
172
|
}
|
|
118
173
|
}
|
|
@@ -28,8 +28,6 @@ export class AztecDatastore implements Datastore {
|
|
|
28
28
|
#memoryDatastore: Map<string, MemoryItem>;
|
|
29
29
|
#dbDatastore: AztecAsyncMap<string, Uint8Array>;
|
|
30
30
|
|
|
31
|
-
#batchOps: BatchOp[] = [];
|
|
32
|
-
|
|
33
31
|
private maxMemoryItems: number;
|
|
34
32
|
|
|
35
33
|
constructor(db: AztecAsyncKVStore, { maxMemoryItems } = { maxMemoryItems: 50 }) {
|
|
@@ -92,23 +90,17 @@ export class AztecDatastore implements Datastore {
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
batch(): Batch {
|
|
93
|
+
const ops: BatchOp[] = [];
|
|
95
94
|
return {
|
|
96
95
|
put: (key, value) => {
|
|
97
|
-
|
|
98
|
-
type: 'put',
|
|
99
|
-
key,
|
|
100
|
-
value,
|
|
101
|
-
});
|
|
96
|
+
ops.push({ type: 'put', key, value });
|
|
102
97
|
},
|
|
103
98
|
delete: key => {
|
|
104
|
-
|
|
105
|
-
type: 'del',
|
|
106
|
-
key,
|
|
107
|
-
});
|
|
99
|
+
ops.push({ type: 'del', key });
|
|
108
100
|
},
|
|
109
101
|
commit: async () => {
|
|
110
102
|
await this.#db.transactionAsync(async () => {
|
|
111
|
-
for (const op of
|
|
103
|
+
for (const op of ops) {
|
|
112
104
|
if (op.type === 'put' && op.value) {
|
|
113
105
|
await this.put(op.key, op.value);
|
|
114
106
|
} else if (op.type === 'del') {
|
|
@@ -116,7 +108,7 @@ export class AztecDatastore implements Datastore {
|
|
|
116
108
|
}
|
|
117
109
|
}
|
|
118
110
|
});
|
|
119
|
-
|
|
111
|
+
ops.length = 0;
|
|
120
112
|
},
|
|
121
113
|
};
|
|
122
114
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
import type { Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
|
|
3
|
+
import type { CheckpointProposalCore, Gossipable, PeerErrorSeverity, TopicType } from '@aztec/stdlib/p2p';
|
|
4
4
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import type { PeerId } from '@libp2p/interface';
|
|
@@ -86,7 +86,12 @@ export class DummyP2PService implements P2PService {
|
|
|
86
86
|
/**
|
|
87
87
|
* Register a callback into the validator client for when a checkpoint proposal is received
|
|
88
88
|
*/
|
|
89
|
-
public
|
|
89
|
+
public registerValidatorCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
|
|
90
|
+
public registerAllNodesCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
|
|
91
|
+
|
|
92
|
+
public notifyOwnCheckpointProposal(_checkpoint: CheckpointProposalCore): Promise<void> {
|
|
93
|
+
return Promise.resolve();
|
|
94
|
+
}
|
|
90
95
|
|
|
91
96
|
/**
|
|
92
97
|
* Register a callback for when a duplicate proposal is detected
|
|
@@ -282,6 +287,7 @@ export class DummyPeerManager implements PeerManagerInterface {
|
|
|
282
287
|
|
|
283
288
|
export class DummyReqResp implements ReqRespInterface {
|
|
284
289
|
updateConfig(_config: Partial<P2PReqRespConfig>): void {}
|
|
290
|
+
setShouldRejectPeer(): void {}
|
|
285
291
|
start(
|
|
286
292
|
_subProtocolHandlers: ReqRespSubProtocolHandlers,
|
|
287
293
|
_subProtocolValidators: ReqRespSubProtocolValidators,
|
package/src/services/encoding.ts
CHANGED
|
@@ -9,6 +9,14 @@ import { webcrypto } from 'node:crypto';
|
|
|
9
9
|
import { compressSync, uncompressSync } from 'snappy';
|
|
10
10
|
import xxhashFactory from 'xxhash-wasm';
|
|
11
11
|
|
|
12
|
+
/** Thrown when a Snappy-compressed response exceeds the allowed decompressed size. */
|
|
13
|
+
export class OversizedSnappyResponseError extends Error {
|
|
14
|
+
constructor(decompressedSize: number, maxSizeKb: number) {
|
|
15
|
+
super(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
|
|
16
|
+
this.name = 'OversizedSnappyResponseError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
// Load WASM
|
|
13
21
|
const xxhash = await xxhashFactory();
|
|
14
22
|
|
|
@@ -86,7 +94,7 @@ export class SnappyTransform implements DataTransform {
|
|
|
86
94
|
const { decompressedSize } = readSnappyPreamble(data);
|
|
87
95
|
if (decompressedSize > maxSizeKb * 1024) {
|
|
88
96
|
this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);
|
|
89
|
-
throw new
|
|
97
|
+
throw new OversizedSnappyResponseError(decompressedSize, maxSizeKb);
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
return Buffer.from(uncompressSync(data, { asBuffer: true }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TopicType, createTopicString } from '@aztec/stdlib/p2p';
|
|
2
|
-
import {
|
|
2
|
+
import { createCheckpointTimingModel } from '@aztec/stdlib/timetable';
|
|
3
3
|
|
|
4
4
|
import { createTopicScoreParams } from '@chainsafe/libp2p-gossipsub/score';
|
|
5
5
|
|
|
@@ -9,12 +9,18 @@ import { createTopicScoreParams } from '@chainsafe/libp2p-gossipsub/score';
|
|
|
9
9
|
export type TopicScoringNetworkParams = {
|
|
10
10
|
/** L2 slot duration in milliseconds */
|
|
11
11
|
slotDurationMs: number;
|
|
12
|
+
/** L1 slot duration in seconds */
|
|
13
|
+
ethereumSlotDuration: number;
|
|
12
14
|
/** Gossipsub heartbeat interval in milliseconds */
|
|
13
15
|
heartbeatIntervalMs: number;
|
|
14
16
|
/** Target committee size (number of validators expected to attest per slot) */
|
|
15
17
|
targetCommitteeSize: number;
|
|
16
18
|
/** Duration per block in milliseconds when building multiple blocks per slot. If undefined, single block mode. */
|
|
17
19
|
blockDurationMs?: number;
|
|
20
|
+
/** Time budget in seconds reserved for L1 publishing. Defaults to ethereumSlotDuration. */
|
|
21
|
+
l1PublishingTime?: number;
|
|
22
|
+
/** One-way proposal/attestation propagation budget in seconds. */
|
|
23
|
+
p2pPropagationTime?: number;
|
|
18
24
|
/** Expected number of block proposals per slot for scoring override. 0 disables scoring, undefined falls back to blocksPerSlot - 1. */
|
|
19
25
|
expectedBlockProposalsPerSlot?: number;
|
|
20
26
|
};
|
|
@@ -25,10 +31,32 @@ export type TopicScoringNetworkParams = {
|
|
|
25
31
|
*
|
|
26
32
|
* @param slotDurationMs - L2 slot duration in milliseconds
|
|
27
33
|
* @param blockDurationMs - Duration per block in milliseconds (undefined = single block mode)
|
|
34
|
+
* @param opts - Shared checkpoint timing inputs used by the sequencer and validators
|
|
28
35
|
* @returns Number of blocks per slot
|
|
29
36
|
*/
|
|
30
|
-
export function calculateBlocksPerSlot(
|
|
31
|
-
|
|
37
|
+
export function calculateBlocksPerSlot(
|
|
38
|
+
slotDurationMs: number,
|
|
39
|
+
blockDurationMs: number | undefined,
|
|
40
|
+
opts?: {
|
|
41
|
+
ethereumSlotDuration: number;
|
|
42
|
+
l1PublishingTime?: number;
|
|
43
|
+
p2pPropagationTime?: number;
|
|
44
|
+
},
|
|
45
|
+
): number {
|
|
46
|
+
if (!opts) {
|
|
47
|
+
return createCheckpointTimingModel({
|
|
48
|
+
aztecSlotDuration: slotDurationMs / 1000,
|
|
49
|
+
blockDuration: blockDurationMs ? blockDurationMs / 1000 : undefined,
|
|
50
|
+
}).calculateMaxBlocksPerSlot();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return createCheckpointTimingModel({
|
|
54
|
+
aztecSlotDuration: slotDurationMs / 1000,
|
|
55
|
+
ethereumSlotDuration: opts.ethereumSlotDuration,
|
|
56
|
+
blockDuration: blockDurationMs ? blockDurationMs / 1000 : undefined,
|
|
57
|
+
l1PublishingTime: opts.l1PublishingTime ?? opts.ethereumSlotDuration,
|
|
58
|
+
p2pPropagationTime: opts.p2pPropagationTime,
|
|
59
|
+
}).calculateMaxBlocksPerSlot();
|
|
32
60
|
}
|
|
33
61
|
|
|
34
62
|
/**
|
|
@@ -279,7 +307,11 @@ export class TopicScoreParamsFactory {
|
|
|
279
307
|
const { slotDurationMs, heartbeatIntervalMs, blockDurationMs } = params;
|
|
280
308
|
|
|
281
309
|
// Compute values that are the same for all topics
|
|
282
|
-
this.blocksPerSlot = calculateBlocksPerSlot(slotDurationMs, blockDurationMs
|
|
310
|
+
this.blocksPerSlot = calculateBlocksPerSlot(slotDurationMs, blockDurationMs, {
|
|
311
|
+
ethereumSlotDuration: params.ethereumSlotDuration,
|
|
312
|
+
l1PublishingTime: params.l1PublishingTime,
|
|
313
|
+
p2pPropagationTime: params.p2pPropagationTime,
|
|
314
|
+
});
|
|
283
315
|
this.heartbeatsPerSlot = slotDurationMs / heartbeatIntervalMs;
|
|
284
316
|
this.invalidDecay = computeDecay(heartbeatIntervalMs, slotDurationMs, INVALID_DECAY_WINDOW_SLOTS);
|
|
285
317
|
|