@aztec/p2p 0.86.0 → 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 (159) hide show
  1. package/dest/bootstrap/bootstrap.d.ts.map +1 -1
  2. package/dest/client/factory.d.ts +4 -1
  3. package/dest/client/factory.d.ts.map +1 -1
  4. package/dest/client/factory.js +16 -14
  5. package/dest/client/index.d.ts +1 -0
  6. package/dest/client/index.d.ts.map +1 -1
  7. package/dest/client/index.js +1 -0
  8. package/dest/client/interface.d.ts +155 -0
  9. package/dest/client/interface.d.ts.map +1 -0
  10. package/dest/client/interface.js +9 -0
  11. package/dest/client/p2p_client.d.ts +26 -164
  12. package/dest/client/p2p_client.d.ts.map +1 -1
  13. package/dest/client/p2p_client.js +185 -114
  14. package/dest/config.d.ts +5 -6
  15. package/dest/config.d.ts.map +1 -1
  16. package/dest/config.js +6 -11
  17. package/dest/enr/generate-enr.d.ts +9 -1
  18. package/dest/enr/generate-enr.d.ts.map +1 -1
  19. package/dest/enr/generate-enr.js +24 -2
  20. package/dest/index.d.ts +1 -0
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +1 -0
  23. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +2 -0
  24. package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
  25. package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +4 -4
  26. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts +1 -0
  27. package/dest/mem_pools/attestation_pool/kv_attestation_pool.d.ts.map +1 -1
  28. package/dest/mem_pools/attestation_pool/kv_attestation_pool.js +8 -2
  29. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts +1 -0
  30. package/dest/mem_pools/attestation_pool/memory_attestation_pool.d.ts.map +1 -1
  31. package/dest/mem_pools/attestation_pool/memory_attestation_pool.js +5 -2
  32. package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
  33. package/dest/mem_pools/attestation_pool/mocks.js +2 -2
  34. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts +4 -0
  35. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.d.ts.map +1 -1
  36. package/dest/mem_pools/tx_pool/aztec_kv_tx_pool.js +50 -14
  37. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts +3 -0
  38. package/dest/mem_pools/tx_pool/memory_tx_pool.d.ts.map +1 -1
  39. package/dest/mem_pools/tx_pool/memory_tx_pool.js +9 -0
  40. package/dest/mem_pools/tx_pool/tx_pool.d.ts +9 -0
  41. package/dest/mem_pools/tx_pool/tx_pool.d.ts.map +1 -1
  42. package/dest/mem_pools/tx_pool/tx_pool_test_suite.d.ts.map +1 -1
  43. package/dest/mem_pools/tx_pool/tx_pool_test_suite.js +13 -5
  44. package/dest/msg_validators/attestation_validator/attestation_validator.js +1 -1
  45. package/dest/msg_validators/block_proposal_validator/block_proposal_validator.js +1 -1
  46. package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
  47. package/dest/msg_validators/tx_validator/data_validator.d.ts.map +1 -1
  48. package/dest/msg_validators/tx_validator/data_validator.js +15 -14
  49. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +0 -2
  50. package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
  51. package/dest/msg_validators/tx_validator/double_spend_validator.js +2 -2
  52. package/dest/msg_validators/tx_validator/factory.d.ts +14 -0
  53. package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -0
  54. package/dest/msg_validators/tx_validator/factory.js +62 -0
  55. package/dest/msg_validators/tx_validator/gas_validator.js +3 -3
  56. package/dest/msg_validators/tx_validator/metadata_validator.d.ts +8 -4
  57. package/dest/msg_validators/tx_validator/metadata_validator.d.ts.map +1 -1
  58. package/dest/msg_validators/tx_validator/metadata_validator.js +35 -17
  59. package/dest/msg_validators/tx_validator/phases_validator.d.ts.map +1 -1
  60. package/dest/msg_validators/tx_validator/phases_validator.js +1 -1
  61. package/dest/msg_validators/tx_validator/tx_proof_validator.js +1 -1
  62. package/dest/services/discv5/discV5_service.d.ts +2 -2
  63. package/dest/services/discv5/discV5_service.d.ts.map +1 -1
  64. package/dest/services/discv5/discV5_service.js +9 -13
  65. package/dest/services/dummy_service.d.ts +3 -3
  66. package/dest/services/dummy_service.d.ts.map +1 -1
  67. package/dest/services/dummy_service.js +6 -1
  68. package/dest/services/encoding.d.ts +1 -3
  69. package/dest/services/encoding.d.ts.map +1 -1
  70. package/dest/services/libp2p/libp2p_service.d.ts +4 -2
  71. package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
  72. package/dest/services/libp2p/libp2p_service.js +94 -88
  73. package/dest/services/peer-manager/metrics.d.ts.map +1 -1
  74. package/dest/services/peer-manager/peer_manager.d.ts +1 -1
  75. package/dest/services/peer-manager/peer_manager.d.ts.map +1 -1
  76. package/dest/services/peer-manager/peer_manager.js +11 -2
  77. package/dest/services/reqresp/connection-sampler/batch_connection_sampler.d.ts.map +1 -1
  78. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts +2 -2
  79. package/dest/services/reqresp/connection-sampler/connection_sampler.d.ts.map +1 -1
  80. package/dest/services/reqresp/connection-sampler/connection_sampler.js +41 -21
  81. package/dest/services/reqresp/interface.d.ts +1 -3
  82. package/dest/services/reqresp/interface.d.ts.map +1 -1
  83. package/dest/services/reqresp/metrics.d.ts.map +1 -1
  84. package/dest/services/reqresp/protocols/goodbye.d.ts +0 -2
  85. package/dest/services/reqresp/protocols/goodbye.d.ts.map +1 -1
  86. package/dest/services/reqresp/protocols/goodbye.js +1 -1
  87. package/dest/services/reqresp/protocols/ping.d.ts +0 -2
  88. package/dest/services/reqresp/protocols/ping.d.ts.map +1 -1
  89. package/dest/services/reqresp/protocols/status.d.ts +0 -2
  90. package/dest/services/reqresp/protocols/status.d.ts.map +1 -1
  91. package/dest/services/reqresp/rate-limiter/rate_limiter.d.ts.map +1 -1
  92. package/dest/services/reqresp/reqresp.d.ts +1 -3
  93. package/dest/services/reqresp/reqresp.d.ts.map +1 -1
  94. package/dest/services/reqresp/reqresp.js +13 -10
  95. package/dest/services/service.d.ts +4 -3
  96. package/dest/services/service.d.ts.map +1 -1
  97. package/dest/test-helpers/get-ports.d.ts.map +1 -1
  98. package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
  99. package/dest/test-helpers/make-test-p2p-clients.js +2 -2
  100. package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
  101. package/dest/test-helpers/reqresp-nodes.js +1 -1
  102. package/dest/testbench/p2p_client_testbench_worker.js +11 -6
  103. package/dest/testbench/testbench.js +1 -1
  104. package/dest/testbench/worker_client_manager.d.ts +0 -1
  105. package/dest/testbench/worker_client_manager.d.ts.map +1 -1
  106. package/dest/testbench/worker_client_manager.js +2 -2
  107. package/dest/types/index.d.ts +1 -0
  108. package/dest/types/index.d.ts.map +1 -1
  109. package/dest/types/index.js +1 -0
  110. package/dest/versioning.d.ts +2 -2
  111. package/dest/versioning.d.ts.map +1 -1
  112. package/dest/versioning.js +6 -1
  113. package/package.json +15 -15
  114. package/src/bootstrap/bootstrap.ts +1 -1
  115. package/src/client/factory.ts +38 -33
  116. package/src/client/index.ts +1 -0
  117. package/src/client/interface.ts +186 -0
  118. package/src/client/p2p_client.ts +226 -287
  119. package/src/config.ts +11 -18
  120. package/src/enr/generate-enr.ts +35 -3
  121. package/src/index.ts +1 -0
  122. package/src/mem_pools/attestation_pool/attestation_pool.ts +3 -0
  123. package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +4 -4
  124. package/src/mem_pools/attestation_pool/kv_attestation_pool.ts +11 -4
  125. package/src/mem_pools/attestation_pool/memory_attestation_pool.ts +10 -3
  126. package/src/mem_pools/attestation_pool/mocks.ts +2 -2
  127. package/src/mem_pools/tx_pool/aztec_kv_tx_pool.ts +79 -34
  128. package/src/mem_pools/tx_pool/memory_tx_pool.ts +16 -1
  129. package/src/mem_pools/tx_pool/tx_pool.ts +12 -0
  130. package/src/mem_pools/tx_pool/tx_pool_test_suite.ts +9 -3
  131. package/src/msg_validators/attestation_validator/attestation_validator.ts +1 -1
  132. package/src/msg_validators/block_proposal_validator/block_proposal_validator.ts +1 -1
  133. package/src/msg_validators/tx_validator/block_header_validator.ts +1 -1
  134. package/src/msg_validators/tx_validator/data_validator.ts +24 -18
  135. package/src/msg_validators/tx_validator/double_spend_validator.ts +2 -2
  136. package/src/msg_validators/tx_validator/factory.ts +94 -0
  137. package/src/msg_validators/tx_validator/gas_validator.ts +3 -3
  138. package/src/msg_validators/tx_validator/metadata_validator.ts +50 -14
  139. package/src/msg_validators/tx_validator/phases_validator.ts +6 -2
  140. package/src/msg_validators/tx_validator/tx_proof_validator.ts +1 -1
  141. package/src/services/discv5/discV5_service.ts +14 -12
  142. package/src/services/dummy_service.ts +8 -2
  143. package/src/services/libp2p/libp2p_service.ts +102 -111
  144. package/src/services/peer-manager/metrics.ts +4 -1
  145. package/src/services/peer-manager/peer_manager.ts +18 -1
  146. package/src/services/reqresp/connection-sampler/batch_connection_sampler.ts +5 -1
  147. package/src/services/reqresp/connection-sampler/connection_sampler.ts +42 -19
  148. package/src/services/reqresp/metrics.ts +4 -1
  149. package/src/services/reqresp/protocols/goodbye.ts +1 -1
  150. package/src/services/reqresp/rate-limiter/rate_limiter.ts +4 -1
  151. package/src/services/reqresp/reqresp.ts +12 -12
  152. package/src/services/service.ts +7 -1
  153. package/src/test-helpers/make-test-p2p-clients.ts +2 -1
  154. package/src/test-helpers/reqresp-nodes.ts +1 -1
  155. package/src/testbench/p2p_client_testbench_worker.ts +10 -4
  156. package/src/testbench/testbench.ts +1 -1
  157. package/src/testbench/worker_client_manager.ts +2 -2
  158. package/src/types/index.ts +1 -0
  159. package/src/versioning.ts +8 -1
@@ -1,9 +1,10 @@
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
+ export { ENR };
7
8
  export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcastPort, l1ChainId) {
8
9
  const peerId = await createLibP2PPeerIdFromPrivateKey(privateKey);
9
10
  const enr = SignableENR.createFromPeerId(peerId);
@@ -19,6 +20,25 @@ export async function createBootnodeENRandPeerId(privateKey, p2pIp, p2pBroadcast
19
20
  peerId
20
21
  };
21
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
+ }
22
42
  export async function printENR(enr, log) {
23
43
  const decoded = ENR.decodeTxt(enr);
24
44
  log(`PeerID: ${await decoded.peerId()}`);
@@ -27,4 +47,6 @@ export async function printENR(enr, log) {
27
47
  log(`TCP: ${decoded.tcp}`);
28
48
  const aztec = decoded.kvs.get(AZTEC_ENR_KEY);
29
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'}`);
30
52
  }
package/dest/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './bootstrap/bootstrap.js';
2
2
  export * from './client/index.js';
3
+ export * from './enr/index.js';
3
4
  export * from './config.js';
4
5
  export * from './mem_pools/attestation_pool/index.js';
5
6
  export * from './mem_pools/tx_pool/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC"}
package/dest/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './bootstrap/bootstrap.js';
2
2
  export * from './client/index.js';
3
+ export * from './enr/index.js';
3
4
  export * from './config.js';
4
5
  export * from './mem_pools/attestation_pool/index.js';
5
6
  export * from './mem_pools/tx_pool/index.js';
@@ -62,5 +62,7 @@ export interface AttestationPool {
62
62
  * @return BlockAttestations
63
63
  */
64
64
  getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
65
+ /** Returns whether the pool is empty. */
66
+ isEmpty(): Promise<boolean>;
65
67
  }
66
68
  //# sourceMappingURL=attestation_pool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/attestation_pool.ts"],"names":[],"mappings":"AAA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;;OAMG;IACH,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;;;;OAMG;IACH,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD;;;;;;;OAOG;IACH,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtF;;;;;;;OAOG;IACH,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAElE;;;;;;;;OAQG;IACH,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAEjG,yCAAyC;IACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7B"}
@@ -108,12 +108,12 @@ export function describeAttestationPool(getAttestationPool) {
108
108
  const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i]));
109
109
  await ap.addAttestations(attestations);
110
110
  for (const attestation of attestations){
111
- const slot = attestation.payload.header.globalVariables.slotNumber;
111
+ const slot = attestation.payload.header.slotNumber;
112
112
  const archive = attestation.archive.toString();
113
113
  const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot.toBigInt(), archive);
114
114
  expect(retreivedAttestations.length).toBe(1);
115
115
  expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
116
- expect(retreivedAttestations[0].payload.header.globalVariables.slotNumber).toEqual(slot);
116
+ expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
117
117
  }
118
118
  });
119
119
  it('should store attestations by differing slot and archive', async ()=>{
@@ -132,12 +132,12 @@ export function describeAttestationPool(getAttestationPool) {
132
132
  const attestations = signers.map((signer, i)=>mockAttestation(signer, slotNumbers[i], archives[i]));
133
133
  await ap.addAttestations(attestations);
134
134
  for (const attestation of attestations){
135
- const slot = attestation.payload.header.globalVariables.slotNumber;
135
+ const slot = attestation.payload.header.slotNumber;
136
136
  const proposalId = attestation.archive.toString();
137
137
  const retreivedAttestations = await ap.getAttestationsForSlotAndProposal(slot.toBigInt(), proposalId);
138
138
  expect(retreivedAttestations.length).toBe(1);
139
139
  expect(retreivedAttestations[0].toBuffer()).toEqual(attestation.toBuffer());
140
- expect(retreivedAttestations[0].payload.header.globalVariables.slotNumber).toEqual(slot);
140
+ expect(retreivedAttestations[0].payload.header.slotNumber).toEqual(slot);
141
141
  }
142
142
  });
143
143
  it('should delete attestations', async ()=>{
@@ -10,6 +10,7 @@ export declare class KvAttestationPool implements AttestationPool {
10
10
  private proposalsForSlot;
11
11
  private attestationsForProposal;
12
12
  constructor(store: AztecAsyncKVStore, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
13
+ isEmpty(): Promise<boolean>;
13
14
  private getProposalKey;
14
15
  private getAttestationKey;
15
16
  addAttestations(attestations: BlockAttestation[]): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"kv_attestation_pool.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/kv_attestation_pool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAGnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,eAAe;IAQrD,OAAO,CAAC,KAAK;IAEb,OAAO,CAAC,GAAG;IATb,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,uBAAuB,CAAqC;gBAG1D,KAAK,EAA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CAAqC;gBAG1D,KAAK,EAAE,iBAAiB,EAChC,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAyC;IASzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAOxC,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,iBAAiB;IAIZ,eAAe,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BhE,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYjE,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAsBhG,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBtD,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrF,kBAAkB,CAAC,YAAY,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBjF"}
@@ -19,6 +19,12 @@ export class KvAttestationPool {
19
19
  this.attestationsForProposal = store.openMultiMap('attestations_for_proposal');
20
20
  this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
21
21
  }
22
+ async isEmpty() {
23
+ for await (const _ of this.attestations.entriesAsync()){
24
+ return false;
25
+ }
26
+ return true;
27
+ }
22
28
  getProposalKey(slot, proposalId) {
23
29
  const slotStr = typeof slot === 'string' ? slot : new Fr(slot).toString();
24
30
  const proposalIdStr = typeof proposalId === 'string' ? proposalId : Buffer.isBuffer(proposalId) ? Fr.fromBuffer(proposalId).toString() : proposalId.toString();
@@ -30,7 +36,7 @@ export class KvAttestationPool {
30
36
  async addAttestations(attestations) {
31
37
  await this.store.transactionAsync(async ()=>{
32
38
  for (const attestation of attestations){
33
- const slotNumber = attestation.payload.header.globalVariables.slotNumber;
39
+ const slotNumber = attestation.payload.header.slotNumber;
34
40
  const proposalId = attestation.archive;
35
41
  const address = attestation.getSender().toString();
36
42
  await this.attestations.set(this.getAttestationKey(slotNumber, proposalId, address), attestation.toBuffer());
@@ -113,7 +119,7 @@ export class KvAttestationPool {
113
119
  async deleteAttestations(attestations) {
114
120
  await this.store.transactionAsync(async ()=>{
115
121
  for (const attestation of attestations){
116
- const slotNumber = attestation.payload.header.globalVariables.slotNumber;
122
+ const slotNumber = attestation.payload.header.slotNumber;
117
123
  const proposalId = attestation.archive;
118
124
  const address = attestation.getSender().toString();
119
125
  await this.attestations.delete(this.getAttestationKey(slotNumber, proposalId, address));
@@ -7,6 +7,7 @@ export declare class InMemoryAttestationPool implements AttestationPool {
7
7
  private metrics;
8
8
  private attestations;
9
9
  constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
10
+ isEmpty(): Promise<boolean>;
10
11
  getAttestationsForSlot(slot: bigint): Promise<BlockAttestation[]>;
11
12
  getAttestationsForSlotAndProposal(slot: bigint, proposalId: string): Promise<BlockAttestation[]>;
12
13
  addAttestations(attestations: BlockAttestation[]): Promise<void>;
@@ -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,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgG;gBAExG,SAAS,GAAE,eAAsC,EAAU,GAAG,yCAAu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C,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"}
@@ -10,6 +10,9 @@ export class InMemoryAttestationPool {
10
10
  this.attestations = new Map();
11
11
  this.metrics = new PoolInstrumentation(telemetry, PoolName.ATTESTATION_POOL);
12
12
  }
13
+ isEmpty() {
14
+ return Promise.resolve(this.attestations.size === 0);
15
+ }
13
16
  getAttestationsForSlot(slot) {
14
17
  return Promise.resolve(Array.from(this.attestations.get(slot)?.values() ?? []).flatMap((proposalAttestationMap)=>Array.from(proposalAttestationMap.values())));
15
18
  }
@@ -26,7 +29,7 @@ export class InMemoryAttestationPool {
26
29
  addAttestations(attestations) {
27
30
  for (const attestation of attestations){
28
31
  // Perf: order and group by slot before insertion
29
- const slotNumber = attestation.payload.header.globalVariables.slotNumber;
32
+ const slotNumber = attestation.payload.header.slotNumber;
30
33
  const proposalId = attestation.archive.toString();
31
34
  const address = attestation.getSender();
32
35
  const slotAttestationMap = getSlotOrDefault(this.attestations, slotNumber.toBigInt());
@@ -93,7 +96,7 @@ export class InMemoryAttestationPool {
93
96
  }
94
97
  deleteAttestations(attestations) {
95
98
  for (const attestation of attestations){
96
- const slotNumber = attestation.payload.header.globalVariables.slotNumber;
99
+ const slotNumber = attestation.payload.header.slotNumber;
97
100
  const slotAttestationMap = this.attestations.get(slotNumber.toBigInt());
98
101
  if (slotAttestationMap) {
99
102
  const proposalId = attestation.archive.toString();
@@ -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"}
@@ -26,8 +26,8 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
26
26
  ].map(()=>TxHash.random()))=>{
27
27
  // Use arbitrary numbers for all other than slot
28
28
  const header = makeHeader(1, 2, slot);
29
- const payload = new ConsensusPayload(header, archive, txs);
29
+ const payload = new ConsensusPayload(header.toPropose(), archive, header.state, txs);
30
30
  const hash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
31
31
  const signature = signer.sign(hash);
32
- return new BlockAttestation(payload, signature);
32
+ return new BlockAttestation(header.globalVariables.blockNumber, payload, signature);
33
33
  };
@@ -23,10 +23,12 @@ export declare class AztecKVTxPool implements TxPool {
23
23
  maxTxPoolSize?: number;
24
24
  archivedTxLimit?: number;
25
25
  }, log?: Logger);
26
+ isEmpty(): Promise<boolean>;
26
27
  markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
27
28
  markMinedAsPending(txHashes: TxHash[]): Promise<void>;
28
29
  getPendingTxHashes(): Promise<TxHash[]>;
29
30
  getMinedTxHashes(): Promise<[TxHash, number][]>;
31
+ getPendingTxCount(): Promise<number>;
30
32
  getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
31
33
  /**
32
34
  * Checks if a transaction exists in the pool and returns it.
@@ -65,6 +67,7 @@ export declare class AztecKVTxPool implements TxPool {
65
67
  */
66
68
  getAllTxHashes(): Promise<TxHash[]>;
67
69
  setMaxTxPoolSize(maxSizeBytes: number | undefined): Promise<void>;
70
+ markTxsAsNonEvictable(txHashes: TxHash[]): Promise<void>;
68
71
  /**
69
72
  * Creates a GasTxValidator instance.
70
73
  * @param db - DB for the validator to use
@@ -119,5 +122,6 @@ export declare class AztecKVTxPool implements TxPool {
119
122
  private evictInvalidTxsAfterReorg;
120
123
  private addPendingTxIndices;
121
124
  private removePendingTxIndices;
125
+ private increasePendingTxCount;
122
126
  }
123
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"],"names":[],"mappings":"AAEA,OAAO,EAAE,K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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;
@@ -55,14 +59,20 @@ import { getPendingTxPriority } from './priority.js';
55
59
  this.#log = log;
56
60
  this.#metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL, ()=>store.estimateSize());
57
61
  }
58
- markAsMined(txHashes, blockNumber) {
62
+ async isEmpty() {
63
+ for await (const _ of this.#txs.entriesAsync()){
64
+ return false;
65
+ }
66
+ return true;
67
+ }
68
+ async markAsMined(txHashes, blockNumber) {
59
69
  if (txHashes.length === 0) {
60
70
  return Promise.resolve();
61
71
  }
62
72
  let deletedPending = 0;
63
73
  const minedNullifiers = new Set();
64
74
  const minedFeePayers = new Set();
65
- return this.#store.transactionAsync(async ()=>{
75
+ await this.#store.transactionAsync(async ()=>{
66
76
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
67
77
  for (const hash of txHashes){
68
78
  const key = hash.toString();
@@ -79,16 +89,21 @@ import { getPendingTxPriority } from './priority.js';
79
89
  }
80
90
  this.#metrics.recordAddedObjects(txHashes.length, 'mined');
81
91
  await this.#pendingTxSize.set(pendingTxSize);
92
+ await this.increasePendingTxCount(-deletedPending);
82
93
  const numTxsEvicted = await this.evictInvalidTxsAfterMining(txHashes, blockNumber, minedNullifiers, minedFeePayers);
83
94
  this.#metrics.recordRemovedObjects(deletedPending + numTxsEvicted, 'pending');
84
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();
85
100
  }
86
- markMinedAsPending(txHashes) {
101
+ async markMinedAsPending(txHashes) {
87
102
  if (txHashes.length === 0) {
88
103
  return Promise.resolve();
89
104
  }
90
105
  let markedAsPending = 0;
91
- return this.#store.transactionAsync(async ()=>{
106
+ await this.#store.transactionAsync(async ()=>{
92
107
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
93
108
  for (const hash of txHashes){
94
109
  const key = hash.toString();
@@ -102,13 +117,13 @@ import { getPendingTxPriority } from './priority.js';
102
117
  }
103
118
  }
104
119
  await this.#pendingTxSize.set(pendingTxSize);
105
- }).then(async ()=>{
106
- const numInvalidTxsEvicted = await this.evictInvalidTxsAfterReorg(txHashes);
107
- const { numLowPriorityTxsEvicted, numNewTxsEvicted } = await this.evictLowPriorityTxs(txHashes);
108
- this.#metrics.recordAddedObjects(markedAsPending - numNewTxsEvicted, 'pending');
109
- this.#metrics.recordRemovedObjects(numInvalidTxsEvicted + numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
110
- this.#metrics.recordRemovedObjects(markedAsPending, 'mined');
111
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');
112
127
  }
113
128
  async getPendingTxHashes() {
114
129
  const vals = await toArray(this.#pendingTxPriorityToHash.valuesAsync({
@@ -123,6 +138,9 @@ import { getPendingTxPriority } from './priority.js';
123
138
  blockNumber
124
139
  ]);
125
140
  }
141
+ async getPendingTxCount() {
142
+ return await this.#pendingTxCount.getAsync() ?? 0;
143
+ }
126
144
  async getTxStatus(txHash) {
127
145
  const key = txHash.toString();
128
146
  const [isMined, isKnown] = await Promise.all([
@@ -187,26 +205,31 @@ import { getPendingTxPriority } from './priority.js';
187
205
  txStats: await tx.getStats()
188
206
  })));
189
207
  await this.#store.transactionAsync(async ()=>{
190
- let pendingCount = 0;
208
+ let addedCount = 0;
191
209
  let pendingTxSize = await this.#pendingTxSize.getAsync() ?? 0;
192
210
  await Promise.all(txs.map(async (tx, i)=>{
193
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
+ }
194
217
  this.#log.verbose(`Adding tx ${txHash.toString()} to pool`, {
195
218
  eventName: 'tx-added-to-pool',
196
219
  ...txStats
197
220
  });
198
- const key = txHash.toString();
199
221
  await this.#txs.set(key, tx.toBuffer());
200
222
  if (!await this.#minedTxHashToBlock.hasAsync(key)) {
201
- pendingCount++;
223
+ addedCount++;
202
224
  pendingTxSize += tx.getSize();
203
225
  await this.addPendingTxIndices(tx, key);
204
226
  this.#metrics.recordSize(tx);
205
227
  }
206
228
  }));
229
+ await this.increasePendingTxCount(addedCount);
207
230
  await this.#pendingTxSize.set(pendingTxSize);
208
231
  const { numLowPriorityTxsEvicted, numNewTxsEvicted } = await this.evictLowPriorityTxs(hashesAndStats.map(({ txHash })=>txHash));
209
- this.#metrics.recordAddedObjects(pendingCount - numNewTxsEvicted, 'pending');
232
+ this.#metrics.recordAddedObjects(addedCount - numNewTxsEvicted, 'pending');
210
233
  this.#metrics.recordRemovedObjects(numLowPriorityTxsEvicted - numNewTxsEvicted, 'pending');
211
234
  });
212
235
  }
@@ -240,6 +263,7 @@ import { getPendingTxPriority } from './priority.js';
240
263
  }
241
264
  }
242
265
  await this.#pendingTxSize.set(pendingTxSize);
266
+ await this.increasePendingTxCount(-pendingDeleted);
243
267
  this.#metrics.recordRemovedObjects(pendingDeleted, 'pending');
244
268
  this.#metrics.recordRemovedObjects(minedDeleted, 'mined');
245
269
  });
@@ -267,6 +291,10 @@ import { getPendingTxPriority } from './priority.js';
267
291
  this.#maxTxPoolSize = maxSizeBytes;
268
292
  return Promise.resolve();
269
293
  }
294
+ markTxsAsNonEvictable(txHashes) {
295
+ txHashes.forEach((txHash)=>this.#nonEvictableTxs.add(txHash.toString()));
296
+ return Promise.resolve();
297
+ }
270
298
  /**
271
299
  * Creates a GasTxValidator instance.
272
300
  * @param db - DB for the validator to use
@@ -355,6 +383,9 @@ import { getPendingTxPriority } from './priority.js';
355
383
  let pendingTxsSize = await this.#pendingTxSize.getAsync() ?? 0;
356
384
  if (pendingTxsSize > this.#maxTxPoolSize) {
357
385
  for await (const txHash of this.#pendingTxPriorityToHash.valuesAsync()){
386
+ if (this.#nonEvictableTxs.has(txHash.toString())) {
387
+ continue;
388
+ }
358
389
  this.#log.verbose(`Evicting tx ${txHash} from pool due to low priority to satisfy max tx size limit`);
359
390
  txsToEvict.push(TxHash.fromString(txHash));
360
391
  const txSize = await this.#pendingTxHashToSize.getAsync(txHash.toString()) ?? (await this.getPendingTxByHash(txHash))?.getSize();
@@ -473,4 +504,9 @@ import { getPendingTxPriority } from './priority.js';
473
504
  await this.#pendingTxHashToHeaderHash.delete(txHash);
474
505
  this.#pendingTxs.delete(txHash);
475
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
+ }
476
512
  }
@@ -18,10 +18,12 @@ export declare class InMemoryTxPool implements TxPool {
18
18
  * @param log - A logger.
19
19
  */
20
20
  constructor(telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
21
+ isEmpty(): Promise<boolean>;
21
22
  markAsMined(txHashes: TxHash[], blockNumber: number): Promise<void>;
22
23
  markMinedAsPending(txHashes: TxHash[]): Promise<void>;
23
24
  getPendingTxHashes(): Promise<TxHash[]>;
24
25
  getMinedTxHashes(): Promise<[TxHash, number][]>;
26
+ getPendingTxCount(): Promise<number>;
25
27
  getTxStatus(txHash: TxHash): Promise<'pending' | 'mined' | undefined>;
26
28
  /**
27
29
  * Checks if a transaction exists in the pool and returns it.
@@ -55,5 +57,6 @@ export declare class InMemoryTxPool implements TxPool {
55
57
  */
56
58
  getAllTxHashes(): Promise<TxHash[]>;
57
59
  setMaxTxPoolSize(_maxSizeBytes: number | undefined): Promise<void>;
60
+ markTxsAsNonEvictable(_: TxHash[]): Promise<void>;
58
61
  }
59
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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E;;;;OAIG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC;IAK3D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,GAAG,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"}
@@ -23,6 +23,9 @@ import { getPendingTxPriority } from './priority.js';
23
23
  this.pendingTxs = new Set();
24
24
  this.metrics = new PoolInstrumentation(telemetry, PoolName.TX_POOL);
25
25
  }
26
+ isEmpty() {
27
+ return Promise.resolve(this.txs.size === 0);
28
+ }
26
29
  markAsMined(txHashes, blockNumber) {
27
30
  const keys = txHashes.map((x)=>x.toBigInt());
28
31
  for (const key of keys){
@@ -65,6 +68,9 @@ import { getPendingTxPriority } from './priority.js';
65
68
  blockNumber
66
69
  ]));
67
70
  }
71
+ getPendingTxCount() {
72
+ return Promise.resolve(this.pendingTxs.size);
73
+ }
68
74
  getTxStatus(txHash) {
69
75
  const key = txHash.toBigInt();
70
76
  if (this.pendingTxs.has(key)) {
@@ -147,4 +153,7 @@ import { getPendingTxPriority } from './priority.js';
147
153
  setMaxTxPoolSize(_maxSizeBytes) {
148
154
  return Promise.resolve();
149
155
  }
156
+ markTxsAsNonEvictable(_) {
157
+ return Promise.resolve();
158
+ }
150
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.
@@ -79,5 +81,12 @@ export interface TxPool {
79
81
  * @param maxSizeBytes - The maximum size in bytes of the mempool. Set to undefined to disable it
80
82
  */
81
83
  setMaxTxPoolSize(maxSizeBytes: number | undefined): Promise<void>;
84
+ /** Returns whether the pool is empty. */
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>;
82
91
  }
83
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,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AAgB,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAEjE;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAEtE;;;OAGG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElE,yCAAyC;IACzC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE5B;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,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);
@@ -6,7 +6,7 @@ export class AttestationValidator {
6
6
  }
7
7
  async validate(message) {
8
8
  const { currentSlot, nextSlot } = await this.epochCache.getProposerInCurrentOrNextSlot();
9
- const slotNumberBigInt = message.payload.header.globalVariables.slotNumber.toBigInt();
9
+ const slotNumberBigInt = message.payload.header.slotNumber.toBigInt();
10
10
  if (slotNumberBigInt !== currentSlot && slotNumberBigInt !== nextSlot) {
11
11
  return PeerErrorSeverity.HighToleranceError;
12
12
  }
@@ -10,7 +10,7 @@ export class BlockProposalValidator {
10
10
  async validate(block) {
11
11
  const { currentProposer, nextProposer, currentSlot, nextSlot } = await this.epochCache.getProposerInCurrentOrNextSlot();
12
12
  // Check that the attestation is for the current or next slot
13
- const slotNumberBigInt = block.payload.header.globalVariables.slotNumber.toBigInt();
13
+ const slotNumberBigInt = block.payload.header.slotNumber.toBigInt();
14
14
  if (slotNumberBigInt !== currentSlot && slotNumberBigInt !== nextSlot) {
15
15
  this.logger.debug(`Penalizing peer for invalid slot number ${slotNumberBigInt}, current slot: ${currentSlot}, next slot: ${nextSlot}`);
16
16
  return PeerErrorSeverity.HighToleranceError;