Merge pull request #10971 from filecoin-project/fix/10910

fix: eth: ensure that the event topics are non-nil
This commit is contained in:
Aayush Rajasekaran
2023-06-12 16:37:41 -05:00
committed by GitHub
2 changed files with 4 additions and 1 deletions
+2
View File
@@ -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 {
+2 -1
View File
@@ -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{{