fix: make test vector extraction work with the FVM

This also ignores the VM "Flush" option and instead, flushes
unconditionally (in the FVM):

1. In the FVM, we don't read blocks on flush (ever).
2. All _uses_ of TVX use a "proxy" blockstore that buffers writes, so
nothing should actually get flushed to lotus.
This commit is contained in:
Steven Allen 2022-08-08 11:13:00 -07:00 committed by Aayush
parent 65ee059591
commit 8df5b81f24
2 changed files with 22 additions and 19 deletions

View File

@ -227,6 +227,10 @@ type VMOpts struct {
}
func NewLegacyVM(ctx context.Context, opts *VMOpts) (*LegacyVM, error) {
if opts.NetworkVersion >= network.Version16 {
return nil, xerrors.Errorf("the legacy VM does not support network versions 16+")
}
buf := blockstore.NewBuffered(opts.Bstore)
cst := cbor.NewCborStore(buf)
state, err := state.LoadStateTree(cst, opts.StateBase)

View File

@ -160,7 +160,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
return big.Zero(), nil
}
return vm.NewLegacyVM(ctx, vmopt)
return vm.NewVM(ctx, vmopt)
})
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
@ -242,35 +242,34 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
LookbackState: lookback,
}
lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts)
if err != nil {
return nil, cid.Undef, err
}
invoker := filcns.NewActorRegistry()
// register the chaos actor if required by the vector.
var vmi vm.Interface
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts)
if err != nil {
return nil, cid.Undef, err
}
invoker := filcns.NewActorRegistry()
av, _ := actorstypes.VersionForNetwork(params.NetworkVersion)
registry := builtin.MakeRegistryLegacy([]rtt.VMActor{chaos.Actor{}})
invoker.Register(av, nil, registry)
lvm.SetInvoker(invoker)
vmi = lvm
} else {
fvm, err := vm.NewVM(context.TODO(), vmOpts)
if err != nil {
return nil, cid.Undef, err
}
vmi = fvm
}
lvm.SetInvoker(invoker)
ret, err := lvm.ApplyMessage(d.ctx, toChainMsg(params.Message))
ret, err := vmi.ApplyMessage(d.ctx, toChainMsg(params.Message))
if err != nil {
return nil, cid.Undef, err
}
var root cid.Cid
if d.vmFlush {
// flush the VM, committing the state tree changes and forcing a
// recursive copoy from the temporary blcokstore to the real blockstore.
root, err = lvm.Flush(d.ctx)
} else {
root, err = lvm.StateTree().(*state.StateTree).Flush(d.ctx)
}
root, err = vmi.Flush(d.ctx)
return ret, root, err
}