Skip to content

Commit

Permalink
Merge pull request #2058 from OffchainLabs/fix-forwarder-panic
Browse files Browse the repository at this point in the history
Fix sequencer forwarder panic on lack of targets
  • Loading branch information
PlasmaPower authored Dec 27, 2023
2 parents 6932d66 + 1fac15d commit 66d00da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions execution/gethexec/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ func (f *TxForwarder) Initialize(inctx context.Context) error {
f.targets = targets
if len(f.rpcClients) > 0 {
f.enabled.Store(true)
} else if lastError == nil {
return errors.New("no non-empty forwarding targets specified")
} else {
return lastError
}
Expand Down
4 changes: 2 additions & 2 deletions execution/gethexec/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (s *Sequencer) CheckHealth(ctx context.Context) error {
func (s *Sequencer) ForwardTarget() string {
s.activeMutex.Lock()
defer s.activeMutex.Unlock()
if s.forwarder == nil {
if s.forwarder == nil || len(s.forwarder.targets) == 0 {
return ""
}
return s.forwarder.targets[0]
Expand All @@ -497,7 +497,7 @@ func (s *Sequencer) ForwardTo(url string) error {
s.activeMutex.Lock()
defer s.activeMutex.Unlock()
if s.forwarder != nil {
if s.forwarder.targets[0] == url {
if len(s.forwarder.targets) > 0 && s.forwarder.targets[0] == url {
log.Warn("attempted to update sequencer forward target with existing target", "url", url)
return nil
}
Expand Down

0 comments on commit 66d00da

Please sign in to comment.