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" gobig "math/big"
"os" "os"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/filecoin-project/lotus/chain/state" "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 { type ExecuteMessageParams struct {
Preroot cid.Cid Preroot cid.Cid
Epoch abi.ChainEpoch Epoch abi.ChainEpoch
Message *types.Message Message *types.Message
CircSupply abi.TokenAmount CircSupply abi.TokenAmount
BaseFee abi.TokenAmount BaseFee abi.TokenAmount
NetworkVersion network.Version
// Rand is an optional vm.Rand implementation to use. If nil, the driver // 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. // 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() 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{ vmOpts := &vm.VMOpts{
StateBase: params.Preroot, StateBase: params.Preroot,
Epoch: params.Epoch, Epoch: params.Epoch,
@ -227,7 +223,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
}, },
Rand: params.Rand, Rand: params.Rand,
BaseFee: params.BaseFee, BaseFee: params.BaseFee,
NetworkVersion: sm.GetNetworkVersion(context.Background(), params.Epoch), NetworkVersion: params.NetworkVersion,
} }
lvm, err := vm.NewVM(context.TODO(), vmOpts) lvm, err := vm.NewVM(context.TODO(), vmOpts)

View File

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