@aztec/p2p 0.0.0-test.0 → 0.0.1-commit.24de95ac
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.map +1 -1
- package/dest/bootstrap/bootstrap.js +22 -9
- package/dest/client/factory.d.ts +13 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +60 -24
- package/dest/client/index.d.ts +1 -0
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +1 -0
- package/dest/client/interface.d.ts +155 -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 -169
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +365 -174
- package/dest/config.d.ts +123 -103
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +173 -34
- package/dest/enr/generate-enr.d.ts +10 -2
- package/dest/enr/generate-enr.d.ts.map +1 -1
- package/dest/enr/generate-enr.js +27 -5
- package/dest/index.d.ts +3 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +42 -4
- 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.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +204 -54
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +10 -2
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +93 -15
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +10 -2
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +86 -18
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -2
- 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/instrumentation.d.ts +7 -11
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +25 -37
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +93 -9
- 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/memory_tx_pool.d.ts +33 -9
- 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.js +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +64 -8
- 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.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 +1 -0
- 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/block_proposal_validator/block_proposal_validator.d.ts +5 -1
- 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 +61 -12
- 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/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.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.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 +0 -2
- 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 +7 -0
- 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 +7 -3
- 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 +91 -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.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +6 -5
- package/dest/services/discv5/discV5_service.d.ts +9 -8
- 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 +49 -10
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +88 -5
- package/dest/services/encoding.d.ts +25 -6
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +73 -5
- package/dest/services/index.d.ts +4 -0
- package/dest/services/index.d.ts.map +1 -1
- package/dest/services/index.js +4 -0
- package/dest/services/libp2p/instrumentation.d.ts +18 -0
- package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
- package/dest/services/libp2p/instrumentation.js +157 -0
- package/dest/services/libp2p/libp2p_service.d.ts +87 -42
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +500 -218
- 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 +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -2
- package/dest/services/peer-manager/peer_manager.d.ts +126 -15
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +547 -72
- package/dest/services/reqresp/config.d.ts +10 -8
- 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 +1 -1
- 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 +30 -13
- 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 +2 -1
- 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 +72 -23
- 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.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 +5 -0
- 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 +49 -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 +2 -4
- 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 +2 -0
- 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 +0 -2
- package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/status.d.ts +38 -6
- 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 +12 -1
- 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/rate_limiter.d.ts +4 -2
- 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.map +1 -1
- package/dest/services/reqresp/rate-limiter/rate_limits.js +21 -1
- package/dest/services/reqresp/reqresp.d.ts +45 -47
- 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 +9 -3
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/reqresp/status.js +9 -2
- package/dest/services/service.d.ts +22 -18
- 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 +56 -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 +54 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/slow_tx_collection.js +176 -0
- package/dest/services/tx_collection/tx_collection.d.ts +110 -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/get-ports.d.ts.map +1 -1
- package/dest/test-helpers/index.d.ts +1 -0
- 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.map +1 -1
- package/dest/test-helpers/make-enrs.js +4 -5
- package/dest/test-helpers/make-test-p2p-clients.d.ts +32 -4
- 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 +14 -10
- 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.js +96 -25
- package/dest/testbench/parse_log_file.js +4 -4
- package/dest/testbench/testbench.js +4 -4
- package/dest/testbench/worker_client_manager.d.ts +0 -5
- 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 +3 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +2 -0
- package/dest/util.d.ts +22 -15
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +64 -67
- package/dest/versioning.d.ts +3 -3
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +8 -3
- package/package.json +28 -24
- 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 +195 -0
- package/src/client/p2p_client.ts +460 -327
- package/src/config.ts +288 -134
- package/src/enr/generate-enr.ts +39 -6
- package/src/index.ts +4 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +48 -4
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +241 -55
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +117 -20
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +114 -22
- package/src/mem_pools/attestation_pool/mocks.ts +11 -10
- package/src/mem_pools/instrumentation.ts +32 -46
- 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 +55 -10
- package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +66 -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 +114 -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 +158 -0
- package/src/services/libp2p/libp2p_service.ts +646 -263
- package/src/services/peer-manager/interface.ts +29 -0
- package/src/services/peer-manager/metrics.ts +16 -1
- package/src/services/peer-manager/peer_manager.ts +652 -78
- 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 +232 -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 +145 -22
- 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 +93 -89
- package/src/versioning.ts +11 -4
package/dest/enr/generate-enr.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { emptyChainConfig } from '@aztec/stdlib/config';
|
|
2
|
-
import { ENR, SignableENR } from '@chainsafe/enr';
|
|
3
2
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
4
|
-
import {
|
|
3
|
+
import { ENR, SignableENR } from '@nethermindeth/enr';
|
|
4
|
+
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from '../types/index.js';
|
|
5
5
|
import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
|
|
6
|
-
import { setAztecEnrKey } from '../versioning.js';
|
|
7
|
-
export
|
|
6
|
+
import { setAztecClientVersionEnrKey, setAztecEnrKey } from '../versioning.js';
|
|
7
|
+
export { ENR };
|
|
8
|
+
export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcastPort, l1ChainId) {
|
|
8
9
|
const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
|
|
9
10
|
const enr = SignableENR.createFromPeerId(peerId);
|
|
10
|
-
const publicAddr = multiaddr(convertToMultiaddr(
|
|
11
|
+
const publicAddr = multiaddr(convertToMultiaddr(p2pIp, p2pBroadcastPort, 'udp'));
|
|
11
12
|
enr.setLocationMultiaddr(publicAddr);
|
|
12
13
|
const config = {
|
|
13
14
|
...emptyChainConfig,
|
|
@@ -19,6 +20,25 @@ export async function createBootnodeENRandPeerId(privateKey, udpAnnounceAddress,
|
|
|
19
20
|
peerId
|
|
20
21
|
};
|
|
21
22
|
}
|
|
23
|
+
export function createNodeENR(peerId, multiAddrUdp, multiAddrTcp, chainConfig, packageVersion) {
|
|
24
|
+
// create ENR from PeerId
|
|
25
|
+
const enr = SignableENR.createFromPeerId(peerId);
|
|
26
|
+
// Add aztec identification to ENR
|
|
27
|
+
const versions = setAztecEnrKey(enr, chainConfig);
|
|
28
|
+
// Add aztec client version to ENR
|
|
29
|
+
setAztecClientVersionEnrKey(enr, packageVersion);
|
|
30
|
+
// set location multiaddr in ENR record
|
|
31
|
+
if (multiAddrUdp) {
|
|
32
|
+
enr.setLocationMultiaddr(multiAddrUdp);
|
|
33
|
+
}
|
|
34
|
+
if (multiAddrTcp) {
|
|
35
|
+
enr.setLocationMultiaddr(multiAddrTcp);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
enr,
|
|
39
|
+
versions
|
|
40
|
+
};
|
|
41
|
+
}
|
|
22
42
|
export async function printENR(enr, log) {
|
|
23
43
|
const decoded = ENR.decodeTxt(enr);
|
|
24
44
|
log(`PeerID: ${await decoded.peerId()}`);
|
|
@@ -27,4 +47,6 @@ export async function printENR(enr, log) {
|
|
|
27
47
|
log(`TCP: ${decoded.tcp}`);
|
|
28
48
|
const aztec = decoded.kvs.get(AZTEC_ENR_KEY);
|
|
29
49
|
log(`Aztec version: ${aztec?.toString()}`);
|
|
50
|
+
const aztecClientVersion = decoded.kvs.get(AZTEC_ENR_CLIENT_VERSION_KEY);
|
|
51
|
+
log(`Aztec client version ${aztecClientVersion ? aztecClientVersion.toString() : 'N/A'}`);
|
|
30
52
|
}
|
package/dest/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export { createSecp256k1PeerId } from '@libp2p/peer-id-factory';
|
|
2
|
+
export type { PeerId } from '@libp2p/interface';
|
|
1
3
|
export * from './bootstrap/bootstrap.js';
|
|
2
4
|
export * from './client/index.js';
|
|
5
|
+
export * from './enr/index.js';
|
|
3
6
|
export * from './config.js';
|
|
4
7
|
export * from './mem_pools/attestation_pool/index.js';
|
|
5
8
|
export * from './mem_pools/tx_pool/index.js';
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export { createSecp256k1PeerId } from '@libp2p/peer-id-factory';
|
|
1
2
|
export * from './bootstrap/bootstrap.js';
|
|
2
3
|
export * from './client/index.js';
|
|
4
|
+
export * from './enr/index.js';
|
|
3
5
|
export * from './config.js';
|
|
4
6
|
export * from './mem_pools/attestation_pool/index.js';
|
|
5
7
|
export * from './mem_pools/tx_pool/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
1
|
+
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
2
|
/**
|
|
3
3
|
* An Attestation Pool contains attestations collected by a validator
|
|
4
4
|
*
|
|
@@ -7,7 +7,27 @@ import type { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
|
7
7
|
*/
|
|
8
8
|
export interface AttestationPool {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Adds new block proposal to the pool
|
|
11
|
+
*/
|
|
12
|
+
addBlockProposal(blockProposal: BlockProposal): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Get block proposal by it's ID
|
|
15
|
+
*
|
|
16
|
+
* @param id - The ID of the block proposal to retrieve. The ID is proposal.payload.archive
|
|
17
|
+
*
|
|
18
|
+
* @return The block proposal if it exists, otherwise undefined.
|
|
19
|
+
*/
|
|
20
|
+
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a block proposal exists in the pool
|
|
23
|
+
*
|
|
24
|
+
* @param idOrProposal - The ID of the block proposal or the block proposal itself to check. The ID is proposal.payload.archive
|
|
25
|
+
*
|
|
26
|
+
* @return True if the block proposal exists, false otherwise.
|
|
27
|
+
*/
|
|
28
|
+
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* AddAttestations
|
|
11
31
|
*
|
|
12
32
|
* @param attestations - Attestations to add into the pool
|
|
13
33
|
*/
|
|
@@ -44,7 +64,16 @@ export interface AttestationPool {
|
|
|
44
64
|
*/
|
|
45
65
|
deleteAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<void>;
|
|
46
66
|
/**
|
|
47
|
-
* Get Attestations for slot
|
|
67
|
+
* Get all Attestations for all proposals for a given slot
|
|
68
|
+
*
|
|
69
|
+
* Retrieve all of the attestations observed pertaining to a given slot
|
|
70
|
+
*
|
|
71
|
+
* @param slot - The slot to query
|
|
72
|
+
* @return BlockAttestations
|
|
73
|
+
*/
|
|
74
|
+
getAttestationsForSlot(slot: bigint): Promise<BlockAttestation[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Get Attestations for slot and given proposal
|
|
48
77
|
*
|
|
49
78
|
* Retrieve all of the attestations observed pertaining to a given slot
|
|
50
79
|
*
|
|
@@ -52,6 +81,15 @@ export interface AttestationPool {
|
|
|
52
81
|
* @param proposalId - The proposal to query
|
|
53
82
|
* @return BlockAttestations
|
|
54
83
|
*/
|
|
55
|
-
|
|
84
|
+
getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a specific attestation exists in the pool
|
|
87
|
+
*
|
|
88
|
+
* @param attestation - The attestation to check
|
|
89
|
+
* @return True if the attestation exists, false otherwise
|
|
90
|
+
*/
|
|
91
|
+
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
92
|
+
/** Returns whether the pool is empty. */
|
|
93
|
+
isEmpty(): Promise<boolean>;
|
|
56
94
|
}
|
|
57
95
|
//# sourceMappingURL=attestation_pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEjE;;;;;;OAMG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzE;;;;OAIG;IACH,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;;;OAIG;IACH,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;;;;OAMG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD;;;;;;;OAOG;IACH,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtF;;;;;;;OAOG;IACH,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAElE;;;;;;;;OAQG;IACH,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEjG;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhE,yCAAyC;IACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attestation_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool_test_suite.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAK7D,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,eAAe,QA0YhF"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { BlockProposal as BlockProposalClass, ConsensusPayload, SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { makeL2BlockHeader } from '@aztec/stdlib/testing';
|
|
3
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
6
|
import { jest } from '@jest/globals';
|
|
5
7
|
import { mock } from 'jest-mock-extended';
|
|
@@ -21,7 +23,18 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
21
23
|
});
|
|
22
24
|
const createAttestationsForSlot = (slotNumber)=>{
|
|
23
25
|
const archive = Fr.random();
|
|
24
|
-
return
|
|
26
|
+
return signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
27
|
+
};
|
|
28
|
+
const mockBlockProposal = (signer, slotNumber, archive = Fr.random())=>{
|
|
29
|
+
const header = makeL2BlockHeader(1, 2, slotNumber);
|
|
30
|
+
const payload = new ConsensusPayload(header.toCheckpointHeader(), archive, header.state);
|
|
31
|
+
const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
32
|
+
const signature = signer.sign(hash);
|
|
33
|
+
const txHashes = [
|
|
34
|
+
TxHash.random(),
|
|
35
|
+
TxHash.random()
|
|
36
|
+
]; // Mock tx hashes
|
|
37
|
+
return new BlockProposalClass(payload, signature, txHashes);
|
|
25
38
|
};
|
|
26
39
|
// We compare buffers as the objects can have cached values attached to them which are not serialised
|
|
27
40
|
// using array containing as the kv store does not respect insertion order
|
|
@@ -34,62 +47,86 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
34
47
|
it('should add attestations to pool', async ()=>{
|
|
35
48
|
const slotNumber = 420;
|
|
36
49
|
const archive = Fr.random();
|
|
37
|
-
const attestations =
|
|
50
|
+
const attestations = signers.slice(0, -1).map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
38
51
|
await ap.addAttestations(attestations);
|
|
39
|
-
|
|
40
|
-
expect(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
53
|
+
expect(retrievedAttestations.length).toBe(attestations.length);
|
|
54
|
+
compareAttestations(retrievedAttestations, attestations);
|
|
55
|
+
// Check hasAttestation for added attestations
|
|
56
|
+
for (const attestation of attestations){
|
|
57
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
58
|
+
}
|
|
59
|
+
const retrievedAttestationsForSlot = await ap.getAttestationsForSlot(BigInt(slotNumber));
|
|
60
|
+
expect(retrievedAttestationsForSlot.length).toBe(attestations.length);
|
|
61
|
+
compareAttestations(retrievedAttestationsForSlot, attestations);
|
|
62
|
+
// Add another one
|
|
63
|
+
const newAttestation = mockAttestation(signers[NUMBER_OF_SIGNERS_PER_TEST - 1], slotNumber, archive);
|
|
64
|
+
await ap.addAttestations([
|
|
65
|
+
newAttestation
|
|
66
|
+
]);
|
|
67
|
+
const retrievedAttestationsAfterAdd = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
68
|
+
expect(retrievedAttestationsAfterAdd.length).toBe(attestations.length + 1);
|
|
69
|
+
compareAttestations(retrievedAttestationsAfterAdd, [
|
|
70
|
+
...attestations,
|
|
71
|
+
newAttestation
|
|
72
|
+
]);
|
|
73
|
+
expect(await ap.hasAttestation(newAttestation)).toBe(true);
|
|
74
|
+
const retrievedAttestationsForSlotAfterAdd = await ap.getAttestationsForSlot(BigInt(slotNumber));
|
|
75
|
+
expect(retrievedAttestationsForSlotAfterAdd.length).toBe(attestations.length + 1);
|
|
76
|
+
compareAttestations(retrievedAttestationsForSlotAfterAdd, [
|
|
77
|
+
...attestations,
|
|
78
|
+
newAttestation
|
|
79
|
+
]);
|
|
44
80
|
// Delete by slot
|
|
45
81
|
await ap.deleteAttestationsForSlot(BigInt(slotNumber));
|
|
46
|
-
|
|
47
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), archive.toString());
|
|
82
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
48
83
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
84
|
+
// Check hasAttestation after deletion
|
|
85
|
+
for (const attestation of attestations){
|
|
86
|
+
expect(await ap.hasAttestation(attestation)).toBe(false);
|
|
87
|
+
}
|
|
88
|
+
expect(await ap.hasAttestation(newAttestation)).toBe(false);
|
|
49
89
|
});
|
|
50
|
-
it('
|
|
90
|
+
it('should handle duplicate proposals in a slot', async ()=>{
|
|
51
91
|
const slotNumber = 420;
|
|
52
92
|
const archive = Fr.random();
|
|
53
|
-
const txs = [
|
|
54
|
-
0,
|
|
55
|
-
1,
|
|
56
|
-
2,
|
|
57
|
-
3,
|
|
58
|
-
4,
|
|
59
|
-
5
|
|
60
|
-
].map(()=>TxHash.random());
|
|
61
93
|
// Use the same signer for all attestations
|
|
62
94
|
const attestations = [];
|
|
63
95
|
const signer = signers[0];
|
|
64
96
|
for(let i = 0; i < NUMBER_OF_SIGNERS_PER_TEST; i++){
|
|
65
|
-
attestations.push(
|
|
97
|
+
attestations.push(mockAttestation(signer, slotNumber, archive));
|
|
66
98
|
}
|
|
99
|
+
// Add them to store and check we end up with only one
|
|
67
100
|
await ap.addAttestations(attestations);
|
|
68
|
-
const retreivedAttestations = await ap.
|
|
101
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString());
|
|
69
102
|
expect(retreivedAttestations.length).toBe(1);
|
|
70
103
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestations[0].toBuffer());
|
|
71
|
-
expect(retreivedAttestations[0].
|
|
72
|
-
|
|
104
|
+
expect(retreivedAttestations[0].getSender()?.toString()).toEqual(signer.address.toString());
|
|
105
|
+
// Try adding them on another operation and check they are still not duplicated
|
|
106
|
+
await ap.addAttestations([
|
|
107
|
+
attestations[0]
|
|
108
|
+
]);
|
|
109
|
+
expect(await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), archive.toString())).toHaveLength(1);
|
|
73
110
|
});
|
|
74
|
-
it('
|
|
111
|
+
it('should store attestations by differing slot', async ()=>{
|
|
75
112
|
const slotNumbers = [
|
|
76
113
|
1,
|
|
77
114
|
2,
|
|
78
115
|
3,
|
|
79
116
|
4
|
|
80
117
|
];
|
|
81
|
-
const attestations =
|
|
118
|
+
const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i]));
|
|
82
119
|
await ap.addAttestations(attestations);
|
|
83
120
|
for (const attestation of attestations){
|
|
84
|
-
const slot = attestation.payload.header.
|
|
121
|
+
const slot = attestation.payload.header.slotNumber;
|
|
85
122
|
const archive = attestation.archive.toString();
|
|
86
|
-
const retreivedAttestations = await ap.
|
|
123
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot.toBigInt(), archive);
|
|
87
124
|
expect(retreivedAttestations.length).toBe(1);
|
|
88
125
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
89
|
-
expect(retreivedAttestations[0].payload.header.
|
|
126
|
+
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
90
127
|
}
|
|
91
128
|
});
|
|
92
|
-
it('
|
|
129
|
+
it('should store attestations by differing slot and archive', async ()=>{
|
|
93
130
|
const slotNumbers = [
|
|
94
131
|
1,
|
|
95
132
|
1,
|
|
@@ -102,70 +139,73 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
102
139
|
Fr.random(),
|
|
103
140
|
Fr.random()
|
|
104
141
|
];
|
|
105
|
-
const attestations =
|
|
142
|
+
const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i], archives[i]));
|
|
106
143
|
await ap.addAttestations(attestations);
|
|
107
144
|
for (const attestation of attestations){
|
|
108
|
-
const slot = attestation.payload.header.
|
|
145
|
+
const slot = attestation.payload.header.slotNumber;
|
|
109
146
|
const proposalId = attestation.archive.toString();
|
|
110
|
-
const retreivedAttestations = await ap.
|
|
147
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot.toBigInt(), proposalId);
|
|
111
148
|
expect(retreivedAttestations.length).toBe(1);
|
|
112
149
|
expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
|
|
113
|
-
expect(retreivedAttestations[0].payload.header.
|
|
150
|
+
expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
|
|
114
151
|
}
|
|
115
152
|
});
|
|
116
|
-
it('
|
|
153
|
+
it('should delete attestations', async ()=>{
|
|
117
154
|
const slotNumber = 420;
|
|
118
155
|
const archive = Fr.random();
|
|
119
|
-
const attestations =
|
|
156
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
120
157
|
const proposalId = attestations[0].archive.toString();
|
|
121
158
|
await ap.addAttestations(attestations);
|
|
122
|
-
|
|
123
|
-
const retreivedAttestations = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
159
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
124
160
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
125
161
|
compareAttestations(retreivedAttestations, attestations);
|
|
162
|
+
// Check hasAttestation before deletion
|
|
163
|
+
for (const attestation of attestations){
|
|
164
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
165
|
+
}
|
|
126
166
|
await ap.deleteAttestations(attestations);
|
|
127
|
-
|
|
128
|
-
const gottenAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
167
|
+
const gottenAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
129
168
|
expect(gottenAfterDelete.length).toBe(0);
|
|
169
|
+
// Check hasAttestation after deletion
|
|
170
|
+
for (const attestation of attestations){
|
|
171
|
+
expect(await ap.hasAttestation(attestation)).toBe(false);
|
|
172
|
+
}
|
|
130
173
|
});
|
|
131
|
-
it('
|
|
174
|
+
it('should blanket delete attestations per slot', async ()=>{
|
|
132
175
|
const slotNumber = 420;
|
|
133
176
|
const archive = Fr.random();
|
|
134
|
-
const attestations =
|
|
177
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
135
178
|
const proposalId = attestations[0].archive.toString();
|
|
136
179
|
await ap.addAttestations(attestations);
|
|
137
|
-
const retreivedAttestations = await ap.
|
|
180
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
138
181
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
139
182
|
compareAttestations(retreivedAttestations, attestations);
|
|
140
183
|
await ap.deleteAttestationsForSlot(BigInt(slotNumber));
|
|
141
|
-
const retreivedAttestationsAfterDelete = await ap.
|
|
184
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
142
185
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
143
186
|
});
|
|
144
|
-
it('
|
|
187
|
+
it('should blanket delete attestations per slot and proposal', async ()=>{
|
|
145
188
|
const slotNumber = 420;
|
|
146
189
|
const archive = Fr.random();
|
|
147
|
-
const attestations =
|
|
190
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
148
191
|
const proposalId = attestations[0].archive.toString();
|
|
149
192
|
// Add another set of attestations with a different proposalId, yet the same slot
|
|
150
193
|
const archive2 = Fr.random();
|
|
151
|
-
const attestations2 =
|
|
194
|
+
const attestations2 = signers.map((signer)=>mockAttestation(signer, slotNumber, archive2));
|
|
152
195
|
const proposalId2 = attestations2[0].archive.toString();
|
|
153
196
|
await ap.addAttestations(attestations);
|
|
154
197
|
await ap.addAttestations(attestations2);
|
|
155
|
-
|
|
156
|
-
expect(metricsMock.recordAddedObjects).toHaveBeenCalledWith(attestations2.length);
|
|
157
|
-
const retreivedAttestations = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
198
|
+
const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
158
199
|
expect(retreivedAttestations.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
159
200
|
compareAttestations(retreivedAttestations, attestations);
|
|
160
201
|
await ap.deleteAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
161
|
-
|
|
162
|
-
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlot(BigInt(slotNumber), proposalId);
|
|
202
|
+
const retreivedAttestationsAfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
163
203
|
expect(retreivedAttestationsAfterDelete.length).toBe(0);
|
|
164
|
-
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.
|
|
204
|
+
const retreivedAttestationsAfterDeleteForOtherProposal = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId2);
|
|
165
205
|
expect(retreivedAttestationsAfterDeleteForOtherProposal.length).toBe(NUMBER_OF_SIGNERS_PER_TEST);
|
|
166
206
|
compareAttestations(retreivedAttestationsAfterDeleteForOtherProposal, attestations2);
|
|
167
207
|
});
|
|
168
|
-
it('
|
|
208
|
+
it('should delete attestations older than a given slot', async ()=>{
|
|
169
209
|
const slotNumbers = [
|
|
170
210
|
1,
|
|
171
211
|
2,
|
|
@@ -179,11 +219,11 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
179
219
|
const attestations = (await Promise.all(slotNumbers.map((slotNumber)=>createAttestationsForSlot(slotNumber)))).flat();
|
|
180
220
|
const proposalId = attestations[0].archive.toString();
|
|
181
221
|
await ap.addAttestations(attestations);
|
|
182
|
-
const attestationsForSlot1 = await ap.
|
|
222
|
+
const attestationsForSlot1 = await ap.getAttestationsForSlotAndProposal(BigInt(1), proposalId);
|
|
183
223
|
expect(attestationsForSlot1.length).toBe(signers.length);
|
|
184
224
|
const deleteAttestationsSpy = jest.spyOn(ap, 'deleteAttestationsForSlot');
|
|
185
225
|
await ap.deleteAttestationsOlderThan(BigInt(73));
|
|
186
|
-
const attestationsForSlot1AfterDelete = await ap.
|
|
226
|
+
const attestationsForSlot1AfterDelete = await ap.getAttestationsForSlotAndProposal(BigInt(1), proposalId);
|
|
187
227
|
expect(attestationsForSlot1AfterDelete.length).toBe(0);
|
|
188
228
|
expect(deleteAttestationsSpy).toHaveBeenCalledTimes(5);
|
|
189
229
|
expect(deleteAttestationsSpy).toHaveBeenCalledWith(BigInt(1));
|
|
@@ -192,4 +232,114 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
192
232
|
expect(deleteAttestationsSpy).toHaveBeenCalledWith(BigInt(69));
|
|
193
233
|
expect(deleteAttestationsSpy).toHaveBeenCalledWith(BigInt(72));
|
|
194
234
|
});
|
|
235
|
+
describe('BlockProposal in attestation pool', ()=>{
|
|
236
|
+
it('should add and retrieve block proposal', async ()=>{
|
|
237
|
+
const slotNumber = 420;
|
|
238
|
+
const archive = Fr.random();
|
|
239
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
240
|
+
const proposalId = proposal.archive.toString();
|
|
241
|
+
await ap.addBlockProposal(proposal);
|
|
242
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
243
|
+
expect(retrievedProposal).toBeDefined();
|
|
244
|
+
expect(retrievedProposal).toEqual(proposal);
|
|
245
|
+
// Check hasBlockProposal with both id and object
|
|
246
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
247
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(true);
|
|
248
|
+
});
|
|
249
|
+
it('should return undefined for non-existent block proposal', async ()=>{
|
|
250
|
+
const nonExistentId = Fr.random().toString();
|
|
251
|
+
const retrievedProposal = await ap.getBlockProposal(nonExistentId);
|
|
252
|
+
expect(retrievedProposal).toBeUndefined();
|
|
253
|
+
// Check hasBlockProposal returns false for non-existent proposal
|
|
254
|
+
expect(await ap.hasBlockProposal(nonExistentId)).toBe(false);
|
|
255
|
+
});
|
|
256
|
+
it('should update block proposal if added twice with same id', async ()=>{
|
|
257
|
+
const slotNumber = 420;
|
|
258
|
+
const archive = Fr.random();
|
|
259
|
+
const proposal1 = mockBlockProposal(signers[0], slotNumber, archive);
|
|
260
|
+
const proposalId = proposal1.archive.toString();
|
|
261
|
+
await ap.addBlockProposal(proposal1);
|
|
262
|
+
// Create a new proposal with same archive but different signer
|
|
263
|
+
const proposal2 = mockBlockProposal(signers[1], slotNumber, archive);
|
|
264
|
+
await ap.addBlockProposal(proposal2);
|
|
265
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
266
|
+
expect(retrievedProposal).toBeDefined();
|
|
267
|
+
// Should have the second proposal
|
|
268
|
+
expect(retrievedProposal.toBuffer()).toEqual(proposal2.toBuffer());
|
|
269
|
+
expect(retrievedProposal.getSender()?.toString()).toBe(signers[1].address.toString());
|
|
270
|
+
});
|
|
271
|
+
it('should handle block proposals with different slots and same archive', async ()=>{
|
|
272
|
+
const archive = Fr.random();
|
|
273
|
+
const proposal1 = mockBlockProposal(signers[0], 100, archive);
|
|
274
|
+
const proposal2 = mockBlockProposal(signers[1], 200, archive);
|
|
275
|
+
const proposalId = archive.toString();
|
|
276
|
+
await ap.addBlockProposal(proposal1);
|
|
277
|
+
await ap.addBlockProposal(proposal2);
|
|
278
|
+
// Should get the latest one added
|
|
279
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
280
|
+
expect(retrievedProposal).toBeDefined();
|
|
281
|
+
expect(retrievedProposal.toBuffer()).toEqual(proposal2.toBuffer());
|
|
282
|
+
expect(retrievedProposal.slotNumber.toBigInt()).toBe(BigInt(200));
|
|
283
|
+
});
|
|
284
|
+
it('should delete block proposal when deleting attestations for slot and proposal', async ()=>{
|
|
285
|
+
const slotNumber = 420;
|
|
286
|
+
const archive = Fr.random();
|
|
287
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
288
|
+
const proposalId = proposal.archive.toString();
|
|
289
|
+
// Add proposal and some attestations
|
|
290
|
+
await ap.addBlockProposal(proposal);
|
|
291
|
+
const attestations = signers.map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
292
|
+
await ap.addAttestations(attestations);
|
|
293
|
+
// Verify proposal exists
|
|
294
|
+
let retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
295
|
+
expect(retrievedProposal).toBeDefined();
|
|
296
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
297
|
+
// Delete attestations for slot and proposal
|
|
298
|
+
await ap.deleteAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
299
|
+
// Proposal should be deleted
|
|
300
|
+
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
301
|
+
expect(retrievedProposal).toBeUndefined();
|
|
302
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(false);
|
|
303
|
+
});
|
|
304
|
+
it('should delete block proposal when deleting attestations for slot', async ()=>{
|
|
305
|
+
const slotNumber = 420;
|
|
306
|
+
const archive = Fr.random();
|
|
307
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
308
|
+
const proposalId = proposal.archive.toString();
|
|
309
|
+
// Add proposal
|
|
310
|
+
await ap.addBlockProposal(proposal);
|
|
311
|
+
// Verify proposal exists
|
|
312
|
+
let retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
313
|
+
expect(retrievedProposal).toBeDefined();
|
|
314
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(true);
|
|
315
|
+
// Delete attestations for slot
|
|
316
|
+
await ap.deleteAttestationsForSlot(BigInt(slotNumber));
|
|
317
|
+
// Proposal should be deleted
|
|
318
|
+
retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
319
|
+
expect(retrievedProposal).toBeUndefined();
|
|
320
|
+
expect(await ap.hasBlockProposal(proposal)).toBe(false);
|
|
321
|
+
});
|
|
322
|
+
it('should be able to fetch both block proposal and attestations', async ()=>{
|
|
323
|
+
const slotNumber = 420;
|
|
324
|
+
const archive = Fr.random();
|
|
325
|
+
const proposal = mockBlockProposal(signers[0], slotNumber, archive);
|
|
326
|
+
const proposalId = proposal.archive.toString();
|
|
327
|
+
// Add proposal first
|
|
328
|
+
await ap.addBlockProposal(proposal);
|
|
329
|
+
// Add attestations for the same proposal
|
|
330
|
+
const attestations = signers.slice(1).map((signer)=>mockAttestation(signer, slotNumber, archive));
|
|
331
|
+
await ap.addAttestations(attestations);
|
|
332
|
+
// Retrieve both proposal and attestations
|
|
333
|
+
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
334
|
+
const retrievedAttestations = await ap.getAttestationsForSlotAndProposal(BigInt(slotNumber), proposalId);
|
|
335
|
+
expect(retrievedProposal).toBeDefined();
|
|
336
|
+
expect(retrievedProposal).toEqual(proposal);
|
|
337
|
+
expect(await ap.hasBlockProposal(proposalId)).toBe(true);
|
|
338
|
+
compareAttestations(retrievedAttestations, attestations);
|
|
339
|
+
// Check hasAttestation for all attestations
|
|
340
|
+
for (const attestation of attestations){
|
|
341
|
+
expect(await ap.hasAttestation(attestation)).toBe(true);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
195
345
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
|
-
import { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
2
|
+
import { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import type { AttestationPool } from './attestation_pool.js';
|
|
5
5
|
export declare class KvAttestationPool implements AttestationPool {
|
|
@@ -7,16 +7,24 @@ export declare class KvAttestationPool implements AttestationPool {
|
|
|
7
7
|
private log;
|
|
8
8
|
private metrics;
|
|
9
9
|
private attestations;
|
|
10
|
+
private proposals;
|
|
10
11
|
private proposalsForSlot;
|
|
11
12
|
private attestationsForProposal;
|
|
12
13
|
constructor(store: AztecAsyncKVStore, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
+
private poolStats;
|
|
15
|
+
isEmpty(): Promise<boolean>;
|
|
13
16
|
private getProposalKey;
|
|
14
17
|
private getAttestationKey;
|
|
15
18
|
addAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
16
|
-
getAttestationsForSlot(slot: bigint
|
|
19
|
+
getAttestationsForSlot(slot: bigint): Promise<BlockAttestation[]>;
|
|
20
|
+
getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
|
|
17
21
|
deleteAttestationsOlderThan(oldestSlot: bigint): Promise<void>;
|
|
18
22
|
deleteAttestationsForSlot(slot: bigint): Promise<void>;
|
|
19
23
|
deleteAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<void>;
|
|
20
24
|
deleteAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
25
|
+
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
26
|
+
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
27
|
+
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
28
|
+
addBlockProposal(blockProposal: BlockProposal): Promise<void>;
|
|
21
29
|
}
|
|
22
30
|
//# sourceMappingURL=kv_attestation_pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAGA,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;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,eAAe;IAYrD,OAAO,CAAC,KAAK;IAEb,OAAO,CAAC,GAAG;IAbb,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,SAAS,CAGf;IACF,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,uBAAuB,CAAqC;gBAG1D,KAAK,EAAE,iBAAiB,EAChC,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAyC;IAUtD,OAAO,CAAC,SAAS,CAIf;IAEW,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAOxC,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,iBAAiB;IAIZ,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqChE,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAsBhG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BnE,cAAc,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB/D,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAahE,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxE,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAM3E"}
|