feat(schemas): Permit hex/dec input via uintParam#454
Conversation
|
this is sensible and safe for block numbers, i support. https://datatracker.ietf.org/doc/html/rfc7159#section-6 says
at 12 seconds per block this won't become a problem for the coming 3.42 billion years. |
|
I can say with very high certainty this change will not be included. Even if some clients accept JSON numbers, the official encoding of numbers is a hex string. The rationale for using hex strings goes like this: In some scripting languages, notably JavaScript, all numbers will be handled as 64 bit floats. The practical limit for integers in float64 is somewhere around 2^53. When decoding a JSON payload containing an integer, it will be stored into a float, and this could lead to a misrepresentation of some values. While it may be safe for block numbers specifically, the protocol does define them as a uint64, and it's easier to just treat them like any other number. |
Ok, thanks Felix. That's reasonable |
Description
At present, clients implementing methods that have integer inputs MUST accept hex string formats. This PR adds the
requirement that they MUST also accept JSON
numbertypes for certain methods.Rationale
Some clients permit the use of JSON
numbertype in JSON-RPC requests. Primarily this is a conveniencefeature, as block numbers and transaction indices are usually represented as decimal.
This change standardises this convenience behaviour and is mainly an ergonomics change affecting RPC endpoint users.
Scope
The changes are limited to the parameter in requests. Responses are not modified and still use the hex representation.
Affected methods are those that accept transaction indices, block numbers or filter numbers:
eth_getTransactionByBlockHashAndIndexBlockNumberOrTageth_getTransactionByBlockNumberAndIndexeth_getBlockByNumbereth_getBlockTransactionCountByNumbereth_getUncleCountByBlockNumbereth_estimateGaseth_feeHistoryeth_createAccessListdebug_getRawHeaderdebug_getRawBlockdebug_getRawReceiptsBlockNumberOrTagOrHasheth_calleth_getBalanceeth_getStorageAteth_getTransactionCounteth_getCodeeth_getProofFiltereth_newFiltereth_uninstallFiltereth_getFilterChangeseth_getFilterLogsChanges
uintParamthat is defined as either hex string (current) or decimal number (new)uintwithuintParamfor method parameterseth_getBlockByNumberSecurity
JSON
numbertype does not differentiate between integer, floating point and SI notation.Floating point numbers and SI notation should be rejected as invalid parameters. This is clear with block number
100.5, but should also apply to block numbers100.0and1e2.If clients parse these variants in different ways, end-users will observe different behaviour across clients.