Skip to content

Commit

Permalink
Remove verify height index (#2634)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Buttolph <[email protected]>
  • Loading branch information
aaronbuchwald and StephenButtolph authored Mar 17, 2024
1 parent a18c4a3 commit 6a3661b
Show file tree
Hide file tree
Showing 30 changed files with 370 additions and 1,726 deletions.
810 changes: 367 additions & 443 deletions proto/pb/vm/vm.pb.go

Large diffs are not rendered by default.

37 changes: 0 additions & 37 deletions proto/pb/vm/vm_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions proto/vm/vm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ service VM {
rpc BatchedParseBlock(BatchedParseBlockRequest) returns (BatchedParseBlockResponse);

// HeightIndexedChainVM
rpc VerifyHeightIndex(google.protobuf.Empty) returns (VerifyHeightIndexResponse);
rpc GetBlockIDAtHeight(GetBlockIDAtHeightRequest) returns (GetBlockIDAtHeightResponse);

// StateSyncableVM
Expand Down Expand Up @@ -101,8 +100,7 @@ enum Error {
ERROR_UNSPECIFIED = 0;
ERROR_CLOSED = 1;
ERROR_NOT_FOUND = 2;
ERROR_HEIGHT_INDEX_INCOMPLETE = 3;
ERROR_STATE_SYNC_NOT_IMPLEMENTED = 4;
ERROR_STATE_SYNC_NOT_IMPLEMENTED = 3;
}

message InitializeRequest {
Expand Down Expand Up @@ -334,10 +332,6 @@ message BatchedParseBlockResponse {
repeated ParseBlockResponse response = 1;
}

message VerifyHeightIndexResponse {
Error err = 1;
}

message GetBlockIDAtHeightRequest {
uint64 height = 1;
}
Expand Down
14 changes: 0 additions & 14 deletions snow/engine/avalanche/vertex/mock_vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions snow/engine/snowman/block/mock_chain_vm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions snow/engine/snowman/block/test_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var (
errParseBlock = errors.New("unexpectedly called ParseBlock")
errGetBlock = errors.New("unexpectedly called GetBlock")
errLastAccepted = errors.New("unexpectedly called LastAccepted")
errVerifyHeightIndex = errors.New("unexpectedly called VerifyHeightIndex")
errGetBlockIDAtHeight = errors.New("unexpectedly called GetBlockIDAtHeight")

_ ChainVM = (*TestVM)(nil)
Expand All @@ -34,15 +33,13 @@ type TestVM struct {
CantGetBlock,
CantSetPreference,
CantLastAccepted,
CantVerifyHeightIndex,
CantGetBlockIDAtHeight bool

BuildBlockF func(context.Context) (snowman.Block, error)
ParseBlockF func(context.Context, []byte) (snowman.Block, error)
GetBlockF func(context.Context, ids.ID) (snowman.Block, error)
SetPreferenceF func(context.Context, ids.ID) error
LastAcceptedF func(context.Context) (ids.ID, error)
VerifyHeightIndexF func(context.Context) error
GetBlockIDAtHeightF func(ctx context.Context, height uint64) (ids.ID, error)
}

Expand Down Expand Up @@ -106,16 +103,6 @@ func (vm *TestVM) LastAccepted(ctx context.Context) (ids.ID, error) {
return ids.ID{}, errLastAccepted
}

func (vm *TestVM) VerifyHeightIndex(ctx context.Context) error {
if vm.VerifyHeightIndexF != nil {
return vm.VerifyHeightIndexF(ctx)
}
if vm.CantVerifyHeightIndex && vm.T != nil {
require.FailNow(vm.T, errVerifyHeightIndex.Error())
}
return errVerifyHeightIndex
}

func (vm *TestVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) {
if vm.GetBlockIDAtHeightF != nil {
return vm.GetBlockIDAtHeightF(ctx, height)
Expand Down
16 changes: 0 additions & 16 deletions snow/engine/snowman/block/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ package block

import (
"context"
"errors"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/common"
)

// ErrIndexIncomplete is used to indicate that the VM is currently repairing its
// index.
//
// TODO: Remove after v1.11.x activates.
var ErrIndexIncomplete = errors.New("query failed because height index is incomplete")

// ChainVM defines the required functionality of a Snowman VM.
//
// A Snowman VM is responsible for defining the representation of state,
Expand Down Expand Up @@ -56,15 +49,6 @@ type ChainVM interface {
// returned.
LastAccepted(context.Context) (ids.ID, error)

// VerifyHeightIndex should return:
// - nil if the height index is available.
// - ErrIndexIncomplete if the height index is not currently available.
// - Any other non-standard error that may have occurred when verifying the
// index.
//
// TODO: Remove after v1.11.x activates.
VerifyHeightIndex(context.Context) error

// GetBlockIDAtHeight returns:
// - The ID of the block that was accepted with [height].
// - database.ErrNotFound if the [height] index is unknown.
Expand Down
4 changes: 0 additions & 4 deletions vms/avm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,6 @@ func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, erro
return vm.state.GetBlockIDAtHeight(height)
}

func (*VM) VerifyHeightIndex(context.Context) error {
return nil
}

/*
******************************************************************************
*********************************** DAG VM ***********************************
Expand Down
4 changes: 0 additions & 4 deletions vms/example/xsvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ func (vm *VM) BuildBlockWithContext(ctx context.Context, blockContext *smblock.C
return vm.builder.BuildBlock(ctx, blockContext)
}

func (*VM) VerifyHeightIndex(context.Context) error {
return nil
}

func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) {
return state.GetBlockIDByHeight(vm.db, height)
}
2 changes: 0 additions & 2 deletions vms/metervm/block_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type blockMetrics struct {
accept,
reject,
// Height metrics
verifyHeightIndex,
getBlockIDAtHeight,
// Block verification with context metrics
shouldVerifyWithContext,
Expand Down Expand Up @@ -69,7 +68,6 @@ func (m *blockMetrics) Initialize(
m.shouldVerifyWithContext = newAverager(namespace, "should_verify_with_context", reg, &errs)
m.verifyWithContext = newAverager(namespace, "verify_with_context", reg, &errs)
m.verifyWithContextErr = newAverager(namespace, "verify_with_context_err", reg, &errs)
m.verifyHeightIndex = newAverager(namespace, "verify_height_index", reg, &errs)
m.getBlockIDAtHeight = newAverager(namespace, "get_block_id_at_height", reg, &errs)

if supportsBlockBuildingWithContext {
Expand Down
8 changes: 0 additions & 8 deletions vms/metervm/block_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,6 @@ func (vm *blockVM) LastAccepted(ctx context.Context) (ids.ID, error) {
return lastAcceptedID, err
}

func (vm *blockVM) VerifyHeightIndex(ctx context.Context) error {
start := vm.clock.Time()
err := vm.ChainVM.VerifyHeightIndex(ctx)
end := vm.clock.Time()
vm.blockMetrics.verifyHeightIndex.Observe(float64(end.Sub(start)))
return err
}

func (vm *blockVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) {
start := vm.clock.Time()
blockID, err := vm.ChainVM.GetBlockIDAtHeight(ctx, height)
Expand Down
4 changes: 0 additions & 4 deletions vms/platformvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ func (vm *VM) Logger() logging.Logger {
return vm.ctx.Log
}

func (*VM) VerifyHeightIndex(_ context.Context) error {
return nil
}

func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) {
return vm.state.GetBlockIDAtHeight(height)
}
Expand Down
3 changes: 0 additions & 3 deletions vms/proposervm/batched_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,9 +1031,6 @@ func initTestRemoteProposerVM(
return nil, errUnknownBlock
}
}
coreVM.VerifyHeightIndexF = func(context.Context) error {
return nil
}

proVM := New(
coreVM,
Expand Down
30 changes: 0 additions & 30 deletions vms/proposervm/block_server.go

This file was deleted.

Loading

0 comments on commit 6a3661b

Please sign in to comment.