Conversation
a950be7 to
59ba335
Compare
59ba335 to
7efa1d1
Compare
tequdev
reviewed
Jun 11, 2025
This commit makes several small improvements to the implementation of the `fixProvisionalDoubleThreading` amendment. - The explicit call to `originalThreadingState_.clear()` is removed as it was superfluous. The `ApplyStateTable` is single-use per transaction, so its member map is destroyed along with it. - A comment is added to the `originalThreadingState_` declaration to clarify this lifecycle assumption. - The comment in `PreviousTxn_test.cpp` is updated to explicitly name the `fixProvisionalDoubleThreading` amendment for better readability. - Minor test cleanup, including adjusting the log level and ensuring a final newline.
This commit improves the comment for the `fixProvisionalDoubleThreading` logic within the `threadItem` function. The new comment clarifies *why* the original SLE state is restored in a single batch after the entire provisional metadata pass is complete, rather than immediately within each `threadItem` call. It explicitly notes that `threadItem` can be called multiple times on the same SLE within a single pass, making an immediate restore incorrect. This provides better context for future developers.
This commit refactors the `threadItem` function to simplify its control flow. The previous implementation had three separate branches that all contained a call to `sle->thread()`. This change consolidates them into a single, unconditional call. The conditional logic for saving the original SLE state (when the `fixProvisionalDoubleThreading` amendment is enabled) is now handled in a separate block before the common threading logic, removing redundancy and making the function's intent clearer.
tequdev
previously approved these changes
Jul 6, 2025
Co-authored-by: tequ <git@tequ.dev>
tequdev
previously approved these changes
Jul 7, 2025
RichardAH
reviewed
Jul 7, 2025
RichardAH
reviewed
Jul 7, 2025
RichardAH
reviewed
Jul 7, 2025
- test both with and without fixProvisionalDoubleThreading amendment - verify PreviousTxnID appears in metadata only when fix is enabled - confirm SLE state is correct regardless of the bug - check that PreviousTxnID never appears in PreviousFields - validate account threading works properly in both cases
RichardAH
reviewed
Jul 8, 2025
Collaborator
Author
|
See PR description, but essentially the tests are brittle and hardcoded
to pseudo random ordering that is partially a function of the txn metadata.
|
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.
Fix missing PreviousTxnID in metadata
The issue was that PreviousTxnID and PreviousTxnLgrSeq fields were missing from the metadata of modified objects (discovered when investigating RippleState/trustline modifications). The root cause was that during provisional metadata generation, ApplyStateTable::threadItem() was modifying the original SLE's threading fields. When the same ApplyStateTable was reused for final metadata generation, the comparison between original and modified states didn't detect any change in these fields since both states had already been updated with the new values.
The fix implements a snapshot-and-restore mechanism in ApplyStateTable::threadItem() that:
This ensures the metadata correctly reflects which transaction previously modified the object. The fix is gated behind the new fixProvisionalDoubleThreading amendment to maintain backward compatibility.
Why the testTieBreaking test fails with fixProvisionalDoubleThreading enabled:
The testTieBreaking test in TxQ_test.cpp verifies the transaction queue's pseudo-random ordering mechanism. When transactions have the same fee, TxQ uses the formula txID XOR parentHash to
determine their order.
The critical insight is that the parent hash includes both the state tree AND the transaction tree (which contains metadata). When fixProvisionalDoubleThreading is enabled:
The test was written with specific assumptions about which transactions would be included in which order. Since fixing the metadata bug fundamentally changes the pseudo-random ordering, the test
fails - not because the TxQ is broken, but because the test is brittle and depends on the exact ordering produced by the buggy metadata.
Solution: Rather than rewrite the test to work with both versions, we disabled the fixProvisionalDoubleThreading amendment for this specific test (testTieBreaking(all - fixProvisionalDoubleThreading)), allowing it to
continue validating the TxQ logic without being affected by the metadata fix.