@@ -13,11 +13,7 @@ import {
1313 type PreAddEvictionResult ,
1414 type PreAddEvictionRule ,
1515 type PreAddPoolAccess ,
16- type PrePendingFilter ,
17- type PrePendingFilterContext ,
18- type PrePendingFilterResult ,
1916 type TxPoolOperations ,
20- type TxValidationFields ,
2117} from './eviction_strategy.js' ;
2218
2319export class EvictionManager {
@@ -26,9 +22,6 @@ export class EvictionManager {
2622 /** Pre-add eviction rules (run inside addTxs transaction) */
2723 private preAddRules : PreAddEvictionRule [ ] = [ ] ;
2824
29- /** Pre-pending filters (run before restoring txs to pending after reorg/unprotect) */
30- private prePendingFilters : PrePendingFilter [ ] = [ ] ;
31-
3225 constructor (
3326 private txPool : TxPoolOperations ,
3427 private log = createLogger ( 'p2p:mempool:tx_pool:eviction_manager' ) ,
@@ -114,68 +107,6 @@ export class EvictionManager {
114107 this . preAddRules . push ( rule ) ;
115108 }
116109
117- public registerPrePendingFilter ( filter : PrePendingFilter ) {
118- this . prePendingFilters . push ( filter ) ;
119- }
120-
121- /**
122- * Filters transactions before they are restored to pending state.
123- * Used during reorgs (un-mining) and slot transitions (unprotecting) to avoid
124- * adding transactions to pending indices only to immediately remove them.
125- *
126- * @param txs - Transaction metadata to validate
127- * @param ctx - Context about why we're filtering
128- * @returns Result with valid and invalid tx hashes
129- */
130- public async filterValidForPending (
131- txs : TxValidationFields [ ] ,
132- ctx : PrePendingFilterContext ,
133- ) : Promise < PrePendingFilterResult > {
134- if ( txs . length === 0 ) {
135- return { valid : [ ] , invalid : [ ] } ;
136- }
137-
138- // Collect all invalid tx hashes from all filters
139- const allInvalid = new Set < string > ( ) ;
140-
141- for ( const filter of this . prePendingFilters ) {
142- try {
143- const invalidFromFilter = await filter . filterInvalid ( txs , ctx ) ;
144- for ( const txHash of invalidFromFilter ) {
145- allInvalid . add ( txHash ) ;
146- }
147- } catch ( err ) {
148- this . log . warn ( `Pre-pending filter ${ filter . name } unexpected error: ${ String ( err ) } ` , {
149- err,
150- filterName : filter . name ,
151- event : ctx . event ,
152- } ) ;
153- // On error, don't filter out any txs - let them go to pending and be evicted later if needed
154- }
155- }
156-
157- // Partition into valid and invalid
158- const valid : string [ ] = [ ] ;
159- const invalid : string [ ] = [ ] ;
160- for ( const tx of txs ) {
161- if ( allInvalid . has ( tx . txHash ) ) {
162- invalid . push ( tx . txHash ) ;
163- } else {
164- valid . push ( tx . txHash ) ;
165- }
166- }
167-
168- if ( invalid . length > 0 ) {
169- this . log . verbose ( `Pre-pending filter: ${ invalid . length } invalid, ${ valid . length } valid` , {
170- event : ctx . event ,
171- invalidCount : invalid . length ,
172- validCount : valid . length ,
173- } ) ;
174- }
175-
176- return { valid, invalid } ;
177- }
178-
179110 public updateConfig ( config : TxPoolOptions ) : void {
180111 for ( const rule of this . rules ) {
181112 rule . updateConfig ( config ) ;
0 commit comments