vmcontext

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0, MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCallDepth = 4096

Variables

View Source
var BatchSealVerifyParallelism = 2 * goruntime.NumCPU()
View Source
var EmptyObjectCid cid.Cid

Functions

func NewActorStateHandle

func NewActorStateHandle(ctx actorStateHandleContext) specsruntime.StateHandle

NewActorStateHandle returns a new `ActorStateHandle`

Note: just visible for testing.

Types

type ActorImplLookup

type ActorImplLookup interface {
	GetActorImpl(code cid.Cid, rt runtime.Runtime) (dispatch.Dispatcher, *dispatch.ExcuteError)
}

ActorImplLookup provides access To upgradeable actor code.

type ActorStorage

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

ActorStorage hides the storage methods From the actors and turns the errors into runtime panics.

func NewActorStorage

func NewActorStorage(ctx context.Context, inner cbornode.IpldStore, gasTank *gas.GasTracker, pricelist gas.Pricelist) *ActorStorage

func (*ActorStorage) StoreGet

func (s *ActorStorage) StoreGet(cid cid.Cid, obj cbor.Unmarshaler) bool

func (*ActorStorage) StorePut

func (s *ActorStorage) StorePut(obj cbor.Marshaler) cid.Cid

type AddressIn

type AddressIn struct {
	Addresses []address.Address
}

AddressIn pattern checks if the callers address is in the list of items provided.

func (AddressIn) IsMatch

func (p AddressIn) IsMatch(ctx runtime.PatternContext) bool

IsMatch returns "True" if the patterns matches

type Any

type Any struct{}

Any patterns always passses.

func (Any) IsMatch

func (Any) IsMatch(ctx runtime.PatternContext) bool

IsMatch returns "True" if the patterns matches

type CircSupplyCalculator

type CircSupplyCalculator func(context.Context, abi.ChainEpoch, tree.Tree) (abi.TokenAmount, error)

type CodeIn

type CodeIn struct {
	Codes []cid.Cid
}

CodeIn pattern checks if the callers code CID is in the list of items provided.

func (CodeIn) IsMatch

func (p CodeIn) IsMatch(ctx runtime.PatternContext) bool

IsMatch returns "True" if the patterns matches

type ExecCallBack

type ExecCallBack func(cid.Cid, VmMessage, *Ret) error

type FakeSyscalls

type FakeSyscalls struct {
}

func (FakeSyscalls) BatchVerifySeals

func (f FakeSyscalls) BatchVerifySeals(ctx context.Context, vis map[address.Address][]proof.SealVerifyInfo) (map[address.Address][]bool, error)

func (FakeSyscalls) ComputeUnsealedSectorCID

func (f FakeSyscalls) ComputeUnsealedSectorCID(ctx context.Context, proof abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error)

func (FakeSyscalls) HashBlake2b

func (f FakeSyscalls) HashBlake2b(data []byte) [32]byte

func (FakeSyscalls) VerifyConsensusFault

func (f FakeSyscalls) VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte, view SyscallsStateView) (*runtime.ConsensusFault, error)

func (FakeSyscalls) VerifyPoSt

func (f FakeSyscalls) VerifyPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) error

func (FakeSyscalls) VerifySeal

func (f FakeSyscalls) VerifySeal(ctx context.Context, info proof.SealVerifyInfo) error

func (FakeSyscalls) VerifySignature

func (f FakeSyscalls) VerifySignature(ctx context.Context, view SyscallsStateView, signature crypto.Signature, signer address.Address, plaintext []byte) error

func (FakeSyscalls) VerifyWinningPoSt

func (f FakeSyscalls) VerifyWinningPoSt(ctx context.Context, info proof.WinningPoStVerifyInfo) error

type GasChargeBlockStore

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

func (*GasChargeBlockStore) Get

func (bs *GasChargeBlockStore) Get(c cid.Cid) (blocks.Block, error)

func (*GasChargeBlockStore) Put

func (bs *GasChargeBlockStore) Put(blk blocks.Block) error

type IsAInitActor

type IsAInitActor struct{}

IsAInitActor pattern checks if the caller is the init actor. Dragons: delete after switching to new actors

func (IsAInitActor) IsMatch

func (IsAInitActor) IsMatch(ctx runtime.PatternContext) bool

IsMatch returns "True" if the patterns matches

type IsAccountActor

type IsAccountActor struct{}

IsAccountActor pattern checks if the caller is an account actor. Dragons: delete after switching to new actors

func (IsAccountActor) IsMatch

IsMatch returns "True" if the patterns matches

type NtwkVersionGetter

type NtwkVersionGetter func(context.Context, abi.ChainEpoch) network.Version

type Ret

type Ret struct {
	GasTracker *gas.GasTracker
	OutPuts    gas.GasOutputs
	Receipt    types.MessageReceipt
}

type SyscallsImpl

type SyscallsImpl interface {
	VerifySignature(ctx context.Context, view SyscallsStateView, signature crypto.Signature, signer address.Address, plaintext []byte) error
	HashBlake2b(data []byte) [32]byte
	ComputeUnsealedSectorCID(ctx context.Context, proof abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error)
	VerifySeal(ctx context.Context, info proof.SealVerifyInfo) error
	BatchVerifySeals(ctx context.Context, vis map[address.Address][]proof.SealVerifyInfo) (map[address.Address][]bool, error)
	VerifyPoSt(ctx context.Context, info proof.WindowPoStVerifyInfo) error
	VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte, view SyscallsStateView) (*specsruntime.ConsensusFault, error)
}

Syscall implementation interface. These methods take the chain epoch and other context that is implicit in the runtime as explicit parameters.

type SyscallsStateView

type SyscallsStateView interface {
	ResolveToKeyAddr(ctx context.Context, address address.Address) (address.Address, error)
	MinerInfo(ctx context.Context, maddr address.Address, nv network.Version) (*miner.MinerInfo, error)
	TotalFilCircSupply(height abi.ChainEpoch, st vmState.Tree) (abi.TokenAmount, error)
	GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) network.Version
}

type TestStorage

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

TestStorage is a fake storage used for testing.

func NewTestStorage

func NewTestStorage(state interface{}) *TestStorage

NewTestStorage returns a new "TestStorage"

func (*TestStorage) StoreGet

func (ts *TestStorage) StoreGet(cid cid.Cid, obj cbor.Unmarshaler) bool

Get implements runtime.Store.

func (*TestStorage) StorePut

func (ts *TestStorage) StorePut(v cbor.Marshaler) cid.Cid

Put implements runtime.Store.

type VM

type VM struct {
	State tree.Tree
	// contains filtered or unexported fields
}

VM holds the stateView and executes messages over the stateView.

func NewVM

func NewVM(actorImpls ActorImplLookup, vmOption VmOption) (*VM, error)

NewVM creates a new runtime for executing messages. Dragons: change To take a root and the store, build the tree internally

func (*VM) ApplyGenesisMessage

func (vm *VM) ApplyGenesisMessage(from address.Address, to address.Address, method abi.MethodNum, value abi.TokenAmount, params interface{}) (*Ret, error)

ApplyGenesisMessage forces the execution of a message in the vm actor.

This Method is intended To be used in the generation of the genesis block only.

func (*VM) ApplyImplicitMessage

func (vm *VM) ApplyImplicitMessage(msg types.ChainMsg) (*Ret, error)

func (*VM) ApplyMessage

func (vm *VM) ApplyMessage(msg types.ChainMsg) (*Ret, error)

todo estimate gasLimit

func (*VM) ApplyTipSetMessages

func (vm *VM) ApplyTipSetMessages(blocks []types.BlockMessagesInfo, ts *types.TipSet, parentEpoch, epoch abi.ChainEpoch, cb ExecCallBack) (cid.Cid, []types.MessageReceipt, error)

ApplyTipSetMessages implements interpreter.VMInterpreter

func (*VM) ContextStore

func (vm *VM) ContextStore() adt.Store

ContextStore provides access To specs-actors adt library.

This type of store is used To access some internal actor stateView.

func (*VM) CurrentEpoch

func (vm *VM) CurrentEpoch() abi.ChainEpoch

CurrentEpoch implements runtime.Runtime.

func (*VM) Flush

func (vm *VM) Flush() (tree.Root, error)

nolint

func (*VM) MutateState

func (vm *VM) MutateState(ctx context.Context, addr address.Address, fn interface{}) error

MutateState usage: MutateState(ctx, idAddr, func(cst cbor.IpldStore, st *ActorStateType) error {...})

func (*VM) NtwkVersion

func (vm *VM) NtwkVersion() network.Version

func (*VM) SetCurrentEpoch

func (vm *VM) SetCurrentEpoch(current abi.ChainEpoch)

func (*VM) StateTree

func (vm *VM) StateTree() tree.Tree

type VMDebugMsg

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

func NewVMDebugMsg

func NewVMDebugMsg() *VMDebugMsg

func (*VMDebugMsg) Printfln

func (debug *VMDebugMsg) Printfln(msg string, args ...interface{})

func (*VMDebugMsg) Println

func (debug *VMDebugMsg) Println(args ...interface{})

func (*VMDebugMsg) WriteToFile

func (debug *VMDebugMsg) WriteToFile(fileName string) error

func (*VMDebugMsg) WriteToTerminal

func (debug *VMDebugMsg) WriteToTerminal()

type VMInterpreter

type VMInterpreter interface {
	// ApplyTipSetMessages applies all the messages in a tipset.
	//
	// Note: any message processing error will be present as an `ExitCode` in the `MessageReceipt`.
	ApplyTipSetMessages(blocks []types.BlockMessagesInfo, ts *types.TipSet, parentEpoch abi.ChainEpoch, epoch abi.ChainEpoch, cb ExecCallBack) (cid.Cid, []types.MessageReceipt, error)
	ApplyGenesisMessage(from address.Address, to address.Address, method abi.MethodNum, value abi.TokenAmount, params interface{}) (*Ret, error)
	ApplyMessage(msg types.ChainMsg) (*Ret, error)
	ApplyImplicitMessage(msg types.ChainMsg) (*Ret, error)

	StateTree() tree.Tree
	Flush() (tree.Root, error)

	MutateState(ctx context.Context, addr address.Address, fn interface{}) error
}

VMInterpreter orchestrates the execution of messages from a tipset on that tipset’s parent State.

type VmMessage

type VmMessage struct {
	From   address.Address
	To     address.Address
	Value  abi.TokenAmount
	Method abi.MethodNum
	Params interface{}
}

func VmMessageFromUnsignedMessage

func VmMessageFromUnsignedMessage(msg *types.UnsignedMessage) VmMessage

func (VmMessage) Caller

func (msg VmMessage) Caller() address.Address

Caller implements runtime.MessageInfo.

func (VmMessage) Receiver

func (msg VmMessage) Receiver() address.Address

Receiver implements runtime.MessageInfo.

func (VmMessage) ValueReceived

func (msg VmMessage) ValueReceived() abi.TokenAmount

ValueReceived implements runtime.MessageInfo.

type VmOption

type VmOption struct {
	CircSupplyCalculator CircSupplyCalculator
	NtwkVersionGetter    NtwkVersionGetter
	Rnd                  chain.RandomnessSource
	BaseFee              abi.TokenAmount
	Fork                 fork.IFork
	ActorCodeLoader      *dispatch.CodeLoader
	Epoch                abi.ChainEpoch
	GasPriceSchedule     *gas.PricesSchedule
	PRoot                cid.Cid
	Bsstore              blockstoreutil.Blockstore
	SysCallsImpl         SyscallsImpl
}

Jump to

Keyboard shortcuts

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