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

[TT-1934] event hash collision #1544

Merged
merged 3 commits into from
Jan 9, 2025
Merged

[TT-1934] event hash collision #1544

merged 3 commits into from
Jan 9, 2025

Conversation

Tofel
Copy link
Contributor

@Tofel Tofel commented Jan 9, 2025

After changing Seth logic to debug event using all ABIs I’ve noticed an intermitently failing Seth smoke test, which turned out to be caused by event signature collision. Two contracts have events with the same name and parameters, but one of them has the last parameter non-indexed. And when that contract’s ABI is selected for decoding, then the test fails.

Comparing signature of the whole event is complicated due to various data types, so I will apply a simpler fix:

if we know what contract is at given address, we know its ABI and we don’t need to iterate overall ABIs

if we don’t then we will iterate over all, but apart from signature also check whether number of indexed parameter matches the log (that’s an easy check)


Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes improve contract log decoding by optimizing the event matching process and fixing minor issues in function parameters and comments. These changes aim to enhance performance, accuracy in event log decoding, and clarity in the codebase.

What

  • seth/client.go
    • Added reflect package import for deep equality checks.
    • Refactored decodeContractLogs to use a precomputed map (sigMap) of event signatures to their possible events and ABIs, improving efficiency by avoiding redundant ABI iterations.
    • Introduced buildEventSignatureMap function to create a signature to event and ABI mapping, facilitating faster event log decoding.
    • Improved logging messages for clarity and debuggability.
    • Added checks for logs with no topics and mismatching indexed parameters, ensuring only logs with matching event signatures and correct indexed parameter counts are processed.
    • Implemented logic to handle known contract ABIs directly, reducing unnecessary ABI comparisons.
  • seth/contract_map.go
    • Fixed parameter name in GetContractAddress to accurately reflect its purpose, enhancing code readability and maintainability.
  • tools/breakingchanges/cmd/main.go
    • Corrected a typo and clarified a comment in getLatestTag to improve code documentation and readability.

@Tofel Tofel force-pushed the tt-1934-event-hash-collision branch from 8b00110 to 3858994 Compare January 9, 2025 14:44
@Tofel Tofel marked this pull request as ready for review January 9, 2025 14:57
@Tofel Tofel requested review from sebawo and a team as code owners January 9, 2025 14:57
@cl-sonarqube-production
Copy link

@Tofel Tofel merged commit cdc37af into main Jan 9, 2025
52 checks passed
@Tofel Tofel deleted the tt-1934-event-hash-collision branch January 9, 2025 16:42
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 this pull request may close these issues.

3 participants