-
Notifications
You must be signed in to change notification settings - Fork 681
Compatibility: cannot unmarshal hex number with leading zero digits into Go struct #166
Comments
* fix-leadingzeros: Fixing leading zeros for hex encoded quantities in tx trufflesuite#166 Complete removal log reason string on transaction failure
+1 ganache version 1.2.2 mac os
|
It seems that the documentation and the go client code do not agree (i have open 18152 for that). From the code of (Transaction) V,R and S are all quantities:
This makes the current ganache-core (master) code fail since it might produce the following (see value of
I was able to improve the situation by changing in
|
Thanks @gislik for submitting this issue! We have fixed the incorrect encoding of the @elv-gilles, thank you for taking the time to comment here and for also submitting the issue with |
…ite#166) Problem: Go-ethereum client cannot unmarshall json it receives from Ganache's response to 'eth_getBlockByHash' request. Best Known Cause: Go-etherum client interprets R and S as quantities, not data ( as evidenced by big.Int type ) (https://github.com/ethereum/go-ethereum/blob/master/core/types/transaction.go#L54) Temporary solution: Encode R and S as RPC quantity, not data. Justification: At the moment, it is easier to customize Ganache than to propose changes to Go-etherum client. Moreover, it appears strange for the Ethereum JSON RPC Specification to treat R and S as data, not quantities: after all, R and S and integer-like objects in the context of the elliptic curve cryptography, i.e. they admit operations such as addition, subtraction, modulus, etc. Proposal for long-term solution: From remarks above, it appears most natural to change the Ethereum JSON RPC Specification to treat R and S as quantities and change Ganache accordingly.
As go-ethereum ignores fixing the bad on their end, couldn't we, in the meantime, at least optionally enable ganache to serialize the |
@sebastianst, It's very frustrating! We're toying with the idea of adding compatibility modes for nodes in Ganache, allowing for parity, geth, etc compatibility. To do so we'll need to change the architecture of ganache to make something like this maintainable for the long term (this refactoring is currently underway). For now, I'll look into PRing the a fix directly into go-ethereum and then assemble a personal army of my fellow Trufflers, ConsenSys folks, and /r/ethdev redditors to attempt to garner attention from the repo maintainers. I'll also see if I can bring the issue up in the All Core devs call this Friday morning (added it to the agenda here: ethereum/pm#97 (comment)). I've got some other high priority work I'm currently working on so I can't give you an ETA for the PR. However, if you'd like to PR the fix to geth (or the spec) yourself I can still attempt to put the personal army together to try to bring attention to the issue. |
A compatibility mode would be a very nice a clean solution! And thanks for bringing up the issue in the next dev call! I think it makes sense to wait what comes out of the call regarding whether to change the spec or geth's implementation before working on it. In the meantime, Perun will release workaround versions of Ganache: https://github.com/perun-network/ganache/releases/tag/v2.0.2-beta.0-perun-geth-sigfix |
Xref: #432 |
The ethclient fails parsing a transaction received from ganache over RPC.
Expected Behavior
It should parse the JSON response.
Current Behavior
Possible Solution
ethclient expects the following transaction fields to hex encodings of a number without any leading zeros:
nonce
gasPrice
gasLimit
value
input
v
r
s
Therefore a
nonce
of 0x02 will fail to parse but 0x2 will succeed.Steps to Reproduce (for bugs)
ganache-cli -p 9545
).npx truffle console
).web3.eth.sendTransaction({from: web3.eth.accounts[0], to: web3.eth.accounts[1], value: 0})
(nonce 0 will be encoded correctly as0x0
).web3.eth.sendTransaction({from: web3.eth.accounts[0], to: web3.eth.accounts[1], value: 0})
(nonce 1 will be encoded incorrectly as0x01
).Context
According to the JSON-RPC specification hex quantity values should be encoded as follows:
ganache should adhere to the spec.
Your Environment
develop
branch.The text was updated successfully, but these errors were encountered: