@aztec/p2p 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5d02921e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -3
- package/dest/client/factory.d.ts +9 -9
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +52 -14
- package/dest/client/interface.d.ts +47 -34
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +39 -51
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +164 -224
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +20 -10
- package/dest/config.d.ts +52 -16
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +100 -37
- 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/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 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +21 -12
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +75 -40
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +57 -57
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +2 -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/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +104 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +251 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +7 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +12 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +54 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +7 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +14 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +16 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/index.d.ts +3 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +2 -1
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +30 -12
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +5 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +78 -15
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +144 -19
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +12 -3
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +50 -45
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +12 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +17 -6
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +14 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +364 -189
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +5 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +4 -3
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +53 -41
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +4 -4
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/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/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/factory.d.ts +133 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +247 -60
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +67 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +104 -37
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +4 -4
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +22 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +72 -24
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +12 -6
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +12 -5
- package/dest/services/encoding.d.ts +7 -3
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +18 -11
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +37 -23
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +274 -173
- 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 +24 -9
- package/dest/services/peer-manager/peer_scoring.d.ts +5 -2
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +28 -10
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +12 -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 +83 -106
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +4 -7
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +11 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +31 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +19 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +52 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +3 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +5 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -8
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +30 -14
- package/dest/services/service.d.ts +26 -4
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -4
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +80 -76
- 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 +38 -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 +100 -0
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -7
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/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.d.ts +7 -3
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +60 -26
- package/dest/services/tx_collection/tx_collection.d.ts +23 -13
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +18 -8
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +26 -29
- package/dest/services/tx_collection/tx_source.d.ts +13 -7
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +26 -7
- package/dest/services/tx_file_store/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +9 -6
- package/dest/services/tx_provider.d.ts +4 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +9 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts +7 -8
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +30 -4
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +105 -4
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +35 -24
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +115 -38
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +57 -27
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +6 -3
- package/dest/util.d.ts +3 -3
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +102 -25
- package/src/client/interface.ts +52 -34
- package/src/client/p2p_client.ts +190 -266
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +33 -14
- package/src/config.ts +149 -43
- package/src/errors/p2p-service.error.ts +11 -0
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/index.ts +1 -1
- package/src/mem_pools/attestation_pool/attestation_pool.ts +104 -50
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +61 -57
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +1 -1
- package/src/mem_pools/instrumentation.ts +17 -13
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool_v2/README.md +85 -11
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +321 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +7 -3
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +18 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +59 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +14 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +33 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +4 -3
- package/src/mem_pools/tx_pool_v2/index.ts +2 -1
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +32 -12
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +209 -27
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +58 -45
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +34 -8
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +410 -187
- package/src/msg_validators/attestation_validator/README.md +49 -0
- package/src/msg_validators/attestation_validator/attestation_validator.ts +5 -4
- package/src/msg_validators/clock_tolerance.ts +4 -3
- package/src/msg_validators/proposal_validator/README.md +123 -0
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +69 -45
- package/src/msg_validators/tx_validator/README.md +119 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +5 -5
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/data_validator.ts +42 -1
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/factory.ts +394 -78
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +123 -27
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +12 -4
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +82 -27
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +18 -7
- package/src/services/encoding.ts +18 -10
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +288 -198
- package/src/services/peer-manager/metrics.ts +7 -0
- package/src/services/peer-manager/peer_manager.ts +28 -9
- package/src/services/peer-manager/peer_scoring.ts +21 -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 +79 -112
- package/src/services/reqresp/batch-tx-requester/interface.ts +3 -6
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +30 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +68 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +2 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +13 -9
- package/src/services/reqresp/reqresp.ts +35 -15
- package/src/services/service.ts +37 -3
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +83 -76
- package/src/services/tx_collection/file_store_tx_collection.ts +202 -0
- package/src/services/tx_collection/file_store_tx_source.ts +129 -0
- package/src/services/tx_collection/index.ts +1 -0
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/proposal_tx_collector.ts +9 -13
- package/src/services/tx_collection/request_tracker.ts +127 -0
- package/src/services/tx_collection/slow_tx_collection.ts +66 -33
- package/src/services/tx_collection/tx_collection.ts +114 -19
- package/src/services/tx_collection/tx_collection_sink.ts +30 -34
- package/src/services/tx_collection/tx_source.ts +28 -8
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +10 -8
- package/src/services/tx_provider.ts +10 -9
- package/src/test-helpers/make-test-p2p-clients.ts +4 -6
- package/src/test-helpers/mock-pubsub.ts +146 -9
- package/src/test-helpers/reqresp-nodes.ts +3 -6
- package/src/test-helpers/testbench-utils.ts +137 -43
- package/src/testbench/p2p_client_testbench_worker.ts +63 -30
- package/src/testbench/worker_client_manager.ts +13 -6
- package/src/util.ts +8 -2
- 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/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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Attestation Validation
|
|
2
|
+
|
|
3
|
+
This module validates `CheckpointAttestation` gossipsub messages. Attestations are signatures from committee members endorsing a checkpoint proposal.
|
|
4
|
+
|
|
5
|
+
**Topic**: `checkpoint_attestation` | **Snappy size limit**: 5 KB
|
|
6
|
+
|
|
7
|
+
## Stage 1: AttestationValidator (Gossipsub Validation)
|
|
8
|
+
|
|
9
|
+
| # | Rule | Consequence | Severity | File |
|
|
10
|
+
|---|------|-------------|----------|------|
|
|
11
|
+
| 1 | **Slot timeliness**: `currentSlot` or `nextSlot`. Previous slot within 500ms: IGNORE. Older: REJECT. | REJECT or IGNORE | HighToleranceError | `attestation_validator.ts` |
|
|
12
|
+
| 2 | **Attester signature**: `getSender()` must recover valid address | REJECT | LowToleranceError | same |
|
|
13
|
+
| 3 | **Attester in committee**: recovered address in committee for slot | REJECT | HighToleranceError | same |
|
|
14
|
+
| 4 | **Proposer exists**: `getProposerAttesterAddressInSlot` must return defined | REJECT | HighToleranceError | same |
|
|
15
|
+
| 5 | **Proposer signature**: `getProposer()` must recover valid address | REJECT | LowToleranceError | same |
|
|
16
|
+
| 6 | **Proposer matches expected**: recovered proposer = expected for slot | REJECT | HighToleranceError | same |
|
|
17
|
+
| 7 | **NoCommitteeError**: committee unavailable | REJECT | LowToleranceError | same |
|
|
18
|
+
|
|
19
|
+
**Fisherman mode extension** (`FishermanAttestationValidator`): if a checkpoint proposal for the same archive exists in pool, the attestation's `ConsensusPayload` must `.equals()` the stored proposal's payload. On mismatch: REJECT + LowToleranceError.
|
|
20
|
+
|
|
21
|
+
## Stage 2: Pool Admission
|
|
22
|
+
|
|
23
|
+
| # | Rule | Consequence |
|
|
24
|
+
|---|------|-------------|
|
|
25
|
+
| 8 | Sender recoverable (pool-side) | Silent drop |
|
|
26
|
+
| 9 | Not a duplicate (same slot + proposalId + signer) | IGNORE |
|
|
27
|
+
| 10 | Per-signer cap: `MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER` = 2 | IGNORE |
|
|
28
|
+
|
|
29
|
+
Own attestations added via `addOwnCheckpointAttestations` bypass the per-signer cap.
|
|
30
|
+
|
|
31
|
+
## Stage 3: Equivocation Detection
|
|
32
|
+
|
|
33
|
+
When a signer's attestation count for a slot reaches exactly 2 (different proposals): `duplicateAttestationCallback` fires -> `WANT_TO_SLASH_EVENT` with `OffenseType.DUPLICATE_ATTESTATION`. Attestation still ACCEPTED and rebroadcast. Callback fires once (not again at count 3+).
|
|
34
|
+
|
|
35
|
+
## Validation at L1 Checkpoint Submission (Archiver)
|
|
36
|
+
|
|
37
|
+
| Rule | Consequence | File |
|
|
38
|
+
|------|-------------|------|
|
|
39
|
+
| Each attestation must have recoverable signature (or address-only is allowed but does not count toward quorum) | Checkpoint rejected as invalid | `archiver/src/modules/validation.ts` |
|
|
40
|
+
| Attestation at index `i` must correspond to committee member at index `i` | Checkpoint rejected as invalid | same |
|
|
41
|
+
| Valid attestation count >= floor(committee * 2/3) + 1 | Checkpoint rejected as invalid | same |
|
|
42
|
+
| No committee / escape hatch open | Accepted unconditionally | same |
|
|
43
|
+
|
|
44
|
+
Note: `skipValidateCheckpointAttestations` config flag bypasses all archiver attestation validation.
|
|
45
|
+
|
|
46
|
+
## Gossipsub Topic Scoring
|
|
47
|
+
|
|
48
|
+
P3 enabled with expected messages per slot = `targetCommitteeSize`. Conservative threshold (30% of convergence value). Max P3 penalty = -34 per topic.
|
|
49
|
+
|
|
@@ -23,13 +23,14 @@ export class CheckpointAttestationValidator implements P2PValidator<CheckpointAt
|
|
|
23
23
|
const slotNumber = message.payload.header.slotNumber;
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
|
|
26
|
+
// Use target slots since proposals target pipeline slots (slot + 1 when pipelining)
|
|
27
|
+
const { targetSlot, nextSlot } = this.epochCache.getTargetAndNextSlot();
|
|
27
28
|
|
|
28
|
-
if (slotNumber !==
|
|
29
|
+
if (slotNumber !== targetSlot && slotNumber !== nextSlot) {
|
|
29
30
|
// Check if message is for previous slot and within clock tolerance
|
|
30
|
-
if (!isWithinClockTolerance(slotNumber,
|
|
31
|
+
if (!isWithinClockTolerance(slotNumber, targetSlot, this.epochCache)) {
|
|
31
32
|
this.logger.warn(
|
|
32
|
-
`Checkpoint attestation slot ${slotNumber} is not current (${
|
|
33
|
+
`Checkpoint attestation slot ${slotNumber} is not current (${targetSlot}) or next (${nextSlot}) slot`,
|
|
33
34
|
);
|
|
34
35
|
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
35
36
|
}
|
|
@@ -36,10 +36,11 @@ export function isWithinClockTolerance(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// Check how far we are into the current slot (in milliseconds)
|
|
39
|
-
const { ts: slotStartTs, nowMs
|
|
39
|
+
const { ts: slotStartTs, nowMs } = epochCache.getEpochAndSlotNow();
|
|
40
|
+
const targetSlot = epochCache.getTargetSlot();
|
|
40
41
|
|
|
41
|
-
// Sanity check: ensure the epoch cache's
|
|
42
|
-
if (
|
|
42
|
+
// Sanity check: ensure the epoch cache's target slot matches the expected current slot
|
|
43
|
+
if (targetSlot !== currentSlot) {
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Proposal Validation
|
|
2
|
+
|
|
3
|
+
This module validates `BlockProposal` and `CheckpointProposal` gossipsub messages. Both share the same base `ProposalValidator` (neither subclass overrides `validate()`), with checkpoint-specific logic layered on top in the gossipsub handler.
|
|
4
|
+
|
|
5
|
+
## BlockProposal
|
|
6
|
+
|
|
7
|
+
**Topic**: `block_proposal` | **Snappy size limit**: 10 MB
|
|
8
|
+
|
|
9
|
+
### Stage 1: Gossipsub Validation (ProposalValidator)
|
|
10
|
+
|
|
11
|
+
File: `proposal_validator.ts`
|
|
12
|
+
|
|
13
|
+
| # | Rule | Consequence | Severity |
|
|
14
|
+
|---|------|-------------|----------|
|
|
15
|
+
| 1 | **Slot check**: must be `currentSlot` or `nextSlot`. Previous slot within 500ms tolerance: IGNORE. | REJECT | HighToleranceError |
|
|
16
|
+
| 2 | **Signature**: `getSender()` must recover a valid address. If `signedTxs` present, its recovered sender must match. | REJECT | MidToleranceError |
|
|
17
|
+
| 3 | **Txs permitted**: if `disableTransactions`, must have 0 txHashes and 0 embedded txs | REJECT | MidToleranceError |
|
|
18
|
+
| 4 | **Max txs**: `txHashes.length <= maxTxsPerBlock` | REJECT | MidToleranceError |
|
|
19
|
+
| 5 | **Embedded txs in txHashes**: every embedded tx's hash must appear in `txHashes` | REJECT | MidToleranceError |
|
|
20
|
+
| 6 | **Proposer check**: signer must match expected proposer for slot (skipped if committee size = 0) | REJECT | MidToleranceError |
|
|
21
|
+
| 7 | **Tx hash integrity**: each embedded tx's recomputed hash must match declared hash | REJECT | LowToleranceError |
|
|
22
|
+
| 8 | **NoCommitteeError**: epoch cache cannot determine committee | REJECT | LowToleranceError |
|
|
23
|
+
|
|
24
|
+
Deserialization guards: `BlockProposal.fromBuffer` and `SignedTxs.fromBuffer` both enforce `txCount <= MAX_TXS_PER_BLOCK` (65536). Violation -> REJECT + LowToleranceError.
|
|
25
|
+
|
|
26
|
+
### Stage 2: Mempool (Attestation Pool)
|
|
27
|
+
|
|
28
|
+
| # | Rule | Consequence |
|
|
29
|
+
|---|------|-------------|
|
|
30
|
+
| 9 | **Duplicate**: same archive root already stored | IGNORE (no penalty) |
|
|
31
|
+
| 10 | **Per-position cap**: max 2 proposals per (slot, indexWithinCheckpoint) | REJECT + HighToleranceError |
|
|
32
|
+
| 11 | **Equivocation**: >1 distinct proposal for same (slot, index) | ACCEPT (rebroadcast for detection). At count=2: `duplicateProposalCallback` fires -> slash event (`OffenseType.DUPLICATE_PROPOSAL`, configured via `slashDuplicateProposalPenalty`) |
|
|
33
|
+
|
|
34
|
+
### Stage 3: Validator-Client Processing (BlockProposalHandler)
|
|
35
|
+
|
|
36
|
+
Only runs on validator nodes. Non-validator nodes use a default handler that triggers tx collection without deep validation.
|
|
37
|
+
|
|
38
|
+
| # | Rule | Failure Reason |
|
|
39
|
+
|---|------|----------------|
|
|
40
|
+
| 12 | Signature re-check | `invalid_proposal` |
|
|
41
|
+
| 13 | ProposalValidator re-run | `invalid_proposal` |
|
|
42
|
+
| 14 | Self-proposal filter | Ignored silently |
|
|
43
|
+
| 15 | Parent block exists (`lastArchive.root` matches known block or genesis) | `parent_block_not_found` |
|
|
44
|
+
| 16 | Parent block slot <= proposal slot | `parent_block_wrong_slot` |
|
|
45
|
+
| 17 | Block number not already in archiver | `block_number_already_exists` |
|
|
46
|
+
| 18 | Checkpoint number consistency (multiple sub-rules for first/non-first blocks) | `invalid_proposal` |
|
|
47
|
+
| 19 | Global variables consistency (non-first block: chainId, version, slot, timestamp, coinbase, feeRecipient, gasFees match parent) | `global_variables_mismatch` |
|
|
48
|
+
| 20 | L1-to-L2 message hash matches `proposal.inHash` | `in_hash_mismatch` |
|
|
49
|
+
| 21 | All txs referenced by `txHashes` obtainable | `txs_not_available` |
|
|
50
|
+
| 22 | **Re-execution**: processed tx count matches `txHashes.length` | `timeout` (ReExTimeoutError) |
|
|
51
|
+
| 23 | **Re-execution**: no failed txs | `failed_txs` (ReExFailedTxsError) -- **SLASHABLE** |
|
|
52
|
+
| 24 | **Re-execution**: archive root and header match proposal | `state_mismatch` (ReExStateMismatchError) -- **SLASHABLE** |
|
|
53
|
+
|
|
54
|
+
**Escape hatch**: during escape hatch periods (`isEscapeHatchOpenAtSlot`), re-execution and slashing are both disabled, and the proposal is rejected locally.
|
|
55
|
+
|
|
56
|
+
**Conditional re-execution**: rules 22-24 only run when at least one condition is true: `fishermanMode` enabled, `slashBroadcastedInvalidBlockPenalty > 0`, committee membership, `alwaysReexecuteBlockProposals`, or `blobClient.canUpload()`.
|
|
57
|
+
|
|
58
|
+
**Slashing**: only `state_mismatch` and `failed_txs` trigger on-chain slashing (`OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL`, gated by `slashBroadcastedInvalidBlockPenalty > 0`). Unknown errors during re-execution do NOT slash.
|
|
59
|
+
|
|
60
|
+
**Embedded tx validation**: txs in `signedTxs` are validated via `createTxValidatorForBlockProposalReceivedTxs` (well-formedness only) when stored in the tx pool. Invalid embedded txs are rejected from the pool but do not cause the block proposal itself to be rejected at gossipsub level.
|
|
61
|
+
|
|
62
|
+
### Gossipsub Topic Scoring
|
|
63
|
+
|
|
64
|
+
| Parameter | Effect |
|
|
65
|
+
|-----------|--------|
|
|
66
|
+
| P4 (invalidMessageDeliveries) | weight = -20, decay over 4 slots |
|
|
67
|
+
| P3 (meshMessageDeliveries) | Enabled only when `expectedBlockProposalsPerSlot > 0` (MBPS mode) |
|
|
68
|
+
| P1/P2 | Only active when P3 is enabled |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## CheckpointProposal
|
|
73
|
+
|
|
74
|
+
**Topic**: `checkpoint_proposal` | **Snappy size limit**: 10 MB
|
|
75
|
+
|
|
76
|
+
### Stage 1: Gossipsub Validation (ProposalValidator)
|
|
77
|
+
|
|
78
|
+
Same `ProposalValidator.validate()` as BlockProposal (shared implementation, neither subclass overrides it). See BlockProposal Stage 1 rules 1-8.
|
|
79
|
+
|
|
80
|
+
### Stage 2: Embedded Block Proposal Validation (if `lastBlock` present)
|
|
81
|
+
|
|
82
|
+
The checkpoint's embedded `lastBlock` is extracted via `getBlockProposal()` and validated through `BlockProposalValidator.validate()` plus block mempool checks.
|
|
83
|
+
|
|
84
|
+
| Rule | Consequence | File |
|
|
85
|
+
|------|-------------|------|
|
|
86
|
+
| Block proposal must pass `BlockProposalValidator.validate()` | If REJECT: entire checkpoint REJECTED | `libp2p_service.ts` |
|
|
87
|
+
| Block proposal must not exceed per-position cap (2) | Checkpoint REJECTED + HighToleranceError | same |
|
|
88
|
+
| Block equivocation detected (>1 proposals for same slot+index) | Checkpoint REJECTED (block itself is ACCEPT for re-broadcast) | same |
|
|
89
|
+
|
|
90
|
+
### Stage 3: Mempool (Attestation Pool)
|
|
91
|
+
|
|
92
|
+
| Rule | Consequence | File |
|
|
93
|
+
|------|-------------|------|
|
|
94
|
+
| Duplicate (same archive ID) | IGNORE (no penalty). Embedded block still processed if valid. | `attestation_pool.ts` |
|
|
95
|
+
| Per-slot cap: `MAX_CHECKPOINT_PROPOSALS_PER_SLOT` = 2 | REJECT + HighToleranceError. Embedded block still processed. | same |
|
|
96
|
+
|
|
97
|
+
### Stage 4: Equivocation Detection
|
|
98
|
+
|
|
99
|
+
When >1 checkpoint proposals exist for same slot (count > 1): ACCEPT (re-broadcast). At count == 2 (exactly): `duplicateProposalCallback` fires. Proposal NOT further processed. Callback fires only once per equivocation pair.
|
|
100
|
+
|
|
101
|
+
### Stage 5: Validator-Client Consensus Validation
|
|
102
|
+
|
|
103
|
+
Determines whether the validator signs an attestation.
|
|
104
|
+
|
|
105
|
+
| Rule | Consequence | File |
|
|
106
|
+
|------|-------------|------|
|
|
107
|
+
| Escape hatch open | No attestation | `validator-client/src/validator.ts` |
|
|
108
|
+
| Signature invalid (re-check) | No attestation | same |
|
|
109
|
+
| Self-proposal | No attestation (ignored) | same |
|
|
110
|
+
| `feeAssetPriceModifier` outside [-100, +100] bps | No attestation | same |
|
|
111
|
+
| Not in committee (unless fisherman mode) | No attestation | same |
|
|
112
|
+
| Checkpoint header mismatch (computed vs proposal) | No attestation | same |
|
|
113
|
+
| Archive root mismatch | No attestation | same |
|
|
114
|
+
| Epoch out hash mismatch | No attestation | same |
|
|
115
|
+
| Last block not found / not matching | No attestation | same |
|
|
116
|
+
| Already attested to this or earlier slot | No attestation (unless `attestToEquivocatedProposals`) | same |
|
|
117
|
+
|
|
118
|
+
**`skipCheckpointProposalValidation` config**: when true, the re-execution checks (header/archive/epoch hash) are all skipped. Signature, fee modifier, committee, escape hatch, and equivocation checks still apply.
|
|
119
|
+
|
|
120
|
+
### Gossipsub Topic Scoring
|
|
121
|
+
|
|
122
|
+
P3 enabled with expected rate of 1 message per slot. P4 weight = -20, max P3 penalty = -34 per topic.
|
|
123
|
+
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import type { BlockProposal, P2PValidator } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { BlockProposal, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
|
|
4
4
|
import { ProposalValidator } from '../proposal_validator/proposal_validator.js';
|
|
5
5
|
|
|
6
|
-
export class BlockProposalValidator
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export class BlockProposalValidator implements P2PValidator<BlockProposal> {
|
|
7
|
+
private proposalValidator: ProposalValidator;
|
|
8
|
+
|
|
9
|
+
constructor(epochCache: EpochCacheInterface, opts: { txsPermitted: boolean; maxTxsPerBlock?: number }) {
|
|
10
|
+
this.proposalValidator = new ProposalValidator(epochCache, opts, 'p2p:block_proposal_validator');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async validate(proposal: BlockProposal): Promise<ValidationResult> {
|
|
14
|
+
const headerResult = await this.proposalValidator.validate(proposal);
|
|
15
|
+
if (headerResult.result !== 'accept') {
|
|
16
|
+
return headerResult;
|
|
17
|
+
}
|
|
18
|
+
return this.proposalValidator.validateTxs(proposal);
|
|
9
19
|
}
|
|
10
20
|
}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import type { CheckpointProposal, P2PValidator } from '@aztec/stdlib/p2p';
|
|
2
|
+
import type { CheckpointProposal, P2PValidator, ValidationResult } from '@aztec/stdlib/p2p';
|
|
3
3
|
|
|
4
4
|
import { ProposalValidator } from '../proposal_validator/proposal_validator.js';
|
|
5
5
|
|
|
6
|
-
export class CheckpointProposalValidator
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export class CheckpointProposalValidator implements P2PValidator<CheckpointProposal> {
|
|
7
|
+
private proposalValidator: ProposalValidator;
|
|
8
|
+
|
|
9
|
+
constructor(epochCache: EpochCacheInterface, opts: { txsPermitted: boolean; maxTxsPerBlock?: number }) {
|
|
10
|
+
this.proposalValidator = new ProposalValidator(epochCache, opts, 'p2p:checkpoint_proposal_validator');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async validate(proposal: CheckpointProposal): Promise<ValidationResult> {
|
|
14
|
+
const headerResult = await this.proposalValidator.validate(proposal);
|
|
15
|
+
if (headerResult.result !== 'accept') {
|
|
16
|
+
return headerResult;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const blockProposal = proposal.getBlockProposal();
|
|
20
|
+
if (blockProposal) {
|
|
21
|
+
return this.proposalValidator.validateTxs(blockProposal);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { result: 'accept' };
|
|
12
25
|
}
|
|
13
26
|
}
|
|
@@ -1,30 +1,44 @@
|
|
|
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 BlockProposal,
|
|
6
|
+
type CheckpointProposalCore,
|
|
7
|
+
PeerErrorSeverity,
|
|
8
|
+
type ValidationResult,
|
|
9
|
+
} from '@aztec/stdlib/p2p';
|
|
5
10
|
|
|
6
11
|
import { isWithinClockTolerance } from '../clock_tolerance.js';
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
/** Validates header-level and tx-level fields of block and checkpoint proposals. */
|
|
14
|
+
export class ProposalValidator {
|
|
15
|
+
private epochCache: EpochCacheInterface;
|
|
16
|
+
private logger: Logger;
|
|
17
|
+
private txsPermitted: boolean;
|
|
18
|
+
private maxTxsPerBlock?: number;
|
|
12
19
|
|
|
13
|
-
constructor(
|
|
20
|
+
constructor(
|
|
21
|
+
epochCache: EpochCacheInterface,
|
|
22
|
+
opts: { txsPermitted: boolean; maxTxsPerBlock?: number },
|
|
23
|
+
loggerName: string,
|
|
24
|
+
) {
|
|
14
25
|
this.epochCache = epochCache;
|
|
15
26
|
this.txsPermitted = opts.txsPermitted;
|
|
27
|
+
this.maxTxsPerBlock = opts.maxTxsPerBlock;
|
|
16
28
|
this.logger = createLogger(loggerName);
|
|
17
29
|
}
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
/** Validates header-level fields: slot, signature, and proposer. */
|
|
32
|
+
public async validate(proposal: BlockProposal | CheckpointProposalCore): Promise<ValidationResult> {
|
|
20
33
|
try {
|
|
21
|
-
// Slot check
|
|
22
|
-
const {
|
|
34
|
+
// Slot check: use target slots since proposals target pipeline slots (slot + 1 when pipelining)
|
|
35
|
+
const { targetSlot, nextSlot } = this.epochCache.getTargetAndNextSlot();
|
|
36
|
+
|
|
23
37
|
const slotNumber = proposal.slotNumber;
|
|
24
|
-
if (slotNumber !==
|
|
38
|
+
if (slotNumber !== targetSlot && slotNumber !== nextSlot) {
|
|
25
39
|
// Check if message is for previous slot and within clock tolerance
|
|
26
|
-
if (!isWithinClockTolerance(slotNumber,
|
|
27
|
-
this.logger.warn(`Penalizing peer for invalid slot number ${slotNumber}`, {
|
|
40
|
+
if (!isWithinClockTolerance(slotNumber, targetSlot, this.epochCache)) {
|
|
41
|
+
this.logger.warn(`Penalizing peer for invalid slot number ${slotNumber}`, { targetSlot, nextSlot });
|
|
28
42
|
return { result: 'reject', severity: PeerErrorSeverity.HighToleranceError };
|
|
29
43
|
}
|
|
30
44
|
this.logger.verbose(`Ignoring proposal for previous slot ${slotNumber} within clock tolerance`);
|
|
@@ -38,30 +52,6 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
38
52
|
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
// Transactions permitted check
|
|
42
|
-
const embeddedTxCount = proposal.txs?.length ?? 0;
|
|
43
|
-
if (!this.txsPermitted && (proposal.txHashes.length > 0 || embeddedTxCount > 0)) {
|
|
44
|
-
this.logger.warn(
|
|
45
|
-
`Penalizing peer for proposal with ${proposal.txHashes.length} transaction(s) when transactions are not permitted`,
|
|
46
|
-
);
|
|
47
|
-
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Embedded txs must be listed in txHashes
|
|
51
|
-
const hashSet = new Set(proposal.txHashes.map(h => h.toString()));
|
|
52
|
-
const missingTxHashes =
|
|
53
|
-
embeddedTxCount > 0
|
|
54
|
-
? proposal.txs!.filter(tx => !hashSet.has(tx.getTxHash().toString())).map(tx => tx.getTxHash().toString())
|
|
55
|
-
: [];
|
|
56
|
-
if (embeddedTxCount > 0 && missingTxHashes.length > 0) {
|
|
57
|
-
this.logger.warn('Penalizing peer for embedded transaction(s) not included in txHashes', {
|
|
58
|
-
embeddedTxCount,
|
|
59
|
-
txHashesLength: proposal.txHashes.length,
|
|
60
|
-
missingTxHashes,
|
|
61
|
-
});
|
|
62
|
-
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
55
|
// Proposer check
|
|
66
56
|
const expectedProposer = await this.epochCache.getProposerAttesterAddressInSlot(slotNumber);
|
|
67
57
|
if (expectedProposer !== undefined && !proposer.equals(expectedProposer)) {
|
|
@@ -72,15 +62,6 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
72
62
|
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
73
63
|
}
|
|
74
64
|
|
|
75
|
-
// Validate tx hashes for all txs embedded in the proposal
|
|
76
|
-
if (!(await Promise.all(proposal.txs?.map(tx => tx.validateTxHash()) ?? [])).every(v => v)) {
|
|
77
|
-
this.logger.warn(`Penalizing peer for invalid tx hashes in proposal`, {
|
|
78
|
-
proposer,
|
|
79
|
-
slotNumber,
|
|
80
|
-
});
|
|
81
|
-
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
82
|
-
}
|
|
83
|
-
|
|
84
65
|
return { result: 'accept' };
|
|
85
66
|
} catch (e) {
|
|
86
67
|
if (e instanceof NoCommitteeError) {
|
|
@@ -89,4 +70,47 @@ export abstract class ProposalValidator<TProposal extends BlockProposal | Checkp
|
|
|
89
70
|
throw e;
|
|
90
71
|
}
|
|
91
72
|
}
|
|
73
|
+
|
|
74
|
+
/** Validates transaction-related fields of a block proposal. */
|
|
75
|
+
public async validateTxs(proposal: BlockProposal): Promise<ValidationResult> {
|
|
76
|
+
// Transactions permitted check
|
|
77
|
+
const embeddedTxCount = proposal.txs?.length ?? 0;
|
|
78
|
+
if (!this.txsPermitted && (proposal.txHashes.length > 0 || embeddedTxCount > 0)) {
|
|
79
|
+
this.logger.warn(
|
|
80
|
+
`Penalizing peer for proposal with ${proposal.txHashes.length} transaction(s) when transactions are not permitted`,
|
|
81
|
+
);
|
|
82
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Max txs per block check
|
|
86
|
+
if (this.maxTxsPerBlock !== undefined && proposal.txHashes.length > this.maxTxsPerBlock) {
|
|
87
|
+
this.logger.warn(
|
|
88
|
+
`Penalizing peer for proposal with ${proposal.txHashes.length} transaction(s) when max is ${this.maxTxsPerBlock}`,
|
|
89
|
+
);
|
|
90
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Embedded txs must be listed in txHashes
|
|
94
|
+
const hashSet = new Set(proposal.txHashes.map(h => h.toString()));
|
|
95
|
+
const missingTxHashes =
|
|
96
|
+
embeddedTxCount > 0
|
|
97
|
+
? proposal.txs!.filter(tx => !hashSet.has(tx.getTxHash().toString())).map(tx => tx.getTxHash().toString())
|
|
98
|
+
: [];
|
|
99
|
+
if (embeddedTxCount > 0 && missingTxHashes.length > 0) {
|
|
100
|
+
this.logger.warn('Penalizing peer for embedded transaction(s) not included in txHashes', {
|
|
101
|
+
embeddedTxCount,
|
|
102
|
+
txHashesLength: proposal.txHashes.length,
|
|
103
|
+
missingTxHashes,
|
|
104
|
+
});
|
|
105
|
+
return { result: 'reject', severity: PeerErrorSeverity.MidToleranceError };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Validate tx hashes for all txs embedded in the proposal
|
|
109
|
+
if (!(await Promise.all(proposal.txs?.map(tx => tx.validateTxHash()) ?? [])).every(v => v)) {
|
|
110
|
+
this.logger.warn(`Penalizing peer for invalid tx hashes in proposal`);
|
|
111
|
+
return { result: 'reject', severity: PeerErrorSeverity.LowToleranceError };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return { result: 'accept' };
|
|
115
|
+
}
|
|
92
116
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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, AllowedSetupCalls
|
|
79
|
+
|
|
80
|
+
Operates on `TxMetaData` (pre-built by the pool) rather than full `Tx` objects.
|
|
81
|
+
|
|
82
|
+
The `AllowedSetupCallsMetaValidator` checks a precomputed boolean flag (`TxMetaData.allowedSetupCalls`) rather than re-running the full `PhasesTxValidator`. This flag is computed by `createCheckAllowedSetupCalls` when the tx first enters the pool (via `addProtectedTxs` or startup hydration), so the pool migration validator can reject txs with disallowed setup calls without needing the full `Tx` object or its dependencies.
|
|
83
|
+
|
|
84
|
+
## Individual Validators
|
|
85
|
+
|
|
86
|
+
| Validator | What it checks | Benchmarked verification duration |
|
|
87
|
+
|-----------|---------------|---------------|
|
|
88
|
+
| `TxPermittedValidator` | Whether the system is accepting transactions (controlled by config flag) | 1.56 us |
|
|
89
|
+
| `DataTxValidator` | Transaction data integrity — correct structure, non-empty fields | 4.10–18.18 ms |
|
|
90
|
+
| `SizeTxValidator` | Transaction does not exceed maximum size limits | 2.28 us |
|
|
91
|
+
| `MetadataTxValidator` | Chain ID, rollup version, protocol contracts hash, VK tree root | 4.18 us |
|
|
92
|
+
| `TimestampTxValidator` | Transaction has not expired (expiration timestamp vs next slot) | 1.56 us |
|
|
93
|
+
| `DoubleSpendTxValidator` | Nullifiers do not already exist in the nullifier tree | 106.08 us |
|
|
94
|
+
| `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 |
|
|
95
|
+
| `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 |
|
|
96
|
+
| `PhasesTxValidator` | Public function calls in setup phase are on the allow list | 10.12–13.12 us |
|
|
97
|
+
| `AllowedSetupCallsMetaValidator` | Checks the precomputed `allowedSetupCalls` flag on `TxMetaData`. Used in pool migration instead of the full `PhasesTxValidator` | — |
|
|
98
|
+
| `BlockHeaderTxValidator` | Transaction's anchor block hash exists in the archive tree | 98.88 us |
|
|
99
|
+
| `TxProofValidator` | Client proof verifies correctly | ~250ms |
|
|
100
|
+
|
|
101
|
+
## Validator Coverage by Entry Point
|
|
102
|
+
|
|
103
|
+
| Validator | Gossip | RPC | Req/resp | Block building | Pool migration |
|
|
104
|
+
|-----------|--------|-----|----------|----------------|----------------|
|
|
105
|
+
| TxPermitted | Stage 1 | Yes | — | — | — |
|
|
106
|
+
| Data | Stage 1 | Yes | Yes | — | — |
|
|
107
|
+
| Size | — | Yes | Yes | — | — |
|
|
108
|
+
| Metadata | Stage 1 | Yes | Yes | — | — |
|
|
109
|
+
| Timestamp | Stage 1 | Yes | — | Yes | Yes |
|
|
110
|
+
| DoubleSpend | Stage 1 | Yes | — | Yes | Yes |
|
|
111
|
+
| Gas (balance + limits) | Stage 1 | Optional* | — | Yes | — |
|
|
112
|
+
| GasLimits (standalone) | — | — | — | — | Yes |
|
|
113
|
+
| Phases | Stage 1 | Yes | — | Yes | — |
|
|
114
|
+
| AllowedSetupCalls | — | — | — | — | Yes |
|
|
115
|
+
| BlockHeader | Stage 1 | Yes | — | Yes | Yes |
|
|
116
|
+
| Proof | Stage 2 | Optional** | Yes | — | — |
|
|
117
|
+
|
|
118
|
+
\* 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.
|
|
119
|
+
\** 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,35 +1,30 @@
|
|
|
1
|
-
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
2
|
-
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
3
1
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
-
import {
|
|
2
|
+
import { AuthRegistryArtifact } from '@aztec/protocol-contracts/auth-registry';
|
|
3
|
+
import { FeeJuiceArtifact } from '@aztec/protocol-contracts/fee-juice';
|
|
5
4
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
import { buildAllowedElement } from './allowed_setup_helpers.js';
|
|
7
|
+
|
|
8
|
+
let defaultAllowedSetupFunctions: AllowedElement[] | undefined;
|
|
9
|
+
|
|
10
|
+
/** Returns the default list of functions allowed to run in the setup phase of a transaction. */
|
|
8
11
|
export async function getDefaultAllowedSetupFunctions(): Promise<AllowedElement[]> {
|
|
9
12
|
if (defaultAllowedSetupFunctions === undefined) {
|
|
10
|
-
defaultAllowedSetupFunctions = [
|
|
11
|
-
// needed for authwit support
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// selector: FunctionSelector.fromSignature('_increase_public_balance((Field),u128)'),
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
classId: (await getContractClassFromArtifact(FPCContract.artifact)).id,
|
|
29
|
-
// We can't restrict the selector because public functions get routed via dispatch.
|
|
30
|
-
// selector: FunctionSelector.fromSignature('prepare_fee((Field),Field,(Field),Field)'),
|
|
31
|
-
},
|
|
32
|
-
];
|
|
13
|
+
defaultAllowedSetupFunctions = await Promise.all([
|
|
14
|
+
// AuthRegistry: needed for authwit support via private path (set_authorized_private enqueues _set_authorized)
|
|
15
|
+
buildAllowedElement(AuthRegistryArtifact, { address: ProtocolContractAddress.AuthRegistry }, '_set_authorized', {
|
|
16
|
+
onlySelf: true,
|
|
17
|
+
rejectNullMsgSender: true,
|
|
18
|
+
}),
|
|
19
|
+
// AuthRegistry: needed for authwit support via public path (PublicFeePaymentMethod calls set_authorized directly)
|
|
20
|
+
buildAllowedElement(AuthRegistryArtifact, { address: ProtocolContractAddress.AuthRegistry }, 'set_authorized', {
|
|
21
|
+
rejectNullMsgSender: true,
|
|
22
|
+
}),
|
|
23
|
+
// FeeJuice: needed for claiming on the same tx as a spend (claim_and_end_setup enqueues this)
|
|
24
|
+
buildAllowedElement(FeeJuiceArtifact, { address: ProtocolContractAddress.FeeJuice }, '_increase_public_balance', {
|
|
25
|
+
onlySelf: true,
|
|
26
|
+
}),
|
|
27
|
+
]);
|
|
33
28
|
}
|
|
34
29
|
return defaultAllowedSetupFunctions;
|
|
35
30
|
}
|