Skip to content

Commit

Permalink
l2geth: cleanly shut down the syncservice (ethereum-optimism#4129)
Browse files Browse the repository at this point in the history
The ss was not previously being shut down cleanly, which
can result in a corrupted db state. This makes the shutdown
more clean.
  • Loading branch information
tynes authored Dec 2, 2022
1 parent 5acb97e commit 0e8652c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-steaks-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/l2geth': patch
---

Close down the syncservice more cleanly
13 changes: 10 additions & 3 deletions l2geth/rollup/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ func (s *SyncService) IsSyncing() bool {
// Stop will close the open channels and cancel the goroutines
// started by this service.
func (s *SyncService) Stop() error {
log.Info("Stopping sync service")
s.scope.Close()
s.chainHeadSub.Unsubscribe()
close(s.chainHeadCh)
Expand All @@ -418,9 +419,15 @@ func (s *SyncService) VerifierLoop() {
log.Info("Starting Verifier Loop", "poll-interval", s.pollInterval, "timestamp-refresh-threshold", s.timestampRefreshThreshold)
t := time.NewTicker(s.pollInterval)
defer t.Stop()
for ; true; <-t.C {
if err := s.verify(); err != nil {
log.Error("Could not verify", "error", err)

for {
select {
case <-t.C:
if err := s.verify(); err != nil {
log.Error("Could not verify", "error", err)
}
case <-s.ctx.Done():
return
}
}
}
Expand Down

0 comments on commit 0e8652c

Please sign in to comment.