tvx and conformance: use precondition state tree as the lookback tree.
This commit is contained in:
parent
5434cfdaa9
commit
9eb8103866
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
||||
@ -199,6 +200,9 @@ type ExecuteMessageParams struct {
|
||||
// Rand is an optional vm.Rand implementation to use. If nil, the driver
|
||||
// will use a vm.Rand that returns a fixed value for all calls.
|
||||
Rand vm.Rand
|
||||
|
||||
// Lookback is the LookbackStateGetter; returns the state tree at a given epoch.
|
||||
Lookback vm.LookbackStateGetter
|
||||
}
|
||||
|
||||
// ExecuteMessage executes a conformance test vector message in a temporary VM.
|
||||
@ -213,6 +217,17 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
|
||||
params.Rand = NewFixedRand()
|
||||
}
|
||||
|
||||
// TODO: This lookback state returns the supplied precondition state tree, unconditionally.
|
||||
// This is obviously not correct, but the lookback state tree is only used to validate the
|
||||
// worker key when verifying a consensus fault. If the worker key hasn't changed in the
|
||||
// current finality window, this workaround is enough.
|
||||
// The correct solutions are documented in https://github.com/filecoin-project/ref-fvm/issues/381,
|
||||
// but they're much harder to implement, and the tradeoffs aren't clear.
|
||||
var lookback vm.LookbackStateGetter = func(ctx context.Context, epoch abi.ChainEpoch) (*state.StateTree, error) {
|
||||
cst := cbor.NewCborStore(bs)
|
||||
return state.LoadStateTree(cst, params.Preroot)
|
||||
}
|
||||
|
||||
vmOpts := &vm.VMOpts{
|
||||
StateBase: params.Preroot,
|
||||
Epoch: params.Epoch,
|
||||
@ -224,6 +239,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
|
||||
Rand: params.Rand,
|
||||
BaseFee: params.BaseFee,
|
||||
NetworkVersion: params.NetworkVersion,
|
||||
LookbackState: lookback,
|
||||
}
|
||||
|
||||
lvm, err := vm.NewVM(context.TODO(), vmOpts)
|
||||
|
Loading…
Reference in New Issue
Block a user