Skip to content

Conversation

@cindyyan317
Copy link
Contributor

@cindyyan317 cindyyan317 commented Jul 23, 2024

Similar with this one. #1542
It failed to unique the NFT data as we wish. https://godbolt.org/z/jP384P7rb
It will write incorrect data if
1 mint and burn happen in the same ledger , wrong data write to nf_tokens and uri tables.
2 accept nft offer and burn happen in the same ledger, the isburn maybe incorrect.

I am separating the function to NFTHelper to unittest it.

@cindyyan317 cindyyan317 marked this pull request as draft July 23, 2024 11:08
@cindyyan317 cindyyan317 changed the title Fix nftData unique bug fix: nftData unique bug Jul 23, 2024
@codecov
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.79%. Comparing base (7749424) to head (cb386f1).

Files Patch % Lines
src/etl/NFTHelpers.cpp 81.81% 2 Missing ⚠️
src/etl/impl/LedgerLoader.hpp 0.00% 1 Missing ⚠️
src/rpc/handlers/LedgerEntry.cpp 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1550      +/-   ##
===========================================
+ Coverage    68.74%   68.79%   +0.05%     
===========================================
  Files          239      239              
  Lines         9672     9676       +4     
  Branches      5369     5371       +2     
===========================================
+ Hits          6649     6657       +8     
+ Misses        1629     1622       -7     
- Partials      1394     1397       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cindyyan317 cindyyan317 marked this pull request as ready for review July 23, 2024 14:52
@cindyyan317 cindyyan317 requested a review from shawnxie999 July 23, 2024 15:29
@shawnxie999
Copy link
Collaborator

shawnxie999 commented Jul 23, 2024

1 mint and burn happen in the same ledger , wrong data write to nf_tokens and uri tables.

IMO it should not matter. A NFT that was minted and burned in the ledger could be regarded as "non-existent".

2 accept nft offer and burn happen in the same ledger, the isburn maybe incorrect.

How would it be incorrect? the data from the burn will have the correct owner and isBurn.

(I haven't looked at the code yet)

@cindyyan317
Copy link
Contributor Author

cindyyan317 commented Jul 24, 2024

How would it be incorrect? the data from the burn will have the correct owner and isBurn.

As the test code shows, https://godbolt.org/z/jP384P7rb, the sorted result is not what we expected.
The 1:1 is sorted after 1:2 sometimes. So the burn tx actually can get erased, so only the nftDatas from accept offer tx gets stored in DB.

IMO it should not matter. A NFT that was minted and burned in the ledger could be regarded as "non-existent".

Again, the sorted result is not expected. So the nftDatas from burn tx might get removed.

std::sort requires a comparison with strict weak ordering and A<B, B<C, C<A violates that.

This violation incurs undefined behavior, and in practice, results in some of the worst kinds of undefined behavior.

I agreed the token minted and burned in the same ledger should be considered as "non-existent", however, current implementation will save the data into the DB , right? Maybe this is another bug we shall fix.

kuznetsss
kuznetsss previously approved these changes Jul 24, 2024
Copy link
Collaborator

@kuznetsss kuznetsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few nits, but feel free to ignore.

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small things on top of what others already noticed 👍

Copy link
Collaborator

@kuznetsss kuznetsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@shawnxie999 shawnxie999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for fixing this! 🙇

@cindyyan317 cindyyan317 merged commit 895f3c0 into XRPLF:develop Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants