vm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2021 License: Apache-2.0, MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCallDepth = 4096

Variables

View Source
var (
	StatSends   uint64
	StatApplied uint64
)

stat counters

View Source
var BatchSealVerifyParallelism = goruntime.NumCPU()
View Source
var EmptyObjectCid cid.Cid
View Source
var EnableGasTracing = false

EnableGasTracing, if true, outputs gas tracing in execution traces.

Functions

func ComputeGasOverestimationBurn

func ComputeGasOverestimationBurn(gasUsed, gasLimit int64) (int64, int64)

ComputeGasOverestimationBurn computes amount of gas to be refunded and amount of gas to be burned Result is (refund, burn)

func Copy

func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) error

func DecodeParams

func DecodeParams(b []byte, out interface{}) error

func DumpActorState

func DumpActorState(act *types.Actor, b []byte) (interface{}, error)

func ResolveToKeyAddr

func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, error)

ResolveToKeyAddr returns the public key type of address (`BLS`/`SECP256K1`) of an account actor identified by `addr`.

func TryCreateAccountActor

func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, address.Address, aerrors.ActorError)

TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses.

Types

type ActorPredicate

type ActorPredicate func(vmr.Runtime, rtt.VMActor) error

An ActorPredicate returns an error if the given actor is not valid for the given runtime environment (e.g., chain height, version, etc.).

func ActorsVersionPredicate

func ActorsVersionPredicate(ver actors.Version) ActorPredicate

type ActorRegistry

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

func NewActorRegistry

func NewActorRegistry() *ActorRegistry

func (*ActorRegistry) Create

func (ar *ActorRegistry) Create(codeCid cid.Cid, rt vmr.Runtime) (*types.Actor, aerrors.ActorError)

func (*ActorRegistry) Invoke

func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError)

func (*ActorRegistry) Register

func (ar *ActorRegistry) Register(pred ActorPredicate, actors ...rtt.VMActor)

type ApplyRet

type ApplyRet struct {
	types.MessageReceipt
	ActorErr       aerrors.ActorError
	ExecutionTrace types.ExecutionTrace
	Duration       time.Duration
	GasCosts       *GasOutputs
}

type CircSupplyCalculator

type CircSupplyCalculator func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error)

type GasCharge

type GasCharge struct {
	Name  string
	Extra interface{}

	ComputeGas int64
	StorageGas int64

	VirtualCompute int64
	VirtualStorage int64
}

func (GasCharge) Total

func (g GasCharge) Total() int64

func (GasCharge) WithExtra

func (g GasCharge) WithExtra(extra interface{}) GasCharge

func (GasCharge) WithVirtual

func (g GasCharge) WithVirtual(compute, storage int64) GasCharge

type GasOutputs

type GasOutputs struct {
	BaseFeeBurn        abi.TokenAmount
	OverEstimationBurn abi.TokenAmount

	MinerPenalty abi.TokenAmount
	MinerTip     abi.TokenAmount
	Refund       abi.TokenAmount

	GasRefund int64
	GasBurned int64
}

func ComputeGasOutputs

func ComputeGasOutputs(gasUsed, gasLimit int64, baseFee, feeCap, gasPremium abi.TokenAmount, chargeNetworkFee bool) GasOutputs

func ZeroGasOutputs

func ZeroGasOutputs() GasOutputs

ZeroGasOutputs returns a logically zeroed GasOutputs.

type LookbackStateGetter

type LookbackStateGetter func(context.Context, abi.ChainEpoch) (*state.StateTree, error)

type Message

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

func (*Message) Caller

func (m *Message) Caller() address.Address

func (*Message) Receiver

func (m *Message) Receiver() address.Address

func (*Message) ValueReceived

func (m *Message) ValueReceived() abi.TokenAmount

type NtwkVersionGetter

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

type Pricelist

type Pricelist interface {
	// OnChainMessage returns the gas used for storing a message of a given size in the chain.
	OnChainMessage(msgSize int) GasCharge
	// OnChainReturnValue returns the gas used for storing the response of a message in the chain.
	OnChainReturnValue(dataSize int) GasCharge

	// OnMethodInvocation returns the gas used when invoking a method.
	OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge

	// OnIpldGet returns the gas used for storing an object
	OnIpldGet() GasCharge
	// OnIpldPut returns the gas used for storing an object
	OnIpldPut(dataSize int) GasCharge

	// OnCreateActor returns the gas used for creating an actor
	OnCreateActor() GasCharge
	// OnDeleteActor returns the gas used for deleting an actor
	OnDeleteActor() GasCharge

	OnVerifySignature(sigType crypto.SigType, planTextSize int) (GasCharge, error)
	OnHashing(dataSize int) GasCharge
	OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge
	OnVerifySeal(info proof2.SealVerifyInfo) GasCharge
	OnVerifyPost(info proof2.WindowPoStVerifyInfo) GasCharge
	OnVerifyConsensusFault() GasCharge
}

Pricelist provides prices for operations in the VM.

Note: this interface should be APPEND ONLY since last chain checkpoint

func PricelistByEpoch

func PricelistByEpoch(epoch abi.ChainEpoch) Pricelist

PricelistByEpoch finds the latest prices for the given epoch

type Rand

type Rand interface {
	GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
	GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)
}

type Runtime

type Runtime struct {
	rt2.Message
	rt2.Syscalls
	// contains filtered or unexported fields
}

func (*Runtime) AbortStateMsg

func (rt *Runtime) AbortStateMsg(msg string)

func (*Runtime) Abortf

func (rt *Runtime) Abortf(code exitcode.ExitCode, msg string, args ...interface{})

func (*Runtime) ChargeGas

func (rt *Runtime) ChargeGas(name string, compute int64, virtual int64)

ChargeGas is spec actors function

func (*Runtime) Context

func (rt *Runtime) Context() context.Context

func (*Runtime) CreateActor

func (rt *Runtime) CreateActor(codeID cid.Cid, addr address.Address)

func (*Runtime) CurrEpoch

func (rt *Runtime) CurrEpoch() abi.ChainEpoch

func (*Runtime) CurrentBalance

func (rt *Runtime) CurrentBalance() abi.TokenAmount

func (*Runtime) DeleteActor

func (rt *Runtime) DeleteActor(beneficiary address.Address)

DeleteActor deletes the executing actor from the state tree, transferring any balance to beneficiary. Aborts if the beneficiary does not exist or is the calling actor. May only be called by the actor itself.

func (*Runtime) GetActorCodeCID

func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool)

func (*Runtime) GetBalance

func (rt *Runtime) GetBalance(a address.Address) (types.BigInt, aerrors.ActorError)

func (*Runtime) GetRandomnessFromBeacon

func (rt *Runtime) GetRandomnessFromBeacon(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness

func (*Runtime) GetRandomnessFromTickets

func (rt *Runtime) GetRandomnessFromTickets(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness

func (*Runtime) Log

func (rt *Runtime) Log(level rtt.LogLevel, msg string, args ...interface{})

func (*Runtime) NetworkVersion

func (rt *Runtime) NetworkVersion() network.Version

func (*Runtime) NewActorAddress

func (rt *Runtime) NewActorAddress() address.Address

func (*Runtime) Pricelist

func (rt *Runtime) Pricelist() Pricelist

func (*Runtime) ResolveAddress

func (rt *Runtime) ResolveAddress(addr address.Address) (ret address.Address, ok bool)

func (*Runtime) Send

func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m cbor.Marshaler, value abi.TokenAmount, out cbor.Er) exitcode.ExitCode

func (*Runtime) StartSpan

func (rt *Runtime) StartSpan(name string) func()

func (*Runtime) StateCreate

func (rt *Runtime) StateCreate(obj cbor.Marshaler)

func (*Runtime) StateReadonly

func (rt *Runtime) StateReadonly(obj cbor.Unmarshaler)

func (*Runtime) StateTransaction

func (rt *Runtime) StateTransaction(obj cbor.Er, f func())

func (*Runtime) StoreGet

func (rt *Runtime) StoreGet(c cid.Cid, o cbor.Unmarshaler) bool

func (*Runtime) StorePut

func (rt *Runtime) StorePut(x cbor.Marshaler) cid.Cid

func (*Runtime) TotalFilCircSupply

func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount

func (*Runtime) ValidateImmediateCallerAcceptAny

func (rt *Runtime) ValidateImmediateCallerAcceptAny()

func (*Runtime) ValidateImmediateCallerIs

func (rt *Runtime) ValidateImmediateCallerIs(as ...address.Address)

func (*Runtime) ValidateImmediateCallerType

func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid)

type SyscallBuilder

type SyscallBuilder func(ctx context.Context, rt *Runtime) runtime2.Syscalls

func Syscalls

func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder

type UnsafeVM

type UnsafeVM struct {
	VM *VM
}

func (*UnsafeVM) MakeRuntime

func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message) *Runtime

type VM

type VM struct {
	Syscalls SyscallBuilder
	// contains filtered or unexported fields
}

func NewVM

func NewVM(ctx context.Context, opts *VMOpts) (*VM, error)

func (*VM) ActorBalance

func (vm *VM) ActorBalance(addr address.Address) (types.BigInt, aerrors.ActorError)

func (*VM) ApplyImplicitMessage

func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error)

func (*VM) ApplyMessage

func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error)

func (*VM) Flush

func (vm *VM) Flush(ctx context.Context) (cid.Cid, error)

func (*VM) GetCircSupply

func (vm *VM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error)

func (*VM) GetNtwkVersion

func (vm *VM) GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) network.Version

func (*VM) Invoke

func (vm *VM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError)

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) SetBlockHeight

func (vm *VM) SetBlockHeight(h abi.ChainEpoch)

func (*VM) SetInvoker

func (vm *VM) SetInvoker(i *ActorRegistry)

func (*VM) ShouldBurn

func (vm *VM) ShouldBurn(st *state.StateTree, msg *types.Message, errcode exitcode.ExitCode) (bool, error)

func (*VM) StateTree

func (vm *VM) StateTree() types.StateTree

type VMOpts

type VMOpts struct {
	StateBase      cid.Cid
	Epoch          abi.ChainEpoch
	Rand           Rand
	Bstore         blockstore.Blockstore
	Syscalls       SyscallBuilder
	CircSupplyCalc CircSupplyCalculator
	NtwkVersion    NtwkVersionGetter // TODO: stebalien: In what cases do we actually need this? It seems like even when creating new networks we want to use the 'global'/build-default version getter
	BaseFee        abi.TokenAmount
	LookbackState  LookbackStateGetter
}

Jump to

Keyboard shortcuts

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