-
Notifications
You must be signed in to change notification settings - Fork 5k
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
ABI objects passed into web3 functions may end up mutated #3748
Comments
Thank you for reporting this :) |
Could you describe what kind of incorrect results you're seeing? |
The short version is that we've got an event which has a The slightly longer version is as follows. We have an event which has a However we then attempt to decode the event ourselves using So, that's the particular reason why our tests are failing, to whatever extent it's relevant. |
@haltman-at Agree it shouldn't mutate the ABI - definitely wrong. The part I don't understand is this
Is it not the case that the decoding returns the expected result per the Solidity docs?, e.g
|
A However, changing the type to So, the event is emitted with the former selector. However, when web3 attempts to decode it -- which it does because we're sending the transaction with So you're right that if web3 got as far as locating the specific ABI item to use in decoding, then yeah, it would decode it as a |
@haltman-at Ah yes I see! Thanks so much for explaining that! |
Is ok if I self-assign here & open a PR (with better tests) fixing this? I am responsible for the errors #3586 |
@cgewecke sure! We're planning a release tongiht, but i can hold off. What do you think a timeline is on this? |
@GregTheGreek Oh! I was thinking end of tomorrow? I don't think the |
could always bump the rc candidate! If you get it in let me know? |
If you get a dist-tag out we can start testing the upgrade on Truffle's side |
Any updates on this? Thanks! |
@cgewecke any news otherwise we can take this on |
Really sorry, this dropped through the cracks. Yes, if you'd like to fix this please go ahead. Un-self-assigning... |
No worries we'll get it done :) |
Hi, do you mind if I pester you again about this? People are bugging us to upgrade, but we still need this fixed... |
OK, I ended up putting up PR #3818 about this! I had trouble completing some of the checklist on my machine, but since this is so simple I hope that's OK. |
Expected behavior
ABI objects (or ABI item objects or ABI parameter objects) that are passed into web3 functions should not be mutated by web3, and should remain valid for use elsewhere without having to worry that web3 has altered them.
Actual behavior
If an ABI parameter object has type
function
, it will be mutated to have typebytes24
instead. As in, the actual object will be altered by a function that definitely shouldn't mutate it.Steps to reproduce the behavior
You will observe that
type
has been mutated, and thus will produce incorrect results if used anywhere else.Further commentary and suggested fix
The problem seems to have been introduced in PR #3586, which attempts to add support for parameters of type
function
, by translating them tobytes24
. However, in doing so, it accidentally mutates the input. The problem can be seen on this line, which mutatestype
rather than creating a modified clone.So, my suggested fix is to change that line to clone rather than mutate.
(The context here, btw, is that we're trying to update Truffle to use Web 1.3.0, and this issue is causing test failures in tests involving
function
ABI parameters.)Environment
Node: v10.22.1
Web3: 1.3.0
The text was updated successfully, but these errors were encountered: