@aztec/p2p 0.0.0-test.1 → 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
4
|
+
import { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
5
5
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
6
6
|
import { PoolInstrumentation, PoolName } from '../instrumentation.js';
|
|
7
7
|
export class KvAttestationPool {
|
|
@@ -9,15 +9,29 @@ export class KvAttestationPool {
|
|
|
9
9
|
log;
|
|
10
10
|
metrics;
|
|
11
11
|
attestations;
|
|
12
|
+
proposals;
|
|
12
13
|
proposalsForSlot;
|
|
13
14
|
attestationsForProposal;
|
|
14
15
|
constructor(store, telemetry = getTelemetryClient(), log = createLogger('aztec:attestation_pool')){
|
|
15
16
|
this.store = store;
|
|
16
17
|
this.log = log;
|
|
18
|
+
this.poolStats = async ()=>{
|
|
19
|
+
return {
|
|
20
|
+
itemCount: await this.attestations.sizeAsync()
|
|
21
|
+
};
|
|
22
|
+
};
|
|
17
23
|
this.attestations = store.openMap('attestations');
|
|
24
|
+
this.proposals = store.openMap('proposals');
|
|
18
25
|
this.proposalsForSlot = store.openMultiMap('proposals_for_slot');
|
|
19
26
|
this.attestationsForProposal = store.openMultiMap('attestations_for_proposal');
|
|
20
|
-
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
|
|
27
|
+
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL, this.poolStats);
|
|
28
|
+
}
|
|
29
|
+
poolStats;
|
|
30
|
+
async isEmpty() {
|
|
31
|
+
for await (const _ of this.attestations.entriesAsync()){
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
21
35
|
}
|
|
22
36
|
getProposalKey(slot, proposalId) {
|
|
23
37
|
const slotStr = typeof slot === 'string' ? slot : new Fr(slot).toString();
|
|
@@ -30,18 +44,41 @@ export class KvAttestationPool {
|
|
|
30
44
|
async addAttestations(attestations) {
|
|
31
45
|
await this.store.transactionAsync(async ()=>{
|
|
32
46
|
for (const attestation of attestations){
|
|
33
|
-
const slotNumber = attestation.payload.header.
|
|
47
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
34
48
|
const proposalId = attestation.archive;
|
|
35
|
-
const
|
|
49
|
+
const sender = attestation.getSender();
|
|
50
|
+
// Skip attestations with invalid signatures
|
|
51
|
+
if (!sender) {
|
|
52
|
+
this.log.warn(`Skipping attestation with invalid signature for slot ${slotNumber.toBigInt()}`, {
|
|
53
|
+
signature: attestation.signature.toString(),
|
|
54
|
+
slotNumber,
|
|
55
|
+
proposalId
|
|
56
|
+
});
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const address = sender.toString();
|
|
36
60
|
await this.attestations.set(this.getAttestationKey(slotNumber, proposalId, address), attestation.toBuffer());
|
|
37
61
|
await this.proposalsForSlot.set(slotNumber.toString(), proposalId.toString());
|
|
38
62
|
await this.attestationsForProposal.set(this.getProposalKey(slotNumber, proposalId), this.getAttestationKey(slotNumber, proposalId, address));
|
|
39
|
-
this.log.verbose(`Added attestation for slot ${slotNumber} from ${address}
|
|
63
|
+
this.log.verbose(`Added attestation for slot ${slotNumber.toBigInt()} from ${address}`, {
|
|
64
|
+
signature: attestation.signature.toString(),
|
|
65
|
+
slotNumber,
|
|
66
|
+
address,
|
|
67
|
+
proposalId
|
|
68
|
+
});
|
|
40
69
|
}
|
|
41
70
|
});
|
|
42
|
-
this.metrics.recordAddedObjects(attestations.length);
|
|
43
71
|
}
|
|
44
|
-
async getAttestationsForSlot(slot
|
|
72
|
+
async getAttestationsForSlot(slot) {
|
|
73
|
+
const slotFr = new Fr(slot);
|
|
74
|
+
const proposalIds = await toArray(this.proposalsForSlot.getValuesAsync(slotFr.toString()));
|
|
75
|
+
const attestations = [];
|
|
76
|
+
for (const proposalId of proposalIds){
|
|
77
|
+
attestations.push(...await this.getAttestationsForSlotAndProposal(slot, proposalId));
|
|
78
|
+
}
|
|
79
|
+
return attestations;
|
|
80
|
+
}
|
|
81
|
+
async getAttestationsForSlotAndProposal(slot, proposalId) {
|
|
45
82
|
const attestationIds = await toArray(this.attestationsForProposal.getValuesAsync(this.getProposalKey(slot, proposalId)));
|
|
46
83
|
const attestations = [];
|
|
47
84
|
// alternatively iterate this.attestaions starting from slot-proposal-EthAddress.zero
|
|
@@ -75,11 +112,11 @@ export class KvAttestationPool {
|
|
|
75
112
|
for (const attestation of attestations){
|
|
76
113
|
await this.attestations.delete(attestation);
|
|
77
114
|
}
|
|
115
|
+
await this.proposals.delete(proposalId);
|
|
78
116
|
await this.attestationsForProposal.delete(this.getProposalKey(slotFr, proposalId));
|
|
79
117
|
}
|
|
118
|
+
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
80
119
|
});
|
|
81
|
-
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
82
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
83
120
|
}
|
|
84
121
|
async deleteAttestationsForSlotAndProposal(slot, proposalId) {
|
|
85
122
|
let numberOfAttestations = 0;
|
|
@@ -90,23 +127,64 @@ export class KvAttestationPool {
|
|
|
90
127
|
for (const attestation of attestations){
|
|
91
128
|
await this.attestations.delete(attestation);
|
|
92
129
|
}
|
|
130
|
+
await this.proposals.delete(proposalId);
|
|
93
131
|
await this.proposalsForSlot.deleteValue(slotString, proposalId);
|
|
94
132
|
await this.attestationsForProposal.delete(this.getProposalKey(slotString, proposalId));
|
|
133
|
+
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
95
134
|
});
|
|
96
|
-
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
97
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
98
135
|
}
|
|
99
136
|
async deleteAttestations(attestations) {
|
|
100
137
|
await this.store.transactionAsync(async ()=>{
|
|
101
138
|
for (const attestation of attestations){
|
|
102
|
-
const slotNumber = attestation.payload.header.
|
|
139
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
103
140
|
const proposalId = attestation.archive;
|
|
104
|
-
const
|
|
105
|
-
|
|
141
|
+
const sender = attestation.getSender();
|
|
142
|
+
// Skip attestations with invalid signatures
|
|
143
|
+
if (!sender) {
|
|
144
|
+
this.log.warn(`Skipping deletion of attestation with invalid signature for slot ${slotNumber.toBigInt()}`);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const address = sender.toString();
|
|
148
|
+
const key = this.getAttestationKey(slotNumber, proposalId, address);
|
|
149
|
+
if (await this.attestations.hasAsync(key)) {
|
|
150
|
+
await this.attestations.delete(key);
|
|
151
|
+
}
|
|
106
152
|
await this.attestationsForProposal.deleteValue(this.getProposalKey(slotNumber, proposalId), this.getAttestationKey(slotNumber, proposalId, address));
|
|
107
153
|
this.log.debug(`Deleted attestation for slot ${slotNumber} from ${address}`);
|
|
108
154
|
}
|
|
109
155
|
});
|
|
110
|
-
|
|
156
|
+
}
|
|
157
|
+
async hasAttestation(attestation) {
|
|
158
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
159
|
+
const proposalId = attestation.archive;
|
|
160
|
+
const sender = attestation.getSender();
|
|
161
|
+
// Attestations with invalid signatures are never in the pool
|
|
162
|
+
if (!sender) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
const address = sender.toString();
|
|
166
|
+
const key = this.getAttestationKey(slotNumber, proposalId, address);
|
|
167
|
+
return await this.attestations.hasAsync(key);
|
|
168
|
+
}
|
|
169
|
+
async getBlockProposal(id) {
|
|
170
|
+
const buffer = await this.proposals.getAsync(id);
|
|
171
|
+
try {
|
|
172
|
+
if (buffer && buffer.length > 0) {
|
|
173
|
+
return BlockProposal.fromBuffer(buffer);
|
|
174
|
+
}
|
|
175
|
+
} catch {
|
|
176
|
+
return Promise.resolve(undefined);
|
|
177
|
+
}
|
|
178
|
+
return Promise.resolve(undefined);
|
|
179
|
+
}
|
|
180
|
+
async hasBlockProposal(idOrProposal) {
|
|
181
|
+
const id = typeof idOrProposal === 'string' ? idOrProposal : idOrProposal.payload.archive.toString();
|
|
182
|
+
return await this.proposals.hasAsync(id);
|
|
183
|
+
}
|
|
184
|
+
async addBlockProposal(blockProposal) {
|
|
185
|
+
await this.store.transactionAsync(async ()=>{
|
|
186
|
+
await this.proposalsForSlot.set(blockProposal.slotNumber.toString(), blockProposal.archive.toString());
|
|
187
|
+
await this.proposals.set(blockProposal.payload.archive.toString(), blockProposal.toBuffer());
|
|
188
|
+
});
|
|
111
189
|
}
|
|
112
190
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
1
|
+
import type { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
2
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
3
3
|
import type { AttestationPool } from './attestation_pool.js';
|
|
4
4
|
export declare class InMemoryAttestationPool implements AttestationPool {
|
|
@@ -6,12 +6,20 @@ export declare class InMemoryAttestationPool implements AttestationPool {
|
|
|
6
6
|
private log;
|
|
7
7
|
private metrics;
|
|
8
8
|
private attestations;
|
|
9
|
+
private proposals;
|
|
9
10
|
constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
10
|
-
|
|
11
|
+
private poolStats;
|
|
12
|
+
isEmpty(): Promise<boolean>;
|
|
13
|
+
getAttestationsForSlot(slot: bigint): Promise<BlockAttestation[]>;
|
|
14
|
+
getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
|
|
11
15
|
addAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
12
16
|
deleteAttestationsOlderThan(oldestSlot: bigint): Promise<void>;
|
|
13
17
|
deleteAttestationsForSlot(slot: bigint): Promise<void>;
|
|
14
18
|
deleteAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<void>;
|
|
15
19
|
deleteAttestations(attestations: BlockAttestation[]): Promise<void>;
|
|
20
|
+
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
21
|
+
addBlockProposal(blockProposal: BlockProposal): Promise<void>;
|
|
22
|
+
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
23
|
+
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
16
24
|
}
|
|
17
25
|
//# sourceMappingURL=memory_attestation_pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/memory_attestation_pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"memory_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/memory_attestation_pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,uBAAwB,YAAW,eAAe;;IAQ3D,OAAO,CAAC,GAAG;IAPb,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgG;IACpH,OAAO,CAAC,SAAS,CAA6B;gBAG5C,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAuC;IAOpD,OAAO,CAAC,SAAS,CAIf;IAEK,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3B,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAWhG,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA6C1D,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBrF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBnE,cAAc,CAAC,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAuB/D,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7D,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAIhE,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;CAIhF"}
|
|
@@ -5,12 +5,26 @@ export class InMemoryAttestationPool {
|
|
|
5
5
|
log;
|
|
6
6
|
metrics;
|
|
7
7
|
attestations;
|
|
8
|
+
proposals;
|
|
8
9
|
constructor(telemetry = getTelemetryClient(), log = createLogger('p2p:attestation_pool')){
|
|
9
10
|
this.log = log;
|
|
11
|
+
this.poolStats = ()=>{
|
|
12
|
+
return Promise.resolve({
|
|
13
|
+
itemCount: this.attestations.size
|
|
14
|
+
});
|
|
15
|
+
};
|
|
10
16
|
this.attestations = new Map();
|
|
11
|
-
this.
|
|
17
|
+
this.proposals = new Map();
|
|
18
|
+
this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL, this.poolStats);
|
|
12
19
|
}
|
|
13
|
-
|
|
20
|
+
poolStats;
|
|
21
|
+
isEmpty() {
|
|
22
|
+
return Promise.resolve(this.attestations.size === 0);
|
|
23
|
+
}
|
|
24
|
+
getAttestationsForSlot(slot) {
|
|
25
|
+
return Promise.resolve(Array.from(this.attestations.get(slot)?.values() ?? []).flatMap((proposalAttestationMap)=>Array.from(proposalAttestationMap.values())));
|
|
26
|
+
}
|
|
27
|
+
getAttestationsForSlotAndProposal(slot, proposalId) {
|
|
14
28
|
const slotAttestationMap = this.attestations.get(slot);
|
|
15
29
|
if (slotAttestationMap) {
|
|
16
30
|
const proposalAttestationMap = slotAttestationMap.get(proposalId);
|
|
@@ -20,19 +34,31 @@ export class InMemoryAttestationPool {
|
|
|
20
34
|
}
|
|
21
35
|
return Promise.resolve([]);
|
|
22
36
|
}
|
|
23
|
-
|
|
37
|
+
addAttestations(attestations) {
|
|
24
38
|
for (const attestation of attestations){
|
|
25
39
|
// Perf: order and group by slot before insertion
|
|
26
|
-
const slotNumber = attestation.payload.header.
|
|
40
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
27
41
|
const proposalId = attestation.archive.toString();
|
|
28
|
-
const
|
|
42
|
+
const sender = attestation.getSender();
|
|
43
|
+
// Skip attestations with invalid signatures
|
|
44
|
+
if (!sender) {
|
|
45
|
+
this.log.warn(`Skipping attestation with invalid signature for slot ${slotNumber.toBigInt()}`, {
|
|
46
|
+
signature: attestation.signature.toString(),
|
|
47
|
+
slotNumber,
|
|
48
|
+
proposalId
|
|
49
|
+
});
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
29
52
|
const slotAttestationMap = getSlotOrDefault(this.attestations, slotNumber.toBigInt());
|
|
30
53
|
const proposalAttestationMap = getProposalOrDefault(slotAttestationMap, proposalId);
|
|
31
|
-
proposalAttestationMap.set(
|
|
32
|
-
this.log.verbose(`Added attestation for slot ${slotNumber} from ${
|
|
54
|
+
proposalAttestationMap.set(sender.toString(), attestation);
|
|
55
|
+
this.log.verbose(`Added attestation for slot ${slotNumber.toBigInt()} from ${sender}`, {
|
|
56
|
+
signature: attestation.signature.toString(),
|
|
57
|
+
slotNumber,
|
|
58
|
+
address: sender,
|
|
59
|
+
proposalId
|
|
60
|
+
});
|
|
33
61
|
}
|
|
34
|
-
// TODO: set these to pending or something ????
|
|
35
|
-
this.metrics.recordAddedObjects(attestations.length);
|
|
36
62
|
return Promise.resolve();
|
|
37
63
|
}
|
|
38
64
|
#getNumberOfAttestationsInSlot(slot) {
|
|
@@ -66,9 +92,14 @@ export class InMemoryAttestationPool {
|
|
|
66
92
|
deleteAttestationsForSlot(slot) {
|
|
67
93
|
// We count the number of attestations we are removing
|
|
68
94
|
const numberOfAttestations = this.#getNumberOfAttestationsInSlot(slot);
|
|
95
|
+
const proposalIdsToDelete = this.attestations.get(slot)?.keys();
|
|
96
|
+
let proposalIdsToDeleteCount = 0;
|
|
97
|
+
proposalIdsToDelete?.forEach((proposalId)=>{
|
|
98
|
+
this.proposals.delete(proposalId);
|
|
99
|
+
proposalIdsToDeleteCount++;
|
|
100
|
+
});
|
|
69
101
|
this.attestations.delete(slot);
|
|
70
|
-
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot}`);
|
|
71
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
102
|
+
this.log.verbose(`Removed ${numberOfAttestations} attestations and ${proposalIdsToDeleteCount} proposals for slot ${slot}`);
|
|
72
103
|
return Promise.resolve();
|
|
73
104
|
}
|
|
74
105
|
deleteAttestationsForSlotAndProposal(slot, proposalId) {
|
|
@@ -78,28 +109,65 @@ export class InMemoryAttestationPool {
|
|
|
78
109
|
const numberOfAttestations = slotAttestationMap.get(proposalId)?.size ?? 0;
|
|
79
110
|
slotAttestationMap.delete(proposalId);
|
|
80
111
|
this.log.verbose(`Removed ${numberOfAttestations} attestations for slot ${slot} and proposal ${proposalId}`);
|
|
81
|
-
this.metrics.recordRemovedObjects(numberOfAttestations);
|
|
82
112
|
}
|
|
83
113
|
}
|
|
114
|
+
this.proposals.delete(proposalId);
|
|
84
115
|
return Promise.resolve();
|
|
85
116
|
}
|
|
86
|
-
|
|
117
|
+
deleteAttestations(attestations) {
|
|
87
118
|
for (const attestation of attestations){
|
|
88
|
-
const slotNumber = attestation.payload.header.
|
|
119
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
89
120
|
const slotAttestationMap = this.attestations.get(slotNumber.toBigInt());
|
|
90
121
|
if (slotAttestationMap) {
|
|
91
122
|
const proposalId = attestation.archive.toString();
|
|
92
123
|
const proposalAttestationMap = getProposalOrDefault(slotAttestationMap, proposalId);
|
|
93
124
|
if (proposalAttestationMap) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
125
|
+
const sender = attestation.getSender();
|
|
126
|
+
// Skip attestations with invalid signatures
|
|
127
|
+
if (!sender) {
|
|
128
|
+
this.log.warn(`Skipping deletion of attestation with invalid signature for slot ${slotNumber.toBigInt()}`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
proposalAttestationMap.delete(sender.toString());
|
|
132
|
+
this.log.debug(`Deleted attestation for slot ${slotNumber} from ${sender}`);
|
|
97
133
|
}
|
|
98
134
|
}
|
|
99
135
|
}
|
|
100
|
-
this.metrics.recordRemovedObjects(attestations.length);
|
|
101
136
|
return Promise.resolve();
|
|
102
137
|
}
|
|
138
|
+
hasAttestation(attestation) {
|
|
139
|
+
const slotNumber = attestation.payload.header.slotNumber;
|
|
140
|
+
const proposalId = attestation.archive.toString();
|
|
141
|
+
const sender = attestation.getSender();
|
|
142
|
+
// Attestations with invalid signatures are never in the pool
|
|
143
|
+
if (!sender) {
|
|
144
|
+
return Promise.resolve(false);
|
|
145
|
+
}
|
|
146
|
+
const slotAttestationMap = this.attestations.get(slotNumber.toBigInt());
|
|
147
|
+
if (!slotAttestationMap) {
|
|
148
|
+
return Promise.resolve(false);
|
|
149
|
+
}
|
|
150
|
+
const proposalAttestationMap = slotAttestationMap.get(proposalId);
|
|
151
|
+
if (!proposalAttestationMap) {
|
|
152
|
+
return Promise.resolve(false);
|
|
153
|
+
}
|
|
154
|
+
return Promise.resolve(proposalAttestationMap.has(sender.toString()));
|
|
155
|
+
}
|
|
156
|
+
addBlockProposal(blockProposal) {
|
|
157
|
+
// We initialize slot-proposal mapping if it does not exist
|
|
158
|
+
// This is important to ensure we can delete this proposal if there were not attestations for it
|
|
159
|
+
const slotProposalMapping = getSlotOrDefault(this.attestations, blockProposal.slotNumber.toBigInt());
|
|
160
|
+
slotProposalMapping.set(blockProposal.payload.archive.toString(), new Map());
|
|
161
|
+
this.proposals.set(blockProposal.payload.archive.toString(), blockProposal);
|
|
162
|
+
return Promise.resolve();
|
|
163
|
+
}
|
|
164
|
+
getBlockProposal(id) {
|
|
165
|
+
return Promise.resolve(this.proposals.get(id));
|
|
166
|
+
}
|
|
167
|
+
hasBlockProposal(idOrProposal) {
|
|
168
|
+
const id = typeof idOrProposal === 'string' ? idOrProposal : idOrProposal.payload.archive.toString();
|
|
169
|
+
return Promise.resolve(this.proposals.has(id));
|
|
170
|
+
}
|
|
103
171
|
}
|
|
104
172
|
/**
|
|
105
173
|
* Get Slot or Default
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { BlockAttestation } from '@aztec/stdlib/p2p';
|
|
4
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
4
|
import { type LocalAccount } from 'viem/accounts';
|
|
6
5
|
/** Generate Account
|
|
7
6
|
*
|
|
@@ -15,5 +14,5 @@ export declare const generateAccount: () => LocalAccount;
|
|
|
15
14
|
* @param slot The slot number the attestation is for
|
|
16
15
|
* @returns A Block Attestation
|
|
17
16
|
*/
|
|
18
|
-
export declare const mockAttestation: (signer: Secp256k1Signer, slot?: number, archive?: Fr
|
|
17
|
+
export declare const mockAttestation: (signer: Secp256k1Signer, slot?: number, archive?: Fr) => BlockAttestation;
|
|
19
18
|
//# sourceMappingURL=mocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,eAAe,CAAC;AAE3F;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAGlC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,EACvB,OAAM,MAAU,EAChB,UAAS,EAAgB,KACxB,gBAYF,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { BlockAttestation, ConsensusPayload, SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '@aztec/stdlib/p2p';
|
|
3
|
-
import {
|
|
4
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
|
+
import { makeL2BlockHeader } from '@aztec/stdlib/testing';
|
|
5
4
|
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
6
5
|
/** Generate Account
|
|
7
6
|
*
|
|
@@ -16,18 +15,13 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
|
16
15
|
* @param signer A viem signer to create a signature
|
|
17
16
|
* @param slot The slot number the attestation is for
|
|
18
17
|
* @returns A Block Attestation
|
|
19
|
-
*/ export const mockAttestation =
|
|
20
|
-
0,
|
|
21
|
-
1,
|
|
22
|
-
2,
|
|
23
|
-
3,
|
|
24
|
-
4,
|
|
25
|
-
5
|
|
26
|
-
].map(()=>TxHash.random()))=>{
|
|
18
|
+
*/ export const mockAttestation = (signer, slot = 0, archive = Fr.random())=>{
|
|
27
19
|
// Use arbitrary numbers for all other than slot
|
|
28
|
-
const header =
|
|
29
|
-
const payload = new ConsensusPayload(header, archive,
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
20
|
+
const header = makeL2BlockHeader(1, 2, slot);
|
|
21
|
+
const payload = new ConsensusPayload(header.toCheckpointHeader(), archive, header.state);
|
|
22
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
23
|
+
const attestationSignature = signer.sign(attestationHash);
|
|
24
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
25
|
+
const proposerSignature = signer.sign(proposalHash);
|
|
26
|
+
return new BlockAttestation(payload, attestationSignature, proposerSignature);
|
|
33
27
|
};
|
|
@@ -4,27 +4,23 @@ export declare enum PoolName {
|
|
|
4
4
|
TX_POOL = "TxPool",
|
|
5
5
|
ATTESTATION_POOL = "AttestationPool"
|
|
6
6
|
}
|
|
7
|
+
export type PoolStatsCallback = () => Promise<{
|
|
8
|
+
itemCount: number | Record<string, number>;
|
|
9
|
+
}>;
|
|
7
10
|
/**
|
|
8
11
|
* Instrumentation class for the Pools (TxPool, AttestationPool, etc).
|
|
9
12
|
*/
|
|
10
13
|
export declare class PoolInstrumentation<PoolObject extends Gossipable> {
|
|
14
|
+
private poolStats;
|
|
11
15
|
/** The number of txs in the mempool */
|
|
12
16
|
private objectsInMempool;
|
|
13
17
|
/** Tracks tx size */
|
|
14
18
|
private objectSize;
|
|
15
19
|
private dbMetrics;
|
|
16
20
|
private defaultAttributes;
|
|
17
|
-
|
|
21
|
+
private meter;
|
|
22
|
+
constructor(telemetry: TelemetryClient, name: PoolName, poolStats: PoolStatsCallback, dbStats?: LmdbStatsCallback);
|
|
18
23
|
recordSize(poolObject: PoolObject): void;
|
|
19
|
-
|
|
20
|
-
* Updates the metrics with the new objects.
|
|
21
|
-
* @param txs - The objects to record
|
|
22
|
-
*/
|
|
23
|
-
recordAddedObjects(count?: number, status?: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* Updates the metrics by removing objects from the mempool.
|
|
26
|
-
* @param count - The number of objects to remove from the mempool
|
|
27
|
-
*/
|
|
28
|
-
recordRemovedObjects(count?: number, status?: string): void;
|
|
24
|
+
private observeStats;
|
|
29
25
|
}
|
|
30
26
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/mem_pools/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAKL,KAAK,iBAAiB,EAKtB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,QAAQ;IAClB,OAAO,WAAW;IAClB,gBAAgB,oBAAoB;CACrC;AA4BD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC;IAC5C,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC,CAAC;AAEH;;GAEG;AACH,qBAAa,mBAAmB,CAAC,UAAU,SAAS,UAAU;IAc1D,OAAO,CAAC,SAAS;IAbnB,uCAAuC;IACvC,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,qBAAqB;IACrB,OAAO,CAAC,UAAU,CAAY;IAE9B,OAAO,CAAC,SAAS,CAAc;IAE/B,OAAO,CAAC,iBAAiB,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAQ;gBAGnB,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,QAAQ,EACN,SAAS,EAAE,iBAAiB,EACpC,OAAO,CAAC,EAAE,iBAAiB;IA2BtB,UAAU,CAAC,UAAU,EAAE,UAAU;IAIxC,OAAO,CAAC,YAAY,CAYlB;CACH"}
|
|
@@ -25,60 +25,48 @@ export var PoolName = /*#__PURE__*/ function(PoolName) {
|
|
|
25
25
|
/**
|
|
26
26
|
* Instrumentation class for the Pools (TxPool, AttestationPool, etc).
|
|
27
27
|
*/ export class PoolInstrumentation {
|
|
28
|
+
poolStats;
|
|
28
29
|
/** The number of txs in the mempool */ objectsInMempool;
|
|
29
30
|
/** Tracks tx size */ objectSize;
|
|
30
31
|
dbMetrics;
|
|
31
32
|
defaultAttributes;
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
meter;
|
|
34
|
+
constructor(telemetry, name, poolStats, dbStats){
|
|
35
|
+
this.poolStats = poolStats;
|
|
36
|
+
this.observeStats = async (observer)=>{
|
|
37
|
+
const { itemCount } = await this.poolStats();
|
|
38
|
+
if (typeof itemCount === 'number') {
|
|
39
|
+
observer.observe(this.objectsInMempool, itemCount, this.defaultAttributes);
|
|
40
|
+
} else {
|
|
41
|
+
for (const [status, count] of Object.entries(itemCount)){
|
|
42
|
+
observer.observe(this.objectsInMempool, count, {
|
|
43
|
+
...this.defaultAttributes,
|
|
44
|
+
[Attributes.STATUS]: status
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.meter = telemetry.getMeter(name);
|
|
34
50
|
this.defaultAttributes = {
|
|
35
51
|
[Attributes.POOL_NAME]: name
|
|
36
52
|
};
|
|
37
53
|
const metricsLabels = getMetricsLabels(name);
|
|
38
|
-
this.objectsInMempool = meter.
|
|
54
|
+
this.objectsInMempool = this.meter.createObservableGauge(metricsLabels.objectInMempool, {
|
|
39
55
|
description: 'The current number of transactions in the mempool'
|
|
40
56
|
});
|
|
41
|
-
this.objectSize = meter.createHistogram(metricsLabels.objectSize, {
|
|
57
|
+
this.objectSize = this.meter.createHistogram(metricsLabels.objectSize, {
|
|
42
58
|
unit: 'By',
|
|
43
59
|
description: 'The size of transactions in the mempool'
|
|
44
60
|
});
|
|
45
|
-
this.dbMetrics = new LmdbMetrics(meter, {
|
|
61
|
+
this.dbMetrics = new LmdbMetrics(this.meter, {
|
|
46
62
|
[Attributes.DB_DATA_TYPE]: 'tx-pool'
|
|
47
63
|
}, dbStats);
|
|
64
|
+
this.meter.addBatchObservableCallback(this.observeStats, [
|
|
65
|
+
this.objectsInMempool
|
|
66
|
+
]);
|
|
48
67
|
}
|
|
49
68
|
recordSize(poolObject) {
|
|
50
69
|
this.objectSize.record(poolObject.getSize());
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
* Updates the metrics with the new objects.
|
|
54
|
-
* @param txs - The objects to record
|
|
55
|
-
*/ recordAddedObjects(count = 1, status) {
|
|
56
|
-
if (count < 0) {
|
|
57
|
-
throw new Error('Count must be positive');
|
|
58
|
-
}
|
|
59
|
-
if (count === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const attributes = status ? {
|
|
63
|
-
...this.defaultAttributes,
|
|
64
|
-
[Attributes.STATUS]: status
|
|
65
|
-
} : this.defaultAttributes;
|
|
66
|
-
this.objectsInMempool.add(count, attributes);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Updates the metrics by removing objects from the mempool.
|
|
70
|
-
* @param count - The number of objects to remove from the mempool
|
|
71
|
-
*/ recordRemovedObjects(count = 1, status) {
|
|
72
|
-
if (count < 0) {
|
|
73
|
-
throw new Error('Count must be positive');
|
|
74
|
-
}
|
|
75
|
-
if (count === 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const attributes = status ? {
|
|
79
|
-
...this.defaultAttributes,
|
|
80
|
-
[Attributes.STATUS]: status
|
|
81
|
-
} : this.defaultAttributes;
|
|
82
|
-
this.objectsInMempool.add(-1 * count, attributes);
|
|
83
|
-
}
|
|
71
|
+
observeStats;
|
|
84
72
|
}
|