@aztec/p2p 0.0.0-test.1 → 0.0.1-commit.21caa21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bootstrap/bootstrap.d.ts +1 -1
- package/dest/bootstrap/bootstrap.d.ts.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -9
- package/dest/client/factory.d.ts +14 -4
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +60 -24
- package/dest/client/index.d.ts +2 -1
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +157 -0
- package/dest/client/interface.d.ts.map +1 -0
- package/dest/client/interface.js +9 -0
- package/dest/client/p2p_client.d.ts +72 -187
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +373 -177
- package/dest/config.d.ts +151 -125
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +183 -34
- package/dest/enr/generate-enr.d.ts +11 -3
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +27 -5
- package/dest/enr/index.d.ts +1 -1
- package/dest/errors/attestation-pool.error.d.ts +7 -0
- package/dest/errors/attestation-pool.error.d.ts.map +1 -0
- package/dest/errors/attestation-pool.error.js +12 -0
- package/dest/errors/reqresp.error.d.ts +1 -1
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/index.d.ts +4 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +68 -8
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- 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 +214 -63
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +21 -6
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +126 -25
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +19 -6
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +111 -21
- package/dest/mem_pools/attestation_pool/mocks.d.ts +225 -5
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +9 -15
- package/dest/mem_pools/index.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts +10 -12
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +35 -38
- package/dest/mem_pools/interface.d.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +62 -13
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +469 -97
- package/dest/mem_pools/tx_pool/index.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +34 -10
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +133 -36
- package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
- package/dest/mem_pools/tx_pool/priority.js +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +65 -9
- package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +264 -39
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +45 -9
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +20 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -0
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +67 -0
- package/dest/msg_validators/attestation_validator/index.d.ts +2 -1
- package/dest/msg_validators/attestation_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/index.js +1 -0
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts +6 -2
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +73 -12
- package/dest/msg_validators/block_proposal_validator/index.d.ts +1 -1
- package/dest/msg_validators/index.d.ts +1 -1
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
- package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +3 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +27 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/archive_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/archive_cache.js +22 -0
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +4 -4
- 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 +56 -86
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +1 -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 +21 -27
- package/dest/msg_validators/tx_validator/factory.d.ts +15 -0
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/factory.js +74 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +11 -0
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/gas_validator.js +115 -0
- package/dest/msg_validators/tx_validator/index.d.ts +8 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +7 -0
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +8 -4
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.js +39 -20
- package/dest/msg_validators/tx_validator/phases_validator.d.ts +14 -0
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/phases_validator.js +93 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts +17 -0
- package/dest/msg_validators/tx_validator/test_utils.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/test_utils.js +22 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +12 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/timestamp_validator.js +32 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts +8 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_permitted_validator.js +24 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
- package/dest/services/data_store.d.ts +1 -1
- package/dest/services/data_store.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.d.ts +10 -9
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +63 -36
- package/dest/services/dummy_service.d.ts +50 -11
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +88 -5
- package/dest/services/encoding.d.ts +26 -7
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +73 -5
- package/dest/services/gossipsub/scoring.d.ts +1 -1
- package/dest/services/index.d.ts +5 -1
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +4 -0
- package/dest/services/libp2p/instrumentation.d.ts +20 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
- package/dest/services/libp2p/instrumentation.js +164 -0
- package/dest/services/libp2p/libp2p_service.d.ts +78 -89
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +698 -246
- package/dest/services/peer-manager/interface.d.ts +23 -0
- package/dest/services/peer-manager/interface.d.ts.map +1 -0
- package/dest/services/peer-manager/interface.js +1 -0
- package/dest/services/peer-manager/metrics.d.ts +6 -2
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +22 -2
- package/dest/services/peer-manager/peer_manager.d.ts +102 -22
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +549 -72
- 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 +40 -2
- package/dest/services/reqresp/config.d.ts +11 -9
- package/dest/services/reqresp/config.d.ts.map +1 -1
- package/dest/services/reqresp/config.js +18 -4
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +2 -2
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +10 -6
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +31 -17
- package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
- package/dest/services/reqresp/connection-sampler/connection_sampler.js +142 -84
- package/dest/services/reqresp/index.d.ts +3 -2
- package/dest/services/reqresp/index.d.ts.map +1 -1
- package/dest/services/reqresp/index.js +2 -1
- package/dest/services/reqresp/interface.d.ts +73 -24
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +45 -26
- package/dest/services/reqresp/metrics.d.ts +1 -1
- package/dest/services/reqresp/metrics.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/auth.d.ts +43 -0
- package/dest/services/reqresp/protocols/auth.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/auth.js +71 -0
- package/dest/services/reqresp/protocols/block.d.ts +6 -1
- package/dest/services/reqresp/protocols/block.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block.js +28 -5
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +30 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +11 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +39 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +47 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +75 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts +4 -0
- package/dest/services/reqresp/protocols/block_txs/index.d.ts.map +1 -0
- package/dest/services/reqresp/protocols/block_txs/index.js +3 -0
- package/dest/services/reqresp/protocols/goodbye.d.ts +3 -5
- package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/goodbye.js +7 -7
- package/dest/services/reqresp/protocols/index.d.ts +3 -1
- package/dest/services/reqresp/protocols/index.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/index.js +2 -0
- package/dest/services/reqresp/protocols/ping.d.ts +1 -3
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +39 -7
- package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.js +72 -5
- package/dest/services/reqresp/protocols/tx.d.ts +13 -2
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +34 -6
- package/dest/services/reqresp/rate-limiter/index.d.ts +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +6 -4
- package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
- 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 +21 -1
- package/dest/services/reqresp/reqresp.d.ts +24 -66
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +298 -207
- package/dest/services/reqresp/status.d.ts +10 -4
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/reqresp/status.js +9 -2
- package/dest/services/service.d.ts +23 -19
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +25 -0
- package/dest/services/tx_collection/config.d.ts.map +1 -0
- package/dest/services/tx_collection/config.js +58 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +50 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/fast_tx_collection.js +300 -0
- package/dest/services/tx_collection/index.d.ts +3 -0
- package/dest/services/tx_collection/index.d.ts.map +1 -0
- package/dest/services/tx_collection/index.js +2 -0
- package/dest/services/tx_collection/instrumentation.d.ts +10 -0
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -0
- package/dest/services/tx_collection/instrumentation.js +34 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +52 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/slow_tx_collection.js +177 -0
- package/dest/services/tx_collection/tx_collection.d.ts +109 -0
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection.js +128 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts +30 -0
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_collection_sink.js +111 -0
- package/dest/services/tx_collection/tx_source.d.ts +18 -0
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/tx_source.js +31 -0
- package/dest/services/tx_provider.d.ts +49 -0
- package/dest/services/tx_provider.d.ts.map +1 -0
- package/dest/services/tx_provider.js +210 -0
- package/dest/services/tx_provider_instrumentation.d.ts +13 -0
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -0
- package/dest/services/tx_provider_instrumentation.js +34 -0
- package/dest/test-helpers/generate-peer-id-private-keys.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts +1 -1
- package/dest/test-helpers/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +2 -1
- package/dest/test-helpers/index.d.ts.map +1 -1
- package/dest/test-helpers/index.js +1 -0
- package/dest/test-helpers/make-enrs.d.ts +1 -1
- package/dest/test-helpers/make-enrs.d.ts.map +1 -1
- package/dest/test-helpers/make-enrs.js +4 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts +33 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +86 -16
- package/dest/test-helpers/mock-pubsub.d.ts +59 -0
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -0
- package/dest/test-helpers/mock-pubsub.js +130 -0
- package/dest/test-helpers/mock-tx-helpers.d.ts +12 -0
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -0
- package/dest/test-helpers/mock-tx-helpers.js +19 -0
- package/dest/test-helpers/reqresp-nodes.d.ts +15 -11
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +62 -28
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +103 -29
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/parse_log_file.js +4 -4
- package/dest/testbench/testbench.d.ts +1 -1
- package/dest/testbench/testbench.js +4 -4
- package/dest/testbench/worker_client_manager.d.ts +1 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +11 -19
- package/dest/types/index.d.ts +4 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +2 -0
- package/dest/util.d.ts +24 -16
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +75 -69
- package/dest/versioning.d.ts +4 -4
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +8 -3
- package/package.json +32 -27
- package/src/bootstrap/bootstrap.ts +27 -11
- package/src/client/factory.ts +136 -45
- package/src/client/index.ts +1 -0
- package/src/client/interface.ts +198 -0
- package/src/client/p2p_client.ts +469 -330
- package/src/config.ts +305 -134
- package/src/enr/generate-enr.ts +39 -6
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/index.ts +4 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +75 -7
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +264 -65
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +173 -34
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +156 -30
- package/src/mem_pools/attestation_pool/mocks.ts +11 -10
- package/src/mem_pools/instrumentation.ts +43 -44
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +549 -108
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +153 -44
- package/src/mem_pools/tx_pool/priority.ts +1 -1
- package/src/mem_pools/tx_pool/tx_pool.ts +67 -8
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +217 -34
- package/src/msg_validators/attestation_validator/attestation_validator.ts +54 -11
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +91 -0
- package/src/msg_validators/attestation_validator/index.ts +1 -0
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +82 -14
- package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +35 -0
- package/src/msg_validators/tx_validator/archive_cache.ts +28 -0
- package/src/msg_validators/tx_validator/block_header_validator.ts +4 -4
- package/src/msg_validators/tx_validator/data_validator.ts +81 -69
- package/src/msg_validators/tx_validator/double_spend_validator.ts +19 -17
- package/src/msg_validators/tx_validator/factory.ts +109 -0
- package/src/msg_validators/tx_validator/gas_validator.ts +134 -0
- package/src/msg_validators/tx_validator/index.ts +7 -0
- package/src/msg_validators/tx_validator/metadata_validator.ts +58 -21
- package/src/msg_validators/tx_validator/phases_validator.ts +116 -0
- package/src/msg_validators/tx_validator/test_utils.ts +43 -0
- package/src/msg_validators/tx_validator/timestamp_validator.ts +46 -0
- package/src/msg_validators/tx_validator/tx_permitted_validator.ts +17 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +6 -5
- package/src/services/discv5/discV5_service.ts +84 -38
- package/src/services/dummy_service.ts +147 -9
- package/src/services/encoding.ts +80 -5
- package/src/services/index.ts +4 -0
- package/src/services/libp2p/instrumentation.ts +167 -0
- package/src/services/libp2p/libp2p_service.ts +866 -294
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +26 -1
- package/src/services/peer-manager/peer_manager.ts +654 -78
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/config.ts +26 -9
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +12 -6
- package/src/services/reqresp/connection-sampler/connection_sampler.ts +148 -95
- package/src/services/reqresp/index.ts +2 -0
- package/src/services/reqresp/interface.ts +91 -36
- package/src/services/reqresp/metrics.ts +4 -1
- package/src/services/reqresp/protocols/auth.ts +83 -0
- package/src/services/reqresp/protocols/block.ts +24 -3
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +90 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +53 -0
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +79 -0
- package/src/services/reqresp/protocols/block_txs/index.ts +3 -0
- package/src/services/reqresp/protocols/goodbye.ts +9 -7
- package/src/services/reqresp/protocols/index.ts +2 -0
- package/src/services/reqresp/protocols/status.ts +117 -5
- package/src/services/reqresp/protocols/tx.ts +35 -6
- package/src/services/reqresp/rate-limiter/rate_limiter.ts +12 -3
- package/src/services/reqresp/rate-limiter/rate_limits.ts +21 -1
- package/src/services/reqresp/reqresp.ts +387 -256
- package/src/services/reqresp/status.ts +12 -3
- package/src/services/service.ts +45 -21
- package/src/services/tx_collection/config.ts +84 -0
- package/src/services/tx_collection/fast_tx_collection.ts +340 -0
- package/src/services/tx_collection/index.ts +2 -0
- package/src/services/tx_collection/instrumentation.ts +43 -0
- package/src/services/tx_collection/slow_tx_collection.ts +233 -0
- package/src/services/tx_collection/tx_collection.ts +215 -0
- package/src/services/tx_collection/tx_collection_sink.ts +129 -0
- package/src/services/tx_collection/tx_source.ts +37 -0
- package/src/services/tx_provider.ts +216 -0
- package/src/services/tx_provider_instrumentation.ts +44 -0
- package/src/test-helpers/index.ts +1 -0
- package/src/test-helpers/make-enrs.ts +4 -5
- package/src/test-helpers/make-test-p2p-clients.ts +111 -21
- package/src/test-helpers/mock-pubsub.ts +188 -0
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +86 -35
- package/src/testbench/p2p_client_testbench_worker.ts +151 -25
- package/src/testbench/parse_log_file.ts +4 -4
- package/src/testbench/testbench.ts +4 -4
- package/src/testbench/worker_client_manager.ts +17 -23
- package/src/types/index.ts +2 -0
- package/src/util.ts +105 -91
- package/src/versioning.ts +11 -4
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { BlockProposal as BlockProposalClass, ConsensusPayload, SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '@aztec/stdlib/p2p';
|
|
5
|
+
import { makeL2BlockHeader } from '@aztec/stdlib/testing';
|
|
3
6
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
7
|
import { jest } from '@jest/globals';
|
|
5
8
|
import { mock } from 'jest-mock-extended';
|
|
@@ -21,7 +24,18 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
21
24
|
});
|
|
22
25
|
const createAttestationsForSlot = (slotNumber)=>{
|
|
23
26
|
const archive = Fr.random();
|
|
24
|
-
return
|
|
27
|
+
return signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
28
|
+
};
|
|
29
|
+
const mockBlockProposal = (signer, slotNumber, archive = Fr.random())=>{
|
|
30
|
+
const header = makeL2BlockHeader(1, 2, slotNumber);
|
|
31
|
+
const payload = new ConsensusPayload(header.toCheckpointHeader(), archive);
|
|
32
|
+
const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
33
|
+
const signature = signer.sign(hash);
|
|
34
|
+
const txHashes = [
|
|
35
|
+
TxHash.random(),
|
|
36
|
+
TxHash.random()
|
|
37
|
+
]; // Mock tx hashes
|
|
38
|
+
return new BlockProposalClass(payload, signature, txHashes);
|
|
25
39
|
};
|
|
26
40
|
// We compare buffers as the objects can have cached values attached to them which are not serialised
|
|
27
41
|
// using array containing as the kv store does not respect insertion order
|
|
@@ -34,62 +48,86 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
34
48
|
it('should add attestations to pool', async ()=>{
|
|
35
49
|
const slotNumber = 420;
|
|
36
50
|
const archive = Fr.random();
|
|
37
|
-
const attestations =
|
|
51
|
+
const attestations = signers.slice(0, -1).map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
38
52
|
await ap.addAttestations(attestations);
|
|
39
|
-
|
|
40
|
-
expect(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString());
|
|
54
|
+
expect(retrievedAttestations.length).toBe(attestations.length);
|
|
55
|
+
compareAttestations(retrievedAttestations, attestations);
|
|
56
|
+
// Check hasAttestation for added attestations
|
|
57
|
+
for (const attestation of attestations){
|
|
58
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
59
|
+
}
|
|
60
|
+
const retrievedAttestationsForSlot = await ap.getAttestationsForSlot(SlotNumber(slotNumber));
|
|
61
|
+
expect(retrievedAttestationsForSlot.length).toBe(attestations.length);
|
|
62
|
+
compareAttestations(retrievedAttestationsForSlot, attestations);
|
|
63
|
+
// Add another one
|
|
64
|
+
const newAttestation = mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
|
|
65
|
+
await ap.addAttestations([
|
|
66
|
+
newAttestation
|
|
67
|
+
]);
|
|
68
|
+
const retrievedAttestationsAfterAdd = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString());
|
|
69
|
+
expect(retrievedAttestationsAfterAdd.length).toBe(attestations.length + 1);
|
|
70
|
+
compareAttestations(retrievedAttestationsAfterAdd, [
|
|
71
|
+
...attestations,
|
|
72
|
+
newAttestation
|
|
73
|
+
]);
|
|
74
|
+
expect(await ap.hasAttestation(newAttestation)).toBe(true);
|
|
75
|
+
const retrievedAttestationsForSlotAfterAdd = await ap.getAttestationsForSlot(SlotNumber(slotNumber));
|
|
76
|
+
expect(retrievedAttestationsForSlotAfterAdd.length).toBe(attestations.length + 1);
|
|
77
|
+
compareAttestations(retrievedAttestationsForSlotAfterAdd, [
|
|
78
|
+
...attestations,
|
|
79
|
+
newAttestation
|
|
80
|
+
]);
|
|
44
81
|
// Delete by slot
|
|
45
|
-
await ap.deleteAttestationsForSlot(
|
|
46
|
-
|
|
47
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), archive.toString());
|
|
82
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
83
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString());
|
|
48
84
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
85
|
+
// Check hasAttestation after deletion
|
|
86
|
+
for (const attestation of attestations){
|
|
87
|
+
expect(await ap.hasAttestation(attestation)).toBe(false);
|
|
88
|
+
}
|
|
89
|
+
expect(await ap.hasAttestation(newAttestation)).toBe(false);
|
|
49
90
|
});
|
|
50
|
-
it('
|
|
91
|
+
it('should handle duplicate proposals in a slot', async ()=>{
|
|
51
92
|
const slotNumber = 420;
|
|
52
93
|
const archive = Fr.random();
|
|
53
|
-
const txs = [
|
|
54
|
-
0,
|
|
55
|
-
1,
|
|
56
|
-
2,
|
|
57
|
-
3,
|
|
58
|
-
4,
|
|
59
|
-
5
|
|
60
|
-
].map(()=>TxHash.random());
|
|
61
94
|
// Use the same signer for all attestations
|
|
62
95
|
const attestations = [];
|
|
63
96
|
const signer = signers[0];
|
|
64
97
|
for(let i = 0; i < NUMBER_OF_SIGNERS_PER_TEST; i++){
|
|
65
|
-
attestations.push(
|
|
98
|
+
attestations.push(mockAttestation(signer, slotNumber, archive));
|
|
66
99
|
}
|
|
100
|
+
// Add them to store and check we end up with only one
|
|
67
101
|
await ap.addAttestations(attestations);
|
|
68
|
-
const retreivedAttestations = await ap.
|
|
102
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString());
|
|
69
103
|
expect(retreivedAttestations.length).toBe(1);
|
|
70
104
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestations[0].toBuffer());
|
|
71
|
-
expect(retreivedAttestations[0].
|
|
72
|
-
|
|
105
|
+
expect(retreivedAttestations[0].getSender()?.toString()).toEqual(signer.address.toString());
|
|
106
|
+
// Try adding them on another operation and check they are still not duplicated
|
|
107
|
+
await ap.addAttestations([
|
|
108
|
+
attestations[0]
|
|
109
|
+
]);
|
|
110
|
+
expect(await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), archive.toString())).toHaveLength(1);
|
|
73
111
|
});
|
|
74
|
-
it('
|
|
112
|
+
it('should store attestations by differing slot', async ()=>{
|
|
75
113
|
const slotNumbers = [
|
|
76
114
|
1,
|
|
77
115
|
2,
|
|
78
116
|
3,
|
|
79
117
|
4
|
|
80
118
|
];
|
|
81
|
-
const attestations =
|
|
119
|
+
const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i]));
|
|
82
120
|
await ap.addAttestations(attestations);
|
|
83
121
|
for (const attestation of attestations){
|
|
84
|
-
const slot = attestation.payload.header.
|
|
122
|
+
const slot = attestation.payload.header.slotNumber;
|
|
85
123
|
const archive = attestation.archive.toString();
|
|
86
|
-
const retreivedAttestations = await ap.
|
|
124
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot, archive);
|
|
87
125
|
expect(retreivedAttestations.length).toBe(1);
|
|
88
126
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
89
|
-
expect(retreivedAttestations[0].payload.header.
|
|
127
|
+
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
90
128
|
}
|
|
91
129
|
});
|
|
92
|
-
it('
|
|
130
|
+
it('should store attestations by differing slot and archive', async ()=>{
|
|
93
131
|
const slotNumbers = [
|
|
94
132
|
1,
|
|
95
133
|
1,
|
|
@@ -102,70 +140,73 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
102
140
|
Fr.random(),
|
|
103
141
|
Fr.random()
|
|
104
142
|
];
|
|
105
|
-
const attestations =
|
|
143
|
+
const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i], archives[i]));
|
|
106
144
|
await ap.addAttestations(attestations);
|
|
107
145
|
for (const attestation of attestations){
|
|
108
|
-
const slot = attestation.payload.header.
|
|
146
|
+
const slot = attestation.payload.header.slotNumber;
|
|
109
147
|
const proposalId = attestation.archive.toString();
|
|
110
|
-
const retreivedAttestations = await ap.
|
|
148
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot, proposalId);
|
|
111
149
|
expect(retreivedAttestations.length).toBe(1);
|
|
112
150
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
113
|
-
expect(retreivedAttestations[0].payload.header.
|
|
151
|
+
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
114
152
|
}
|
|
115
153
|
});
|
|
116
|
-
it('
|
|
154
|
+
it('should delete attestations', async ()=>{
|
|
117
155
|
const slotNumber = 420;
|
|
118
156
|
const archive = Fr.random();
|
|
119
|
-
const attestations =
|
|
157
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
120
158
|
const proposalId = attestations[0].archive.toString();
|
|
121
159
|
await ap.addAttestations(attestations);
|
|
122
|
-
|
|
123
|
-
const retreivedAttestations = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
160
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
124
161
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
125
162
|
compareAttestations(retreivedAttestations, attestations);
|
|
163
|
+
// Check hasAttestation before deletion
|
|
164
|
+
for (const attestation of attestations){
|
|
165
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
166
|
+
}
|
|
126
167
|
await ap.deleteAttestations(attestations);
|
|
127
|
-
|
|
128
|
-
const gottenAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
168
|
+
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
129
169
|
expect(gottenAfterDelete.length).toBe(0);
|
|
170
|
+
// Check hasAttestation after deletion
|
|
171
|
+
for (const attestation of attestations){
|
|
172
|
+
expect(await ap.hasAttestation(attestation)).toBe(false);
|
|
173
|
+
}
|
|
130
174
|
});
|
|
131
|
-
it('
|
|
175
|
+
it('should blanket delete attestations per slot', async ()=>{
|
|
132
176
|
const slotNumber = 420;
|
|
133
177
|
const archive = Fr.random();
|
|
134
|
-
const attestations =
|
|
178
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
135
179
|
const proposalId = attestations[0].archive.toString();
|
|
136
180
|
await ap.addAttestations(attestations);
|
|
137
|
-
const retreivedAttestations = await ap.
|
|
181
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
138
182
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
139
183
|
compareAttestations(retreivedAttestations, attestations);
|
|
140
|
-
await ap.deleteAttestationsForSlot(
|
|
141
|
-
const retreivedAttestationsAfterDelete = await ap.
|
|
184
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
185
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
142
186
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
143
187
|
});
|
|
144
|
-
it('
|
|
188
|
+
it('should blanket delete attestations per slot and proposal', async ()=>{
|
|
145
189
|
const slotNumber = 420;
|
|
146
190
|
const archive = Fr.random();
|
|
147
|
-
const attestations =
|
|
191
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
148
192
|
const proposalId = attestations[0].archive.toString();
|
|
149
193
|
// Add another set of attestations with a different proposalId, yet the same slot
|
|
150
194
|
const archive2 = Fr.random();
|
|
151
|
-
const attestations2 =
|
|
195
|
+
const attestations2 = signers.map((signer)=>mockAttestation(signer, slotNumber, archive2));
|
|
152
196
|
const proposalId2 = attestations2[0].archive.toString();
|
|
153
197
|
await ap.addAttestations(attestations);
|
|
154
198
|
await ap.addAttestations(attestations2);
|
|
155
|
-
|
|
156
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations2.length);
|
|
157
|
-
const retreivedAttestations = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
199
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
158
200
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
159
201
|
compareAttestations(retreivedAttestations, attestations);
|
|
160
|
-
await ap.deleteAttestationsForSlotAndProposal(
|
|
161
|
-
|
|
162
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
202
|
+
await ap.deleteAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
203
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
163
204
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
164
|
-
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.
|
|
205
|
+
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId2);
|
|
165
206
|
expect(retreivedAttestationsAfterDeleteForOtherProposal.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
166
207
|
compareAttestations(retreivedAttestationsAfterDeleteForOtherProposal, attestations2);
|
|
167
208
|
});
|
|
168
|
-
it('
|
|
209
|
+
it('should delete attestations older than a given slot', async ()=>{
|
|
169
210
|
const slotNumbers = [
|
|
170
211
|
1,
|
|
171
212
|
2,
|
|
@@ -179,17 +220,127 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
179
220
|
const attestations = (await Promise.all(slotNumbers.map((slotNumber)=>createAttestationsForSlot(slotNumber)))).flat();
|
|
180
221
|
const proposalId = attestations[0].archive.toString();
|
|
181
222
|
await ap.addAttestations(attestations);
|
|
182
|
-
const attestationsForSlot1 = await ap.
|
|
223
|
+
const attestationsForSlot1 = await ap.getAttestationsForSlotAndProposal(SlotNumber(1), proposalId);
|
|
183
224
|
expect(attestationsForSlot1.length).toBe(signers.length);
|
|
184
225
|
const deleteAttestationsSpy = jest.spyOn(ap, 'deleteAttestationsForSlot');
|
|
185
|
-
await ap.deleteAttestationsOlderThan(
|
|
186
|
-
const attestationsForSlot1AfterDelete = await ap.
|
|
226
|
+
await ap.deleteAttestationsOlderThan(SlotNumber(73));
|
|
227
|
+
const attestationsForSlot1AfterDelete = await ap.getAttestationsForSlotAndProposal(SlotNumber(1), proposalId);
|
|
187
228
|
expect(attestationsForSlot1AfterDelete.length).toBe(0);
|
|
188
229
|
expect(deleteAttestationsSpy).toHaveBeenCalledTimes(5);
|
|
189
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
190
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
191
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
192
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
193
|
-
expect(deleteAttestationsSpy).toHaveBeenCalledWith(
|
|
230
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(1));
|
|
231
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(2));
|
|
232
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(3));
|
|
233
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(69));
|
|
234
|
+
expect(deleteAttestationsSpy).toHaveBeenCalledWith(SlotNumber(72));
|
|
235
|
+
});
|
|
236
|
+
describe('BlockProposal in attestation pool', ()=>{
|
|
237
|
+
it('should add and retrieve block proposal', async ()=>{
|
|
238
|
+
const slotNumber = 420;
|
|
239
|
+
const archive = Fr.random();
|
|
240
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
241
|
+
const proposalId = proposal.archive.toString();
|
|
242
|
+
await ap.addBlockProposal(proposal);
|
|
243
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
244
|
+
expect(retrievedProposal).toBeDefined();
|
|
245
|
+
expect(retrievedProposal).toEqual(proposal);
|
|
246
|
+
// Check hasBlockProposal with both id and object
|
|
247
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
248
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(true);
|
|
249
|
+
});
|
|
250
|
+
it('should return undefined for non-existent block proposal', async ()=>{
|
|
251
|
+
const nonExistentId = Fr.random().toString();
|
|
252
|
+
const retrievedProposal = await ap.getBlockProposal(nonExistentId);
|
|
253
|
+
expect(retrievedProposal).toBeUndefined();
|
|
254
|
+
// Check hasBlockProposal returns false for non-existent proposal
|
|
255
|
+
expect(await ap.hasBlockProposal(nonExistentId)).toBe(false);
|
|
256
|
+
});
|
|
257
|
+
it('should update block proposal if added twice with same id', async ()=>{
|
|
258
|
+
const slotNumber = 420;
|
|
259
|
+
const archive = Fr.random();
|
|
260
|
+
const proposal1 = mockBlockProposal(signers[0], slotNumber, archive);
|
|
261
|
+
const proposalId = proposal1.archive.toString();
|
|
262
|
+
await ap.addBlockProposal(proposal1);
|
|
263
|
+
// Create a new proposal with same archive but different signer
|
|
264
|
+
const proposal2 = mockBlockProposal(signers[1], slotNumber, archive);
|
|
265
|
+
await ap.addBlockProposal(proposal2);
|
|
266
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
267
|
+
expect(retrievedProposal).toBeDefined();
|
|
268
|
+
// Should have the second proposal
|
|
269
|
+
expect(retrievedProposal.toBuffer()).toEqual(proposal2.toBuffer());
|
|
270
|
+
expect(retrievedProposal.getSender()?.toString()).toBe(signers[1].address.toString());
|
|
271
|
+
});
|
|
272
|
+
it('should handle block proposals with different slots and same archive', async ()=>{
|
|
273
|
+
const archive = Fr.random();
|
|
274
|
+
const proposal1 = mockBlockProposal(signers[0], 100, archive);
|
|
275
|
+
const proposal2 = mockBlockProposal(signers[1], 200, archive);
|
|
276
|
+
const proposalId = archive.toString();
|
|
277
|
+
await ap.addBlockProposal(proposal1);
|
|
278
|
+
await ap.addBlockProposal(proposal2);
|
|
279
|
+
// Should get the latest one added
|
|
280
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
281
|
+
expect(retrievedProposal).toBeDefined();
|
|
282
|
+
expect(retrievedProposal.toBuffer()).toEqual(proposal2.toBuffer());
|
|
283
|
+
expect(retrievedProposal.slotNumber).toBe(SlotNumber(200));
|
|
284
|
+
});
|
|
285
|
+
it('should delete block proposal when deleting attestations for slot and proposal', async ()=>{
|
|
286
|
+
const slotNumber = 420;
|
|
287
|
+
const archive = Fr.random();
|
|
288
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
289
|
+
const proposalId = proposal.archive.toString();
|
|
290
|
+
// Add proposal and some attestations
|
|
291
|
+
await ap.addBlockProposal(proposal);
|
|
292
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
293
|
+
await ap.addAttestations(attestations);
|
|
294
|
+
// Verify proposal exists
|
|
295
|
+
let retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
296
|
+
expect(retrievedProposal).toBeDefined();
|
|
297
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
298
|
+
// Delete attestations for slot and proposal
|
|
299
|
+
await ap.deleteAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
300
|
+
// Proposal should be deleted
|
|
301
|
+
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
302
|
+
expect(retrievedProposal).toBeUndefined();
|
|
303
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(false);
|
|
304
|
+
});
|
|
305
|
+
it('should delete block proposal when deleting attestations for slot', async ()=>{
|
|
306
|
+
const slotNumber = 420;
|
|
307
|
+
const archive = Fr.random();
|
|
308
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
309
|
+
const proposalId = proposal.archive.toString();
|
|
310
|
+
// Add proposal
|
|
311
|
+
await ap.addBlockProposal(proposal);
|
|
312
|
+
// Verify proposal exists
|
|
313
|
+
let retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
314
|
+
expect(retrievedProposal).toBeDefined();
|
|
315
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(true);
|
|
316
|
+
// Delete attestations for slot
|
|
317
|
+
await ap.deleteAttestationsForSlot(SlotNumber(slotNumber));
|
|
318
|
+
// Proposal should be deleted
|
|
319
|
+
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
320
|
+
expect(retrievedProposal).toBeUndefined();
|
|
321
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(false);
|
|
322
|
+
});
|
|
323
|
+
it('should be able to fetch both block proposal and attestations', async ()=>{
|
|
324
|
+
const slotNumber = 420;
|
|
325
|
+
const archive = Fr.random();
|
|
326
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
327
|
+
const proposalId = proposal.archive.toString();
|
|
328
|
+
// Add proposal first
|
|
329
|
+
await ap.addBlockProposal(proposal);
|
|
330
|
+
// Add attestations for the same proposal
|
|
331
|
+
const attestations = signers.slice(1).map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
332
|
+
await ap.addAttestations(attestations);
|
|
333
|
+
// Retrieve both proposal and attestations
|
|
334
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
335
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(SlotNumber(slotNumber), proposalId);
|
|
336
|
+
expect(retrievedProposal).toBeDefined();
|
|
337
|
+
expect(retrievedProposal).toEqual(proposal);
|
|
338
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
339
|
+
compareAttestations(retrievedAttestations, attestations);
|
|
340
|
+
// Check hasAttestation for all attestations
|
|
341
|
+
for (const attestation of attestations){
|
|
342
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
194
345
|
});
|
|
195
346
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './attestation_pool.js';
|
|
2
2
|
export * from './memory_attestation_pool.js';
|
|
3
|
-
//# sourceMappingURL=
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvYXR0ZXN0YXRpb25fcG9vbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsOEJBQThCLENBQUMifQ==
|
|
@@ -1,22 +1,37 @@
|
|
|
1
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
3
|
+
import { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
4
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
5
|
import type { AttestationPool } from './attestation_pool.js';
|
|
6
|
+
export declare const MAX_PROPOSALS_PER_SLOT = 5;
|
|
7
|
+
export declare const ATTESTATION_CAP_BUFFER = 10;
|
|
5
8
|
export declare class KvAttestationPool implements AttestationPool {
|
|
6
9
|
private store;
|
|
7
10
|
private log;
|
|
8
11
|
private metrics;
|
|
9
12
|
private attestations;
|
|
13
|
+
private proposals;
|
|
10
14
|
private proposalsForSlot;
|
|
11
15
|
private attestationsForProposal;
|
|
12
16
|
constructor(store: AztecAsyncKVStore, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
17
|
+
private poolStats;
|
|
18
|
+
isEmpty(): Promise<boolean>;
|
|
13
19
|
private getProposalKey;
|
|
14
20
|
private getAttestationKey;
|
|
15
21
|
addAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
16
|
-
getAttestationsForSlot(slot:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]>;
|
|
23
|
+
getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]>;
|
|
24
|
+
deleteAttestationsOlderThan(oldestSlot: SlotNumber): Promise<void>;
|
|
25
|
+
deleteAttestationsForSlot(slot: SlotNumber): Promise<void>;
|
|
26
|
+
deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void>;
|
|
20
27
|
deleteAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
28
|
+
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
29
|
+
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
30
|
+
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
31
|
+
addBlockProposal(blockProposal: BlockProposal): Promise<void>;
|
|
32
|
+
hasReachedProposalCap(slot: SlotNumber): Promise<boolean>;
|
|
33
|
+
hasReachedAttestationCap(slot: SlotNumber, proposalId: string, committeeSize: number): Promise<boolean>;
|
|
34
|
+
canAddProposal(block: BlockProposal): Promise<boolean>;
|
|
35
|
+
canAddAttestation(attestation: BlockAttestation, committeeSize: number): Promise<boolean>;
|
|
21
36
|
}
|
|
22
|
-
//# sourceMappingURL=
|
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BQUcsYUFBYSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FHcEY7SUFFWSxnQkFBZ0IsQ0FBQyxhQUFhLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FlekU7SUFFWSxxQkFBcUIsQ0FBQyxJQUFJLEVBQUUsVUFBVSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FHckU7SUFFWSx3QkFBd0IsQ0FBQyxJQUFJLEVBQUUsVUFBVSxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsYUFBYSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBR25IO0lBRVksY0FBYyxDQUFDLEtBQUssRUFBRSxhQUFhLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUlsRTtJQUVZLGlCQUFpQixDQUFDLFdBQVcsRUFBRSxnQkFBZ0IsRUFBRSxhQUFhLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FTckc7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,eAAO,MAAM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