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

More thoughts on 0 bytes #5

Open
BlinkyStitt opened this issue May 29, 2020 · 10 comments
Open

More thoughts on 0 bytes #5

BlinkyStitt opened this issue May 29, 2020 · 10 comments

Comments

@BlinkyStitt
Copy link

So it looks like having 5 leading zero bytes is helpful in reducing deployment costs.

Would it be possible to have a pattern that requires the first 5 bytes to be zero and then adds extra score for more zero bytes anywhere else in the address?

@BlinkyStitt
Copy link
Author

Actually, nevermind. Deployment cost ended up being the same.

@BlinkyStitt
Copy link
Author

Sorry. Still thinking this through. This might be true.

@BlinkyStitt BlinkyStitt reopened this May 29, 2020
@johguse
Copy link
Owner

johguse commented May 29, 2020

I'm ready to add functionality, just generalize the required pattern over the hash as much as possible and I'll add it. I.e, is 2 leading zero bytes + 4 additional random zero bytes better than 4 leading zero bytes and 0 additional random zero bytes?

@matnad
Copy link

matnad commented Jun 3, 2020

I think leading zero bytes are always worth a lot more than random zero bytes. But among the addresses found with n leading zero bytes, it should prefer ones where more mixed in zero bytes are found.

Leading Zero Bytes: Weight 20
Random Zero Byte: Weight 1

Reasoning:

  • Leading zero bytes will reduce bytecode that involves the address, making deployments cheaper.
  • Mixed in zero bytes will make calls cheaper when the address is used in the calldata.

@wysenynja

@johguse
Copy link
Owner

johguse commented Jun 3, 2020

Wonderful, I'll implement this tomorrow and upload a new release.

@matnad
Copy link

matnad commented Jun 8, 2020

Thanks, I will definitely be using this once it is available :)

@johguse
Copy link
Owner

johguse commented Jun 8, 2020

Yeah, sorry for the long delay. Been prioritizing day work, will try to get this done during the week.

@BlinkyStitt
Copy link
Author

Will you have any time to work on this soon? If not, could you give some guidance. I'm about ready to deploy some contracts and would like to have lots of leading and mixed 0s

@pokrovskyy
Copy link

I think my comment goes along the lines with this request - I would like to score for zero-bytes. This is important for gas-optimization purposes (each non-zero byte in calldata in 18 gas while zero bytes are only 4, please don't ask why does this matter 😆 )

Currently, it seems --zeros option scores for individual zero characters. However, from gas-optimization standpoint, byte alignment is crucial - eg. 2005 is same as 2525 (2 non-zero bytes), but 0025 is much better (1 zero byte, 1 non-zero byte). Thus, it would be great to optimize for zero-bytes @johguse please. Thanks!

@pokrovskyy
Copy link

lol @johguse ignore my request above, as I went into the code to implement the above, I noticed you actually added that in 41b8c8e 😆 👏 But you should really add that to README.

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

No branches or pull requests

4 participants