Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeGasOverestimationBurn(gasUsed, gasLimit int64) (int64, int64)
- func Copy(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid) error
- func DecodeParams(b []byte, out interface{}) error
- func DumpActorState(i *ActorRegistry, act *types.Actor, b []byte) (interface{}, error)
- func ResolveToDeterministicAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, error)
- func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, address.Address, aerrors.ActorError)
- type ActorPredicate
- type ActorRegistry
- func (ar *ActorRegistry) Create(codeCid cid.Cid, rt vmr.Runtime) (*types.Actor, aerrors.ActorError)
- func (ar *ActorRegistry) Invoke(codeCid cid.Cid, rt vmr.Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError)
- func (ar *ActorRegistry) Register(av actorstypes.Version, pred ActorPredicate, vmactors []builtin.RegistryEntry)
- type ApplyRet
- type CircSupplyCalculator
- type FVM
- type FvmExtern
- type GasCharge
- type GasOutputs
- type Interface
- type LegacyVM
- func (vm *LegacyVM) ActorStore(ctx context.Context) adt.Store
- func (vm *LegacyVM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error)
- func (vm *LegacyVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error)
- func (vm *LegacyVM) Flush(ctx context.Context) (cid.Cid, error)
- func (vm *LegacyVM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error)
- func (vm *LegacyVM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError)
- func (vm *LegacyVM) SetInvoker(i *ActorRegistry)
- func (vm *LegacyVM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *types.Message, ...) (bool, error)
- func (vm *LegacyVM) StateTree() types.StateTree
- type LookbackStateGetter
- type Message
- type MethodMeta
- type NtwkVersionGetter
- type Pricelist
- type Rand
- type Runtime
- func (rt *Runtime) AbortStateMsg(msg string)
- func (rt *Runtime) Abortf(code exitcode.ExitCode, msg string, args ...interface{})
- func (rt *Runtime) BaseFee() abi.TokenAmount
- func (rt *Runtime) ChargeGas(name string, compute int64, virtual int64)
- func (rt *Runtime) Context() context.Context
- func (rt *Runtime) CreateActor(codeID cid.Cid, addr address.Address)
- func (rt *Runtime) CurrEpoch() abi.ChainEpoch
- func (rt *Runtime) CurrentBalance() abi.TokenAmount
- func (rt *Runtime) DeleteActor(beneficiary address.Address)
- func (rt *Runtime) GetActorCodeCID(addr address.Address) (ret cid.Cid, ok bool)
- func (rt *Runtime) GetBalance(a address.Address) (types.BigInt, aerrors.ActorError)
- func (rt *Runtime) GetRandomnessFromBeacon(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, ...) abi.Randomness
- func (rt *Runtime) GetRandomnessFromTickets(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, ...) abi.Randomness
- func (rt *Runtime) Log(level rtt.LogLevel, msg string, args ...interface{})
- func (rt *Runtime) NetworkVersion() network.Version
- func (rt *Runtime) NewActorAddress() address.Address
- func (rt *Runtime) Pricelist() Pricelist
- func (rt *Runtime) ResolveAddress(addr address.Address) (ret address.Address, ok bool)
- func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m cbor.Marshaler, ...) exitcode.ExitCode
- func (rt *Runtime) StartSpan(name string) func()
- func (rt *Runtime) StateCreate(obj cbor.Marshaler)
- func (rt *Runtime) StateReadonly(obj cbor.Unmarshaler)
- func (rt *Runtime) StateTransaction(obj cbor.Er, f func())
- func (rt *Runtime) StoreGet(c cid.Cid, o cbor.Unmarshaler) bool
- func (rt *Runtime) StorePut(x cbor.Marshaler) cid.Cid
- func (rt *Runtime) TotalFilCircSupply() abi.TokenAmount
- func (rt *Runtime) ValidateImmediateCallerAcceptAny()
- func (rt *Runtime) ValidateImmediateCallerIs(as ...address.Address)
- func (rt *Runtime) ValidateImmediateCallerType(ts ...cid.Cid)
- type SyscallBuilder
- type TipSetGetter
- type UnsafeVM
- type VMOpts
Constants ¶
const CborCodec = 0x51
const MaxCallDepth = 4096
Variables ¶
var ( StatSends uint64 StatApplied uint64 )
stat counters
var BatchSealVerifyParallelism = goruntime.NumCPU()
var EmptyObjectCid cid.Cid
var EnableDetailedTracing = os.Getenv("LOTUS_VM_ENABLE_TRACING") == "1"
EnableDetailedTracing has different behaviour in the LegacyVM and FVM. In the LegacyVM, it enables detailed gas tracing, slowing down execution. In the FVM, it enables execution traces, which are primarily used to observe subcalls.
var Prices = map[abi.ChainEpoch]Pricelist{ abi.ChainEpoch(0): &pricelistV0{ computeGasMulti: 1, storageGasMulti: 1000, onChainMessageComputeBase: 38863, onChainMessageStorageBase: 36, onChainMessageStoragePerByte: 1, onChainReturnValuePerByte: 1, sendBase: 29233, sendTransferFunds: 27500, sendTransferOnlyPremium: 159672, sendInvokeMethod: -5377, ipldGetBase: 75242, ipldPutBase: 84070, ipldPutPerByte: 1, createActorCompute: 1108454, createActorStorage: 36 + 40, deleteActor: -(36 + 40), verifySignature: map[crypto.SigType]int64{ crypto.SigTypeBLS: 16598605, crypto.SigTypeSecp256k1: 1637292, crypto.SigTypeDelegated: 1637292, }, hashingBase: 31355, computeUnsealedSectorCidBase: 98647, verifySealBase: 2000, verifyAggregateSealBase: 0, verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{ abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: { flat: 123861062, scale: 9226981, }, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1: { flat: 748593537, scale: 85639, }, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1: { flat: 748593537, scale: 85639, }, }, verifyPostDiscount: true, verifyConsensusFault: 495422, }, abi.ChainEpoch(build.UpgradeCalicoHeight): &pricelistV0{ computeGasMulti: 1, storageGasMulti: 1300, onChainMessageComputeBase: 38863, onChainMessageStorageBase: 36, onChainMessageStoragePerByte: 1, onChainReturnValuePerByte: 1, sendBase: 29233, sendTransferFunds: 27500, sendTransferOnlyPremium: 159672, sendInvokeMethod: -5377, ipldGetBase: 114617, ipldPutBase: 353640, ipldPutPerByte: 1, createActorCompute: 1108454, createActorStorage: 36 + 40, deleteActor: -(36 + 40), verifySignature: map[crypto.SigType]int64{ crypto.SigTypeBLS: 16598605, crypto.SigTypeSecp256k1: 1637292, }, hashingBase: 31355, computeUnsealedSectorCidBase: 98647, verifySealBase: 2000, verifyAggregateSealPer: map[abi.RegisteredSealProof]int64{ abi.RegisteredSealProof_StackedDrg32GiBV1_1: 449900, abi.RegisteredSealProof_StackedDrg64GiBV1_1: 359272, }, verifyAggregateSealSteps: map[abi.RegisteredSealProof]stepCost{ abi.RegisteredSealProof_StackedDrg32GiBV1_1: { {4, 103994170}, {7, 112356810}, {13, 122912610}, {26, 137559930}, {52, 162039100}, {103, 210960780}, {205, 318351180}, {410, 528274980}, }, abi.RegisteredSealProof_StackedDrg64GiBV1_1: { {4, 102581240}, {7, 110803030}, {13, 120803700}, {26, 134642130}, {52, 157357890}, {103, 203017690}, {205, 304253590}, {410, 509880640}, }, }, verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{ abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: { flat: 117680921, scale: 43780, }, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1: { flat: 117680921, scale: 43780, }, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1: { flat: 117680921, scale: 43780, }, }, verifyPostDiscount: false, verifyConsensusFault: 495422, verifyReplicaUpdate: 36316136, }, build.UpgradeHyggeHeight: &pricelistV0{ computeGasMulti: 1, storageGasMulti: 1300, onChainMessageComputeBase: 38863 + 475000, onChainMessageStorageBase: 36, onChainMessageStoragePerByte: 1, onChainReturnValuePerByte: 1, }, }
Prices are the price lists per starting epoch. Public for testing purposes (concretely to allow the test vector runner to rebase prices).
Functions ¶
func ComputeGasOverestimationBurn ¶
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 DumpActorState ¶
func DumpActorState(i *ActorRegistry, act *types.Actor, b []byte) (interface{}, error)
func ResolveToDeterministicAddr ¶
func ResolveToDeterministicAddr(state types.StateTree, cst cbor.IpldStore, addr address.Address) (address.Address, error)
ResolveToDeterministicAddr returns the public key type of address (`BLS`/`SECP256K1`) of an actor identified by `addr`, or its delegated address.
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 ¶
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 actorstypes.Version) ActorPredicate
type ActorRegistry ¶
type ActorRegistry struct { Methods map[cid.Cid]map[abi.MethodNum]MethodMeta // 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(av actorstypes.Version, pred ActorPredicate, vmactors []builtin.RegistryEntry)
type ApplyRet ¶
type ApplyRet struct { types.MessageReceipt ActorErr aerrors.ActorError ExecutionTrace types.ExecutionTrace Duration time.Duration GasCosts *GasOutputs Events []types.Event }
type CircSupplyCalculator ¶
type CircSupplyCalculator func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error)
type FVM ¶
type FVM struct {
// contains filtered or unexported fields
}
func (*FVM) ApplyImplicitMessage ¶
func (*FVM) ApplyMessage ¶
type FvmExtern ¶
type FvmExtern struct { Rand blockstore.Blockstore // contains filtered or unexported fields }
func (*FvmExtern) VerifyConsensusFault ¶
func (x *FvmExtern) VerifyConsensusFault(ctx context.Context, a, b, extra []byte) (*ffi_cgo.ConsensusFault, int64)
VerifyConsensusFault is similar to the one in syscalls.go used by the Lotus VM, except it never errors Errors are logged and "no fault" is returned, which is functionally what go-actors does anyway
type GasCharge ¶
type GasCharge struct { Name string Extra interface{} ComputeGas int64 StorageGas int64 VirtualCompute int64 VirtualStorage int64 }
func (GasCharge) WithVirtual ¶
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 Interface ¶
type Interface interface { // Applies the given message onto the VM's current state, returning the result of the execution ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) // Same as above but for system messages (the Cron invocation and block reward payments). // Must NEVER fail. ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) // Flush all buffered objects into the state store provided to the VM at construction. Flush(ctx context.Context) (cid.Cid, error) }
func NewDualExecutionFVM ¶
type LegacyVM ¶
type LegacyVM struct { Syscalls SyscallBuilder // contains filtered or unexported fields }
func (*LegacyVM) ActorStore ¶
Get the buffered blockstore associated with the LegacyVM. This includes any temporary blocks produced during this LegacyVM's execution.
func (*LegacyVM) ApplyImplicitMessage ¶
func (*LegacyVM) ApplyMessage ¶
func (*LegacyVM) GetCircSupply ¶
func (*LegacyVM) SetInvoker ¶
func (vm *LegacyVM) SetInvoker(i *ActorRegistry)
func (*LegacyVM) ShouldBurn ¶
type LookbackStateGetter ¶
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func (*Message) ValueReceived ¶
func (m *Message) ValueReceived() abi.TokenAmount
type NtwkVersionGetter ¶
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 proof7.SealVerifyInfo) GasCharge OnVerifyAggregateSeals(aggregate proof7.AggregateSealVerifyProofAndInfos) GasCharge OnVerifyReplicaUpdate(update proof7.ReplicaUpdateInfo) GasCharge OnVerifyPost(info proof7.WindowPoStVerifyInfo) GasCharge OnVerifyConsensusFault() GasCharge }
Pricelist provides prices for operations in the LegacyVM.
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 ¶
func (*Runtime) AbortStateMsg ¶
func (*Runtime) BaseFee ¶
func (rt *Runtime) BaseFee() abi.TokenAmount
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 (*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) NetworkVersion ¶
func (*Runtime) NewActorAddress ¶
func (rt *Runtime) NewActorAddress() address.Address
func (*Runtime) ResolveAddress ¶
func (*Runtime) StateCreate ¶
func (*Runtime) StateReadonly ¶
func (rt *Runtime) StateReadonly(obj cbor.Unmarshaler)
func (*Runtime) StateTransaction ¶
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 ¶
func Syscalls ¶
func Syscalls(verifier storiface.Verifier) SyscallBuilder
type TipSetGetter ¶
type VMOpts ¶
type VMOpts struct { StateBase cid.Cid Epoch abi.ChainEpoch Timestamp uint64 Rand Rand Bstore blockstore.Blockstore Actors *ActorRegistry Syscalls SyscallBuilder CircSupplyCalc CircSupplyCalculator NetworkVersion network.Version BaseFee abi.TokenAmount LookbackState LookbackStateGetter TipSetGetter TipSetGetter Tracing bool // ReturnEvents decodes and returns emitted events. ReturnEvents bool }