Skip to content
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

Preparation for efficient consecutive burns #447

Merged
merged 7 commits into from
Feb 14, 2023

Conversation

Vectorized
Copy link
Collaborator

@Vectorized Vectorized commented Feb 6, 2023

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:

  • ERC721A
    • New internal _ownershipIsInitialized function. This is for the ERC721AQueryable extension to easily find the previous initialized slot.
    • The _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.
  • ERC721AQueryable
    • Changed tokensOfOwner to use the tokensOfOwnerIn logic. This is for smaller bytecode and reduced code duplication -- we don't need best runtime gas for these external query functions. Also, the tokensOfOwnerIn logic requires less modifications to make it capable of handling the uninitialized slots after a burn slot.

@Vectorized Vectorized merged commit b97b199 into chiru-labs:main Feb 14, 2023
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.

None yet

2 participants