-
Notifications
You must be signed in to change notification settings - Fork 453
Description
Originally posted by @fvictorio, here.
--
Methods like eth_getBlockByNumber expect an Integer value which is defined like this:
eth1.0-specs/json-rpc/spec.json
Line 1791 in ff5f44c
"pattern": "^0x[a-fA-F0-9]+$",
Notice that according to this pattern, a value like "0x0123" should be accepted, but if you try that in geth you get this error:
invalid argument 0: hex number with leading zero digits
In Hardhat we've decided to be as strict as geth with this, because otherwise users running code in Hardhat could find later that the same code doesn't work on geth. But accepting leading zeros makes sense because some tools generate hexadecimal strings padded with zeros (for example, to have an even length). See this Hardhat issue for an scenario where this happens.
I don't know what's the right thing to do here. Ideally geth, and any other client that does this, would be more permissive about it. The alternative is to make the spec iself match the scrict behavior, but I'd rather follow the robustness principle here.