@aztec/p2p 0.0.1-commit.358457c → 0.0.1-commit.381b1a9
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 +12 -7
- package/dest/client/interface.d.ts +4 -4
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +4 -4
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +9 -27
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -2
- package/dest/config.d.ts +32 -11
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +85 -31
- package/dest/mem_pools/tx_pool/priority.d.ts +2 -2
- package/dest/mem_pools/tx_pool/priority.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/priority.js +4 -4
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +3 -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/interfaces.d.ts +7 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +8 -6
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- 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 +3 -3
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +30 -7
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +62 -16
- 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_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 +38 -30
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/block_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/block_proposal_validator.js +10 -2
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts +6 -4
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/checkpoint_proposal_validator.js +16 -2
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts +13 -8
- package/dest/msg_validators/proposal_validator/proposal_validator.d.ts.map +1 -1
- package/dest/msg_validators/proposal_validator/proposal_validator.js +48 -36
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts +2 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/allowed_public_setup.js +24 -20
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts +17 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/allowed_setup_helpers.js +24 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts +9 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/contract_instance_validator.js +48 -0
- package/dest/msg_validators/tx_validator/factory.d.ts +15 -4
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +21 -8
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/fee_payer_balance.js +6 -2
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +13 -4
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +39 -9
- 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/phases_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/phases_validator.js +44 -23
- 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 +6 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +31 -23
- 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 +37 -14
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +11 -17
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +15 -49
- 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 +1 -1
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +2 -1
- package/dest/testbench/p2p_client_testbench_worker.js +7 -6
- package/dest/testbench/worker_client_manager.d.ts +3 -1
- package/dest/testbench/worker_client_manager.d.ts.map +1 -1
- package/dest/testbench/worker_client_manager.js +4 -1
- package/package.json +14 -14
- package/src/client/factory.ts +15 -14
- package/src/client/interface.ts +3 -9
- package/src/client/p2p_client.ts +7 -38
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -2
- package/src/config.ts +124 -34
- package/src/mem_pools/tx_pool/priority.ts +4 -4
- package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +3 -1
- package/src/mem_pools/tx_pool_v2/README.md +9 -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/interfaces.ts +11 -1
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +15 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +2 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -1
- package/src/mem_pools/tx_pool_v2/interfaces.ts +3 -3
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +89 -17
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +11 -11
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +43 -27
- package/src/msg_validators/proposal_validator/block_proposal_validator.ts +14 -4
- package/src/msg_validators/proposal_validator/checkpoint_proposal_validator.ts +20 -7
- package/src/msg_validators/proposal_validator/proposal_validator.ts +63 -40
- package/src/msg_validators/tx_validator/allowed_public_setup.ts +22 -27
- package/src/msg_validators/tx_validator/allowed_setup_helpers.ts +31 -0
- package/src/msg_validators/tx_validator/contract_instance_validator.ts +56 -0
- package/src/msg_validators/tx_validator/factory.ts +22 -2
- package/src/msg_validators/tx_validator/fee_payer_balance.ts +6 -2
- package/src/msg_validators/tx_validator/gas_validator.ts +41 -8
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/phases_validator.ts +51 -26
- package/src/services/encoding.ts +5 -6
- package/src/services/libp2p/libp2p_service.ts +30 -21
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +42 -14
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +24 -63
- 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 -0
- package/src/testbench/p2p_client_testbench_worker.ts +3 -6
- package/src/testbench/worker_client_manager.ts +11 -4
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts +0 -23
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.d.ts.map +0 -1
- package/dest/msg_validators/proposal_validator/proposal_validator_test_suite.js +0 -212
- package/src/msg_validators/proposal_validator/proposal_validator_test_suite.ts +0 -230
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
2
|
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { maxBy } from '@aztec/foundation/collection';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { type Logger, createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
@@ -16,13 +17,13 @@ import {
|
|
|
16
17
|
CheckpointProposal,
|
|
17
18
|
type CheckpointProposalCore,
|
|
18
19
|
type Gossipable,
|
|
19
|
-
P2PClientType,
|
|
20
20
|
P2PMessage,
|
|
21
21
|
type ValidationResult as P2PValidationResult,
|
|
22
22
|
PeerErrorSeverity,
|
|
23
|
+
PeerErrorSeverityByHarshness,
|
|
23
24
|
TopicType,
|
|
24
25
|
createTopicString,
|
|
25
|
-
|
|
26
|
+
getTopicsForConfig,
|
|
26
27
|
metricsTopicStrToLabels,
|
|
27
28
|
} from '@aztec/stdlib/p2p';
|
|
28
29
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
@@ -135,7 +136,7 @@ type ReceivedMessageValidationResult<T, M = undefined> =
|
|
|
135
136
|
/**
|
|
136
137
|
* Lib P2P implementation of the P2PService interface.
|
|
137
138
|
*/
|
|
138
|
-
export class LibP2PService
|
|
139
|
+
export class LibP2PService extends WithTracer implements P2PService {
|
|
139
140
|
private discoveryRunningPromise?: RunningPromise;
|
|
140
141
|
private msgIdSeenValidators: Record<TopicType, MessageSeenValidator> = {} as Record<TopicType, MessageSeenValidator>;
|
|
141
142
|
|
|
@@ -182,7 +183,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
182
183
|
protected logger: Logger;
|
|
183
184
|
|
|
184
185
|
constructor(
|
|
185
|
-
private clientType: T,
|
|
186
186
|
private config: P2PConfig,
|
|
187
187
|
protected node: PubSubLibp2p,
|
|
188
188
|
private peerDiscoveryService: PeerDiscoveryService,
|
|
@@ -224,10 +224,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
224
224
|
this.protocolVersion,
|
|
225
225
|
);
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, {
|
|
227
|
+
const proposalValidatorOpts = {
|
|
229
228
|
txsPermitted: !config.disableTransactions,
|
|
230
|
-
|
|
229
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
230
|
+
};
|
|
231
|
+
this.blockProposalValidator = new BlockProposalValidator(epochCache, proposalValidatorOpts);
|
|
232
|
+
this.checkpointProposalValidator = new CheckpointProposalValidator(epochCache, proposalValidatorOpts);
|
|
231
233
|
this.checkpointAttestationValidator = config.fishermanMode
|
|
232
234
|
? new FishermanAttestationValidator(epochCache, mempools.attestationPool, telemetry)
|
|
233
235
|
: new CheckpointAttestationValidator(epochCache);
|
|
@@ -235,11 +237,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
235
237
|
this.gossipSubEventHandler = this.handleGossipSubEvent.bind(this);
|
|
236
238
|
|
|
237
239
|
this.blockReceivedCallback = async (block: BlockProposal): Promise<boolean> => {
|
|
238
|
-
this.logger.
|
|
239
|
-
`Handler not yet registered
|
|
240
|
+
this.logger.warn(
|
|
241
|
+
`Handler for block received not yet registered on P2P service. Received block ${block.blockNumber} for slot ${block.slotNumber} from peer.`,
|
|
240
242
|
{ p2pMessageIdentifier: await block.p2pMessageLoggingIdentifier() },
|
|
241
243
|
);
|
|
242
|
-
return
|
|
244
|
+
return true;
|
|
243
245
|
};
|
|
244
246
|
|
|
245
247
|
this.checkpointReceivedCallback = (
|
|
@@ -262,8 +264,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
262
264
|
* @param txPool - The transaction pool to be accessed by the service.
|
|
263
265
|
* @returns The new service.
|
|
264
266
|
*/
|
|
265
|
-
public static async new
|
|
266
|
-
clientType: T,
|
|
267
|
+
public static async new(
|
|
267
268
|
config: P2PConfig,
|
|
268
269
|
peerId: PeerId,
|
|
269
270
|
deps: {
|
|
@@ -475,7 +476,6 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
475
476
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
476
477
|
|
|
477
478
|
return new LibP2PService(
|
|
478
|
-
clientType,
|
|
479
479
|
config,
|
|
480
480
|
node,
|
|
481
481
|
peerDiscoveryService,
|
|
@@ -549,7 +549,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
549
549
|
await this.node.start();
|
|
550
550
|
|
|
551
551
|
// Subscribe to standard GossipSub topics by default
|
|
552
|
-
for (const topic of
|
|
552
|
+
for (const topic of getTopicsForConfig(this.config.disableTransactions)) {
|
|
553
553
|
this.subscribeToTopic(this.topicStrings[topic]);
|
|
554
554
|
}
|
|
555
555
|
|
|
@@ -818,9 +818,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
818
818
|
if (msg.topic === this.topicStrings[TopicType.tx]) {
|
|
819
819
|
await this.handleGossipedTx(p2pMessage.payload, msgId, source);
|
|
820
820
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_attestation]) {
|
|
821
|
-
|
|
822
|
-
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
823
|
-
}
|
|
821
|
+
await this.processCheckpointAttestationFromPeer(p2pMessage.payload, msgId, source);
|
|
824
822
|
} else if (msg.topic === this.topicStrings[TopicType.block_proposal]) {
|
|
825
823
|
await this.processBlockFromPeer(p2pMessage.payload, msgId, source);
|
|
826
824
|
} else if (msg.topic === this.topicStrings[TopicType.checkpoint_proposal]) {
|
|
@@ -1194,7 +1192,7 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1194
1192
|
// Note: Validators do NOT attest to individual blocks, only to checkpoint proposals.
|
|
1195
1193
|
const isValid = await this.blockReceivedCallback(block, sender);
|
|
1196
1194
|
if (!isValid) {
|
|
1197
|
-
this.logger.
|
|
1195
|
+
this.logger.info(`Block proposal validation failed for block ${block.blockNumber}`, block.toBlockInfo());
|
|
1198
1196
|
}
|
|
1199
1197
|
}
|
|
1200
1198
|
|
|
@@ -1623,8 +1621,12 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1623
1621
|
nextSlotTimestamp: UInt64,
|
|
1624
1622
|
): Promise<Record<string, TransactionValidator>> {
|
|
1625
1623
|
const gasFees = await this.getGasFees(currentBlockNumber);
|
|
1626
|
-
const allowedInSetup =
|
|
1624
|
+
const allowedInSetup = [
|
|
1625
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
1626
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
1627
|
+
];
|
|
1627
1628
|
const blockNumber = BlockNumber(currentBlockNumber + 1);
|
|
1629
|
+
const l1Constants = await this.archiver.getL1Constants();
|
|
1628
1630
|
|
|
1629
1631
|
return createFirstStageTxValidationsForGossipedTransactions(
|
|
1630
1632
|
nextSlotTimestamp,
|
|
@@ -1638,6 +1640,11 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1638
1640
|
!this.config.disableTransactions,
|
|
1639
1641
|
allowedInSetup,
|
|
1640
1642
|
this.logger.getBindings(),
|
|
1643
|
+
{
|
|
1644
|
+
rollupManaLimit: l1Constants.rollupManaLimit,
|
|
1645
|
+
maxBlockL2Gas: this.config.validateMaxL2BlockGas,
|
|
1646
|
+
maxBlockDAGas: this.config.validateMaxDABlockGas,
|
|
1647
|
+
},
|
|
1641
1648
|
);
|
|
1642
1649
|
}
|
|
1643
1650
|
|
|
@@ -1663,8 +1670,10 @@ export class LibP2PService<T extends P2PClientType = P2PClientType.Full> extends
|
|
|
1663
1670
|
|
|
1664
1671
|
// A promise that resolves when all validations have been run
|
|
1665
1672
|
const allValidations = await Promise.all(validationPromises);
|
|
1666
|
-
const
|
|
1667
|
-
if (
|
|
1673
|
+
const failures = allValidations.filter(x => !x.isValid);
|
|
1674
|
+
if (failures.length > 0) {
|
|
1675
|
+
// Pick the most severe failure (lowest tolerance = harshest penalty)
|
|
1676
|
+
const failed = maxBy(failures, f => PeerErrorSeverityByHarshness.indexOf(f.severity))!;
|
|
1668
1677
|
return {
|
|
1669
1678
|
allPassed: false,
|
|
1670
1679
|
failure: {
|
|
@@ -8,6 +8,7 @@ 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';
|
|
11
12
|
|
|
12
13
|
import type { IMissingTxsTracker } from '../../tx_collection/missing_txs_tracker.js';
|
|
13
14
|
import { ReqRespSubProtocol } from '.././interface.js';
|
|
@@ -89,9 +90,10 @@ export class BatchTxRequester {
|
|
|
89
90
|
if (this.opts.peerCollection) {
|
|
90
91
|
this.peers = this.opts.peerCollection;
|
|
91
92
|
} else {
|
|
93
|
+
const initialPeers = this.p2pService.connectionSampler.getPeerListSortedByConnectionCountAsc();
|
|
92
94
|
const badPeerThreshold = this.opts.badPeerThreshold ?? DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD;
|
|
93
95
|
this.peers = new PeerCollection(
|
|
94
|
-
|
|
96
|
+
initialPeers,
|
|
95
97
|
this.pinnedPeer,
|
|
96
98
|
this.dateProvider,
|
|
97
99
|
badPeerThreshold,
|
|
@@ -225,6 +227,7 @@ export class BatchTxRequester {
|
|
|
225
227
|
* Starts dumb worker loops
|
|
226
228
|
* */
|
|
227
229
|
private async dumbRequester() {
|
|
230
|
+
const nextPeerIndex = this.makeRoundRobinIndexer();
|
|
228
231
|
const nextBatchIndex = this.makeRoundRobinIndexer();
|
|
229
232
|
|
|
230
233
|
// Chunk missing tx hashes into batches of txBatchSize, wrapping around to ensure no peer gets less than txBatchSize
|
|
@@ -260,9 +263,15 @@ export class BatchTxRequester {
|
|
|
260
263
|
return { blockRequest, txs };
|
|
261
264
|
};
|
|
262
265
|
|
|
263
|
-
const
|
|
266
|
+
const nextPeer = () => {
|
|
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);
|
|
264
273
|
const workers = Array.from({ length: workerCount }, (_, index) =>
|
|
265
|
-
this.dumbWorkerLoop(
|
|
274
|
+
this.dumbWorkerLoop(nextPeer, makeRequest, index + 1),
|
|
266
275
|
);
|
|
267
276
|
|
|
268
277
|
await Promise.allSettled(workers);
|
|
@@ -323,6 +332,14 @@ export class BatchTxRequester {
|
|
|
323
332
|
* Starts smart worker loops
|
|
324
333
|
* */
|
|
325
334
|
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
|
+
|
|
326
343
|
const makeRequest = (pid: PeerId) => {
|
|
327
344
|
const txs = this.txsMetadata.getTxsToRequestFromThePeer(pid);
|
|
328
345
|
const blockRequest = BlockTxsRequest.fromTxsSourceAndMissingTxs(this.blockTxsSource, txs);
|
|
@@ -333,8 +350,9 @@ export class BatchTxRequester {
|
|
|
333
350
|
return { blockRequest, txs };
|
|
334
351
|
};
|
|
335
352
|
|
|
336
|
-
const workers = Array.from(
|
|
337
|
-
|
|
353
|
+
const workers = Array.from(
|
|
354
|
+
{ length: Math.min(this.smartParallelWorkerCount, this.peers.getAllPeers().size) },
|
|
355
|
+
(_, index) => this.smartWorkerLoop(nextPeer, makeRequest, index + 1),
|
|
338
356
|
);
|
|
339
357
|
|
|
340
358
|
await Promise.allSettled(workers);
|
|
@@ -369,18 +387,26 @@ export class BatchTxRequester {
|
|
|
369
387
|
if (weRanOutOfPeersToQuery) {
|
|
370
388
|
this.logger.debug(`Worker loop smart: No more peers to query`);
|
|
371
389
|
|
|
372
|
-
// If
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
// If there are no more dumb peers to query then none of our peers can become smart,
|
|
391
|
+
// thus we can simply exit this worker
|
|
392
|
+
const noMoreDumbPeersToQuery = this.peers.getDumbPeersToQuery().length === 0;
|
|
393
|
+
if (noMoreDumbPeersToQuery) {
|
|
394
|
+
// These might be either smart peers that will get unblocked after _some time_
|
|
395
|
+
const nextSmartPeerDelay = this.peers.getNextSmartPeerAvailabilityDelayMs();
|
|
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;
|
|
378
404
|
}
|
|
379
405
|
|
|
406
|
+
// Otherwise there are still some dumb peers that could become smart.
|
|
380
407
|
// We end up here when all known smart peers became temporarily unavailable via combination of
|
|
381
408
|
// (bad, in-flight, or rate-limited) or in some weird scenario all current smart peers turn bad which is permanent
|
|
382
|
-
// but
|
|
383
|
-
// or new peer can join as dumb and be promoted later
|
|
409
|
+
// but dumb peers still exist that could become smart.
|
|
384
410
|
//
|
|
385
411
|
// When a dumb peer responds with valid txIndices, it gets
|
|
386
412
|
// promoted to smart and releases the semaphore, waking this worker.
|
|
@@ -573,7 +599,9 @@ export class BatchTxRequester {
|
|
|
573
599
|
this.markTxsPeerHas(peerId, response);
|
|
574
600
|
|
|
575
601
|
// Unblock smart workers
|
|
576
|
-
this.
|
|
602
|
+
if (this.peers.getSmartPeersToQuery().length <= this.smartParallelWorkerCount) {
|
|
603
|
+
this.smartRequesterSemaphore.release();
|
|
604
|
+
}
|
|
577
605
|
}
|
|
578
606
|
|
|
579
607
|
private isBlockResponseValid(response: BlockTxsResponse): boolean {
|
|
@@ -2,22 +2,18 @@ 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';
|
|
6
5
|
|
|
7
|
-
import type { ConnectionSampler } from '../connection-sampler/connection_sampler.js';
|
|
8
6
|
import { DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD } from './config.js';
|
|
9
7
|
import type { IPeerPenalizer } from './interface.js';
|
|
10
8
|
|
|
11
9
|
export const RATE_LIMIT_EXCEEDED_PEER_CACHE_TTL = 1000; // 1s
|
|
12
10
|
|
|
13
11
|
export interface IPeerCollection {
|
|
12
|
+
getAllPeers(): Set<string>;
|
|
13
|
+
getSmartPeers(): Set<string>;
|
|
14
14
|
markPeerSmart(peerId: PeerId): void;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
nextSmartPeerToQuery(): PeerId | undefined;
|
|
18
|
-
/** Sample next peer in round-robin fashion. No dumb peers if returns undefined */
|
|
19
|
-
nextDumbPeerToQuery(): PeerId | undefined;
|
|
20
|
-
|
|
15
|
+
getSmartPeersToQuery(): Array<string>;
|
|
16
|
+
getDumbPeersToQuery(): Array<string>;
|
|
21
17
|
thereAreSomeDumbRatelimitExceededPeers(): boolean;
|
|
22
18
|
penalisePeer(peerId: PeerId, severity: PeerErrorSeverity): void;
|
|
23
19
|
unMarkPeerAsBad(peerId: PeerId): void;
|
|
@@ -32,6 +28,8 @@ export interface IPeerCollection {
|
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
export class PeerCollection implements IPeerCollection {
|
|
31
|
+
private readonly peers;
|
|
32
|
+
|
|
35
33
|
private readonly smartPeers = new Set<string>();
|
|
36
34
|
private readonly inFlightPeers = new Set<string>();
|
|
37
35
|
private readonly rateLimitExceededPeers = new Map<string, number>();
|
|
@@ -39,60 +37,46 @@ export class PeerCollection implements IPeerCollection {
|
|
|
39
37
|
private readonly badPeers = new Set<string>();
|
|
40
38
|
|
|
41
39
|
constructor(
|
|
42
|
-
|
|
40
|
+
initialPeers: PeerId[],
|
|
43
41
|
private readonly pinnedPeerId: PeerId | undefined,
|
|
44
42
|
private readonly dateProvider: DateProvider,
|
|
45
43
|
private readonly badPeerThreshold: number = DEFAULT_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD,
|
|
46
44
|
private readonly peerPenalizer?: IPeerPenalizer,
|
|
47
45
|
) {
|
|
48
|
-
|
|
46
|
+
this.peers = new Set(initialPeers.map(peer => peer.toString()));
|
|
47
|
+
|
|
48
|
+
// Pinned peer is treaded 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);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
public
|
|
57
|
-
this.
|
|
58
|
-
}
|
|
59
|
-
|
|
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);
|
|
57
|
+
public getAllPeers(): Set<string> {
|
|
58
|
+
return this.peers;
|
|
77
59
|
}
|
|
78
60
|
|
|
79
|
-
public
|
|
80
|
-
return
|
|
61
|
+
public getSmartPeers(): Set<string> {
|
|
62
|
+
return this.smartPeers;
|
|
81
63
|
}
|
|
82
64
|
|
|
83
|
-
public
|
|
84
|
-
|
|
65
|
+
public markPeerSmart(peerId: PeerId): void {
|
|
66
|
+
this.smartPeers.add(peerId.toString());
|
|
85
67
|
}
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
return
|
|
69
|
+
public getSmartPeersToQuery(): Array<string> {
|
|
70
|
+
return Array.from(
|
|
89
71
|
this.smartPeers.difference(this.getBadPeers().union(this.inFlightPeers).union(this.getRateLimitExceededPeers())),
|
|
90
72
|
);
|
|
91
73
|
}
|
|
92
74
|
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
this.
|
|
75
|
+
public getDumbPeersToQuery(): Array<string> {
|
|
76
|
+
return Array.from(
|
|
77
|
+
this.peers.difference(
|
|
78
|
+
this.smartPeers.union(this.getBadPeers()).union(this.inFlightPeers).union(this.getRateLimitExceededPeers()),
|
|
79
|
+
),
|
|
96
80
|
);
|
|
97
81
|
}
|
|
98
82
|
|
|
@@ -218,27 +202,4 @@ export class PeerCollection implements IPeerCollection {
|
|
|
218
202
|
|
|
219
203
|
return minExpiry! - now;
|
|
220
204
|
}
|
|
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
|
-
}
|
|
244
205
|
}
|
|
@@ -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,
|
|
@@ -4,7 +4,6 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
|
4
4
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
5
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { P2PClientType } from '@aztec/stdlib/p2p';
|
|
8
7
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
9
8
|
|
|
10
9
|
import type { GossipsubEvents, GossipsubMessage } from '@chainsafe/libp2p-gossipsub';
|
|
@@ -42,11 +41,10 @@ type GossipSubService = PubSubLibp2p['services']['pubsub'];
|
|
|
42
41
|
* Given a mock gossip sub network, returns a factory function that creates an instance LibP2PService connected to it.
|
|
43
42
|
* Designed to be used in tests in P2PClientDeps.p2pServiceFactory.
|
|
44
43
|
*/
|
|
45
|
-
export function getMockPubSubP2PServiceFactory
|
|
44
|
+
export function getMockPubSubP2PServiceFactory(
|
|
46
45
|
network: MockGossipSubNetwork,
|
|
47
|
-
): (...args: Parameters<(typeof LibP2PService
|
|
46
|
+
): (...args: Parameters<(typeof LibP2PService)['new']>) => Promise<LibP2PService> {
|
|
48
47
|
return (
|
|
49
|
-
clientType: P2PClientType,
|
|
50
48
|
config: P2PConfig,
|
|
51
49
|
peerId: PeerId,
|
|
52
50
|
deps: {
|
|
@@ -66,8 +64,7 @@ export function getMockPubSubP2PServiceFactory<T extends P2PClientType>(
|
|
|
66
64
|
const peerManager = new DummyPeerManager(peerId, network);
|
|
67
65
|
const reqresp: ReqRespInterface = new MockReqResp(peerId, network);
|
|
68
66
|
const peerDiscoveryService = new DummyPeerDiscoveryService();
|
|
69
|
-
const service = new LibP2PService
|
|
70
|
-
clientType as T,
|
|
67
|
+
const service = new LibP2PService(
|
|
71
68
|
config,
|
|
72
69
|
libp2p,
|
|
73
70
|
peerDiscoveryService,
|
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
IVCProofVerificationResult,
|
|
13
13
|
WorldStateSynchronizer,
|
|
14
14
|
} from '@aztec/stdlib/interfaces/server';
|
|
15
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
16
15
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
17
16
|
import { compressComponentVersions } from '@aztec/stdlib/versioning';
|
|
18
17
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -107,8 +106,7 @@ export async function createLibp2pNode(
|
|
|
107
106
|
*
|
|
108
107
|
*
|
|
109
108
|
*/
|
|
110
|
-
export async function createTestLibP2PService
|
|
111
|
-
clientType: T,
|
|
109
|
+
export async function createTestLibP2PService(
|
|
112
110
|
boostrapAddrs: string[] = [],
|
|
113
111
|
archiver: L2BlockSource & ContractDataSource,
|
|
114
112
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
@@ -159,8 +157,7 @@ export async function createTestLibP2PService<T extends P2PClientType>(
|
|
|
159
157
|
p2pNode.services.pubsub.score.params.appSpecificScore = (peerId: string) =>
|
|
160
158
|
peerManager.shouldDisableP2PGossip(peerId) ? -Infinity : peerManager.getPeerScore(peerId);
|
|
161
159
|
|
|
162
|
-
return new LibP2PService
|
|
163
|
-
clientType,
|
|
160
|
+
return new LibP2PService(
|
|
164
161
|
config,
|
|
165
162
|
p2pNode as PubSubLibp2p,
|
|
166
163
|
discoveryService,
|
|
@@ -19,7 +19,7 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
|
19
19
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
20
20
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
21
21
|
import type { ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
22
|
-
import { type BlockProposal,
|
|
22
|
+
import { type BlockProposal, P2PMessage } from '@aztec/stdlib/p2p';
|
|
23
23
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
24
24
|
import { makeAztecAddress, makeBlockHeader, makeBlockProposal, mockTx } from '@aztec/stdlib/testing';
|
|
25
25
|
import { Tx, TxHash, type TxValidationResult } from '@aztec/stdlib/tx';
|
|
@@ -86,12 +86,11 @@ export interface BenchReadyMessage {
|
|
|
86
86
|
}
|
|
87
87
|
const txCache = new Map<number, Tx[]>();
|
|
88
88
|
|
|
89
|
-
class TestLibP2PService
|
|
89
|
+
class TestLibP2PService extends LibP2PService {
|
|
90
90
|
private disableTxValidation: boolean;
|
|
91
91
|
private gossipMessageCount = 0;
|
|
92
92
|
|
|
93
93
|
constructor(
|
|
94
|
-
clientType: T,
|
|
95
94
|
config: P2PConfig,
|
|
96
95
|
node: PubSubLibp2p,
|
|
97
96
|
peerDiscoveryService: PeerDiscoveryService,
|
|
@@ -107,7 +106,6 @@ class TestLibP2PService<T extends P2PClientType = P2PClientType.Full> extends Li
|
|
|
107
106
|
disableTxValidation = true,
|
|
108
107
|
) {
|
|
109
108
|
super(
|
|
110
|
-
clientType,
|
|
111
109
|
config,
|
|
112
110
|
node,
|
|
113
111
|
peerDiscoveryService,
|
|
@@ -342,6 +340,7 @@ process.on('message', async msg => {
|
|
|
342
340
|
const config: P2PConfig = {
|
|
343
341
|
...rawConfig,
|
|
344
342
|
peerIdPrivateKey: rawConfig.peerIdPrivateKey ? new SecretValue(rawConfig.peerIdPrivateKey) : undefined,
|
|
343
|
+
priceBumpPercentage: 10n,
|
|
345
344
|
} as P2PConfig;
|
|
346
345
|
|
|
347
346
|
workerConfig = config;
|
|
@@ -365,7 +364,6 @@ process.on('message', async msg => {
|
|
|
365
364
|
};
|
|
366
365
|
|
|
367
366
|
const client = await createP2PClient(
|
|
368
|
-
P2PClientType.Full,
|
|
369
367
|
config as P2PConfig & DataStoreConfig,
|
|
370
368
|
l2BlockSource,
|
|
371
369
|
proofVerifier as ClientProtocolCircuitVerifier,
|
|
@@ -378,7 +376,6 @@ process.on('message', async msg => {
|
|
|
378
376
|
);
|
|
379
377
|
|
|
380
378
|
const testService = new TestLibP2PService(
|
|
381
|
-
P2PClientType.Full,
|
|
382
379
|
config,
|
|
383
380
|
(client as any).p2pService.node,
|
|
384
381
|
(client as any).p2pService.peerDiscoveryService,
|
|
@@ -81,13 +81,15 @@ class WorkerClientManager {
|
|
|
81
81
|
* Note: We send the raw peerIdPrivateKey string instead of SecretValue
|
|
82
82
|
* because SecretValue.toJSON() returns '[Redacted]', losing the value.
|
|
83
83
|
* The worker must re-wrap it in SecretValue.
|
|
84
|
+
* We also omit priceBumpPercentage since it's a bigint and can't be
|
|
85
|
+
* serialized over IPC (which uses JSON under the hood).
|
|
84
86
|
*/
|
|
85
87
|
private createClientConfig(
|
|
86
88
|
clientIndex: number,
|
|
87
89
|
port: number,
|
|
88
90
|
otherNodes: string[],
|
|
89
|
-
): Omit<P2PConfig, 'peerIdPrivateKey'> & { peerIdPrivateKey: string } & Partial<ChainConfig> {
|
|
90
|
-
|
|
91
|
+
): Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & { peerIdPrivateKey: string } & Partial<ChainConfig> {
|
|
92
|
+
const { priceBumpPercentage: _, ...config } = {
|
|
91
93
|
...getP2PDefaultConfig(),
|
|
92
94
|
p2pEnabled: true,
|
|
93
95
|
peerIdPrivateKey: this.peerIdPrivateKeys[clientIndex],
|
|
@@ -96,7 +98,10 @@ class WorkerClientManager {
|
|
|
96
98
|
p2pPort: port,
|
|
97
99
|
bootstrapNodes: [...otherNodes],
|
|
98
100
|
...this.p2pConfig,
|
|
99
|
-
}
|
|
101
|
+
};
|
|
102
|
+
return config as Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & {
|
|
103
|
+
peerIdPrivateKey: string;
|
|
104
|
+
} & Partial<ChainConfig>;
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
/**
|
|
@@ -104,7 +109,9 @@ class WorkerClientManager {
|
|
|
104
109
|
* Config uses raw string for peerIdPrivateKey (not SecretValue) for IPC serialization.
|
|
105
110
|
*/
|
|
106
111
|
private spawnWorkerProcess(
|
|
107
|
-
config: Omit<P2PConfig, 'peerIdPrivateKey'> & {
|
|
112
|
+
config: Omit<P2PConfig, 'peerIdPrivateKey' | 'priceBumpPercentage'> & {
|
|
113
|
+
peerIdPrivateKey: string;
|
|
114
|
+
} & Partial<ChainConfig>,
|
|
108
115
|
clientIndex: number,
|
|
109
116
|
): [ChildProcess, Promise<void>] {
|
|
110
117
|
const useCompiled = existsSync(workerJsPath);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { EpochCacheInterface } from '@aztec/epoch-cache';
|
|
2
|
-
import type { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { type BlockProposal, type CheckpointProposal, type ValidationResult } from '@aztec/stdlib/p2p';
|
|
5
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
-
import type { MockProxy } from 'jest-mock-extended';
|
|
7
|
-
export interface ProposalValidatorTestParams<TProposal extends BlockProposal | CheckpointProposal> {
|
|
8
|
-
validatorFactory: (epochCache: EpochCacheInterface, opts: {
|
|
9
|
-
txsPermitted: boolean;
|
|
10
|
-
}) => {
|
|
11
|
-
validate: (proposal: TProposal) => Promise<ValidationResult>;
|
|
12
|
-
};
|
|
13
|
-
makeProposal: (options?: any) => Promise<TProposal>;
|
|
14
|
-
makeHeader: (epochNumber: number | bigint, slotNumber: number | bigint, blockNumber: number | bigint) => any;
|
|
15
|
-
getSigner: () => Secp256k1Signer;
|
|
16
|
-
getAddress: (signer?: Secp256k1Signer) => EthAddress;
|
|
17
|
-
getSlot: (slot: number | bigint) => any;
|
|
18
|
-
getTxHashes: (n: number) => TxHash[];
|
|
19
|
-
getTxs: () => any[];
|
|
20
|
-
epochCacheMock: () => MockProxy<EpochCacheInterface>;
|
|
21
|
-
}
|
|
22
|
-
export declare function sharedProposalValidatorTests<TProposal extends BlockProposal | CheckpointProposal>(params: ProposalValidatorTestParams<TProposal>): void;
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfdmFsaWRhdG9yX3Rlc3Rfc3VpdGUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tc2dfdmFsaWRhdG9ycy9wcm9wb3NhbF92YWxpZGF0b3IvcHJvcG9zYWxfdmFsaWRhdG9yX3Rlc3Rfc3VpdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUM5RCxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUNoRSxPQUFPLEVBQ0wsS0FBSyxhQUFhLEVBQ2xCLEtBQUssa0JBQWtCLEVBRXZCLEtBQUssZ0JBQWdCLEVBQ3RCLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFL0MsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFcEQsTUFBTSxXQUFXLDJCQUEyQixDQUFDLFNBQVMsU0FBUyxhQUFhLEdBQUcsa0JBQWtCO0lBQy9GLGdCQUFnQixFQUFFLENBQ2hCLFVBQVUsRUFBRSxtQkFBbUIsRUFDL0IsSUFBSSxFQUFFO1FBQUUsWUFBWSxFQUFFLE9BQU8sQ0FBQTtLQUFFLEtBQzVCO1FBQUUsUUFBUSxFQUFFLENBQUMsUUFBUSxFQUFFLFNBQVMsS0FBSyxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FBQTtLQUFFLENBQUM7SUFDdEUsWUFBWSxFQUFFLENBQUMsT0FBTyxDQUFDLEVBQUUsR0FBRyxLQUFLLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUNwRCxVQUFVLEVBQUUsQ0FBQyxXQUFXLEVBQUUsTUFBTSxHQUFHLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxHQUFHLE1BQU0sRUFBRSxXQUFXLEVBQUUsTUFBTSxHQUFHLE1BQU0sS0FBSyxHQUFHLENBQUM7SUFDN0csU0FBUyxFQUFFLE1BQU0sZUFBZSxDQUFDO0lBQ2pDLFVBQVUsRUFBRSxDQUFDLE1BQU0sQ0FBQyxFQUFFLGVBQWUsS0FBSyxVQUFVLENBQUM7SUFDckQsT0FBTyxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sR0FBRyxNQUFNLEtBQUssR0FBRyxDQUFDO0lBQ3hDLFdBQVcsRUFBRSxDQUFDLENBQUMsRUFBRSxNQUFNLEtBQUssTUFBTSxFQUFFLENBQUM7SUFDckMsTUFBTSxFQUFFLE1BQU0sR0FBRyxFQUFFLENBQUM7SUFDcEIsY0FBYyxFQUFFLE1BQU0sU0FBUyxDQUFDLG1CQUFtQixDQUFDLENBQUM7Q0FDdEQ7QUFFRCx3QkFBZ0IsNEJBQTRCLENBQUMsU0FBUyxTQUFTLGFBQWEsR0FBRyxrQkFBa0IsRUFDL0YsTUFBTSxFQUFFLDJCQUEyQixDQUFDLFNBQVMsQ0FBQyxRQXdNL0MifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proposal_validator_test_suite.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/proposal_validator/proposal_validator_test_suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,2BAA2B,CAAC,SAAS,SAAS,aAAa,GAAG,kBAAkB;IAC/F,gBAAgB,EAAE,CAChB,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,KAC5B;QAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAA;KAAE,CAAC;IACtE,YAAY,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IACpD,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,KAAK,GAAG,CAAC;IAC7G,SAAS,EAAE,MAAM,eAAe,CAAC;IACjC,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,UAAU,CAAC;IACrD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,GAAG,CAAC;IACxC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACrC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,SAAS,CAAC,mBAAmB,CAAC,CAAC;CACtD;AAED,wBAAgB,4BAA4B,CAAC,SAAS,SAAS,aAAa,GAAG,kBAAkB,EAC/F,MAAM,EAAE,2BAA2B,CAAC,SAAS,CAAC,QAwM/C"}
|