tvx runner: use network version from variant.

This commit is contained in:
Raúl Kripalani 2022-01-04 17:23:17 +00:00
parent 921fda94c7
commit 2c3d0d826d
2 changed files with 20 additions and 21 deletions

View File

@ -5,6 +5,8 @@ import (
gobig "math/big"
"os"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/filecoin-project/lotus/chain/state"
@ -187,11 +189,12 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
}
type ExecuteMessageParams struct {
Preroot cid.Cid
Epoch abi.ChainEpoch
Message *types.Message
CircSupply abi.TokenAmount
BaseFee abi.TokenAmount
Preroot cid.Cid
Epoch abi.ChainEpoch
Message *types.Message
CircSupply abi.TokenAmount
BaseFee abi.TokenAmount
NetworkVersion network.Version
// 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.
@ -210,13 +213,6 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
params.Rand = NewFixedRand()
}
// dummy state manager; only to reference the GetNetworkVersion method,
// which does not depend on state.
sm, err := stmgr.NewStateManager(nil, filcns.NewTipSetExecutor(), nil, filcns.DefaultUpgradeSchedule(), nil)
if err != nil {
return nil, cid.Cid{}, err
}
vmOpts := &vm.VMOpts{
StateBase: params.Preroot,
Epoch: params.Epoch,
@ -227,7 +223,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
},
Rand: params.Rand,
BaseFee: params.BaseFee,
NetworkVersion: sm.GetNetworkVersion(context.Background(), params.Epoch),
NetworkVersion: params.NetworkVersion,
}
lvm, err := vm.NewVM(context.TODO(), vmOpts)

View File

@ -14,6 +14,7 @@ import (
"github.com/fatih/color"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-state-types/network"
"github.com/hashicorp/go-multierror"
blocks "github.com/ipfs/go-block-format"
"github.com/ipfs/go-blockservice"
@ -54,7 +55,8 @@ var TipsetVectorOpts struct {
func ExecuteMessageVector(r Reporter, vector *schema.TestVector, variant *schema.Variant) (diffs []string, err error) {
var (
ctx = context.Background()
baseEpoch = variant.Epoch
baseEpoch = abi.ChainEpoch(variant.Epoch)
nv = network.Version(variant.NetworkVersion)
root = vector.Pre.StateTree.RootCID
)
@ -76,18 +78,19 @@ func ExecuteMessageVector(r Reporter, vector *schema.TestVector, variant *schema
// add the epoch offset if one is set.
if m.EpochOffset != nil {
baseEpoch += *m.EpochOffset
baseEpoch += abi.ChainEpoch(*m.EpochOffset)
}
// Execute the message.
var ret *vm.ApplyRet
ret, root, err = driver.ExecuteMessage(bs, ExecuteMessageParams{
Preroot: root,
Epoch: abi.ChainEpoch(baseEpoch),
Message: msg,
BaseFee: BaseFeeOrDefault(vector.Pre.BaseFee),
CircSupply: CircSupplyOrDefault(vector.Pre.CircSupply),
Rand: NewReplayingRand(r, vector.Randomness),
Preroot: root,
Epoch: baseEpoch,
Message: msg,
BaseFee: BaseFeeOrDefault(vector.Pre.BaseFee),
CircSupply: CircSupplyOrDefault(vector.Pre.CircSupply),
Rand: NewReplayingRand(r, vector.Randomness),
NetworkVersion: nv,
})
if err != nil {
r.Fatalf("fatal failure when executing message: %s", err)