@aztec/p2p 0.0.1-commit.b655e406 → 0.0.1-commit.c7c42ec
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/client/factory.d.ts +2 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +2 -3
- package/dest/client/index.d.ts +1 -1
- package/dest/client/interface.d.ts +4 -2
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +9 -27
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +39 -32
- package/dest/config.d.ts +62 -59
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +19 -12
- package/dest/enr/generate-enr.d.ts +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 +28 -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 +35 -34
- package/dest/mem_pools/attestation_pool/index.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +13 -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 +41 -18
- package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +11 -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 +30 -8
- 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 +2 -2
- 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 +30 -60
- 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 +262 -324
- 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 +11 -6
- 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 +30 -24
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +4 -3
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +12 -12
- 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 +1 -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 +22 -10
- 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/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/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 +1 -1
- 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 +1 -1
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
- 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 +3 -2
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- 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 +1 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/dummy_service.d.ts +1 -1
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +1 -1
- 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 +14 -70
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +231 -66
- 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 +1 -32
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +6 -2
- 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 -2
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +1 -1
- 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/status.d.ts +2 -2
- package/dest/services/reqresp/status.d.ts.map +1 -1
- package/dest/services/service.d.ts +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/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 +11 -11
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- 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_source.d.ts +1 -1
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- 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 +11 -2
- 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-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 +2 -2
- package/dest/test-helpers/mock-tx-helpers.d.ts.map +1 -1
- package/dest/test-helpers/mock-tx-helpers.js +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +12 -8
- package/dest/testbench/parse_log_file.d.ts +1 -1
- package/dest/testbench/testbench.d.ts +1 -1
- 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 +1 -1
- package/package.json +19 -18
- package/src/client/factory.ts +5 -10
- package/src/client/interface.ts +4 -1
- package/src/client/p2p_client.ts +63 -60
- package/src/config.ts +28 -17
- package/src/errors/attestation-pool.error.ts +13 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +29 -5
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +47 -34
- package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +66 -24
- package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +50 -16
- package/src/mem_pools/attestation_pool/mocks.ts +3 -3
- 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 +314 -373
- 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 +11 -5
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +23 -17
- package/src/msg_validators/attestation_validator/attestation_validator.ts +14 -16
- 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 +26 -10
- package/src/msg_validators/tx_validator/archive_cache.ts +1 -1
- package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
- package/src/msg_validators/tx_validator/factory.ts +3 -2
- package/src/msg_validators/tx_validator/metadata_validator.ts +1 -1
- 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 +2 -1
- package/src/services/encoding.ts +1 -1
- package/src/services/libp2p/instrumentation.ts +10 -1
- package/src/services/libp2p/libp2p_service.ts +263 -79
- package/src/services/peer-manager/metrics.ts +32 -0
- package/src/services/peer-manager/peer_manager.ts +6 -2
- package/src/services/peer-manager/peer_scoring.ts +46 -3
- package/src/services/reqresp/interface.ts +1 -1
- 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/tx_collection/config.ts +1 -1
- package/src/services/tx_collection/fast_tx_collection.ts +3 -2
- package/src/services/tx_collection/slow_tx_collection.ts +7 -6
- package/src/services/tx_collection/tx_collection.ts +10 -9
- package/src/services/tx_provider.ts +21 -5
- package/src/services/tx_provider_instrumentation.ts +19 -2
- package/src/test-helpers/mock-pubsub.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +1 -1
- package/src/test-helpers/reqresp-nodes.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +10 -6
- package/src/util.ts +12 -2
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +0 -80
- 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 -238
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +0 -283
package/src/client/p2p_client.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
5
6
|
import type {
|
|
6
7
|
EthAddress,
|
|
7
|
-
L2Block,
|
|
8
8
|
L2BlockId,
|
|
9
|
+
L2BlockNew,
|
|
9
10
|
L2BlockSource,
|
|
10
11
|
L2BlockStream,
|
|
11
12
|
L2BlockStreamEvent,
|
|
12
13
|
L2Tips,
|
|
13
|
-
PublishedL2Block,
|
|
14
14
|
} from '@aztec/stdlib/block';
|
|
15
15
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
16
16
|
import { getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
@@ -62,14 +62,14 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
62
62
|
private provenBlockNumberAtStart = -1;
|
|
63
63
|
private finalizedBlockNumberAtStart = -1;
|
|
64
64
|
|
|
65
|
-
private synchedBlockHashes: AztecAsyncMap<
|
|
66
|
-
private synchedLatestBlockNumber: AztecAsyncSingleton<
|
|
67
|
-
private synchedProvenBlockNumber: AztecAsyncSingleton<
|
|
68
|
-
private synchedFinalizedBlockNumber: AztecAsyncSingleton<
|
|
65
|
+
private synchedBlockHashes: AztecAsyncMap<BlockNumber, string>;
|
|
66
|
+
private synchedLatestBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
67
|
+
private synchedProvenBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
68
|
+
private synchedFinalizedBlockNumber: AztecAsyncSingleton<BlockNumber>;
|
|
69
69
|
private synchedLatestSlot: AztecAsyncSingleton<bigint>;
|
|
70
70
|
|
|
71
71
|
private txPool: TxPool;
|
|
72
|
-
private attestationPool:
|
|
72
|
+
private attestationPool: AttestationPool;
|
|
73
73
|
|
|
74
74
|
private config: P2PConfig;
|
|
75
75
|
|
|
@@ -91,7 +91,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
91
91
|
_clientType: T,
|
|
92
92
|
private store: AztecAsyncKVStore,
|
|
93
93
|
private l2BlockSource: L2BlockSource & ContractDataSource,
|
|
94
|
-
mempools: MemPools
|
|
94
|
+
mempools: MemPools,
|
|
95
95
|
private p2pService: P2PService,
|
|
96
96
|
private txCollection: TxCollection,
|
|
97
97
|
config: Partial<P2PConfig> = {},
|
|
@@ -103,7 +103,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
103
103
|
|
|
104
104
|
this.config = { ...getP2PDefaultConfig(), ...config };
|
|
105
105
|
this.txPool = mempools.txPool;
|
|
106
|
-
this.attestationPool = mempools.attestationPool
|
|
106
|
+
this.attestationPool = mempools.attestationPool;
|
|
107
107
|
|
|
108
108
|
this.txProvider = new TxProvider(
|
|
109
109
|
this.txCollection,
|
|
@@ -121,14 +121,14 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
121
121
|
this.log.debug(`Received block proposal from ${sender.toString()}`);
|
|
122
122
|
// TODO(palla/txs): Need to subtract validatorReexecuteDeadlineMs from this deadline (see ValidatorClient.getReexecutionDeadline)
|
|
123
123
|
const constants = this.txCollection.getConstants();
|
|
124
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(block.slotNumber
|
|
124
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(block.slotNumber + 1), constants));
|
|
125
125
|
const deadline = new Date(nextSlotTimestampSeconds * 1000);
|
|
126
126
|
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
|
|
127
127
|
if (!parentBlock) {
|
|
128
128
|
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
const blockNumber = parentBlock.getBlockNumber() + 1;
|
|
131
|
+
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
132
132
|
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
133
133
|
return undefined;
|
|
134
134
|
});
|
|
@@ -162,7 +162,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
162
162
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
public getL2BlockHash(number:
|
|
165
|
+
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
166
166
|
return this.synchedBlockHashes.getAsync(number);
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -203,10 +203,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
const genesisHash = GENESIS_BLOCK_HEADER_HASH.toString();
|
|
207
|
+
|
|
206
208
|
return {
|
|
207
|
-
latest: { hash: latestBlockHash
|
|
208
|
-
proven: { hash: provenBlockHash
|
|
209
|
-
finalized: { hash: finalizedBlockHash
|
|
209
|
+
latest: { hash: latestBlockHash ?? genesisHash, number: latestBlockNumber },
|
|
210
|
+
proven: { hash: provenBlockHash ?? genesisHash, number: provenBlockNumber },
|
|
211
|
+
finalized: { hash: finalizedBlockHash ?? genesisHash, number: finalizedBlockNumber },
|
|
210
212
|
};
|
|
211
213
|
}
|
|
212
214
|
|
|
@@ -214,15 +216,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
214
216
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
215
217
|
switch (event.type) {
|
|
216
218
|
case 'blocks-added':
|
|
217
|
-
await this.handleLatestL2Blocks(event.blocks);
|
|
219
|
+
await this.handleLatestL2Blocks(event.blocks.map(b => b.block.toL2Block()));
|
|
218
220
|
break;
|
|
219
221
|
case 'chain-finalized': {
|
|
220
222
|
// TODO (alexg): I think we can prune the block hashes map here
|
|
221
223
|
await this.setBlockHash(event.block);
|
|
222
|
-
const from = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
224
|
+
const from = BlockNumber((await this.getSyncedFinalizedBlockNum()) + 1);
|
|
223
225
|
const limit = event.block.number - from + 1;
|
|
224
226
|
if (limit > 0) {
|
|
225
|
-
|
|
227
|
+
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
228
|
+
await this.handleFinalizedL2Blocks(oldBlocks.map(b => b.toL2Block()));
|
|
226
229
|
}
|
|
227
230
|
break;
|
|
228
231
|
}
|
|
@@ -279,12 +282,9 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
279
282
|
const syncedProvenBlock = (await this.getSyncedProvenBlockNum()) + 1;
|
|
280
283
|
const syncedFinalizedBlock = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
281
284
|
|
|
282
|
-
if (
|
|
283
|
-
(await this.txPool.isEmpty()) &&
|
|
284
|
-
(this.attestationPool === undefined || (await this.attestationPool?.isEmpty()))
|
|
285
|
-
) {
|
|
285
|
+
if ((await this.txPool.isEmpty()) && (await this.attestationPool.isEmpty())) {
|
|
286
286
|
// if mempools are empty, we don't care about syncing prior blocks
|
|
287
|
-
this.initBlockStream(this.latestBlockNumberAtStart);
|
|
287
|
+
this.initBlockStream(BlockNumber(this.latestBlockNumberAtStart));
|
|
288
288
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
289
289
|
this.syncPromise = Promise.resolve();
|
|
290
290
|
await this.p2pService.start();
|
|
@@ -332,7 +332,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
332
332
|
return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
private initBlockStream(startingBlock?:
|
|
335
|
+
private initBlockStream(startingBlock?: BlockNumber) {
|
|
336
336
|
if (!this.blockStream) {
|
|
337
337
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
338
338
|
this.blockStream = new TraceableL2BlockStream(
|
|
@@ -371,29 +371,32 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
374
|
-
[Attributes.SLOT_NUMBER]: proposal.slotNumber
|
|
374
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
375
375
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
376
|
-
[Attributes.P2P_ID]: (await proposal.
|
|
376
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
377
377
|
}))
|
|
378
378
|
public broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
379
|
-
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber
|
|
379
|
+
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
380
380
|
return this.p2pService.propagate(proposal);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
public async
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
383
|
+
public async broadcastAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
384
|
+
this.log.verbose(`Broadcasting ${attestations.length} attestations to peers`);
|
|
385
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
389
|
+
return await (proposalId
|
|
390
|
+
? this.attestationPool.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
391
|
+
: this.attestationPool.getAttestationsForSlot(slot));
|
|
389
392
|
}
|
|
390
393
|
|
|
391
394
|
public addAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
392
|
-
return this.attestationPool
|
|
395
|
+
return this.attestationPool.addAttestations(attestations);
|
|
393
396
|
}
|
|
394
397
|
|
|
395
398
|
public deleteAttestation(attestation: BlockAttestation): Promise<void> {
|
|
396
|
-
return this.attestationPool
|
|
399
|
+
return this.attestationPool.deleteAttestations([attestation]);
|
|
397
400
|
}
|
|
398
401
|
|
|
399
402
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
@@ -643,20 +646,20 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
643
646
|
* Public function to check the latest block number that the P2P client is synced to.
|
|
644
647
|
* @returns Block number of latest L2 Block we've synced with.
|
|
645
648
|
*/
|
|
646
|
-
public async getSyncedLatestBlockNum(): Promise<
|
|
647
|
-
return (await this.synchedLatestBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
649
|
+
public async getSyncedLatestBlockNum(): Promise<BlockNumber> {
|
|
650
|
+
return (await this.synchedLatestBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
648
651
|
}
|
|
649
652
|
|
|
650
653
|
/**
|
|
651
654
|
* Public function to check the latest proven block number that the P2P client is synced to.
|
|
652
655
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
653
656
|
*/
|
|
654
|
-
public async getSyncedProvenBlockNum(): Promise<
|
|
655
|
-
return (await this.synchedProvenBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
657
|
+
public async getSyncedProvenBlockNum(): Promise<BlockNumber> {
|
|
658
|
+
return (await this.synchedProvenBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
656
659
|
}
|
|
657
660
|
|
|
658
|
-
public async getSyncedFinalizedBlockNum(): Promise<
|
|
659
|
-
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
661
|
+
public async getSyncedFinalizedBlockNum(): Promise<BlockNumber> {
|
|
662
|
+
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
660
663
|
}
|
|
661
664
|
|
|
662
665
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
@@ -672,7 +675,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
672
675
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
673
676
|
const blockHash =
|
|
674
677
|
blockNumber === 0
|
|
675
|
-
?
|
|
678
|
+
? GENESIS_BLOCK_HEADER_HASH.toString()
|
|
676
679
|
: await this.l2BlockSource
|
|
677
680
|
.getBlockHeader(blockNumber)
|
|
678
681
|
.then(header => header?.hash())
|
|
@@ -680,8 +683,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
680
683
|
|
|
681
684
|
return {
|
|
682
685
|
state: this.currentState,
|
|
683
|
-
syncedToL2Block: { number: blockNumber, hash: blockHash },
|
|
684
|
-
}
|
|
686
|
+
syncedToL2Block: { number: blockNumber, hash: blockHash! },
|
|
687
|
+
};
|
|
685
688
|
}
|
|
686
689
|
|
|
687
690
|
/**
|
|
@@ -689,10 +692,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
689
692
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
690
693
|
* @returns Empty promise.
|
|
691
694
|
*/
|
|
692
|
-
private async markTxsAsMinedFromBlocks(blocks:
|
|
695
|
+
private async markTxsAsMinedFromBlocks(blocks: L2BlockNew[]): Promise<void> {
|
|
693
696
|
for (const block of blocks) {
|
|
694
697
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
695
|
-
await this.txPool.markAsMined(txHashes, block.
|
|
698
|
+
await this.txPool.markAsMined(txHashes, block.header);
|
|
696
699
|
}
|
|
697
700
|
}
|
|
698
701
|
|
|
@@ -701,33 +704,34 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
701
704
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
702
705
|
* @returns Empty promise.
|
|
703
706
|
*/
|
|
704
|
-
private async handleLatestL2Blocks(blocks:
|
|
707
|
+
private async handleLatestL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
705
708
|
if (!blocks.length) {
|
|
706
709
|
return Promise.resolve();
|
|
707
710
|
}
|
|
708
711
|
|
|
709
|
-
await this.markTxsAsMinedFromBlocks(blocks
|
|
710
|
-
await this.
|
|
712
|
+
await this.markTxsAsMinedFromBlocks(blocks);
|
|
713
|
+
await this.txPool.clearNonEvictableTxs();
|
|
714
|
+
await this.startCollectingMissingTxs(blocks);
|
|
711
715
|
|
|
712
|
-
const lastBlock = blocks.at(-1)
|
|
716
|
+
const lastBlock = blocks.at(-1)!;
|
|
713
717
|
|
|
714
718
|
await Promise.all(
|
|
715
719
|
blocks.map(async block =>
|
|
716
720
|
this.setBlockHash({
|
|
717
|
-
number: block.
|
|
718
|
-
hash: await block.
|
|
721
|
+
number: block.number,
|
|
722
|
+
hash: await block.hash().then(h => h.toString()),
|
|
719
723
|
}),
|
|
720
724
|
),
|
|
721
725
|
);
|
|
722
726
|
|
|
723
727
|
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
724
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
728
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
725
729
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
726
730
|
await this.startServiceIfSynched();
|
|
727
731
|
}
|
|
728
732
|
|
|
729
733
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
730
|
-
private async startCollectingMissingTxs(blocks:
|
|
734
|
+
private async startCollectingMissingTxs(blocks: L2BlockNew[]): Promise<void> {
|
|
731
735
|
try {
|
|
732
736
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
733
737
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -760,7 +764,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
760
764
|
* @param blocks - A list of finalized L2 blocks.
|
|
761
765
|
* @returns Empty promise.
|
|
762
766
|
*/
|
|
763
|
-
private async handleFinalizedL2Blocks(blocks:
|
|
767
|
+
private async handleFinalizedL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
764
768
|
if (!blocks.length) {
|
|
765
769
|
return Promise.resolve();
|
|
766
770
|
}
|
|
@@ -774,7 +778,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
774
778
|
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
775
779
|
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
776
780
|
|
|
777
|
-
await this.attestationPool
|
|
781
|
+
await this.attestationPool.deleteAttestationsOlderThan(lastBlockSlot);
|
|
778
782
|
|
|
779
783
|
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
780
784
|
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
@@ -786,7 +790,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
786
790
|
* Updates the tx pool after a chain prune.
|
|
787
791
|
* @param latestBlock - The block number the chain was pruned to.
|
|
788
792
|
*/
|
|
789
|
-
private async handlePruneL2Blocks(latestBlock:
|
|
793
|
+
private async handlePruneL2Blocks(latestBlock: BlockNumber): Promise<void> {
|
|
790
794
|
const txsToDelete = new Map<string, TxHash>();
|
|
791
795
|
const minedTxs = await this.txPool.getMinedTxHashes();
|
|
792
796
|
|
|
@@ -825,8 +829,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
825
829
|
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
826
830
|
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
827
831
|
} else {
|
|
828
|
-
this.
|
|
829
|
-
await this.txPool.markMinedAsPending(minedTxsFromReorg);
|
|
832
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg, latestBlock);
|
|
830
833
|
}
|
|
831
834
|
|
|
832
835
|
await this.synchedLatestBlockNumber.set(latestBlock);
|
package/src/config.ts
CHANGED
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
pickConfigMappings,
|
|
10
10
|
secretStringConfigHelper,
|
|
11
11
|
} from '@aztec/foundation/config';
|
|
12
|
-
import { Fr } from '@aztec/foundation/
|
|
12
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
13
|
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
14
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
14
|
+
import { FunctionSelector } from '@aztec/stdlib/abi/function-selector';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
16
|
import { type AllowedElement, type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
17
17
|
|
|
@@ -133,11 +133,8 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
133
133
|
/** Which calls are allowed in the public setup phase of a tx. */
|
|
134
134
|
txPublicSetupAllowList: AllowedElement[];
|
|
135
135
|
|
|
136
|
-
/** The maximum
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/** If the pool is full, it will still accept a few more txs until it reached maxTxPoolOverspillFactor * maxTxPoolSize. Then it will evict */
|
|
140
|
-
txPoolOverflowFactor: number;
|
|
136
|
+
/** The maximum number of pending txs before evicting lower priority txs. */
|
|
137
|
+
maxPendingTxCount: number;
|
|
141
138
|
|
|
142
139
|
/** The node's seen message ID cache size */
|
|
143
140
|
seenMessageCacheSize: number;
|
|
@@ -164,6 +161,12 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
164
161
|
|
|
165
162
|
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
166
163
|
txPoolDeleteTxsAfterReorg: boolean;
|
|
164
|
+
|
|
165
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
166
|
+
debugP2PInstrumentMessages: boolean;
|
|
167
|
+
|
|
168
|
+
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
169
|
+
fishermanMode: boolean;
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
export const DEFAULT_P2P_PORT = 40400;
|
|
@@ -369,15 +372,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
369
372
|
printDefault: () =>
|
|
370
373
|
'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
|
|
371
374
|
},
|
|
372
|
-
|
|
373
|
-
env: '
|
|
374
|
-
description: 'The maximum
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
env: 'P2P_TX_POOL_OVERFLOW_FACTOR',
|
|
379
|
-
description: 'How much the tx pool can overflow before it starts evicting txs. Must be greater than 1',
|
|
380
|
-
...floatConfigHelper(1.1), // 10% overflow
|
|
375
|
+
maxPendingTxCount: {
|
|
376
|
+
env: 'P2P_MAX_PENDING_TX_COUNT',
|
|
377
|
+
description: 'The maximum number of pending txs before evicting lower priority txs.',
|
|
378
|
+
// Worst case scenario: Uncompressed public/private tx is ~ 156kb
|
|
379
|
+
// This implies we are using ~156MB of memory for pending pool
|
|
380
|
+
...numberConfigHelper(1_000),
|
|
381
381
|
},
|
|
382
382
|
seenMessageCacheSize: {
|
|
383
383
|
env: 'P2P_SEEN_MSG_CACHE_SIZE',
|
|
@@ -406,7 +406,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
406
406
|
},
|
|
407
407
|
dropTransactionsProbability: {
|
|
408
408
|
env: 'P2P_DROP_TX_CHANCE',
|
|
409
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
409
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
410
410
|
...floatConfigHelper(0),
|
|
411
411
|
},
|
|
412
412
|
disableTransactions: {
|
|
@@ -420,6 +420,17 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
420
420
|
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
421
421
|
...booleanConfigHelper(false),
|
|
422
422
|
},
|
|
423
|
+
debugP2PInstrumentMessages: {
|
|
424
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
425
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
426
|
+
...booleanConfigHelper(false),
|
|
427
|
+
},
|
|
428
|
+
fishermanMode: {
|
|
429
|
+
env: 'FISHERMAN_MODE',
|
|
430
|
+
description:
|
|
431
|
+
'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
432
|
+
...booleanConfigHelper(false),
|
|
433
|
+
},
|
|
423
434
|
...p2pReqRespConfigMappings,
|
|
424
435
|
...chainConfigMappings,
|
|
425
436
|
...txCollectionConfigMappings,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class AttestationPoolError extends Error {
|
|
2
|
+
constructor(message?: string) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'AttestationPoolError';
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ProposalSlotCapExceededError extends AttestationPoolError {
|
|
9
|
+
constructor(message?: string) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'ProposalSlotCapExceededError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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
|
|
|
3
4
|
/**
|
|
@@ -51,7 +52,7 @@ export interface AttestationPool {
|
|
|
51
52
|
*
|
|
52
53
|
* @param slot - The oldest slot to keep.
|
|
53
54
|
*/
|
|
54
|
-
deleteAttestationsOlderThan(slot:
|
|
55
|
+
deleteAttestationsOlderThan(slot: SlotNumber): Promise<void>;
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
58
|
* Delete Attestations for slot
|
|
@@ -60,7 +61,7 @@ export interface AttestationPool {
|
|
|
60
61
|
*
|
|
61
62
|
* @param slot - The slot to delete.
|
|
62
63
|
*/
|
|
63
|
-
deleteAttestationsForSlot(slot:
|
|
64
|
+
deleteAttestationsForSlot(slot: SlotNumber): Promise<void>;
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* Delete Attestations for slot and proposal
|
|
@@ -70,7 +71,7 @@ export interface AttestationPool {
|
|
|
70
71
|
* @param slot - The slot to delete.
|
|
71
72
|
* @param proposalId - The proposal to delete.
|
|
72
73
|
*/
|
|
73
|
-
deleteAttestationsForSlotAndProposal(slot:
|
|
74
|
+
deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void>;
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* Get all Attestations for all proposals for a given slot
|
|
@@ -80,7 +81,7 @@ export interface AttestationPool {
|
|
|
80
81
|
* @param slot - The slot to query
|
|
81
82
|
* @return BlockAttestations
|
|
82
83
|
*/
|
|
83
|
-
getAttestationsForSlot(slot:
|
|
84
|
+
getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]>;
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
87
|
* Get Attestations for slot and given proposal
|
|
@@ -91,7 +92,7 @@ export interface AttestationPool {
|
|
|
91
92
|
* @param proposalId - The proposal to query
|
|
92
93
|
* @return BlockAttestations
|
|
93
94
|
*/
|
|
94
|
-
getAttestationsForSlotAndProposal(slot:
|
|
95
|
+
getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]>;
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* Check if a specific attestation exists in the pool
|
|
@@ -101,6 +102,29 @@ export interface AttestationPool {
|
|
|
101
102
|
*/
|
|
102
103
|
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
103
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Returns whether adding this proposal is permitted at current capacity:
|
|
107
|
+
* - True if the proposal already exists, allow overwrite to keep parity with tests.
|
|
108
|
+
* - True if the slot is below the proposal cap.
|
|
109
|
+
* - False if the slot is at/above cap and this would be a new unique proposal.
|
|
110
|
+
*
|
|
111
|
+
* @param block - The block proposal to check
|
|
112
|
+
* @returns True if the proposal can be added (or already exists), false otherwise.
|
|
113
|
+
*/
|
|
114
|
+
canAddProposal(block: BlockProposal): Promise<boolean>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns whether an attestation would be accepted for (slot, proposalId):
|
|
118
|
+
* - True if the attestation already exists for this sender.
|
|
119
|
+
* - True if the attestation cap for (slot, proposalId) has not been reached.
|
|
120
|
+
* - False if the cap is reached and this attestation would be a new unique entry.
|
|
121
|
+
*
|
|
122
|
+
* @param attestation - The attestation to check
|
|
123
|
+
* @param committeeSize - Committee size for the attestation's slot, implementation may add a small buffer
|
|
124
|
+
* @returns True if the attestation can be added, false otherwise.
|
|
125
|
+
*/
|
|
126
|
+
canAddAttestation(attestation: BlockAttestation, committeeSize: number): Promise<boolean>;
|
|
127
|
+
|
|
104
128
|
/** Returns whether the pool is empty. */
|
|
105
129
|
isEmpty(): Promise<boolean>;
|
|
106
130
|
}
|