@aztec/p2p 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1
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 +2 -1
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +8 -3
- 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 +11 -34
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +68 -46
- package/dest/config.d.ts +65 -56
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +21 -5
- 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 +3 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +11 -2
- package/dest/mem_pools/interface.d.ts +1 -1
- package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +17 -40
- 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 +103 -44
- package/dest/mem_pools/tx_pool/index.d.ts +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +19 -6
- package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/memory_tx_pool.js +88 -9
- package/dest/mem_pools/tx_pool/priority.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool.d.ts +21 -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 +132 -7
- 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 +56 -9
- 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 +29 -69
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +375 -133
- package/dest/services/peer-manager/interface.d.ts +1 -1
- package/dest/services/peer-manager/metrics.d.ts +3 -1
- package/dest/services/peer-manager/metrics.d.ts.map +1 -1
- package/dest/services/peer-manager/metrics.js +11 -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 +27 -12
- 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 +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 +14 -10
- 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/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 +5 -4
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +8 -4
- package/dest/services/tx_provider_instrumentation.d.ts +1 -1
- package/dest/services/tx_provider_instrumentation.d.ts.map +1 -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 +2 -2
- 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 +16 -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 +17 -3
- package/src/client/interface.ts +8 -5
- package/src/client/p2p_client.ts +88 -74
- package/src/config.ts +33 -6
- 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 +13 -0
- package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +116 -48
- package/src/mem_pools/tx_pool/memory_tx_pool.ts +98 -12
- package/src/mem_pools/tx_pool/tx_pool.ts +20 -5
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +115 -7
- 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 +63 -18
- 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 +427 -157
- package/src/services/peer-manager/metrics.ts +10 -0
- package/src/services/peer-manager/peer_manager.ts +22 -14
- 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/reqresp.ts +15 -11
- package/src/services/service.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 +9 -7
- package/src/test-helpers/make-enrs.ts +1 -1
- package/src/test-helpers/mock-tx-helpers.ts +24 -0
- package/src/test-helpers/reqresp-nodes.ts +3 -2
- package/src/testbench/p2p_client_testbench_worker.ts +12 -5
- package/src/testbench/testbench.ts +2 -2
- package/src/util.ts +12 -2
- package/src/versioning.ts +3 -3
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';
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
trackSpan,
|
|
27
27
|
} from '@aztec/telemetry-client';
|
|
28
28
|
|
|
29
|
-
import type { ENR } from '@chainsafe/enr';
|
|
30
29
|
import type { PeerId } from '@libp2p/interface';
|
|
30
|
+
import type { ENR } from '@nethermindeth/enr';
|
|
31
31
|
|
|
32
32
|
import { type P2PConfig, getP2PDefaultConfig } from '../config.js';
|
|
33
33
|
import type { AttestationPool } from '../mem_pools/attestation_pool/attestation_pool.js';
|
|
@@ -62,10 +62,10 @@ 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;
|
|
@@ -121,9 +121,15 @@ 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
|
-
await this.
|
|
126
|
+
const parentBlock = await this.l2BlockSource.getBlockHeaderByArchive(block.payload.header.lastArchiveRoot);
|
|
127
|
+
if (!parentBlock) {
|
|
128
|
+
this.log.debug(`Cannot collect txs for proposal as parent block not found`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const blockNumber = BlockNumber(parentBlock.getBlockNumber() + 1);
|
|
132
|
+
await this.txProvider.getTxsForBlockProposal(block, blockNumber, { pinnedPeer: sender, deadline });
|
|
127
133
|
return undefined;
|
|
128
134
|
});
|
|
129
135
|
|
|
@@ -156,7 +162,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
156
162
|
return Promise.resolve(this.p2pService.getPeers(includePending));
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
public getL2BlockHash(number:
|
|
165
|
+
public getL2BlockHash(number: BlockNumber): Promise<string | undefined> {
|
|
160
166
|
return this.synchedBlockHashes.getAsync(number);
|
|
161
167
|
}
|
|
162
168
|
|
|
@@ -197,10 +203,12 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
|
|
206
|
+
const genesisHash = GENESIS_BLOCK_HEADER_HASH.toString();
|
|
207
|
+
|
|
200
208
|
return {
|
|
201
|
-
latest: { hash: latestBlockHash
|
|
202
|
-
proven: { hash: provenBlockHash
|
|
203
|
-
finalized: { hash: finalizedBlockHash
|
|
209
|
+
latest: { hash: latestBlockHash ?? genesisHash, number: latestBlockNumber },
|
|
210
|
+
proven: { hash: provenBlockHash ?? genesisHash, number: provenBlockNumber },
|
|
211
|
+
finalized: { hash: finalizedBlockHash ?? genesisHash, number: finalizedBlockNumber },
|
|
204
212
|
};
|
|
205
213
|
}
|
|
206
214
|
|
|
@@ -208,15 +216,16 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
208
216
|
this.log.debug(`Handling block stream event ${event.type}`);
|
|
209
217
|
switch (event.type) {
|
|
210
218
|
case 'blocks-added':
|
|
211
|
-
await this.handleLatestL2Blocks(event.blocks);
|
|
219
|
+
await this.handleLatestL2Blocks(event.blocks.map(b => b.block.toL2Block()));
|
|
212
220
|
break;
|
|
213
221
|
case 'chain-finalized': {
|
|
214
222
|
// TODO (alexg): I think we can prune the block hashes map here
|
|
215
223
|
await this.setBlockHash(event.block);
|
|
216
|
-
const from = (await this.getSyncedFinalizedBlockNum()) + 1;
|
|
224
|
+
const from = BlockNumber((await this.getSyncedFinalizedBlockNum()) + 1);
|
|
217
225
|
const limit = event.block.number - from + 1;
|
|
218
226
|
if (limit > 0) {
|
|
219
|
-
|
|
227
|
+
const oldBlocks = await this.l2BlockSource.getBlocks(from, limit);
|
|
228
|
+
await this.handleFinalizedL2Blocks(oldBlocks.map(b => b.toL2Block()));
|
|
220
229
|
}
|
|
221
230
|
break;
|
|
222
231
|
}
|
|
@@ -278,7 +287,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
278
287
|
(this.attestationPool === undefined || (await this.attestationPool?.isEmpty()))
|
|
279
288
|
) {
|
|
280
289
|
// if mempools are empty, we don't care about syncing prior blocks
|
|
281
|
-
this.initBlockStream(this.latestBlockNumberAtStart);
|
|
290
|
+
this.initBlockStream(BlockNumber(this.latestBlockNumberAtStart));
|
|
282
291
|
this.setCurrentState(P2PClientState.RUNNING);
|
|
283
292
|
this.syncPromise = Promise.resolve();
|
|
284
293
|
await this.p2pService.start();
|
|
@@ -326,7 +335,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
326
335
|
return this.p2pService.addReqRespSubProtocol(subProtocol, handler, validator);
|
|
327
336
|
}
|
|
328
337
|
|
|
329
|
-
private initBlockStream(startingBlock?:
|
|
338
|
+
private initBlockStream(startingBlock?: BlockNumber) {
|
|
330
339
|
if (!this.blockStream) {
|
|
331
340
|
const { blockRequestBatchSize: batchSize, blockCheckIntervalMS: pollIntervalMS } = this.config;
|
|
332
341
|
this.blockStream = new TraceableL2BlockStream(
|
|
@@ -365,17 +374,21 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
365
374
|
}
|
|
366
375
|
|
|
367
376
|
@trackSpan('p2pClient.broadcastProposal', async proposal => ({
|
|
368
|
-
[Attributes.
|
|
369
|
-
[Attributes.SLOT_NUMBER]: proposal.slotNumber.toNumber(),
|
|
377
|
+
[Attributes.SLOT_NUMBER]: proposal.slotNumber,
|
|
370
378
|
[Attributes.BLOCK_ARCHIVE]: proposal.archive.toString(),
|
|
371
|
-
[Attributes.P2P_ID]: (await proposal.
|
|
379
|
+
[Attributes.P2P_ID]: (await proposal.p2pMessageLoggingIdentifier()).toString(),
|
|
372
380
|
}))
|
|
373
381
|
public broadcastProposal(proposal: BlockProposal): Promise<void> {
|
|
374
|
-
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber
|
|
382
|
+
this.log.verbose(`Broadcasting proposal for slot ${proposal.slotNumber} to peers`);
|
|
375
383
|
return this.p2pService.propagate(proposal);
|
|
376
384
|
}
|
|
377
385
|
|
|
378
|
-
public async
|
|
386
|
+
public async broadcastAttestations(attestations: BlockAttestation[]): Promise<void> {
|
|
387
|
+
this.log.verbose(`Broadcasting ${attestations.length} attestations to peers`);
|
|
388
|
+
await Promise.all(attestations.map(att => this.p2pService.propagate(att)));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
public async getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]> {
|
|
379
392
|
return (
|
|
380
393
|
(await (proposalId
|
|
381
394
|
? this.attestationPool?.getAttestationsForSlotAndProposal(slot, proposalId)
|
|
@@ -387,6 +400,10 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
387
400
|
return this.attestationPool?.addAttestations(attestations) ?? Promise.resolve();
|
|
388
401
|
}
|
|
389
402
|
|
|
403
|
+
public deleteAttestation(attestation: BlockAttestation): Promise<void> {
|
|
404
|
+
return this.attestationPool?.deleteAttestations([attestation]) ?? Promise.resolve();
|
|
405
|
+
}
|
|
406
|
+
|
|
390
407
|
// REVIEW: https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
391
408
|
// ^ This pattern is not my favorite (md)
|
|
392
409
|
public registerBlockProposalHandler(handler: P2PBlockReceivedCallback): void {
|
|
@@ -599,7 +616,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
599
616
|
* @param txHash - Hash of the tx to query.
|
|
600
617
|
* @returns Pending or mined depending on its status, or undefined if not found.
|
|
601
618
|
*/
|
|
602
|
-
public getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
|
|
619
|
+
public getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | 'deleted' | undefined> {
|
|
603
620
|
return this.txPool.getTxStatus(txHash);
|
|
604
621
|
}
|
|
605
622
|
|
|
@@ -634,20 +651,20 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
634
651
|
* Public function to check the latest block number that the P2P client is synced to.
|
|
635
652
|
* @returns Block number of latest L2 Block we've synced with.
|
|
636
653
|
*/
|
|
637
|
-
public async getSyncedLatestBlockNum(): Promise<
|
|
638
|
-
return (await this.synchedLatestBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
654
|
+
public async getSyncedLatestBlockNum(): Promise<BlockNumber> {
|
|
655
|
+
return (await this.synchedLatestBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
639
656
|
}
|
|
640
657
|
|
|
641
658
|
/**
|
|
642
659
|
* Public function to check the latest proven block number that the P2P client is synced to.
|
|
643
660
|
* @returns Block number of latest proven L2 Block we've synced with.
|
|
644
661
|
*/
|
|
645
|
-
public async getSyncedProvenBlockNum(): Promise<
|
|
646
|
-
return (await this.synchedProvenBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
662
|
+
public async getSyncedProvenBlockNum(): Promise<BlockNumber> {
|
|
663
|
+
return (await this.synchedProvenBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
647
664
|
}
|
|
648
665
|
|
|
649
|
-
public async getSyncedFinalizedBlockNum(): Promise<
|
|
650
|
-
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? INITIAL_L2_BLOCK_NUM - 1;
|
|
666
|
+
public async getSyncedFinalizedBlockNum(): Promise<BlockNumber> {
|
|
667
|
+
return (await this.synchedFinalizedBlockNumber.getAsync()) ?? BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
651
668
|
}
|
|
652
669
|
|
|
653
670
|
/** Returns latest L2 slot for which we have seen an L2 block. */
|
|
@@ -663,7 +680,7 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
663
680
|
const blockNumber = await this.getSyncedLatestBlockNum();
|
|
664
681
|
const blockHash =
|
|
665
682
|
blockNumber === 0
|
|
666
|
-
?
|
|
683
|
+
? GENESIS_BLOCK_HEADER_HASH.toString()
|
|
667
684
|
: await this.l2BlockSource
|
|
668
685
|
.getBlockHeader(blockNumber)
|
|
669
686
|
.then(header => header?.hash())
|
|
@@ -671,8 +688,8 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
671
688
|
|
|
672
689
|
return {
|
|
673
690
|
state: this.currentState,
|
|
674
|
-
syncedToL2Block: { number: blockNumber, hash: blockHash },
|
|
675
|
-
}
|
|
691
|
+
syncedToL2Block: { number: blockNumber, hash: blockHash! },
|
|
692
|
+
};
|
|
676
693
|
}
|
|
677
694
|
|
|
678
695
|
/**
|
|
@@ -680,58 +697,45 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
680
697
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
681
698
|
* @returns Empty promise.
|
|
682
699
|
*/
|
|
683
|
-
private async markTxsAsMinedFromBlocks(blocks:
|
|
700
|
+
private async markTxsAsMinedFromBlocks(blocks: L2BlockNew[]): Promise<void> {
|
|
684
701
|
for (const block of blocks) {
|
|
685
702
|
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
686
703
|
await this.txPool.markAsMined(txHashes, block.header);
|
|
687
704
|
}
|
|
688
705
|
}
|
|
689
706
|
|
|
690
|
-
/**
|
|
691
|
-
* Deletes txs from these blocks.
|
|
692
|
-
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
693
|
-
* @returns Empty promise.
|
|
694
|
-
*/
|
|
695
|
-
private async deleteTxsFromBlocks(blocks: L2Block[]): Promise<void> {
|
|
696
|
-
this.log.debug(`Deleting txs from blocks ${blocks[0].number} to ${blocks[blocks.length - 1].number}`);
|
|
697
|
-
for (const block of blocks) {
|
|
698
|
-
const txHashes = block.body.txEffects.map(txEffect => txEffect.txHash);
|
|
699
|
-
await this.txPool.deleteTxs(txHashes);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
707
|
/**
|
|
704
708
|
* Handles new mined blocks by marking the txs in them as mined.
|
|
705
709
|
* @param blocks - A list of existing blocks with txs that the P2P client needs to ensure the tx pool is reconciled with.
|
|
706
710
|
* @returns Empty promise.
|
|
707
711
|
*/
|
|
708
|
-
private async handleLatestL2Blocks(blocks:
|
|
712
|
+
private async handleLatestL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
709
713
|
if (!blocks.length) {
|
|
710
714
|
return Promise.resolve();
|
|
711
715
|
}
|
|
712
716
|
|
|
713
|
-
await this.markTxsAsMinedFromBlocks(blocks
|
|
714
|
-
await this.startCollectingMissingTxs(blocks
|
|
717
|
+
await this.markTxsAsMinedFromBlocks(blocks);
|
|
718
|
+
await this.startCollectingMissingTxs(blocks);
|
|
715
719
|
|
|
716
|
-
const lastBlock = blocks.at(-1)
|
|
720
|
+
const lastBlock = blocks.at(-1)!;
|
|
717
721
|
|
|
718
722
|
await Promise.all(
|
|
719
723
|
blocks.map(async block =>
|
|
720
724
|
this.setBlockHash({
|
|
721
|
-
number: block.
|
|
722
|
-
hash: await block.
|
|
725
|
+
number: block.number,
|
|
726
|
+
hash: await block.hash().then(h => h.toString()),
|
|
723
727
|
}),
|
|
724
728
|
),
|
|
725
729
|
);
|
|
726
730
|
|
|
727
731
|
await this.synchedLatestBlockNumber.set(lastBlock.number);
|
|
728
|
-
await this.synchedLatestSlot.set(lastBlock.header.getSlot());
|
|
732
|
+
await this.synchedLatestSlot.set(BigInt(lastBlock.header.getSlot()));
|
|
729
733
|
this.log.verbose(`Synched to latest block ${lastBlock.number}`);
|
|
730
734
|
await this.startServiceIfSynched();
|
|
731
735
|
}
|
|
732
736
|
|
|
733
737
|
/** Request txs for unproven blocks so the prover node has more chances to get them. */
|
|
734
|
-
private async startCollectingMissingTxs(blocks:
|
|
738
|
+
private async startCollectingMissingTxs(blocks: L2BlockNew[]): Promise<void> {
|
|
735
739
|
try {
|
|
736
740
|
// TODO(#15435): If the archiver has lagged behind L1, the reported proven block number may
|
|
737
741
|
// be much lower than the actual one, and it does not update until the pending chain is
|
|
@@ -764,20 +768,24 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
764
768
|
* @param blocks - A list of finalized L2 blocks.
|
|
765
769
|
* @returns Empty promise.
|
|
766
770
|
*/
|
|
767
|
-
private async handleFinalizedL2Blocks(blocks:
|
|
768
|
-
this.log.trace(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
|
|
771
|
+
private async handleFinalizedL2Blocks(blocks: L2BlockNew[]): Promise<void> {
|
|
769
772
|
if (!blocks.length) {
|
|
770
773
|
return Promise.resolve();
|
|
771
774
|
}
|
|
775
|
+
this.log.debug(`Handling finalized blocks ${blocks.length} up to ${blocks.at(-1)?.number}`);
|
|
772
776
|
|
|
773
777
|
const lastBlockNum = blocks[blocks.length - 1].number;
|
|
774
778
|
const lastBlockSlot = blocks[blocks.length - 1].header.getSlot();
|
|
775
779
|
|
|
776
|
-
|
|
780
|
+
const txHashes = blocks.flatMap(block => block.body.txEffects.map(txEffect => txEffect.txHash));
|
|
781
|
+
this.log.debug(`Deleting ${txHashes.length} txs from pool from finalized blocks up to ${lastBlockNum}`);
|
|
782
|
+
await this.txPool.deleteTxs(txHashes, { permanently: true });
|
|
783
|
+
await this.txPool.cleanupDeletedMinedTxs(lastBlockNum);
|
|
784
|
+
|
|
777
785
|
await this.attestationPool?.deleteAttestationsOlderThan(lastBlockSlot);
|
|
778
786
|
|
|
779
787
|
await this.synchedFinalizedBlockNumber.set(lastBlockNum);
|
|
780
|
-
this.log.debug(`Synched to finalized block ${lastBlockNum}`);
|
|
788
|
+
this.log.debug(`Synched to finalized block ${lastBlockNum} at slot ${lastBlockSlot}`);
|
|
781
789
|
|
|
782
790
|
await this.startServiceIfSynched();
|
|
783
791
|
}
|
|
@@ -786,42 +794,48 @@ export class P2PClient<T extends P2PClientType = P2PClientType.Full>
|
|
|
786
794
|
* Updates the tx pool after a chain prune.
|
|
787
795
|
* @param latestBlock - The block number the chain was pruned to.
|
|
788
796
|
*/
|
|
789
|
-
private async handlePruneL2Blocks(latestBlock:
|
|
797
|
+
private async handlePruneL2Blocks(latestBlock: BlockNumber): Promise<void> {
|
|
790
798
|
const txsToDelete = new Map<string, TxHash>();
|
|
791
799
|
const minedTxs = await this.txPool.getMinedTxHashes();
|
|
792
800
|
|
|
793
801
|
// Find transactions that reference pruned blocks in their historical header
|
|
794
802
|
for (const tx of await this.txPool.getAllTxs()) {
|
|
795
803
|
// every tx that's been generated against a block that has now been pruned is no longer valid
|
|
796
|
-
if (tx.data.constants.
|
|
804
|
+
if (tx.data.constants.anchorBlockHeader.globalVariables.blockNumber > latestBlock) {
|
|
797
805
|
const txHash = tx.getTxHash();
|
|
798
806
|
txsToDelete.set(txHash.toString(), txHash);
|
|
799
807
|
}
|
|
800
808
|
}
|
|
801
809
|
|
|
802
|
-
this.log.info(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
);
|
|
810
|
+
this.log.info(`Detected chain prune. Removing ${txsToDelete.size} txs built against pruned blocks.`, {
|
|
811
|
+
newLatestBlock: latestBlock,
|
|
812
|
+
previousLatestBlock: await this.getSyncedLatestBlockNum(),
|
|
813
|
+
txsToDelete: Array.from(txsToDelete.keys()),
|
|
814
|
+
});
|
|
807
815
|
|
|
808
816
|
// delete invalid txs (both pending and mined)
|
|
809
817
|
await this.txPool.deleteTxs(Array.from(txsToDelete.values()));
|
|
810
818
|
|
|
811
819
|
// everything left in the mined set was built against a block on the proven chain so its still valid
|
|
812
|
-
// move back to pending the txs that were reorged out of the chain
|
|
820
|
+
// move back to pending the txs that were reorged out of the chain, unless txPoolDeleteTxsAfterReorg is set,
|
|
821
|
+
// in which case we clean them up to avoid potential reorg loops
|
|
813
822
|
// NOTE: we can't move _all_ txs back to pending because the tx pool could keep hold of mined txs for longer
|
|
814
823
|
// (see this.keepProvenTxsFor)
|
|
815
|
-
|
|
816
|
-
const txsToMoveToPending: TxHash[] = [];
|
|
824
|
+
const minedTxsFromReorg: TxHash[] = [];
|
|
817
825
|
for (const [txHash, blockNumber] of minedTxs) {
|
|
818
|
-
|
|
819
|
-
|
|
826
|
+
// We keep the txsToDelete out of this list as they have already been deleted above
|
|
827
|
+
if (blockNumber > latestBlock && !txsToDelete.has(txHash.toString())) {
|
|
828
|
+
minedTxsFromReorg.push(txHash);
|
|
820
829
|
}
|
|
821
830
|
}
|
|
822
831
|
|
|
823
|
-
this.
|
|
824
|
-
|
|
832
|
+
if (this.config.txPoolDeleteTxsAfterReorg) {
|
|
833
|
+
this.log.info(`Deleting ${minedTxsFromReorg.length} mined txs from reorg`);
|
|
834
|
+
await this.txPool.deleteTxs(minedTxsFromReorg);
|
|
835
|
+
} else {
|
|
836
|
+
this.log.info(`Moving ${minedTxsFromReorg.length} mined txs from reorg back to pending`);
|
|
837
|
+
await this.txPool.markMinedAsPending(minedTxsFromReorg);
|
|
838
|
+
}
|
|
825
839
|
|
|
826
840
|
await this.synchedLatestBlockNumber.set(latestBlock);
|
|
827
841
|
// no need to update block hashes, as they will be updated as new blocks are added
|
package/src/config.ts
CHANGED
|
@@ -9,7 +9,7 @@ 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
14
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
15
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -127,7 +127,7 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
127
127
|
/** A list of preferred peers. */
|
|
128
128
|
preferredPeers: string[];
|
|
129
129
|
|
|
130
|
-
/** The maximum possible size of the P2P DB in KB. Overwrites the general
|
|
130
|
+
/** The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
131
131
|
p2pStoreMapSizeKb?: number;
|
|
132
132
|
|
|
133
133
|
/** Which calls are allowed in the public setup phase of a tx. */
|
|
@@ -161,6 +161,15 @@ export interface P2PConfig extends P2PReqRespConfig, ChainConfig, TxCollectionCo
|
|
|
161
161
|
|
|
162
162
|
/** The probability that a transaction is discarded. - For testing purposes only */
|
|
163
163
|
dropTransactionsProbability: number;
|
|
164
|
+
|
|
165
|
+
/** Whether to delete transactions from the pool after a reorg instead of moving them back to pending. */
|
|
166
|
+
txPoolDeleteTxsAfterReorg: boolean;
|
|
167
|
+
|
|
168
|
+
/** Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY */
|
|
169
|
+
debugP2PInstrumentMessages: boolean;
|
|
170
|
+
|
|
171
|
+
/** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
|
|
172
|
+
fishermanMode: boolean;
|
|
164
173
|
}
|
|
165
174
|
|
|
166
175
|
export const DEFAULT_P2P_PORT = 40400;
|
|
@@ -357,7 +366,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
357
366
|
p2pStoreMapSizeKb: {
|
|
358
367
|
env: 'P2P_STORE_MAP_SIZE_KB',
|
|
359
368
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
360
|
-
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general
|
|
369
|
+
description: 'The maximum possible size of the P2P DB in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
361
370
|
},
|
|
362
371
|
txPublicSetupAllowList: {
|
|
363
372
|
env: 'TX_PUBLIC_SETUP_ALLOWLIST',
|
|
@@ -403,7 +412,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
403
412
|
},
|
|
404
413
|
dropTransactionsProbability: {
|
|
405
414
|
env: 'P2P_DROP_TX_CHANCE',
|
|
406
|
-
description: 'The probability that a transaction is discarded. - For testing purposes only',
|
|
415
|
+
description: 'The probability that a transaction is discarded (0 - 1). - For testing purposes only',
|
|
407
416
|
...floatConfigHelper(0),
|
|
408
417
|
},
|
|
409
418
|
disableTransactions: {
|
|
@@ -412,6 +421,22 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
|
|
|
412
421
|
'Whether transactions are disabled for this node. This means transactions will be rejected at the RPC and P2P layers.',
|
|
413
422
|
...booleanConfigHelper(false),
|
|
414
423
|
},
|
|
424
|
+
txPoolDeleteTxsAfterReorg: {
|
|
425
|
+
env: 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG',
|
|
426
|
+
description: 'Whether to delete transactions from the pool after a reorg instead of moving them back to pending.',
|
|
427
|
+
...booleanConfigHelper(false),
|
|
428
|
+
},
|
|
429
|
+
debugP2PInstrumentMessages: {
|
|
430
|
+
env: 'DEBUG_P2P_INSTRUMENT_MESSAGES',
|
|
431
|
+
description: 'Alters the format of p2p messages to include things like broadcast timestamp FOR TESTING ONLY',
|
|
432
|
+
...booleanConfigHelper(false),
|
|
433
|
+
},
|
|
434
|
+
fishermanMode: {
|
|
435
|
+
env: 'FISHERMAN_MODE',
|
|
436
|
+
description:
|
|
437
|
+
'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
|
|
438
|
+
...booleanConfigHelper(false),
|
|
439
|
+
},
|
|
415
440
|
...p2pReqRespConfigMappings,
|
|
416
441
|
...chainConfigMappings,
|
|
417
442
|
...txCollectionConfigMappings,
|
|
@@ -441,9 +466,10 @@ export type BootnodeConfig = Pick<
|
|
|
441
466
|
| 'peerIdPrivateKeyPath'
|
|
442
467
|
| 'bootstrapNodes'
|
|
443
468
|
| 'listenAddress'
|
|
469
|
+
| 'queryForIp'
|
|
444
470
|
> &
|
|
445
471
|
Required<Pick<P2PConfig, 'p2pIp' | 'p2pPort'>> &
|
|
446
|
-
Pick<DataStoreConfig, 'dataDirectory' | '
|
|
472
|
+
Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb'> &
|
|
447
473
|
Pick<ChainConfig, 'l1ChainId'>;
|
|
448
474
|
|
|
449
475
|
const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
|
|
@@ -454,9 +480,10 @@ const bootnodeConfigKeys: (keyof BootnodeConfig)[] = [
|
|
|
454
480
|
'peerIdPrivateKey',
|
|
455
481
|
'peerIdPrivateKeyPath',
|
|
456
482
|
'dataDirectory',
|
|
457
|
-
'
|
|
483
|
+
'dataStoreMapSizeKb',
|
|
458
484
|
'bootstrapNodes',
|
|
459
485
|
'l1ChainId',
|
|
486
|
+
'queryForIp',
|
|
460
487
|
];
|
|
461
488
|
|
|
462
489
|
export const bootnodeConfigMappings = pickConfigMappings(
|
package/src/enr/generate-enr.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
2
2
|
import { type ChainConfig, emptyChainConfig } from '@aztec/stdlib/config';
|
|
3
3
|
import type { ComponentsVersions } from '@aztec/stdlib/versioning';
|
|
4
4
|
|
|
5
|
-
import { ENR, SignableENR } from '@chainsafe/enr';
|
|
6
5
|
import type { PeerId } from '@libp2p/interface';
|
|
7
6
|
import { type Multiaddr, multiaddr } from '@multiformats/multiaddr';
|
|
7
|
+
import { ENR, SignableENR } from '@nethermindeth/enr';
|
|
8
8
|
|
|
9
9
|
import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from '../types/index.js';
|
|
10
10
|
import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
|
|
@@ -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
|
/**
|
|
@@ -21,6 +22,15 @@ export interface AttestationPool {
|
|
|
21
22
|
*/
|
|
22
23
|
getBlockProposal(id: string): Promise<BlockProposal | undefined>;
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Check if a block proposal exists in the pool
|
|
27
|
+
*
|
|
28
|
+
* @param idOrProposal - The ID of the block proposal or the block proposal itself to check. The ID is proposal.payload.archive
|
|
29
|
+
*
|
|
30
|
+
* @return True if the block proposal exists, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
hasBlockProposal(idOrProposal: string | BlockProposal): Promise<boolean>;
|
|
33
|
+
|
|
24
34
|
/**
|
|
25
35
|
* AddAttestations
|
|
26
36
|
*
|
|
@@ -42,7 +52,7 @@ export interface AttestationPool {
|
|
|
42
52
|
*
|
|
43
53
|
* @param slot - The oldest slot to keep.
|
|
44
54
|
*/
|
|
45
|
-
deleteAttestationsOlderThan(slot:
|
|
55
|
+
deleteAttestationsOlderThan(slot: SlotNumber): Promise<void>;
|
|
46
56
|
|
|
47
57
|
/**
|
|
48
58
|
* Delete Attestations for slot
|
|
@@ -51,7 +61,7 @@ export interface AttestationPool {
|
|
|
51
61
|
*
|
|
52
62
|
* @param slot - The slot to delete.
|
|
53
63
|
*/
|
|
54
|
-
deleteAttestationsForSlot(slot:
|
|
64
|
+
deleteAttestationsForSlot(slot: SlotNumber): Promise<void>;
|
|
55
65
|
|
|
56
66
|
/**
|
|
57
67
|
* Delete Attestations for slot and proposal
|
|
@@ -61,7 +71,7 @@ export interface AttestationPool {
|
|
|
61
71
|
* @param slot - The slot to delete.
|
|
62
72
|
* @param proposalId - The proposal to delete.
|
|
63
73
|
*/
|
|
64
|
-
deleteAttestationsForSlotAndProposal(slot:
|
|
74
|
+
deleteAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<void>;
|
|
65
75
|
|
|
66
76
|
/**
|
|
67
77
|
* Get all Attestations for all proposals for a given slot
|
|
@@ -71,7 +81,7 @@ export interface AttestationPool {
|
|
|
71
81
|
* @param slot - The slot to query
|
|
72
82
|
* @return BlockAttestations
|
|
73
83
|
*/
|
|
74
|
-
getAttestationsForSlot(slot:
|
|
84
|
+
getAttestationsForSlot(slot: SlotNumber): Promise<BlockAttestation[]>;
|
|
75
85
|
|
|
76
86
|
/**
|
|
77
87
|
* Get Attestations for slot and given proposal
|
|
@@ -82,7 +92,38 @@ export interface AttestationPool {
|
|
|
82
92
|
* @param proposalId - The proposal to query
|
|
83
93
|
* @return BlockAttestations
|
|
84
94
|
*/
|
|
85
|
-
getAttestationsForSlotAndProposal(slot:
|
|
95
|
+
getAttestationsForSlotAndProposal(slot: SlotNumber, proposalId: string): Promise<BlockAttestation[]>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if a specific attestation exists in the pool
|
|
99
|
+
*
|
|
100
|
+
* @param attestation - The attestation to check
|
|
101
|
+
* @return True if the attestation exists, false otherwise
|
|
102
|
+
*/
|
|
103
|
+
hasAttestation(attestation: BlockAttestation): Promise<boolean>;
|
|
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>;
|
|
86
127
|
|
|
87
128
|
/** Returns whether the pool is empty. */
|
|
88
129
|
isEmpty(): Promise<boolean>;
|