Skip to content
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

Incorrect method_id definition for events ABI #156

Closed
k1rill-fedoseev opened this issue Nov 29, 2023 · 2 comments · Fixed by #157
Closed

Incorrect method_id definition for events ABI #156

k1rill-fedoseev opened this issue Nov 29, 2023 · 2 comments · Fixed by #157

Comments

@k1rill-fedoseev
Copy link
Member

ABI spec stores full 32-byte event selectors in topic0 - https://docs.soliditylang.org/en/v0.8.23/abi-spec.html#events, which is a slightly different behavior than the 4-byte selectors used for methods and errors.

Using shorter 4-byte event ids for event signature matching is error-prone and can lead to unnecessary collisions:

$ cast sig 'Transfer(address,address,uint256)'                              
0xddf252ad
$ cast sig 'BeckerrJon(bytes16,bytes4,bytes23,bytes16,bytes1,bytes7,bytes1)'
0xddf252ad
$ cast sig-event 'Transfer(address,address,uint256)'                        
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
$ cast sig-event 'BeckerrJon(bytes16,bytes4,bytes23,bytes16,bytes1,bytes7,bytes1)'
0xddf252ade8bdc6f18de3868ae50ab6e67ee261b7136b3141cd791f1ad4786a79

At last, 4-byte method_id definition in FunctionSelector struct does not make a lot of sense for events, a full 32-byte selector would be more useful in practice.

@ayrat555
Copy link
Collaborator

@k1rill-fedoseev sorry for the late reply. I missed this issue.

do you know what is the behaviour of https://web3js.readthedocs.io/en/v1.2.11/web3-eth-abi.html ? do they store 4 or 32 bytes?

@k1rill-fedoseev
Copy link
Member Author

Web3js parses event signatures as 32 bytes - https://web3js.readthedocs.io/en/v1.2.11/web3-eth-abi.html#encodeeventsignature
They also use full 32-byte signatures for log parsing and decoding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants