Preparation for efficient consecutive burns #447
Merged
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.
Right now, the code assumes that the slot after a burnt slot will always be initialized.
These code changes allow for efficient bulk burning by allowing the slots after a burnt slot to remain uninitialized:
simply set the burn bit of the starting slot to true, and the rest of the uninitialized slots will be considered burnt.
For now, the batch burning logic is not included due to it's complexity.
It is left to the developer to implement their batch burning logic.
This does not affect how the storage slots are written, and will not cause a breaking change.
It simply makes the ownership reading logic able to handle lazy batch burning, which is a superset of what the current code can do.
Changes:
_ownershipIsInitialized
function. This is for the ERC721AQueryable extension to easily find the previous initialized slot._packedOwnershipOf
function will now revert if the slot before an uninitialized slot is burned. Also, reordered the checks for to keep runtime gas costs the same.tokensOfOwner
to use thetokensOfOwnerIn
logic. This is for smaller bytecode and reduced code duplication -- we don't need best runtime gas for these external query functions. Also, thetokensOfOwnerIn
logic requires less modifications to make it capable of handling the uninitialized slots after a burn slot.