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

Add a generic interface for ownership storage hitchhiking #323

Merged
merged 12 commits into from
Jun 14, 2022

Conversation

cxkoda
Copy link
Contributor

@cxkoda cxkoda commented Jun 8, 2022

A quick draft implementation for #322 "Allowing general storage hitchhiking".

Comment on lines 648 to 653
_packedOwnerships[tokenId] =
_addressToUint256(from) |
(block.timestamp << BITPOS_START_TIMESTAMP) |
(_extraData(from, address(0), _unpackExtraData(prevOwnershipPacked)) << BITPOS_EXTRA_DATA) |
BITMASK_BURNED |
BITMASK_NEXT_INITIALIZED;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of my new tests for the behavior of _extraData failed for burns on my machine. I was able to track it back to the _addressToUint256(from) part in the above code. Replacing it with (_addressToUint256(from) & ((1 << 160) - 1)) |, so zeroing the leading 96bits solved the issue. I have no idea why _addressToUint256 seems to produce dirty uint256s though. @Vectorized

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the compiler didn't clean the bits.

I have added some changes to ensure that.

@cxkoda cxkoda marked this pull request as ready for review June 12, 2022 22:25
@Vectorized
Copy link
Collaborator

Ok, did some changes:

  1. Merged the latest changes
  2. Mask the address in _packOwnershipData` to prevent dirty bits.
  3. Changed extraData to use the last 24 bits.
  4. Changed all zero address checks to the regular version (for safety reasons).

contracts/ERC721A.sol Outdated Show resolved Hide resolved
contracts/ERC721A.sol Show resolved Hide resolved
@Vectorized Vectorized merged commit c7248cc into chiru-labs:main Jun 14, 2022
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.

3 participants