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:
parent
65ee059591
commit
8df5b81f24
@ -227,6 +227,10 @@ type VMOpts struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewLegacyVM(ctx context.Context, opts *VMOpts) (*LegacyVM, error) {
|
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)
|
buf := blockstore.NewBuffered(opts.Bstore)
|
||||||
cst := cbor.NewCborStore(buf)
|
cst := cbor.NewCborStore(buf)
|
||||||
state, err := state.LoadStateTree(cst, opts.StateBase)
|
state, err := state.LoadStateTree(cst, opts.StateBase)
|
||||||
|
@ -160,7 +160,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
|
|||||||
return big.Zero(), nil
|
return big.Zero(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm.NewLegacyVM(ctx, vmopt)
|
return vm.NewVM(ctx, vmopt)
|
||||||
})
|
})
|
||||||
|
|
||||||
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
|
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
|
||||||
@ -242,35 +242,34 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
|
|||||||
LookbackState: lookback,
|
LookbackState: lookback,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var vmi vm.Interface
|
||||||
|
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
|
||||||
lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts)
|
lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cid.Undef, err
|
return nil, cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
invoker := filcns.NewActorRegistry()
|
invoker := filcns.NewActorRegistry()
|
||||||
|
|
||||||
// register the chaos actor if required by the vector.
|
|
||||||
if chaosOn, ok := d.selector["chaos_actor"]; ok && chaosOn == "true" {
|
|
||||||
av, _ := actorstypes.VersionForNetwork(params.NetworkVersion)
|
av, _ := actorstypes.VersionForNetwork(params.NetworkVersion)
|
||||||
registry := builtin.MakeRegistryLegacy([]rtt.VMActor{chaos.Actor{}})
|
registry := builtin.MakeRegistryLegacy([]rtt.VMActor{chaos.Actor{}})
|
||||||
invoker.Register(av, nil, registry)
|
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 := vmi.ApplyMessage(d.ctx, toChainMsg(params.Message))
|
||||||
|
|
||||||
ret, err := lvm.ApplyMessage(d.ctx, toChainMsg(params.Message))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cid.Undef, err
|
return nil, cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var root cid.Cid
|
var root cid.Cid
|
||||||
if d.vmFlush {
|
root, err = vmi.Flush(d.ctx)
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret, root, err
|
return ret, root, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user