@aztec/p2p 0.0.1-commit.8f9871590 → 0.0.1-commit.934299a21
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 -2
- package/dest/client/factory.d.ts.map +1 -1
- package/dest/client/factory.js +13 -23
- package/dest/client/interface.d.ts +9 -18
- package/dest/client/interface.d.ts.map +1 -1
- package/dest/client/p2p_client.d.ts +5 -16
- package/dest/client/p2p_client.d.ts.map +1 -1
- package/dest/client/p2p_client.js +40 -71
- package/dest/client/test/tx_proposal_collector/proposal_tx_collector_worker.js +5 -5
- package/dest/config.d.ts +4 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +0 -5
- package/dest/errors/tx-pool.error.d.ts +8 -0
- package/dest/errors/tx-pool.error.d.ts.map +1 -0
- package/dest/errors/tx-pool.error.js +9 -0
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts +3 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/deleted_pool.js +9 -0
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/eviction_manager.js +18 -9
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.js +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.js +10 -4
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/index.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/index.js +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts +48 -5
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/interfaces.js +8 -0
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.js +5 -5
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.d.ts +2 -2
- 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 +12 -6
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts +4 -4
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.js +14 -4
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts +3 -3
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.js +2 -2
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts +15 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.d.ts.map +1 -0
- package/dest/mem_pools/tx_pool_v2/instrumentation.js +43 -0
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts +16 -6
- package/dest/mem_pools/tx_pool_v2/interfaces.d.ts.map +1 -1
- package/dest/mem_pools/tx_pool_v2/interfaces.js +3 -1
- package/dest/mem_pools/tx_pool_v2/tx_metadata.d.ts +12 -2
- 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 -1
- package/dest/mem_pools/tx_pool_v2/tx_pool_indices.d.ts +5 -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 +12 -2
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2.d.ts +6 -3
- 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 -5
- package/dest/mem_pools/tx_pool_v2/tx_pool_v2_impl.d.ts +11 -5
- 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 +241 -130
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts +2 -2
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/aggregate_tx_validator.js +3 -3
- package/dest/msg_validators/tx_validator/factory.d.ts +114 -6
- package/dest/msg_validators/tx_validator/factory.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/factory.js +219 -58
- package/dest/msg_validators/tx_validator/gas_validator.d.ts +58 -3
- package/dest/msg_validators/tx_validator/gas_validator.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/gas_validator.js +73 -36
- package/dest/msg_validators/tx_validator/index.d.ts +2 -1
- package/dest/msg_validators/tx_validator/index.d.ts.map +1 -1
- package/dest/msg_validators/tx_validator/index.js +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/msg_validators/tx_validator/nullifier_cache.js +24 -0
- package/dest/services/dummy_service.d.ts +4 -4
- package/dest/services/dummy_service.d.ts.map +1 -1
- package/dest/services/dummy_service.js +4 -4
- package/dest/services/encoding.d.ts +1 -1
- package/dest/services/encoding.d.ts.map +1 -1
- package/dest/services/encoding.js +2 -1
- package/dest/services/gossipsub/topic_score_params.d.ts +18 -6
- package/dest/services/gossipsub/topic_score_params.d.ts.map +1 -1
- package/dest/services/gossipsub/topic_score_params.js +32 -10
- package/dest/services/libp2p/libp2p_service.d.ts +11 -7
- package/dest/services/libp2p/libp2p_service.d.ts.map +1 -1
- package/dest/services/libp2p/libp2p_service.js +62 -71
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts +4 -3
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/batch_tx_requester.js +19 -46
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts +2 -6
- package/dest/services/reqresp/batch-tx-requester/interface.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts +10 -13
- package/dest/services/reqresp/batch-tx-requester/missing_txs.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/missing_txs.js +25 -46
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts +17 -11
- package/dest/services/reqresp/batch-tx-requester/peer_collection.d.ts.map +1 -1
- package/dest/services/reqresp/batch-tx-requester/peer_collection.js +49 -15
- package/dest/services/reqresp/batch-tx-requester/tx_validator.js +2 -2
- package/dest/services/service.d.ts +5 -3
- package/dest/services/service.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/fast_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/fast_tx_collection.js +39 -33
- package/dest/services/tx_collection/file_store_tx_collection.d.ts +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_collection.js +4 -2
- package/dest/services/tx_collection/file_store_tx_source.d.ts +15 -6
- package/dest/services/tx_collection/file_store_tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/file_store_tx_source.js +47 -16
- package/dest/services/tx_collection/instrumentation.d.ts +1 -1
- package/dest/services/tx_collection/instrumentation.d.ts.map +1 -1
- package/dest/services/tx_collection/instrumentation.js +2 -1
- package/dest/services/tx_collection/missing_txs_tracker.d.ts +32 -0
- package/dest/services/tx_collection/missing_txs_tracker.d.ts.map +1 -0
- package/dest/services/tx_collection/missing_txs_tracker.js +27 -0
- package/dest/services/tx_collection/proposal_tx_collector.d.ts +7 -6
- package/dest/services/tx_collection/proposal_tx_collector.d.ts.map +1 -1
- package/dest/services/tx_collection/proposal_tx_collector.js +5 -4
- package/dest/services/tx_collection/slow_tx_collection.d.ts +2 -2
- package/dest/services/tx_collection/slow_tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/slow_tx_collection.js +10 -8
- package/dest/services/tx_collection/tx_collection.d.ts +5 -4
- package/dest/services/tx_collection/tx_collection.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.d.ts +6 -5
- package/dest/services/tx_collection/tx_collection_sink.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_collection_sink.js +13 -22
- package/dest/services/tx_collection/tx_source.d.ts +8 -3
- package/dest/services/tx_collection/tx_source.d.ts.map +1 -1
- package/dest/services/tx_collection/tx_source.js +19 -2
- package/dest/services/tx_file_store/tx_file_store.js +1 -1
- 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 +4 -4
- package/dest/test-helpers/mock-pubsub.d.ts +3 -2
- package/dest/test-helpers/mock-pubsub.d.ts.map +1 -1
- package/dest/test-helpers/mock-pubsub.js +6 -0
- package/dest/test-helpers/testbench-utils.d.ts +6 -3
- package/dest/test-helpers/testbench-utils.d.ts.map +1 -1
- package/dest/test-helpers/testbench-utils.js +1 -1
- package/dest/testbench/p2p_client_testbench_worker.d.ts +2 -2
- package/dest/testbench/p2p_client_testbench_worker.d.ts.map +1 -1
- package/dest/testbench/p2p_client_testbench_worker.js +6 -6
- package/dest/util.d.ts +2 -2
- package/dest/util.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/client/factory.ts +19 -35
- package/src/client/interface.ts +16 -19
- package/src/client/p2p_client.ts +46 -93
- package/src/client/test/tx_proposal_collector/proposal_tx_collector_worker.ts +18 -8
- package/src/config.ts +2 -10
- package/src/errors/tx-pool.error.ts +12 -0
- package/src/mem_pools/tx_pool_v2/deleted_pool.ts +11 -0
- package/src/mem_pools/tx_pool_v2/eviction/eviction_manager.ts +21 -8
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_eviction_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/eviction/fee_payer_balance_pre_add_rule.ts +15 -4
- package/src/mem_pools/tx_pool_v2/eviction/index.ts +4 -0
- package/src/mem_pools/tx_pool_v2/eviction/interfaces.ts +49 -4
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_mining_rule.ts +2 -2
- package/src/mem_pools/tx_pool_v2/eviction/invalid_txs_after_reorg_rule.ts +5 -5
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_eviction_rule.ts +12 -9
- package/src/mem_pools/tx_pool_v2/eviction/low_priority_pre_add_rule.ts +24 -6
- package/src/mem_pools/tx_pool_v2/eviction/nullifier_conflict_rule.ts +3 -3
- package/src/mem_pools/tx_pool_v2/instrumentation.ts +69 -0
- package/src/mem_pools/tx_pool_v2/interfaces.ts +15 -6
- package/src/mem_pools/tx_pool_v2/tx_metadata.ts +46 -2
- package/src/mem_pools/tx_pool_v2/tx_pool_indices.ts +14 -3
- package/src/mem_pools/tx_pool_v2/tx_pool_v2.ts +12 -7
- package/src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts +264 -125
- package/src/msg_validators/tx_validator/README.md +115 -0
- package/src/msg_validators/tx_validator/aggregate_tx_validator.ts +3 -3
- package/src/msg_validators/tx_validator/factory.ts +353 -77
- package/src/msg_validators/tx_validator/gas_validator.ts +90 -27
- package/src/msg_validators/tx_validator/index.ts +1 -0
- package/src/msg_validators/tx_validator/nullifier_cache.ts +30 -0
- package/src/services/dummy_service.ts +6 -6
- package/src/services/encoding.ts +2 -1
- package/src/services/gossipsub/README.md +29 -14
- package/src/services/gossipsub/topic_score_params.ts +49 -13
- package/src/services/libp2p/libp2p_service.ts +75 -79
- package/src/services/reqresp/batch-tx-requester/batch_tx_requester.ts +20 -48
- package/src/services/reqresp/batch-tx-requester/interface.ts +1 -5
- package/src/services/reqresp/batch-tx-requester/missing_txs.ts +23 -71
- package/src/services/reqresp/batch-tx-requester/peer_collection.ts +63 -24
- package/src/services/reqresp/batch-tx-requester/tx_validator.ts +2 -2
- package/src/services/service.ts +11 -2
- package/src/services/tx_collection/fast_tx_collection.ts +51 -30
- package/src/services/tx_collection/file_store_tx_collection.ts +7 -3
- package/src/services/tx_collection/file_store_tx_source.ts +61 -17
- package/src/services/tx_collection/instrumentation.ts +7 -1
- package/src/services/tx_collection/missing_txs_tracker.ts +52 -0
- package/src/services/tx_collection/proposal_tx_collector.ts +8 -7
- package/src/services/tx_collection/slow_tx_collection.ts +8 -9
- package/src/services/tx_collection/tx_collection.ts +4 -3
- package/src/services/tx_collection/tx_collection_sink.ts +15 -29
- package/src/services/tx_collection/tx_source.ts +22 -3
- package/src/services/tx_file_store/tx_file_store.ts +1 -1
- package/src/services/tx_provider.ts +2 -2
- package/src/test-helpers/mock-pubsub.ts +10 -0
- package/src/test-helpers/testbench-utils.ts +3 -3
- package/src/testbench/p2p_client_testbench_worker.ts +18 -11
- package/src/util.ts +7 -1
|
@@ -4,6 +4,7 @@ import type { DateProvider } from '@aztec/foundation/timer';
|
|
|
4
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
5
|
import type { L2Block, L2BlockId } from '@aztec/stdlib/block';
|
|
6
6
|
import { BlockHeader, Tx, TxHash } from '@aztec/stdlib/tx';
|
|
7
|
+
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
7
8
|
import { type AddTxsResult, type PoolReadAccess, type TxPoolV2Config, type TxPoolV2Dependencies } from './interfaces.js';
|
|
8
9
|
import { type TxState } from './tx_metadata.js';
|
|
9
10
|
/**
|
|
@@ -22,7 +23,7 @@ export interface TxPoolV2Callbacks {
|
|
|
22
23
|
*/
|
|
23
24
|
export declare class TxPoolV2Impl {
|
|
24
25
|
#private;
|
|
25
|
-
constructor(store: AztecAsyncKVStore, archiveStore: AztecAsyncKVStore, deps: TxPoolV2Dependencies, callbacks: TxPoolV2Callbacks, config: Partial<TxPoolV2Config> | undefined, dateProvider: DateProvider, log: Logger);
|
|
26
|
+
constructor(store: AztecAsyncKVStore, archiveStore: AztecAsyncKVStore, deps: TxPoolV2Dependencies, callbacks: TxPoolV2Callbacks, telemetry: TelemetryClient, config: Partial<TxPoolV2Config> | undefined, dateProvider: DateProvider, log: Logger);
|
|
26
27
|
/**
|
|
27
28
|
* Hydrates the in-memory state from the database on startup.
|
|
28
29
|
* Pipeline: Load → Check Mined Status → Partition → Validate Non-Mined → Rebuild Pending Pool → Delete Invalid
|
|
@@ -33,18 +34,21 @@ export declare class TxPoolV2Impl {
|
|
|
33
34
|
hydrateFromDatabase(): Promise<void>;
|
|
34
35
|
addPendingTxs(txs: Tx[], opts: {
|
|
35
36
|
source?: string;
|
|
37
|
+
feeComparisonOnly?: boolean;
|
|
36
38
|
}): Promise<AddTxsResult>;
|
|
37
|
-
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'
|
|
39
|
+
canAddPendingTx(tx: Tx): Promise<'accepted' | 'ignored'>;
|
|
38
40
|
addProtectedTxs(txs: Tx[], block: BlockHeader, opts: {
|
|
39
41
|
source?: string;
|
|
40
42
|
}): Promise<void>;
|
|
41
|
-
protectTxs(txHashes: TxHash[], block: BlockHeader): TxHash[]
|
|
43
|
+
protectTxs(txHashes: TxHash[], block: BlockHeader): Promise<TxHash[]>;
|
|
42
44
|
addMinedTxs(txs: Tx[], block: BlockHeader, opts: {
|
|
43
45
|
source?: string;
|
|
44
46
|
}): Promise<void>;
|
|
45
47
|
handleMinedBlock(block: L2Block): Promise<void>;
|
|
46
48
|
prepareForSlot(slotNumber: SlotNumber): Promise<void>;
|
|
47
|
-
handlePrunedBlocks(latestBlock: L2BlockId
|
|
49
|
+
handlePrunedBlocks(latestBlock: L2BlockId, options?: {
|
|
50
|
+
deleteAllTxs?: boolean;
|
|
51
|
+
}): Promise<void>;
|
|
48
52
|
handleFailedExecution(txHashes: TxHash[]): Promise<void>;
|
|
49
53
|
handleFinalizedBlock(block: BlockHeader): Promise<void>;
|
|
50
54
|
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
@@ -66,6 +70,8 @@ export declare class TxPoolV2Impl {
|
|
|
66
70
|
pending: number;
|
|
67
71
|
protected: number;
|
|
68
72
|
mined: number;
|
|
73
|
+
softDeleted: number;
|
|
74
|
+
totalMetadataBytes: number;
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfcG9vbF92Ml9pbXBsLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbWVtX3Bvb2xzL3R4X3Bvb2xfdjIvdHhfcG9vbF92Ml9pbXBsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBZSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUMxRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUl4RSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsU0FBUyxFQUFpQixNQUFNLHFCQUFxQixDQUFDO0FBRzdFLE9BQU8sRUFBRSxXQUFXLEVBQUUsRUFBRSxFQUFFLE1BQU0sRUFBb0IsTUFBTSxrQkFBa0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSx5QkFBeUIsQ0F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STtRQUNWLE9BQU8sRUFBRSxNQUFNLENBQUM7UUFDaEIsU0FBUyxFQUFFLE1BQU0sQ0FBQztRQUNsQixLQUFLLEVBQUUsTUFBTSxDQUFDO1FBQ2QsV0FBVyxFQUFFLE1BQU0sQ0FBQztRQUNwQixrQkFBa0IsRUFBRSxNQUFNLENBQUM7S0FDNUIsQ0FLQTtDQXFURiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_pool_v2_impl.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAIxE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAoB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tx_pool_v2_impl.d.ts","sourceRoot":"","sources":["../../../src/mem_pools/tx_pool_v2/tx_pool_v2_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAIxE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAoB,MAAM,kB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E,SAAS,CAAC,EAAE,CAExC;IAED,eAAe,IAAI,MAAM,CAQxB;IAED,OAAO,IAAI,OAAO,CAEjB;IAED,UAAU,IAAI,MAAM,CAEnB;IAED,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAE3D;IAED,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhD;IAID,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAalD;IAID,iBAAiB,IAAI,cAAc,CAOlC;IAID,QAAQ,IAAI;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAKA;CAqTF"}
|
|
@@ -6,7 +6,8 @@ import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
|
|
|
6
6
|
import { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
7
7
|
import { TxArchive } from './archive/index.js';
|
|
8
8
|
import { DeletedPool } from './deleted_pool.js';
|
|
9
|
-
import { EvictionManager, FeePayerBalanceEvictionRule, FeePayerBalancePreAddRule, InvalidTxsAfterMiningRule, InvalidTxsAfterReorgRule, LowPriorityEvictionRule, LowPriorityPreAddRule, NullifierConflictRule } from './eviction/index.js';
|
|
9
|
+
import { EvictionManager, FeePayerBalanceEvictionRule, FeePayerBalancePreAddRule, InvalidTxsAfterMiningRule, InvalidTxsAfterReorgRule, LowPriorityEvictionRule, LowPriorityPreAddRule, NullifierConflictRule, TxPoolRejectionCode } from './eviction/index.js';
|
|
10
|
+
import { TxPoolV2Instrumentation } from './instrumentation.js';
|
|
10
11
|
import { DEFAULT_TX_POOL_V2_CONFIG } from './interfaces.js';
|
|
11
12
|
import { buildTxMetaData, checkNullifierConflict } from './tx_metadata.js';
|
|
12
13
|
import { TxPoolIndices } from './tx_pool_indices.js';
|
|
@@ -30,9 +31,11 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
30
31
|
#deletedPool;
|
|
31
32
|
#evictionManager;
|
|
32
33
|
#dateProvider;
|
|
34
|
+
#instrumentation;
|
|
35
|
+
#evictedTxHashes = new Set();
|
|
33
36
|
#log;
|
|
34
37
|
#callbacks;
|
|
35
|
-
constructor(store, archiveStore, deps, callbacks, config = {}, dateProvider, log){
|
|
38
|
+
constructor(store, archiveStore, deps, callbacks, telemetry, config = {}, dateProvider, log){
|
|
36
39
|
this.#store = store;
|
|
37
40
|
this.#txsDB = store.openMap('txs');
|
|
38
41
|
this.#l2BlockSource = deps.l2BlockSource;
|
|
@@ -45,6 +48,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
45
48
|
this.#archive = new TxArchive(archiveStore, this.#config.archivedTxLimit, log);
|
|
46
49
|
this.#deletedPool = new DeletedPool(store, this.#txsDB, log);
|
|
47
50
|
this.#dateProvider = dateProvider;
|
|
51
|
+
this.#instrumentation = new TxPoolV2Instrumentation(telemetry, ()=>this.#indices.getTotalMetadataBytes());
|
|
48
52
|
this.#log = log;
|
|
49
53
|
this.#callbacks = callbacks;
|
|
50
54
|
// Setup eviction manager with rules
|
|
@@ -122,8 +126,12 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
122
126
|
const accepted = [];
|
|
123
127
|
const ignored = [];
|
|
124
128
|
const rejected = [];
|
|
129
|
+
const errors = new Map();
|
|
125
130
|
const acceptedPending = new Set();
|
|
126
131
|
const poolAccess = this.#createPreAddPoolAccess();
|
|
132
|
+
const preAddContext = opts.feeComparisonOnly !== undefined ? {
|
|
133
|
+
feeComparisonOnly: opts.feeComparisonOnly
|
|
134
|
+
} : undefined;
|
|
127
135
|
await this.#store.transactionAsync(async ()=>{
|
|
128
136
|
for (const tx of txs){
|
|
129
137
|
const txHash = tx.getTxHash();
|
|
@@ -150,7 +158,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
150
158
|
accepted.push(txHash);
|
|
151
159
|
} else {
|
|
152
160
|
// Regular pending tx - validate and run pre-add rules
|
|
153
|
-
const result = await this.#tryAddRegularPendingTx(tx, opts, poolAccess, acceptedPending, ignored);
|
|
161
|
+
const result = await this.#tryAddRegularPendingTx(tx, opts, poolAccess, acceptedPending, ignored, errors, preAddContext);
|
|
154
162
|
if (result.status === 'accepted') {
|
|
155
163
|
acceptedPending.add(txHashStr);
|
|
156
164
|
} else if (result.status === 'rejected') {
|
|
@@ -160,26 +168,36 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
}
|
|
171
|
+
// Run post-add eviction rules for pending txs (inside transaction for atomicity)
|
|
172
|
+
if (acceptedPending.size > 0) {
|
|
173
|
+
const feePayers = Array.from(acceptedPending).map((txHash)=>this.#indices.getMetadata(txHash).feePayer);
|
|
174
|
+
const uniqueFeePayers = new Set(feePayers);
|
|
175
|
+
await this.#evictionManager.evictAfterNewTxs(Array.from(acceptedPending), [
|
|
176
|
+
...uniqueFeePayers
|
|
177
|
+
]);
|
|
178
|
+
}
|
|
163
179
|
});
|
|
164
180
|
// Build final accepted list for pending txs (excludes intra-batch evictions)
|
|
165
181
|
for (const txHashStr of acceptedPending){
|
|
166
182
|
accepted.push(TxHash.fromString(txHashStr));
|
|
167
183
|
}
|
|
168
|
-
//
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
]);
|
|
184
|
+
// Record metrics
|
|
185
|
+
if (ignored.length > 0) {
|
|
186
|
+
this.#instrumentation.recordIgnored(ignored.length);
|
|
187
|
+
}
|
|
188
|
+
if (rejected.length > 0) {
|
|
189
|
+
this.#instrumentation.recordRejected(rejected.length);
|
|
175
190
|
}
|
|
176
191
|
return {
|
|
177
192
|
accepted,
|
|
178
193
|
ignored,
|
|
179
|
-
rejected
|
|
194
|
+
rejected,
|
|
195
|
+
...errors.size > 0 ? {
|
|
196
|
+
errors
|
|
197
|
+
} : {}
|
|
180
198
|
};
|
|
181
199
|
}
|
|
182
|
-
/** Validates and adds a regular pending tx. Returns status. */ async #tryAddRegularPendingTx(tx, opts, poolAccess, acceptedPending, ignored) {
|
|
200
|
+
/** Validates and adds a regular pending tx. Returns status. */ async #tryAddRegularPendingTx(tx, opts, poolAccess, acceptedPending, ignored, errors, preAddContext) {
|
|
183
201
|
const txHash = tx.getTxHash();
|
|
184
202
|
const txHashStr = txHash.toString();
|
|
185
203
|
// Build metadata and validate using metadata
|
|
@@ -190,26 +208,51 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
190
208
|
};
|
|
191
209
|
}
|
|
192
210
|
// Run pre-add rules
|
|
193
|
-
const preAddResult = await this.#evictionManager.runPreAddRules(meta, poolAccess);
|
|
211
|
+
const preAddResult = await this.#evictionManager.runPreAddRules(meta, poolAccess, preAddContext);
|
|
194
212
|
if (preAddResult.shouldIgnore) {
|
|
195
|
-
this.#log.debug(`Ignoring tx ${txHashStr}: ${preAddResult.reason}`);
|
|
213
|
+
this.#log.debug(`Ignoring tx ${txHashStr}: ${preAddResult.reason?.message ?? 'unknown reason'}`);
|
|
214
|
+
if (preAddResult.reason && preAddResult.reason.code !== TxPoolRejectionCode.INTERNAL_ERROR) {
|
|
215
|
+
errors.set(txHashStr, preAddResult.reason);
|
|
216
|
+
}
|
|
196
217
|
return {
|
|
197
218
|
status: 'ignored'
|
|
198
219
|
};
|
|
199
220
|
}
|
|
200
|
-
// Evict conflicts
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
221
|
+
// Evict conflicts, grouped by rule name for metrics
|
|
222
|
+
if (preAddResult.evictions && preAddResult.evictions.length > 0) {
|
|
223
|
+
const byReason = new Map();
|
|
224
|
+
for (const { txHash: evictHash, reason } of preAddResult.evictions){
|
|
225
|
+
const group = byReason.get(reason);
|
|
226
|
+
if (group) {
|
|
227
|
+
group.push(evictHash);
|
|
228
|
+
} else {
|
|
229
|
+
byReason.set(reason, [
|
|
230
|
+
evictHash
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const [reason, hashes] of byReason){
|
|
235
|
+
await this.#evictTxs(hashes, reason);
|
|
236
|
+
}
|
|
237
|
+
for (const evictHashStr of preAddResult.txHashesToEvict){
|
|
238
|
+
this.#log.debug(`Evicted tx ${evictHashStr} due to higher-fee tx ${txHashStr}`, {
|
|
239
|
+
evictedTxHash: evictHashStr,
|
|
240
|
+
replacementTxHash: txHashStr
|
|
241
|
+
});
|
|
242
|
+
if (acceptedPending.has(evictHashStr)) {
|
|
243
|
+
// Evicted tx was from this batch - mark as ignored in result
|
|
244
|
+
acceptedPending.delete(evictHashStr);
|
|
245
|
+
ignored.push(TxHash.fromString(evictHashStr));
|
|
246
|
+
}
|
|
211
247
|
}
|
|
212
248
|
}
|
|
249
|
+
// Randomly drop the transaction for testing purposes (report as accepted so it propagates)
|
|
250
|
+
if (this.#config.dropTransactionsProbability > 0 && Math.random() < this.#config.dropTransactionsProbability) {
|
|
251
|
+
this.#log.debug(`Dropping tx ${txHashStr} (simulated drop for testing)`);
|
|
252
|
+
return {
|
|
253
|
+
status: 'accepted'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
213
256
|
// Add the transaction
|
|
214
257
|
await this.#addTx(tx, 'pending', opts);
|
|
215
258
|
return {
|
|
@@ -222,13 +265,8 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
222
265
|
if (this.#indices.has(txHashStr)) {
|
|
223
266
|
return 'ignored';
|
|
224
267
|
}
|
|
225
|
-
// Build metadata and
|
|
268
|
+
// Build metadata and check pre-add rules
|
|
226
269
|
const meta = await buildTxMetaData(tx);
|
|
227
|
-
const validationResult = await this.#validateMeta(meta, undefined, 'can add pending');
|
|
228
|
-
if (validationResult !== true) {
|
|
229
|
-
return 'rejected';
|
|
230
|
-
}
|
|
231
|
-
// Use pre-add rules
|
|
232
270
|
const poolAccess = this.#createPreAddPoolAccess();
|
|
233
271
|
const preAddResult = await this.#evictionManager.runPreAddRules(meta, poolAccess);
|
|
234
272
|
return preAddResult.shouldIgnore ? 'ignored' : 'accepted';
|
|
@@ -264,20 +302,53 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
264
302
|
}
|
|
265
303
|
});
|
|
266
304
|
}
|
|
267
|
-
protectTxs(txHashes, block) {
|
|
305
|
+
async protectTxs(txHashes, block) {
|
|
268
306
|
const slotNumber = block.globalVariables.slotNumber;
|
|
269
307
|
const missing = [];
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
308
|
+
let softDeletedHits = 0;
|
|
309
|
+
let missingPreviouslyEvicted = 0;
|
|
310
|
+
await this.#store.transactionAsync(async ()=>{
|
|
311
|
+
for (const txHash of txHashes){
|
|
312
|
+
const txHashStr = txHash.toString();
|
|
313
|
+
if (this.#indices.has(txHashStr)) {
|
|
314
|
+
// Update protection for existing tx
|
|
315
|
+
this.#indices.updateProtection(txHashStr, slotNumber);
|
|
316
|
+
} else if (this.#deletedPool.isSoftDeleted(txHashStr)) {
|
|
317
|
+
// Resurrect soft-deleted tx as protected
|
|
318
|
+
const buffer = await this.#txsDB.getAsync(txHashStr);
|
|
319
|
+
if (buffer) {
|
|
320
|
+
const tx = Tx.fromBuffer(buffer);
|
|
321
|
+
await this.#addTx(tx, {
|
|
322
|
+
protected: slotNumber
|
|
323
|
+
});
|
|
324
|
+
softDeletedHits++;
|
|
325
|
+
} else {
|
|
326
|
+
// Data missing despite soft-delete flag — treat as truly missing
|
|
327
|
+
this.#indices.setProtection(txHashStr, slotNumber);
|
|
328
|
+
missing.push(txHash);
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
// Truly missing — pre-record protection for tx we don't have yet
|
|
332
|
+
this.#indices.setProtection(txHashStr, slotNumber);
|
|
333
|
+
missing.push(txHash);
|
|
334
|
+
if (this.#evictedTxHashes.has(txHashStr)) {
|
|
335
|
+
missingPreviouslyEvicted++;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
279
338
|
}
|
|
339
|
+
});
|
|
340
|
+
// Record metrics
|
|
341
|
+
if (softDeletedHits > 0) {
|
|
342
|
+
this.#instrumentation.recordSoftDeletedHits(softDeletedHits);
|
|
343
|
+
}
|
|
344
|
+
if (missing.length > 0) {
|
|
345
|
+
this.#log.debug(`protectTxs missing tx hashes: ${missing.map((h)=>h.toString()).join(', ')}`);
|
|
346
|
+
this.#instrumentation.recordMissingOnProtect(missing.length);
|
|
280
347
|
}
|
|
348
|
+
if (missingPreviouslyEvicted > 0) {
|
|
349
|
+
this.#instrumentation.recordMissingPreviouslyEvicted(missingPreviouslyEvicted);
|
|
350
|
+
}
|
|
351
|
+
this.#log.info(`Protected ${txHashes.length} txs, missing: ${missing.length}, soft-deleted hits: ${softDeletedHits}`);
|
|
281
352
|
return missing;
|
|
282
353
|
}
|
|
283
354
|
async addMinedTxs(txs, block, opts) {
|
|
@@ -316,47 +387,50 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
316
387
|
found.push(meta);
|
|
317
388
|
}
|
|
318
389
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
390
|
+
await this.#store.transactionAsync(async ()=>{
|
|
391
|
+
// Step 4: Mark txs as mined (only those we have in the pool)
|
|
392
|
+
for (const meta of found){
|
|
393
|
+
this.#indices.markAsMined(meta, blockId);
|
|
394
|
+
await this.#deletedPool.clearIfMinedHigher(meta.txHash, blockId.number);
|
|
395
|
+
}
|
|
396
|
+
// Step 5: Run post-event eviction rules (inside transaction for atomicity)
|
|
397
|
+
await this.#evictionManager.evictAfterNewBlock(block.header, nullifiers, feePayers);
|
|
398
|
+
});
|
|
326
399
|
this.#log.info(`Marked ${found.length} txs as mined in block ${blockId.number}`);
|
|
327
400
|
}
|
|
328
401
|
async prepareForSlot(slotNumber) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
402
|
+
await this.#store.transactionAsync(async ()=>{
|
|
403
|
+
// Step 0: Clean up slot-deleted txs from previous slots
|
|
404
|
+
await this.#deletedPool.cleanupSlotDeleted(slotNumber);
|
|
405
|
+
// Step 1: Find expired protected txs
|
|
406
|
+
const expiredProtected = this.#indices.findExpiredProtectedTxs(slotNumber);
|
|
407
|
+
// Step 2: Clear protection for all expired entries (including those without metadata)
|
|
408
|
+
this.#indices.clearProtection(expiredProtected);
|
|
409
|
+
// Step 3: Filter to only txs that have metadata and are not mined
|
|
410
|
+
const txsToRestore = this.#indices.filterRestorable(expiredProtected);
|
|
411
|
+
if (txsToRestore.length === 0) {
|
|
412
|
+
this.#log.debug(`Preparing for slot ${slotNumber}, no txs to unprotect`);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
this.#log.info(`Preparing for slot ${slotNumber}: unprotecting ${txsToRestore.length} txs`);
|
|
416
|
+
// Step 4: Validate for pending pool
|
|
417
|
+
const { valid, invalid } = await this.#revalidateMetadata(txsToRestore, 'during prepareForSlot');
|
|
418
|
+
// Step 5: Resolve nullifier conflicts and add winners to pending indices
|
|
419
|
+
const { added, toEvict } = this.#applyNullifierConflictResolution(valid);
|
|
420
|
+
// Step 6: Delete invalid txs and evict conflict losers
|
|
421
|
+
await this.#deleteTxsBatch(invalid);
|
|
422
|
+
await this.#evictTxs(toEvict, 'NullifierConflict');
|
|
423
|
+
// Step 7: Run eviction rules (enforce pool size limit)
|
|
424
|
+
if (added.length > 0) {
|
|
425
|
+
const feePayers = added.map((meta)=>meta.feePayer);
|
|
426
|
+
const uniqueFeePayers = new Set(feePayers);
|
|
427
|
+
await this.#evictionManager.evictAfterNewTxs(added.map((m)=>m.txHash), [
|
|
428
|
+
...uniqueFeePayers
|
|
429
|
+
]);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
358
432
|
}
|
|
359
|
-
async handlePrunedBlocks(latestBlock) {
|
|
433
|
+
async handlePrunedBlocks(latestBlock, options) {
|
|
360
434
|
// Step 1: Find transactions mined after the prune point
|
|
361
435
|
const txsToUnmine = this.#indices.findTxsMinedAfter(latestBlock.number);
|
|
362
436
|
if (txsToUnmine.length === 0) {
|
|
@@ -364,40 +438,48 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
364
438
|
return;
|
|
365
439
|
}
|
|
366
440
|
this.#log.info(`Handling prune to block ${latestBlock.number}: un-mining ${txsToUnmine.length} txs`);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
441
|
+
await this.#store.transactionAsync(async ()=>{
|
|
442
|
+
// Step 2: Mark ALL un-mined txs with their original mined block number
|
|
443
|
+
// This ensures they get soft-deleted if removed later, and only hard-deleted
|
|
444
|
+
// when their original mined block is finalized
|
|
445
|
+
await this.#deletedPool.markFromPrunedBlock(txsToUnmine.map((m)=>({
|
|
446
|
+
txHash: m.txHash,
|
|
447
|
+
minedAtBlock: BlockNumber(m.minedL2BlockId.number)
|
|
448
|
+
})));
|
|
449
|
+
// Step 3: Unmine - clear mined status from metadata
|
|
450
|
+
for (const meta of txsToUnmine){
|
|
451
|
+
this.#indices.markAsUnmined(meta);
|
|
452
|
+
}
|
|
453
|
+
// If deleteAllTxs is set (epoch prune), delete all un-mined txs and return early
|
|
454
|
+
if (options?.deleteAllTxs) {
|
|
455
|
+
const allTxHashes = txsToUnmine.map((m)=>m.txHash);
|
|
456
|
+
await this.#deleteTxsBatch(allTxHashes);
|
|
457
|
+
this.#log.info(`Handled prune to block ${latestBlock.number} with deleteAllTxs: deleted ${allTxHashes.length} txs`);
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
// Step 4: Filter out protected txs (they'll be handled by prepareForSlot)
|
|
461
|
+
const unprotectedTxs = this.#indices.filterUnprotected(txsToUnmine);
|
|
462
|
+
// Step 5: Validate for pending pool
|
|
463
|
+
const { valid, invalid } = await this.#revalidateMetadata(unprotectedTxs, 'during handlePrunedBlocks');
|
|
464
|
+
// Step 6: Resolve nullifier conflicts and add winners to pending indices
|
|
465
|
+
const { toEvict } = this.#applyNullifierConflictResolution(valid);
|
|
466
|
+
// Step 7: Delete invalid txs and evict conflict losers
|
|
467
|
+
await this.#deleteTxsBatch(invalid);
|
|
468
|
+
await this.#evictTxs(toEvict, 'NullifierConflict');
|
|
469
|
+
this.#log.info(`Handled prune to block ${latestBlock.number}: ${valid.length} txs restored to pending, ${invalid.length} invalid, ${toEvict.length} evicted due to nullifier conflicts`, {
|
|
470
|
+
txHashesRestored: valid.map((m)=>m.txHash),
|
|
471
|
+
txHashesInvalid: invalid,
|
|
472
|
+
txHashesEvicted: toEvict
|
|
473
|
+
});
|
|
474
|
+
// Step 8: Run eviction rules for ALL pending txs (not just restored ones)
|
|
475
|
+
// This handles cases like existing pending txs with invalid fee payer balances
|
|
476
|
+
await this.#evictionManager.evictAfterChainPrune(latestBlock.number);
|
|
393
477
|
});
|
|
394
|
-
// Step 8: Run eviction rules for ALL pending txs (not just restored ones)
|
|
395
|
-
// This handles cases like existing pending txs with invalid fee payer balances
|
|
396
|
-
await this.#evictionManager.evictAfterChainPrune(latestBlock.number);
|
|
397
478
|
}
|
|
398
479
|
async handleFailedExecution(txHashes) {
|
|
399
|
-
|
|
400
|
-
|
|
480
|
+
await this.#store.transactionAsync(async ()=>{
|
|
481
|
+
await this.#deleteTxsBatch(txHashes.map((h)=>h.toString()));
|
|
482
|
+
});
|
|
401
483
|
this.#log.info(`Deleted ${txHashes.length} failed txs`, {
|
|
402
484
|
txHashes: txHashes.map((h)=>h.toString())
|
|
403
485
|
});
|
|
@@ -406,24 +488,26 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
406
488
|
const blockNumber = block.globalVariables.blockNumber;
|
|
407
489
|
// Step 1: Find mined txs at or before finalized block
|
|
408
490
|
const minedTxsToFinalize = this.#indices.findTxsMinedAtOrBefore(blockNumber);
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
491
|
+
await this.#store.transactionAsync(async ()=>{
|
|
492
|
+
// Step 2: Collect mined txs for archiving (before deletion)
|
|
493
|
+
const txsToArchive = [];
|
|
494
|
+
if (this.#archive.isEnabled()) {
|
|
495
|
+
for (const txHashStr of minedTxsToFinalize){
|
|
496
|
+
const buffer = await this.#txsDB.getAsync(txHashStr);
|
|
497
|
+
if (buffer) {
|
|
498
|
+
txsToArchive.push(Tx.fromBuffer(buffer));
|
|
499
|
+
}
|
|
416
500
|
}
|
|
417
501
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
502
|
+
// Step 3: Delete mined txs from active pool
|
|
503
|
+
await this.#deleteTxsBatch(minedTxsToFinalize);
|
|
504
|
+
// Step 4: Finalize soft-deleted txs
|
|
505
|
+
await this.#deletedPool.finalizeBlock(blockNumber);
|
|
506
|
+
// Step 5: Archive mined txs
|
|
507
|
+
if (txsToArchive.length > 0) {
|
|
508
|
+
await this.#archive.archiveTxs(txsToArchive);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
427
511
|
if (minedTxsToFinalize.length > 0) {
|
|
428
512
|
this.#log.info(`Finalized ${minedTxsToFinalize.length} mined txs from blocks up to ${blockNumber}`, {
|
|
429
513
|
txHashes: minedTxsToFinalize
|
|
@@ -528,7 +612,10 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
528
612
|
}
|
|
529
613
|
// === Metrics ===
|
|
530
614
|
countTxs() {
|
|
531
|
-
return
|
|
615
|
+
return {
|
|
616
|
+
...this.#indices.countTxs(),
|
|
617
|
+
softDeleted: this.#deletedPool.getSoftDeletedCount()
|
|
618
|
+
};
|
|
532
619
|
}
|
|
533
620
|
// ============================================================================
|
|
534
621
|
// PRIVATE HELPERS - Transaction Management
|
|
@@ -554,9 +641,11 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
554
641
|
this.#indices.addMined(meta);
|
|
555
642
|
}
|
|
556
643
|
const stateStr = typeof state === 'string' ? state : Object.keys(state)[0];
|
|
557
|
-
this.#log.
|
|
644
|
+
this.#log.debug(`Added tx ${txHashStr} as ${stateStr}`, {
|
|
558
645
|
eventName: 'tx-added-to-pool',
|
|
559
|
-
|
|
646
|
+
txHash: txHashStr,
|
|
647
|
+
state: stateStr,
|
|
648
|
+
source: opts.source
|
|
560
649
|
});
|
|
561
650
|
return meta;
|
|
562
651
|
}
|
|
@@ -579,6 +668,28 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
579
668
|
await this.#deleteTx(txHashStr);
|
|
580
669
|
}
|
|
581
670
|
}
|
|
671
|
+
/** Evicts transactions: records eviction metric with reason, caches hashes, then deletes. */ async #evictTxs(txHashes, reason) {
|
|
672
|
+
if (txHashes.length === 0) {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
this.#instrumentation.recordEvictions(txHashes.length, reason);
|
|
676
|
+
for (const txHashStr of txHashes){
|
|
677
|
+
this.#log.debug(`Evicting tx ${txHashStr}`, {
|
|
678
|
+
txHash: txHashStr,
|
|
679
|
+
reason
|
|
680
|
+
});
|
|
681
|
+
this.#addToEvictedCache(txHashStr);
|
|
682
|
+
}
|
|
683
|
+
await this.#deleteTxsBatch(txHashes);
|
|
684
|
+
}
|
|
685
|
+
/** Adds a tx hash to the bounded evicted cache, evicting the oldest entry if at capacity. */ #addToEvictedCache(txHashStr) {
|
|
686
|
+
if (this.#evictedTxHashes.size >= this.#config.evictedTxCacheSize) {
|
|
687
|
+
// FIFO eviction: remove the first (oldest) entry
|
|
688
|
+
const oldest = this.#evictedTxHashes.values().next().value;
|
|
689
|
+
this.#evictedTxHashes.delete(oldest);
|
|
690
|
+
}
|
|
691
|
+
this.#evictedTxHashes.add(txHashStr);
|
|
692
|
+
}
|
|
582
693
|
// ============================================================================
|
|
583
694
|
// PRIVATE HELPERS - Validation & Conflict Resolution
|
|
584
695
|
// ============================================================================
|
|
@@ -717,7 +828,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
717
828
|
if (preAddResult.shouldIgnore) {
|
|
718
829
|
// Transaction rejected - mark for deletion from DB
|
|
719
830
|
rejected.push(meta.txHash);
|
|
720
|
-
this.#log.debug(`Rejected tx ${meta.txHash} during rebuild: ${preAddResult.reason}`);
|
|
831
|
+
this.#log.debug(`Rejected tx ${meta.txHash} during rebuild: ${preAddResult.reason?.message ?? 'unknown reason'}`);
|
|
721
832
|
continue;
|
|
722
833
|
}
|
|
723
834
|
// Evict any conflicting txs identified by pre-add rules
|
|
@@ -753,7 +864,7 @@ import { TxPoolIndices } from './tx_pool_indices.js';
|
|
|
753
864
|
getFeePayerPendingTxs: (feePayer)=>this.#indices.getFeePayerPendingTxs(feePayer),
|
|
754
865
|
getPendingTxCount: ()=>this.#indices.getPendingTxCount(),
|
|
755
866
|
getLowestPriorityPending: (limit)=>this.#indices.getLowestPriorityPending(limit),
|
|
756
|
-
deleteTxs: (txHashes)=>this.#
|
|
867
|
+
deleteTxs: (txHashes, reason)=>this.#evictTxs(txHashes, reason ?? 'unknown')
|
|
757
868
|
};
|
|
758
869
|
}
|
|
759
870
|
#createPreAddPoolAccess() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TxValidationResult, TxValidator } from '@aztec/stdlib/tx';
|
|
2
2
|
export declare class AggregateTxValidator<T> implements TxValidator<T> {
|
|
3
|
-
|
|
3
|
+
readonly validators: TxValidator<T>[];
|
|
4
4
|
constructor(...validators: TxValidator<T>[]);
|
|
5
5
|
validateTx(tx: T): Promise<TxValidationResult>;
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdncmVnYXRlX3R4X3ZhbGlkYXRvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL21zZ192YWxpZGF0b3JzL3R4X3ZhbGlkYXRvci9hZ2dyZWdhdGVfdHhfdmFsaWRhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXhFLHFCQUFhLG9CQUFvQixDQUFDLENBQUMsQ0FBRSxZQUFXLFdBQVcsQ0FBQyxDQUFDLENBQUM7SUFDNUQsUUFBUSxDQUFDLFVBQVUsRUFBRSxXQUFXLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztJQUN0QyxZQUFZLEdBQUcsVUFBVSxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxFQU0xQztJQUVLLFVBQVUsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQWtCbkQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate_tx_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/aggregate_tx_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"aggregate_tx_validator.d.ts","sourceRoot":"","sources":["../../../src/msg_validators/tx_validator/aggregate_tx_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,YAAY,GAAG,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,EAM1C;IAEK,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkBnD;CACF"}
|