@aztec/p2p 0.0.1-commit.87a0206 → 0.0.1-commit.8f9871590
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client/factory.d.ts +3 -3
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +42 -8
- package/dest/client/interface.d.ts +30 -15
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +33 -35
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +107 -137
- package/dest/config.d.ts +22 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +16 -1
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts +21 -12
- package/dest/mem_pools/attestation_pool/attestation_pool.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool.js +67 -37
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/attestation_pool_test_suite.js +53 -53
- package/dest/mem_pools/attestation_pool/index.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/index.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/index.js +1 -1
- package/dest/mem_pools/attestation_pool/mocks.d.ts +2 -2
- package/dest/mem_pools/attestation_pool/mocks.d.ts.map +1 -1
- package/dest/mem_pools/attestation_pool/mocks.js +2 -2
- package/dest/mem_pools/index.d.ts +2 -1
- package/dest/mem_pools/index.d.ts.map +1 -1
- package/dest/mem_pools/interface.d.ts +3 -3
- package/dest/mem_pools/interface.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +102 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +242 -0
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +5 -3
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +3 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.js +3 -1
- package/dest/mem_pools/tx_pool_v2/index.d.ts +2 -1
- package/dest/mem_pools/tx_pool_v2/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/index.js +1 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +7 -3
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +2 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +28 -4
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.js +37 -4
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +8 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.js +15 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +4 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.js +6 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +4 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.js +110 -78
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +3 -3
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts +16 -3
- package/dest/msg_validators/tx_validator/block_header_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/block_header_validator.js +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts +13 -3
- package/dest/msg_validators/tx_validator/double_spend_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/double_spend_validator.js +4 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts +20 -4
- package/dest/msg_validators/tx_validator/timestamp_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/timestamp_validator.js +6 -6
- package/dest/services/dummy_service.d.ts +6 -2
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +3 -0
- package/dest/services/encoding.d.ts +2 -2
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +2 -2
- package/dest/services/gossipsub/index.d.ts +3 -0
- package/dest/services/gossipsub/index.d.ts.map +1 -0
- package/dest/services/gossipsub/index.js +2 -0
- package/dest/services/gossipsub/scoring.d.ts +21 -3
- package/dest/services/gossipsub/scoring.d.ts.map +1 -1
- package/dest/services/gossipsub/scoring.js +24 -7
- package/dest/services/gossipsub/topic_score_params.d.ts +161 -0
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -0
- package/dest/services/gossipsub/topic_score_params.js +324 -0
- package/dest/services/libp2p/libp2p_service.d.ts +11 -3
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +91 -67
- package/dest/services/peer-manager/peer_scoring.d.ts +1 -1
- package/dest/services/peer-manager/peer_scoring.d.ts.map +1 -1
- package/dest/services/peer-manager/peer_scoring.js +25 -2
- package/dest/services/reqresp/interface.d.ts +10 -1
- package/dest/services/reqresp/interface.d.ts.map +1 -1
- package/dest/services/reqresp/interface.js +15 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts +3 -3
- package/dest/services/reqresp/protocols/block_txs/block_txs_handler.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts +7 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/block_txs/block_txs_reqresp.js +15 -0
- package/dest/services/reqresp/protocols/tx.d.ts +7 -1
- package/dest/services/reqresp/protocols/tx.d.ts.map +1 -1
- package/dest/services/reqresp/protocols/tx.js +20 -0
- package/dest/services/reqresp/reqresp.d.ts +1 -1
- package/dest/services/reqresp/reqresp.d.ts.map +1 -1
- package/dest/services/reqresp/reqresp.js +11 -4
- package/dest/services/service.d.ts +18 -1
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/config.d.ts +19 -1
- package/dest/services/tx_collection/config.d.ts.map +1 -1
- package/dest/services/tx_collection/config.js +46 -0
- package/dest/services/tx_collection/fast_tx_collection.d.ts +3 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +17 -3
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +53 -0
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_collection.js +165 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts +28 -0
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -0
- package/dest/services/tx_collection/file_store_tx_source.js +59 -0
- package/dest/services/tx_collection/index.d.ts +2 -1
- package/dest/services/tx_collection/index.d.ts.map +1 -1
- package/dest/services/tx_collection/index.js +1 -0
- package/dest/services/tx_collection/slow_tx_collection.d.ts +6 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +55 -23
- package/dest/services/tx_collection/tx_collection.d.ts +19 -7
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection.js +75 -3
- package/dest/services/tx_collection/tx_collection_sink.d.ts +15 -6
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -7
- package/dest/services/tx_file_store/config.d.ts +1 -3
- package/dest/services/tx_file_store/config.d.ts.map +1 -1
- package/dest/services/tx_file_store/config.js +0 -4
- package/dest/services/tx_file_store/tx_file_store.d.ts +4 -3
- package/dest/services/tx_file_store/tx_file_store.d.ts.map +1 -1
- package/dest/services/tx_file_store/tx_file_store.js +8 -5
- package/dest/services/tx_provider.d.ts +3 -3
- package/dest/services/tx_provider.d.ts.map +1 -1
- package/dest/services/tx_provider.js +5 -4
- package/dest/test-helpers/make-test-p2p-clients.d.ts +3 -3
- package/dest/test-helpers/make-test-p2p-clients.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.d.ts +27 -1
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +97 -2
- package/dest/test-helpers/reqresp-nodes.d.ts +1 -1
- package/dest/test-helpers/reqresp-nodes.d.ts.map +1 -1
- package/dest/test-helpers/reqresp-nodes.js +2 -1
- package/dest/test-helpers/testbench-utils.d.ts +32 -24
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +103 -36
- package/dest/testbench/p2p_client_testbench_worker.js +3 -3
- package/package.json +14 -14
- package/src/client/factory.ts +78 -9
- package/src/client/interface.ts +32 -13
- package/src/client/p2p_client.ts +135 -157
- package/src/config.ts +34 -2
- package/src/index.ts +1 -0
- package/src/mem_pools/attestation_pool/attestation_pool.ts +95 -44
- package/src/mem_pools/attestation_pool/attestation_pool_test_suite.ts +57 -53
- package/src/mem_pools/attestation_pool/index.ts +3 -3
- package/src/mem_pools/attestation_pool/mocks.ts +2 -1
- package/src/mem_pools/index.ts +3 -0
- package/src/mem_pools/interface.ts +2 -2
- package/src/mem_pools/tx_pool/README.md +1 -1
- package/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/README.md +76 -10
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +310 -0
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +3 -0
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +1 -1
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +3 -1
- package/src/mem_pools/tx_pool_v2/index.ts +1 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +8 -2
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +57 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +18 -2
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +7 -1
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +122 -80
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +2 -2
- package/src/msg_validators/tx_validator/block_header_validator.ts +15 -3
- package/src/msg_validators/tx_validator/double_spend_validator.ts +11 -6
- package/src/msg_validators/tx_validator/timestamp_validator.ts +23 -18
- package/src/services/dummy_service.ts +6 -0
- package/src/services/encoding.ts +2 -2
- package/src/services/gossipsub/README.md +626 -0
- package/src/services/gossipsub/index.ts +2 -0
- package/src/services/gossipsub/scoring.ts +29 -5
- package/src/services/gossipsub/topic_score_params.ts +451 -0
- package/src/services/libp2p/libp2p_service.ts +91 -70
- package/src/services/peer-manager/peer_scoring.ts +25 -0
- package/src/services/reqresp/interface.ts +26 -1
- package/src/services/reqresp/protocols/block_txs/block_txs_handler.ts +2 -2
- package/src/services/reqresp/protocols/block_txs/block_txs_reqresp.ts +17 -0
- package/src/services/reqresp/protocols/tx.ts +22 -0
- package/src/services/reqresp/reqresp.ts +13 -3
- package/src/services/service.ts +20 -0
- package/src/services/tx_collection/config.ts +68 -0
- package/src/services/tx_collection/fast_tx_collection.ts +14 -2
- package/src/services/tx_collection/file_store_tx_collection.ts +198 -0
- package/src/services/tx_collection/file_store_tx_source.ts +73 -0
- package/src/services/tx_collection/index.ts +1 -0
- package/src/services/tx_collection/slow_tx_collection.ts +64 -30
- package/src/services/tx_collection/tx_collection.ts +109 -13
- package/src/services/tx_collection/tx_collection_sink.ts +17 -7
- package/src/services/tx_file_store/config.ts +0 -6
- package/src/services/tx_file_store/tx_file_store.ts +9 -7
- package/src/services/tx_provider.ts +8 -7
- package/src/test-helpers/make-test-p2p-clients.ts +3 -3
- package/src/test-helpers/mock-pubsub.ts +133 -3
- package/src/test-helpers/reqresp-nodes.ts +2 -1
- package/src/test-helpers/testbench-utils.ts +117 -40
- package/src/testbench/p2p_client_testbench_worker.ts +3 -3
|
@@ -3,7 +3,7 @@ import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
5
5
|
import { makeBlockHeader, makeBlockProposal, makeCheckpointHeader, makeCheckpointProposal } from '@aztec/stdlib/testing';
|
|
6
|
-
import {
|
|
6
|
+
import { MAX_BLOCK_PROPOSALS_PER_POSITION, MAX_CHECKPOINT_PROPOSALS_PER_SLOT } from './attestation_pool.js';
|
|
7
7
|
import { mockCheckpointAttestation } from './mocks.js';
|
|
8
8
|
const NUMBER_OF_SIGNERS_PER_TEST = 4;
|
|
9
9
|
export function describeAttestationPool(getAttestationPool) {
|
|
@@ -167,7 +167,7 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
167
167
|
const result = await ap.tryAddBlockProposal(proposal);
|
|
168
168
|
expect(result.added).toBe(true);
|
|
169
169
|
expect(result.alreadyExists).toBe(false);
|
|
170
|
-
expect(result.
|
|
170
|
+
expect(result.count).toBe(1);
|
|
171
171
|
const retrievedProposal = await ap.getBlockProposal(proposalId);
|
|
172
172
|
expect(retrievedProposal).toBeDefined();
|
|
173
173
|
expect(retrievedProposal).toEqual(proposal);
|
|
@@ -222,7 +222,7 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
222
222
|
const result = await ap.tryAddCheckpointProposal(proposal);
|
|
223
223
|
expect(result.added).toBe(true);
|
|
224
224
|
expect(result.alreadyExists).toBe(false);
|
|
225
|
-
expect(result.
|
|
225
|
+
expect(result.count).toBe(1);
|
|
226
226
|
const retrievedProposal = await ap.getCheckpointProposal(proposalId);
|
|
227
227
|
expect(retrievedProposal).toBeDefined();
|
|
228
228
|
expect(retrievedProposal.toBuffer()).toEqual(proposal.toBuffer());
|
|
@@ -275,19 +275,19 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
275
275
|
});
|
|
276
276
|
it('should return added=false when exceeding capacity', async ()=>{
|
|
277
277
|
const slotNumber = 420;
|
|
278
|
-
// Add
|
|
279
|
-
for(let i = 0; i <
|
|
278
|
+
// Add MAX_CHECKPOINT_PROPOSALS_PER_SLOT proposals
|
|
279
|
+
for(let i = 0; i < MAX_CHECKPOINT_PROPOSALS_PER_SLOT; i++){
|
|
280
280
|
const proposal = await mockCheckpointProposalForPool(signers[i % NUMBER_OF_SIGNERS_PER_TEST], slotNumber);
|
|
281
281
|
const result = await ap.tryAddCheckpointProposal(proposal);
|
|
282
282
|
expect(result.added).toBe(true);
|
|
283
|
-
expect(result.
|
|
283
|
+
expect(result.count).toBe(i + 1);
|
|
284
284
|
}
|
|
285
285
|
// The next proposal should not be added
|
|
286
286
|
const extraProposal = await mockCheckpointProposalForPool(signers[0], slotNumber);
|
|
287
287
|
const result = await ap.tryAddCheckpointProposal(extraProposal);
|
|
288
288
|
expect(result.added).toBe(false);
|
|
289
289
|
expect(result.alreadyExists).toBe(false);
|
|
290
|
-
expect(result.
|
|
290
|
+
expect(result.count).toBe(MAX_CHECKPOINT_PROPOSALS_PER_SLOT);
|
|
291
291
|
});
|
|
292
292
|
});
|
|
293
293
|
describe('Duplicate proposal detection', ()=>{
|
|
@@ -303,12 +303,12 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
303
303
|
});
|
|
304
304
|
};
|
|
305
305
|
describe('tryAddBlockProposal duplicate detection', ()=>{
|
|
306
|
-
it('should return
|
|
306
|
+
it('should return count=1 when pool is empty', async ()=>{
|
|
307
307
|
const proposal = await mockBlockProposalWithIndex(signers[0], 100, 0);
|
|
308
308
|
const result = await ap.tryAddBlockProposal(proposal);
|
|
309
309
|
expect(result.added).toBe(true);
|
|
310
310
|
expect(result.alreadyExists).toBe(false);
|
|
311
|
-
expect(result.
|
|
311
|
+
expect(result.count).toBe(1);
|
|
312
312
|
});
|
|
313
313
|
it('should return alreadyExists when same proposal exists', async ()=>{
|
|
314
314
|
const proposal = await mockBlockProposalWithIndex(signers[0], 100, 0);
|
|
@@ -316,22 +316,22 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
316
316
|
const result = await ap.tryAddBlockProposal(proposal);
|
|
317
317
|
expect(result.added).toBe(false);
|
|
318
318
|
expect(result.alreadyExists).toBe(true);
|
|
319
|
-
expect(result.
|
|
319
|
+
expect(result.count).toBe(1);
|
|
320
320
|
});
|
|
321
|
-
it('should detect duplicate via
|
|
321
|
+
it('should detect duplicate via count when different proposal exists at same position', async ()=>{
|
|
322
322
|
const slotNumber = 100;
|
|
323
323
|
const indexWithinCheckpoint = 2;
|
|
324
324
|
// Add first proposal
|
|
325
325
|
const proposal1 = await mockBlockProposalWithIndex(signers[0], slotNumber, indexWithinCheckpoint);
|
|
326
326
|
const result1 = await ap.tryAddBlockProposal(proposal1);
|
|
327
|
-
expect(result1.
|
|
327
|
+
expect(result1.count).toBe(1);
|
|
328
328
|
// Add a different proposal at same position - this is a duplicate (equivocation)
|
|
329
329
|
const proposal2 = await mockBlockProposalWithIndex(signers[1], slotNumber, indexWithinCheckpoint);
|
|
330
330
|
const result2 = await ap.tryAddBlockProposal(proposal2);
|
|
331
331
|
expect(result2.added).toBe(true);
|
|
332
332
|
expect(result2.alreadyExists).toBe(false);
|
|
333
|
-
//
|
|
334
|
-
expect(result2.
|
|
333
|
+
// count >= 2 indicates duplicate detection
|
|
334
|
+
expect(result2.count).toBe(2);
|
|
335
335
|
});
|
|
336
336
|
it('should not detect duplicate for different positions in same slot', async ()=>{
|
|
337
337
|
const slotNumber = 100;
|
|
@@ -342,8 +342,8 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
342
342
|
const proposal2 = await mockBlockProposalWithIndex(signers[1], slotNumber, 1);
|
|
343
343
|
const result = await ap.tryAddBlockProposal(proposal2);
|
|
344
344
|
expect(result.added).toBe(true);
|
|
345
|
-
//
|
|
346
|
-
expect(result.
|
|
345
|
+
// count = 1 means no duplicate for this position
|
|
346
|
+
expect(result.count).toBe(1);
|
|
347
347
|
});
|
|
348
348
|
it('should not detect duplicate for same position in different slots', async ()=>{
|
|
349
349
|
const indexWithinCheckpoint = 0;
|
|
@@ -354,41 +354,41 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
354
354
|
const proposal2 = await mockBlockProposalWithIndex(signers[1], 200, indexWithinCheckpoint);
|
|
355
355
|
const result = await ap.tryAddBlockProposal(proposal2);
|
|
356
356
|
expect(result.added).toBe(true);
|
|
357
|
-
//
|
|
358
|
-
expect(result.
|
|
357
|
+
// count = 1 means no duplicate for this position
|
|
358
|
+
expect(result.count).toBe(1);
|
|
359
359
|
});
|
|
360
|
-
it('should track multiple duplicates correctly via
|
|
360
|
+
it('should track multiple duplicates correctly via count', async ()=>{
|
|
361
361
|
const slotNumber = 100;
|
|
362
362
|
const indexWithinCheckpoint = 0;
|
|
363
363
|
// Add multiple proposals for same position
|
|
364
364
|
const proposal1 = await mockBlockProposalWithIndex(signers[0], slotNumber, indexWithinCheckpoint);
|
|
365
365
|
const result1 = await ap.tryAddBlockProposal(proposal1);
|
|
366
|
-
expect(result1.
|
|
366
|
+
expect(result1.count).toBe(1);
|
|
367
367
|
const proposal2 = await mockBlockProposalWithIndex(signers[1], slotNumber, indexWithinCheckpoint);
|
|
368
368
|
const result2 = await ap.tryAddBlockProposal(proposal2);
|
|
369
|
-
expect(result2.
|
|
369
|
+
expect(result2.count).toBe(2);
|
|
370
370
|
// Add a third proposal for same position
|
|
371
371
|
const proposal3 = await mockBlockProposalWithIndex(signers[2], slotNumber, indexWithinCheckpoint);
|
|
372
372
|
const result3 = await ap.tryAddBlockProposal(proposal3);
|
|
373
373
|
expect(result3.added).toBe(true);
|
|
374
|
-
expect(result3.
|
|
374
|
+
expect(result3.count).toBe(3);
|
|
375
375
|
});
|
|
376
376
|
it('should return added=false when exceeding capacity', async ()=>{
|
|
377
377
|
const slotNumber = 100;
|
|
378
378
|
const indexWithinCheckpoint = 0;
|
|
379
|
-
// Add
|
|
380
|
-
for(let i = 0; i <
|
|
379
|
+
// Add MAX_BLOCK_PROPOSALS_PER_POSITION proposals
|
|
380
|
+
for(let i = 0; i < MAX_BLOCK_PROPOSALS_PER_POSITION; i++){
|
|
381
381
|
const proposal = await mockBlockProposalWithIndex(signers[i % NUMBER_OF_SIGNERS_PER_TEST], slotNumber, indexWithinCheckpoint);
|
|
382
382
|
const result = await ap.tryAddBlockProposal(proposal);
|
|
383
383
|
expect(result.added).toBe(true);
|
|
384
|
-
expect(result.
|
|
384
|
+
expect(result.count).toBe(i + 1);
|
|
385
385
|
}
|
|
386
386
|
// The next proposal should not be added
|
|
387
387
|
const extraProposal = await mockBlockProposalWithIndex(signers[0], slotNumber, indexWithinCheckpoint);
|
|
388
388
|
const result = await ap.tryAddBlockProposal(extraProposal);
|
|
389
389
|
expect(result.added).toBe(false);
|
|
390
390
|
expect(result.alreadyExists).toBe(false);
|
|
391
|
-
expect(result.
|
|
391
|
+
expect(result.count).toBe(MAX_BLOCK_PROPOSALS_PER_POSITION);
|
|
392
392
|
});
|
|
393
393
|
it('should clean up block position index when deleting old data', async ()=>{
|
|
394
394
|
const slotNumber = 100;
|
|
@@ -396,16 +396,16 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
396
396
|
// Add proposal
|
|
397
397
|
const proposal1 = await mockBlockProposalWithIndex(signers[0], slotNumber, indexWithinCheckpoint);
|
|
398
398
|
await ap.tryAddBlockProposal(proposal1);
|
|
399
|
-
// Verify it's tracked (adding another should show
|
|
399
|
+
// Verify it's tracked (adding another should show count = 2)
|
|
400
400
|
const proposal2 = await mockBlockProposalWithIndex(signers[1], slotNumber, indexWithinCheckpoint);
|
|
401
401
|
let result = await ap.tryAddBlockProposal(proposal2);
|
|
402
|
-
expect(result.
|
|
402
|
+
expect(result.count).toBe(2);
|
|
403
403
|
// Delete old data
|
|
404
404
|
await ap.deleteOlderThan(SlotNumber(slotNumber + 1));
|
|
405
|
-
// Verify position index is cleaned up (
|
|
405
|
+
// Verify position index is cleaned up (count should be 1 now)
|
|
406
406
|
const proposal3 = await mockBlockProposalWithIndex(signers[2], slotNumber, indexWithinCheckpoint);
|
|
407
407
|
result = await ap.tryAddBlockProposal(proposal3);
|
|
408
|
-
expect(result.
|
|
408
|
+
expect(result.count).toBe(1);
|
|
409
409
|
});
|
|
410
410
|
it('should correctly delete block proposals at slot boundary', async ()=>{
|
|
411
411
|
// Add proposals at slots 99, 100, and 101 with various indices
|
|
@@ -422,14 +422,14 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
422
422
|
// Slot 99 proposals should have their index cleaned up
|
|
423
423
|
const newProposal99 = await mockBlockProposalWithIndex(signers[0], 99, 0);
|
|
424
424
|
const result99 = await ap.tryAddBlockProposal(newProposal99);
|
|
425
|
-
expect(result99.
|
|
425
|
+
expect(result99.count).toBe(1); // Index was cleaned up
|
|
426
426
|
// Slot 100 and 101 should still be tracked
|
|
427
427
|
const newProposal100 = await mockBlockProposalWithIndex(signers[1], 100, 0);
|
|
428
428
|
const result100 = await ap.tryAddBlockProposal(newProposal100);
|
|
429
|
-
expect(result100.
|
|
429
|
+
expect(result100.count).toBe(2); // Still has the original
|
|
430
430
|
const newProposal101 = await mockBlockProposalWithIndex(signers[2], 101, 0);
|
|
431
431
|
const result101 = await ap.tryAddBlockProposal(newProposal101);
|
|
432
|
-
expect(result101.
|
|
432
|
+
expect(result101.count).toBe(2); // Still has the original
|
|
433
433
|
});
|
|
434
434
|
it('should delete all indices for a given slot', async ()=>{
|
|
435
435
|
const slotNumber = 50;
|
|
@@ -445,13 +445,13 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
445
445
|
// All indices should be cleaned up
|
|
446
446
|
const newProposal0 = await mockBlockProposalWithIndex(signers[0], slotNumber, 0);
|
|
447
447
|
const result0 = await ap.tryAddBlockProposal(newProposal0);
|
|
448
|
-
expect(result0.
|
|
448
|
+
expect(result0.count).toBe(1);
|
|
449
449
|
const newProposal1 = await mockBlockProposalWithIndex(signers[1], slotNumber, 1);
|
|
450
450
|
const result1 = await ap.tryAddBlockProposal(newProposal1);
|
|
451
|
-
expect(result1.
|
|
451
|
+
expect(result1.count).toBe(1);
|
|
452
452
|
const newProposal2 = await mockBlockProposalWithIndex(signers[2], slotNumber, 2);
|
|
453
453
|
const result2 = await ap.tryAddBlockProposal(newProposal2);
|
|
454
|
-
expect(result2.
|
|
454
|
+
expect(result2.count).toBe(1);
|
|
455
455
|
});
|
|
456
456
|
it('should delete block proposals from storage when deleting old data', async ()=>{
|
|
457
457
|
const oldSlot = 50;
|
|
@@ -488,12 +488,12 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
488
488
|
});
|
|
489
489
|
return proposal.toCore();
|
|
490
490
|
};
|
|
491
|
-
it('should return
|
|
491
|
+
it('should return count=1 when pool is empty', async ()=>{
|
|
492
492
|
const proposal = await mockCheckpointProposalCoreForPool(signers[0], 100);
|
|
493
493
|
const result = await ap.tryAddCheckpointProposal(proposal);
|
|
494
494
|
expect(result.added).toBe(true);
|
|
495
495
|
expect(result.alreadyExists).toBe(false);
|
|
496
|
-
expect(result.
|
|
496
|
+
expect(result.count).toBe(1);
|
|
497
497
|
});
|
|
498
498
|
it('should return alreadyExists when same proposal exists', async ()=>{
|
|
499
499
|
const proposal = await mockCheckpointProposalCoreForPool(signers[0], 100);
|
|
@@ -501,21 +501,21 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
501
501
|
const result = await ap.tryAddCheckpointProposal(proposal);
|
|
502
502
|
expect(result.added).toBe(false);
|
|
503
503
|
expect(result.alreadyExists).toBe(true);
|
|
504
|
-
expect(result.
|
|
504
|
+
expect(result.count).toBe(1);
|
|
505
505
|
});
|
|
506
|
-
it('should detect duplicate via
|
|
506
|
+
it('should detect duplicate via count when different proposal exists for same slot', async ()=>{
|
|
507
507
|
const slotNumber = 100;
|
|
508
508
|
// Add first proposal
|
|
509
509
|
const proposal1 = await mockCheckpointProposalCoreForPool(signers[0], slotNumber);
|
|
510
510
|
const result1 = await ap.tryAddCheckpointProposal(proposal1);
|
|
511
|
-
expect(result1.
|
|
511
|
+
expect(result1.count).toBe(1);
|
|
512
512
|
// Add a different proposal for same slot - this is a duplicate (equivocation)
|
|
513
513
|
const proposal2 = await mockCheckpointProposalCoreForPool(signers[1], slotNumber);
|
|
514
514
|
const result2 = await ap.tryAddCheckpointProposal(proposal2);
|
|
515
515
|
expect(result2.added).toBe(true);
|
|
516
516
|
expect(result2.alreadyExists).toBe(false);
|
|
517
|
-
//
|
|
518
|
-
expect(result2.
|
|
517
|
+
// count >= 2 indicates duplicate detection
|
|
518
|
+
expect(result2.count).toBe(2);
|
|
519
519
|
});
|
|
520
520
|
it('should not detect duplicate for different slots', async ()=>{
|
|
521
521
|
// Add proposal at slot 100
|
|
@@ -525,23 +525,23 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
525
525
|
const proposal2 = await mockCheckpointProposalCoreForPool(signers[1], 200);
|
|
526
526
|
const result = await ap.tryAddCheckpointProposal(proposal2);
|
|
527
527
|
expect(result.added).toBe(true);
|
|
528
|
-
//
|
|
529
|
-
expect(result.
|
|
528
|
+
// count = 1 means no duplicate for this slot
|
|
529
|
+
expect(result.count).toBe(1);
|
|
530
530
|
});
|
|
531
|
-
it('should track multiple duplicates correctly via
|
|
531
|
+
it('should track multiple duplicates correctly via count', async ()=>{
|
|
532
532
|
const slotNumber = 100;
|
|
533
533
|
// Add multiple proposals for same slot
|
|
534
534
|
const proposal1 = await mockCheckpointProposalCoreForPool(signers[0], slotNumber);
|
|
535
535
|
const result1 = await ap.tryAddCheckpointProposal(proposal1);
|
|
536
|
-
expect(result1.
|
|
536
|
+
expect(result1.count).toBe(1);
|
|
537
537
|
const proposal2 = await mockCheckpointProposalCoreForPool(signers[1], slotNumber);
|
|
538
538
|
const result2 = await ap.tryAddCheckpointProposal(proposal2);
|
|
539
|
-
expect(result2.
|
|
539
|
+
expect(result2.count).toBe(2);
|
|
540
540
|
// Add a third proposal for same slot
|
|
541
541
|
const proposal3 = await mockCheckpointProposalCoreForPool(signers[2], slotNumber);
|
|
542
542
|
const result3 = await ap.tryAddCheckpointProposal(proposal3);
|
|
543
543
|
expect(result3.added).toBe(true);
|
|
544
|
-
expect(result3.
|
|
544
|
+
expect(result3.count).toBe(3);
|
|
545
545
|
});
|
|
546
546
|
it('should not count attestations as proposals for duplicate detection', async ()=>{
|
|
547
547
|
const slotNumber = 100;
|
|
@@ -556,8 +556,8 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
556
556
|
const result = await ap.tryAddCheckpointProposal(proposal);
|
|
557
557
|
expect(result.added).toBe(true);
|
|
558
558
|
expect(result.alreadyExists).toBe(false);
|
|
559
|
-
//
|
|
560
|
-
expect(result.
|
|
559
|
+
// count should be 1, NOT 2 - attestations should not count as proposals
|
|
560
|
+
expect(result.count).toBe(1);
|
|
561
561
|
});
|
|
562
562
|
it('should not count attestations for different proposals as duplicates', async ()=>{
|
|
563
563
|
const slotNumber = 100;
|
|
@@ -574,12 +574,12 @@ export function describeAttestationPool(getAttestationPool) {
|
|
|
574
574
|
const proposal1 = await mockCheckpointProposalCoreForPool(signers[2], slotNumber, archive1);
|
|
575
575
|
const result1 = await ap.tryAddCheckpointProposal(proposal1);
|
|
576
576
|
expect(result1.added).toBe(true);
|
|
577
|
-
expect(result1.
|
|
577
|
+
expect(result1.count).toBe(1);
|
|
578
578
|
// Add the second checkpoint proposal - this IS a duplicate (different archive, same slot)
|
|
579
579
|
const proposal2 = await mockCheckpointProposalCoreForPool(signers[3], slotNumber, archive2);
|
|
580
580
|
const result2 = await ap.tryAddCheckpointProposal(proposal2);
|
|
581
581
|
expect(result2.added).toBe(true);
|
|
582
|
-
expect(result2.
|
|
582
|
+
expect(result2.count).toBe(2);
|
|
583
583
|
});
|
|
584
584
|
});
|
|
585
585
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AttestationPool, type AttestationPoolApi, type TryAddResult, createTestAttestationPool,
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
1
|
+
export { AttestationPool, type AttestationPoolApi, type TryAddResult, createTestAttestationPool, MAX_CHECKPOINT_PROPOSALS_PER_SLOT, MAX_BLOCK_PROPOSALS_PER_POSITION, MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER, } from './attestation_pool.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvYXR0ZXN0YXRpb25fcG9vbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsZUFBZSxFQUNmLEtBQUssa0JBQWtCLEVBQ3ZCLEtBQUssWUFBWSxFQUNqQix5QkFBeUIsRUFDekIsaUNBQWlDLEVBQ2pDLGdDQUFnQyxFQUNoQyxvQ0FBb0MsR0FDckMsTUFBTSx1QkFBdUIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,yBAAyB,EACzB,iCAAiC,EACjC,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AttestationPool, createTestAttestationPool,
|
|
1
|
+
export { AttestationPool, createTestAttestationPool, MAX_CHECKPOINT_PROPOSALS_PER_SLOT, MAX_BLOCK_PROPOSALS_PER_POSITION, MAX_ATTESTATIONS_PER_SLOT_AND_SIGNER } from './attestation_pool.js';
|
|
@@ -238,5 +238,5 @@ export declare const generateAccount: () => {
|
|
|
238
238
|
* @param header The checkpoint header (defaults to random with given slot)
|
|
239
239
|
* @returns A Checkpoint Attestation
|
|
240
240
|
*/
|
|
241
|
-
export declare const mockCheckpointAttestation: (signer: Secp256k1Signer, slot?: number, archive?: Fr, header?: CheckpointHeader | undefined) => CheckpointAttestation;
|
|
242
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
241
|
+
export declare const mockCheckpointAttestation: (signer: Secp256k1Signer, slot?: number, archive?: Fr, header?: CheckpointHeader | undefined, feeAssetPriceModifier?: bigint) => CheckpointAttestation;
|
|
242
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja3MuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZW1fcG9vbHMvYXR0ZXN0YXRpb25fcG9vbC9tb2N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B,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/attestation_pool/mocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EACL,qBAAqB,EAItB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,wJAoBrC,CAAC"}
|
|
@@ -18,11 +18,11 @@ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
|
18
18
|
* @param archive The archive root (defaults to random)
|
|
19
19
|
* @param header The checkpoint header (defaults to random with given slot)
|
|
20
20
|
* @returns A Checkpoint Attestation
|
|
21
|
-
*/ export const mockCheckpointAttestation = (signer, slot = 0, archive = Fr.random(), header)=>{
|
|
21
|
+
*/ export const mockCheckpointAttestation = (signer, slot = 0, archive = Fr.random(), header, feeAssetPriceModifier = 0n)=>{
|
|
22
22
|
header = header ?? CheckpointHeader.random({
|
|
23
23
|
slotNumber: SlotNumber(slot)
|
|
24
24
|
});
|
|
25
|
-
const payload = new ConsensusPayload(header, archive);
|
|
25
|
+
const payload = new ConsensusPayload(header, archive, feeAssetPriceModifier);
|
|
26
26
|
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.checkpointAttestation);
|
|
27
27
|
const attestationSignature = signer.sign(attestationHash);
|
|
28
28
|
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.checkpointProposal);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AttestationPool, type AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
2
|
export { type MemPools } from './interface.js';
|
|
3
3
|
export { type TxPool } from './tx_pool/tx_pool.js';
|
|
4
|
-
|
|
4
|
+
export { type TxPoolV2, type TxPoolV2Config, type TxPoolV2Events, type AddTxsResult } from './tx_pool_v2/index.js';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tZW1fcG9vbHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGVBQWUsRUFBRSxLQUFLLGtCQUFrQixFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDbEcsT0FBTyxFQUFFLEtBQUssUUFBUSxFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFFL0MsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFbkQsT0FBTyxFQUFFLEtBQUssUUFBUSxFQUFFLEtBQUssY0FBYyxFQUFFLEtBQUssY0FBYyxFQUFFLEtBQUssWUFBWSxFQUFFLE1BQU0sdUJBQXVCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mem_pools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mem_pools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAClG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AttestationPoolApi } from './attestation_pool/attestation_pool.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TxPoolV2 } from './tx_pool_v2/interfaces.js';
|
|
3
3
|
/**
|
|
4
4
|
* A interface the combines all mempools
|
|
5
5
|
*/
|
|
6
6
|
export type MemPools = {
|
|
7
|
-
txPool:
|
|
7
|
+
txPool: TxPoolV2;
|
|
8
8
|
attestationPool: AttestationPoolApi;
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbWVtX3Bvb2xzL2ludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdDQUF3QyxDQUFDO0FBQ2pGLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBRTNEOztHQUVHO0FBQ0gsTUFBTSxNQUFNLFFBQVEsR0FBRztJQUNyQixNQUFNLEVBQUUsUUFBUSxDQUFDO0lBQ2pCLGVBQWUsRUFBRSxrQkFBa0IsQ0FBQztDQUNyQyxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/mem_pools/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/mem_pools/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,QAAQ,CAAC;IACjB,eAAe,EAAE,kBAAkB,CAAC;CACrC,CAAC"}
|
|
@@ -50,9 +50,9 @@ import { EvictionEvent } from './eviction_strategy.js';
|
|
|
50
50
|
continue;
|
|
51
51
|
}
|
|
52
52
|
// Evict pending txs with an expiration timestamp less than or equal to the mined block timestamp
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
this.log.verbose(`Evicting tx ${txHash} from pool due to the tx being expired (
|
|
53
|
+
const expirationTimestamp = tx.data.expirationTimestamp;
|
|
54
|
+
if (expirationTimestamp <= timestamp) {
|
|
55
|
+
this.log.verbose(`Evicting tx ${txHash} from pool due to the tx being expired (expirationTimestamp: ${expirationTimestamp}, mined block timestamp: ${timestamp})`);
|
|
56
56
|
txsToEvict.push(txHash);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
|
+
/**
|
|
5
|
+
* Manages all transaction deletions in the pool.
|
|
6
|
+
*
|
|
7
|
+
* When a chain prune (reorg) happens, transactions from pruned blocks are tracked here.
|
|
8
|
+
* This class is responsible for ALL deletion decisions:
|
|
9
|
+
*
|
|
10
|
+
* - Transactions from pruned blocks are "prune-soft-deleted" - removed from indices but kept
|
|
11
|
+
* in the database for later re-execution until their mined block is finalized
|
|
12
|
+
* - Transactions NOT from pruned blocks are "slot-soft-deleted" - kept in the database
|
|
13
|
+
* until the next slot, so other nodes can still fetch them via reqresp
|
|
14
|
+
*
|
|
15
|
+
* When a block is finalized, prune-soft-deleted transactions that were originally mined at or
|
|
16
|
+
* before that block number are permanently (hard) deleted. Slot-soft-deleted transactions
|
|
17
|
+
* are hard-deleted when `prepareForSlot` advances to a new slot.
|
|
18
|
+
*/
|
|
19
|
+
export declare class DeletedPool {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(store: AztecAsyncKVStore, txsDB: AztecAsyncMap<string, Buffer>, log: Logger);
|
|
22
|
+
/**
|
|
23
|
+
* Loads state from the database on startup.
|
|
24
|
+
* Slot-deleted txs are stale after restart and are immediately hard-deleted.
|
|
25
|
+
*/
|
|
26
|
+
hydrateFromDatabase(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Marks transactions as being from a pruned block.
|
|
29
|
+
* Called during handlePrunedBlocks for ALL transactions that were un-mined.
|
|
30
|
+
*
|
|
31
|
+
* If a tx was previously tracked (e.g., mined at block 4, pruned, re-mined at block 5,
|
|
32
|
+
* pruned again), updates to the higher block number. This ensures the tx is kept until
|
|
33
|
+
* its most recent mined block is finalized.
|
|
34
|
+
*
|
|
35
|
+
* @param txs - Array of {txHash, minedAtBlock} pairs, where minedAtBlock is the block
|
|
36
|
+
* number in which the tx was mined before being un-mined
|
|
37
|
+
*/
|
|
38
|
+
markFromPrunedBlock(txs: {
|
|
39
|
+
txHash: string;
|
|
40
|
+
minedAtBlock: BlockNumber;
|
|
41
|
+
}[]): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Deletes a transaction. This is the single entry point for ALL deletions.
|
|
44
|
+
* The tx is always soft-deleted (kept in DB):
|
|
45
|
+
*
|
|
46
|
+
* - If the tx is from a pruned block: prune-soft-delete (kept until finalized)
|
|
47
|
+
* - If the tx is NOT from a pruned block: slot-soft-delete (kept until next slot)
|
|
48
|
+
*/
|
|
49
|
+
deleteTx(txHash: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Clears tracking for a transaction if it re-mines at a block number >= the tracked minedAtBlock.
|
|
52
|
+
*
|
|
53
|
+
* When a tx re-mines at a higher (or equal) block, the old high-water mark is no longer needed:
|
|
54
|
+
* any future prune would re-add the tx with an even higher block number. Clearing keeps
|
|
55
|
+
* DeletedPool consistent — only txs that are actually un-mined should be tracked here.
|
|
56
|
+
*
|
|
57
|
+
* When a tx re-mines at a lower block, we must preserve the existing entry to retain
|
|
58
|
+
* the high-water mark for re-execution purposes.
|
|
59
|
+
*/
|
|
60
|
+
clearIfMinedHigher(txHash: string, minedAtBlock: BlockNumber): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if a transaction is from a pruned block.
|
|
63
|
+
*/
|
|
64
|
+
isFromPrunedBlock(txHash: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a transaction is soft-deleted (either prune-based or slot-based).
|
|
67
|
+
*/
|
|
68
|
+
isSoftDeleted(txHash: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the block number in which a transaction was originally mined.
|
|
71
|
+
*/
|
|
72
|
+
getMinedAtBlock(txHash: string): BlockNumber | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Finalizes transactions when a block is finalized.
|
|
75
|
+
* Hard-deletes transactions that were originally mined at or before the finalized block.
|
|
76
|
+
*
|
|
77
|
+
* @returns The hashes of transactions that were hard-deleted
|
|
78
|
+
*/
|
|
79
|
+
finalizeBlock(finalizedBlockNumber: BlockNumber): Promise<string[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Cleans up slot-deleted transactions from previous slots.
|
|
82
|
+
* Called at the start of prepareForSlot. Updates #currentSlot and hard-deletes
|
|
83
|
+
* any txs that were deleted in an earlier slot.
|
|
84
|
+
*/
|
|
85
|
+
cleanupSlotDeleted(currentSlot: SlotNumber): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Clears soft-deletion status for a transaction being re-added to the pool.
|
|
88
|
+
* Removes slot-deleted tracking entirely, and resets the prune-soft-deleted flag
|
|
89
|
+
* while preserving the prune tracking itself (so a subsequent delete still uses
|
|
90
|
+
* the prune path).
|
|
91
|
+
*/
|
|
92
|
+
clearSoftDeleted(txHash: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the count of transactions from pruned blocks.
|
|
95
|
+
*/
|
|
96
|
+
getCount(): number;
|
|
97
|
+
/**
|
|
98
|
+
* Gets all transaction hashes from pruned blocks.
|
|
99
|
+
*/
|
|
100
|
+
getPrunedTxHashes(): string[];
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVsZXRlZF9wb29sLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbWVtX3Bvb2xzL3R4X3Bvb2xfdjIvZGVsZXRlZF9wb29sLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUF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