Skip to content

Commit

Permalink
fix(sync): adds missing error log (#965)
Browse files Browse the repository at this point in the history
Co-authored-by: zale144 <[email protected]>
  • Loading branch information
danwt and zale144 authored Jul 19, 2024
1 parent cce7cd3 commit 9da82f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions block/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package block

import (
"context"
"errors"
"fmt"

"code.cloudfoundry.org/go-diodes"
"github.com/dymensionxyz/gerr-cosmos/gerrc"

"github.com/dymensionxyz/dymint/da"
)
Expand Down Expand Up @@ -35,11 +37,14 @@ func (m *Manager) RetrieveLoop(ctx context.Context) (err error) {
func (m *Manager) syncToTargetHeight(targetHeight uint64) error {
for currH := m.State.NextHeight(); currH <= targetHeight; currH = m.State.NextHeight() {
// if we have the block locally, we don't need to fetch it from the DA
err := m.processLocalBlock(currH)
err := m.applyLocalBlock(currH)
if err == nil {
m.logger.Info("Synced from local", "store height", currH, "target height", targetHeight)
continue
}
if !errors.Is(err, gerrc.ErrNotFound) {
m.logger.Error("Apply local block", "err", err)
}

err = m.syncFromDABatch()
if err != nil {
Expand Down Expand Up @@ -80,14 +85,14 @@ func (m *Manager) syncFromDABatch() error {
return nil
}

func (m *Manager) processLocalBlock(height uint64) error {
func (m *Manager) applyLocalBlock(height uint64) error {
block, err := m.Store.LoadBlock(height)
if err != nil {
return err
return fmt.Errorf("load block: %w", gerrc.ErrNotFound)
}
commit, err := m.Store.LoadCommit(height)
if err != nil {
return err
return fmt.Errorf("load commit: %w", gerrc.ErrNotFound)
}
if err := m.validateBlock(block, commit); err != nil {
return fmt.Errorf("validate block from local store: height: %d: %w", height, err)
Expand Down

0 comments on commit 9da82f1

Please sign in to comment.