Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 committed Oct 30, 2023
1 parent 0f5b503 commit fe215b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
23 changes: 5 additions & 18 deletions vms/proposervm/state_syncable_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
"github.com/ava-labs/avalanchego/vms/proposervm/summary"

safemath "github.com/ava-labs/avalanchego/utils/math"
)

func (vm *VM) StateSyncEnabled(ctx context.Context) (bool, error) {
Expand Down Expand Up @@ -173,37 +171,26 @@ func (vm *VM) BackfillBlocksEnabled(ctx context.Context) (ids.ID, error) {
return ids.Empty, err
}

innerBlk, err := vm.ChainVM.GetBlock(ctx, innerBlkID)
if err != nil {
return ids.Empty, err
}

vm.latestBlockBackfillingHeight = innerBlk.Height()
// vvv This is wrong vvv It returns innerVM BlockID, instead of proposerVM blockID
return innerBlkID, nil
}

func (vm *VM) BackfillBlocks(ctx context.Context, blksBytes [][]byte) (ids.ID, error) {
var (
innerBlksBytes = make([][]byte, 0, len(blksBytes))
minBlocksHeight = vm.latestBlockBackfillingHeight
)

innerBlksBytes := make([][]byte, 0, len(blksBytes))
for i, blkBytes := range blksBytes {
blk, err := vm.parseProposerBlock(ctx, blkBytes)
if err != nil {
return ids.Empty, fmt.Errorf("failed parsing backfilled block, index %d, %w", i, err)
}
if blk.Height() > vm.latestBlockBackfillingHeight {
return ids.Empty, fmt.Errorf("")
}
minBlocksHeight = safemath.Min(minBlocksHeight, blk.Height())

// TODO: introduce validation

if err := blk.acceptOuterBlk(); err != nil {
return ids.Empty, fmt.Errorf("failed indexing backfilled block, index %d, %w", i, err)
}
innerBlksBytes = append(innerBlksBytes, blk.getInnerBlk().Bytes())
}

vm.lastAcceptedHeight = minBlocksHeight
// vvv This is wrong vvv It returns innerVM BlockID, instead of proposerVM blockID
return vm.ssVM.BackfillBlocks(ctx, innerBlksBytes)
}
3 changes: 0 additions & 3 deletions vms/proposervm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ type VM struct {

// lastAcceptedHeight is set to the last accepted PostForkBlock's height.
lastAcceptedHeight uint64

// blockBackfilling attributes
latestBlockBackfillingHeight uint64
}

// New performs best when [minBlkDelay] is whole seconds. This is because block
Expand Down

0 comments on commit fe215b2

Please sign in to comment.