evm

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: GPL-3.0, LGPL-3.0 Imports: 81 Imported by: 0

README

EVM Package

The EVM package implements the AvalancheGo VM interface.

VM

The VM creates the Ethereum backend and provides basic block building, parsing, and retrieval logic to the consensus engine.

APIs

The VM creates APIs for the node through the function CreateHandlers(). CreateHandlers returns the Service struct to serve Subnet-EVM specific APIs. Additionally, the Ethereum backend APIs are also returned at the /rpc extension.

Block Handling

The VM implements buildBlock, parseBlock, and getBlock and uses the chain package from AvalancheGo to construct a metered state, which uses these functions to implement an efficient caching layer and maintain the required invariants for blocks that get returned to the consensus engine.

To do this, the VM uses a modified version of the Ethereum RLP block type here and uses the core package's BlockChain type here to handle the insertion and storage of blocks into the chain.

Block

The Block type implements the AvalancheGo ChainVM Block interface. The key functions for this interface are Verify(), Accept(), Reject(), and Status().

The Block type wraps the stateless block type here and implements these functions to allow the consensus engine to verify blocks as valid, perform consensus, and mark them as accepted or rejected. See the documentation in AvalancheGo for the more detailed VM invariants that are maintained here.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ID this VM should be referenced by
	IDStr = "subnetevm"
	ID    = ids.ID{'s', 'u', 'b', 'n', 'e', 't', 'e', 'v', 'm'}
)
View Source
var (
	// GitCommit is set by the build script
	GitCommit string
	// Version is the version of Subnet EVM
	Version string = "v0.6.3"
)
View Source
var (
	ErrSnapshotNotSupported = errors.New("snapshot is not supported")
)

Functions

func NewSharedMemoryWriter

func NewSharedMemoryWriter() *sharedMemoryWriter

func SubnetEVMJSONFormat

func SubnetEVMJSONFormat(alias string) log.Format

func SubnetEVMTermFormat

func SubnetEVMTermFormat(alias string) log.Format

Types

type Admin

type Admin struct {
	// contains filtered or unexported fields
}

Admin is the API service for admin API calls

func NewAdminService

func NewAdminService(vm *VM, performanceDir string) *Admin

func (*Admin) GetVMConfig

func (p *Admin) GetVMConfig(_ *http.Request, _ *struct{}, reply *ConfigReply) error

func (*Admin) LockProfile

func (p *Admin) LockProfile(_ *http.Request, _ *struct{}, _ *api.EmptyReply) error

LockProfile runs a mutex profile writing to the specified file

func (*Admin) MemoryProfile

func (p *Admin) MemoryProfile(_ *http.Request, _ *struct{}, _ *api.EmptyReply) error

MemoryProfile runs a memory profile writing to the specified file

func (*Admin) SetLogLevel

func (p *Admin) SetLogLevel(_ *http.Request, args *SetLogLevelArgs, reply *api.EmptyReply) error

func (*Admin) StartCPUProfiler

func (p *Admin) StartCPUProfiler(_ *http.Request, _ *struct{}, _ *api.EmptyReply) error

StartCPUProfiler starts a cpu profile writing to the specified file

func (*Admin) StopCPUProfiler

func (p *Admin) StopCPUProfiler(r *http.Request, _ *struct{}, _ *api.EmptyReply) error

StopCPUProfiler stops the cpu profile

type Batch

type Batch struct{ database.Batch }

Batch implements ethdb.Batch

func (Batch) Replay

func (batch Batch) Replay(w ethdb.KeyValueWriter) error

Replay implements ethdb.Batch

func (Batch) ValueSize

func (batch Batch) ValueSize() int

ValueSize implements ethdb.Batch

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block implements the snowman.Block interface

func (*Block) Accept

func (b *Block) Accept(context.Context) error

Accept implements the snowman.Block interface

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes implements the snowman.Block interface

func (*Block) Height

func (b *Block) Height() uint64

Height implements the snowman.Block interface

func (*Block) ID

func (b *Block) ID() ids.ID

ID implements the snowman.Block interface

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent implements the snowman.Block interface

func (*Block) Reject

func (b *Block) Reject(context.Context) error

Reject implements the snowman.Block interface

func (*Block) SetStatus

func (b *Block) SetStatus(status choices.Status)

SetStatus implements the InternalBlock interface allowing ChainState to set the status on an existing block

func (*Block) ShouldVerifyWithContext

func (b *Block) ShouldVerifyWithContext(context.Context) (bool, error)

ShouldVerifyWithContext implements the block.WithVerifyContext interface

func (*Block) Status

func (b *Block) Status() choices.Status

Status implements the snowman.Block interface

func (*Block) String

func (b *Block) String() string

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp implements the snowman.Block interface

func (*Block) Verify

func (b *Block) Verify(context.Context) error

Verify implements the snowman.Block interface

func (*Block) VerifyWithContext

func (b *Block) VerifyWithContext(ctx context.Context, proposerVMBlockCtx *block.Context) error

VerifyWithContext implements the block.WithVerifyContext interface

type BlockValidator

type BlockValidator interface {
	SyntacticVerify(b *Block, rules params.Rules) error
}

func NewBlockValidator

func NewBlockValidator() BlockValidator

type BuildGenesisArgs

type BuildGenesisArgs struct {
	GenesisData *core.Genesis       `json:"genesisData"`
	Encoding    formatting.Encoding `json:"encoding"`
}

BuildGenesisArgs are arguments for BuildGenesis

type BuildGenesisReply

type BuildGenesisReply struct {
	GenesisBytes string              `json:"genesisBytes"`
	Encoding     formatting.Encoding `json:"encoding"`
}

BuildGenesisReply is the reply from BuildGenesis

type Client

type Client interface {
	StartCPUProfiler(ctx context.Context, options ...rpc.Option) error
	StopCPUProfiler(ctx context.Context, options ...rpc.Option) error
	MemoryProfile(ctx context.Context, options ...rpc.Option) error
	LockProfile(ctx context.Context, options ...rpc.Option) error
	SetLogLevel(ctx context.Context, level log.Lvl, options ...rpc.Option) error
	GetVMConfig(ctx context.Context, options ...rpc.Option) (*Config, error)
}

Client interface for interacting with EVM chain

func NewCChainClient

func NewCChainClient(uri string) Client

NewCChainClient returns a Client for interacting with the C Chain

func NewClient

func NewClient(uri, chain string) Client

NewClient returns a Client for interacting with EVM chain

type Config

type Config struct {
	// Airdrop
	AirdropFile string `json:"airdrop"`

	// Subnet EVM APIs
	SnowmanAPIEnabled bool   `json:"snowman-api-enabled"`
	AdminAPIEnabled   bool   `json:"admin-api-enabled"`
	AdminAPIDir       string `json:"admin-api-dir"`
	WarpAPIEnabled    bool   `json:"warp-api-enabled"`

	// EnabledEthAPIs is a list of Ethereum services that should be enabled
	// If none is specified, then we use the default list [defaultEnabledAPIs]
	EnabledEthAPIs []string `json:"eth-apis"`

	// Continuous Profiler
	ContinuousProfilerDir       string   `json:"continuous-profiler-dir"`       // If set to non-empty string creates a continuous profiler
	ContinuousProfilerFrequency Duration `json:"continuous-profiler-frequency"` // Frequency to run continuous profiler if enabled
	ContinuousProfilerMaxFiles  int      `json:"continuous-profiler-max-files"` // Maximum number of files to maintain

	// API Gas/Price Caps
	RPCGasCap   uint64  `json:"rpc-gas-cap"`
	RPCTxFeeCap float64 `json:"rpc-tx-fee-cap"`

	// Cache settings
	TrieCleanCache            int `json:"trie-clean-cache"`            // Size of the trie clean cache (MB)
	TrieDirtyCache            int `json:"trie-dirty-cache"`            // Size of the trie dirty cache (MB)
	TrieDirtyCommitTarget     int `json:"trie-dirty-commit-target"`    // Memory limit to target in the dirty cache before performing a commit (MB)
	TriePrefetcherParallelism int `json:"trie-prefetcher-parallelism"` // Max concurrent disk reads trie prefetcher should perform at once
	SnapshotCache             int `json:"snapshot-cache"`              // Size of the snapshot disk layer clean cache (MB)

	// Eth Settings
	Preimages      bool `json:"preimages-enabled"`
	SnapshotWait   bool `json:"snapshot-wait"`
	SnapshotVerify bool `json:"snapshot-verification-enabled"`

	// Pruning Settings
	Pruning                         bool    `json:"pruning-enabled"`                    // If enabled, trie roots are only persisted every 4096 blocks
	AcceptorQueueLimit              int     `json:"accepted-queue-limit"`               // Maximum blocks to queue before blocking during acceptance
	CommitInterval                  uint64  `json:"commit-interval"`                    // Specifies the commit interval at which to persist EVM and atomic tries.
	AllowMissingTries               bool    `json:"allow-missing-tries"`                // If enabled, warnings preventing an incomplete trie index are suppressed
	PopulateMissingTries            *uint64 `json:"populate-missing-tries,omitempty"`   // Sets the starting point for re-populating missing tries. Disables re-generation if nil.
	PopulateMissingTriesParallelism int     `json:"populate-missing-tries-parallelism"` // Number of concurrent readers to use when re-populating missing tries on startup.
	PruneWarpDB                     bool    `json:"prune-warp-db-enabled"`              // Determines if the warpDB should be cleared on startup

	// Metric Settings
	MetricsExpensiveEnabled bool `json:"metrics-expensive-enabled"` // Debug-level metrics that might impact runtime performance

	// API Settings
	LocalTxsEnabled bool `json:"local-txs-enabled"`

	TxPoolPriceLimit   uint64   `json:"tx-pool-price-limit"`
	TxPoolPriceBump    uint64   `json:"tx-pool-price-bump"`
	TxPoolAccountSlots uint64   `json:"tx-pool-account-slots"`
	TxPoolGlobalSlots  uint64   `json:"tx-pool-global-slots"`
	TxPoolAccountQueue uint64   `json:"tx-pool-account-queue"`
	TxPoolGlobalQueue  uint64   `json:"tx-pool-global-queue"`
	TxPoolLifetime     Duration `json:"tx-pool-lifetime"`

	APIMaxDuration           Duration      `json:"api-max-duration"`
	WSCPURefillRate          Duration      `json:"ws-cpu-refill-rate"`
	WSCPUMaxStored           Duration      `json:"ws-cpu-max-stored"`
	MaxBlocksPerRequest      int64         `json:"api-max-blocks-per-request"`
	AllowUnfinalizedQueries  bool          `json:"allow-unfinalized-queries"`
	AllowUnprotectedTxs      bool          `json:"allow-unprotected-txs"`
	AllowUnprotectedTxHashes []common.Hash `json:"allow-unprotected-tx-hashes"`

	// Keystore Settings
	KeystoreDirectory             string `json:"keystore-directory"` // both absolute and relative supported
	KeystoreExternalSigner        string `json:"keystore-external-signer"`
	KeystoreInsecureUnlockAllowed bool   `json:"keystore-insecure-unlock-allowed"`

	// Gossip Settings
	PushGossipPercentStake    float64          `json:"push-gossip-percent-stake"`
	PushGossipNumValidators   int              `json:"push-gossip-num-validators"`
	PushGossipNumPeers        int              `json:"push-gossip-num-peers"`
	PushRegossipNumValidators int              `json:"push-regossip-num-validators"`
	PushRegossipNumPeers      int              `json:"push-regossip-num-peers"`
	PushGossipFrequency       Duration         `json:"push-gossip-frequency"`
	PullGossipFrequency       Duration         `json:"pull-gossip-frequency"`
	RegossipFrequency         Duration         `json:"regossip-frequency"`
	PriorityRegossipAddresses []common.Address `json:"priority-regossip-addresses"`

	// Log
	LogLevel      string `json:"log-level"`
	LogJSONFormat bool   `json:"log-json-format"`

	// Address for Tx Fees (must be empty if not supported by blockchain)
	FeeRecipient string `json:"feeRecipient"`

	// Offline Pruning Settings
	OfflinePruning                bool   `json:"offline-pruning-enabled"`
	OfflinePruningBloomFilterSize uint64 `json:"offline-pruning-bloom-filter-size"`
	OfflinePruningDataDirectory   string `json:"offline-pruning-data-directory"`

	// VM2VM network
	MaxOutboundActiveRequests           int64 `json:"max-outbound-active-requests"`
	MaxOutboundActiveCrossChainRequests int64 `json:"max-outbound-active-cross-chain-requests"`

	// Sync settings
	StateSyncEnabled         bool   `json:"state-sync-enabled"`
	StateSyncSkipResume      bool   `json:"state-sync-skip-resume"` // Forces state sync to use the highest available summary block
	StateSyncServerTrieCache int    `json:"state-sync-server-trie-cache"`
	StateSyncIDs             string `json:"state-sync-ids"`
	StateSyncCommitInterval  uint64 `json:"state-sync-commit-interval"`
	StateSyncMinBlocks       uint64 `json:"state-sync-min-blocks"`
	StateSyncRequestSize     uint16 `json:"state-sync-request-size"`

	// Database Settings
	InspectDatabase bool `json:"inspect-database"` // Inspects the database on startup if enabled.

	// SkipUpgradeCheck disables checking that upgrades must take place before the last
	// accepted block. Skipping this check is useful when a node operator does not update
	// their node before the network upgrade and their node accepts blocks that have
	// identical state with the pre-upgrade ruleset.
	SkipUpgradeCheck bool `json:"skip-upgrade-check"`

	// AcceptedCacheSize is the depth to keep in the accepted headers cache and the
	// accepted logs cache at the accepted tip.
	//
	// This is particularly useful for improving the performance of eth_getLogs
	// on RPC nodes.
	AcceptedCacheSize int `json:"accepted-cache-size"`

	// TxLookupLimit is the maximum number of blocks from head whose tx indices
	// are reserved:
	//  * 0:   means no limit
	//  * N:   means N block limit [HEAD-N+1, HEAD] and delete extra indexes
	TxLookupLimit uint64 `json:"tx-lookup-limit"`

	// SkipTxIndexing skips indexing transactions.
	// This is useful for validators that don't need to index transactions.
	// TxLookupLimit can be still used to control unindexing old transactions.
	SkipTxIndexing bool `json:"skip-tx-indexing"`

	// WarpOffChainMessages encodes off-chain messages (unrelated to any on-chain event ie. block or AddressedCall)
	// that the node should be willing to sign.
	// Note: only supports AddressedCall payloads as defined here:
	// https://github.com/cryft-labs/cryftgo/tree/7623ffd4be915a5185c9ed5e11fa9be15a6e1f00/vms/platformvm/warp/payload#addressedcall
	WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`
}

Config ...

func (Config) EthAPIs

func (c Config) EthAPIs() []string

EthAPIs returns an array of strings representing the Eth APIs that should be enabled

func (Config) EthBackendSettings

func (c Config) EthBackendSettings() eth.Settings

func (*Config) SetDefaults

func (c *Config) SetDefaults()

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if this is an invalid config.

type ConfigReply

type ConfigReply struct {
	Config *Config `json:"config"`
}

type Database

type Database struct{ database.Database }

Database implements ethdb.Database

func (Database) NewBatch

func (db Database) NewBatch() ethdb.Batch

NewBatch implements ethdb.Database

func (Database) NewBatchWithSize

func (db Database) NewBatchWithSize(size int) ethdb.Batch

NewBatchWithSize implements ethdb.Database TODO: propagate size through avalanchego Database interface

func (Database) NewIterator

func (db Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator

NewIterator implements ethdb.Database

Note: This method assumes that the prefix is NOT part of the start, so there's no need for the caller to prepend the prefix to the start.

func (Database) NewIteratorWithStart

func (db Database) NewIteratorWithStart(start []byte) ethdb.Iterator

NewIteratorWithStart implements ethdb.Database

func (Database) NewSnapshot

func (db Database) NewSnapshot() (ethdb.Snapshot, error)

func (Database) Stat

func (db Database) Stat(string) (string, error)

Stat implements ethdb.Database

type DecodeGenesisArgs

type DecodeGenesisArgs struct {
	GenesisBytes string              `json:"genesisBytes"`
	Encoding     formatting.Encoding `json:"encoding"`
}

DecodeGenesisArgs are arguments for DecodeGenesis

type DecodeGenesisReply

type DecodeGenesisReply struct {
	Genesis  *core.Genesis       `json:"genesisData"`
	Encoding formatting.Encoding `json:"encoding"`
}

DecodeGenesisReply is the reply from DecodeGenesis

type Duration

type Duration struct {
	time.Duration
}

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

String implements the stringer interface.

func (Duration) String

func (d Duration) String() string

String implements the stringer interface.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) (err error)

type EthPushGossiper

type EthPushGossiper struct {
	// contains filtered or unexported fields
}

EthPushGossiper is used by the ETH backend to push transactions issued over the RPC and added to the mempool to peers.

func (*EthPushGossiper) Add

func (e *EthPushGossiper) Add(tx *types.Transaction)

type Factory

type Factory struct{}

func (*Factory) New

func (*Factory) New(logging.Logger) (interface{}, error)

type GetAcceptedFrontReply

type GetAcceptedFrontReply struct {
	Hash   common.Hash `json:"hash"`
	Number *big.Int    `json:"number"`
}

GetAcceptedFrontReply defines the reply that will be sent from the GetAcceptedFront API call

type GossipEthTx

type GossipEthTx struct {
	Tx *types.Transaction
}

func (*GossipEthTx) GossipID

func (tx *GossipEthTx) GossipID() ids.ID

type GossipEthTxMarshaller

type GossipEthTxMarshaller struct{}

func (GossipEthTxMarshaller) MarshalGossip

func (g GossipEthTxMarshaller) MarshalGossip(tx *GossipEthTx) ([]byte, error)

func (GossipEthTxMarshaller) UnmarshalGossip

func (g GossipEthTxMarshaller) UnmarshalGossip(bytes []byte) (*GossipEthTx, error)

type GossipEthTxPool

type GossipEthTxPool struct {
	// contains filtered or unexported fields
}

func NewGossipEthTxPool

func NewGossipEthTxPool(mempool *txpool.TxPool, registerer prometheus.Registerer) (*GossipEthTxPool, error)

func (*GossipEthTxPool) Add

func (g *GossipEthTxPool) Add(tx *GossipEthTx) error

Add enqueues the transaction to the mempool. Subscribe should be called to receive an event if tx is actually added to the mempool or not.

func (*GossipEthTxPool) GetFilter

func (g *GossipEthTxPool) GetFilter() ([]byte, []byte)

func (*GossipEthTxPool) Has

func (g *GossipEthTxPool) Has(txID ids.ID) bool

Has should just return whether or not the [txID] is still in the mempool, not whether it is in the mempool AND pending.

func (*GossipEthTxPool) Iterate

func (g *GossipEthTxPool) Iterate(f func(tx *GossipEthTx) bool)

func (*GossipEthTxPool) Subscribe

func (g *GossipEthTxPool) Subscribe(ctx context.Context)

type GossipHandler

type GossipHandler struct {
	// contains filtered or unexported fields
}

GossipHandler handles incoming gossip messages

func NewGossipHandler

func NewGossipHandler(vm *VM, stats GossipStats) *GossipHandler

func (*GossipHandler) HandleEthTxs

func (h *GossipHandler) HandleEthTxs(nodeID ids.NodeID, msg message.EthTxsGossip) error

type GossipStats

type GossipStats interface {
	IncEthTxsGossipReceived()

	// new vs. known txs received
	IncEthTxsGossipReceivedError()
	IncEthTxsGossipReceivedKnown()
	IncEthTxsGossipReceivedNew()
}

GossipStats contains methods for updating incoming and outgoing gossip stats.

func NewGossipStats

func NewGossipStats() GossipStats

type SetLogLevelArgs

type SetLogLevelArgs struct {
	Level string `json:"level"`
}

type SnowmanAPI

type SnowmanAPI struct {
	// contains filtered or unexported fields
}

SnowmanAPI introduces snowman specific functionality to the evm

func (*SnowmanAPI) GetAcceptedFront

func (api *SnowmanAPI) GetAcceptedFront(ctx context.Context) (*GetAcceptedFrontReply, error)

GetAcceptedFront returns the last accepted block's hash and height

func (*SnowmanAPI) IssueBlock

func (api *SnowmanAPI) IssueBlock(ctx context.Context) error

IssueBlock to the chain

type StateSyncClient

type StateSyncClient interface {
	// methods that implement the client side of [block.StateSyncableVM]
	StateSyncEnabled(context.Context) (bool, error)
	GetOngoingSyncStateSummary(context.Context) (block.StateSummary, error)
	ParseStateSummary(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)

	// additional methods required by the evm package
	StateSyncClearOngoingSummary() error
	Shutdown() error
	Error() error
}

func NewStateSyncClient

func NewStateSyncClient(config *stateSyncClientConfig) StateSyncClient

type StateSyncServer

type StateSyncServer interface {
	GetLastStateSummary(context.Context) (block.StateSummary, error)
	GetStateSummary(context.Context, uint64) (block.StateSummary, error)
}

func NewStateSyncServer

func NewStateSyncServer(config *stateSyncServerConfig) StateSyncServer

type StaticService

type StaticService struct{}

StaticService defines the static API services exposed by the evm

func CreateStaticService

func CreateStaticService() *StaticService

func (*StaticService) BuildGenesis

func (ss *StaticService) BuildGenesis(_ *http.Request, args *BuildGenesisArgs, reply *BuildGenesisReply) error

BuildGenesis constructs a genesis file.

func (*StaticService) DecodeGenesis

func (ss *StaticService) DecodeGenesis(_ *http.Request, args *DecodeGenesisArgs, reply *DecodeGenesisReply) error

BuildGenesis constructs a genesis file.

type Status

type Status uint32

Status ...

const (
	Unknown Status = iota
	Dropped
	Processing
	Accepted
)

List of possible status values Unknown Zero value, means the status is not known Dropped means the transaction was in the mempool, but was dropped because it failed verification Processing means the transaction is in the mempool Accepted means the transaction was accepted

func (Status) MarshalJSON

func (s Status) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (Status) Valid

func (s Status) Valid() error

Valid returns nil if the status is a valid status.

type SubnetEVMLogger

type SubnetEVMLogger struct {
	log.Handler
}

func InitLogger

func InitLogger(alias string, level string, jsonFormat bool, writer io.Writer) (SubnetEVMLogger, error)

InitLogger initializes logger with alias and sets the log level and format with the original os.StdErr interface along with the context logger.

func (*SubnetEVMLogger) SetLogLevel

func (c *SubnetEVMLogger) SetLogLevel(level string) error

SetLogLevel sets the log level of initialized log handler.

type Syncer

type Syncer interface {
	Start(ctx context.Context) error
	Done() <-chan error
}

Syncer represents a step in state sync, along with Start/Done methods to control and monitor progress. Error returns an error if any was encountered.

type VM

type VM struct {

	// *chain.State helps to implement the VM interface by wrapping blocks
	// with an efficient caching layer.
	*chain.State

	peer.Network

	// State sync server and client
	StateSyncServer
	StateSyncClient
	// contains filtered or unexported fields
}

VM implements the snowman.ChainVM interface

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)

CreateHandlers makes new http handlers that can handle API calls

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers(context.Context) (map[string]http.Handler, error)

CreateStaticHandlers makes new http handlers that can handle API calls

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(_ context.Context, blkHeight uint64) (ids.ID, error)

GetBlockAtHeight returns the canonical block at [blkHeight]. If [blkHeight] is less than the height of the last accepted block, this will return the block accepted at that height. Otherwise, it may return a blkID that has not yet been accepted. Note: the engine assumes that if a block is not found at [blkHeight], then database.ErrNotFound will be returned. This indicates that the VM has state synced and does not have all historical blocks available.

func (*VM) GetCurrentNonce

func (vm *VM) GetCurrentNonce(address common.Address) (uint64, error)

GetCurrentNonce returns the nonce associated with the address at the preferred block

func (*VM) HealthCheck

func (vm *VM) HealthCheck(context.Context) (interface{}, error)

Health returns nil if this chain is healthy. Also returns details, which should be one of: string, []byte, map[string]string

func (*VM) Initialize

func (vm *VM) Initialize(
	_ context.Context,
	chainCtx *snow.Context,
	db database.Database,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngine chan<- commonEng.Message,
	fxs []*commonEng.Fx,
	appSender commonEng.AppSender,
) error

Initialize implements the snowman.ChainVM interface

func (*VM) NewBlockBuilder

func (vm *VM) NewBlockBuilder(notifyBuildBlockChan chan<- commonEng.Message) *blockBuilder

func (*VM) ParseEthBlock

func (vm *VM) ParseEthBlock(b []byte) (*types.Block, error)

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blkID ids.ID) error

SetPreference sets what the current tail of the chain is

func (*VM) SetState

func (vm *VM) SetState(_ context.Context, state snow.State) error

func (*VM) Shutdown

func (vm *VM) Shutdown(context.Context) error

Shutdown implements the snowman.ChainVM interface

func (*VM) VerifyHeightIndex

func (vm *VM) VerifyHeightIndex(context.Context) error

VerifyHeightIndex always returns a nil error since the index is maintained by vm.blockChain.

func (*VM) Version

func (vm *VM) Version(context.Context) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL