-
Notifications
You must be signed in to change notification settings - Fork 266
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
JSON RPC methods converting args more consistently #1659
Merged
Vovchyk
merged 5 commits into
master
from
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
Dec 14, 2021
Merged
JSON RPC methods converting args more consistently #1659
Vovchyk
merged 5 commits into
master
from
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
Dec 14, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline:run |
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
November 22, 2021 13:59
bea7685
to
5031e8b
Compare
Vovchyk
previously approved these changes
Nov 23, 2021
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
8 times, most recently
from
November 27, 2021 03:20
910cd05
to
98f847c
Compare
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
November 29, 2021 17:06
9fea3c0
to
5fe2113
Compare
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
2 times, most recently
from
December 2, 2021 14:12
f132b52
to
94e1819
Compare
pipeline:run |
1 similar comment
pipeline:run |
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
December 2, 2021 16:03
94e1819
to
f2638a4
Compare
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
December 13, 2021 17:11
f2638a4
to
7e14047
Compare
pipeline:run |
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
December 14, 2021 13:46
7e14047
to
71cd4f0
Compare
Validating hexadecimal number
rmoreliovlabs
force-pushed
the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
from
December 14, 2021 14:10
71cd4f0
to
60f9f4f
Compare
Kudos, SonarCloud Quality Gate passed! |
Vovchyk
approved these changes
Dec 14, 2021
Vovchyk
deleted the
more-consistent-parsing-for-hex-or-numbers-args-in-endpoints
branch
December 14, 2021 14:45
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are some JSON RPC methods that process transactions with data provided as JSON, like eth_sendTransaction, eth_call, eth_estimateGas (the method eth_sendRawTransaction receives the encoded transaction in an hexadecimal string)
Description
They are some JSON RPC methods that process transactions with data provided as JSON, like
eth_sendTransaction
,eth_call
,eth_estimateGas
(the methodeth_sendRawTransaction
receives the encoded transaction in an hexadecimal string)Let's take one of this arguments:
gas
It comes as a string, like
"1000000"
,"0xa000"
, but also"a000"
is accepted in SOME methods (not all, others reject this value without0x
prefix). This is the inconsistency.In the method
EthModule.call
an internal method is used:
callConstant
:The
args.gas
field is string. ThehexArgs.getGasLimit()
code is:But NOTABLY, the
stringHexToByteArray
method converts the numeric string (ie"1000"
) AS HEXADECIMAL:So, the result is a byte array with
{ 0x10, 0x00 }
This contrasts with the send transaction behavior.
eth_sendTransaction
receives the sameargs
but it processes them differently. Internally, it executesEthModuleTransactionBase.sendTransaction
, that useTypeConverter.stringNumberAsBigInt(args.gas)
to convert the gas string.This is the code of the conversion method:
IT TAKES INTO ACCOUNT THE PREFIX 0x, so,
"1000"
will be parse AS DECIMAL, not hexadecimal.This inconsistency does not affect the consensus, and apparently only affects non-critical methods (query methods).
TO CHECK: other fields conversion, like
args.gasPrice
Extracted from: #1458
Motivation and Context
It will add more consistency at the moment of parsing args from our RPC methods
How Has This Been Tested?
Yes added some tests and also tested on postman
Types of changes
Checklist: