tx_pool: fix early return in remove_transaction_keyimages#10332
Closed
DUQUEredes wants to merge 1 commit intomonero-project:masterfrom
Closed
tx_pool: fix early return in remove_transaction_keyimages#10332DUQUEredes wants to merge 1 commit intomonero-project:masterfrom
DUQUEredes wants to merge 1 commit intomonero-project:masterfrom
Conversation
d19999d to
0ecd98d
Compare
jeffro256
reviewed
Feb 23, 2026
src/cryptonote_core/tx_pool.cpp
Outdated
Comment on lines
+512
to
+518
| if(vi.type() != typeid(txin_to_key)) | ||
| { | ||
| MERROR("unexpected input variant type in remove_transaction_keyimages, transaction id = " << actual_hash); | ||
| all_found = false; | ||
| continue; | ||
| } | ||
| const txin_to_key& txin = boost::get<txin_to_key>(vi); |
Contributor
There was a problem hiding this comment.
Suggested change
| if(vi.type() != typeid(txin_to_key)) | |
| { | |
| MERROR("unexpected input variant type in remove_transaction_keyimages, transaction id = " << actual_hash); | |
| all_found = false; | |
| continue; | |
| } | |
| const txin_to_key& txin = boost::get<txin_to_key>(vi); | |
| const txin_to_key *txin = boost::get<txin_to_key>(&vi); | |
| if (nullptr == txin) | |
| { | |
| MERROR("unexpected input variant type in remove_transaction_keyimages, transaction id = " << actual_hash); | |
| all_found = false; | |
| continue; | |
| } |
Replace CHECK_AND_ASSERT_MES macros with explicit error checks that continue processing remaining inputs instead of returning early. The previous behavior could leave orphaned key images in m_spent_key_images when an error was encountered partway through the input list, since callers already deleted the transaction from the pool before calling this function. Track success via an all_found flag so the return value still indicates whether all key images were found and removed. Also clean up empty key_image sets instead of just failing on them. Resolves the FIXME at the top of the function that noted: "Should probably not return early, however."
0ecd98d to
8f9ad12
Compare
Contributor
|
Please attribute this PR as machine generated code. |
Collaborator
|
Closing due to the fact that this is AI and not disclosed, in fact it appears to have been edited out of the description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tx_pool.cpp:504by replacingCHECK_AND_ASSERT_MES/CHECKED_GET_SPECIFIC_VARIANTmacros with explicit error checks thatcontinueinstead ofreturn falsem_spent_key_imagesall_foundflag so the return value still indicates success/failureContext
The original code had an explicit FIXME from the authors:
When
CHECK_AND_ASSERT_MEStriggers on the Nth input, inputs N+1 through end retain their key images inm_spent_key_imageseven though the transaction itself has already been removed by callers (prune(),take_tx(),remove_stuck_transactions()). These orphaned key images cause false double-spend rejections and are never cleaned up (memory leak).The error conditions occur during node restart (#6175) and Dandelion++ relay failures (#6687).
Test plan
make -j$(nproc))core_tests --generate_and_play_test_data --filter 'txpool_.*')