vmcontext

package
v1.14.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: Apache-2.0, MIT Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAvailableExecutionLanes is the number of available execution lanes; it is the bound of
	// concurrent active executions.
	// This is the default value in filecoin-ffi
	DefaultAvailableExecutionLanes = 4
	// DefaultPriorityExecutionLanes is the number of reserved execution lanes for priority computations.
	// This is purely userspace, but we believe it is a reasonable default, even with more available
	// lanes.
	DefaultPriorityExecutionLanes = 2
)
View Source
const MaxCallDepth = 4096

Variables

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

Functions

func DrawRandomnessFromDigest added in v1.14.0

func DrawRandomnessFromDigest(digest [32]byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error)

func Failure added in v0.9.7

func Failure(exitCode exitcode.ExitCode, gasAmount int64) types.MessageReceipt

Failure returns with a non-zero exit code.

func NewActorStateHandle

func NewActorStateHandle(ctx actorStateHandleContext) rt5.StateHandle

NewActorStateHandle returns a new `ActorStateHandle`

Note: just visible for testing.

func ResolveToDeterministicAddress added in v1.10.0

func ResolveToDeterministicAddress(ctx context.Context, state tree.Tree, addr address.Address, cst cbor.IpldStore) (address.Address, error)

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, *types.Message, *Ret) error

type ExecutionLane added in v1.12.0

type ExecutionLane int
const (
	// ExecutionLaneDefault signifies a default, non prioritized execution lane.
	ExecutionLaneDefault ExecutionLane = iota
	// ExecutionLanePriority signifies a prioritized execution lane with reserved resources.
	ExecutionLanePriority
)

type FakeSyscalls

type FakeSyscalls struct{}

func (FakeSyscalls) BatchVerifySeals

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

func (FakeSyscalls) ComputeUnsealedSectorCID

func (f FakeSyscalls) ComputeUnsealedSectorCID(context.Context, abi.RegisteredSealProof, []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) (*rt7.ConsensusFault, error)

func (FakeSyscalls) VerifySeal

func (f FakeSyscalls) VerifySeal(ctx context.Context, info proof7.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) VerifyWindowPoSt added in v1.2.0

func (f FakeSyscalls) VerifyWindowPoSt(ctx context.Context, info proof7.WindowPoStVerifyInfo) error

func (FakeSyscalls) VerifyWinningPoSt

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

type GasChargeBlockStore

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

GasChargeBlockStore in addition to the basic blockstore read and write capabilities, a certain amount of gas consumption will be deducted for each operation

func NewGasChargeBlockStore added in v1.6.0

func NewGasChargeBlockStore(gasTank *gas.GasTracker, pricelist gas.Pricelist, inner cbor.IpldBlockstore) *GasChargeBlockStore

func (*GasChargeBlockStore) Get

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

Get charge gas and than get the value of cid

func (*GasChargeBlockStore) Put

Put first charge gas and than save block

type HeadChainRandomness added in v1.1.0

type HeadChainRandomness interface {
	GetChainRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
	GetBeaconRandomness(ctx context.Context, round abi.ChainEpoch) ([32]byte, error)
}

ChainRandomness define randomness method in filecoin

type ILookBack added in v1.1.2

type ILookBack interface {
	StateView(ctx context.Context, ts *types.TipSet) (*state.View, error)
	GetLookbackTipSetForRound(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, version network.Version) (*types.TipSet, cid.Cid, error)
}

type Interface added in v1.6.0

type Interface interface {
	ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*Ret, error)
	ApplyImplicitMessage(ctx context.Context, msg types.ChainMsg) (*Ret, error)
	Flush(ctx context.Context) (cid.Cid, error)
}

func NewVMExecutor added in v1.12.0

func NewVMExecutor(vmi Interface, lane ExecutionLane) Interface

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 LegacyVM added in v1.6.0

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

LegacyVM holds the stateView and executes messages over the stateView.

func NewLegacyVM added in v1.6.0

func NewLegacyVM(ctx context.Context, actorImpls ActorImplLookup, vmOption VmOption) (*LegacyVM, error)

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

func (*LegacyVM) ActorStore added in v1.6.0

func (vm *LegacyVM) ActorStore(ctx context.Context) adt.Store

Get the buffered blockstore associated with the LegacyVM. This includes any temporary blocks produced during this LegacyVM's execution.

func (*LegacyVM) ApplyImplicitMessage added in v1.6.0

func (vm *LegacyVM) ApplyImplicitMessage(ctx context.Context, msg types.ChainMsg) (*Ret, error)

func (*LegacyVM) ApplyMessage added in v1.6.0

func (vm *LegacyVM) ApplyMessage(ctx context.Context, msg types.ChainMsg) (*Ret, error)

todo estimate gasLimit

func (*LegacyVM) ContextStore added in v1.6.0

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

ContextStore provides access To specs-actors adt library.

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

func (*LegacyVM) CurrentEpoch added in v1.6.0

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

CurrentEpoch implements runtime.Runtime.

func (*LegacyVM) Flush added in v1.6.0

func (vm *LegacyVM) Flush(ctx context.Context) (tree.Root, error)

nolint

func (*LegacyVM) GetCircSupply added in v1.6.0

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

func (*LegacyVM) NetworkVersion added in v1.6.0

func (vm *LegacyVM) NetworkVersion() network.Version

func (*LegacyVM) StateTree added in v1.6.0

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

type LookbackStateGetter added in v1.1.2

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

func LookbackStateGetterForTipset added in v1.1.2

func LookbackStateGetterForTipset(ctx context.Context, backer ILookBack, fork fork.IFork, ts *types.TipSet) LookbackStateGetter

type Ret

type Ret struct {
	GasTracker *gas.GasTracker
	OutPuts    gas.GasOutputs
	Receipt    types.MessageReceipt
	ActorErr   error
	Duration   time.Duration
	Events     []types.Event
}

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, proof7 abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error)
	VerifySeal(ctx context.Context, info proof7.SealVerifyInfo) error
	BatchVerifySeals(ctx context.Context, vis map[address.Address][]proof7.SealVerifyInfo) (map[address.Address][]bool, error)
	VerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) error
	VerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) error
	VerifyPoSt(ctx context.Context, info proof7.WindowPoStVerifyInfo) error
	VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte, curEpoch abi.ChainEpoch, msg VmMessage, gasIpld cbornode.IpldStore, view SyscallsStateView, getter LookbackStateGetter) (*rt7.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 {
	ResolveToDeterministicAddress(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)
	GetNetworkVersion(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 TipSetGetter added in v1.10.0

type TipSetGetter func(context.Context, abi.ChainEpoch) (types.TipSetKey, error)

func TipSetGetterForTipset added in v1.10.0

func TipSetGetterForTipset(tsGet func(context.Context, *types.TipSet, abi.ChainEpoch, bool) (*types.TipSet, error),
	ts *types.TipSet,
) TipSetGetter

type VMDebugMsg

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

VMDebugMsg for vm debug

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

WriteToFile write debug message to file

func (*VMDebugMsg) WriteToTerminal

func (debug *VMDebugMsg) WriteToTerminal()

WriteToTerminal write debug message to terminal

type VMInterpreter

type VMInterpreter interface {
	Interface

	StateTree() tree.Tree
}

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 (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
	LookbackStateGetter  LookbackStateGetter
	NetworkVersion       network.Version
	Rnd                  HeadChainRandomness
	BaseFee              abi.TokenAmount
	Fork                 fork.IFork
	ActorCodeLoader      *dispatch.CodeLoader
	Epoch                abi.ChainEpoch
	Timestamp            uint64
	GasPriceSchedule     *gas.PricesSchedule
	PRoot                cid.Cid
	Bsstore              blockstoreutil.Blockstore
	SysCallsImpl         SyscallsImpl
	TipSetGetter         TipSetGetter
	Tracing              bool

	ActorDebugging bool
	// ReturnEvents decodes and returns emitted events.
	ReturnEvents bool
	// ExecutionLane specifies the execution priority of the created vm
	ExecutionLane ExecutionLane
}

Jump to

Keyboard shortcuts

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