Skip to content
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
16 changes: 16 additions & 0 deletions vms/proposervm/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func (p *postForkCommonComponents) buildChild(
// is at least the parent's P-Chain height
pChainHeight, err := p.vm.optimalPChainHeight(ctx, parentPChainHeight)
if err != nil {
p.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to calculate optimal P-chain height"),
zap.Stringer("parentID", parentID),
zap.Error(err),
)
return nil, err
}

Expand All @@ -199,6 +204,11 @@ func (p *postForkCommonComponents) buildChild(
proposerID := p.vm.ctx.NodeID
minDelay, err := p.vm.Windower.Delay(ctx, parentHeight+1, parentPChainHeight, proposerID)
if err != nil {
p.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to calculate required timestamp delay"),
zap.Stringer("parentID", parentID),
zap.Error(err),
)
return nil, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that we do not log an error below here if if delay < minDelay { as that can happen normally and is handled gracefully.

Expand Down Expand Up @@ -254,6 +264,12 @@ func (p *postForkCommonComponents) buildChild(
)
}
if err != nil {
p.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to generate proposervm block header"),
zap.Stringer("parentID", parentID),
zap.Stringer("blkID", innerBlock.ID()),
zap.Error(err),
)
Comment on lines +267 to +272
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erroring here technically won't cause an invariant break... However, it's unexpected so I felt like logging an error here still made sense.

return nil, err
}

Expand Down
10 changes: 9 additions & 1 deletion vms/proposervm/post_fork_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"context"
"time"

"go.uber.org/zap"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/choices"
"github.com/ava-labs/avalanchego/vms/proposervm/block"
Expand Down Expand Up @@ -113,13 +115,19 @@ func (*postForkOption) verifyPostForkOption(context.Context, *postForkOption) er
}

func (b *postForkOption) buildChild(ctx context.Context) (Block, error) {
parentID := b.ID()
parentPChainHeight, err := b.pChainHeight(ctx)
if err != nil {
b.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to fetch parent's P-chain height"),
zap.Stringer("parentID", parentID),
zap.Error(err),
)
return nil, err
}
return b.postForkCommonComponents.buildChild(
ctx,
b.ID(),
parentID,
b.Timestamp(),
parentPChainHeight,
)
Expand Down
5 changes: 5 additions & 0 deletions vms/proposervm/pre_fork_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ func (b *preForkBlock) buildChild(ctx context.Context) (Block, error) {
// is at least the minimum height
pChainHeight, err := b.vm.optimalPChainHeight(ctx, b.vm.minimumPChainHeight)
if err != nil {
b.vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to calculate optimal P-chain height"),
zap.Stringer("parentID", parentID),
zap.Error(err),
)
return nil, err
}

Expand Down
5 changes: 5 additions & 0 deletions vms/proposervm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ func (vm *VM) SetState(ctx context.Context, newState snow.State) error {
func (vm *VM) BuildBlock(ctx context.Context) (snowman.Block, error) {
preferredBlock, err := vm.getBlock(ctx, vm.preferred)
if err != nil {
vm.ctx.Log.Error("unexpected build block failure",
zap.String("reason", "failed to fetch preferred block"),
zap.Stringer("parentID", vm.preferred),
zap.Error(err),
)
return nil, err
}

Expand Down