diff --git a/dot/state/epoch.go b/dot/state/epoch.go index 13ede479b8..0aa3decf69 100644 --- a/dot/state/epoch.go +++ b/dot/state/epoch.go @@ -12,7 +12,6 @@ import ( "github.com/ChainSafe/chaindb" "github.com/ChainSafe/gossamer/dot/types" - "github.com/ChainSafe/gossamer/lib/blocktree" "github.com/ChainSafe/gossamer/lib/common" "github.com/ChainSafe/gossamer/pkg/scale" ) @@ -399,7 +398,7 @@ func (nem nextEpochMap[T]) Retrieve(blockState *BlockState, epoch uint64, header // sometimes while moving to the next epoch is possible the header // is not fully imported by the blocktree, in this case we will use // its parent header which migth be already imported. - if errors.Is(err, blocktree.ErrEndNodeNotFound) { + if errors.Is(err, chaindb.ErrKeyNotFound) { parentHeader, err := blockState.GetHeader(header.ParentHash) if err != nil { return nil, fmt.Errorf("cannot get parent header: %w", err) diff --git a/dot/sync/chain_processor.go b/dot/sync/chain_processor.go index 439419dd5a..4ba27803f0 100644 --- a/dot/sync/chain_processor.go +++ b/dot/sync/chain_processor.go @@ -92,7 +92,7 @@ func (s *chainProcessor) processReadyBlocks() { if err := s.processBlockData(*bd); err != nil { // depending on the error, we might want to save this block for later - if !errors.Is(err, errFailedToGetParent) { + if !errors.Is(err, errFailedToGetParent) && !errors.Is(err, blocktree.ErrParentNotFound) { logger.Errorf("block data processing for block with hash %s failed: %s", bd.Hash, err) continue } diff --git a/lib/blocktree/errors.go b/lib/blocktree/errors.go index aace46dcc5..e6a018d4dd 100644 --- a/lib/blocktree/errors.go +++ b/lib/blocktree/errors.go @@ -20,6 +20,7 @@ var ( // ErrEndNodeNotFound is returned if the end of a subchain does not exist ErrEndNodeNotFound = errors.New("end node does not exist") + ErrKeyNotFound = errors.New("key not found") // ErrNilDescendant is returned if calling subchain with a nil node ErrNilDescendant = errors.New("descendant node is nil") diff --git a/lib/blocktree/leaves.go b/lib/blocktree/leaves.go index 549bb07cb8..d217836e32 100644 --- a/lib/blocktree/leaves.go +++ b/lib/blocktree/leaves.go @@ -5,7 +5,7 @@ package blocktree import ( "bytes" - "errors" + "fmt" "sync" "github.com/ChainSafe/gossamer/lib/common" @@ -41,7 +41,7 @@ func (lm *leafMap) store(key Hash, value *node) { func (lm *leafMap) load(key Hash) (*node, error) { v, ok := lm.smap.Load(key) if !ok { - return nil, errors.New("key not found") + return nil, fmt.Errorf("%w: %s", ErrKeyNotFound, key) } return v.(*node), nil