@aztec/p2p 0.0.1-commit.43c09e3f → 0.0.1-commit.4ad48494d

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 (230) hide show
  1. package/dest/client/factory.d.ts +5 -5
  2. package/dest/client/factory.d.ts.map +1 -1
  3. package/dest/client/factory.js +44 -10
  4. package/dest/client/interface.d.ts +37 -15
  5. package/dest/client/interface.d.ts.map +1 -1
  6. package/dest/client/p2p_client.d.ts +35 -36
  7. package/dest/client/p2p_client.d.ts.map +1 -1
  8. package/dest/client/p2p_client.js +114 -138
  9. package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +1 -1
  10. package/dest/config.d.ts +23 -5
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +16 -1
  13. package/dest/index.d.ts +2 -1
  14. package/dest/index.d.ts.map +1 -1
  15. package/dest/index.js +1 -0
  16. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +104 -88
  17. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  18. package/dest/mem_pools/attestation_pool/attestation_pool.js +441 -3
  19. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +2 -2
  20. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
  21. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +353 -87
  22. package/dest/mem_pools/attestation_pool/index.d.ts +2 -3
  23. package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
  24. package/dest/mem_pools/attestation_pool/index.js +1 -2
  25. package/dest/mem_pools/index.d.ts +3 -2
  26. package/dest/mem_pools/index.d.ts.map +1 -1
  27. package/dest/mem_pools/index.js +1 -1
  28. package/dest/mem_pools/interface.d.ts +5 -5
  29. package/dest/mem_pools/interface.d.ts.map +1 -1
  30. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +102 -0
  31. package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
  32. package/dest/mem_pools/tx_pool_v2/deleted_pool.js +242 -0
  33. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
  34. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
  35. package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -0
  36. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +3 -1
  37. package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +3 -1
  38. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
  39. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
  40. package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +3 -1
  41. package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -1
  42. package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool_v2/index.js +1 -0
  44. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +11 -3
  45. package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
  46. package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
  47. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +27 -3
  48. package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
  49. package/dest/mem_pools/tx_pool_v2/tx_metadata.js +39 -5
  50. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +105 -0
  51. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -0
  52. package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +345 -0
  53. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
  54. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
  55. package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +12 -2
  56. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +4 -2
  57. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
  58. package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +259 -520
  59. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts +3 -3
  60. package/dest/msg_validators/attestation_validator/fisherman_attestation_validator.d.ts.map +1 -1
  61. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
  62. package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
  63. package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
  64. package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
  65. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  66. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
  67. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  68. package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
  69. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
  70. package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
  71. package/dest/msg_validators/tx_validator/timestamp_validator.js +2 -2
  72. package/dest/services/dummy_service.d.ts +10 -2
  73. package/dest/services/dummy_service.d.ts.map +1 -1
  74. package/dest/services/dummy_service.js +6 -0
  75. package/dest/services/encoding.d.ts +2 -2
  76. package/dest/services/encoding.d.ts.map +1 -1
  77. package/dest/services/encoding.js +2 -2
  78. package/dest/services/gossipsub/index.d.ts +3 -0
  79. package/dest/services/gossipsub/index.d.ts.map +1 -0
  80. package/dest/services/gossipsub/index.js +2 -0
  81. package/dest/services/gossipsub/scoring.d.ts +21 -3
  82. package/dest/services/gossipsub/scoring.d.ts.map +1 -1
  83. package/dest/services/gossipsub/scoring.js +24 -7
  84. package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
  85. package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
  86. package/dest/services/gossipsub/topic_score_params.js +324 -0
  87. package/dest/services/libp2p/libp2p_service.d.ts +84 -35
  88. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  89. package/dest/services/libp2p/libp2p_service.js +368 -273
  90. package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
  91. package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
  92. package/dest/services/peer-manager/peer_scoring.js +25 -2
  93. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -4
  94. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
  95. package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +8 -8
  96. package/dest/services/reqresp/interface.d.ts +10 -1
  97. package/dest/services/reqresp/interface.d.ts.map +1 -1
  98. package/dest/services/reqresp/interface.js +15 -1
  99. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +7 -5
  100. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
  101. package/dest/services/reqresp/protocols/block_txs/block_txs_handler.js +16 -11
  102. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +21 -10
  103. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
  104. package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +27 -11
  105. package/dest/services/reqresp/protocols/tx.d.ts +7 -1
  106. package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
  107. package/dest/services/reqresp/protocols/tx.js +20 -0
  108. package/dest/services/reqresp/reqresp.d.ts +1 -1
  109. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  110. package/dest/services/reqresp/reqresp.js +11 -4
  111. package/dest/services/service.d.ts +35 -1
  112. package/dest/services/service.d.ts.map +1 -1
  113. package/dest/services/tx_collection/config.d.ts +22 -4
  114. package/dest/services/tx_collection/config.d.ts.map +1 -1
  115. package/dest/services/tx_collection/config.js +49 -3
  116. package/dest/services/tx_collection/fast_tx_collection.d.ts +6 -5
  117. package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
  118. package/dest/services/tx_collection/fast_tx_collection.js +27 -17
  119. package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
  120. package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
  121. package/dest/services/tx_collection/file_store_tx_collection.js +165 -0
  122. package/dest/services/tx_collection/file_store_tx_source.d.ts +28 -0
  123. package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
  124. package/dest/services/tx_collection/file_store_tx_source.js +59 -0
  125. package/dest/services/tx_collection/index.d.ts +3 -2
  126. package/dest/services/tx_collection/index.d.ts.map +1 -1
  127. package/dest/services/tx_collection/index.js +1 -0
  128. package/dest/services/tx_collection/proposal_tx_collector.d.ts +12 -12
  129. package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
  130. package/dest/services/tx_collection/proposal_tx_collector.js +4 -5
  131. package/dest/services/tx_collection/slow_tx_collection.d.ts +6 -2
  132. package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
  133. package/dest/services/tx_collection/slow_tx_collection.js +55 -23
  134. package/dest/services/tx_collection/tx_collection.d.ts +19 -7
  135. package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
  136. package/dest/services/tx_collection/tx_collection.js +75 -3
  137. package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
  138. package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
  139. package/dest/services/tx_collection/tx_collection_sink.js +13 -7
  140. package/dest/services/tx_file_store/config.d.ts +1 -3
  141. package/dest/services/tx_file_store/config.d.ts.map +1 -1
  142. package/dest/services/tx_file_store/config.js +0 -4
  143. package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
  144. package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
  145. package/dest/services/tx_file_store/tx_file_store.js +8 -5
  146. package/dest/services/tx_provider.d.ts +3 -3
  147. package/dest/services/tx_provider.d.ts.map +1 -1
  148. package/dest/services/tx_provider.js +5 -4
  149. package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
  150. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  151. package/dest/test-helpers/mock-pubsub.d.ts +27 -1
  152. package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
  153. package/dest/test-helpers/mock-pubsub.js +97 -2
  154. package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
  155. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  156. package/dest/test-helpers/reqresp-nodes.js +2 -1
  157. package/dest/test-helpers/testbench-utils.d.ts +40 -38
  158. package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
  159. package/dest/test-helpers/testbench-utils.js +128 -59
  160. package/dest/testbench/p2p_client_testbench_worker.js +2 -2
  161. package/package.json +14 -14
  162. package/src/client/factory.ts +81 -13
  163. package/src/client/interface.ts +45 -14
  164. package/src/client/p2p_client.ts +151 -161
  165. package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +1 -1
  166. package/src/config.ts +34 -2
  167. package/src/index.ts +1 -0
  168. package/src/mem_pools/attestation_pool/attestation_pool.ts +496 -91
  169. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +442 -102
  170. package/src/mem_pools/attestation_pool/index.ts +9 -2
  171. package/src/mem_pools/index.ts +4 -1
  172. package/src/mem_pools/interface.ts +4 -4
  173. package/src/mem_pools/tx_pool_v2/README.md +103 -16
  174. package/src/mem_pools/tx_pool_v2/deleted_pool.ts +310 -0
  175. package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +3 -0
  176. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +1 -1
  177. package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +1 -1
  178. package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +3 -1
  179. package/src/mem_pools/tx_pool_v2/index.ts +1 -0
  180. package/src/mem_pools/tx_pool_v2/interfaces.ts +10 -2
  181. package/src/mem_pools/tx_pool_v2/tx_metadata.ts +57 -6
  182. package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +433 -0
  183. package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +10 -1
  184. package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +266 -607
  185. package/src/msg_validators/attestation_validator/fisherman_attestation_validator.ts +2 -2
  186. package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
  187. package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
  188. package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
  189. package/src/msg_validators/tx_validator/timestamp_validator.ts +19 -14
  190. package/src/services/dummy_service.ts +12 -0
  191. package/src/services/encoding.ts +2 -2
  192. package/src/services/gossipsub/README.md +626 -0
  193. package/src/services/gossipsub/index.ts +2 -0
  194. package/src/services/gossipsub/scoring.ts +29 -5
  195. package/src/services/gossipsub/topic_score_params.ts +451 -0
  196. package/src/services/libp2p/libp2p_service.ts +370 -275
  197. package/src/services/peer-manager/peer_scoring.ts +25 -0
  198. package/src/services/reqresp/batch-tx-requester/README.md +7 -7
  199. package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +11 -11
  200. package/src/services/reqresp/interface.ts +26 -1
  201. package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +23 -14
  202. package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +38 -15
  203. package/src/services/reqresp/protocols/tx.ts +22 -0
  204. package/src/services/reqresp/reqresp.ts +13 -3
  205. package/src/services/service.ts +40 -0
  206. package/src/services/tx_collection/config.ts +74 -6
  207. package/src/services/tx_collection/fast_tx_collection.ts +28 -26
  208. package/src/services/tx_collection/file_store_tx_collection.ts +198 -0
  209. package/src/services/tx_collection/file_store_tx_source.ts +73 -0
  210. package/src/services/tx_collection/index.ts +2 -1
  211. package/src/services/tx_collection/proposal_tx_collector.ts +12 -14
  212. package/src/services/tx_collection/slow_tx_collection.ts +64 -30
  213. package/src/services/tx_collection/tx_collection.ts +109 -13
  214. package/src/services/tx_collection/tx_collection_sink.ts +17 -7
  215. package/src/services/tx_file_store/config.ts +0 -6
  216. package/src/services/tx_file_store/tx_file_store.ts +9 -7
  217. package/src/services/tx_provider.ts +8 -7
  218. package/src/test-helpers/make-test-p2p-clients.ts +3 -3
  219. package/src/test-helpers/mock-pubsub.ts +133 -3
  220. package/src/test-helpers/reqresp-nodes.ts +2 -1
  221. package/src/test-helpers/testbench-utils.ts +127 -71
  222. package/src/testbench/p2p_client_testbench_worker.ts +2 -2
  223. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +0 -40
  224. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +0 -1
  225. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +0 -218
  226. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +0 -31
  227. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +0 -1
  228. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +0 -180
  229. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +0 -320
  230. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +0 -264
@@ -2,7 +2,7 @@ import type { EpochCacheInterface } from '@aztec/epoch-cache';
2
2
  import { type CheckpointAttestation, PeerErrorSeverity, type ValidationResult } from '@aztec/stdlib/p2p';
3
3
  import { Attributes, Metrics, type TelemetryClient, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
4
4
 
5
- import type { AttestationPool } from '../../mem_pools/attestation_pool/attestation_pool.js';
5
+ import type { AttestationPoolApi } from '../../mem_pools/attestation_pool/attestation_pool.js';
6
6
  import { CheckpointAttestationValidator } from './attestation_validator.js';
7
7
 
8
8
  /**
@@ -18,7 +18,7 @@ export class FishermanAttestationValidator extends CheckpointAttestationValidato
18
18
 
19
19
  constructor(
20
20
  epochCache: EpochCacheInterface,
21
- private attestationPool: AttestationPool,
21
+ private attestationPool: AttestationPoolApi,
22
22
  telemetryClient: TelemetryClient,
23
23
  ) {
24
24
  super(epochCache);
@@ -1,6 +1,6 @@
1
- import type { ProcessedTx, Tx, TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
1
+ import type { TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
2
2
 
3
- export class AggregateTxValidator<T extends Tx | ProcessedTx> implements TxValidator<T> {
3
+ export class AggregateTxValidator<T> implements TxValidator<T> {
4
4
  #validators: TxValidator<T>[];
5
5
  constructor(...validators: TxValidator<T>[]) {
6
6
  if (validators.length === 0) {
@@ -1,12 +1,24 @@
1
1
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
2
  import type { BlockHash } from '@aztec/stdlib/block';
3
- import { type AnyTx, TX_ERROR_BLOCK_HEADER, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
3
+ import { TX_ERROR_BLOCK_HEADER, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
4
4
 
5
5
  export interface ArchiveSource {
6
6
  getArchiveIndices: (archives: BlockHash[]) => Promise<(bigint | undefined)[]>;
7
7
  }
8
8
 
9
- export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
9
+ /** Structural interface for block header validation. */
10
+ export interface HasBlockHeaderData {
11
+ txHash: { toString(): string };
12
+ data: {
13
+ constants: {
14
+ anchorBlockHeader: {
15
+ hash(): Promise<BlockHash>;
16
+ };
17
+ };
18
+ };
19
+ }
20
+
21
+ export class BlockHeaderTxValidator<T extends HasBlockHeaderData> implements TxValidator<T> {
10
22
  #log: Logger;
11
23
  #archiveSource: ArchiveSource;
12
24
 
@@ -18,7 +30,7 @@ export class BlockHeaderTxValidator<T extends AnyTx> implements TxValidator<T> {
18
30
  async validateTx(tx: T): Promise<TxValidationResult> {
19
31
  const [index] = await this.#archiveSource.getArchiveIndices([await tx.data.constants.anchorBlockHeader.hash()]);
20
32
  if (index === undefined) {
21
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for referencing an unknown block header`);
33
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for referencing an unknown block header`);
22
34
  return { result: 'invalid', reason: [TX_ERROR_BLOCK_HEADER] };
23
35
  }
24
36
  return { result: 'valid' };
@@ -1,9 +1,8 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
1
2
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
2
3
  import {
3
- type AnyTx,
4
4
  TX_ERROR_DUPLICATE_NULLIFIER_IN_TX,
5
5
  TX_ERROR_EXISTING_NULLIFIER,
6
- Tx,
7
6
  type TxValidationResult,
8
7
  type TxValidator,
9
8
  } from '@aztec/stdlib/tx';
@@ -12,7 +11,13 @@ export interface NullifierSource {
12
11
  nullifiersExist: (nullifiers: Buffer[]) => Promise<boolean[]>;
13
12
  }
14
13
 
15
- export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
14
+ /** Structural interface for double-spend validation. */
15
+ export interface HasNullifierData {
16
+ txHash: { toString(): string };
17
+ data: { getNonEmptyNullifiers(): Fr[] };
18
+ }
19
+
20
+ export class DoubleSpendTxValidator<T extends HasNullifierData> implements TxValidator<T> {
16
21
  #log: Logger;
17
22
  #nullifierSource: NullifierSource;
18
23
 
@@ -22,17 +27,17 @@ export class DoubleSpendTxValidator<T extends AnyTx> implements TxValidator<T> {
22
27
  }
23
28
 
24
29
  async validateTx(tx: T): Promise<TxValidationResult> {
25
- const nullifiers = tx instanceof Tx ? tx.data.getNonEmptyNullifiers() : tx.txEffect.nullifiers;
30
+ const nullifiers = tx.data.getNonEmptyNullifiers();
26
31
 
27
32
  // Ditch this tx if it has repeated nullifiers
28
33
  const uniqueNullifiers = new Set(nullifiers.map(n => n.toBigInt()));
29
34
  if (uniqueNullifiers.size !== nullifiers.length) {
30
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for emitting duplicate nullifiers`);
35
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for emitting duplicate nullifiers`);
31
36
  return { result: 'invalid', reason: [TX_ERROR_DUPLICATE_NULLIFIER_IN_TX] };
32
37
  }
33
38
 
34
39
  if ((await this.#nullifierSource.nullifiersExist(nullifiers.map(n => n.toBuffer()))).some(Boolean)) {
35
- this.#log.verbose(`Rejecting tx ${'txHash' in tx ? tx.txHash : tx.hash} for repeating a nullifier`);
40
+ this.#log.verbose(`Rejecting tx ${tx.txHash} for repeating a nullifier`);
36
41
  return { result: 'invalid', reason: [TX_ERROR_EXISTING_NULLIFIER] };
37
42
  }
38
43
 
@@ -1,15 +1,24 @@
1
- import { BlockNumber } from '@aztec/foundation/branded-types';
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
- import {
4
- type AnyTx,
5
- TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP,
6
- type TxValidationResult,
7
- type TxValidator,
8
- getTxHash,
9
- } from '@aztec/stdlib/tx';
3
+ import { TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
10
4
  import type { UInt64 } from '@aztec/stdlib/types';
11
5
 
12
- export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
6
+ /** Structural interface for timestamp validation. */
7
+ export interface HasTimestampData {
8
+ txHash: { toString(): string };
9
+ data: {
10
+ includeByTimestamp: bigint;
11
+ constants: {
12
+ anchorBlockHeader: {
13
+ globalVariables: {
14
+ blockNumber: BlockNumber;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ }
20
+
21
+ export class TimestampTxValidator<T extends HasTimestampData> implements TxValidator<T> {
13
22
  #log: Logger;
14
23
 
15
24
  constructor(
@@ -38,11 +47,7 @@ export class TimestampTxValidator<T extends AnyTx> implements TxValidator<T> {
38
47
  );
39
48
  }
40
49
  this.#log.verbose(
41
- `Rejecting tx ${getTxHash(
42
- tx,
43
- )} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${
44
- this.values.timestamp
45
- }.`,
50
+ `Rejecting tx ${tx.txHash} for low expiration timestamp. Tx expiration timestamp: ${includeByTimestamp}, timestamp: ${this.values.timestamp}.`,
46
51
  );
47
52
  return Promise.resolve({ result: 'invalid', reason: [TX_ERROR_INVALID_INCLUDE_BY_TIMESTAMP] });
48
53
  } else {
@@ -26,6 +26,8 @@ import { ReqRespStatus } from './reqresp/status.js';
26
26
  import {
27
27
  type P2PBlockReceivedCallback,
28
28
  type P2PCheckpointReceivedCallback,
29
+ type P2PDuplicateAttestationCallback,
30
+ type P2PDuplicateProposalCallback,
29
31
  type P2PService,
30
32
  type PeerDiscoveryService,
31
33
  PeerDiscoveryState,
@@ -82,6 +84,16 @@ export class DummyP2PService implements P2PService {
82
84
  */
83
85
  public registerCheckpointReceivedCallback(_callback: P2PCheckpointReceivedCallback) {}
84
86
 
87
+ /**
88
+ * Register a callback for when a duplicate proposal is detected
89
+ */
90
+ public registerDuplicateProposalCallback(_callback: P2PDuplicateProposalCallback): void {}
91
+
92
+ /**
93
+ * Register a callback for when a duplicate attestation is detected
94
+ */
95
+ public registerDuplicateAttestationCallback(_callback: P2PDuplicateAttestationCallback): void {}
96
+
85
97
  /**
86
98
  * Sends a request to a peer.
87
99
  * @param _protocol - The protocol to send the request on.
@@ -78,11 +78,11 @@ export class SnappyTransform implements DataTransform {
78
78
  return this.inboundTransformData(Buffer.from(data), topic);
79
79
  }
80
80
 
81
- public inboundTransformData(data: Buffer, topic?: TopicType): Buffer {
81
+ public inboundTransformData(data: Buffer, topic?: TopicType, maxSizeKbOverride?: number): Buffer {
82
82
  if (data.length === 0) {
83
83
  return data;
84
84
  }
85
- const maxSizeKb = this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
85
+ const maxSizeKb = maxSizeKbOverride ?? this.maxSizesKb[topic!] ?? this.defaultMaxSizeKb;
86
86
  const { decompressedSize } = readSnappyPreamble(data);
87
87
  if (decompressedSize > maxSizeKb * 1024) {
88
88
  this.logger.warn(`Decompressed size ${decompressedSize} exceeds maximum allowed size of ${maxSizeKb}kb`);