hyperledger / web3j

Lightweight Java and Android library for integration with Ethereum clients
https://www.web3labs.com/web3j-sdk
Other
5.07k stars 1.67k forks source link

Transaction MessageDecode exception #1393

Open lukerQuant opened 3 years ago

lukerQuant commented 3 years ago

Transaction MessageDecode exception

For any unconfirmed transaction in the pending pool, we have been getting a messageDecode exception.

Steps To Reproduce

We are using web3j 4.8.4 and getting a transaction object fo transactions recently been added to the pending pool (example data found here: https://etherscan.io/txsPending?&so)

Expected behavior

Web3js returns a transaction object (with a few params set to null) in this case (https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#gettransaction)

Actual behavior

We get a messageDecode exception for Block Number & Block Hash

Environment

Additional context

Using ethGetTransactionByHash

"message": "JSON mapping problem: io.overledger.standards.transaction.TransactionResponse["transaction"]->io.overledger.standards.transaction.Transaction["nativeData"]->org.web3j.protocol.core.methods.response.Transaction["blockNumber"]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Value must be in format 0x[1-9]+[0-9]* or 0x0 (through reference chain: io.overledger.standards.transaction.TransactionResponse["transaction"]->io.overledger.standards.transaction.Transaction["nativeData"]->org.web3j.protocol.core.methods.response.Transaction["blockNumber"])",

darekurlik commented 1 year ago

H! I've tried that on web3j core version 4.8.1 and 4.9.6 . I was calling txPoolContent() and once then I called getBlockNumber() on pending transaction which resulted in an exception: org.web3j.exceptions.MessageDecodingException: Value must be in format 0x[1-9]+[0-9]* or 0x0 at org.web3j.utils.Numeric.decodeQuantity(Numeric.java:48) at org.web3j.protocol.core.methods.response.Transaction.getBlockNumber(Transaction.java:175)

IMO the assumption is that blockNumber cannot be null and that is why it fails. There need to be a code change in Transaction.getBlockNumber() to either return Optional or null otherwise it will fail.