vm

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Overview

Package vm implements custom VM.

Index

Constants

View Source
const (
	Name           = "spacesvm"
	PublicEndpoint = "/public"
)

Variables

View Source
var (
	ErrNoPendingTx    = errors.New("no pending tx")
	ErrTypedDataIsNil = errors.New("typed data is nil")
	ErrInputIsNil     = errors.New("input is nil")
	ErrInvalidEmptyTx = errors.New("invalid empty transaction")
	ErrCorruption     = errors.New("corruption detected")
)

Functions

This section is empty.

Types

type BalanceArgs

type BalanceArgs struct {
	Address common.Address `serialize:"true" json:"address"`
}

type BalanceReply

type BalanceReply struct {
	Balance uint64 `serialize:"true" json:"balance"`
}

type BlockBuilder

type BlockBuilder interface {
	Build()
	Gossip()
	HandleGenerateBlock()
}

type ClaimedArgs

type ClaimedArgs struct {
	Space string `serialize:"true" json:"space"`
}

type ClaimedReply

type ClaimedReply struct {
	Claimed bool `serialize:"true" json:"claimed"`
}

type Config

type Config struct {
	BuildInterval    time.Duration `serialize:"true" json:"buildInterval"`
	GossipInterval   time.Duration `serialize:"true" json:"gossipInterval"`
	RegossipInterval time.Duration `serialize:"true" json:"regossipInterval"`

	PruneLimit        int           `serialize:"true" json:"pruneLimit"`
	PruneInterval     time.Duration `serialize:"true" json:"pruneInterval"`
	FullPruneInterval time.Duration `serialize:"true" json:"fullPruneInterval"`

	CompactInterval time.Duration `serialize:"true" json:"compactInterval"`

	MempoolSize       int `serialize:"true" json:"mempoolSize"`
	ActivityCacheSize int `serialize:"true" json:"activityCacheSize"`
}

func (*Config) SetDefaults

func (c *Config) SetDefaults()

type GenesisReply

type GenesisReply struct {
	Genesis *chain.Genesis `serialize:"true" json:"genesis"`
}

type HasTxArgs

type HasTxArgs struct {
	TxID ids.ID `serialize:"true" json:"txId"`
}

type HasTxReply

type HasTxReply struct {
	Accepted bool `serialize:"true" json:"accepted"`
}

type InfoArgs

type InfoArgs struct {
	Space string `serialize:"true" json:"space"`
}

type InfoReply

type InfoReply struct {
	Info   *chain.SpaceInfo      `serialize:"true" json:"info"`
	Values []*chain.KeyValueMeta `serialize:"true" json:"values"`
}

type IssueRawTxArgs

type IssueRawTxArgs struct {
	Tx []byte `serialize:"true" json:"tx"`
}

type IssueRawTxReply

type IssueRawTxReply struct {
	TxID ids.ID `serialize:"true" json:"txId"`
}

type IssueTxArgs

type IssueTxArgs struct {
	TypedData *tdata.TypedData `serialize:"true" json:"typedData"`
	Signature hexutil.Bytes    `serialize:"true" json:"signature"`
}

type IssueTxReply

type IssueTxReply struct {
	TxID ids.ID `serialize:"true" json:"txId"`
}

type LastAcceptedReply

type LastAcceptedReply struct {
	Height  uint64 `serialize:"true" json:"height"`
	BlockID ids.ID `serialize:"true" json:"blockId"`
}

type ManualBuilder

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

func (*ManualBuilder) Build

func (b *ManualBuilder) Build()

func (*ManualBuilder) Gossip

func (b *ManualBuilder) Gossip()

func (*ManualBuilder) HandleGenerateBlock

func (b *ManualBuilder) HandleGenerateBlock()

func (*ManualBuilder) NotifyBuild

func (b *ManualBuilder) NotifyBuild()

type NetworkReply

type NetworkReply struct {
	NetworkID uint32 `serialize:"true" json:"networkId"`
	SubnetID  ids.ID `serialize:"true" json:"subnetId"`
	ChainID   ids.ID `serialize:"true" json:"chainId"`
}

type OwnedArgs

type OwnedArgs struct {
	Address common.Address `serialize:"true" json:"address"`
}

type OwnedReply

type OwnedReply struct {
	Spaces []string `serialize:"true" json:"spaces"`
}

type PingReply

type PingReply struct {
	Success bool `serialize:"true" json:"success"`
}

type PublicService

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

func (*PublicService) Balance

func (svc *PublicService) Balance(_ *http.Request, args *BalanceArgs, reply *BalanceReply) error

func (*PublicService) Claimed

func (svc *PublicService) Claimed(_ *http.Request, args *ClaimedArgs, reply *ClaimedReply) error

func (*PublicService) Genesis

func (svc *PublicService) Genesis(_ *http.Request, _ *struct{}, reply *GenesisReply) (err error)

func (*PublicService) HasTx

func (svc *PublicService) HasTx(_ *http.Request, args *HasTxArgs, reply *HasTxReply) error

func (*PublicService) Info

func (svc *PublicService) Info(_ *http.Request, args *InfoArgs, reply *InfoReply) error

func (*PublicService) IssueRawTx

func (svc *PublicService) IssueRawTx(_ *http.Request, args *IssueRawTxArgs, reply *IssueRawTxReply) error

func (*PublicService) IssueTx

func (svc *PublicService) IssueTx(_ *http.Request, args *IssueTxArgs, reply *IssueTxReply) error

func (*PublicService) LastAccepted

func (svc *PublicService) LastAccepted(_ *http.Request, _ *struct{}, reply *LastAcceptedReply) error

func (*PublicService) Network

func (svc *PublicService) Network(_ *http.Request, _ *struct{}, reply *NetworkReply) (err error)

func (*PublicService) Owned

func (svc *PublicService) Owned(_ *http.Request, args *OwnedArgs, reply *OwnedReply) error

func (*PublicService) Ping

func (svc *PublicService) Ping(_ *http.Request, _ *struct{}, reply *PingReply) (err error)

func (*PublicService) RecentActivity

func (svc *PublicService) RecentActivity(_ *http.Request, _ *struct{}, reply *RecentActivityReply) error

func (*PublicService) Resolve

func (svc *PublicService) Resolve(_ *http.Request, args *ResolveArgs, reply *ResolveReply) error

func (*PublicService) SuggestedFee

func (svc *PublicService) SuggestedFee(
	_ *http.Request,
	args *SuggestedFeeArgs,
	reply *SuggestedFeeReply,
) error

func (*PublicService) SuggestedRawFee

func (svc *PublicService) SuggestedRawFee(
	_ *http.Request,
	_ *struct{},
	reply *SuggestedRawFeeReply,
) error

type PushNetwork

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

func (*PushNetwork) GossipNewTxs

func (n *PushNetwork) GossipNewTxs(newTxs []*chain.Transaction) error

func (*PushNetwork) RegossipTxs

func (n *PushNetwork) RegossipTxs() error

Triggers "AppGossip" on the pending transactions in the mempool. "force" is true to re-gossip whether recently gossiped or not

type RecentActivityReply

type RecentActivityReply struct {
	Activity []*chain.Activity `serialize:"true" json:"activity"`
}

type ResolveArgs

type ResolveArgs struct {
	Path string `serialize:"true" json:"path"`
}

type ResolveReply

type ResolveReply struct {
	Exists    bool             `serialize:"true" json:"exists"`
	Value     []byte           `serialize:"true" json:"value"`
	ValueMeta *chain.ValueMeta `serialize:"true" json:"valueMeta"`
}

type SuggestedFeeArgs

type SuggestedFeeArgs struct {
	Input *chain.Input `serialize:"true" json:"input"`
}

type SuggestedFeeReply

type SuggestedFeeReply struct {
	TypedData *tdata.TypedData `serialize:"true" json:"typedData"`
	TotalCost uint64           `serialize:"true" json:"totalCost"`
}

type SuggestedRawFeeReply

type SuggestedRawFeeReply struct {
	Price uint64 `serialize:"true" json:"price"`
	Cost  uint64 `serialize:"true" json:"cost"`
}

type TimeBuilder

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

TimeBuilder tells the engine when to build blocks and gossip transactions

func (*TimeBuilder) Build

func (b *TimeBuilder) Build()

func (*TimeBuilder) Gossip

func (b *TimeBuilder) Gossip()

periodically but less aggressively force-regossip the pending

func (*TimeBuilder) HandleGenerateBlock

func (b *TimeBuilder) HandleGenerateBlock()

HandleGenerateBlock should be called immediately after [BuildBlock]. [HandleGenerateBlock] invocation could lead to quiesence, building a block with some delay, or attempting to build another block immediately.

type VM

type VM struct {
	AirdropData []byte
	// contains filtered or unexported fields
}

func (*VM) Accepted

func (vm *VM) Accepted(b *chain.StatelessBlock)

func (*VM) AppGossip

func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

Handles incoming "AppGossip" messages, parses them to transactions, and submits them to the mempool. The "AppGossip" message is sent by the other VM (spacesvm) via "common.AppSender" to receive txs and forward them to the other node (validator).

implements "snowmanblock.ChainVM.commom.VM.AppHandler" assume gossip via proposervm has been activated ref. "avalanchego/vms/platformvm/network.AppGossip" ref. "coreeth/plugin/evm.GossipHandler.HandleEthTxs"

func (*VM) AppRequest

func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

implements "snowmanblock.ChainVM.commom.VM.AppHandler"

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32) error

implements "snowmanblock.ChainVM.commom.VM.AppHandler"

func (*VM) AppResponse

func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

implements "snowmanblock.ChainVM.commom.VM.AppHandler"

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (snowman.Block, error)

implements "snowmanblock.ChainVM" called via "avalanchego" node over RPC

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, id ids.NodeID, nodeVersion *avagoversion.Application) error

implements "snowmanblock.ChainVM.commom.VM.validators.Connector"

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]*common.HTTPHandler, error)

implements "snowmanblock.ChainVM.common.VM" for "ext/vm/[chainID]"

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers(ctx context.Context) (map[string]*common.HTTPHandler, error)

implements "snowmanblock.ChainVM.common.VM" for "ext/vm/[vmID]"

func (*VM) CrossChainAppRequest

func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, request []byte) error

func (*VM) CrossChainAppRequestFailed

func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32) error

func (*VM) CrossChainAppResponse

func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, id ids.NodeID) error

implements "snowmanblock.ChainVM.commom.VM.validators.Connector"

func (*VM) ExecutionContext

func (vm *VM) ExecutionContext(currTime int64, lastBlock *chain.StatelessBlock) (*chain.Context, error)

func (*VM) Genesis

func (vm *VM) Genesis() *chain.Genesis

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, id ids.ID) (snowman.Block, error)

implements "snowmanblock.ChainVM.commom.VM.Getter" replaces "core.SnowmanVM.GetBlock"

func (*VM) GetStatelessBlock

func (vm *VM) GetStatelessBlock(blkID ids.ID) (*chain.StatelessBlock, error)

func (*VM) HealthCheck

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

implements "snowmanblock.ChainVM.commom.VM.health.Checkable"

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *snow.Context,
	dbManager manager.Manager,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngine chan<- common.Message,
	_ []*common.Fx,
	appSender common.AppSender,
) error

implements "snowmanblock.ChainVM.common.VM"

func (*VM) IsBootstrapped

func (vm *VM) IsBootstrapped() bool

func (*VM) LastAccepted

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

"LastAccepted" implements "snowmanblock.ChainVM" replaces "core.SnowmanVM.LastAccepted"

func (*VM) Mempool

func (vm *VM) Mempool() chain.Mempool

func (*VM) Network

func (vm *VM) Network() *PushNetwork

used for testing VM

func (*VM) NewManualBuilder

func (vm *VM) NewManualBuilder() *ManualBuilder

func (*VM) NewPushNetwork

func (vm *VM) NewPushNetwork() *PushNetwork

func (*VM) NewTimeBuilder

func (vm *VM) NewTimeBuilder() *TimeBuilder

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, source []byte) (snowman.Block, error)

implements "snowmanblock.ChainVM.commom.VM.Parser" replaces "core.SnowmanVM.ParseBlock"

func (*VM) Rejected

func (vm *VM) Rejected(b *chain.StatelessBlock)

func (*VM) SetBlockBuilder

func (vm *VM) SetBlockBuilder(b func() BlockBuilder)

[SetBlockBuilder] changes the BlockBuilder during runtime by stopping the previous block builder and then starting a new one.

func (*VM) SetPreference

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

"SetPreference" implements "snowmanblock.ChainVM" replaces "core.SnowmanVM.SetPreference"

func (*VM) SetState

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

func (*VM) Shutdown

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

implements "snowmanblock.ChainVM.common.VM"

func (*VM) State

func (vm *VM) State() database.Database

func (*VM) Submit

func (vm *VM) Submit(txs ...*chain.Transaction) (errs []error)

func (*VM) SuggestedFee

func (vm *VM) SuggestedFee() (uint64, uint64, error)

func (*VM) ValidBlockID

func (vm *VM) ValidBlockID(blockID ids.ID) (bool, error)

func (*VM) Verified

func (vm *VM) Verified(b *chain.StatelessBlock)

func (*VM) Version

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

implements "snowmanblock.ChainVM.common.VM"

Jump to

Keyboard shortcuts

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