Skip to content

Commit

Permalink
Fix nil pointer in the block header logs
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko authored Feb 16, 2022
1 parent 4fb8746 commit 17a93a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#### Transcoder

### Bug Fixes 🐞
- \#2267 Fix nil pointer in the block header logs (@leszko)

#### General

Expand Down
7 changes: 6 additions & 1 deletion eth/blockwatch/block_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,12 @@ func (w *Watcher) enrichWithL1BlockNumber(header *MiniHeader) (*MiniHeader, erro
if header == nil || header.L1BlockNumber != nil {
return header, nil
}
return w.client.HeaderByHash(header.Hash)
fetchedBlock, err := w.client.HeaderByHash(header.Hash)
if err != nil {
return header, err
}
header.L1BlockNumber = fetchedBlock.L1BlockNumber
return header, nil
}

func isUnknownBlockErr(err error) bool {
Expand Down
2 changes: 2 additions & 0 deletions eth/blockwatch/block_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ func TestEnrichWithL1_One(t *testing.T) {
header := &MiniHeader{
Number: big.NewInt(FakeBlockNumber),
Hash: common.HexToHash(FakeHash),
Logs: []types.Log{logStub},
}
events := []*Event{{BlockHeader: header}}

Expand All @@ -536,6 +537,7 @@ func TestEnrichWithL1_One(t *testing.T) {
assert.Equal(common.HexToHash(FakeHash), res[0].BlockHeader.Hash)
assert.Equal(big.NewInt(FakeBlockNumber), res[0].BlockHeader.Number)
assert.Equal(big.NewInt(FakeL1BlockNumber), res[0].BlockHeader.L1BlockNumber)
assert.Contains(res[0].BlockHeader.Logs, logStub)
}

func TestEnrichWithL1_Multiple(t *testing.T) {
Expand Down

0 comments on commit 17a93a6

Please sign in to comment.