Skip to content

Commit 5098a33

Browse files
committed
chore: check for nil pointer
Signed-off-by: Jeremy Letang <me@jeremyletang.com>
1 parent b8d740f commit 5098a33

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

core/datasource/external/ethverifier/l2_verifier_snapshot.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,25 @@ func (s *L2Verifiers) restoreState(ctx context.Context, l2EthOracles *snapshotpb
126126
Time: v.LastBlock.BlockTime,
127127
}
128128
}
129+
// do it once just in case
130+
verifier.restoreLastEthBlock(ctx, lastBlock)
129131

130-
var patchBlock *types.EthBlock
131-
if v.Misc.PatchBlock != nil {
132-
lastBlock = &types.EthBlock{
133-
Height: v.Misc.PatchBlock.BlockHeight,
134-
Time: v.Misc.PatchBlock.BlockTime,
132+
// only run this if the misc exists, which might
133+
// not be the case on a new upgrade after it's
134+
// introduced
135+
if v.Misc != nil {
136+
var patchBlock *types.EthBlock
137+
if v.Misc.PatchBlock != nil {
138+
lastBlock = &types.EthBlock{
139+
Height: v.Misc.PatchBlock.BlockHeight,
140+
Time: v.Misc.PatchBlock.BlockTime,
141+
}
135142
}
136-
}
137143

138-
verifier.restoreLastEthBlock(ctx, lastBlock)
139-
verifier.restorePatchBlock(ctx, patchBlock)
140-
verifier.restoreSeen(v.Misc.Buckets)
144+
verifier.restoreLastEthBlock(ctx, lastBlock)
145+
verifier.restorePatchBlock(ctx, patchBlock)
146+
verifier.restoreSeen(v.Misc.Buckets)
147+
}
141148

142149
pending := []*ethcall.ContractCallEvent{}
143150

0 commit comments

Comments
 (0)