This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
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.
Fix JSON encoding of Log & Receipt; respect data/quantity format types (no leading zeroes for quantities)
As you may already know, the RPC format defines
DATA
andQUANTITY
hex formats:DATA
has leading zeroes, padding length to a multiple of 2QUANTITY
may not have any leading zeroesThe log/receipt JSON encodings in the Ganache RPC turned out to be invalid sometimes, i.e. leading zeroes in quantities. Go-ethereum failed to decode the
eth_getLogs
RPC responses, as it strictly enforces the formatting as defined in the spec.You can find a clear spec of the
DATA
/QUANTITY
properties in the ethereum wiki:Receipt: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt
Logs: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
I changed the
toJSON
methods ofLog
andReceipt
to call theto.rpcQuantityHexString
andto.rpcDataHexString
, to force proper formatting (these methods where already made available for some other RPC formatting).Note that the previous implementation,
to.hex
, didn't pad with zeroes, but also didn't enforce the spec. (E.g. callhex("0x0123")
for a quantity and you get"0x0123"
).