-
Notifications
You must be signed in to change notification settings - Fork 842
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
Use BitMaps for more gas-efficient minting / transfer / burning #391
Comments
We have considered and discussed that at great lengths internally and with external experts. Unfortunately, this is not a feature we are interested to add. They have removed the storage of the balance data, which makes If you remove that from ERC721A, you will instantly see the minting gas drop by > 20k. The 15k gas savings you see is due to:
Keeping an O(1) |
I've reworked the non Test Feedback The repo's gas tests are incomplete because they use a contract to do batches and thus they're heavily skewed by warm storage memory. In addition to those tests, or instead, should be a set of individual calls to e.g. transferFirst, transferMiddle, transferLast - these 3 provide much more useful information for real world use cases. The results are using slightly different tests to the repo's to allow for some storage warm ups and gas measures. Results Batch of 100(!) Batch of 10 Comments Code readability is unchanged other than Two magic numbers are used from 721Psi - I'd want to know how they're calculated and have a deep set of tests for a large range of token ids (0-10,000,000) including lots of transfers and burns. Code complexity is reasonable as long as the algorithm is explained. All I've done is partition ids into 256 unit blocks, something I'd been playing with, and used 721Psi's clever trick to make that fast (previously I'd not known about this clever flag search trick, kudos to the dev). If anyone wants the code, it's here. A previous commit EDIT: DO NOT USE IN PRODUCTION CODE! You'll want a lot more tests and this was only meant as a draft for testing. Repo Link to lengthless array optimisation PR: |
New (100 batch)
Previous (100 batch)
|
Additional negative - minting gas estimation would be trickier during busy mints. Would need to allow 20k or so above whatever the wallet estimates. |
I came across another 721 implementation, ERC721Psi, which like 721A supports batch minting, but does so at a reduced gas cost (on the order of ~15k less gas for
_mint()
in my benchmarking). It also has cheaper transfers and burn functionality.I thought I would take a look at how to port this over to 721A - but got a bit overwhelmed with the deep optimizations in 721A, like how I would handle the
_packedOwnerships
and_setExtraDataAt()
.I'm happy to contribute / collaborate on a PR - but I feel like it'd be helpful if someone more familiar with the 721A code could take a look at the 721Psi approach and see if:
ERC721Psi Information:
The text was updated successfully, but these errors were encountered: