@aztec/p2p 0.87.5 → 0.87.7

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.
Files changed (80) hide show
  1. package/dest/client/interface.d.ts +8 -4
  2. package/dest/client/interface.d.ts.map +1 -1
  3. package/dest/client/p2p_client.d.ts +4 -3
  4. package/dest/client/p2p_client.d.ts.map +1 -1
  5. package/dest/client/p2p_client.js +17 -10
  6. package/dest/config.d.ts +10 -0
  7. package/dest/config.d.ts.map +1 -1
  8. package/dest/config.js +12 -2
  9. package/dest/index.d.ts +1 -0
  10. package/dest/index.d.ts.map +1 -1
  11. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +5 -6
  12. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  13. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +37 -12
  14. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -2
  15. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  16. package/dest/mem_pools/tx_pool/memory_tx_pool.js +1 -3
  17. package/dest/mem_pools/tx_pool/tx_pool.d.ts +6 -1
  18. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  19. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts +10 -0
  20. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.d.ts.map +1 -0
  21. package/dest/msg_validators/msg_seen_validator/msg_seen_validator.js +36 -0
  22. package/dest/services/dummy_service.d.ts +1 -1
  23. package/dest/services/dummy_service.d.ts.map +1 -1
  24. package/dest/services/dummy_service.js +1 -1
  25. package/dest/services/index.d.ts +1 -0
  26. package/dest/services/index.d.ts.map +1 -1
  27. package/dest/services/index.js +1 -0
  28. package/dest/services/libp2p/instrumentation.d.ts +11 -0
  29. package/dest/services/libp2p/instrumentation.d.ts.map +1 -0
  30. package/dest/services/libp2p/instrumentation.js +29 -0
  31. package/dest/services/libp2p/libp2p_service.d.ts +8 -5
  32. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  33. package/dest/services/libp2p/libp2p_service.js +59 -12
  34. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts +1 -1
  35. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  36. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.js +7 -3
  37. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -1
  38. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  39. package/dest/services/reqresp/connection-sampler/connection_sampler.js +8 -3
  40. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  41. package/dest/services/reqresp/protocols/goodbye.js +3 -1
  42. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts +4 -2
  43. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  44. package/dest/services/reqresp/rate-limiter/rate_limiter.js +10 -2
  45. package/dest/services/reqresp/rate-limiter/rate_limits.js +1 -1
  46. package/dest/services/reqresp/reqresp.d.ts +3 -3
  47. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  48. package/dest/services/reqresp/reqresp.js +39 -13
  49. package/dest/services/service.d.ts +3 -2
  50. package/dest/services/service.d.ts.map +1 -1
  51. package/dest/services/tx_collector.d.ts +14 -0
  52. package/dest/services/tx_collector.d.ts.map +1 -0
  53. package/dest/services/tx_collector.js +76 -0
  54. package/dest/test-helpers/reqresp-nodes.d.ts +3 -3
  55. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  56. package/dest/test-helpers/reqresp-nodes.js +4 -4
  57. package/dest/testbench/p2p_client_testbench_worker.js +1 -1
  58. package/package.json +12 -12
  59. package/src/client/interface.ts +8 -4
  60. package/src/client/p2p_client.ts +22 -10
  61. package/src/config.ts +22 -1
  62. package/src/index.ts +2 -0
  63. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +45 -18
  64. package/src/mem_pools/tx_pool/memory_tx_pool.ts +2 -4
  65. package/src/mem_pools/tx_pool/tx_pool.ts +7 -1
  66. package/src/msg_validators/msg_seen_validator/msg_seen_validator.ts +36 -0
  67. package/src/services/dummy_service.ts +3 -1
  68. package/src/services/index.ts +1 -0
  69. package/src/services/libp2p/instrumentation.ts +39 -0
  70. package/src/services/libp2p/libp2p_service.ts +79 -11
  71. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +4 -2
  72. package/src/services/reqresp/connection-sampler/connection_sampler.ts +8 -3
  73. package/src/services/reqresp/protocols/goodbye.ts +3 -1
  74. package/src/services/reqresp/rate-limiter/rate_limiter.ts +9 -3
  75. package/src/services/reqresp/rate-limiter/rate_limits.ts +1 -1
  76. package/src/services/reqresp/reqresp.ts +44 -16
  77. package/src/services/service.ts +4 -1
  78. package/src/services/tx_collector.ts +103 -0
  79. package/src/test-helpers/reqresp-nodes.ts +13 -8
  80. package/src/testbench/p2p_client_testbench_worker.ts +1 -1
@@ -0,0 +1,11 @@
1
+ import type { Timer } from '@aztec/foundation/timer';
2
+ import type { TopicType } from '@aztec/stdlib/p2p';
3
+ import { type TelemetryClient } from '@aztec/telemetry-client';
4
+ export declare class P2PInstrumentation {
5
+ private messageValidationDuration;
6
+ private messagePrevalidationCount;
7
+ constructor(client: TelemetryClient, name: string);
8
+ recordMessageValidation(topicName: TopicType, timerOrMs: Timer | number): void;
9
+ incMessagePrevalidationStatus(passed: boolean, topicName: TopicType | undefined): void;
10
+ }
11
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,yBAAyB,CAAgB;gBAErC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM;IAe1C,uBAAuB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM;IAKvE,6BAA6B,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS;CAGvF"}
@@ -0,0 +1,29 @@
1
+ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
2
+ export class P2PInstrumentation {
3
+ messageValidationDuration;
4
+ messagePrevalidationCount;
5
+ constructor(client, name){
6
+ const meter = client.getMeter(name);
7
+ this.messageValidationDuration = meter.createHistogram(Metrics.P2P_GOSSIP_MESSAGE_VALIDATION_DURATION, {
8
+ unit: 'ms',
9
+ description: 'How long validating a gossiped message takes',
10
+ valueType: ValueType.INT
11
+ });
12
+ this.messagePrevalidationCount = meter.createUpDownCounter(Metrics.P2P_GOSSIP_MESSAGE_PREVALIDATION_COUNT, {
13
+ description: 'How many message pass/fail prevalidation',
14
+ valueType: ValueType.INT
15
+ });
16
+ }
17
+ recordMessageValidation(topicName, timerOrMs) {
18
+ const ms = typeof timerOrMs === 'number' ? timerOrMs : timerOrMs.ms();
19
+ this.messageValidationDuration.record(Math.ceil(ms), {
20
+ [Attributes.TOPIC_NAME]: topicName
21
+ });
22
+ }
23
+ incMessagePrevalidationStatus(passed, topicName) {
24
+ this.messagePrevalidationCount.add(1, {
25
+ [Attributes.TOPIC_NAME]: topicName,
26
+ [Attributes.OK]: passed
27
+ });
28
+ }
29
+ }
@@ -3,7 +3,7 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
3
  import type { L2BlockSource } from '@aztec/stdlib/block';
4
4
  import type { ContractDataSource } from '@aztec/stdlib/contract';
5
5
  import type { ClientProtocolCircuitVerifier, PeerInfo, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
6
- import { BlockAttestation, BlockProposal, type Gossipable, P2PClientType } from '@aztec/stdlib/p2p';
6
+ import { BlockAttestation, BlockProposal, type Gossipable, P2PClientType, TopicType } from '@aztec/stdlib/p2p';
7
7
  import { Tx } from '@aztec/stdlib/tx';
8
8
  import { type TelemetryClient, WithTracer } from '@aztec/telemetry-client';
9
9
  import type { ENR } from '@chainsafe/enr';
@@ -14,7 +14,7 @@ import type { MemPools } from '../../mem_pools/interface.js';
14
14
  import { type PubSubLibp2p } from '../../util.js';
15
15
  import { ReqRespSubProtocol, type SubProtocolMap } from '../reqresp/interface.js';
16
16
  import { ReqResp } from '../reqresp/reqresp.js';
17
- import type { P2PService, PeerDiscoveryService } from '../service.js';
17
+ import type { P2PBlockReceivedCallback, P2PService, PeerDiscoveryService } from '../service.js';
18
18
  /**
19
19
  * Lib P2P implementation of the P2PService interface.
20
20
  */
@@ -31,6 +31,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
31
31
  private jobQueue;
32
32
  private peerManager;
33
33
  private discoveryRunningPromise?;
34
+ private msgIdSeenValidators;
34
35
  private attestationValidator;
35
36
  private blockProposalValidator;
36
37
  private protocolVersion;
@@ -45,6 +46,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
45
46
  */
46
47
  private blockReceivedCallback;
47
48
  private gossipSubEventHandler;
49
+ private instrumentation;
48
50
  constructor(clientType: T, config: P2PConfig, node: PubSubLibp2p, peerDiscoveryService: PeerDiscoveryService, mempools: MemPools<T>, archiver: L2BlockSource & ContractDataSource, epochCache: EpochCacheInterface, proofVerifier: ClientProtocolCircuitVerifier, worldStateSynchronizer: WorldStateSynchronizer, telemetry: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
49
51
  /**
50
52
  * Creates an instance of the LibP2P service.
@@ -82,13 +84,13 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
82
84
  * @param requests - The requests to send to the peers
83
85
  * @returns The responses to the requests
84
86
  */
85
- sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(protocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[]): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
87
+ sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(protocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], pinnedPeerId: PeerId | undefined): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
86
88
  /**
87
89
  * Get the ENR of the node
88
90
  * @returns The ENR of the node
89
91
  */
90
92
  getEnr(): ENR | undefined;
91
- registerBlockReceivedCallback(callback: (block: BlockProposal) => Promise<BlockAttestation | undefined>): void;
93
+ registerBlockReceivedCallback(callback: P2PBlockReceivedCallback): void;
92
94
  /**
93
95
  * Subscribes to a topic.
94
96
  * @param topic - The topic to subscribe to.
@@ -101,6 +103,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
101
103
  * @returns The number of recipients the data was sent to.
102
104
  */
103
105
  private publishToTopic;
106
+ protected preValidateReceivedMessage(msg: Message, msgId: string, source: PeerId): boolean;
104
107
  /**
105
108
  * Handles a new gossip message that was received by the client.
106
109
  * @param topic - The message's topic.
@@ -110,7 +113,7 @@ export declare class LibP2PService<T extends P2PClientType = P2PClientType.Full>
110
113
  protected validateReceivedMessage<T>(validationFunc: () => Promise<{
111
114
  result: boolean;
112
115
  obj: T;
113
- }>, msgId: string, source: PeerId): Promise<{
116
+ }>, msgId: string, source: PeerId, topicType: TopicType): Promise<{
114
117
  result: boolean;
115
118
  obj: T | undefined;
116
119
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"libp2p_service.d.ts","sourceRoot":"","sources":["../../../src/services/libp2p/libp2p_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KA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AAS,GACnB,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;cAqBnC,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAiBnF;;;;;OAKG;YACW,0BAA0B;YAgC1B,oBAAoB;YA8BpB,yBAAyB;IAsCvC;;;OAGG;YAOW,oBAAoB;IAIlC;;;OAGG;IACU,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,CAAC;IAYvD;;;;;;;;;;;;;OAaG;YAIW,mBAAmB;YAuBnB,oBAAoB;YAwBpB,UAAU;IAWX,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB/C;;;;;;;;OAQG;YACW,uBAAuB;IAiBrC;;;;;OAKG;YACW,cAAc;IA4B5B;;;;;;;;;;OAUG;YACW,wBAAwB;IAuBtC;;;;;OAKG;IAOU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjG;;;;;OAKG;IAIU,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAWnF,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAI7B,WAAW;YAcX,UAAU;CAYzB"}
@@ -7,6 +7,7 @@ function _ts_decorate(decorators, target, key, desc) {
7
7
  import { createLibp2pComponentLogger, createLogger } from '@aztec/foundation/log';
8
8
  import { SerialQueue } from '@aztec/foundation/queue';
9
9
  import { RunningPromise } from '@aztec/foundation/running-promise';
10
+ import { Timer } from '@aztec/foundation/timer';
10
11
  import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
11
12
  import { GasFees } from '@aztec/stdlib/gas';
12
13
  import { BlockAttestation, BlockProposal, P2PClientType, P2PMessage, PeerErrorSeverity, TopicType, createTopicString, getTopicTypeForClientType, metricsTopicStrToLabels } from '@aztec/stdlib/p2p';
@@ -27,6 +28,7 @@ import { mplex } from '@libp2p/mplex';
27
28
  import { tcp } from '@libp2p/tcp';
28
29
  import { createLibp2p } from 'libp2p';
29
30
  import { AttestationValidator, BlockProposalValidator } from '../../msg_validators/index.js';
31
+ import { MessageSeenValidator } from '../../msg_validators/msg_seen_validator/msg_seen_validator.js';
30
32
  import { getDefaultAllowedSetupFunctions } from '../../msg_validators/tx_validator/allowed_public_setup.js';
31
33
  import { createTxMessageValidators } from '../../msg_validators/tx_validator/factory.js';
32
34
  import { DoubleSpendTxValidator, TxProofValidator } from '../../msg_validators/tx_validator/index.js';
@@ -42,6 +44,7 @@ import { DEFAULT_SUB_PROTOCOL_VALIDATORS, ReqRespSubProtocol } from '../reqresp/
42
44
  import { reqGoodbyeHandler } from '../reqresp/protocols/goodbye.js';
43
45
  import { pingHandler, reqRespBlockHandler, reqRespTxHandler, statusHandler } from '../reqresp/protocols/index.js';
44
46
  import { ReqResp } from '../reqresp/reqresp.js';
47
+ import { P2PInstrumentation } from './instrumentation.js';
45
48
  /**
46
49
  * Lib P2P implementation of the P2PService interface.
47
50
  */ export class LibP2PService extends WithTracer {
@@ -57,6 +60,7 @@ import { ReqResp } from '../reqresp/reqresp.js';
57
60
  jobQueue;
58
61
  peerManager;
59
62
  discoveryRunningPromise;
63
+ msgIdSeenValidators;
60
64
  // Message validators
61
65
  attestationValidator;
62
66
  blockProposalValidator;
@@ -73,8 +77,13 @@ import { ReqResp } from '../reqresp/reqresp.js';
73
77
  * @returns The attestation for the block, if any.
74
78
  */ blockReceivedCallback;
75
79
  gossipSubEventHandler;
80
+ instrumentation;
76
81
  constructor(clientType, config, node, peerDiscoveryService, mempools, archiver, epochCache, proofVerifier, worldStateSynchronizer, telemetry, logger = createLogger('p2p:libp2p_service')){
77
- super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.mempools = mempools, this.archiver = archiver, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.logger = logger, this.jobQueue = new SerialQueue(), this.protocolVersion = '', this.topicStrings = {}, this.trustedPeersIds = [];
82
+ super(telemetry, 'LibP2PService'), this.clientType = clientType, this.config = config, this.node = node, this.peerDiscoveryService = peerDiscoveryService, this.mempools = mempools, this.archiver = archiver, this.proofVerifier = proofVerifier, this.worldStateSynchronizer = worldStateSynchronizer, this.logger = logger, this.jobQueue = new SerialQueue(), this.msgIdSeenValidators = {}, this.protocolVersion = '', this.topicStrings = {}, this.trustedPeersIds = [];
83
+ this.instrumentation = new P2PInstrumentation(telemetry, 'LibP2PService');
84
+ this.msgIdSeenValidators[TopicType.tx] = new MessageSeenValidator(config.seenMessageCacheSize);
85
+ this.msgIdSeenValidators[TopicType.block_proposal] = new MessageSeenValidator(config.seenMessageCacheSize);
86
+ this.msgIdSeenValidators[TopicType.block_attestation] = new MessageSeenValidator(config.seenMessageCacheSize);
78
87
  const versions = getVersions(config);
79
88
  this.protocolVersion = compressComponentVersions(versions);
80
89
  logger.info(`Started libp2p service with protocol version ${this.protocolVersion}`);
@@ -322,8 +331,8 @@ import { ReqResp } from '../reqresp/reqresp.js';
322
331
  * @param protocol - The request response protocol to use
323
332
  * @param requests - The requests to send to the peers
324
333
  * @returns The responses to the requests
325
- */ sendBatchRequest(protocol, requests) {
326
- return this.reqresp.sendBatchRequest(protocol, requests);
334
+ */ sendBatchRequest(protocol, requests, pinnedPeerId) {
335
+ return this.reqresp.sendBatchRequest(protocol, requests, pinnedPeerId);
327
336
  }
328
337
  /**
329
338
  * Get the ENR of the node
@@ -333,7 +342,6 @@ import { ReqResp } from '../reqresp/reqresp.js';
333
342
  }
334
343
  registerBlockReceivedCallback(callback) {
335
344
  this.blockReceivedCallback = callback;
336
- this.logger.verbose('Block received callback registered');
337
345
  }
338
346
  /**
339
347
  * Subscribes to a topic.
@@ -361,6 +369,31 @@ import { ReqResp } from '../reqresp/reqresp.js';
361
369
  const result = await this.node.services.pubsub.publish(topic, p2pMessage.toMessageData());
362
370
  return result.recipients.length;
363
371
  }
372
+ preValidateReceivedMessage(msg, msgId, source) {
373
+ let topicType;
374
+ switch(msg.topic){
375
+ case this.topicStrings[TopicType.tx]:
376
+ topicType = TopicType.tx;
377
+ break;
378
+ case this.topicStrings[TopicType.block_attestation]:
379
+ topicType = TopicType.block_attestation;
380
+ break;
381
+ case this.topicStrings[TopicType.block_proposal]:
382
+ topicType = TopicType.block_proposal;
383
+ break;
384
+ default:
385
+ this.logger.error(`Received message on unknown topic: ${msg.topic}`);
386
+ break;
387
+ }
388
+ const validator = topicType ? this.msgIdSeenValidators[topicType] : undefined;
389
+ if (!validator || !validator.addMessage(msgId)) {
390
+ this.instrumentation.incMessagePrevalidationStatus(false, topicType);
391
+ this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), TopicValidatorResult.Ignore);
392
+ return false;
393
+ }
394
+ this.instrumentation.incMessagePrevalidationStatus(true, topicType);
395
+ return true;
396
+ }
364
397
  /**
365
398
  * Handles a new gossip message that was received by the client.
366
399
  * @param topic - The message's topic.
@@ -374,6 +407,9 @@ import { ReqResp } from '../reqresp/reqresp.js';
374
407
  messageId: p2pMessage.id,
375
408
  messageLatency
376
409
  });
410
+ if (!this.preValidateReceivedMessage(msg, msgId, source)) {
411
+ return;
412
+ }
377
413
  if (msg.topic === this.topicStrings[TopicType.tx]) {
378
414
  await this.handleGossipedTx(p2pMessage.payload, msgId, source);
379
415
  }
@@ -385,16 +421,20 @@ import { ReqResp } from '../reqresp/reqresp.js';
385
421
  }
386
422
  return;
387
423
  }
388
- async validateReceivedMessage(validationFunc, msgId, source) {
424
+ async validateReceivedMessage(validationFunc, msgId, source, topicType) {
389
425
  let resultAndObj = {
390
426
  result: false,
391
427
  obj: undefined
392
428
  };
429
+ const timer = new Timer();
393
430
  try {
394
431
  resultAndObj = await validationFunc();
395
432
  } catch (err) {
396
433
  this.logger.error(`Error deserialising and validating message `, err);
397
434
  }
435
+ if (resultAndObj.result) {
436
+ this.instrumentation.recordMessageValidation(topicType, timer);
437
+ }
398
438
  this.node.services.pubsub.reportMessageValidationResult(msgId, source.toString(), resultAndObj.result && resultAndObj.obj ? TopicValidatorResult.Accept : TopicValidatorResult.Reject);
399
439
  return resultAndObj;
400
440
  }
@@ -407,7 +447,7 @@ import { ReqResp } from '../reqresp/reqresp.js';
407
447
  obj: tx
408
448
  };
409
449
  };
410
- const { result, obj: tx } = await this.validateReceivedMessage(validationFunc, msgId, source);
450
+ const { result, obj: tx } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.tx);
411
451
  if (!result || !tx) {
412
452
  return;
413
453
  }
@@ -436,7 +476,7 @@ import { ReqResp } from '../reqresp/reqresp.js';
436
476
  obj: attestation
437
477
  };
438
478
  };
439
- const { result, obj: attestation } = await this.validateReceivedMessage(validationFunc, msgId, source);
479
+ const { result, obj: attestation } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.block_attestation);
440
480
  if (!result || !attestation) {
441
481
  return;
442
482
  }
@@ -463,23 +503,30 @@ import { ReqResp } from '../reqresp/reqresp.js';
463
503
  obj: block
464
504
  };
465
505
  };
466
- const { result, obj: block } = await this.validateReceivedMessage(validationFunc, msgId, source);
506
+ const { result, obj: block } = await this.validateReceivedMessage(validationFunc, msgId, source, TopicType.block_proposal);
467
507
  if (!result || !block) {
468
508
  return;
469
509
  }
470
- await this.processValidBlockProposal(block);
510
+ await this.processValidBlockProposal(block, source);
471
511
  }
472
512
  // REVIEW: callback pattern https://github.com/AztecProtocol/aztec-packages/issues/7963
473
- async processValidBlockProposal(block) {
474
- this.logger.verbose(`Received block ${block.blockNumber.toNumber()} for slot ${block.slotNumber.toNumber()} from external peer.`, {
513
+ async processValidBlockProposal(block, sender) {
514
+ const slot = block.slotNumber.toBigInt();
515
+ const previousSlot = slot - 1n;
516
+ const epoch = slot / 32n;
517
+ this.logger.verbose(`Received block ${block.blockNumber.toNumber()} for slot ${slot}, epoch ${epoch} from external peer.`, {
475
518
  p2pMessageIdentifier: await block.p2pMessageIdentifier(),
476
519
  slot: block.slotNumber.toNumber(),
477
520
  archive: block.archive.toString(),
478
521
  block: block.blockNumber.toNumber()
479
522
  });
523
+ const attestationsForPreviousSlot = await this.mempools.attestationPool?.getAttestationsForSlot(previousSlot);
524
+ if (attestationsForPreviousSlot !== undefined) {
525
+ this.logger.verbose(`Received ${attestationsForPreviousSlot.length} attestations for slot ${previousSlot}`);
526
+ }
480
527
  // Mark the txs in this proposal as non-evictable
481
528
  await this.mempools.txPool.markTxsAsNonEvictable(block.payload.txHashes);
482
- const attestation = await this.blockReceivedCallback(block);
529
+ const attestation = await this.blockReceivedCallback(block, sender);
483
530
  // TODO: fix up this pattern - the abstraction is not nice
484
531
  // The attestation can be undefined if no handler is registered / the validator deems the block invalid
485
532
  if (attestation != undefined) {
@@ -18,7 +18,7 @@ export declare class BatchConnectionSampler {
18
18
  private readonly logger;
19
19
  private readonly batch;
20
20
  private readonly requestsPerPeer;
21
- constructor(connectionSampler: ConnectionSampler, batchSize: number, maxPeers: number);
21
+ constructor(connectionSampler: ConnectionSampler, batchSize: number, maxPeers: number, exclude?: PeerId[]);
22
22
  /**
23
23
  * Gets the peer responsible for handling a specific request index
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"batch_connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/batch_connection_sampler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IAM/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGtB,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM;IAgBlB;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUpD;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAmB1C;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;CACF"}
1
+ {"version":3,"file":"batch_connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/batch_connection_sampler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,qBAAa,sBAAsB;IAM/B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IALpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;gBAGtB,iBAAiB,EAAE,iBAAiB,EACrD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAAE;IAiBpB;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUpD;;;;;OAKG;IACH,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAmB1C;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAI,iBAAiB,IAAI,MAAM,CAE9B;CACF"}
@@ -16,7 +16,7 @@ import { createLogger } from '@aztec/foundation/log';
16
16
  logger;
17
17
  batch;
18
18
  requestsPerPeer;
19
- constructor(connectionSampler, batchSize, maxPeers){
19
+ constructor(connectionSampler, batchSize, maxPeers, exclude){
20
20
  this.connectionSampler = connectionSampler;
21
21
  this.logger = createLogger('p2p:reqresp:batch-connection-sampler');
22
22
  this.batch = [];
@@ -29,7 +29,11 @@ import { createLogger } from '@aztec/foundation/log';
29
29
  // Calculate how many requests each peer should handle, cannot be 0
30
30
  this.requestsPerPeer = Math.max(1, Math.floor(batchSize / maxPeers));
31
31
  // Sample initial peers
32
- this.batch = this.connectionSampler.samplePeersBatch(maxPeers);
32
+ const excluding = exclude && new Map(exclude.map((peerId)=>[
33
+ peerId.toString(),
34
+ true
35
+ ]));
36
+ this.batch = this.connectionSampler.samplePeersBatch(maxPeers, excluding);
33
37
  }
34
38
  /**
35
39
  * Gets the peer responsible for handling a specific request index
@@ -60,7 +64,7 @@ import { createLogger } from '@aztec/foundation/log';
60
64
  true
61
65
  ]
62
66
  ]);
63
- const newPeer = this.connectionSampler.getPeer(excluding);
67
+ const newPeer = this.connectionSampler.getPeer(excluding); // Q: Shouldn't we accumulate all excluded peers? Otherwise the sampler could return us a previously excluded peer?
64
68
  if (newPeer) {
65
69
  this.batch[index] = newPeer;
66
70
  this.logger.trace('Replaced peer', {
@@ -52,9 +52,10 @@ export declare class ConnectionSampler {
52
52
  * Samples a batch of unique peers from the libp2p node, prioritizing peers without active connections
53
53
  *
54
54
  * @param numberToSample - The number of peers to sample
55
+ * @param excluding - The peers to exclude from the sampling
55
56
  * @returns Array of unique sampled peers, prioritizing those without active connections
56
57
  */
57
- samplePeersBatch(numberToSample: number): PeerId[];
58
+ samplePeersBatch(numberToSample: number, excluding?: Map<string, boolean>): PeerId[];
58
59
  /**
59
60
  * Dials a protocol and returns the stream
60
61
  *
@@ -1 +1 @@
1
- {"version":3,"file":"connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/connection_sampler.ts"],"names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QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4B5C;;OAEG;YACW,uBAAuB;CAetC"}
1
+ {"version":3,"file":"connection_sampler.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/connection-sampler/connection_sampler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAShE,qBAAa,aAAa;IACxB,MAAM,CAAC,GAAG,EAAE,MAAM;CAGnB;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAY1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAb1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;IACzE,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,YAAY,CAAyB;IAE7C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAkC;IACzE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAGnE,OAAO,CAAC,SAAS,CAAkC;gBAGhC,MAAM,EAAE,MAAM,EACd,iBAAiB,GAAE,MAAc,EAAE,sBAAsB;IACzD,OAAO,GAAE,aAAmC;IAO/D;;OAEG;IACG,IAAI;IAgBV;;;;;OAKG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAO7D;;;;;;;;;;;OAWG;IACH,eAAe,CACb,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;QACD,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,YAAY,EAAE,MAAM,EAAE,CAAC;KACxB;IAuCD;;;;;;OAMG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE;IAyCpF;;;;;;OAMG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAwCvF;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC5C;;OAEG;YACW,uBAAuB;CAetC"}
@@ -117,8 +117,9 @@ export class RandomSampler {
117
117
  * Samples a batch of unique peers from the libp2p node, prioritizing peers without active connections
118
118
  *
119
119
  * @param numberToSample - The number of peers to sample
120
+ * @param excluding - The peers to exclude from the sampling
120
121
  * @returns Array of unique sampled peers, prioritizing those without active connections
121
- */ samplePeersBatch(numberToSample) {
122
+ */ samplePeersBatch(numberToSample, excluding) {
122
123
  const peers = this.libp2p.getPeers();
123
124
  this.logger.debug('Sampling peers batch', {
124
125
  numberToSample,
@@ -129,7 +130,7 @@ export class RandomSampler {
129
130
  const batch = [];
130
131
  const withActiveConnections = new Set();
131
132
  for(let i = 0; i < numberToSample; i++){
132
- const { peer, sampledPeers } = this.getPeerFromList(peers, undefined);
133
+ const { peer, sampledPeers } = this.getPeerFromList(peers, excluding);
133
134
  if (peer) {
134
135
  batch.push(peer);
135
136
  }
@@ -217,7 +218,11 @@ export class RandomSampler {
217
218
  protocol: stream.protocol,
218
219
  activeConnectionsCount: updatedActiveConnectionsCount
219
220
  });
220
- await stream?.close();
221
+ //NOTE: All other status codes indicate closed stream.
222
+ //Either graceful close (closed/closing) or forced close (aborted/reset)
223
+ if (stream.status === 'open') {
224
+ await stream?.close();
225
+ }
221
226
  } catch (error) {
222
227
  this.logger.error(`Failed to close connection to peer with stream id ${streamId}`, error);
223
228
  } finally{
@@ -1 +1 @@
1
- {"version":3,"file":"goodbye.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/protocols/goodbye.ts"],"names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M,iBAAiB,CAAC;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,oBAAY,aAAa;IACvB,0FAA0F;IAC1F,QAAQ,IAAM;IACd,sIAAsI;IACtI,SAAS,IAAM;IACf,gFAAgF;IAChF,SAAS,IAAM;IACf,2EAA2E;IAC3E,MAAM,IAAM;IACZ,2BAA2B;IAC3B,aAAa,IAAM;IACnB,qBAAqB;IACrB,OAAO,IAAM;CACd;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CASjE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED;;GAEG;AACH,qBAAa,sBAAsB;IAGrB,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,MAAM,CAAwC;gBAElC,OAAO,EAAE,OAAO;IAEvB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,yBAAyB,CAWrF"}
@@ -79,7 +79,9 @@ export function decodeGoodbyeReason(buffer) {
79
79
  return (peerId, _msg)=>{
80
80
  const reason = decodeGoodbyeReason(_msg);
81
81
  peerManager.goodbyeReceived(peerId, reason);
82
- // Return a buffer of length 1 as an acknowledgement: this is allowed to fail
82
+ // NOTE: In the current implementation this won't be sent to peer,
83
+ // as the connection to peer has been already closed by peerManager.goodbyeReceived
84
+ // We have this just to satisfy interface
83
85
  return Promise.resolve(Buffer.from([
84
86
  0x0
85
87
  ]));
@@ -1,6 +1,6 @@
1
1
  import type { PeerId } from '@libp2p/interface';
2
2
  import type { PeerScoring } from '../../peer-manager/peer_scoring.js';
3
- import type { ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
3
+ import type { ProtocolRateLimitQuota, ReqRespSubProtocol, ReqRespSubProtocolRateLimits } from '../interface.js';
4
4
  /**
5
5
  * GCRARateLimiter: A Generic Cell Rate Algorithm (GCRA) based rate limiter.
6
6
  *
@@ -89,8 +89,9 @@ export declare class SubProtocolRateLimiter {
89
89
  export declare class RequestResponseRateLimiter {
90
90
  private peerScoring;
91
91
  private subProtocolRateLimiters;
92
+ private rateLimits;
92
93
  private cleanupInterval;
93
- constructor(peerScoring: PeerScoring, rateLimits?: ReqRespSubProtocolRateLimits);
94
+ constructor(peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>);
94
95
  start(): void;
95
96
  allow(subProtocol: ReqRespSubProtocol, peerId: PeerId): RateLimitStatus;
96
97
  cleanupInactivePeers(): void;
@@ -98,5 +99,6 @@ export declare class RequestResponseRateLimiter {
98
99
  * Make sure to call destroy on each of the sub protocol rate limiters when cleaning up
99
100
  */
100
101
  stop(): void;
102
+ getRateLimits(protocol: ReqRespSubProtocol): ProtocolRateLimitQuota;
101
103
  }
102
104
  //# sourceMappingURL=rate_limiter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rate_limiter.d.ts","sourceRoot":"","sources":["../../../../src/services/reqresp/rate-limiter/rate_limiter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAMxF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAe;IAE1B,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAE1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC;;;OAGG;gBACS,UAA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ateLimitStatus(status) {
148
148
  */ export class RequestResponseRateLimiter {
149
149
  peerScoring;
150
150
  subProtocolRateLimiters;
151
+ rateLimits;
151
152
  cleanupInterval;
152
- constructor(peerScoring, rateLimits = DEFAULT_RATE_LIMITS){
153
+ constructor(peerScoring, rateLimits = {}){
153
154
  this.peerScoring = peerScoring;
154
155
  this.cleanupInterval = undefined;
155
156
  this.subProtocolRateLimiters = new Map();
156
- for (const [subProtocol, protocolLimits] of Object.entries(rateLimits)){
157
+ this.rateLimits = {
158
+ ...DEFAULT_RATE_LIMITS,
159
+ ...rateLimits
160
+ };
161
+ for (const [subProtocol, protocolLimits] of Object.entries(this.rateLimits)){
157
162
  this.subProtocolRateLimiters.set(subProtocol, new SubProtocolRateLimiter(protocolLimits.peerLimit.quotaCount, protocolLimits.peerLimit.quotaTimeMs, protocolLimits.globalLimit.quotaCount, protocolLimits.globalLimit.quotaTimeMs));
158
163
  }
159
164
  }
@@ -181,4 +186,7 @@ export function prettyPrintRateLimitStatus(status) {
181
186
  */ stop() {
182
187
  clearInterval(this.cleanupInterval);
183
188
  }
189
+ getRateLimits(protocol) {
190
+ return this.rateLimits[protocol];
191
+ }
184
192
  }
@@ -28,7 +28,7 @@ export const DEFAULT_RATE_LIMITS = {
28
28
  },
29
29
  globalLimit: {
30
30
  quotaTimeMs: 1000,
31
- quotaCount: 20
31
+ quotaCount: 200
32
32
  }
33
33
  },
34
34
  [ReqRespSubProtocol.BLOCK]: {
@@ -4,7 +4,7 @@ import type { PeerId } from '@libp2p/interface';
4
4
  import type { Libp2p } from 'libp2p';
5
5
  import type { PeerScoring } from '../peer-manager/peer_scoring.js';
6
6
  import type { P2PReqRespConfig } from './config.js';
7
- import { type ReqRespResponse, ReqRespSubProtocol, type ReqRespSubProtocolHandlers, type ReqRespSubProtocolValidators, type SubProtocolMap } from './interface.js';
7
+ import { type ReqRespResponse, ReqRespSubProtocol, type ReqRespSubProtocolHandlers, type ReqRespSubProtocolRateLimits, type ReqRespSubProtocolValidators, type SubProtocolMap } from './interface.js';
8
8
  /**
9
9
  * The Request Response Service
10
10
  *
@@ -31,7 +31,7 @@ export declare class ReqResp {
31
31
  private rateLimiter;
32
32
  private snappyTransform;
33
33
  private metrics;
34
- constructor(config: P2PReqRespConfig, libp2p: Libp2p, peerScoring: PeerScoring, telemetryClient?: TelemetryClient);
34
+ constructor(config: P2PReqRespConfig, libp2p: Libp2p, peerScoring: PeerScoring, rateLimits?: Partial<ReqRespSubProtocolRateLimits>, telemetryClient?: TelemetryClient);
35
35
  get tracer(): import("@aztec/telemetry-client").Tracer;
36
36
  /**
37
37
  * Start the reqresp service
@@ -93,7 +93,7 @@ export declare class ReqResp {
93
93
  *
94
94
  * @throws {CollectiveReqRespTimeoutError} - If the request batch exceeds the specified timeout (`timeoutMs`).
95
95
  */
96
- sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(subProtocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
96
+ sendBatchRequest<SubProtocol extends ReqRespSubProtocol>(subProtocol: SubProtocol, requests: InstanceType<SubProtocolMap[SubProtocol]['request']>[], pinnedPeer: PeerId | undefined, timeoutMs?: number, maxPeers?: number, maxRetryAttempts?: number): Promise<(InstanceType<SubProtocolMap[SubProtocol]['response']> | undefined)[]>;
97
97
  /**
98
98
  * Sends a request to a specific peer
99
99
  *
@@ -1 +1 @@
1
- {"version":3,"file":"reqresp.d.ts","sourceRoot":"","sources":["../../../src/services/reqresp/reqresp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAc,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAE1G,OAAO,KAAK,EAAsB,MAAM,EAAU,MAAM,mBAAmB,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MA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