github.com/MetalBlockchain/metalgo@v1.11.9/snow/engine/snowman/block/state_syncable_vm.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package block
     5  
     6  import (
     7  	"context"
     8  	"errors"
     9  )
    10  
    11  var ErrStateSyncableVMNotImplemented = errors.New("vm does not implement StateSyncableVM interface")
    12  
    13  // StateSyncableVM contains the functionality to allow VMs to sync to a given
    14  // state, rather then boostrapping from genesis.
    15  type StateSyncableVM interface {
    16  	// StateSyncEnabled indicates whether the state sync is enabled for this VM.
    17  	// If StateSyncableVM is not implemented, as it may happen with a wrapper
    18  	// VM, StateSyncEnabled should return false, nil
    19  	StateSyncEnabled(context.Context) (bool, error)
    20  
    21  	// GetOngoingSyncStateSummary returns an in-progress state summary if it
    22  	// exists.
    23  	//
    24  	// The engine can then ask the network if the ongoing summary is still
    25  	// supported, thus helping the VM decide whether to continue an in-progress
    26  	// sync or start over.
    27  	//
    28  	// Returns database.ErrNotFound if there is no in-progress sync.
    29  	GetOngoingSyncStateSummary(context.Context) (StateSummary, error)
    30  
    31  	// GetLastStateSummary returns the latest state summary.
    32  	//
    33  	// Returns database.ErrNotFound if no summary is available.
    34  	GetLastStateSummary(context.Context) (StateSummary, error)
    35  
    36  	// ParseStateSummary parses a state summary out of [summaryBytes].
    37  	ParseStateSummary(ctx context.Context, summaryBytes []byte) (StateSummary, error)
    38  
    39  	// GetStateSummary retrieves the state summary that was generated at height
    40  	// [summaryHeight].
    41  	//
    42  	// Returns database.ErrNotFound if no summary is available at
    43  	// [summaryHeight].
    44  	GetStateSummary(ctx context.Context, summaryHeight uint64) (StateSummary, error)
    45  }