Skip to content

Commit

Permalink
Merge pull request #10971 from filecoin-project/fix/10910
Browse files Browse the repository at this point in the history
fix: eth: ensure that the event topics are non-nil
  • Loading branch information
arajasek authored Jun 12, 2023
2 parents 5b31b79 + 739d61c commit 1e29616
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions node/impl/full/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,8 @@ func ethLogFromEvent(entries []types.EventEntry) (data []byte, topics []ethtypes
topicsFoundCount int
dataFound bool
)
// Topics must be non-nil, even if empty. So we might as well pre-allocate for 4 (the max).
topics = make([]ethtypes.EthHash, 0, 4)
for _, entry := range entries {
// Drop events with non-raw topics to avoid mistakes.
if entry.Codec != cid.Raw {
Expand Down
3 changes: 2 additions & 1 deletion node/impl/full/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func TestEthLogFromEvent(t *testing.T) {
data, topics, ok := ethLogFromEvent(nil)
require.True(t, ok)
require.Nil(t, data)
require.Nil(t, topics)
require.Empty(t, topics)
require.NotNil(t, topics)

// basic topic
data, topics, ok = ethLogFromEvent([]types.EventEntry{{
Expand Down

0 comments on commit 1e29616

Please sign in to comment.