Skip to content

Fix event parser panic from insufficient topics (#789)#790

Merged
anishnaik merged 1 commit intomasterfrom
fix/event-parser-bounds-check
Feb 6, 2026
Merged

Fix event parser panic from insufficient topics (#789)#790
anishnaik merged 1 commit intomasterfrom
fix/event-parser-bounds-check

Conversation

@anishnaik
Copy link
Copy Markdown
Collaborator

Summary

Fixes panic in event parsing when processing events with insufficient topics. This commonly occurs with vm.etch cheatcode when compiled ABI doesn't match runtime bytecode.

Changes

Added two bounds checks to UnpackEventAndValues in compilation/abiutils/solidity_events.go:

  1. Check Topics array is non-empty (before accessing Topics[0])
  2. Verify sufficient topics exist for indexed arguments (before accessing Topics[i+1])

Both checks return nil on failure, maintaining consistency with existing error handling patterns in the codebase.

Behavior

  • Event unpacking failures now return gracefully without panics
  • Execution traces display <unresolved(topics=[...], data=...)> for unresolvable events
  • No behavior changes for valid events
  • Consistent error handling pattern across codebase

Testing

  • All existing tests pass (go test -v ./...)
  • Code formatted and linted

Fixes #789

🤖 Generated with Claude Code

Add two bounds checks to UnpackEventAndValues to prevent panic when
processing events with insufficient topics:

1. Check Topics array is non-empty before accessing Topics[0]
2. Verify sufficient topics exist for indexed arguments before loop

Both checks return nil to gracefully handle ABI resolution failures,
maintaining consistency with existing error handling patterns.

Fixes panic when vm.etch creates mismatched ABI/bytecode combinations.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@anishnaik anishnaik merged commit 5e9ece7 into master Feb 6, 2026
15 checks passed
@anishnaik anishnaik deleted the fix/event-parser-bounds-check branch February 6, 2026 07:13
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.

[Bug]: Event parser panic when ABI resolution fails during vm.etch deployment

1 participant