remove duplicated txs#142
Conversation
| // There can be a case when a transaction is included in the block, but also marked as invalid, so it will be present | ||
| // in both transactions and invalidTxs maps from transactions pool, with the same execution order. In that case, | ||
| // we want to make sure that we process that transaction only as invalid. |
There was a problem hiding this comment.
can we have also a unit test to cover this?
There was a problem hiding this comment.
we need to check why the outport driver adds the transaction in two pools, I don't think this is correct.
There was a problem hiding this comment.
Pull request overview
This PR refactors how transaction hashes are collected and ordered from the outport.TransactionPool to avoid processing duplicate transactions twice (especially when a tx appears both as valid and invalid), and adds a test scaffold for the new behavior.
Changes:
- Refactors
getTxsWithOrderto deduplicate by tx hash using a map, ensuring invalid entries override valid ones. - Adds a test-only exported wrapper for
getTxsWithOrder. - Adds a unit test that exercises a duplicate tx scenario (via a length assertion).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| process/eventsInterceptor.go | Switches ordered-tx collection to a map-based dedup flow before sorting. |
| process/export_test.go | Exposes a test-only wrapper to call getTxsWithOrder from external tests. |
| process/eventsInterceptor_test.go | Adds a new test case for duplicate tx handling in the pool. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return baseNilEventsDataChecks(eventsData) | ||
| } | ||
|
|
||
| type txsWithOrderExportedFields struct { |
There was a problem hiding this comment.
*optional: export fields of main struct and just export it here, instead of creating separate duplicated struct for testing
This pull request refactors the logic for collecting transactions from the pool to handle duplicate transactions more robustly. The main improvement is ensuring that transactions present in both the valid and invalid pools are only processed as invalid, preventing duplicate processing. The code now uses a map to deduplicate transactions before assembling the ordered list.
Handling of duplicate transactions:
getTxsWithOrderfunction to use a map (txsWithOrderMap) instead of a slice to collect transactions, ensuring each transaction hash appears only once and is processed as invalid if present in both pools.