ethereum / execution-apis

Collection of APIs provided by Ethereum execution layer clients
Creative Commons Zero v1.0 Universal
908 stars 352 forks source link

Is the pattern for "hex encoded 256 bit unsigned integer" correct? #556

Open fvictorio opened 1 month ago

fvictorio commented 1 month ago

The pattern for hex encoded 256 bit unsigned integer doesn't look correct to me:

^0x([1-9a-f]+[0-9a-f]{0,31})|0$

I think there are two problems here. The first one is that the + there means that one million 1s would be a valid value, which is obviously incorrect.

And if the + is removed, there's still a problem, because then the string has a length of at most 32 hex characters, but for a 32-byte value the max length should be 64 hex characters.

I think the right pattern should be:

^0x([1-9a-f][0-9a-f]{0,63})|0$

I don't know why the test for this works fine though. I haven't checked how these tests are executed, and if they validate the patterns somehow.