Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging for block verification failure #2224

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion snow/engine/snowman/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,12 @@ func (t *Transitive) addToNonVerifieds(blk snowman.Block) {
// addUnverifiedBlockToConsensus returns whether the block was added and an
// error if one occurred while adding it to consensus.
func (t *Transitive) addUnverifiedBlockToConsensus(ctx context.Context, blk snowman.Block) (bool, error) {
blkID := blk.ID()

// make sure this block is valid
if err := blk.Verify(ctx); err != nil {
t.Ctx.Log.Debug("block verification failed",
zap.Stringer("blkID", blkID),
zap.Error(err),
)

Expand All @@ -976,7 +979,6 @@ func (t *Transitive) addUnverifiedBlockToConsensus(ctx context.Context, blk snow
return false, nil
}

blkID := blk.ID()
t.nonVerifieds.Remove(blkID)
t.nonVerifiedCache.Evict(blkID)
t.metrics.numNonVerifieds.Set(float64(t.nonVerifieds.Len()))
Expand Down
6 changes: 5 additions & 1 deletion vms/proposervm/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ func (p *postForkCommonComponents) Verify(
return err
}
if childPChainHeight > currentPChainHeight {
return errPChainHeightNotReached
return fmt.Errorf("%w: %d > %d",
errPChainHeightNotReached,
childPChainHeight,
currentPChainHeight,
)
}

childHeight := child.Height()
Expand Down
7 changes: 6 additions & 1 deletion vms/proposervm/pre_fork_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package proposervm

import (
"context"
"fmt"
"time"

"go.uber.org/zap"
Expand Down Expand Up @@ -128,7 +129,11 @@ func (b *preForkBlock) verifyPostForkChild(ctx context.Context, child *postForkB
return err
}
if childPChainHeight > currentPChainHeight {
return errPChainHeightNotReached
return fmt.Errorf("%w: %d > %d",
errPChainHeightNotReached,
childPChainHeight,
currentPChainHeight,
)
}
if childPChainHeight < b.vm.minimumPChainHeight {
return errPChainHeightTooLow
Expand Down
Loading