Skip to content

Commit 761d25c

Browse files
ajsuttonsamlaf
authored andcommitted
op-program: Optimise block by header lookup (ethereum-optimism#13932)
We just requested the header by hash so can skip hashing the header to update the cache and just use the already known hash.
1 parent bf0a5db commit 761d25c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

op-program/client/l2/canon.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ func (o *CanonicalBlockHeaderOracle) GetHeaderByNumber(n uint64) *types.Header {
4848

4949
h := o.earliestIndexedBlock
5050
for h.Number.Uint64() > n {
51-
h = o.blockByHashFn(h.ParentHash).Header()
52-
o.hashByNum[h.Number.Uint64()] = h.Hash()
51+
hash := h.ParentHash
52+
h = o.blockByHashFn(hash).Header()
53+
o.hashByNum[h.Number.Uint64()] = hash
5354
}
5455
o.earliestIndexedBlock = h
5556
return h

0 commit comments

Comments
 (0)