feat: use either lotus vm or fvm consistently
This commit is contained in:
parent
9bb936b75c
commit
b6682f4bbe
@ -112,7 +112,12 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
|
||||
)
|
||||
}
|
||||
|
||||
fromActor, err := vmi.StateTree().GetActor(msg.From)
|
||||
stTree, err := sm.StateTree(bstate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fromActor, err := stTree.GetActor(msg.From)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("call raw get actor: %s", err)
|
||||
}
|
||||
@ -219,7 +224,12 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
|
||||
}
|
||||
}
|
||||
|
||||
fromActor, err := vmi.StateTree().GetActor(msg.From)
|
||||
stTree, err := sm.StateTree(state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fromActor, err := stTree.GetActor(msg.From)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("call raw get actor: %s", err)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ type StateManager struct {
|
||||
compWait map[string]chan struct{}
|
||||
stlk sync.Mutex
|
||||
genesisMsigLk sync.Mutex
|
||||
newVM func(context.Context, *vm.VMOpts) (*vm.VM, error)
|
||||
newVM func(context.Context, *vm.VMOpts) (vm.VMI, error)
|
||||
Syscalls vm.SyscallBuilder
|
||||
preIgnitionVesting []msig0.State
|
||||
postIgnitionVesting []msig0.State
|
||||
@ -142,7 +142,7 @@ func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder,
|
||||
latestVersion: lastVersion,
|
||||
stateMigrations: stateMigrations,
|
||||
expensiveUpgrades: expensiveUpgrades,
|
||||
newVM: vm.NewLotusVM,
|
||||
newVM: vm.NewVM,
|
||||
Syscalls: sys,
|
||||
cs: cs,
|
||||
tsExec: exec,
|
||||
@ -347,12 +347,12 @@ func (sm *StateManager) ValidateChain(ctx context.Context, ts *types.TipSet) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sm *StateManager) SetVMConstructor(nvm func(context.Context, *vm.VMOpts) (*vm.VM, error)) {
|
||||
func (sm *StateManager) SetVMConstructor(nvm func(context.Context, *vm.VMOpts) (vm.VMI, error)) {
|
||||
sm.newVM = nvm
|
||||
}
|
||||
|
||||
func (sm *StateManager) VMConstructor() func(context.Context, *vm.VMOpts) (*vm.VM, error) {
|
||||
return func(ctx context.Context, opts *vm.VMOpts) (*vm.VM, error) {
|
||||
func (sm *StateManager) VMConstructor() func(context.Context, *vm.VMOpts) (vm.VMI, error) {
|
||||
return func(ctx context.Context, opts *vm.VMOpts) (vm.VMI, error) {
|
||||
return sm.newVM(ctx, opts)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package vm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -12,3 +13,11 @@ type VMI interface {
|
||||
ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error)
|
||||
Flush(ctx context.Context) (cid.Cid, error)
|
||||
}
|
||||
|
||||
func NewVM(ctx context.Context, opts *VMOpts) (VMI, error) {
|
||||
if os.Getenv("LOTUS_USE_FVM_DOESNT_WORK_YET") == "1" {
|
||||
return NewFVM(ctx, opts)
|
||||
}
|
||||
|
||||
return NewLotusVM(ctx, opts)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user