diff --git a/block/manager.go b/block/manager.go index bb5195200..3f4f0a019 100644 --- a/block/manager.go +++ b/block/manager.go @@ -172,12 +172,12 @@ func (m *Manager) Start(ctx context.Context) error { return fmt.Errorf("sync block manager from settlement: %w", err) } // check if sequencer in the middle of rotation - nextSeqAddr, err := m.MissingLastBatch() + nextSeqAddr, missing, err := m.MissingLastBatch() if err != nil { - return fmt.Errorf("missing last batch: %w", err) + return fmt.Errorf("checking if missing last batch: %w", err) } // if sequencer is in the middle of rotation, complete rotation instead of running the main loop - if nextSeqAddr != "" { + if missing { m.handleRotationReq(ctx, nextSeqAddr) return nil } diff --git a/block/sequencers.go b/block/sequencers.go index a3aa6a283..c7ae87e0b 100644 --- a/block/sequencers.go +++ b/block/sequencers.go @@ -59,7 +59,6 @@ func (m *Manager) MonitorSequencerRotation(ctx context.Context, rotateC chan str // for this case, the old proposer counts as "sequencer" as well, so he'll be able to submit the last state update. func (m *Manager) IsProposer() bool { localProposerKey, _ := m.LocalKey.GetPublic().Raw() - l2Proposer := m.GetProposerPubKey().Bytes() var expectedHubProposer []byte @@ -70,22 +69,20 @@ func (m *Manager) IsProposer() bool { } // check rotation in progress (I'm the proposer, but needs to complete rotation) -func (m *Manager) MissingLastBatch() (string, error) { +func (m *Manager) MissingLastBatch() (string, bool, error) { localProposerKey, _ := m.LocalKey.GetPublic().Raw() next, err := m.SLClient.CheckRotationInProgress() if err != nil { - return "", err + return "", false, err } if next == nil { - return "", nil + return "", false, nil } // rotation in progress, // check if we're the old proposer and needs to complete rotation - if !bytes.Equal(next.PublicKey.Bytes(), localProposerKey) { - return next.Address, nil - } - - return "", nil + curr := m.SLClient.GetProposer() + isProposer := bytes.Equal(curr.PublicKey.Bytes(), localProposerKey) + return next.Address, isProposer, nil } // handleRotationReq completes the rotation flow once a signal is received from the SL diff --git a/types/sequencer.go b/types/sequencer.go index cd466c71a..776cdf9ff 100644 --- a/types/sequencer.go +++ b/types/sequencer.go @@ -44,7 +44,7 @@ func (s *SequencerSet) SetProposer(proposer *types.Validator) { s.ProposerHash = GetHash(proposer) // Add proposer to bonded set if not already present - if !s.HasAddress(proposer.Address) { + if proposer != nil && !s.HasAddress(proposer.Address) { s.Sequencers = append(s.Sequencers, proposer) } }