vm

package
v0.6.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0, MIT Imports: 47 Imported by: 43

Documentation

Index

Constants

View Source
const (
	GasStorageMulti = 1000
	GasComputeMulti = 1
)

Variables

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

Functions

func ComputeGasOverestimationBurn added in v0.5.0

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(from, to blockstore.Blockstore, root cid.Cid) error

func DecodeParams

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

func DumpActorState

func DumpActorState(code cid.Cid, b []byte) (interface{}, error)

func NewBLSAccountActor

func NewBLSAccountActor() *types.Actor

func NewSecp256k1AccountActor

func NewSecp256k1AccountActor() *types.Actor

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, aerrors.ActorError)

TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses.

Types

type ApplyRet

type ApplyRet struct {
	types.MessageReceipt
	ActorErr       aerrors.ActorError
	Penalty        types.BigInt
	MinerTip       types.BigInt
	ExecutionTrace types.ExecutionTrace
	Duration       time.Duration
}

type CircSupplyCalculator added in v0.5.0

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

type GasCharge added in v0.4.0

type GasCharge struct {
	Name  string
	Extra interface{}

	ComputeGas int64
	StorageGas int64

	VirtualCompute int64
	VirtualStorage int64
}

func (GasCharge) Total added in v0.4.0

func (g GasCharge) Total() int64

func (GasCharge) WithExtra added in v0.4.0

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

func (GasCharge) WithVirtual added in v0.4.0

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

type GasOutputs added in v0.5.0

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

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

	GasRefund int64
	GasBurned int64
}

func ComputeGasOutputs added in v0.5.0

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

type Invokee

type Invokee interface {
	Exports() []interface{}
}

type Invoker added in v0.3.1

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

func NewInvoker added in v0.2.8

func NewInvoker() *Invoker

func (*Invoker) Invoke added in v0.3.1

func (inv *Invoker) Invoke(codeCid cid.Cid, rt runtime.Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError)

func (*Invoker) Register added in v0.3.1

func (inv *Invoker) Register(c cid.Cid, instance Invokee, state interface{})

type NtwkVersionGetter added in v0.6.0

type NtwkVersionGetter func(context.Context, abi.ChainEpoch) runtime.NetworkVersion

type Pricelist added in v0.3.0

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 proof.SealVerifyInfo) GasCharge
	OnVerifyPost(info proof.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 added in v0.3.0

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 added in v0.3.0

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

func (*Runtime) AbortStateMsg added in v0.3.0

func (rt *Runtime) AbortStateMsg(msg string)

func (*Runtime) Abortf added in v0.3.0

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

func (*Runtime) ChargeGas added in v0.3.0

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

ChargeGas is spec actors function

func (*Runtime) Context added in v0.3.0

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

func (*Runtime) CreateActor added in v0.3.0

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

func (*Runtime) CurrEpoch added in v0.3.0

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

func (*Runtime) CurrentBalance added in v0.3.0

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

func (*Runtime) DeleteActor added in v0.3.0

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. May only be called by the actor itself.

func (*Runtime) Get added in v0.3.0

func (rt *Runtime) Get(c cid.Cid, o vmr.CBORUnmarshaler) bool

func (*Runtime) GetActorCodeCID added in v0.3.0

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

func (*Runtime) GetBalance added in v0.3.0

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

func (*Runtime) GetRandomnessFromBeacon added in v0.5.0

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

func (*Runtime) GetRandomnessFromTickets added in v0.5.0

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

func (*Runtime) Log added in v0.5.0

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

func (*Runtime) Message added in v0.3.0

func (rt *Runtime) Message() vmr.Message

func (*Runtime) NetworkVersion added in v0.6.0

func (rt *Runtime) NetworkVersion() vmr.NetworkVersion

func (*Runtime) NewActorAddress added in v0.3.0

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

func (*Runtime) Pricelist added in v0.3.0

func (rt *Runtime) Pricelist() Pricelist

func (*Runtime) Put added in v0.3.0

func (rt *Runtime) Put(x vmr.CBORMarshaler) cid.Cid

func (*Runtime) ResolveAddress added in v0.3.0

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

func (*Runtime) Send added in v0.3.0

func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode)

func (*Runtime) StartSpan added in v0.3.0

func (rt *Runtime) StartSpan(name string) vmr.TraceSpan

func (*Runtime) State added in v0.3.0

func (rt *Runtime) State() vmr.StateHandle

func (*Runtime) Store added in v0.3.0

func (rt *Runtime) Store() vmr.Store

func (*Runtime) Syscalls added in v0.3.0

func (rt *Runtime) Syscalls() vmr.Syscalls

func (*Runtime) TotalFilCircSupply added in v0.3.0

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

func (*Runtime) ValidateImmediateCallerAcceptAny added in v0.3.0

func (rt *Runtime) ValidateImmediateCallerAcceptAny()

func (*Runtime) ValidateImmediateCallerIs added in v0.3.0

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

func (*Runtime) ValidateImmediateCallerType added in v0.3.0

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

type SyscallBuilder added in v0.5.0

type SyscallBuilder func(ctx context.Context, cstate *state.StateTree, cst cbor.IpldStore) runtime.Syscalls

func Syscalls added in v0.2.1

func Syscalls(verifier ffiwrapper.Verifier) SyscallBuilder

type UnsafeVM added in v0.5.0

type UnsafeVM struct {
	VM *VM
}

func (*UnsafeVM) MakeRuntime added in v0.5.0

func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, nac uint64) *Runtime

type VM

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

func NewVM

func NewVM(opts *VMOpts) (*VM, error)

func (*VM) ActorBalance

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

func (*VM) ApplyImplicitMessage added in v0.3.0

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 added in v0.5.0

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

func (*VM) GetNtwkVersion added in v0.6.0

func (vm *VM) GetNtwkVersion(ctx context.Context, ce abi.ChainEpoch) runtime.NetworkVersion

func (*VM) Invoke

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

func (*VM) MutateState added in v0.3.0

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 added in v0.2.8

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

func (*VM) StateTree

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

type VMOpts added in v0.5.0

type VMOpts struct {
	StateBase      cid.Cid
	Epoch          abi.ChainEpoch
	Rand           Rand
	Bstore         bstore.Blockstore
	Syscalls       SyscallBuilder
	CircSupplyCalc CircSupplyCalculator
	NtwkVersion    NtwkVersionGetter
	BaseFee        abi.TokenAmount
}

Jump to

Keyboard shortcuts

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