diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index 9e40dc68e..3e7d486fd 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -96,10 +96,7 @@ func (c *Client) WaitTillL2ExecutionEngineSynced(ctx context.Context) error { return err } - if progress.SyncProgress != nil || - progress.CurrentBlockID == nil || - progress.HighestBlockID == nil || - progress.CurrentBlockID.Cmp(progress.HighestBlockID) < 0 { + if progress.isSyncing() { log.Info("L2 execution engine is syncing", "progress", progress) return errSyncing } @@ -281,6 +278,14 @@ type L2SyncProgress struct { HighestBlockID *big.Int } +// isSyncing returns true if the L2 execution engine is syncing with L1. +func (p *L2SyncProgress) isSyncing() bool { + return p.SyncProgress != nil || + p.CurrentBlockID == nil || + p.HighestBlockID == nil || + p.CurrentBlockID.Cmp(p.HighestBlockID) < 0 +} + // L2ExecutionEngineSyncProgress fetches the sync progress of the given L2 execution engine. func (c *Client) L2ExecutionEngineSyncProgress(ctx context.Context) (*L2SyncProgress, error) { ctxWithTimeout, cancel := ctxWithTimeoutOrDefault(ctx, defaultTimeout)