@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
|
@@ -4,19 +4,20 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
-
import {
|
|
7
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
|
+
import { randomInt } from '@aztec/foundation/crypto/random';
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
10
|
import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
9
|
-
import { SerialQueue } from '@aztec/foundation/queue';
|
|
10
11
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
11
12
|
import { Timer } from '@aztec/foundation/timer';
|
|
12
|
-
import {
|
|
13
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
14
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
13
15
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
14
16
|
import { BlockAttestation, BlockProposal, P2PClientType, P2PMessage, PeerErrorSeverity, TopicType, createTopicString, getTopicsForClientAndConfig, metricsTopicStrToLabels } from '@aztec/stdlib/p2p';
|
|
15
17
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
16
18
|
import { Tx } from '@aztec/stdlib/tx';
|
|
17
19
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
18
20
|
import { Attributes, OtelMetricsAdapter, WithTracer, trackSpan } from '@aztec/telemetry-client';
|
|
19
|
-
import { ENR } from '@chainsafe/enr';
|
|
20
21
|
import { gossipsub } from '@chainsafe/libp2p-gossipsub';
|
|
21
22
|
import { createPeerScoreParams, createTopicScoreParams } from '@chainsafe/libp2p-gossipsub/score';
|
|
22
23
|
import { SignaturePolicy } from '@chainsafe/libp2p-gossipsub/types';
|
|
@@ -25,15 +26,16 @@ import { yamux } from '@chainsafe/libp2p-yamux';
|
|
|
25
26
|
import { bootstrap } from '@libp2p/bootstrap';
|
|
26
27
|
import { identify } from '@libp2p/identify';
|
|
27
28
|
import { TopicValidatorResult } from '@libp2p/interface';
|
|
28
|
-
import '@libp2p/kad-dht';
|
|
29
29
|
import { mplex } from '@libp2p/mplex';
|
|
30
30
|
import { tcp } from '@libp2p/tcp';
|
|
31
|
+
import { ENR } from '@nethermindeth/enr';
|
|
31
32
|
import { createLibp2p } from 'libp2p';
|
|
32
|
-
import {
|
|
33
|
+
import { ProposalSlotCapExceededError } from '../../errors/attestation-pool.error.js';
|
|
34
|
+
import { AttestationValidator, BlockProposalValidator, FishermanAttestationValidator } from '../../msg_validators/index.js';
|
|
33
35
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
34
36
|
import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
|
|
35
37
|
import { createTxMessageValidators } from '../../msg_validators/tx_validator/factory.js';
|
|
36
|
-
import { DoubleSpendTxValidator, TxProofValidator } from '../../msg_validators/tx_validator/index.js';
|
|
38
|
+
import { AggregateTxValidator, DataTxValidator, DoubleSpendTxValidator, MetadataTxValidator, TxProofValidator } from '../../msg_validators/tx_validator/index.js';
|
|
37
39
|
import { GossipSubEvent } from '../../types/index.js';
|
|
38
40
|
import { convertToMultiaddr } from '../../util.js';
|
|
39
41
|
import { getVersions } from '../../versioning.js';
|
|
@@ -63,8 +65,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
63
65
|
epochCache;
|
|
64
66
|
proofVerifier;
|
|
65
67
|
worldStateSynchronizer;
|
|
66
|
-
logger;
|
|
67
|
-
jobQueue;
|
|
68
68
|
discoveryRunningPromise;
|
|
69
69
|
msgIdSeenValidators;
|
|
70
70
|
// Message validators
|
|
@@ -80,8 +80,11 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
80
80
|
*/ blockReceivedCallback;
|
|
81
81
|
gossipSubEventHandler;
|
|
82
82
|
instrumentation;
|
|
83
|
+
logger;
|
|
83
84
|
constructor(clientType, config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:libp2p_service')){
|
|
84
|
-
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.
|
|
85
|
+
super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.reqresp = reqresp, this.peerManager = peerManager, this.mempools = mempools, this.archiver = archiver, this.epochCache = epochCache, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.msgIdSeenValidators = {}, this.protocolVersion = '', this.topicStrings = {};
|
|
86
|
+
// Create child logger with fisherman prefix if in fisherman mode
|
|
87
|
+
this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
|
|
85
88
|
this.instrumentation = new P2PInstrumentation(telemetry, 'LibP2PService');
|
|
86
89
|
this.msgIdSeenValidators[TopicType.tx] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
87
90
|
this.msgIdSeenValidators[TopicType.block_proposal] = new MessageSeenValidator(config.seenMessageCacheSize);
|
|
@@ -92,12 +95,15 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
92
95
|
this.topicStrings[TopicType.tx] = createTopicString(TopicType.tx, this.protocolVersion);
|
|
93
96
|
this.topicStrings[TopicType.block_proposal] = createTopicString(TopicType.block_proposal, this.protocolVersion);
|
|
94
97
|
this.topicStrings[TopicType.block_attestation] = createTopicString(TopicType.block_attestation, this.protocolVersion);
|
|
95
|
-
|
|
96
|
-
this.
|
|
98
|
+
// Use FishermanAttestationValidator in fisherman mode to validate attestation payloads against proposals
|
|
99
|
+
this.attestationValidator = config.fishermanMode ? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry) : new AttestationValidator(epochCache);
|
|
100
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
101
|
+
txsPermitted: !config.disableTransactions
|
|
102
|
+
});
|
|
97
103
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
98
104
|
this.blockReceivedCallback = async (block)=>{
|
|
99
|
-
this.logger.debug(`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber
|
|
100
|
-
p2pMessageIdentifier: await block.
|
|
105
|
+
this.logger.debug(`Handler not yet registered: Block received callback not set. Received block for slot ${block.slotNumber} from peer.`, {
|
|
106
|
+
p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier()
|
|
101
107
|
});
|
|
102
108
|
return undefined;
|
|
103
109
|
};
|
|
@@ -165,7 +171,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
165
171
|
// The connection attempts to the node on TCP layer are not necessarily valid Aztec peers so we want to have a bit of leeway here
|
|
166
172
|
// If we hit the limit, the connection will be temporarily accepted and immediately dropped.
|
|
167
173
|
// Docs: https://nodejs.org/api/net.html#servermaxconnections
|
|
168
|
-
maxConnections:
|
|
174
|
+
maxConnections: maxPeerCount * 2,
|
|
169
175
|
// socket option: the maximum length of the queue of pending connections
|
|
170
176
|
// https://nodejs.org/dist/latest-v22.x/docs/api/net.html#serverlisten
|
|
171
177
|
// it's not safe if we increase this number
|
|
@@ -176,7 +182,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
176
182
|
// In case closeAbove is reached, the server stops listening altogether
|
|
177
183
|
// It's important that there is enough difference between closeAbove and listenAbove,
|
|
178
184
|
// otherwise the server.listener will flap between being closed and open potentially degrading perf even more
|
|
179
|
-
closeAbove: maxPeerCount *
|
|
185
|
+
closeAbove: maxPeerCount * 3,
|
|
180
186
|
listenBelow: Math.floor(maxPeerCount * 0.9)
|
|
181
187
|
}
|
|
182
188
|
})
|
|
@@ -192,7 +198,9 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
192
198
|
],
|
|
193
199
|
connectionManager: {
|
|
194
200
|
minConnections: 0,
|
|
195
|
-
maxConnections
|
|
201
|
+
// We set maxConnections above maxPeerCount because if we hit limit of maxPeerCount
|
|
202
|
+
// libp2p will start aggressively rejecting all new connections, preventing network discovery and crawling.
|
|
203
|
+
maxConnections: maxPeerCount * 2,
|
|
196
204
|
maxParallelDials: 100,
|
|
197
205
|
dialTimeout: 30_000,
|
|
198
206
|
maxPeerAddrsToDial: 5,
|
|
@@ -273,7 +281,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
273
281
|
},
|
|
274
282
|
logger: createLibp2pComponentLogger(logger.module)
|
|
275
283
|
});
|
|
276
|
-
const peerScoring = new PeerScoring(config);
|
|
284
|
+
const peerScoring = new PeerScoring(config, telemetry);
|
|
277
285
|
const reqresp = new ReqResp(config, node, peerScoring, createLogger(`${logger.module}:reqresp`));
|
|
278
286
|
const peerManager = new PeerManager(node, peerDiscoveryService, config, telemetry, createLogger(`${logger.module}:peer_manager`), peerScoring, reqresp, worldStateSynchronizer, protocolVersion, epochCache);
|
|
279
287
|
// Update gossipsub score params
|
|
@@ -295,8 +303,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
295
303
|
throw new Error('Announce address not provided.');
|
|
296
304
|
}
|
|
297
305
|
const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
|
|
298
|
-
// Start job queue, peer discovery service and libp2p node
|
|
299
|
-
this.jobQueue.start();
|
|
300
306
|
await this.peerManager.initializePeers();
|
|
301
307
|
if (!this.config.p2pDiscoveryDisabled) {
|
|
302
308
|
await this.peerDiscoveryService.start();
|
|
@@ -311,10 +317,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
311
317
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
312
318
|
const blockHandler = reqRespBlockHandler(this.archiver);
|
|
313
319
|
const statusHandler = reqRespStatusHandler(this.protocolVersion, this.worldStateSynchronizer, this.logger);
|
|
314
|
-
// In case P2P client doesnt'have attestation pool,
|
|
315
|
-
// const blockTxsHandler = this.mempools.attestationPool
|
|
316
|
-
// ? reqRespBlockTxsHandler(this.mempools.attestationPool, this.mempools.txPool)
|
|
317
|
-
// : def;
|
|
318
320
|
const requestResponseHandlers = {
|
|
319
321
|
[ReqRespSubProtocol.PING]: pingHandler,
|
|
320
322
|
[ReqRespSubProtocol.STATUS]: statusHandler.bind(this),
|
|
@@ -322,7 +324,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
322
324
|
[ReqRespSubProtocol.BLOCK]: blockHandler.bind(this)
|
|
323
325
|
};
|
|
324
326
|
// Only handle block transactions request if attestation pool is available to the client
|
|
325
|
-
if (this.mempools.attestationPool) {
|
|
327
|
+
if (this.mempools.attestationPool && !this.config.disableTransactions) {
|
|
326
328
|
const blockTxsHandler = reqRespBlockTxsHandler(this.mempools.attestationPool, this.mempools.txPool);
|
|
327
329
|
requestResponseHandlers[ReqRespSubProtocol.BLOCK_TXS] = blockTxsHandler.bind(this);
|
|
328
330
|
}
|
|
@@ -331,14 +333,17 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
331
333
|
}
|
|
332
334
|
// add GossipSub listener
|
|
333
335
|
this.node.services.pubsub.addEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
|
|
334
|
-
// Start running promise for peer discovery
|
|
335
|
-
this.discoveryRunningPromise = new RunningPromise(()=>
|
|
336
|
+
// Start running promise for peer discovery and metrics collection
|
|
337
|
+
this.discoveryRunningPromise = new RunningPromise(async ()=>{
|
|
338
|
+
await this.peerManager.heartbeat();
|
|
339
|
+
}, this.logger, this.config.peerCheckIntervalMS);
|
|
336
340
|
this.discoveryRunningPromise.start();
|
|
337
341
|
// Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
|
|
338
342
|
const reqrespSubProtocolValidators = {
|
|
339
343
|
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
340
|
-
|
|
341
|
-
[ReqRespSubProtocol.
|
|
344
|
+
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
345
|
+
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this),
|
|
346
|
+
[ReqRespSubProtocol.BLOCK]: this.validateRequestedBlock.bind(this)
|
|
342
347
|
};
|
|
343
348
|
await this.reqresp.start(requestResponseHandlers, reqrespSubProtocolValidators);
|
|
344
349
|
this.logger.info(`Started P2P service`, {
|
|
@@ -357,8 +362,6 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
357
362
|
// Stop peer manager
|
|
358
363
|
this.logger.debug('Stopping peer manager...');
|
|
359
364
|
await this.peerManager.stop();
|
|
360
|
-
this.logger.debug('Stopping job queue...');
|
|
361
|
-
await this.jobQueue.end();
|
|
362
365
|
this.logger.debug('Stopping running promise...');
|
|
363
366
|
await this.discoveryRunningPromise?.stop();
|
|
364
367
|
this.logger.debug('Stopping peer discovery service...');
|
|
@@ -424,15 +427,15 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
424
427
|
if (!this.node.services.pubsub) {
|
|
425
428
|
throw new Error('Pubsub service not available.');
|
|
426
429
|
}
|
|
427
|
-
const p2pMessage =
|
|
428
|
-
this.logger.debug(`Publishing message`, {
|
|
429
|
-
topic,
|
|
430
|
-
messageId: p2pMessage.id
|
|
431
|
-
});
|
|
430
|
+
const p2pMessage = P2PMessage.fromGossipable(message, this.config.debugP2PInstrumentMessages);
|
|
432
431
|
const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
|
|
433
432
|
return result.recipients.length;
|
|
434
433
|
}
|
|
435
|
-
|
|
434
|
+
/**
|
|
435
|
+
* Checks if this message has already been seen, based on its msgId computed from hashing the message data.
|
|
436
|
+
* Note that we do not rely on the seenCache from gossipsub since we want to keep a longer history of seen
|
|
437
|
+
* messages to avoid tx echoes across the network.
|
|
438
|
+
*/ preValidateReceivedMessage(msg, msgId, source) {
|
|
436
439
|
let topicType;
|
|
437
440
|
switch(msg.topic){
|
|
438
441
|
case this.topicStrings[TopicType.tx]:
|
|
@@ -464,66 +467,108 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
464
467
|
};
|
|
465
468
|
}
|
|
466
469
|
/**
|
|
470
|
+
* Safely deserializes a P2PMessage from raw message data.
|
|
471
|
+
* @param msgId - The message ID.
|
|
472
|
+
* @param source - The peer ID of the message source.
|
|
473
|
+
* @param data - The raw message data.
|
|
474
|
+
* @returns The deserialized P2PMessage or undefined if deserialization fails.
|
|
475
|
+
*/ safelyDeserializeP2PMessage(msgId, source, data) {
|
|
476
|
+
try {
|
|
477
|
+
return P2PMessage.fromMessageData(Buffer.from(data), this.config.debugP2PInstrumentMessages);
|
|
478
|
+
} catch (err) {
|
|
479
|
+
this.logger.error(`Error deserializing P2PMessage`, err, {
|
|
480
|
+
msgId,
|
|
481
|
+
source: source.toString()
|
|
482
|
+
});
|
|
483
|
+
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Reject);
|
|
484
|
+
this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
|
|
485
|
+
return undefined;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
467
489
|
* Handles a new gossip message that was received by the client.
|
|
468
490
|
* @param topic - The message's topic.
|
|
469
491
|
* @param data - The message data
|
|
470
492
|
*/ async handleNewGossipMessage(msg, msgId, source) {
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
messageLatency
|
|
478
|
-
});
|
|
493
|
+
const msgReceivedTime = Date.now();
|
|
494
|
+
let topicType;
|
|
495
|
+
const p2pMessage = this.safelyDeserializeP2PMessage(msgId, source, msg.data);
|
|
496
|
+
if (!p2pMessage) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
479
499
|
const preValidationResult = this.preValidateReceivedMessage(msg, msgId, source);
|
|
480
500
|
if (!preValidationResult.result) {
|
|
481
501
|
return;
|
|
482
|
-
} else if (preValidationResult.topicType !== undefined) {
|
|
483
|
-
// guard against clock skew & DST
|
|
484
|
-
if (messageLatency > 0) {
|
|
485
|
-
this.instrumentation.recordMessageLatency(preValidationResult.topicType, messageLatency);
|
|
486
|
-
}
|
|
487
502
|
}
|
|
488
503
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
504
|
+
topicType = TopicType.tx;
|
|
489
505
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
490
506
|
}
|
|
491
|
-
if (msg.topic === this.topicStrings[TopicType.block_attestation]
|
|
492
|
-
|
|
507
|
+
if (msg.topic === this.topicStrings[TopicType.block_attestation]) {
|
|
508
|
+
topicType = TopicType.block_attestation;
|
|
509
|
+
if (this.clientType === P2PClientType.Full) {
|
|
510
|
+
await this.processAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
511
|
+
}
|
|
493
512
|
}
|
|
494
513
|
if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
514
|
+
topicType = TopicType.block_proposal;
|
|
495
515
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
496
516
|
}
|
|
517
|
+
if (p2pMessage.timestamp !== undefined && topicType !== undefined) {
|
|
518
|
+
const latency = msgReceivedTime - p2pMessage.timestamp.getTime();
|
|
519
|
+
this.instrumentation.recordMessageLatency(topicType, latency);
|
|
520
|
+
}
|
|
497
521
|
return;
|
|
498
522
|
}
|
|
499
523
|
async validateReceivedMessage(validationFunc, msgId, source, topicType) {
|
|
500
524
|
let resultAndObj = {
|
|
501
|
-
result:
|
|
502
|
-
obj: undefined
|
|
525
|
+
result: TopicValidatorResult.Reject
|
|
503
526
|
};
|
|
504
527
|
const timer = new Timer();
|
|
505
528
|
try {
|
|
506
529
|
resultAndObj = await validationFunc();
|
|
507
530
|
} catch (err) {
|
|
508
|
-
this.
|
|
531
|
+
this.peerManager.penalizePeer(source, PeerErrorSeverity.LowToleranceError);
|
|
532
|
+
this.logger.error(`Error deserializing and validating gossipsub message`, err, {
|
|
533
|
+
msgId,
|
|
534
|
+
source: source.toString(),
|
|
535
|
+
topicType
|
|
536
|
+
});
|
|
509
537
|
}
|
|
510
|
-
if (resultAndObj.result) {
|
|
538
|
+
if (resultAndObj.result === TopicValidatorResult.Accept) {
|
|
511
539
|
this.instrumentation.recordMessageValidation(topicType, timer);
|
|
512
540
|
}
|
|
513
|
-
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result
|
|
541
|
+
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result);
|
|
514
542
|
return resultAndObj;
|
|
515
543
|
}
|
|
516
544
|
async handleGossipedTx(payloadData, msgId, source) {
|
|
517
545
|
const validationFunc = async ()=>{
|
|
518
546
|
const tx = Tx.fromBuffer(payloadData);
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
547
|
+
const isValid = await this.validatePropagatedTx(tx, source);
|
|
548
|
+
const exists = isValid && await this.mempools.txPool.hasTx(tx.getTxHash());
|
|
549
|
+
this.logger.trace(`Validate propagated tx`, {
|
|
550
|
+
isValid,
|
|
551
|
+
exists,
|
|
552
|
+
[Attributes.P2P_ID]: source.toString()
|
|
553
|
+
});
|
|
554
|
+
if (!isValid) {
|
|
555
|
+
return {
|
|
556
|
+
result: TopicValidatorResult.Reject
|
|
557
|
+
};
|
|
558
|
+
} else if (exists) {
|
|
559
|
+
return {
|
|
560
|
+
result: TopicValidatorResult.Ignore,
|
|
561
|
+
obj: tx
|
|
562
|
+
};
|
|
563
|
+
} else {
|
|
564
|
+
return {
|
|
565
|
+
result: TopicValidatorResult.Accept,
|
|
566
|
+
obj: tx
|
|
567
|
+
};
|
|
568
|
+
}
|
|
524
569
|
};
|
|
525
570
|
const { result, obj: tx } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.tx);
|
|
526
|
-
if (
|
|
571
|
+
if (result !== TopicValidatorResult.Accept || !tx) {
|
|
527
572
|
return;
|
|
528
573
|
}
|
|
529
574
|
const txHash = tx.getTxHash();
|
|
@@ -533,9 +578,10 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
533
578
|
txHash: txHashString
|
|
534
579
|
});
|
|
535
580
|
if (this.config.dropTransactions && randomInt(1000) < this.config.dropTransactionsProbability * 1000) {
|
|
536
|
-
this.logger.
|
|
581
|
+
this.logger.warn(`Intentionally dropping tx ${txHashString} (probability rule)`);
|
|
537
582
|
return;
|
|
538
583
|
}
|
|
584
|
+
this.instrumentation.incrementTxReceived(1);
|
|
539
585
|
await this.mempools.txPool.addTxs([
|
|
540
586
|
tx
|
|
541
587
|
]);
|
|
@@ -548,25 +594,57 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
548
594
|
*/ async processAttestationFromPeer(payloadData, msgId, source) {
|
|
549
595
|
const validationFunc = async ()=>{
|
|
550
596
|
const attestation = BlockAttestation.fromBuffer(payloadData);
|
|
551
|
-
const
|
|
552
|
-
this.
|
|
597
|
+
const pool = this.mempools.attestationPool;
|
|
598
|
+
const isValid = await this.validateAttestation(source, attestation);
|
|
599
|
+
const exists = isValid && await pool.hasAttestation(attestation);
|
|
600
|
+
let canAdd = true;
|
|
601
|
+
if (isValid && !exists) {
|
|
602
|
+
const slot = attestation.payload.header.slotNumber;
|
|
603
|
+
const { committee } = await this.epochCache.getCommittee(slot);
|
|
604
|
+
const committeeSize = committee?.length ?? 0;
|
|
605
|
+
canAdd = await pool.canAddAttestation(attestation, committeeSize);
|
|
606
|
+
}
|
|
607
|
+
this.logger.trace(`Validate propagated block attestation`, {
|
|
608
|
+
isValid,
|
|
609
|
+
exists,
|
|
610
|
+
canAdd,
|
|
553
611
|
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toString(),
|
|
554
612
|
[Attributes.P2P_ID]: source.toString()
|
|
555
613
|
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
614
|
+
if (!isValid) {
|
|
615
|
+
return {
|
|
616
|
+
result: TopicValidatorResult.Reject
|
|
617
|
+
};
|
|
618
|
+
} else if (exists) {
|
|
619
|
+
return {
|
|
620
|
+
result: TopicValidatorResult.Ignore,
|
|
621
|
+
obj: attestation
|
|
622
|
+
};
|
|
623
|
+
} else if (!canAdd) {
|
|
624
|
+
this.logger.warn(`Dropping block attestation due to per-(slot, proposalId) attestation cap`, {
|
|
625
|
+
slot: attestation.payload.header.slotNumber.toString(),
|
|
626
|
+
archive: attestation.archive.toString(),
|
|
627
|
+
source: source.toString()
|
|
628
|
+
});
|
|
629
|
+
return {
|
|
630
|
+
result: TopicValidatorResult.Ignore,
|
|
631
|
+
obj: attestation
|
|
632
|
+
};
|
|
633
|
+
} else {
|
|
634
|
+
return {
|
|
635
|
+
result: TopicValidatorResult.Accept,
|
|
636
|
+
obj: attestation
|
|
637
|
+
};
|
|
638
|
+
}
|
|
560
639
|
};
|
|
561
640
|
const { result, obj: attestation } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.block_attestation);
|
|
562
|
-
if (
|
|
641
|
+
if (result !== TopicValidatorResult.Accept || !attestation) {
|
|
563
642
|
return;
|
|
564
643
|
}
|
|
565
|
-
this.logger.debug(`Received attestation for
|
|
566
|
-
p2pMessageIdentifier: await attestation.
|
|
567
|
-
slot: attestation.slotNumber
|
|
644
|
+
this.logger.debug(`Received attestation for slot ${attestation.slotNumber} from external peer ${source.toString()}`, {
|
|
645
|
+
p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
|
|
646
|
+
slot: attestation.slotNumber,
|
|
568
647
|
archive: attestation.archive.toString(),
|
|
569
|
-
block: attestation.blockNumber,
|
|
570
648
|
source: source.toString()
|
|
571
649
|
});
|
|
572
650
|
await this.mempools.attestationPool.addAttestations([
|
|
@@ -576,15 +654,44 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
576
654
|
async processBlockFromPeer(payloadData, msgId, source) {
|
|
577
655
|
const validationFunc = async ()=>{
|
|
578
656
|
const block = BlockProposal.fromBuffer(payloadData);
|
|
579
|
-
const
|
|
580
|
-
this.
|
|
657
|
+
const isValid = await this.validateBlockProposal(source, block);
|
|
658
|
+
const pool = this.mempools.attestationPool;
|
|
659
|
+
// Note that we dont have an attestation pool if we're a prover node, but we still
|
|
660
|
+
// subscribe to block proposal topics in order to prevent their txs from being cleared.
|
|
661
|
+
const exists = isValid && await pool?.hasBlockProposal(block);
|
|
662
|
+
const canAdd = isValid && await pool?.canAddProposal(block);
|
|
663
|
+
this.logger.trace(`Validate propagated block proposal`, {
|
|
664
|
+
isValid,
|
|
665
|
+
exists,
|
|
666
|
+
canAdd,
|
|
581
667
|
[Attributes.SLOT_NUMBER]: block.payload.header.slotNumber.toString(),
|
|
582
668
|
[Attributes.P2P_ID]: source.toString()
|
|
583
669
|
});
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
670
|
+
if (!isValid) {
|
|
671
|
+
return {
|
|
672
|
+
result: TopicValidatorResult.Reject
|
|
673
|
+
};
|
|
674
|
+
} else if (exists) {
|
|
675
|
+
return {
|
|
676
|
+
result: TopicValidatorResult.Ignore,
|
|
677
|
+
obj: block
|
|
678
|
+
};
|
|
679
|
+
} else if (!canAdd) {
|
|
680
|
+
this.peerManager.penalizePeer(source, PeerErrorSeverity.MidToleranceError);
|
|
681
|
+
this.logger.warn(`Penalizing peer for block proposal exceeding per-slot cap`, {
|
|
682
|
+
slot: block.slotNumber.toString(),
|
|
683
|
+
archive: block.archive.toString(),
|
|
684
|
+
source: source.toString()
|
|
685
|
+
});
|
|
686
|
+
return {
|
|
687
|
+
result: TopicValidatorResult.Reject
|
|
688
|
+
};
|
|
689
|
+
} else {
|
|
690
|
+
return {
|
|
691
|
+
result: TopicValidatorResult.Accept,
|
|
692
|
+
obj: block
|
|
693
|
+
};
|
|
694
|
+
}
|
|
588
695
|
};
|
|
589
696
|
const { result, obj: block } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.block_proposal);
|
|
590
697
|
if (!result || !block) {
|
|
@@ -594,33 +701,43 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
594
701
|
}
|
|
595
702
|
// REVIEW: callback pattern https://github.com/AztecProtocol/aztec-packages/issues/7963
|
|
596
703
|
async processValidBlockProposal(block, sender) {
|
|
597
|
-
const slot = block.slotNumber
|
|
598
|
-
const previousSlot = slot -
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
slot: block.slotNumber.toNumber(),
|
|
704
|
+
const slot = block.slotNumber;
|
|
705
|
+
const previousSlot = SlotNumber(slot - 1);
|
|
706
|
+
this.logger.verbose(`Received block proposal for slot ${slot} from external peer ${sender.toString()}.`, {
|
|
707
|
+
p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier(),
|
|
708
|
+
slot: block.slotNumber,
|
|
603
709
|
archive: block.archive.toString(),
|
|
604
|
-
block: block.blockNumber,
|
|
605
710
|
source: sender.toString()
|
|
606
711
|
});
|
|
607
712
|
const attestationsForPreviousSlot = await this.mempools.attestationPool?.getAttestationsForSlot(previousSlot);
|
|
608
713
|
if (attestationsForPreviousSlot !== undefined) {
|
|
609
714
|
this.logger.verbose(`Received ${attestationsForPreviousSlot.length} attestations for slot ${previousSlot}`);
|
|
610
715
|
}
|
|
611
|
-
//
|
|
716
|
+
// Attempt to add proposal, then mark the txs in this proposal as non-evictable
|
|
717
|
+
try {
|
|
718
|
+
await this.mempools.attestationPool?.addBlockProposal(block);
|
|
719
|
+
} catch (err) {
|
|
720
|
+
// Drop proposals if we hit per-slot cap in the attestation pool; rethrow unknown errors
|
|
721
|
+
if (err instanceof ProposalSlotCapExceededError) {
|
|
722
|
+
this.logger.warn(`Dropping block proposal due to per-slot proposal cap`, {
|
|
723
|
+
slot: String(slot),
|
|
724
|
+
archive: block.archive.toString(),
|
|
725
|
+
error: err.message
|
|
726
|
+
});
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
throw err;
|
|
730
|
+
}
|
|
612
731
|
await this.mempools.txPool.markTxsAsNonEvictable(block.txHashes);
|
|
613
|
-
await this.mempools.attestationPool?.addBlockProposal(block);
|
|
614
732
|
const attestations = await this.blockReceivedCallback(block, sender);
|
|
615
733
|
// TODO: fix up this pattern - the abstraction is not nice
|
|
616
|
-
// The attestation can be undefined if no handler is registered / the validator deems the block invalid
|
|
734
|
+
// The attestation can be undefined if no handler is registered / the validator deems the block invalid / in fisherman mode
|
|
617
735
|
if (attestations?.length) {
|
|
618
736
|
for (const attestation of attestations){
|
|
619
|
-
this.logger.verbose(`Broadcasting attestation for
|
|
620
|
-
p2pMessageIdentifier: await attestation.
|
|
621
|
-
slot: attestation.slotNumber
|
|
622
|
-
archive: attestation.archive.toString()
|
|
623
|
-
block: attestation.blockNumber
|
|
737
|
+
this.logger.verbose(`Broadcasting attestation for slot ${attestation.slotNumber}`, {
|
|
738
|
+
p2pMessageIdentifier: await attestation.p2pMessageLoggingIdentifier(),
|
|
739
|
+
slot: attestation.slotNumber,
|
|
740
|
+
archive: attestation.archive.toString()
|
|
624
741
|
});
|
|
625
742
|
await this.broadcastAttestation(attestation);
|
|
626
743
|
}
|
|
@@ -636,19 +753,84 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
636
753
|
* Propagates provided message to peers.
|
|
637
754
|
* @param message - The message to propagate.
|
|
638
755
|
*/ async propagate(message) {
|
|
639
|
-
const p2pMessageIdentifier = await message.
|
|
756
|
+
const p2pMessageIdentifier = await message.p2pMessageLoggingIdentifier();
|
|
640
757
|
this.logger.trace(`Message ${p2pMessageIdentifier} queued`, {
|
|
641
758
|
p2pMessageIdentifier
|
|
642
759
|
});
|
|
643
|
-
void this.
|
|
644
|
-
await this.sendToPeers(message);
|
|
645
|
-
}).catch((error)=>{
|
|
760
|
+
void this.sendToPeers(message).catch((error)=>{
|
|
646
761
|
this.logger.error(`Error propagating message ${p2pMessageIdentifier}`, {
|
|
647
762
|
error
|
|
648
763
|
});
|
|
649
764
|
});
|
|
650
765
|
}
|
|
651
766
|
/**
|
|
767
|
+
* Validate the requested block transactions. Allow partial returns.
|
|
768
|
+
* @param request - The block transactions request.
|
|
769
|
+
* @param response - The block transactions response.
|
|
770
|
+
* @param peerId - The ID of the peer that made the request.
|
|
771
|
+
* @returns True if the requested block transactions are valid, false otherwise.
|
|
772
|
+
*/ async validateRequestedBlockTxs(request, response, peerId) {
|
|
773
|
+
const requestedTxValidator = this.createRequestedTxValidator();
|
|
774
|
+
try {
|
|
775
|
+
if (!response.blockHash.equals(request.blockHash)) {
|
|
776
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
777
|
+
throw new ValidationError(`Received block txs for unexpected block: expected ${request.blockHash.toString()}, got ${response.blockHash.toString()}`);
|
|
778
|
+
}
|
|
779
|
+
if (response.txIndices.getLength() !== request.txIndices.getLength()) {
|
|
780
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
781
|
+
throw new ValidationError(`Received block txs with mismatched bitvector length: expected ${request.txIndices.getLength()}, got ${response.txIndices.getLength()}`);
|
|
782
|
+
}
|
|
783
|
+
// Check no duplicates and not exceeding returnable count
|
|
784
|
+
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
785
|
+
const availableIndices = new Set(response.txIndices.getTrueIndices());
|
|
786
|
+
const maxReturnable = [
|
|
787
|
+
...requestedIndices
|
|
788
|
+
].filter((i)=>availableIndices.has(i)).length;
|
|
789
|
+
const returnedHashes = await Promise.all(response.txs.map((tx)=>tx.getTxHash().toString()));
|
|
790
|
+
const uniqueReturned = new Set(returnedHashes.map((h)=>h.toString()));
|
|
791
|
+
if (uniqueReturned.size !== returnedHashes.length) {
|
|
792
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
793
|
+
throw new ValidationError(`Received duplicate txs in block txs response`);
|
|
794
|
+
}
|
|
795
|
+
if (response.txs.length > maxReturnable) {
|
|
796
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
797
|
+
throw new ValidationError(`Received more txs (${response.txs.length}) than requested-and-available (${maxReturnable})`);
|
|
798
|
+
}
|
|
799
|
+
// Given proposal (should have locally), ensure returned txs are valid subset and match request indices
|
|
800
|
+
const proposal = await this.mempools.attestationPool?.getBlockProposal(request.blockHash.toString());
|
|
801
|
+
if (proposal) {
|
|
802
|
+
// Build intersected indices
|
|
803
|
+
const intersectIdx = request.txIndices.getTrueIndices().filter((i)=>response.txIndices.isSet(i));
|
|
804
|
+
// Enforce subset membership and preserve increasing order by index.
|
|
805
|
+
const hashToIndexInProposal = new Map(proposal.txHashes.map((h, i)=>[
|
|
806
|
+
h.toString(),
|
|
807
|
+
i
|
|
808
|
+
]));
|
|
809
|
+
const allowedIndexSet = new Set(intersectIdx);
|
|
810
|
+
const indices = returnedHashes.map((h)=>hashToIndexInProposal.get(h));
|
|
811
|
+
const allAllowed = indices.every((idx)=>idx !== undefined && allowedIndexSet.has(idx));
|
|
812
|
+
const strictlyIncreasing = indices.every((idx, i)=>i === 0 ? idx !== undefined : idx > indices[i - 1]);
|
|
813
|
+
if (!allAllowed || !strictlyIncreasing) {
|
|
814
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
815
|
+
throw new ValidationError('Returned txs do not match expected subset/order for requested indices');
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
// No local proposal, cannot check the membership/order of the returned txs
|
|
819
|
+
this.logger.warn(`Block proposal not found for block hash ${request.blockHash.toString()}; cannot validate membership/order of returned txs`);
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
await Promise.all(response.txs.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator)));
|
|
823
|
+
return true;
|
|
824
|
+
} catch (e) {
|
|
825
|
+
if (e instanceof ValidationError) {
|
|
826
|
+
this.logger.warn(`Failed validation for requested block txs from peer ${peerId.toString()}`);
|
|
827
|
+
} else {
|
|
828
|
+
this.logger.error(`Error during validation of requested block txs`, e);
|
|
829
|
+
}
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
652
834
|
* Validate a collection of txs that has been requested from a peer.
|
|
653
835
|
*
|
|
654
836
|
* The core component of this validator is that each tx hash MUST match the requested tx hash,
|
|
@@ -658,36 +840,89 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
658
840
|
* ReqRespSubProtocol.TX subprotocol validation.
|
|
659
841
|
*
|
|
660
842
|
* @param requestedTxHash - The collection of the txs that was requested.
|
|
661
|
-
* @param responseTx - The
|
|
843
|
+
* @param responseTx - The collection of txs that was received as a response to the request.
|
|
662
844
|
* @param peerId - The peer ID of the peer that sent the tx.
|
|
663
845
|
* @returns True if the whole collection of txs is valid, false otherwise.
|
|
664
|
-
*/
|
|
665
|
-
// I think we should still extract the valid txs and return them, so that we can still use the response.
|
|
666
|
-
async validateRequestedTx(requestedTxHash, responseTx, peerId) {
|
|
846
|
+
*/ async validateRequestedTxs(requestedTxHash, responseTx, peerId) {
|
|
667
847
|
const requested = new Set(requestedTxHash.map((h)=>h.toString()));
|
|
668
|
-
const
|
|
848
|
+
const requestedTxValidator = this.createRequestedTxValidator();
|
|
849
|
+
//TODO: (mralj) - this is somewhat naive implementation, if single tx is invlid we consider the whole response invalid.
|
|
850
|
+
// I think we should still extract the valid txs and return them, so that we can still use the response.
|
|
669
851
|
try {
|
|
670
|
-
await Promise.all(responseTx.map(
|
|
671
|
-
if (!requested.has(tx.getTxHash().toString())) {
|
|
672
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
673
|
-
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
|
|
674
|
-
}
|
|
675
|
-
const { result } = await proofValidator.validateTx(tx);
|
|
676
|
-
if (result === 'invalid') {
|
|
677
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
678
|
-
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that is invalid.`);
|
|
679
|
-
}
|
|
680
|
-
}));
|
|
852
|
+
await Promise.all(responseTx.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator, requested)));
|
|
681
853
|
return true;
|
|
682
854
|
} catch (e) {
|
|
683
855
|
if (e instanceof ValidationError) {
|
|
684
|
-
this.logger.
|
|
856
|
+
this.logger.warn(`Failed to validate requested txs from peer ${peerId.toString()}, reason ${e.message}`);
|
|
685
857
|
} else {
|
|
686
|
-
this.logger.
|
|
858
|
+
this.logger.error(`Error during validation of requested txs`, e);
|
|
687
859
|
}
|
|
688
860
|
return false;
|
|
689
861
|
}
|
|
690
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* Validates a BLOCK response.
|
|
865
|
+
*
|
|
866
|
+
* If a local copy exists, enforces hash equality. If missing, rejects (no penalty) since the hash cannot be verified.
|
|
867
|
+
* Penalizes on block number mismatch or hash mismatch.
|
|
868
|
+
*
|
|
869
|
+
* @param requestedBlockNumber - The requested block number.
|
|
870
|
+
* @param responseBlock - The block returned by the peer.
|
|
871
|
+
* @param peerId - The peer that returned the block.
|
|
872
|
+
* @returns True if the response is valid, false otherwise.
|
|
873
|
+
*/ async validateRequestedBlock(requestedBlockNumber, responseBlock, peerId) {
|
|
874
|
+
try {
|
|
875
|
+
const reqNum = Number(requestedBlockNumber.toString());
|
|
876
|
+
if (responseBlock.number !== reqNum) {
|
|
877
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
const local = await this.archiver.getBlock(BlockNumber(reqNum));
|
|
881
|
+
if (!local) {
|
|
882
|
+
// We are missing the local block; we cannot verify the hash yet. Reject without penalizing.
|
|
883
|
+
// TODO: Consider extending this validator to accept an expected hash or
|
|
884
|
+
// performing quorum-based checks when using P2P syncing prior to L1 sync.
|
|
885
|
+
this.logger.warn(`Local block ${reqNum} not found; rejecting BLOCK response without hash verification`);
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
const [localHash, respHash] = await Promise.all([
|
|
889
|
+
local.hash(),
|
|
890
|
+
responseBlock.hash()
|
|
891
|
+
]);
|
|
892
|
+
if (!localHash.equals(respHash)) {
|
|
893
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
return true;
|
|
897
|
+
} catch (e) {
|
|
898
|
+
this.logger.warn(`Error validating requested block`, e);
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
createRequestedTxValidator() {
|
|
903
|
+
return new AggregateTxValidator(new DataTxValidator(), new MetadataTxValidator({
|
|
904
|
+
l1ChainId: new Fr(this.config.l1ChainId),
|
|
905
|
+
rollupVersion: new Fr(this.config.rollupVersion),
|
|
906
|
+
protocolContractsHash,
|
|
907
|
+
vkTreeRoot: getVKTreeRoot()
|
|
908
|
+
}), new TxProofValidator(this.proofVerifier));
|
|
909
|
+
}
|
|
910
|
+
async validateRequestedTx(tx, peerId, txValidator, requested) {
|
|
911
|
+
const penalize = (severity)=>this.peerManager.penalizePeer(peerId, severity);
|
|
912
|
+
if (!await tx.validateTxHash()) {
|
|
913
|
+
penalize(PeerErrorSeverity.MidToleranceError);
|
|
914
|
+
throw new ValidationError(`Received tx with invalid hash ${tx.getTxHash().toString()}.`);
|
|
915
|
+
}
|
|
916
|
+
if (requested && !requested.has(tx.getTxHash().toString())) {
|
|
917
|
+
penalize(PeerErrorSeverity.MidToleranceError);
|
|
918
|
+
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
|
|
919
|
+
}
|
|
920
|
+
const { result } = await txValidator.validateTx(tx);
|
|
921
|
+
if (result === 'invalid') {
|
|
922
|
+
penalize(PeerErrorSeverity.LowToleranceError);
|
|
923
|
+
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that is invalid.`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
691
926
|
async validatePropagatedTx(tx, peerId) {
|
|
692
927
|
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
693
928
|
// We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
|
|
@@ -702,7 +937,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
702
937
|
let { severity } = outcome.failure;
|
|
703
938
|
// Double spend validator has a special case handler
|
|
704
939
|
if (name === 'doubleSpendValidator') {
|
|
705
|
-
const txBlockNumber = currentBlockNumber + 1; // tx is expected to be in the next block
|
|
940
|
+
const txBlockNumber = BlockNumber(currentBlockNumber + 1); // tx is expected to be in the next block
|
|
706
941
|
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
707
942
|
}
|
|
708
943
|
this.peerManager.penalizePeer(peerId, severity);
|
|
@@ -752,8 +987,8 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
752
987
|
*/ async createMessageValidators(currentBlockNumber, nextSlotTimestamp) {
|
|
753
988
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
754
989
|
const allowedInSetup = this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
|
|
755
|
-
const blockNumberInWhichTheTxIsConsideredToBeIncluded = currentBlockNumber + 1;
|
|
756
|
-
return createTxMessageValidators(nextSlotTimestamp, blockNumberInWhichTheTxIsConsideredToBeIncluded, this.worldStateSynchronizer, gasFees, this.config.l1ChainId, this.config.rollupVersion,
|
|
990
|
+
const blockNumberInWhichTheTxIsConsideredToBeIncluded = BlockNumber(currentBlockNumber + 1);
|
|
991
|
+
return createTxMessageValidators(nextSlotTimestamp, blockNumberInWhichTheTxIsConsideredToBeIncluded, this.worldStateSynchronizer, gasFees, this.config.l1ChainId, this.config.rollupVersion, protocolContractsHash, this.archiver, this.proofVerifier, !this.config.disableTransactions, allowedInSetup);
|
|
757
992
|
}
|
|
758
993
|
/**
|
|
759
994
|
* Run validations on a tx.
|
|
@@ -808,7 +1043,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
808
1043
|
}
|
|
809
1044
|
const snapshotValidator = new DoubleSpendTxValidator({
|
|
810
1045
|
nullifiersExist: async (nullifiers)=>{
|
|
811
|
-
const merkleTree = this.worldStateSynchronizer.getSnapshot(blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow);
|
|
1046
|
+
const merkleTree = this.worldStateSynchronizer.getSnapshot(BlockNumber(blockNumber - this.config.doubleSpendSeverePeerPenaltyWindow));
|
|
812
1047
|
const indices = await merkleTree.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, nullifiers);
|
|
813
1048
|
return indices.map((index)=>index !== undefined);
|
|
814
1049
|
}
|
|
@@ -854,7 +1089,7 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
854
1089
|
}
|
|
855
1090
|
async sendToPeers(message) {
|
|
856
1091
|
const parent = message.constructor;
|
|
857
|
-
const identifier = await message.
|
|
1092
|
+
const identifier = await message.p2pMessageLoggingIdentifier().then((i)=>i.toString());
|
|
858
1093
|
this.logger.trace(`Sending message ${identifier}`, {
|
|
859
1094
|
p2pMessageIdentifier: identifier
|
|
860
1095
|
});
|
|
@@ -883,25 +1118,33 @@ import { P2PInstrumentation } from './instrumentation.js';
|
|
|
883
1118
|
}
|
|
884
1119
|
_ts_decorate([
|
|
885
1120
|
trackSpan('Libp2pService.processValidBlockProposal', async (block)=>({
|
|
886
|
-
[Attributes.
|
|
887
|
-
[Attributes.SLOT_NUMBER]: block.slotNumber.toNumber(),
|
|
1121
|
+
[Attributes.SLOT_NUMBER]: block.slotNumber,
|
|
888
1122
|
[Attributes.BLOCK_ARCHIVE]: block.archive.toString(),
|
|
889
|
-
[Attributes.P2P_ID]: await block.
|
|
1123
|
+
[Attributes.P2P_ID]: await block.p2pMessageLoggingIdentifier().then((i)=>i.toString())
|
|
890
1124
|
}))
|
|
891
1125
|
], LibP2PService.prototype, "processValidBlockProposal", null);
|
|
892
1126
|
_ts_decorate([
|
|
893
1127
|
trackSpan('Libp2pService.broadcastAttestation', async (attestation)=>({
|
|
894
|
-
[Attributes.
|
|
895
|
-
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
|
|
1128
|
+
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
896
1129
|
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
897
|
-
[Attributes.P2P_ID]: await attestation.
|
|
1130
|
+
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then((i)=>i.toString())
|
|
898
1131
|
}))
|
|
899
1132
|
], LibP2PService.prototype, "broadcastAttestation", null);
|
|
1133
|
+
_ts_decorate([
|
|
1134
|
+
trackSpan('Libp2pService.validateRequestedBlockTxs', (request)=>({
|
|
1135
|
+
[Attributes.BLOCK_HASH]: request.blockHash.toString()
|
|
1136
|
+
}))
|
|
1137
|
+
], LibP2PService.prototype, "validateRequestedBlockTxs", null);
|
|
900
1138
|
_ts_decorate([
|
|
901
1139
|
trackSpan('Libp2pService.validateRequestedTx', (requestedTxHash, _responseTx)=>({
|
|
902
1140
|
[Attributes.TX_HASH]: requestedTxHash.toString()
|
|
903
1141
|
}))
|
|
904
|
-
], LibP2PService.prototype, "
|
|
1142
|
+
], LibP2PService.prototype, "validateRequestedTxs", null);
|
|
1143
|
+
_ts_decorate([
|
|
1144
|
+
trackSpan('Libp2pService.validateRequestedBlock', (requestedBlockNumber, _responseBlock)=>({
|
|
1145
|
+
[Attributes.BLOCK_NUMBER]: requestedBlockNumber.toString()
|
|
1146
|
+
}))
|
|
1147
|
+
], LibP2PService.prototype, "validateRequestedBlock", null);
|
|
905
1148
|
_ts_decorate([
|
|
906
1149
|
trackSpan('Libp2pService.validatePropagatedTx', (tx)=>({
|
|
907
1150
|
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
@@ -909,10 +1152,9 @@ _ts_decorate([
|
|
|
909
1152
|
], LibP2PService.prototype, "validatePropagatedTx", null);
|
|
910
1153
|
_ts_decorate([
|
|
911
1154
|
trackSpan('Libp2pService.validateAttestation', async (_, attestation)=>({
|
|
912
|
-
[Attributes.
|
|
913
|
-
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber.toNumber(),
|
|
1155
|
+
[Attributes.SLOT_NUMBER]: attestation.payload.header.slotNumber,
|
|
914
1156
|
[Attributes.BLOCK_ARCHIVE]: attestation.archive.toString(),
|
|
915
|
-
[Attributes.P2P_ID]: await attestation.
|
|
1157
|
+
[Attributes.P2P_ID]: await attestation.p2pMessageLoggingIdentifier().then((i)=>i.toString())
|
|
916
1158
|
}))
|
|
917
1159
|
], LibP2PService.prototype, "validateAttestation", null);
|
|
918
1160
|
_ts_decorate([
|