@aztec/p2p 0.0.1-commit.b2a5d0dd1 → 0.0.1-commit.b3d3157a
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 +9 -1
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +12 -9
- package/dest/client/interface.d.ts +6 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +11 -8
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +53 -17
- package/dest/config.d.ts +43 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +48 -8
- package/dest/errors/reqresp.error.d.ts +1 -20
- package/dest/errors/reqresp.error.d.ts.map +1 -1
- package/dest/errors/reqresp.error.js +0 -21
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +93 -55
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +258 -195
- 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 +175 -59
- package/dest/mem_pools/attestation_pool/mocks.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +6 -4
- package/dest/mem_pools/instrumentation.d.ts +1 -1
- package/dest/mem_pools/instrumentation.d.ts.map +1 -1
- package/dest/mem_pools/instrumentation.js +17 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts +1 -5
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/archive/tx_archive.js +1 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +73 -83
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts +5 -2
- package/dest/msg_validators/attestation_validator/attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/attestation_validator.js +18 -2
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +5 -3
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
- package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.js +3 -4
- package/dest/msg_validators/clock_tolerance.d.ts +1 -1
- package/dest/msg_validators/clock_tolerance.d.ts.map +1 -1
- package/dest/msg_validators/clock_tolerance.js +13 -11
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +5 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +8 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +28 -2
- 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/aggregate_tx_validator.js +8 -15
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +3 -3
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts +15 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/cached_tx_validator.js +19 -0
- package/dest/msg_validators/tx_validator/data_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/data_validator.js +1 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +5 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +11 -7
- package/dest/msg_validators/tx_validator/index.d.ts +3 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +2 -0
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts +2 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/tx_proof_validator.js +2 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts +48 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/tx_validation_cache.js +68 -0
- package/dest/services/discv5/discV5_service.d.ts +2 -1
- package/dest/services/discv5/discV5_service.d.ts.map +1 -1
- package/dest/services/discv5/discV5_service.js +35 -8
- package/dest/services/dummy_service.d.ts +10 -17
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +9 -18
- package/dest/services/libp2p/libp2p_service.d.ts +19 -21
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +147 -148
- package/dest/services/peer-manager/peer_manager.d.ts +1 -1
- package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_manager.js +1 -0
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -8
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +35 -44
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +8 -5
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts +5 -14
- package/dest/services/reqresp/batch-tx-requester/tx_validator.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +6 -20
- package/dest/services/reqresp/interface.d.ts +3 -10
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +0 -9
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts +4 -3
- package/dest/services/reqresp/protocols/block_txs/bitvector.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/bitvector.js +3 -2
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +31 -28
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +12 -7
- 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 +42 -24
- package/dest/services/reqresp/reqresp.d.ts +5 -29
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +16 -206
- package/dest/services/service.d.ts +7 -13
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +2 -23
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +2 -55
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +12 -28
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +43 -83
- package/dest/services/tx_collection/index.d.ts +2 -3
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +0 -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/instrumentation.js +0 -2
- package/dest/services/tx_collection/tx_collection.d.ts +35 -51
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +275 -119
- package/dest/services/tx_collection/tx_collection_sink.d.ts +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +2 -2
- package/dest/services/tx_file_store/tx_file_store.d.ts +1 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +4 -14
- package/dest/services/tx_provider.d.ts +3 -1
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +3 -0
- package/dest/test-helpers/make-test-p2p-clients.d.ts +1 -1
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +13 -7
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +12 -37
- package/dest/test-helpers/reqresp-nodes.d.ts +4 -5
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +11 -15
- package/dest/test-helpers/test_tx_provider.d.ts +3 -1
- package/dest/test-helpers/test_tx_provider.d.ts.map +1 -1
- package/dest/test-helpers/test_tx_provider.js +3 -0
- package/dest/test-helpers/testbench-utils.d.ts +12 -14
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +19 -14
- package/dest/testbench/p2p_client_testbench_worker.d.ts +3 -5
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +13 -24
- package/dest/testbench/worker_client_manager.d.ts +3 -6
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +2 -8
- package/dest/util.d.ts +11 -6
- package/dest/util.d.ts.map +1 -1
- package/dest/util.js +35 -14
- package/dest/versioning.d.ts +3 -6
- package/dest/versioning.d.ts.map +1 -1
- package/dest/versioning.js +3 -24
- package/package.json +15 -14
- package/src/bootstrap/bootstrap.ts +9 -1
- package/src/client/factory.ts +20 -5
- package/src/client/interface.ts +6 -10
- package/src/client/p2p_client.ts +61 -36
- package/src/client/test/{tx_proposal_collector/README.md → p2p_client.batch_tx_requester.bench.README.md} +23 -53
- package/src/config.ts +94 -6
- package/src/errors/reqresp.error.ts +0 -25
- package/src/mem_pools/attestation_pool/attestation_pool.ts +309 -238
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +198 -62
- package/src/mem_pools/attestation_pool/mocks.ts +13 -8
- package/src/mem_pools/instrumentation.ts +5 -1
- package/src/mem_pools/tx_pool_v2/archive/tx_archive.ts +1 -9
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +73 -90
- package/src/msg_validators/attestation_validator/attestation_validator.ts +21 -1
- package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +11 -7
- package/src/msg_validators/clock_tolerance.ts +13 -12
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +9 -2
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +14 -2
- package/src/msg_validators/proposal_validator/proposal_validator.ts +39 -2
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -12
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +3 -3
- package/src/msg_validators/tx_validator/cached_tx_validator.ts +31 -0
- package/src/msg_validators/tx_validator/data_validator.ts +2 -0
- package/src/msg_validators/tx_validator/factory.ts +15 -6
- package/src/msg_validators/tx_validator/index.ts +2 -0
- package/src/msg_validators/tx_validator/tx_proof_validator.ts +2 -0
- package/src/msg_validators/tx_validator/tx_validation_cache.ts +101 -0
- package/src/services/discv5/discV5_service.ts +38 -5
- package/src/services/dummy_service.ts +12 -43
- package/src/services/libp2p/libp2p_service.ts +169 -167
- package/src/services/peer-manager/peer_manager.ts +1 -0
- package/src/services/reqresp/README.md +0 -14
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +39 -52
- package/src/services/reqresp/batch-tx-requester/interface.ts +11 -4
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +12 -25
- package/src/services/reqresp/interface.ts +2 -38
- package/src/services/reqresp/protocols/block_txs/bitvector.ts +3 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +34 -30
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +47 -20
- package/src/services/reqresp/reqresp.ts +11 -251
- package/src/services/service.ts +9 -30
- package/src/services/tx_collection/config.ts +3 -80
- package/src/services/tx_collection/file_store_tx_collection.ts +54 -103
- package/src/services/tx_collection/index.ts +1 -6
- package/src/services/tx_collection/instrumentation.ts +1 -7
- package/src/services/tx_collection/tx_collection.ts +330 -173
- package/src/services/tx_collection/tx_collection_sink.ts +2 -2
- package/src/services/tx_file_store/tx_file_store.ts +5 -17
- package/src/services/tx_provider.ts +5 -0
- package/src/test-helpers/make-test-p2p-clients.ts +1 -0
- package/src/test-helpers/mock-pubsub.ts +17 -60
- package/src/test-helpers/reqresp-nodes.ts +8 -20
- package/src/test-helpers/test_tx_provider.ts +5 -0
- package/src/test-helpers/testbench-utils.ts +23 -27
- package/src/testbench/p2p_client_testbench_worker.ts +16 -42
- package/src/testbench/worker_client_manager.ts +4 -19
- package/src/util.ts +32 -17
- package/src/versioning.ts +3 -33
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts +0 -2
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +0 -318
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts +0 -73
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.d.ts.map +0 -1
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.js +0 -8
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +0 -64
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +0 -1
- package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +0 -151
- package/dest/services/tx_collection/fast_tx_collection.d.ts +0 -51
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/fast_tx_collection.js +0 -311
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +0 -48
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +0 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +0 -50
- package/dest/services/tx_collection/slow_tx_collection.d.ts +0 -57
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +0 -1
- package/dest/services/tx_collection/slow_tx_collection.js +0 -211
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +0 -357
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker_protocol.ts +0 -43
- package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +0 -161
- package/src/services/tx_collection/fast_tx_collection.ts +0 -361
- package/src/services/tx_collection/proposal_tx_collector.ts +0 -108
- package/src/services/tx_collection/slow_tx_collection.ts +0 -266
|
@@ -370,9 +370,9 @@ function applyDecs2203RFactory() {
|
|
|
370
370
|
function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
|
|
371
371
|
return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
|
|
372
372
|
}
|
|
373
|
-
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5,
|
|
373
|
+
var _dec, _dec1, _dec2, _dec3, _dec4, _dec5, _initProto;
|
|
374
374
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
375
|
-
import { maxBy } from '@aztec/foundation/collection';
|
|
375
|
+
import { maxBy, merge } from '@aztec/foundation/collection';
|
|
376
376
|
import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
377
377
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
378
378
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -392,12 +392,13 @@ import { identify } from '@libp2p/identify';
|
|
|
392
392
|
import { TopicValidatorResult } from '@libp2p/interface';
|
|
393
393
|
import { mplex } from '@libp2p/mplex';
|
|
394
394
|
import { tcp } from '@libp2p/tcp';
|
|
395
|
+
import { multiaddr } from '@multiformats/multiaddr';
|
|
395
396
|
import { ENR } from '@nethermindeth/enr';
|
|
396
397
|
import { createLibp2p } from 'libp2p';
|
|
397
398
|
import { CheckpointProposalReceivedCallbackNotRegisteredError } from '../../errors/p2p-service.error.js';
|
|
398
399
|
import { BlockProposalValidator, CheckpointAttestationValidator, CheckpointProposalValidator, DoubleSpendTxValidator, FishermanAttestationValidator, getDefaultAllowedSetupFunctions } from '../../msg_validators/index.js';
|
|
399
400
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
400
|
-
import { createFirstStageTxValidationsForGossipedTransactions, createSecondStageTxValidationsForGossipedTransactions, createTxValidatorForBlockProposalReceivedTxs
|
|
401
|
+
import { createFirstStageTxValidationsForGossipedTransactions, createSecondStageTxValidationsForGossipedTransactions, createTxValidatorForBlockProposalReceivedTxs } from '../../msg_validators/tx_validator/factory.js';
|
|
401
402
|
import { GossipSubEvent } from '../../types/index.js';
|
|
402
403
|
import { convertToMultiaddr } from '../../util.js';
|
|
403
404
|
import { getVersions } from '../../versioning.js';
|
|
@@ -408,7 +409,7 @@ import { APP_SPECIFIC_WEIGHT, gossipScoreThresholds } from '../gossipsub/scoring
|
|
|
408
409
|
import { createAllTopicScoreParams } from '../gossipsub/topic_score_params.js';
|
|
409
410
|
import { PeerManager } from '../peer-manager/peer_manager.js';
|
|
410
411
|
import { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
411
|
-
import {
|
|
412
|
+
import { ReqRespSubProtocol, ValidationError, pingHandler, reqGoodbyeHandler, reqRespBlockTxsHandler, reqRespStatusHandler, reqRespTxHandler } from '../reqresp/index.js';
|
|
412
413
|
import { ReqResp } from '../reqresp/reqresp.js';
|
|
413
414
|
import { P2PInstrumentation } from './instrumentation.js';
|
|
414
415
|
_dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId, attestation)=>({
|
|
@@ -426,10 +427,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
426
427
|
[Attributes.SLOT_NUMBER]: checkpoint.slotNumber,
|
|
427
428
|
[Attributes.BLOCK_ARCHIVE]: checkpoint.archive.toString(),
|
|
428
429
|
[Attributes.P2P_ID]: await checkpoint.p2pMessageLoggingIdentifier().then((i)=>i.toString())
|
|
429
|
-
})), _dec5 = trackSpan('Libp2pService.
|
|
430
|
+
})), _dec5 = trackSpan('Libp2pService.validateRequestedBlockTxsConsistency', (request)=>({
|
|
430
431
|
[Attributes.BLOCK_ARCHIVE]: request.archiveRoot.toString()
|
|
431
|
-
})), _dec6 = trackSpan('Libp2pService.validateRequestedTx', (requestedTxHash, _responseTx)=>({
|
|
432
|
-
[Attributes.TX_HASH]: requestedTxHash.toString()
|
|
433
432
|
}));
|
|
434
433
|
/**
|
|
435
434
|
* Lib P2P implementation of the P2PService interface.
|
|
@@ -445,6 +444,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
445
444
|
proofVerifier;
|
|
446
445
|
worldStateSynchronizer;
|
|
447
446
|
blockMinFeesProvider;
|
|
447
|
+
txValidationCache;
|
|
448
448
|
static{
|
|
449
449
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
450
450
|
[
|
|
@@ -475,12 +475,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
475
475
|
[
|
|
476
476
|
_dec5,
|
|
477
477
|
2,
|
|
478
|
-
"
|
|
479
|
-
],
|
|
480
|
-
[
|
|
481
|
-
_dec6,
|
|
482
|
-
2,
|
|
483
|
-
"validateRequestedTxs"
|
|
478
|
+
"validateRequestedBlockTxsConsistency"
|
|
484
479
|
]
|
|
485
480
|
], []));
|
|
486
481
|
}
|
|
@@ -494,6 +489,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
494
489
|
topicStrings;
|
|
495
490
|
/** Callback invoked when a duplicate proposal is detected (triggers slashing). */ duplicateProposalCallback;
|
|
496
491
|
/** Callback invoked when a duplicate attestation is detected (triggers slashing). */ duplicateAttestationCallback;
|
|
492
|
+
/** Callback invoked when a valid checkpoint attestation is accepted into the pool. */ checkpointAttestationCallback;
|
|
497
493
|
/**
|
|
498
494
|
* Callback for when a block is received from a peer.
|
|
499
495
|
* @param block - The block received from the peer.
|
|
@@ -510,11 +506,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
510
506
|
* @returns The attestations for the checkpoint, if any.
|
|
511
507
|
*/ validatorCheckpointReceivedCallback;
|
|
512
508
|
gossipSubEventHandler;
|
|
509
|
+
ipChangedHandler;
|
|
510
|
+
discoveredP2pIp;
|
|
513
511
|
instrumentation;
|
|
514
512
|
telemetry;
|
|
515
513
|
logger;
|
|
516
|
-
constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger = createLogger('p2p:libp2p_service')){
|
|
517
|
-
super(telemetry, 'LibP2PService'), 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.blockMinFeesProvider = blockMinFeesProvider, this.msgIdSeenValidators = (_initProto(this), {}), this.protocolVersion = '', this.topicStrings = {};
|
|
514
|
+
constructor(config, node, peerDiscoveryService, reqresp, peerManager, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger = createLogger('p2p:libp2p_service'), txValidationCache){
|
|
515
|
+
super(telemetry, 'LibP2PService'), 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.blockMinFeesProvider = blockMinFeesProvider, this.txValidationCache = txValidationCache, this.msgIdSeenValidators = (_initProto(this), {}), this.protocolVersion = '', this.topicStrings = {};
|
|
518
516
|
this.telemetry = telemetry;
|
|
519
517
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
520
518
|
this.logger = config.fishermanMode ? logger.createChild('[FISHERMAN]') : logger;
|
|
@@ -534,15 +532,22 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
534
532
|
const proposalValidatorOpts = {
|
|
535
533
|
txsPermitted: !config.disableTransactions,
|
|
536
534
|
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
537
|
-
|
|
535
|
+
maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
|
|
536
|
+
p2pPropagationTime,
|
|
537
|
+
skipSlotValidation: config.skipProposalSlotValidation,
|
|
538
|
+
signatureContext: {
|
|
539
|
+
chainId: config.l1ChainId,
|
|
540
|
+
rollupAddress: config.rollupAddress
|
|
541
|
+
}
|
|
538
542
|
};
|
|
539
543
|
this.blockProposalValidator = new BlockProposalValidator(epochCache, proposalValidatorOpts);
|
|
540
544
|
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, proposalValidatorOpts);
|
|
541
|
-
|
|
542
|
-
l1PublishingTime: config.l1PublishingTime
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
545
|
+
const attestationValidatorOpts = {
|
|
546
|
+
l1PublishingTime: config.l1PublishingTime,
|
|
547
|
+
p2pPropagationTime,
|
|
548
|
+
signatureContext: proposalValidatorOpts.signatureContext
|
|
549
|
+
};
|
|
550
|
+
this.checkpointAttestationValidator = config.fishermanMode ? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry, attestationValidatorOpts) : new CheckpointAttestationValidator(epochCache, attestationValidatorOpts);
|
|
546
551
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
547
552
|
this.blockReceivedCallback = async (block)=>{
|
|
548
553
|
this.logger.warn(`Handler for block received not yet registered on P2P service. Received block ${block.blockNumber} for slot ${block.slotNumber} from peer.`, {
|
|
@@ -559,6 +564,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
559
564
|
}
|
|
560
565
|
updateConfig(config) {
|
|
561
566
|
this.reqresp.updateConfig(config);
|
|
567
|
+
this.config = merge(this.config, config);
|
|
562
568
|
}
|
|
563
569
|
/**
|
|
564
570
|
* Creates an instance of the LibP2P service.
|
|
@@ -566,7 +572,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
566
572
|
* @param txPool - The transaction pool to be accessed by the service.
|
|
567
573
|
* @returns The new service.
|
|
568
574
|
*/ static async new(config, peerId, deps) {
|
|
569
|
-
const { worldStateSynchronizer, epochCache, l2BlockSource, mempools, proofVerifier, peerStore, blockMinFeesProvider, telemetry, logger, packageVersion } = deps;
|
|
575
|
+
const { worldStateSynchronizer, epochCache, l2BlockSource, mempools, proofVerifier, peerStore, blockMinFeesProvider, telemetry, logger, packageVersion, txValidationCache } = deps;
|
|
570
576
|
const { p2pPort, maxPeerCount, listenAddress } = config;
|
|
571
577
|
const bindAddrTcp = convertToMultiaddr(listenAddress, p2pPort, 'tcp');
|
|
572
578
|
const datastore = new AztecDatastore(peerStore);
|
|
@@ -718,7 +724,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
718
724
|
})
|
|
719
725
|
}),
|
|
720
726
|
components: (components)=>({
|
|
721
|
-
connectionManager: components.connectionManager
|
|
727
|
+
connectionManager: components.connectionManager,
|
|
728
|
+
addressManager: components.addressManager
|
|
722
729
|
})
|
|
723
730
|
},
|
|
724
731
|
logger: createLibp2pComponentLogger(logger.module, logger.getBindings())
|
|
@@ -735,7 +742,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
735
742
|
// Note: positive topic scores can offset penalties, so alignment is best-effort.
|
|
736
743
|
node.services.pubsub.score.params.appSpecificWeight = APP_SPECIFIC_WEIGHT;
|
|
737
744
|
node.services.pubsub.score.params.appSpecificScore = (peerId)=>peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
738
|
-
return new LibP2PService(config, node, peerDiscoveryService, reqresp, peerManager, mempools, l2BlockSource, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger);
|
|
745
|
+
return new LibP2PService(config, node, peerDiscoveryService, reqresp, peerManager, mempools, l2BlockSource, epochCache, proofVerifier, worldStateSynchronizer, blockMinFeesProvider, telemetry, logger, txValidationCache);
|
|
739
746
|
}
|
|
740
747
|
/**
|
|
741
748
|
* Starts the LibP2P service.
|
|
@@ -745,12 +752,11 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
745
752
|
if (this.node.status === 'started') {
|
|
746
753
|
throw new Error('P2P service already started');
|
|
747
754
|
}
|
|
748
|
-
// Get listen & announce addresses for logging
|
|
749
755
|
const { p2pIp, p2pPort } = this.config;
|
|
750
|
-
if (!p2pIp) {
|
|
751
|
-
throw new Error('Announce address not provided.');
|
|
756
|
+
if (!p2pIp && !this.config.queryForIp) {
|
|
757
|
+
throw new Error('Announce address not provided and queryForIp is not enabled.');
|
|
752
758
|
}
|
|
753
|
-
const announceTcpMultiaddr = convertToMultiaddr(p2pIp, p2pPort, 'tcp');
|
|
759
|
+
const announceTcpMultiaddr = p2pIp ? convertToMultiaddr(p2pIp, p2pPort, 'tcp') : undefined;
|
|
754
760
|
// Create request response protocol handlers
|
|
755
761
|
const txHandler = reqRespTxHandler(this.mempools);
|
|
756
762
|
const goodbyeHandler = reqGoodbyeHandler(this.peerManager);
|
|
@@ -767,14 +773,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
767
773
|
if (!this.config.disableTransactions) {
|
|
768
774
|
requestResponseHandlers[ReqRespSubProtocol.TX] = txHandler.bind(this);
|
|
769
775
|
}
|
|
770
|
-
// Define the sub protocol validators - This is done within this start() method to gain a callback to the existing validateTx function
|
|
771
|
-
const reqrespSubProtocolValidators = {
|
|
772
|
-
...DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
773
|
-
[ReqRespSubProtocol.TX]: this.validateRequestedTxs.bind(this),
|
|
774
|
-
[ReqRespSubProtocol.BLOCK_TXS]: this.validateRequestedBlockTxs.bind(this)
|
|
775
|
-
};
|
|
776
776
|
await this.peerManager.initializePeers();
|
|
777
|
-
await this.reqresp.start(requestResponseHandlers
|
|
777
|
+
await this.reqresp.start(requestResponseHandlers);
|
|
778
778
|
await this.node.start();
|
|
779
779
|
// Subscribe to standard GossipSub topics by default
|
|
780
780
|
for (const topic of getTopicsForConfig(this.config.disableTransactions)){
|
|
@@ -786,6 +786,34 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
786
786
|
if (!this.config.p2pDiscoveryDisabled) {
|
|
787
787
|
await this.peerDiscoveryService.start();
|
|
788
788
|
}
|
|
789
|
+
// Bridge discv5 IP changes to libp2p's AddressManager so peers see the updated address
|
|
790
|
+
if (this.config.queryForIp) {
|
|
791
|
+
this.discoveredP2pIp = this.config.p2pIp;
|
|
792
|
+
this.logger.info('IP change tracking enabled, bridging discv5 IP updates to libp2p AddressManager');
|
|
793
|
+
this.ipChangedHandler = (ip)=>{
|
|
794
|
+
const addressManager = this.node.services.components.addressManager;
|
|
795
|
+
const newAddr = multiaddr(convertToMultiaddr(ip, this.config.p2pPort, 'tcp'));
|
|
796
|
+
const previousIp = this.discoveredP2pIp;
|
|
797
|
+
if (previousIp) {
|
|
798
|
+
const oldAddr = multiaddr(convertToMultiaddr(previousIp, this.config.p2pPort, 'tcp'));
|
|
799
|
+
addressManager.removeObservedAddr(oldAddr);
|
|
800
|
+
this.logger.info('Libp2p announce address updated due to IP change', {
|
|
801
|
+
previousIp,
|
|
802
|
+
newIp: ip,
|
|
803
|
+
newMultiaddr: newAddr.toString()
|
|
804
|
+
});
|
|
805
|
+
} else {
|
|
806
|
+
this.logger.info('Libp2p announce address set from initial discv5 IP discovery', {
|
|
807
|
+
ip,
|
|
808
|
+
multiaddr: newAddr.toString()
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
addressManager.addObservedAddr(newAddr);
|
|
812
|
+
addressManager.confirmObservedAddr(newAddr);
|
|
813
|
+
this.discoveredP2pIp = ip;
|
|
814
|
+
};
|
|
815
|
+
this.peerDiscoveryService.on('ip:changed', this.ipChangedHandler);
|
|
816
|
+
}
|
|
789
817
|
this.discoveryRunningPromise = new RunningPromise(async ()=>{
|
|
790
818
|
await this.peerManager.heartbeat();
|
|
791
819
|
}, this.logger, this.config.peerCheckIntervalMS);
|
|
@@ -803,6 +831,10 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
803
831
|
*/ async stop() {
|
|
804
832
|
// Remove gossip sub listener
|
|
805
833
|
this.node.services.pubsub.removeEventListener(GossipSubEvent.MESSAGE, this.gossipSubEventHandler);
|
|
834
|
+
if (this.ipChangedHandler) {
|
|
835
|
+
this.peerDiscoveryService.removeListener('ip:changed', this.ipChangedHandler);
|
|
836
|
+
this.ipChangedHandler = undefined;
|
|
837
|
+
}
|
|
806
838
|
// Stop peer manager
|
|
807
839
|
this.logger.debug('Stopping peer manager...');
|
|
808
840
|
await this.peerManager.stop();
|
|
@@ -816,8 +848,8 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
816
848
|
await this.stopLibP2P();
|
|
817
849
|
this.logger.info('LibP2P service stopped');
|
|
818
850
|
}
|
|
819
|
-
addReqRespSubProtocol(subProtocol, handler
|
|
820
|
-
return this.reqresp.addSubProtocol(subProtocol, handler
|
|
851
|
+
addReqRespSubProtocol(subProtocol, handler) {
|
|
852
|
+
return this.reqresp.addSubProtocol(subProtocol, handler);
|
|
821
853
|
}
|
|
822
854
|
registerThisValidatorAddresses(address) {
|
|
823
855
|
this.peerManager.registerThisValidatorAddresses(address);
|
|
@@ -839,14 +871,6 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
839
871
|
};
|
|
840
872
|
setImmediate(()=>void safeJob());
|
|
841
873
|
}
|
|
842
|
-
/**
|
|
843
|
-
* Send a batch of requests to peers, and return the responses
|
|
844
|
-
* @param protocol - The request response protocol to use
|
|
845
|
-
* @param requests - The requests to send to the peers
|
|
846
|
-
* @returns The responses to the requests
|
|
847
|
-
*/ sendBatchRequest(protocol, requests, pinnedPeerId) {
|
|
848
|
-
return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
|
|
849
|
-
}
|
|
850
874
|
sendRequestToPeer(peerId, subProtocol, payload, dialTimeout) {
|
|
851
875
|
return this.reqresp.sendRequestToPeer(peerId, subProtocol, payload, dialTimeout);
|
|
852
876
|
}
|
|
@@ -865,9 +889,6 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
865
889
|
registerAllNodesCheckpointReceivedCallback(callback) {
|
|
866
890
|
this.allNodesCheckpointReceivedCallback = callback;
|
|
867
891
|
}
|
|
868
|
-
async notifyOwnCheckpointProposal(checkpoint) {
|
|
869
|
-
await this.allNodesCheckpointReceivedCallback(checkpoint, this.node.peerId);
|
|
870
|
-
}
|
|
871
892
|
/**
|
|
872
893
|
* Registers a callback to be invoked when a duplicate proposal is detected.
|
|
873
894
|
* This callback is triggered on the first duplicate (when count goes from 1 to 2).
|
|
@@ -881,6 +902,9 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
881
902
|
*/ registerDuplicateAttestationCallback(callback) {
|
|
882
903
|
this.duplicateAttestationCallback = callback;
|
|
883
904
|
}
|
|
905
|
+
registerCheckpointAttestationCallback(callback) {
|
|
906
|
+
this.checkpointAttestationCallback = callback;
|
|
907
|
+
}
|
|
884
908
|
/**
|
|
885
909
|
* Subscribes to a topic.
|
|
886
910
|
* @param topic - The topic to subscribe to.
|
|
@@ -995,6 +1019,13 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
995
1019
|
}
|
|
996
1020
|
// Process the message, optionally within a linked span for trace propagation
|
|
997
1021
|
const processMessage = async ()=>{
|
|
1022
|
+
if (this.config.skipIncomingProposals && (msg.topic === this.topicStrings[TopicType.block_proposal] || msg.topic === this.topicStrings[TopicType.checkpoint_proposal])) {
|
|
1023
|
+
this.logger.warn(`Ignoring incoming proposal (skipIncomingProposals is set)`, {
|
|
1024
|
+
topic: msg.topic
|
|
1025
|
+
});
|
|
1026
|
+
this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
998
1029
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
999
1030
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
1000
1031
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
@@ -1304,6 +1335,7 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
1304
1335
|
}
|
|
1305
1336
|
}
|
|
1306
1337
|
// Attestation was added successfully - accept it so other nodes can also detect the equivocation
|
|
1338
|
+
this.checkpointAttestationCallback?.(attestation);
|
|
1307
1339
|
return {
|
|
1308
1340
|
result: TopicValidatorResult.Accept,
|
|
1309
1341
|
obj: attestation
|
|
@@ -1422,15 +1454,24 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
1422
1454
|
* Validates and processes the checkpoint proposal, then triggers the callback for attestation.
|
|
1423
1455
|
*/ async handleGossipedCheckpointProposal(payloadData, msgId, source) {
|
|
1424
1456
|
const { result, obj: checkpoint, metadata: { isEquivocated, processBlock } = {} } = await this.validateReceivedMessage(()=>this.validateAndStoreCheckpointProposal(source, CheckpointProposal.fromBuffer(payloadData)), msgId, source, TopicType.checkpoint_proposal);
|
|
1457
|
+
// Process checkpoint proposal if valid and not equivocated.
|
|
1458
|
+
const processCheckpointFn = ()=>result === TopicValidatorResult.Accept && checkpoint && !isEquivocated ? this.processValidCheckpointProposal(checkpoint.toCore(), source) : Promise.resolve();
|
|
1425
1459
|
// If the checkpoint contained a valid last block, we process it even if the checkpoint itself is to be rejected
|
|
1426
1460
|
// TODO(palla/mbps): Is this ok? Should we be considering a block from a checkpoint that was equivocated?
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1461
|
+
const processBlockFn = ()=>processBlock && checkpoint && checkpoint.getBlockProposal() ? this.processValidBlockProposal(checkpoint.getBlockProposal(), source) : Promise.resolve();
|
|
1462
|
+
// A node that skips checkpoint validation attests without re-executing the embedded last block, so run
|
|
1463
|
+
// the checkpoint callback first: this creates and broadcasts the attestation before the block is
|
|
1464
|
+
// processed. Otherwise the block's re-execution — which can stall until the re-execution deadline
|
|
1465
|
+
// waiting for a parent that may never arrive — would delay the attestation past the slot's attestation
|
|
1466
|
+
// window, after which peers reject it as stale.
|
|
1467
|
+
if (this.config.skipCheckpointProposalValidation) {
|
|
1468
|
+
await processCheckpointFn();
|
|
1469
|
+
await processBlockFn();
|
|
1431
1470
|
return;
|
|
1432
1471
|
}
|
|
1433
|
-
|
|
1472
|
+
// Process the block first, since it's required for the checkpoint proposal validation.
|
|
1473
|
+
await processBlockFn();
|
|
1474
|
+
await processCheckpointFn();
|
|
1434
1475
|
}
|
|
1435
1476
|
/**
|
|
1436
1477
|
* Validates a checkpoint proposal. Penalizes peer if validation fails. Adds the checkpoint and
|
|
@@ -1587,62 +1628,66 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
1587
1628
|
});
|
|
1588
1629
|
}
|
|
1589
1630
|
/**
|
|
1590
|
-
* Validate the requested block transactions
|
|
1631
|
+
* Validate the requested block transactions request-response consistency.
|
|
1632
|
+
* It does NOT validate the transactions themselves.
|
|
1591
1633
|
* @param request - The block transactions request.
|
|
1592
1634
|
* @param response - The block transactions response.
|
|
1593
1635
|
* @param peerId - The ID of the peer that made the request.
|
|
1594
|
-
* @returns True if the
|
|
1595
|
-
*/ async
|
|
1596
|
-
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1636
|
+
* @returns True if the request-response is consistent, false otherwise.
|
|
1637
|
+
*/ async validateRequestedBlockTxsConsistency(request, response, peerId) {
|
|
1597
1638
|
try {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
throw new ValidationError(`Received block txs for unexpected archive root: expected ${request.archiveRoot.toString()}, got ${response.archiveRoot.toString()}`);
|
|
1601
|
-
}
|
|
1602
|
-
if (response.txIndices.getLength() !== request.txIndices.getLength()) {
|
|
1603
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1604
|
-
throw new ValidationError(`Received block txs with mismatched bitvector length: expected ${request.txIndices.getLength()}, got ${response.txIndices.getLength()}`);
|
|
1605
|
-
}
|
|
1606
|
-
// Check no duplicates and not exceeding returnable count
|
|
1607
|
-
const requestedIndices = new Set(request.txIndices.getTrueIndices());
|
|
1608
|
-
const availableIndices = new Set(response.txIndices.getTrueIndices());
|
|
1609
|
-
const maxReturnable = [
|
|
1610
|
-
...requestedIndices
|
|
1611
|
-
].filter((i)=>availableIndices.has(i)).length;
|
|
1612
|
-
const returnedHashes = await Promise.all(response.txs.map((tx)=>tx.getTxHash().toString()));
|
|
1639
|
+
// Check for duplicates txs (or hashes) in the response.
|
|
1640
|
+
const returnedHashes = response.txs.map((tx)=>tx.getTxHash().toString());
|
|
1613
1641
|
const uniqueReturned = new Set(returnedHashes.map((h)=>h.toString()));
|
|
1614
1642
|
if (uniqueReturned.size !== returnedHashes.length) {
|
|
1615
1643
|
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1616
1644
|
throw new ValidationError(`Received duplicate txs in block txs response`);
|
|
1617
1645
|
}
|
|
1618
|
-
|
|
1646
|
+
// We get the block tx hashes from the proposal or the archiver.
|
|
1647
|
+
const proposal = await this.mempools.attestationPool.getBlockProposalByArchive(request.archiveRoot.toString());
|
|
1648
|
+
const blockTxHashes = proposal?.txHashes ?? (await this.archiver.getBlock({
|
|
1649
|
+
archive: request.archiveRoot
|
|
1650
|
+
}))?.body.txEffects.map((e)=>e.txHash);
|
|
1651
|
+
// If we don't have the block, we can't verify membership/order of the returned txs.
|
|
1652
|
+
if (!blockTxHashes) {
|
|
1653
|
+
// This shouldn't happen, since we asked for the block (proposal).
|
|
1654
|
+
// Neither a local proposal nor an archived block: we cannot verify membership/order of the
|
|
1655
|
+
// returned txs. This is a local-state gap, not a peer fault, so we do not penalize.
|
|
1656
|
+
this.logger.warn(`Block ${request.archiveRoot.toString()} not found in attestation pool or archiver; cannot validate membership/order of returned txs`);
|
|
1657
|
+
// NOTE: We mark the response as invalid, given the limitations of a true/false return value.
|
|
1658
|
+
return false;
|
|
1659
|
+
}
|
|
1660
|
+
// Verify that the returned tx hashes are a subset of (tx hashes by index) U (explicitly requested tx hashes).
|
|
1661
|
+
const uniqueRequestedHashes = new Set([
|
|
1662
|
+
// tx hashes requested by index.
|
|
1663
|
+
...request.txIndices.getTrueIndices().map((i)=>blockTxHashes[i].toString()),
|
|
1664
|
+
// explicitly requested tx hashes.
|
|
1665
|
+
...request.txHashes.map((h)=>h.toString())
|
|
1666
|
+
]);
|
|
1667
|
+
if (!returnedHashes.every((h)=>uniqueRequestedHashes.has(h))) {
|
|
1668
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1669
|
+
throw new ValidationError('Returned txs should be a subset of (tx hashes by index) U (explicitly requested tx hashes)');
|
|
1670
|
+
}
|
|
1671
|
+
// Tx indices information is optional, but if present, we need to verify a few things.
|
|
1672
|
+
if (!response.peerHasBlock()) {
|
|
1673
|
+
this.logger.debug(`Peer ${peerId.toString()} signalled missing block`);
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
// If the response has a non-empty bitvector, it needs to be consistent with the number of txs in the block.
|
|
1677
|
+
if (response.txIndices.getLength() !== blockTxHashes.length) {
|
|
1619
1678
|
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.MidToleranceError);
|
|
1620
|
-
throw new ValidationError(`Received
|
|
1679
|
+
throw new ValidationError(`Received block txs with mismatched bitvector length: expected ${blockTxHashes.length}, got ${response.txIndices.getLength()}`);
|
|
1621
1680
|
}
|
|
1622
|
-
//
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
]));
|
|
1632
|
-
const allowedIndexSet = new Set(intersectIdx);
|
|
1633
|
-
const indices = returnedHashes.map((h)=>hashToIndexInProposal.get(h));
|
|
1634
|
-
const allAllowed = indices.every((idx)=>idx !== undefined && allowedIndexSet.has(idx));
|
|
1635
|
-
const strictlyIncreasing = indices.every((idx, i)=>i === 0 ? idx !== undefined : idx > indices[i - 1]);
|
|
1636
|
-
if (!allAllowed || !strictlyIncreasing) {
|
|
1637
|
-
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1638
|
-
throw new ValidationError('Returned txs do not match expected subset/order for requested indices');
|
|
1639
|
-
}
|
|
1640
|
-
} else {
|
|
1641
|
-
// No local proposal, cannot check the membership/order of the returned txs
|
|
1642
|
-
this.logger.warn(`Block proposal not found for archive root ${request.archiveRoot.toString()}; cannot validate membership/order of returned txs`);
|
|
1643
|
-
return false;
|
|
1681
|
+
// For every index we requested that the peer claims to have (per its bitvector), the
|
|
1682
|
+
// corresponding tx must be present in the response. A peer advertising availability but
|
|
1683
|
+
// withholding the tx is inconsistent.
|
|
1684
|
+
const returnedHashSet = new Set(returnedHashes);
|
|
1685
|
+
const expectedIndices = request.txIndices.getTrueIndices().filter((i)=>response.txIndices.isSet(i));
|
|
1686
|
+
const missingExpected = expectedIndices.some((i)=>!returnedHashSet.has(blockTxHashes[i].toString()));
|
|
1687
|
+
if (missingExpected) {
|
|
1688
|
+
this.peerManager.penalizePeer(peerId, PeerErrorSeverity.LowToleranceError);
|
|
1689
|
+
throw new ValidationError('Peer advertised requested txs via indices but did not return them');
|
|
1644
1690
|
}
|
|
1645
|
-
await Promise.all(response.txs.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator)));
|
|
1646
1691
|
return true;
|
|
1647
1692
|
} catch (e) {
|
|
1648
1693
|
if (e instanceof ValidationError) {
|
|
@@ -1653,54 +1698,6 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
1653
1698
|
return false;
|
|
1654
1699
|
}
|
|
1655
1700
|
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Validate a collection of txs that has been requested from a peer.
|
|
1658
|
-
*
|
|
1659
|
-
* The core component of this validator is that each tx hash MUST match the requested tx hash,
|
|
1660
|
-
* In order to perform this check, the tx proof must be verified.
|
|
1661
|
-
*
|
|
1662
|
-
* Note: This function is called from within `ReqResp.sendRequest` as part of the
|
|
1663
|
-
* ReqRespSubProtocol.TX subprotocol validation.
|
|
1664
|
-
*
|
|
1665
|
-
* @param requestedTxHash - The collection of the txs that was requested.
|
|
1666
|
-
* @param responseTx - The collection of txs that was received as a response to the request.
|
|
1667
|
-
* @param peerId - The peer ID of the peer that sent the tx.
|
|
1668
|
-
* @returns True if the whole collection of txs is valid, false otherwise.
|
|
1669
|
-
*/ async validateRequestedTxs(requestedTxHash, responseTx, peerId) {
|
|
1670
|
-
const requested = new Set(requestedTxHash.map((h)=>h.toString()));
|
|
1671
|
-
const requestedTxValidator = this.createRequestedTxValidator();
|
|
1672
|
-
//TODO: (mralj) - this is somewhat naive implementation, if single tx is invalid we consider the whole response invalid.
|
|
1673
|
-
// I think we should still extract the valid txs and return them, so that we can still use the response.
|
|
1674
|
-
try {
|
|
1675
|
-
await Promise.all(responseTx.map((tx)=>this.validateRequestedTx(tx, peerId, requestedTxValidator, requested)));
|
|
1676
|
-
return true;
|
|
1677
|
-
} catch (e) {
|
|
1678
|
-
if (e instanceof ValidationError) {
|
|
1679
|
-
this.logger.warn(`Failed to validate requested txs from peer ${peerId.toString()}, reason ${e.message}`);
|
|
1680
|
-
} else {
|
|
1681
|
-
this.logger.error(`Error during validation of requested txs`, e);
|
|
1682
|
-
}
|
|
1683
|
-
return false;
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
async validateRequestedTx(tx, peerId, txValidator, requested) {
|
|
1687
|
-
const penalize = (severity)=>this.peerManager.penalizePeer(peerId, severity);
|
|
1688
|
-
if (requested && !requested.has(tx.getTxHash().toString())) {
|
|
1689
|
-
penalize(PeerErrorSeverity.MidToleranceError);
|
|
1690
|
-
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that was not requested.`);
|
|
1691
|
-
}
|
|
1692
|
-
const { result } = await txValidator.validateTx(tx);
|
|
1693
|
-
if (result === 'invalid') {
|
|
1694
|
-
penalize(PeerErrorSeverity.LowToleranceError);
|
|
1695
|
-
throw new ValidationError(`Received tx with hash ${tx.getTxHash().toString()} that is invalid.`);
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
createRequestedTxValidator() {
|
|
1699
|
-
return createTxValidatorForReqResponseReceivedTxs(this.proofVerifier, {
|
|
1700
|
-
l1ChainId: this.config.l1ChainId,
|
|
1701
|
-
rollupVersion: this.config.rollupVersion
|
|
1702
|
-
});
|
|
1703
|
-
}
|
|
1704
1701
|
getGasFees() {
|
|
1705
1702
|
return this.blockMinFeesProvider.getCurrentMinFees();
|
|
1706
1703
|
}
|
|
@@ -1713,16 +1710,18 @@ _dec = trackSpan('Libp2pService.validateAndStoreCheckpointAttestation', (_peerId
|
|
|
1713
1710
|
txValidatorConfig: {
|
|
1714
1711
|
l1ChainId: this.config.l1ChainId,
|
|
1715
1712
|
rollupVersion: this.config.rollupVersion,
|
|
1716
|
-
proofVerifier: this.proofVerifier
|
|
1713
|
+
proofVerifier: this.proofVerifier,
|
|
1714
|
+
txValidationCache: this.txValidationCache
|
|
1717
1715
|
},
|
|
1718
|
-
peerScoring: this.peerManager
|
|
1716
|
+
peerScoring: this.peerManager,
|
|
1717
|
+
validateRequestedBlockTxsConsistency: this.validateRequestedBlockTxsConsistency.bind(this)
|
|
1719
1718
|
};
|
|
1720
1719
|
}
|
|
1721
1720
|
async validateTxsReceivedInBlockProposal(txs) {
|
|
1722
1721
|
const validator = createTxValidatorForBlockProposalReceivedTxs(this.proofVerifier, {
|
|
1723
1722
|
l1ChainId: this.config.l1ChainId,
|
|
1724
1723
|
rollupVersion: this.config.rollupVersion
|
|
1725
|
-
}, this.logger.getBindings());
|
|
1724
|
+
}, this.logger.getBindings(), this.txValidationCache);
|
|
1726
1725
|
const results = await Promise.all(txs.map(async (tx)=>{
|
|
1727
1726
|
const result = await validator.validateTx(tx);
|
|
1728
1727
|
return result.result !== 'invalid';
|
|
@@ -175,4 +175,4 @@ export declare class PeerManager implements PeerManagerInterface {
|
|
|
175
175
|
handleAuthRequestFromPeer(_authRequest: AuthRequest, peerId: PeerId): Promise<StatusMessage>;
|
|
176
176
|
private updateAuthenticatedPeers;
|
|
177
177
|
}
|
|
178
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
178
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVlcl9tYW5hZ2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2VydmljZXMvcGVlci1tYW5hZ2VyL3BlZXJfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQ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AI/B;;;;;;;;;SASK;IACQ,yBAAyB,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAOxG;YAEa,wBAAwB;CAwBvC"}
|
|
@@ -416,6 +416,7 @@ export class PeerManager {
|
|
|
416
416
|
protectedConnections: protectedPeerCount,
|
|
417
417
|
maxPeerCount: this.config.maxPeerCount,
|
|
418
418
|
cachedPeers: this.cachedPeers.size,
|
|
419
|
+
discv5KadPeers: this.peerDiscoveryService.getKadValues().length,
|
|
419
420
|
...this.peerScoring.getStats()
|
|
420
421
|
});
|
|
421
422
|
this.metrics.recordPeerCount(connections.length);
|
|
@@ -33,13 +33,6 @@ export declare class BatchTxRequester {
|
|
|
33
33
|
private handleSuccessResponseFromPeer;
|
|
34
34
|
private handleReceivedTxs;
|
|
35
35
|
private decideIfPeerIsSmart;
|
|
36
|
-
/**
|
|
37
|
-
* Handles an archive root mismatch between local state and peer response.
|
|
38
|
-
*
|
|
39
|
-
* - Response archive is Fr.ZERO (peer pruned proposal, legitimate): marks peer dumb.
|
|
40
|
-
* - Non-zero archive mismatch (malicious response): penalises + marks dumb.
|
|
41
|
-
*/
|
|
42
|
-
private handleArchiveRootMismatch;
|
|
43
36
|
private peerHasSomeTxsWeAreMissing;
|
|
44
37
|
private markTxsPeerHas;
|
|
45
38
|
private extractHashesPeerHasFromResponse;
|
|
@@ -48,4 +41,4 @@ export declare class BatchTxRequester {
|
|
|
48
41
|
private unlockSmartRequesterSemaphores;
|
|
49
42
|
private sleepClampedToDeadline;
|
|
50
43
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmF0Y2hfdHhfcmVxdWVzdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvc2VydmljZXMvcmVxcmVzcC9iYXRjaC10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FCQUFxQjtJQXdCN0IsT0FBTyxDQUFDLFVBQVU7SUFZbEIsT0FBTyxDQUFDLDhCQUE4QjtZQVV4QixzQkFBc0I7Q0FNckMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_tx_requester.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/batch_tx_requester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"batch_tx_requester.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/batch-tx-requester/batch_tx_requester.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAqC,MAAM,kBAAkB,CAAC;AAEzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE9E,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAQjG,OAAO,KAAK,EAAE,6BAA6B,EAAE,uBAAuB,EAAyB,MAAM,gBAAgB,CAAC;AAsBpH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkB;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC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