-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce fixNFTokenDirV1
amendment:
#4155
Conversation
o Fixes an off-by-one when determining which NFTokenPage an NFToken belongs on. o Improves handling of packed sets of 32 NFTs with identical low 96-bits. o Fixes marker handling by the account_nfts RPC command. o Tightens constraints of NFTokenPage invariant checks. Adds unit tests to exercise the fixed cases as well as tests for previously untested functionality.
// We need to move the entire contents of this page to | ||
// narr and leave carr empty. This keeps the NFTs | ||
// that must be together all on their own page. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this comment and the next confusing. Below, on lines 168 - 174, we move a (possibly empty) range from narr
to carr
. This comment says "move the contents to narr
and leave carr
empty", when it really means "leave narr
full and carr
empty" (i.e. no move is performed).
The next comment says "leave carr
intact and produce an empty narr
" when it really means "empty the contents of narr
into carr
" (i.e. carr
is not left intact).
After reading this function many many times, I finally understand that narr
means "new array", the array of tokens that will be placed into np
, the "new page", and which will all have a strictly lesser low-96-bits than the tokens in cp
, the "current page" that will be left at its same page key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call on these comments. Thanks for reading carefully. Sorry I messed them up the first time. How's this for the first one?
// We need to leave the entire contents of this page in
// narr so carr stays empty. The new NFT will be
// inserted in carr. This keeps the NFTs that must be
// together all on their own page.
And for the second comment...
// If neither of those conditions apply then put all of
// narr into carr and produce an empty narr where the new NFT
// will be inserted. Leave the split at narr.begin().
Could you compare the expected behavior in these two hypothetical cases - i.e. what would happen?
[Ref #4101] |
Great question @intelliot.
Sure. Let's look at case 2 first:
First of all, the situations that are covered by Problem 1: Depending on the numeric values of the NFTokenIDs that an account already owns, transactions that attempt to mint or acquire NFTokens with specific unusual numeric relationships to the NFTokens the account already owns may fail with a Once the Problem 2: By carefully selecting which NFTokenIDs an account owns, the account can block itself from owning more NFTokens. This requires that the account own at least 32 NFTokens, all 32 of which must be carefully chosen. If this happens then attempting to mint or acquire any NFToken will result in a Once the If we have case 1 ...
then none of the problems described above will occur. Clearly it's preferable to have the |
High Level Overview of Change
NFTokenPage
anNFToken
belongs on.account_nfts
RPC command.NFTokenPage
invariant checks.Also adds unit tests to exercise the fixed cases as well as tests for previously untested functionality.
Context of Change
Certain capabilities for testing NFTokenPage functionality became available after the release of 1.9.0. Those test capabilities showed problems in the existing NFTokenPage functionality in specific corner cases. The
fixNFTokenDirV1
amendment addresses those new corner cases that were found.Without the
fixNFTokenDirV1
amendment the corner cases would (typically) fail with atecINVARIANT_FAILED
. With the amendment the cases either work as hoped or produce a different error, liketecNO_SUITABLE_TOKEN_PAGE
.Type of Change