@aztec/p2p 0.86.0-starknet.1 → 0.87.0

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 (132) hide show
  1. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  2. package/dest/client/factory.d.ts +1 -1
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +11 -13
  5. package/dest/client/interface.d.ts +10 -1
  6. package/dest/client/interface.d.ts.map +1 -1
  7. package/dest/client/p2p_client.d.ts +18 -6
  8. package/dest/client/p2p_client.d.ts.map +1 -1
  9. package/dest/client/p2p_client.js +103 -53
  10. package/dest/config.d.ts +5 -6
  11. package/dest/config.d.ts.map +1 -1
  12. package/dest/config.js +6 -11
  13. package/dest/enr/generate-enr.d.ts +7 -0
  14. package/dest/enr/generate-enr.d.ts.map +1 -1
  15. package/dest/enr/generate-enr.js +23 -2
  16. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  17. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  18. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +3 -0
  19. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  20. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +44 -14
  21. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +2 -0
  22. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  23. package/dest/mem_pools/tx_pool/memory_tx_pool.js +6 -0
  24. package/dest/mem_pools/tx_pool/tx_pool.d.ts +7 -0
  25. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  26. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  27. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +13 -5
  28. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  29. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  30. package/dest/msg_validators/tx_validator/data_validator.js +15 -14
  31. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +0 -2
  32. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  33. package/dest/msg_validators/tx_validator/double_spend_validator.js +2 -2
  34. package/dest/msg_validators/tx_validator/factory.d.ts +14 -0
  35. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
  36. package/dest/msg_validators/tx_validator/factory.js +62 -0
  37. package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
  38. package/dest/msg_validators/tx_validator/metadata_validator.js +5 -5
  39. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  40. package/dest/msg_validators/tx_validator/phases_validator.js +1 -1
  41. package/dest/msg_validators/tx_validator/tx_proof_validator.js +1 -1
  42. package/dest/services/discv5/discV5_service.d.ts +2 -2
  43. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  44. package/dest/services/discv5/discV5_service.js +9 -13
  45. package/dest/services/dummy_service.d.ts +3 -3
  46. package/dest/services/dummy_service.d.ts.map +1 -1
  47. package/dest/services/dummy_service.js +6 -1
  48. package/dest/services/encoding.d.ts +1 -3
  49. package/dest/services/encoding.d.ts.map +1 -1
  50. package/dest/services/libp2p/libp2p_service.d.ts +4 -2
  51. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  52. package/dest/services/libp2p/libp2p_service.js +87 -88
  53. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  54. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  55. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  56. package/dest/services/peer-manager/peer_manager.js +11 -2
  57. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  58. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -2
  59. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  60. package/dest/services/reqresp/connection-sampler/connection_sampler.js +41 -21
  61. package/dest/services/reqresp/interface.d.ts +1 -3
  62. package/dest/services/reqresp/interface.d.ts.map +1 -1
  63. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  64. package/dest/services/reqresp/protocols/goodbye.d.ts +0 -2
  65. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  66. package/dest/services/reqresp/protocols/goodbye.js +1 -1
  67. package/dest/services/reqresp/protocols/ping.d.ts +0 -2
  68. package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
  69. package/dest/services/reqresp/protocols/status.d.ts +0 -2
  70. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  71. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  72. package/dest/services/reqresp/reqresp.d.ts +1 -3
  73. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  74. package/dest/services/reqresp/reqresp.js +2 -2
  75. package/dest/services/service.d.ts +3 -2
  76. package/dest/services/service.d.ts.map +1 -1
  77. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  78. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  79. package/dest/test-helpers/make-test-p2p-clients.js +2 -2
  80. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  81. package/dest/test-helpers/reqresp-nodes.js +1 -1
  82. package/dest/testbench/p2p_client_testbench_worker.js +9 -6
  83. package/dest/testbench/testbench.js +1 -1
  84. package/dest/testbench/worker_client_manager.d.ts +0 -1
  85. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  86. package/dest/testbench/worker_client_manager.js +2 -2
  87. package/dest/types/index.d.ts +1 -0
  88. package/dest/types/index.d.ts.map +1 -1
  89. package/dest/types/index.js +1 -0
  90. package/dest/versioning.d.ts +2 -2
  91. package/dest/versioning.d.ts.map +1 -1
  92. package/dest/versioning.js +6 -1
  93. package/package.json +15 -15
  94. package/src/bootstrap/bootstrap.ts +1 -1
  95. package/src/client/factory.ts +33 -32
  96. package/src/client/interface.ts +13 -1
  97. package/src/client/p2p_client.ts +129 -55
  98. package/src/config.ts +11 -18
  99. package/src/enr/generate-enr.ts +33 -3
  100. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +2 -2
  101. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +4 -1
  102. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +72 -34
  103. package/src/mem_pools/tx_pool/memory_tx_pool.ts +12 -1
  104. package/src/mem_pools/tx_pool/tx_pool.ts +9 -0
  105. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +9 -3
  106. package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
  107. package/src/msg_validators/tx_validator/data_validator.ts +24 -18
  108. package/src/msg_validators/tx_validator/double_spend_validator.ts +2 -2
  109. package/src/msg_validators/tx_validator/factory.ts +94 -0
  110. package/src/msg_validators/tx_validator/gas_validator.ts +3 -3
  111. package/src/msg_validators/tx_validator/metadata_validator.ts +5 -5
  112. package/src/msg_validators/tx_validator/phases_validator.ts +6 -2
  113. package/src/msg_validators/tx_validator/tx_proof_validator.ts +1 -1
  114. package/src/services/discv5/discV5_service.ts +14 -12
  115. package/src/services/dummy_service.ts +8 -2
  116. package/src/services/libp2p/libp2p_service.ts +95 -107
  117. package/src/services/peer-manager/metrics.ts +4 -1
  118. package/src/services/peer-manager/peer_manager.ts +18 -1
  119. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +5 -1
  120. package/src/services/reqresp/connection-sampler/connection_sampler.ts +42 -19
  121. package/src/services/reqresp/metrics.ts +4 -1
  122. package/src/services/reqresp/protocols/goodbye.ts +1 -1
  123. package/src/services/reqresp/rate-limiter/rate_limiter.ts +4 -1
  124. package/src/services/reqresp/reqresp.ts +2 -1
  125. package/src/services/service.ts +4 -1
  126. package/src/test-helpers/make-test-p2p-clients.ts +2 -1
  127. package/src/test-helpers/reqresp-nodes.ts +1 -1
  128. package/src/testbench/p2p_client_testbench_worker.ts +8 -4
  129. package/src/testbench/testbench.ts +1 -1
  130. package/src/testbench/worker_client_manager.ts +2 -2
  131. package/src/types/index.ts +1 -0
  132. package/src/versioning.ts +8 -1
package/dest/config.js CHANGED
@@ -84,16 +84,6 @@ export const p2pConfigMappings = {
84
84
  description: 'If announceUdpAddress or announceTcpAddress are not provided, query for the IP address of the machine. Default is false.',
85
85
  ...booleanConfigHelper()
86
86
  },
87
- keepProvenTxsInPoolFor: {
88
- env: 'P2P_TX_POOL_KEEP_PROVEN_FOR',
89
- description: 'How many blocks have to pass after a block is proven before its txs are deleted (zero to delete immediately once proven)',
90
- ...numberConfigHelper(0)
91
- },
92
- keepAttestationsInPoolFor: {
93
- env: 'P2P_ATTESTATION_POOL_KEEP_FOR',
94
- description: 'How many slots to keep attestations for.',
95
- ...numberConfigHelper(96)
96
- },
97
87
  gossipsubInterval: {
98
88
  env: 'P2P_GOSSIPSUB_INTERVAL_MS',
99
89
  description: 'The interval of the gossipsub heartbeat to perform maintenance tasks.',
@@ -131,9 +121,14 @@ export const p2pConfigMappings = {
131
121
  },
132
122
  gossipsubMcacheGossip: {
133
123
  env: 'P2P_GOSSIPSUB_MCACHE_GOSSIP',
134
- description: 'How many message cache windows to include when gossiping with other pears.',
124
+ description: 'How many message cache windows to include when gossiping with other peers.',
135
125
  ...numberConfigHelper(3)
136
126
  },
127
+ gossipsubSeenTTL: {
128
+ env: 'P2P_GOSSIPSUB_SEEN_TTL',
129
+ description: 'How long to keep message IDs in the seen cache.',
130
+ ...numberConfigHelper(20 * 60 * 1000)
131
+ },
137
132
  gossipsubTxTopicWeight: {
138
133
  env: 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT',
139
134
  description: 'The weight of the tx topic for the gossipsub protocol.',
@@ -1,10 +1,17 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
+ import { type ChainConfig } from '@aztec/stdlib/config';
3
+ import type { ComponentsVersions } from '@aztec/stdlib/versioning';
2
4
  import { ENR, SignableENR } from '@chainsafe/enr';
3
5
  import type { PeerId } from '@libp2p/interface';
6
+ import { type Multiaddr } from '@multiformats/multiaddr';
4
7
  export { ENR };
5
8
  export declare function createBootnodeENRandPeerId(privateKey: string, p2pIp: string, p2pBroadcastPort: number, l1ChainId: number): Promise<{
6
9
  enr: SignableENR;
7
10
  peerId: PeerId;
8
11
  }>;
12
+ export declare function createNodeENR(peerId: PeerId, multiAddrUdp: Multiaddr | undefined, multiAddrTcp: Multiaddr | undefined, chainConfig: ChainConfig, packageVersion: string): {
13
+ enr: SignableENR;
14
+ versions: ComponentsVersions;
15
+ };
9
16
  export declare function printENR(enr: string, log: LogFn): Promise<void>;
10
17
  //# sourceMappingURL=generate-enr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-enr.d.ts","sourceRoot":"","sources":["../../src/enr/generate-enr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAa/C;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAQrD"}
1
+ {"version":3,"file":"generate-enr.d.ts","sourceRoot":"","sources":["../../src/enr/generate-enr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAC;AAMpE,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAa/C;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,GAAG,SAAS,EACnC,YAAY,EAAE,SAAS,GAAG,SAAS,EACnC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,GACrB;IAAE,GAAG,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,kBAAkB,CAAA;CAAE,CAiBpD;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAYrD"}
@@ -1,9 +1,9 @@
1
1
  import { emptyChainConfig } from '@aztec/stdlib/config';
2
2
  import { ENR, SignableENR } from '@chainsafe/enr';
3
3
  import { multiaddr } from '@multiformats/multiaddr';
4
- import { AZTEC_ENR_KEY } from '../types/index.js';
4
+ import { AZTEC_ENR_CLIENT_VERSION_KEY, AZTEC_ENR_KEY } from '../types/index.js';
5
5
  import { convertToMultiaddr, createLibP2PPeerIdFromPrivateKey } from '../util.js';
6
- import { setAztecEnrKey } from '../versioning.js';
6
+ import { setAztecClientVersionEnrKey, setAztecEnrKey } from '../versioning.js';
7
7
  export { ENR };
8
8
  export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcastPort, l1ChainId) {
9
9
  const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
@@ -20,6 +20,25 @@ export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcast
20
20
  peerId
21
21
  };
22
22
  }
23
+ export function createNodeENR(peerId, multiAddrUdp, multiAddrTcp, chainConfig, packageVersion) {
24
+ // create ENR from PeerId
25
+ const enr = SignableENR.createFromPeerId(peerId);
26
+ // Add aztec identification to ENR
27
+ const versions = setAztecEnrKey(enr, chainConfig);
28
+ // Add aztec client version to ENR
29
+ setAztecClientVersionEnrKey(enr, packageVersion);
30
+ // set location multiaddr in ENR record
31
+ if (multiAddrUdp) {
32
+ enr.setLocationMultiaddr(multiAddrUdp);
33
+ }
34
+ if (multiAddrTcp) {
35
+ enr.setLocationMultiaddr(multiAddrTcp);
36
+ }
37
+ return {
38
+ enr,
39
+ versions
40
+ };
41
+ }
23
42
  export async function printENR(enr, log) {
24
43
  const decoded = ENR.decodeTxt(enr);
25
44
  log(`PeerID: ${await decoded.peerId()}`);
@@ -28,4 +47,6 @@ export async function printENR(enr, log) {
28
47
  log(`TCP: ${decoded.tcp}`);
29
48
  const aztec = decoded.kvs.get(AZTEC_ENR_KEY);
30
49
  log(`Aztec version: ${aztec?.toString()}`);
50
+ const aztecClientVersion = decoded.kvs.get(AZTEC_ENR_CLIENT_VERSION_KEY);
51
+ log(`Aztec client version ${aztecClientVersion ? aztecClientVersion.toString() : 'N/A'}`);
31
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"memory_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/memory_attestation_pool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,uBAAwB,YAAW,eAAe;;IAKE,OAAO,CAAC,GAAG;IAJ1E,OAAO,CAA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IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAWhG,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC1D,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAiB3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,eAAe,CAAC;AAE3F;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAGlC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,WAClB,eAAe,SACjB,MAAM,YACH,EAAE,QACN,MAAM,EAAE,KACZ,gBASF,CAAC"}
1
+ {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAIjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,KAAK,YAAY,EAA2C,MAAM,eAAe,CAAC;AAE3F;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,YAGlC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,EACvB,OAAM,MAAU,EAChB,UAAS,EAAgB,EACzB,MAAK,MAAM,EAAkD,KAC5D,gBASF,CAAC"}
@@ -28,6 +28,7 @@ export declare class AztecKVTxPool implements TxPool {
28
28
  markMinedAsPending(txHashes: TxHash[]): Promise<void>;
29
29
  getPendingTxHashes(): Promise<TxHash[]>;
30
30
  getMinedTxHashes(): Promise<[TxHash, number][]>;
31
+ getPendingTxCount(): Promise<number>;
31
32
  getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
32
33
  /**
33
34
  * Checks if a transaction exists in the pool and returns it.
@@ -66,6 +67,7 @@ export declare class AztecKVTxPool implements TxPool {
66
67
  */
67
68
  getAllTxHashes(): Promise<TxHash[]>;
68
69
  setMaxTxPoolSize(maxSizeBytes: number | undefined): Promise<void>;
70
+ markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
69
71
  /**
70
72
  * Creates a GasTxValidator instance.
71
73
  * @param db - DB for the validator to use
@@ -120,5 +122,6 @@ export declare class AztecKVTxPool implements TxPool {
120
122
  private evictInvalidTxsAfterReorg;
121
123
  private addPendingTxIndices;
122
124
  private removePendingTxIndices;
125
+ private increasePendingTxCount;
123
126
  }
124
127
  //# sourceMappingURL=aztec_kv_tx_pool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aztec_kv_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/aztec_kv_tx_pool.ts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MnB,sBAAsB;YAOtB,sBAAsB;CAOrC"}
@@ -22,7 +22,9 @@ import { getPendingTxPriority } from './priority.js';
22
22
  /** Index from tx hash to its tx size (in bytes), filtered by pending txs. */ #pendingTxHashToSize;
23
23
  /** Index from tx hash to its header hash, filtered by pending txs. */ #pendingTxHashToHeaderHash;
24
24
  /** The cumulative tx size in bytes that the pending txs in the pool take up. */ #pendingTxSize;
25
+ /** Count of total pending txs. */ #pendingTxCount;
25
26
  /** In-memory mapping of pending tx hashes to the hydrated pending tx in the pool. */ #pendingTxs;
27
+ /** In-memory set of txs that should not be evicted from the pool. */ #nonEvictableTxs;
26
28
  /** KV store for archived txs. */ #archive;
27
29
  /** Archived txs map for future lookup. */ #archivedTxs;
28
30
  /** Indexes of the archived txs by insertion order. */ #archivedTxIndices;
@@ -44,8 +46,10 @@ import { getPendingTxPriority } from './priority.js';
44
46
  this.#pendingTxHashToSize = store.openMap('pendingTxHashToSize');
45
47
  this.#pendingTxHashToHeaderHash = store.openMap('pendingTxHashToHeaderHash');
46
48
  this.#pendingTxSize = store.openSingleton('pendingTxSize');
49
+ this.#pendingTxCount = store.openSingleton('pendingTxCount');
47
50
  this.#maxTxPoolSize = config.maxTxPoolSize;
48
51
  this.#pendingTxs = new Map();
52
+ this.#nonEvictableTxs = new Set();
49
53
  this.#archivedTxs = archive.openMap('archivedTxs');
50
54
  this.#archivedTxIndices = archive.openMap('archivedTxIndices');
51
55
  this.#archivedTxLimit = config.archivedTxLimit ?? 0;
@@ -61,14 +65,14 @@ import { getPendingTxPriority } from './priority.js';
61
65
  }
62
66
  return true;
63
67
  }
64
- markAsMined(txHashes, blockNumber) {
68
+ async markAsMined(txHashes, blockNumber) {
65
69
  if (txHashes.length === 0) {
66
70
  return Promise.resolve();
67
71
  }
68
72
  let deletedPending = 0;
69
73
  const minedNullifiers = new Set();
70
74
  const minedFeePayers = new Set();
71
- return this.#store.transactionAsync(async ()=>{
75
+ await this.#store.transactionAsync(async ()=>{
72
76
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
73
77
  for (const hash of txHashes){
74
78
  const key = hash.toString();
@@ -85,16 +89,21 @@ import { getPendingTxPriority } from './priority.js';
85
89
  }
86
90
  this.#metrics.recordAddedObjects(txHashes.length, 'mined');
87
91
  await this.#pendingTxSize.set(pendingTxSize);
92
+ await this.increasePendingTxCount(-deletedPending);
88
93
  const numTxsEvicted = await this.evictInvalidTxsAfterMining(txHashes, blockNumber, minedNullifiers, minedFeePayers);
89
94
  this.#metrics.recordRemovedObjects(deletedPending + numTxsEvicted, 'pending');
90
95
  });
96
+ // We update this after the transaction above. This ensures that the non-evictable transactions are not evicted
97
+ // until any that have been mined are marked as such.
98
+ // The non-evictable set is not considered when evicting transactions that are invalid after a block is mined.
99
+ this.#nonEvictableTxs.clear();
91
100
  }
92
- markMinedAsPending(txHashes) {
101
+ async markMinedAsPending(txHashes) {
93
102
  if (txHashes.length === 0) {
94
103
  return Promise.resolve();
95
104
  }
96
105
  let markedAsPending = 0;
97
- return this.#store.transactionAsync(async ()=>{
106
+ await this.#store.transactionAsync(async ()=>{
98
107
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
99
108
  for (const hash of txHashes){
100
109
  const key = hash.toString();
@@ -108,13 +117,13 @@ import { getPendingTxPriority } from './priority.js';
108
117
  }
109
118
  }
110
119
  await this.#pendingTxSize.set(pendingTxSize);
111
- }).then(async ()=>{
112
- const numInvalidTxsEvicted = await this.evictInvalidTxsAfterReorg(txHashes);
113
- const { numLowPriorityTxsEvicted, numNewTxsEvicted } = await this.evictLowPriorityTxs(txHashes);
114
- this.#metrics.recordAddedObjects(markedAsPending - numNewTxsEvicted, 'pending');
115
- this.#metrics.recordRemovedObjects(numInvalidTxsEvicted + numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
116
- this.#metrics.recordRemovedObjects(markedAsPending, 'mined');
117
120
  });
121
+ const numInvalidTxsEvicted = await this.evictInvalidTxsAfterReorg(txHashes);
122
+ const { numLowPriorityTxsEvicted, numNewTxsEvicted } = await this.evictLowPriorityTxs(txHashes);
123
+ await this.increasePendingTxCount(markedAsPending);
124
+ this.#metrics.recordAddedObjects(markedAsPending - numNewTxsEvicted, 'pending');
125
+ this.#metrics.recordRemovedObjects(numInvalidTxsEvicted + numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
126
+ this.#metrics.recordRemovedObjects(markedAsPending, 'mined');
118
127
  }
119
128
  async getPendingTxHashes() {
120
129
  const vals = await toArray(this.#pendingTxPriorityToHash.valuesAsync({
@@ -129,6 +138,9 @@ import { getPendingTxPriority } from './priority.js';
129
138
  blockNumber
130
139
  ]);
131
140
  }
141
+ async getPendingTxCount() {
142
+ return await this.#pendingTxCount.getAsync() ?? 0;
143
+ }
132
144
  async getTxStatus(txHash) {
133
145
  const key = txHash.toString();
134
146
  const [isMined, isKnown] = await Promise.all([
@@ -193,26 +205,31 @@ import { getPendingTxPriority } from './priority.js';
193
205
  txStats: await tx.getStats()
194
206
  })));
195
207
  await this.#store.transactionAsync(async ()=>{
196
- let pendingCount = 0;
208
+ let addedCount = 0;
197
209
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
198
210
  await Promise.all(txs.map(async (tx, i)=>{
199
211
  const { txHash, txStats } = hashesAndStats[i];
212
+ const key = txHash.toString();
213
+ if (await this.#txs.hasAsync(key)) {
214
+ this.#log.debug(`Tx ${txHash.toString()} already exists in the pool`);
215
+ return;
216
+ }
200
217
  this.#log.verbose(`Adding tx ${txHash.toString()} to pool`, {
201
218
  eventName: 'tx-added-to-pool',
202
219
  ...txStats
203
220
  });
204
- const key = txHash.toString();
205
221
  await this.#txs.set(key, tx.toBuffer());
206
222
  if (!await this.#minedTxHashToBlock.hasAsync(key)) {
207
- pendingCount++;
223
+ addedCount++;
208
224
  pendingTxSize += tx.getSize();
209
225
  await this.addPendingTxIndices(tx, key);
210
226
  this.#metrics.recordSize(tx);
211
227
  }
212
228
  }));
229
+ await this.increasePendingTxCount(addedCount);
213
230
  await this.#pendingTxSize.set(pendingTxSize);
214
231
  const { numLowPriorityTxsEvicted, numNewTxsEvicted } = await this.evictLowPriorityTxs(hashesAndStats.map(({ txHash })=>txHash));
215
- this.#metrics.recordAddedObjects(pendingCount - numNewTxsEvicted, 'pending');
232
+ this.#metrics.recordAddedObjects(addedCount - numNewTxsEvicted, 'pending');
216
233
  this.#metrics.recordRemovedObjects(numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
217
234
  });
218
235
  }
@@ -246,6 +263,7 @@ import { getPendingTxPriority } from './priority.js';
246
263
  }
247
264
  }
248
265
  await this.#pendingTxSize.set(pendingTxSize);
266
+ await this.increasePendingTxCount(-pendingDeleted);
249
267
  this.#metrics.recordRemovedObjects(pendingDeleted, 'pending');
250
268
  this.#metrics.recordRemovedObjects(minedDeleted, 'mined');
251
269
  });
@@ -273,6 +291,10 @@ import { getPendingTxPriority } from './priority.js';
273
291
  this.#maxTxPoolSize = maxSizeBytes;
274
292
  return Promise.resolve();
275
293
  }
294
+ markTxsAsNonEvictable(txHashes) {
295
+ txHashes.forEach((txHash)=>this.#nonEvictableTxs.add(txHash.toString()));
296
+ return Promise.resolve();
297
+ }
276
298
  /**
277
299
  * Creates a GasTxValidator instance.
278
300
  * @param db - DB for the validator to use
@@ -361,6 +383,9 @@ import { getPendingTxPriority } from './priority.js';
361
383
  let pendingTxsSize = await this.#pendingTxSize.getAsync() ?? 0;
362
384
  if (pendingTxsSize > this.#maxTxPoolSize) {
363
385
  for await (const txHash of this.#pendingTxPriorityToHash.valuesAsync()){
386
+ if (this.#nonEvictableTxs.has(txHash.toString())) {
387
+ continue;
388
+ }
364
389
  this.#log.verbose(`Evicting tx ${txHash} from pool due to low priority to satisfy max tx size limit`);
365
390
  txsToEvict.push(TxHash.fromString(txHash));
366
391
  const txSize = await this.#pendingTxHashToSize.getAsync(txHash.toString()) ?? (await this.getPendingTxByHash(txHash))?.getSize();
@@ -479,4 +504,9 @@ import { getPendingTxPriority } from './priority.js';
479
504
  await this.#pendingTxHashToHeaderHash.delete(txHash);
480
505
  this.#pendingTxs.delete(txHash);
481
506
  }
507
+ async increasePendingTxCount(count) {
508
+ const pendingTxCount = await this.#pendingTxCount.getAsync() ?? 0;
509
+ this.#log.debug(`Increasing pending tx count: current ${pendingTxCount} + count ${count} = ${pendingTxCount + count}`);
510
+ await this.#pendingTxCount.set(pendingTxCount + count);
511
+ }
482
512
  }
@@ -23,6 +23,7 @@ export declare class InMemoryTxPool implements TxPool {
23
23
  markMinedAsPending(txHashes: TxHash[]): Promise<void>;
24
24
  getPendingTxHashes(): Promise<TxHash[]>;
25
25
  getMinedTxHashes(): Promise<[TxHash, number][]>;
26
+ getPendingTxCount(): Promise<number>;
26
27
  getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
27
28
  /**
28
29
  * Checks if a transaction exists in the pool and returns it.
@@ -56,5 +57,6 @@ export declare class InMemoryTxPool implements TxPool {
56
57
  */
57
58
  getAllTxHashes(): Promise<TxHash[]>;
58
59
  setMaxTxPoolSize(_maxSizeBytes: number | undefined): Promise<void>;
60
+ markTxsAsNonEvictable(_: TxHash[]): Promise<void>;
59
61
  }
60
62
  //# sourceMappingURL=memory_tx_pool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory_tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/memory_tx_pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAInF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,qBAAa,cAAe,YAAW,MAAM;IAcoB,OAAO,CAAC,GAAG;IAb1E;;OAEG;IACH,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,UAAU,CAAc;IAEhC,OA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SAAS,CAAC,EAAE,CAAC;IAG7D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC,mBAAmB,IAAI,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAIrD;;;;OAIG;IACU,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB7C;;;;OAIG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBnD;;;OAGG;IACI,SAAS,IAAI,OAAO,CAAC,EAAE,EAAE,CAAC;IAIjC;;;OAGG;IACI,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI1C,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlD"}
@@ -68,6 +68,9 @@ import { getPendingTxPriority } from './priority.js';
68
68
  blockNumber
69
69
  ]));
70
70
  }
71
+ getPendingTxCount() {
72
+ return Promise.resolve(this.pendingTxs.size);
73
+ }
71
74
  getTxStatus(txHash) {
72
75
  const key = txHash.toBigInt();
73
76
  if (this.pendingTxs.has(key)) {
@@ -150,4 +153,7 @@ import { getPendingTxPriority } from './priority.js';
150
153
  setMaxTxPoolSize(_maxSizeBytes) {
151
154
  return Promise.resolve();
152
155
  }
156
+ markTxsAsNonEvictable(_) {
157
+ return Promise.resolve();
158
+ }
153
159
  }
@@ -63,6 +63,8 @@ export interface TxPool {
63
63
  * @returns An array of pending transaction hashes found in the tx pool.
64
64
  */
65
65
  getPendingTxHashes(): Promise<TxHash[]>;
66
+ /** Returns the number of pending txs in the pool. */
67
+ getPendingTxCount(): Promise<number>;
66
68
  /**
67
69
  * Gets the hashes of mined transactions currently in the tx pool.
68
70
  * @returns An array of mined transaction hashes found in the tx pool.
@@ -81,5 +83,10 @@ export interface TxPool {
81
83
  setMaxTxPoolSize(maxSizeBytes: number | undefined): Promise<void>;
82
84
  /** Returns whether the pool is empty. */
83
85
  isEmpty(): Promise<boolean>;
86
+ /**
87
+ * Marks transactions as non-evictible in the pool.
88
+ * @param txHashes - Hashes of the transactions to mark as non-evictible.
89
+ */
90
+ markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
84
91
  }
85
92
  //# sourceMappingURL=tx_pool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tx_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAErD;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;IAE9D;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE/C;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;IAE7D;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;OAIG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CA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E,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"tx_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool_test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,QAiKrD"}
1
+ {"version":3,"file":"tx_pool_test_suite.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool/tx_pool_test_suite.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,MAAM,QAuKrD"}
@@ -20,6 +20,7 @@ import { mockTx } from '@aztec/stdlib/testing';
20
20
  await expect(pool.getPendingTxHashes()).resolves.toEqual([
21
21
  await tx1.getTxHash()
22
22
  ]);
23
+ await expect(pool.getPendingTxCount()).resolves.toEqual(1);
23
24
  });
24
25
  it('Removes txs from the pool', async ()=>{
25
26
  const tx1 = await mockTx();
@@ -31,6 +32,7 @@ import { mockTx } from '@aztec/stdlib/testing';
31
32
  ]);
32
33
  await expect(pool.getTxByHash(await tx1.getTxHash())).resolves.toBeFalsy();
33
34
  await expect(pool.getTxStatus(await tx1.getTxHash())).resolves.toBeUndefined();
35
+ await expect(pool.getPendingTxCount()).resolves.toEqual(0);
34
36
  });
35
37
  it('Marks txs as mined', async ()=>{
36
38
  const tx1 = await mockTx(1);
@@ -53,6 +55,7 @@ import { mockTx } from '@aztec/stdlib/testing';
53
55
  await expect(pool.getPendingTxHashes()).resolves.toEqual([
54
56
  await tx2.getTxHash()
55
57
  ]);
58
+ await expect(pool.getPendingTxCount()).resolves.toEqual(1);
56
59
  });
57
60
  it('Marks txs as pending after being mined', async ()=>{
58
61
  const tx1 = await mockTx(1);
@@ -74,6 +77,7 @@ import { mockTx } from '@aztec/stdlib/testing';
74
77
  await tx1.getTxHash(),
75
78
  await tx2.getTxHash()
76
79
  ]));
80
+ await expect(pool.getPendingTxCount()).resolves.toEqual(2);
77
81
  });
78
82
  it('Only marks txs as pending if they are known', async ()=>{
79
83
  const tx1 = await mockTx(1);
@@ -107,6 +111,7 @@ import { mockTx } from '@aztec/stdlib/testing';
107
111
  await expect(pool.getPendingTxHashes()).resolves.toEqual([
108
112
  await tx1.getTxHash()
109
113
  ]); // tx2 is not in the pool
114
+ await expect(pool.getPendingTxCount()).resolves.toEqual(1);
110
115
  });
111
116
  it('Returns all transactions in the pool', async ()=>{
112
117
  const tx1 = await mockTx(1);
@@ -124,6 +129,7 @@ import { mockTx } from '@aztec/stdlib/testing';
124
129
  tx2,
125
130
  tx3
126
131
  ]));
132
+ await expect(pool.getPendingTxCount()).resolves.toEqual(3);
127
133
  });
128
134
  it('Returns all txHashes in the pool', async ()=>{
129
135
  const tx1 = await mockTx(1);
@@ -135,12 +141,14 @@ import { mockTx } from '@aztec/stdlib/testing';
135
141
  tx3
136
142
  ]);
137
143
  const poolTxHashes = await pool.getAllTxHashes();
144
+ const expectedHashes = await Promise.all([
145
+ tx1,
146
+ tx2,
147
+ tx3
148
+ ].map((tx)=>tx.getTxHash()));
138
149
  expect(poolTxHashes).toHaveLength(3);
139
- expect(poolTxHashes).toEqual(expect.arrayContaining([
140
- await tx1.getTxHash(),
141
- await tx2.getTxHash(),
142
- await tx3.getTxHash()
143
- ]));
150
+ expect(poolTxHashes).toEqual(expect.arrayContaining(expectedHashes));
151
+ await expect(pool.getPendingTxCount()).resolves.toEqual(3);
144
152
  });
145
153
  it('Returns txs by their hash', async ()=>{
146
154
  const tx1 = await mockTx(1);
@@ -11,7 +11,7 @@ export class BlockHeaderTxValidator {
11
11
  await tx.data.constants.historicalHeader.hash()
12
12
  ]);
13
13
  if (index === undefined) {
14
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for referencing an unknown block header`);
14
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for referencing an unknown block header`);
15
15
  return {
16
16
  result: 'invalid',
17
17
  reason: [
@@ -1 +1 @@
1
- {"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,EAAE,EACF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,eAAgB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAG/C,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmFtD"}
1
+ {"version":3,"file":"data_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/data_validator.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,EAAE,EACF,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,eAAgB,YAAW,WAAW,CAAC,EAAE,CAAC;;IAG/C,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyFtD"}
@@ -12,7 +12,7 @@ export class DataTxValidator {
12
12
  async #hasCorrectCalldata(tx) {
13
13
  if (tx.publicFunctionCalldata.length !== tx.numberOfPublicCalls()) {
14
14
  const reason = TX_ERROR_CALLDATA_COUNT_MISMATCH;
15
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${tx.publicFunctionCalldata.length}.`);
15
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected ${tx.numberOfPublicCalls()}. Got ${tx.publicFunctionCalldata.length}.`);
16
16
  return {
17
17
  result: 'invalid',
18
18
  reason: [
@@ -22,7 +22,7 @@ export class DataTxValidator {
22
22
  }
23
23
  if (tx.getTotalPublicCalldataCount() > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
24
24
  const reason = TX_ERROR_CALLDATA_COUNT_TOO_LARGE;
25
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`);
25
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Expected no greater than ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS} fields. Got ${tx.getTotalPublicCalldataCount()}.`);
26
26
  return {
27
27
  result: 'invalid',
28
28
  reason: [
@@ -36,7 +36,7 @@ export class DataTxValidator {
36
36
  const hash = await computeCalldataHash(calldata);
37
37
  if (!hash.equals(request.calldataHash)) {
38
38
  const reason = TX_ERROR_INCORRECT_CALLDATA;
39
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
39
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)}. Reason: ${reason}. Call request index: ${i}.`);
40
40
  return {
41
41
  result: 'invalid',
42
42
  reason: [
@@ -51,9 +51,8 @@ export class DataTxValidator {
51
51
  }
52
52
  async #hasCorrectContractClassLogs(tx) {
53
53
  const contractClassLogsHashes = tx.data.getNonEmptyContractClassLogsHashes();
54
- const hashedContractClasslogs = await Promise.all(tx.contractClassLogs.map((l)=>l.hash()));
55
- if (contractClassLogsHashes.length !== hashedContractClasslogs.length) {
56
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched number of contract class logs. Expected ${contractClassLogsHashes.length}. Got ${hashedContractClasslogs.length}.`);
54
+ if (contractClassLogsHashes.length !== tx.contractClassLogs.length) {
55
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched number of contract class logs. Expected ${contractClassLogsHashes.length}. Got ${tx.contractClassLogs.length}.`);
57
56
  return {
58
57
  result: 'invalid',
59
58
  reason: [
@@ -61,12 +60,13 @@ export class DataTxValidator {
61
60
  ]
62
61
  };
63
62
  }
63
+ const expectedHashes = await Promise.all(tx.contractClassLogs.map((l)=>l.hash()));
64
64
  for (const [i, logHash] of contractClassLogsHashes.entries()){
65
- const hashedLog = hashedContractClasslogs[i];
66
- if (!logHash.value.equals(hashedLog)) {
67
- if (hashedContractClasslogs.some((l)=>logHash.value.equals(l))) {
68
- const matchingLogIndex = hashedContractClasslogs.findIndex((l)=>logHash.value.equals(l));
69
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs indices. Expected ${i} from the kernel's log hashes. Got ${matchingLogIndex} in the tx.`);
65
+ const hash = expectedHashes[i];
66
+ if (!logHash.value.equals(hash)) {
67
+ if (expectedHashes.some((h)=>logHash.value.equals(h))) {
68
+ const matchingLogIndex = expectedHashes.findIndex((l)=>logHash.value.equals(l));
69
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs indices. Expected ${i} from the kernel's log hashes. Got ${matchingLogIndex} in the tx.`);
70
70
  return {
71
71
  result: 'invalid',
72
72
  reason: [
@@ -74,7 +74,7 @@ export class DataTxValidator {
74
74
  ]
75
75
  };
76
76
  } else {
77
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs. Expected hash ${logHash.value} from the kernels. Got ${hashedLog} in the tx.`);
77
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs. Expected hash ${logHash.value} from the kernels. Got ${hash} in the tx.`);
78
78
  return {
79
79
  result: 'invalid',
80
80
  reason: [
@@ -83,8 +83,9 @@ export class DataTxValidator {
83
83
  };
84
84
  }
85
85
  }
86
- if (logHash.logHash.length !== tx.contractClassLogs[i].getEmittedLength()) {
87
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} because of mismatched contract class logs length. Expected ${logHash.logHash.length} from the kernel's log hashes. Got ${tx.contractClassLogs[i].getEmittedLength()} in the tx.`);
86
+ const expectedMinLength = 1 + tx.contractClassLogs[i].fields.findLastIndex((f)=>!f.isZero());
87
+ if (logHash.logHash.length < expectedMinLength) {
88
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} because of incorrect contract class log length. Expected the length to be at least ${expectedMinLength}. Got ${logHash.logHash.length}.`);
88
89
  return {
89
90
  result: 'invalid',
90
91
  reason: [
@@ -1,5 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
1
  import { type AnyTx, type TxValidationResult, type TxValidator } from '@aztec/stdlib/tx';
4
2
  export interface NullifierSource {
5
3
  nullifiersExist: (nullifiers: Buffer[]) => Promise<boolean[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"double_spend_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/double_spend_validator.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,KAAK,EAIV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC/D;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;gBAIhE,eAAe,EAAE,eAAe;IAItC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiBrD"}
1
+ {"version":3,"file":"double_spend_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/double_spend_validator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EAIV,KAAK,kBAAkB,EACvB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CAC/D;AAED,qBAAa,sBAAsB,CAAC,CAAC,SAAS,KAAK,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;;gBAIhE,eAAe,EAAE,eAAe;IAItC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAiBrD"}
@@ -11,7 +11,7 @@ export class DoubleSpendTxValidator {
11
11
  // Ditch this tx if it has repeated nullifiers
12
12
  const uniqueNullifiers = new Set(nullifiers);
13
13
  if (uniqueNullifiers.size !== nullifiers.length) {
14
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for emitting duplicate nullifiers`);
14
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for emitting duplicate nullifiers`);
15
15
  return {
16
16
  result: 'invalid',
17
17
  reason: [
@@ -20,7 +20,7 @@ export class DoubleSpendTxValidator {
20
20
  };
21
21
  }
22
22
  if ((await this.#nullifierSource.nullifiersExist(nullifiers.map((n)=>n.toBuffer()))).some(Boolean)) {
23
- this.#log.warn(`Rejecting tx ${await Tx.getHash(tx)} for repeating a nullifier`);
23
+ this.#log.verbose(`Rejecting tx ${await Tx.getHash(tx)} for repeating a nullifier`);
24
24
  return {
25
25
  result: 'invalid',
26
26
  reason: [
@@ -0,0 +1,14 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import type { ContractDataSource } from '@aztec/stdlib/contract';
3
+ import type { GasFees } from '@aztec/stdlib/gas';
4
+ import type { AllowedElement, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
5
+ import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
6
+ import type { Tx, TxValidationResult } from '@aztec/stdlib/tx';
7
+ export interface MessageValidator {
8
+ validator: {
9
+ validateTx(tx: Tx): Promise<TxValidationResult>;
10
+ };
11
+ severity: PeerErrorSeverity;
12
+ }
13
+ export declare function createTxMessageValidators(blockNumber: number, worldStateSynchronizer: WorldStateSynchronizer, gasFees: GasFees, l1ChainId: number, rollupVersion: number, protocolContractTreeRoot: Fr, contractDataSource: ContractDataSource, proofVerifier: ClientProtocolCircuitVerifier, allowedInSetup?: AllowedElement[]): Record<string, MessageValidator>[];
14
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAW/D,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE;QACT,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;KACjD,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,wBAAwB,EAAE,EAAE,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,6BAA6B,EAC5C,cAAc,GAAE,cAAc,EAAO,GACpC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAqDpC"}