@aztec/p2p 0.0.1-commit.7ac86ea28 → 0.0.1-commit.7b86788
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/client/factory.d.ts +4 -5
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +15 -26
- package/dest/client/interface.d.ts +6 -13
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +5 -13
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +3 -58
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -2
- package/dest/config.d.ts +2 -5
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +0 -5
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +2 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +10 -6
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +7 -5
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +26 -4
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +48 -7
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +9 -10
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +2 -2
- 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 +173 -146
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- 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/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/services/dummy_service.d.ts +2 -3
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +1 -4
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +7 -7
- package/dest/services/libp2p/libp2p_service.d.ts +15 -13
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +64 -80
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +1 -1
- 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 +14 -37
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +2 -1
- package/dest/services/service.d.ts +2 -2
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +4 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +5 -6
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/make-test-p2p-clients.js +1 -2
- package/dest/test-helpers/mock-pubsub.d.ts +2 -3
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +2 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +2 -3
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -2
- package/dest/test-helpers/testbench-utils.d.ts +2 -2
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +5 -5
- package/package.json +14 -14
- package/src/client/factory.ts +22 -46
- package/src/client/interface.ts +5 -19
- package/src/client/p2p_client.ts +4 -88
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -2
- package/src/config.ts +1 -9
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +2 -2
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +10 -6
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +7 -4
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +65 -10
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +1 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +179 -148
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/services/dummy_service.ts +1 -5
- package/src/services/encoding.ts +5 -6
- package/src/services/libp2p/libp2p_service.ts +75 -90
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +14 -42
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/reqresp/reqresp.ts +3 -1
- package/src/services/service.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/make-test-p2p-clients.ts +0 -2
- package/src/test-helpers/mock-pubsub.ts +3 -6
- package/src/test-helpers/reqresp-nodes.ts +2 -5
- package/src/test-helpers/testbench-utils.ts +1 -1
- package/src/testbench/p2p_client_testbench_worker.ts +2 -6
package/src/services/encoding.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Taken from lodestar: https://github.com/ChainSafe/lodestar
|
|
2
|
-
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { MAX_TX_SIZE_KB, TopicType, getTopicFromString } from '@aztec/stdlib/p2p';
|
|
5
4
|
|
|
6
5
|
import type { RPC } from '@chainsafe/libp2p-gossipsub/message';
|
|
7
6
|
import type { DataTransform } from '@chainsafe/libp2p-gossipsub/types';
|
|
8
7
|
import type { Message } from '@libp2p/interface';
|
|
8
|
+
import { webcrypto } from 'node:crypto';
|
|
9
9
|
import { compressSync, uncompressSync } from 'snappy';
|
|
10
10
|
import xxhashFactory from 'xxhash-wasm';
|
|
11
11
|
|
|
@@ -44,11 +44,10 @@ export function msgIdToStrFn(msgId: Uint8Array): string {
|
|
|
44
44
|
* @param message - The libp2p message
|
|
45
45
|
* @returns The message identifier
|
|
46
46
|
*/
|
|
47
|
-
export function getMsgIdFn(
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return sha256(Buffer.concat(vec)).subarray(0, 20);
|
|
47
|
+
export async function getMsgIdFn({ topic, data }: Message): Promise<Uint8Array> {
|
|
48
|
+
const buffer = Buffer.concat([Buffer.from(topic), data]);
|
|
49
|
+
const hash = await webcrypto.subtle.digest('SHA-256', buffer);
|
|
50
|
+
return Buffer.from(hash.slice(0, 20));
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
const DefaultMaxSizesKb: Record<TopicType, number> = {
|
|
@@ -16,13 +16,12 @@ import {
|
|
|
16
16
|
CheckpointProposal,
|
|
17
17
|
type CheckpointProposalCore,
|
|
18
18
|
type Gossipable,
|
|
19
|
-
P2PClientType,
|
|
20
19
|
P2PMessage,
|
|
21
20
|
type ValidationResult as P2PValidationResult,
|
|
22
21
|
PeerErrorSeverity,
|
|
23
22
|
TopicType,
|
|
24
23
|
createTopicString,
|
|
25
|
-
|
|
24
|
+
getTopicsForConfig,
|
|
26
25
|
metricsTopicStrToLabels,
|
|
27
26
|
} from '@aztec/stdlib/p2p';
|
|
28
27
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -69,9 +68,11 @@ import {
|
|
|
69
68
|
} from '../../msg_validators/index.js';
|
|
70
69
|
import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
|
|
71
70
|
import {
|
|
72
|
-
type
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
type TransactionValidator,
|
|
72
|
+
createFirstStageTxValidationsForGossipedTransactions,
|
|
73
|
+
createSecondStageTxValidationsForGossipedTransactions,
|
|
74
|
+
createTxValidatorForBlockProposalReceivedTxs,
|
|
75
|
+
createTxValidatorForReqResponseReceivedTxs,
|
|
75
76
|
} from '../../msg_validators/tx_validator/factory.js';
|
|
76
77
|
import { GossipSubEvent } from '../../types/index.js';
|
|
77
78
|
import { type PubSubLibp2p, convertToMultiaddr } from '../../util.js';
|
|
@@ -87,6 +88,9 @@ import { PeerScoring } from '../peer-manager/peer_scoring.js';
|
|
|
87
88
|
import type { BatchTxRequesterLibP2PService } from '../reqresp/batch-tx-requester/interface.js';
|
|
88
89
|
import type { P2PReqRespConfig } from '../reqresp/config.js';
|
|
89
90
|
import {
|
|
91
|
+
AuthRequest,
|
|
92
|
+
BlockTxsRequest,
|
|
93
|
+
BlockTxsResponse,
|
|
90
94
|
DEFAULT_SUB_PROTOCOL_VALIDATORS,
|
|
91
95
|
type ReqRespInterface,
|
|
92
96
|
type ReqRespResponse,
|
|
@@ -94,14 +98,9 @@ import {
|
|
|
94
98
|
type ReqRespSubProtocolHandler,
|
|
95
99
|
type ReqRespSubProtocolHandlers,
|
|
96
100
|
type ReqRespSubProtocolValidators,
|
|
101
|
+
StatusMessage,
|
|
97
102
|
type SubProtocolMap,
|
|
98
103
|
ValidationError,
|
|
99
|
-
} from '../reqresp/index.js';
|
|
100
|
-
import {
|
|
101
|
-
AuthRequest,
|
|
102
|
-
BlockTxsRequest,
|
|
103
|
-
BlockTxsResponse,
|
|
104
|
-
StatusMessage,
|
|
105
104
|
pingHandler,
|
|
106
105
|
reqGoodbyeHandler,
|
|
107
106
|
reqRespBlockHandler,
|
|
@@ -135,7 +134,7 @@ type ReceivedMessageValidationResult<T, M = undefined> =
|
|
|
135
134
|
/**
|
|
136
135
|
* Lib P2P implementation of the P2PService interface.
|
|
137
136
|
*/
|
|
138
|
-
export class LibP2PService
|
|
137
|
+
export class LibP2PService extends WithTracer implements P2PService {
|
|
139
138
|
private discoveryRunningPromise?: RunningPromise;
|
|
140
139
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
141
140
|
|
|
@@ -182,7 +181,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
182
181
|
protected logger: Logger;
|
|
183
182
|
|
|
184
183
|
constructor(
|
|
185
|
-
private clientType: T,
|
|
186
184
|
private config: P2PConfig,
|
|
187
185
|
protected node: PubSubLibp2p,
|
|
188
186
|
private peerDiscoveryService: PeerDiscoveryService,
|
|
@@ -262,8 +260,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
262
260
|
* @param txPool - The transaction pool to be accessed by the service.
|
|
263
261
|
* @returns The new service.
|
|
264
262
|
*/
|
|
265
|
-
public static async new
|
|
266
|
-
clientType: T,
|
|
263
|
+
public static async new(
|
|
267
264
|
config: P2PConfig,
|
|
268
265
|
peerId: PeerId,
|
|
269
266
|
deps: {
|
|
@@ -475,7 +472,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
475
472
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
476
473
|
|
|
477
474
|
return new LibP2PService(
|
|
478
|
-
clientType,
|
|
479
475
|
config,
|
|
480
476
|
node,
|
|
481
477
|
peerDiscoveryService,
|
|
@@ -549,7 +545,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
549
545
|
await this.node.start();
|
|
550
546
|
|
|
551
547
|
// Subscribe to standard GossipSub topics by default
|
|
552
|
-
for (const topic of
|
|
548
|
+
for (const topic of getTopicsForConfig(this.config.disableTransactions)) {
|
|
553
549
|
this.subscribeToTopic(this.topicStrings[topic]);
|
|
554
550
|
}
|
|
555
551
|
|
|
@@ -818,9 +814,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
818
814
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
819
815
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
820
816
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
821
|
-
|
|
822
|
-
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
823
|
-
}
|
|
817
|
+
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
824
818
|
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
825
819
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
826
820
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
@@ -906,15 +900,45 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
906
900
|
protected async handleGossipedTx(payloadData: Buffer, msgId: string, source: PeerId) {
|
|
907
901
|
const validationFunc: () => Promise<ReceivedMessageValidationResult<Tx>> = async () => {
|
|
908
902
|
const tx = Tx.fromBuffer(payloadData);
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
903
|
+
|
|
904
|
+
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
905
|
+
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
906
|
+
|
|
907
|
+
// Stage 1: fast validators (metadata, data, timestamps, double-spend, gas, phases, block header)
|
|
908
|
+
const firstStageValidators = await this.createFirstStageMessageValidators(currentBlockNumber, nextSlotTimestamp);
|
|
909
|
+
const firstStageOutcome = await this.runValidations(tx, firstStageValidators);
|
|
910
|
+
if (!firstStageOutcome.allPassed) {
|
|
911
|
+
const { name } = firstStageOutcome.failure;
|
|
912
|
+
let { severity } = firstStageOutcome.failure;
|
|
913
|
+
|
|
914
|
+
// Double spend validator has a special case handler. We perform more detailed examination
|
|
915
|
+
// as to how recently the nullifier was entered into the tree and if the transaction should
|
|
916
|
+
// have 'known' the nullifier existed. This determines the severity of the penalty applied to the peer.
|
|
917
|
+
if (name === 'doubleSpendValidator') {
|
|
918
|
+
const txBlockNumber = BlockNumber(currentBlockNumber + 1);
|
|
919
|
+
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
this.peerManager.penalizePeer(source, severity);
|
|
923
|
+
return { result: TopicValidatorResult.Reject };
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Pool pre-check: see if the pool would accept this tx before doing expensive proof verification
|
|
927
|
+
const canAdd = await this.mempools.txPool.canAddPendingTx(tx);
|
|
928
|
+
if (canAdd === 'ignored') {
|
|
929
|
+
return { result: TopicValidatorResult.Ignore, obj: tx };
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Stage 2: expensive proof verification
|
|
933
|
+
const secondStageValidators = this.createSecondStageMessageValidators();
|
|
934
|
+
const secondStageOutcome = await this.runValidations(tx, secondStageValidators);
|
|
935
|
+
if (!secondStageOutcome.allPassed) {
|
|
936
|
+
const { severity } = secondStageOutcome.failure;
|
|
937
|
+
this.peerManager.penalizePeer(source, severity);
|
|
914
938
|
return { result: TopicValidatorResult.Reject };
|
|
915
939
|
}
|
|
916
940
|
|
|
917
|
-
//
|
|
941
|
+
// Pool add: persist the tx
|
|
918
942
|
const txHash = tx.getTxHash();
|
|
919
943
|
const addResult = await this.mempools.txPool.addPendingTxs([tx], { source: 'gossip' });
|
|
920
944
|
|
|
@@ -922,7 +946,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
922
946
|
const wasIgnored = addResult.ignored.some(h => h.equals(txHash));
|
|
923
947
|
|
|
924
948
|
this.logger.trace(`Validate propagated tx`, {
|
|
925
|
-
isValid,
|
|
926
949
|
wasAccepted,
|
|
927
950
|
wasIgnored,
|
|
928
951
|
[Attributes.P2P_ID]: source.toString(),
|
|
@@ -1537,43 +1560,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1537
1560
|
}
|
|
1538
1561
|
|
|
1539
1562
|
protected createRequestedTxValidator(): TxValidator {
|
|
1540
|
-
return
|
|
1563
|
+
return createTxValidatorForReqResponseReceivedTxs(this.proofVerifier, {
|
|
1541
1564
|
l1ChainId: this.config.l1ChainId,
|
|
1542
1565
|
rollupVersion: this.config.rollupVersion,
|
|
1543
1566
|
});
|
|
1544
1567
|
}
|
|
1545
1568
|
|
|
1546
|
-
@trackSpan('Libp2pService.validatePropagatedTx', tx => ({
|
|
1547
|
-
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
1548
|
-
}))
|
|
1549
|
-
protected async validatePropagatedTx(tx: Tx, peerId: PeerId): Promise<boolean> {
|
|
1550
|
-
const currentBlockNumber = await this.archiver.getBlockNumber();
|
|
1551
|
-
|
|
1552
|
-
// We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
|
|
1553
|
-
const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
|
|
1554
|
-
const messageValidators = await this.createMessageValidators(currentBlockNumber, nextSlotTimestamp);
|
|
1555
|
-
|
|
1556
|
-
for (const validator of messageValidators) {
|
|
1557
|
-
const outcome = await this.runValidations(tx, validator);
|
|
1558
|
-
|
|
1559
|
-
if (outcome.allPassed) {
|
|
1560
|
-
continue;
|
|
1561
|
-
}
|
|
1562
|
-
const { name } = outcome.failure;
|
|
1563
|
-
let { severity } = outcome.failure;
|
|
1564
|
-
|
|
1565
|
-
// Double spend validator has a special case handler
|
|
1566
|
-
if (name === 'doubleSpendValidator') {
|
|
1567
|
-
const txBlockNumber = BlockNumber(currentBlockNumber + 1); // tx is expected to be in the next block
|
|
1568
|
-
severity = await this.handleDoubleSpendFailure(tx, txBlockNumber);
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
this.peerManager.penalizePeer(peerId, severity);
|
|
1572
|
-
return false;
|
|
1573
|
-
}
|
|
1574
|
-
return true;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
1569
|
private async getGasFees(blockNumber: BlockNumber): Promise<GasFees> {
|
|
1578
1570
|
if (blockNumber === this.feesCache?.blockNumber) {
|
|
1579
1571
|
return this.feesCache.gasFees;
|
|
@@ -1601,60 +1593,53 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1601
1593
|
};
|
|
1602
1594
|
}
|
|
1603
1595
|
|
|
1604
|
-
public async
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1596
|
+
public async validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void> {
|
|
1597
|
+
const validator = createTxValidatorForBlockProposalReceivedTxs(
|
|
1598
|
+
this.proofVerifier,
|
|
1599
|
+
{ l1ChainId: this.config.l1ChainId, rollupVersion: this.config.rollupVersion },
|
|
1600
|
+
this.logger.getBindings(),
|
|
1601
|
+
);
|
|
1610
1602
|
|
|
1611
|
-
await Promise.all(
|
|
1603
|
+
const results = await Promise.all(
|
|
1612
1604
|
txs.map(async tx => {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
if (!outcome.allPassed) {
|
|
1616
|
-
throw new Error('Invalid tx detected', { cause: { outcome } });
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1605
|
+
const result = await validator.validateTx(tx);
|
|
1606
|
+
return result.result !== 'invalid';
|
|
1619
1607
|
}),
|
|
1620
1608
|
);
|
|
1609
|
+
if (results.some(value => value === false)) {
|
|
1610
|
+
throw new Error('Invalid tx detected');
|
|
1611
|
+
}
|
|
1621
1612
|
}
|
|
1622
1613
|
|
|
1623
|
-
/**
|
|
1624
|
-
|
|
1625
|
-
*
|
|
1626
|
-
* Each validator is a pair of a validator and a severity.
|
|
1627
|
-
* If a validator fails, the peer is penalized with the severity of the validator.
|
|
1628
|
-
*
|
|
1629
|
-
* @param currentBlockNumber - The current synced block number.
|
|
1630
|
-
* @param nextSlotTimestamp - The timestamp of the next slot (used to validate txs are not expired).
|
|
1631
|
-
* @returns The message validators.
|
|
1632
|
-
*/
|
|
1633
|
-
private async createMessageValidators(
|
|
1614
|
+
/** Creates the first stage (fast) validators for gossiped transactions. */
|
|
1615
|
+
protected async createFirstStageMessageValidators(
|
|
1634
1616
|
currentBlockNumber: BlockNumber,
|
|
1635
1617
|
nextSlotTimestamp: UInt64,
|
|
1636
|
-
): Promise<Record<string,
|
|
1618
|
+
): Promise<Record<string, TransactionValidator>> {
|
|
1637
1619
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1638
1620
|
const allowedInSetup = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
|
|
1621
|
+
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1639
1622
|
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
return createTxMessageValidators(
|
|
1623
|
+
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1643
1624
|
nextSlotTimestamp,
|
|
1644
|
-
|
|
1625
|
+
blockNumber,
|
|
1645
1626
|
this.worldStateSynchronizer,
|
|
1646
1627
|
gasFees,
|
|
1647
1628
|
this.config.l1ChainId,
|
|
1648
1629
|
this.config.rollupVersion,
|
|
1649
1630
|
protocolContractsHash,
|
|
1650
1631
|
this.archiver,
|
|
1651
|
-
this.proofVerifier,
|
|
1652
1632
|
!this.config.disableTransactions,
|
|
1653
1633
|
allowedInSetup,
|
|
1654
1634
|
this.logger.getBindings(),
|
|
1655
1635
|
);
|
|
1656
1636
|
}
|
|
1657
1637
|
|
|
1638
|
+
/** Creates the second stage (expensive proof verification) validators for gossiped transactions. */
|
|
1639
|
+
protected createSecondStageMessageValidators(): Record<string, TransactionValidator> {
|
|
1640
|
+
return createSecondStageTxValidationsForGossipedTransactions(this.proofVerifier, this.logger.getBindings());
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1658
1643
|
/**
|
|
1659
1644
|
* Run validations on a tx.
|
|
1660
1645
|
* @param tx - The tx to validate.
|
|
@@ -1663,7 +1648,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1663
1648
|
*/
|
|
1664
1649
|
private async runValidations(
|
|
1665
1650
|
tx: Tx,
|
|
1666
|
-
messageValidators: Record<string,
|
|
1651
|
+
messageValidators: Record<string, TransactionValidator>,
|
|
1667
1652
|
): Promise<ValidationOutcome> {
|
|
1668
1653
|
const validationPromises = Object.entries(messageValidators).map(async ([name, { validator, severity }]) => {
|
|
1669
1654
|
const { result } = await validator.validateTx(tx);
|
|
@@ -8,7 +8,6 @@ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
|
8
8
|
import { Tx, TxArray, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
10
|
import type { PeerId } from '@libp2p/interface';
|
|
11
|
-
import { peerIdFromString } from '@libp2p/peer-id';
|
|
12
11
|
|
|
13
12
|
import type { IMissingTxsTracker } from '../../tx_collection/missing_txs_tracker.js';
|
|
14
13
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
@@ -90,10 +89,9 @@ export class BatchTxRequester {
|
|
|
90
89
|
if (this.opts.peerCollection) {
|
|
91
90
|
this.peers = this.opts.peerCollection;
|
|
92
91
|
} else {
|
|
93
|
-
const initialPeers = this.p2pService.connectionSampler.getPeerListSortedByConnectionCountAsc();
|
|
94
92
|
const badPeerThreshold = this.opts.badPeerThreshold ?? DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD;
|
|
95
93
|
this.peers = new PeerCollection(
|
|
96
|
-
|
|
94
|
+
this.p2pService.connectionSampler,
|
|
97
95
|
this.pinnedPeer,
|
|
98
96
|
this.dateProvider,
|
|
99
97
|
badPeerThreshold,
|
|
@@ -227,7 +225,6 @@ export class BatchTxRequester {
|
|
|
227
225
|
* Starts dumb worker loops
|
|
228
226
|
* */
|
|
229
227
|
private async dumbRequester() {
|
|
230
|
-
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
231
228
|
const nextBatchIndex = this.makeRoundRobinIndexer();
|
|
232
229
|
|
|
233
230
|
// Chunk missing tx hashes into batches of txBatchSize, wrapping around to ensure no peer gets less than txBatchSize
|
|
@@ -263,15 +260,9 @@ export class BatchTxRequester {
|
|
|
263
260
|
return { blockRequest, txs };
|
|
264
261
|
};
|
|
265
262
|
|
|
266
|
-
const
|
|
267
|
-
const peers = this.peers.getDumbPeersToQuery();
|
|
268
|
-
const idx = nextPeerIndex(() => peers.length);
|
|
269
|
-
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const workerCount = Math.min(this.dumbParallelWorkerCount, this.peers.getAllPeers().size);
|
|
263
|
+
const workerCount = this.dumbParallelWorkerCount;
|
|
273
264
|
const workers = Array.from({ length: workerCount }, (_, index) =>
|
|
274
|
-
this.dumbWorkerLoop(
|
|
265
|
+
this.dumbWorkerLoop(this.peers.nextDumbPeerToQuery.bind(this.peers), makeRequest, index + 1),
|
|
275
266
|
);
|
|
276
267
|
|
|
277
268
|
await Promise.allSettled(workers);
|
|
@@ -332,14 +323,6 @@ export class BatchTxRequester {
|
|
|
332
323
|
* Starts smart worker loops
|
|
333
324
|
* */
|
|
334
325
|
private async smartRequester() {
|
|
335
|
-
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
336
|
-
|
|
337
|
-
const nextPeer = () => {
|
|
338
|
-
const peers = this.peers.getSmartPeersToQuery();
|
|
339
|
-
const idx = nextPeerIndex(() => peers.length);
|
|
340
|
-
return idx === undefined ? undefined : peerIdFromString(peers[idx]);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
326
|
const makeRequest = (pid: PeerId) => {
|
|
344
327
|
const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
|
|
345
328
|
const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
|
|
@@ -350,9 +333,8 @@ export class BatchTxRequester {
|
|
|
350
333
|
return { blockRequest, txs };
|
|
351
334
|
};
|
|
352
335
|
|
|
353
|
-
const workers = Array.from(
|
|
354
|
-
|
|
355
|
-
(_, index) => this.smartWorkerLoop(nextPeer, makeRequest, index + 1),
|
|
336
|
+
const workers = Array.from({ length: this.smartParallelWorkerCount }, (_, index) =>
|
|
337
|
+
this.smartWorkerLoop(this.peers.nextSmartPeerToQuery.bind(this.peers), makeRequest, index + 1),
|
|
356
338
|
);
|
|
357
339
|
|
|
358
340
|
await Promise.allSettled(workers);
|
|
@@ -387,26 +369,18 @@ export class BatchTxRequester {
|
|
|
387
369
|
if (weRanOutOfPeersToQuery) {
|
|
388
370
|
this.logger.debug(`Worker loop smart: No more peers to query`);
|
|
389
371
|
|
|
390
|
-
// If
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
const thereAreSomeRateLimitedSmartPeers = nextSmartPeerDelay !== undefined;
|
|
397
|
-
if (thereAreSomeRateLimitedSmartPeers) {
|
|
398
|
-
await this.sleepClampedToDeadline(nextSmartPeerDelay);
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
this.logger.debug(`Worker loop smart: No more smart peers to query killing ${workerIndex}`);
|
|
403
|
-
break;
|
|
372
|
+
// If we have rate limited peers wait for them.
|
|
373
|
+
const nextSmartPeerDelay = this.peers.getNextSmartPeerAvailabilityDelayMs();
|
|
374
|
+
const thereAreSomeRateLimitedSmartPeers = nextSmartPeerDelay !== undefined;
|
|
375
|
+
if (thereAreSomeRateLimitedSmartPeers) {
|
|
376
|
+
await this.sleepClampedToDeadline(nextSmartPeerDelay);
|
|
377
|
+
continue;
|
|
404
378
|
}
|
|
405
379
|
|
|
406
|
-
// Otherwise there are still some dumb peers that could become smart.
|
|
407
380
|
// We end up here when all known smart peers became temporarily unavailable via combination of
|
|
408
381
|
// (bad, in-flight, or rate-limited) or in some weird scenario all current smart peers turn bad which is permanent
|
|
409
|
-
// but dumb peers
|
|
382
|
+
// but there are dumb peers that could be promoted
|
|
383
|
+
// or new peer can join as dumb and be promoted later
|
|
410
384
|
//
|
|
411
385
|
// When a dumb peer responds with valid txIndices, it gets
|
|
412
386
|
// promoted to smart and releases the semaphore, waking this worker.
|
|
@@ -599,9 +573,7 @@ export class BatchTxRequester {
|
|
|
599
573
|
this.markTxsPeerHas(peerId, response);
|
|
600
574
|
|
|
601
575
|
// Unblock smart workers
|
|
602
|
-
|
|
603
|
-
this.smartRequesterSemaphore.release();
|
|
604
|
-
}
|
|
576
|
+
this.smartRequesterSemaphore.release();
|
|
605
577
|
}
|
|
606
578
|
|
|
607
579
|
private isBlockResponseValid(response: BlockTxsResponse): boolean {
|
|
@@ -2,18 +2,22 @@ import type { DateProvider } from '@aztec/foundation/timer';
|
|
|
2
2
|
import type { PeerErrorSeverity } from '@aztec/stdlib/p2p';
|
|
3
3
|
|
|
4
4
|
import type { PeerId } from '@libp2p/interface';
|
|
5
|
+
import { peerIdFromString } from '@libp2p/peer-id';
|
|
5
6
|
|
|
7
|
+
import type { ConnectionSampler } from '../connection-sampler/connection_sampler.js';
|
|
6
8
|
import { DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD } from './config.js';
|
|
7
9
|
import type { IPeerPenalizer } from './interface.js';
|
|
8
10
|
|
|
9
11
|
export const RATE_LIMIT_EXCEEDED_PEER_CACHE_TTL = 1000; // 1s
|
|
10
12
|
|
|
11
13
|
export interface IPeerCollection {
|
|
12
|
-
getAllPeers(): Set<string>;
|
|
13
|
-
getSmartPeers(): Set<string>;
|
|
14
14
|
markPeerSmart(peerId: PeerId): void;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
/** Sample next peer in round-robin fashion. No smart peers if returns undefined */
|
|
17
|
+
nextSmartPeerToQuery(): PeerId | undefined;
|
|
18
|
+
/** Sample next peer in round-robin fashion. No dumb peers if returns undefined */
|
|
19
|
+
nextDumbPeerToQuery(): PeerId | undefined;
|
|
20
|
+
|
|
17
21
|
thereAreSomeDumbRatelimitExceededPeers(): boolean;
|
|
18
22
|
penalisePeer(peerId: PeerId, severity: PeerErrorSeverity): void;
|
|
19
23
|
unMarkPeerAsBad(peerId: PeerId): void;
|
|
@@ -28,8 +32,6 @@ export interface IPeerCollection {
|
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
export class PeerCollection implements IPeerCollection {
|
|
31
|
-
private readonly peers;
|
|
32
|
-
|
|
33
35
|
private readonly smartPeers = new Set<string>();
|
|
34
36
|
private readonly inFlightPeers = new Set<string>();
|
|
35
37
|
private readonly rateLimitExceededPeers = new Map<string, number>();
|
|
@@ -37,46 +39,60 @@ export class PeerCollection implements IPeerCollection {
|
|
|
37
39
|
private readonly badPeers = new Set<string>();
|
|
38
40
|
|
|
39
41
|
constructor(
|
|
40
|
-
|
|
42
|
+
private readonly connectionSampler: Pick<ConnectionSampler, 'getPeerListSortedByConnectionCountAsc'>,
|
|
41
43
|
private readonly pinnedPeerId: PeerId | undefined,
|
|
42
44
|
private readonly dateProvider: DateProvider,
|
|
43
45
|
private readonly badPeerThreshold: number = DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD,
|
|
44
46
|
private readonly peerPenalizer?: IPeerPenalizer,
|
|
45
47
|
) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Pinned peer is treaded specially, always mark it as in-flight
|
|
48
|
+
// Pinned peer is treated specially, always mark it as in-flight
|
|
49
49
|
// and never return it as part of smart/dumb peers
|
|
50
50
|
if (this.pinnedPeerId) {
|
|
51
51
|
const peerIdStr = this.pinnedPeerId.toString();
|
|
52
52
|
this.inFlightPeers.add(peerIdStr);
|
|
53
|
-
this.peers.delete(peerIdStr);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
public
|
|
58
|
-
|
|
56
|
+
public markPeerSmart(peerId: PeerId): void {
|
|
57
|
+
this.smartPeers.add(peerId.toString());
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
// We keep track of all peers that are queried for peer sampling algorithm
|
|
61
|
+
private queriedSmartPeers: Set<string> = new Set<string>();
|
|
62
|
+
private queriedDumbPeers: Set<string> = new Set<string>();
|
|
63
|
+
|
|
64
|
+
private static nextPeer(allPeers: Set<string>, queried: Set<string>): PeerId | undefined {
|
|
65
|
+
if (allPeers.size === 0) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const availablePeers = allPeers.difference(queried);
|
|
69
|
+
let [first] = availablePeers;
|
|
70
|
+
if (first === undefined) {
|
|
71
|
+
// We queried all peers. Start over
|
|
72
|
+
[first] = allPeers;
|
|
73
|
+
queried.clear();
|
|
74
|
+
}
|
|
75
|
+
queried.add(first);
|
|
76
|
+
return peerIdFromString(first);
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
public
|
|
66
|
-
this.
|
|
79
|
+
public nextSmartPeerToQuery(): PeerId | undefined {
|
|
80
|
+
return PeerCollection.nextPeer(this.availableSmartPeers, this.queriedSmartPeers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public nextDumbPeerToQuery(): PeerId | undefined {
|
|
84
|
+
return PeerCollection.nextPeer(this.availableDumbPeers, this.queriedDumbPeers);
|
|
67
85
|
}
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
return
|
|
87
|
+
private get availableSmartPeers(): Set<string> {
|
|
88
|
+
return this.peers.intersection(
|
|
71
89
|
this.smartPeers.difference(this.getBadPeers().union(this.inFlightPeers).union(this.getRateLimitExceededPeers())),
|
|
72
90
|
);
|
|
73
91
|
}
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
this.
|
|
78
|
-
this.smartPeers.union(this.getBadPeers()).union(this.inFlightPeers).union(this.getRateLimitExceededPeers()),
|
|
79
|
-
),
|
|
93
|
+
private get availableDumbPeers(): Set<string> {
|
|
94
|
+
return this.peers.difference(
|
|
95
|
+
this.smartPeers.union(this.getBadPeers()).union(this.inFlightPeers).union(this.getRateLimitExceededPeers()),
|
|
80
96
|
);
|
|
81
97
|
}
|
|
82
98
|
|
|
@@ -202,4 +218,27 @@ export class PeerCollection implements IPeerCollection {
|
|
|
202
218
|
|
|
203
219
|
return minExpiry! - now;
|
|
204
220
|
}
|
|
221
|
+
|
|
222
|
+
private orderedPeers: Set<string> = new Set();
|
|
223
|
+
|
|
224
|
+
private get peers(): Set<string> {
|
|
225
|
+
const pinnedStr = this.pinnedPeerId?.toString();
|
|
226
|
+
const currentlyConnected = new Set(
|
|
227
|
+
this.connectionSampler
|
|
228
|
+
.getPeerListSortedByConnectionCountAsc()
|
|
229
|
+
.map(p => p.toString())
|
|
230
|
+
.filter(p => p !== pinnedStr),
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
// Remove disconnected peers, preserving order of the rest.
|
|
234
|
+
this.orderedPeers = this.orderedPeers.intersection(currentlyConnected);
|
|
235
|
+
|
|
236
|
+
// Append newly connected peers at the end (lowest priority).
|
|
237
|
+
for (const peer of currentlyConnected) {
|
|
238
|
+
if (!this.orderedPeers.has(peer)) {
|
|
239
|
+
this.orderedPeers.add(peer);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return this.orderedPeers;
|
|
243
|
+
}
|
|
205
244
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import { Tx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { createTxValidatorForReqResponseReceivedTxs } from '../../../msg_validators/index.js';
|
|
5
5
|
|
|
6
6
|
export interface BatchRequestTxValidatorConfig {
|
|
7
7
|
l1ChainId: number;
|
|
@@ -29,7 +29,7 @@ export class BatchRequestTxValidator implements IBatchRequestTxValidator {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static createRequestedTxValidator(config: BatchRequestTxValidatorConfig): TxValidator {
|
|
32
|
-
return
|
|
32
|
+
return createTxValidatorForReqResponseReceivedTxs(config.proofVerifier, {
|
|
33
33
|
l1ChainId: config.l1ChainId,
|
|
34
34
|
rollupVersion: config.rollupVersion,
|
|
35
35
|
});
|
|
@@ -627,7 +627,9 @@ export class ReqResp implements ReqRespInterface {
|
|
|
627
627
|
// and that this stream should be dropped
|
|
628
628
|
const isMessageToNotWarn =
|
|
629
629
|
err instanceof Error &&
|
|
630
|
-
['stream reset', 'Cannot push value onto an ended pushable'].some(msg =>
|
|
630
|
+
['stream reset', 'Cannot push value onto an ended pushable', 'read ECONNRESET'].some(msg =>
|
|
631
|
+
err.message.includes(msg),
|
|
632
|
+
);
|
|
631
633
|
const level = isMessageToNotWarn ? 'debug' : 'warn';
|
|
632
634
|
this.logger[level]('Unknown stream error while handling the stream, aborting', {
|
|
633
635
|
protocol,
|
package/src/services/service.ts
CHANGED
|
@@ -139,7 +139,7 @@ export interface P2PService {
|
|
|
139
139
|
/** Returns the number of peers in the GossipSub mesh for a given topic type. */
|
|
140
140
|
getGossipMeshPeerCount(topicType: TopicType): number;
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
validateTxsReceivedInBlockProposal(txs: Tx[]): Promise<void>;
|
|
143
143
|
|
|
144
144
|
addReqRespSubProtocol(
|
|
145
145
|
subProtocol: ReqRespSubProtocol,
|
|
@@ -25,7 +25,7 @@ export class TxProvider implements ITxProvider {
|
|
|
25
25
|
constructor(
|
|
26
26
|
private txCollection: TxCollection,
|
|
27
27
|
private txPool: TxPoolV2,
|
|
28
|
-
private
|
|
28
|
+
private blockProposalTransactionValidator: Pick<P2PClient, 'validateTxsReceivedInBlockProposal'>,
|
|
29
29
|
private log: Logger = createLogger('p2p:tx-collector'),
|
|
30
30
|
client: TelemetryClient = getTelemetryClient(),
|
|
31
31
|
) {
|
|
@@ -227,7 +227,7 @@ export class TxProvider implements ITxProvider {
|
|
|
227
227
|
if (txs.length === 0) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
await this.
|
|
230
|
+
await this.blockProposalTransactionValidator.validateTxsReceivedInBlockProposal(txs);
|
|
231
231
|
await this.txPool.addProtectedTxs(txs, blockHeader);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
@@ -7,7 +7,6 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
7
7
|
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
8
8
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
9
9
|
import type { WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
11
10
|
|
|
12
11
|
import { createP2PClient } from '../client/index.js';
|
|
13
12
|
import type { P2PClient } from '../client/p2p_client.js';
|
|
@@ -98,7 +97,6 @@ export async function makeTestP2PClient(
|
|
|
98
97
|
const kvStore = await openTmpStore('test');
|
|
99
98
|
|
|
100
99
|
const client = await createP2PClient(
|
|
101
|
-
P2PClientType.Full,
|
|
102
100
|
config,
|
|
103
101
|
l2BlockSource,
|
|
104
102
|
proofVerifier,
|