-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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: Event selectors do not distinguish indexed arguments #4168
Comments
Relating to the related problem, see https://etherscan.io/address/0xff1f9e2e0dcbaaa85d9320bca4d82d619eec531e#code. It redefines Transfer without indexed parameters. The Transfer event emitted contains no indexed data, however, the ABI says two of the fields are indexed. Clearly a bug. |
As a note, in the language they are indeed considered clashing:
The naive change is to include |
@axic That's true but shouldn't the same happen with derived contracts? This compiles without warnings: contract C {
event Approve(address a, address b);
}
contract D is C {
event Approve(address indexed a, address b);
} |
I think that is a distinct bug. In a lot of cases The proper review how inheritance should work will be done during the "inheritance review" after 0.5.0. |
Seems easy enough for me. Is this the way we want to solve this issue? |
The safe solution to this would be #11819. |
ran into this error testing ERC721 token contracts in foundry with two different Transfer events, the second has the last parameter as // one contract emits:
event Transfer(address indexed from, address indexed to, uint256 value);
// the other emits:
event Transfer(address indexed from, address indexed to, uint256 indexed id); |
Event selectors are calculated as the hash of the event name and the canonical types of its arguments:
(Source)
This means that the "indexedness" of its arguments is not reflected in the selector. Put another way, each event selector maps to many ways of decoding a log, and in general there is no way to know which is the correct one. (This is true regardless of this issue because of hash collisions, but that's a separate thing, and I believe this is more serious.)
For example, the logs corresponding to
Foo(address a, address indexed b)
would be indistinguishable fromFoo(address indexed a, address b)
. I think this incompatibility should be visible in the event selector.A related problem is that, as of Solidity 0.4.24, redefining an event of a parent contract with different indexedness will not results in errors or warnings.
If we agree that this is a problem with the ABI, we may want to tackle it for 0.5.0, since the fix will probably be backwards-incompatible.
The text was updated successfully, but these errors were encountered: