Closed Destiner closed 5 years ago
I suspect that these transactions were simply buggy and Solidity allowed them to execute because it ignores the data that should be 0s. In fact, I think it's valuable that eth-abi noticed that these are malformed.
In this example, I would bet that the _tradeID
was incorrectly encoded in this example transaction. Note that if you take the 32 bytes supplied and decode them as if they were UTF-8, you get this:
In [9]: Web3.toText(0x3039616566623164303162643464343438333039393266386631323132303631)
Out[9]: '09aefb1d01bd4d44830992f8f1212061'
It's extremely unlikely that a set of random data would decode to a valid hex string. (and since it started as 32 bytes, once it was decoded, you get 16 bytes) So I think that eth-abi actually helped you spot a bug in someone's transaction.
The transaction didn't fail because it shortcuts and exits cleanly if the tradeId
is missing. So however Solidity decided to interpret that first argument, chances are it was simply discarded as an invalid trade id and returned immediately.
@carver 🥇 Yes, what you said. Sorry I didn't see this until today. @Destiner If a value is bytes16
, then it must have 16 trailing padding bytes of \x00
in order to be spec compliant. This implies there must be some bug elsewhere in the software stack that is supporting that contract. I'll go ahead and close this since it's not an issue with eth-abi.
What was wrong?
I tried to parse input of transaction and it gave me an error. Tx hash is 0xfc70289a7d33238c1d45fa62b7cd1f150e8951264025f782f87c5ad09b5838c9.
Source of this contract is publicly known, and both Etherscan and 4bytes show the same signature for that method_id (0x35adc0c5).
However, when I try to decode that particular transaction with that ABI (
bytes16,address,address,uint256,uint16
), the eth-abi gives me an error. I believe that this is due to the fact that the first argument is bytes16 while the input looks like bytes32. Moreover, replacing last 16 bytes with zeroes solves the problem.Click to expand
--------------------------------------------------------------------------- NonEmptyPaddingBytes Traceback (most recent call last) ```Here's another transaction from the same contract that can't be parsed: 0x035b1e59b573ab7f4ec05f235c01b8ac0304c995e542d52ad321b4e2ea796315
Here's another transaction from similar contract that can't be parsed: 0x7977c27c9312ef4d98f5e42ff0e2774157af4fc3664e5211589721cacd4fbce0
All other transactions from these two contracts work fine.
How can it be fixed?
Seems like eth-abi should accept that input even though it seems malformed.