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