-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Error decoding bytes parameter for logs emitted by external functions (solc 0.4.x) #891
Comments
If this is only happening on events, the data can be sanitized by padding (right) with 0’s until the length is congruent to 0 mod 32 bytes. I’ll have to think deeper whether this is safe to do in general though. It may be something that I could expose as part of the error recovery API... |
Multiple dynamic types in the event signature data seem to complicate this a little. For example with event a(bytes8 b1, bytes b2, bytes b3) solc 0.4.x data looks like: public
external
Have tried disabling the buffer overrun check in Reader#peekBytes and mis-formatted event data seems to decode ok for a range of inputs (including v. long bytes sequences). [
"0x0000000000000001",
"0xaaaaaaaa",
"0xbbbbbbbb"
] Do you think a "tolerant" flag for abi.decode might be safe for events data generally? |
I will have to look into this more, but I think this might indicate the data is absolutely corrupted and irrecoverable in a generic sense. This makes things, I believe, undecidable. Since there is no way to detect the bug, since one There is no way to tell the first There would need to be a way to flag an event as “handle-external-bug” for the event. But now comes the bigger issue. If a contract used external and public functions with the same event, they could be mixed. Also, if an external caller a public with an emit, does it bug out or work? I guess that matters less, since an external can call and external using call (so usually to another contract). Which means the output could literally have multiple valid (but different) interpretations. With no way to tell which is correct. Also, it’s an np-complete algorithm, but the n is rather small, so that is less a concern to me. The least worst option I can think of, would be adding another type, Hmmmm... |
Just to clarify my understanding. This means that even when the ethers AbiCoder accepted buggy events, it only worked if the |
I'm honestly not sure. In V5, with this Solidity (compiling with 0.4.24) event E(bytes b1, bytes b2, uint u1);
function fire(bytes b1, bytes b2, uint u1) external {
emit E(b1,b2,u1);
} The data looks like this:
Disabling the buffer overflow error in Reader results in a successful decoding
|
Hi, just circling back here... My impression is that the consensus in the companion Web3 issue is that if there was a way to "sweep this under the rug" by allowing non-strict decoding of events (via a flag that disabled the buffer check), people would be ok with it. The decoding seems to work in the identified cases without the overflow check and in general, event data is being formatted correctly by Solidity. @ricmoo Do you have any thoughts about this? |
After quite a bit of experimentation and playing around with possible scenarios, I have come to the conclusion that it seems safe to support events (and only events) using a "loose" I have added support in 5.0.12, but only for the In Solidity 0.4 the ABIv2 was Please try this out and let me know if it works for you. I've tried it against the various examples opened up in all the issues I could find related to non-word-aligned Thanks! :) |
Thanks @ricmoo! |
We Don't have Times to develope manage setting only we Wan setup automaticlly moving forward. If last behind |
Got this exact same error Event data type is a string, which is an Solidity 0.8.7, ethers 5.4.7 using hardhat 2.6.4 and hardhat-ethers 2.0.2. Stack trace:
I Will find a way around it, just wanted to let y'all know this is still happening. |
This error is intentional. It means that there is an invalid UTF-8 string that is being returned by the contract and that it is is unsafe to use for most purposes (such as hashing, using as a key or showing in a UI). If you catch the error, there should be enough information to choose a lossy method of decoding the string, or you may wish to address the root cause. The Make sense? :) |
(Cross-reporting from web3 3544. Apologies in advance if this has already been reported here.)
Using the v5 ABI package, this error
is thrown when decoding events with
bytes
params whenexternal
visibilityExample data for contract above
public_fireEvent
external_fireEvent
external
's bytes data is not right-padded due to a bug reported in ethereum/solidity#3493. The fix shipped with solc 0.5.x.@ricmoo Do you have any views about what could/should be done for this case? 🙂
The text was updated successfully, but these errors were encountered: