ERADICATE2 icon indicating copy to clipboard operation
ERADICATE2 copied to clipboard

More thoughts on 0 bytes

Open BlinkyStitt opened this issue 5 years ago • 10 comments

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 avatar May 29 '20 16:05 BlinkyStitt

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

BlinkyStitt avatar May 29 '20 16:05 BlinkyStitt

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

BlinkyStitt avatar May 29 '20 17:05 BlinkyStitt

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?

johguse avatar May 29 '20 18:05 johguse

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

matnad avatar Jun 03 '20 21:06 matnad

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

johguse avatar Jun 03 '20 21:06 johguse

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

matnad avatar Jun 08 '20 12:06 matnad

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

johguse avatar Jun 08 '20 20:06 johguse

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

BlinkyStitt avatar Jun 02 '21 01:06 BlinkyStitt

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 avatar Jul 25 '22 18:07 pokrovskyy

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

pokrovskyy avatar Jul 25 '22 18:07 pokrovskyy