-
Notifications
You must be signed in to change notification settings - Fork 462
/
vm.go
65 lines (48 loc) · 1.87 KB
/
vm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package vm
import (
"context"
"fmt"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/venus/pkg/vm/dispatch"
"github.com/filecoin-project/venus/pkg/vm/register"
"github.com/filecoin-project/venus/pkg/vm/vmcontext"
)
// Re-exports
type VmOption = vmcontext.VmOption //nolint
type Ret = vmcontext.Ret
// Interpreter is the LegacyVM.
type Interpreter = vmcontext.VMInterpreter
type (
SyscallsImpl = vmcontext.SyscallsImpl
SyscallsStateView = vmcontext.SyscallsStateView
)
type (
ExecCallBack = vmcontext.ExecCallBack
VmMessage = vmcontext.VmMessage //nolint
FakeSyscalls = vmcontext.FakeSyscalls
ChainRandomness = vmcontext.HeadChainRandomness
)
type Interface = vmcontext.Interface // nolint
// NewLegacyVM creates a new LegacyVM interpreter.
func NewLegacyVM(ctx context.Context, option VmOption) (Interpreter, error) {
if option.NetworkVersion >= network.Version16 {
return nil, fmt.Errorf("the legacy VM does not support network versions 16+")
}
if option.ActorCodeLoader == nil {
option.ActorCodeLoader = GetDefaultActors()
}
return vmcontext.NewLegacyVM(ctx, option.ActorCodeLoader, option)
}
// GetDefaultActors return a code loader with the built-in actors that come with the system.
var GetDefaultActors = register.GetDefaultActros
// ActorCodeLoader allows yo to load an actor's code based on its id an epoch.
type ActorCodeLoader = dispatch.CodeLoader
// ActorMethodSignature wraps a specific method and allows you to encode/decodes input/output bytes into concrete types.
type ActorMethodSignature = dispatch.MethodSignature
type (
ILookBack = vmcontext.ILookBack
LookbackStateGetter = vmcontext.LookbackStateGetter
TipSetGetter = vmcontext.TipSetGetter
)
var ResolveToDeterministicAddress = vmcontext.ResolveToDeterministicAddress
var DrawRandomnessFromDigest = vmcontext.DrawRandomnessFromDigest