From 14ef069ea184f873eca8362fa497919942ffc89c Mon Sep 17 00:00:00 2001 From: Aayush Date: Mon, 7 Nov 2022 16:50:55 -0500 Subject: [PATCH] tvx: fixup VM creation --- cmd/tvx/stores.go | 3 +-- conformance/driver.go | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/cmd/tvx/stores.go b/cmd/tvx/stores.go index 0c06aa83e..9035c482a 100644 --- a/cmd/tvx/stores.go +++ b/cmd/tvx/stores.go @@ -5,8 +5,6 @@ import ( "log" "sync" - "golang.org/x/xerrors" - "github.com/fatih/color" blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-blockservice" @@ -18,6 +16,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" format "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-merkledag" + "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/blockstore" diff --git a/conformance/driver.go b/conformance/driver.go index b5550580e..db8f2ccba 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -256,11 +256,21 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP lvm.SetInvoker(invoker) vmi = lvm } else { - fvm, err := vm.NewVM(context.TODO(), vmOpts) - if err != nil { - return nil, cid.Undef, err + if vmOpts.NetworkVersion >= network.Version16 { + fvm, err := vm.NewFVM(context.TODO(), vmOpts) + if err != nil { + return nil, cid.Undef, err + } + vmi = fvm + } else { + lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts) + if err != nil { + return nil, cid.Undef, err + } + invoker := filcns.NewActorRegistry() + lvm.SetInvoker(invoker) + vmi = lvm } - vmi = fvm } ret, err := vmi.ApplyMessage(d.ctx, toChainMsg(params.Message)) @@ -269,7 +279,13 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP } var root cid.Cid - root, err = vmi.Flush(d.ctx) + if d.vmFlush { + // flush the VM, committing the state tree changes and forcing a + // recursive copy from the temporary blockstore to the real blockstore. + root, err = vmi.Flush(d.ctx) + } else { + root, err = vmi.(*vm.LegacyVM).StateTree().(*state.StateTree).Flush(d.ctx) + } return ret, root, err }