diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index fbf7b6785b0..d85aa810f72 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -166,7 +166,7 @@ func TestForkHeightTriggers(t *testing.T) { inv := filcns.NewActorRegistry() inv.Register(nil, testActor{}) - sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) { + sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.VMI, error) { nvm, err := vm.NewLotusVM(ctx, vmopt) if err != nil { return nil, err @@ -281,7 +281,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) { inv := filcns.NewActorRegistry() inv.Register(nil, testActor{}) - sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) { + sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.VMI, error) { nvm, err := vm.NewLotusVM(ctx, vmopt) if err != nil { return nil, err @@ -500,7 +500,7 @@ func TestForkPreMigration(t *testing.T) { inv := filcns.NewActorRegistry() inv.Register(nil, testActor{}) - sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) { + sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.VMI, error) { nvm, err := vm.NewLotusVM(ctx, vmopt) if err != nil { return nil, err diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 743e0fdeeb1..c8f8a0d9e19 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -5,6 +5,8 @@ import ( "context" "time" + "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/lotus/build" @@ -215,9 +217,24 @@ type FVM struct { } func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { + circToReport := opts.FilVested + // For v14 (and earlier), we perform the FilVested portion of the calculation, and let the FVM dynamically do the rest + // v15 and after, the circ supply is always constant per epoch, so we calculate the base and report it at creation + if opts.NetworkVersion >= network.Version15 { + state, err := state.LoadStateTree(cbor.NewCborStore(opts.Bstore), opts.StateBase) + if err != nil { + return nil, err + } + + circToReport, err = opts.CircSupplyCalc(ctx, opts.Epoch, state) + if err != nil { + return nil, err + } + } + fvm, err := ffi.CreateFVM(0, &FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore, lbState: opts.LookbackState, base: opts.StateBase, epoch: opts.Epoch}, - opts.Epoch, opts.BaseFee, opts.FilVested, opts.NetworkVersion, opts.StateBase, + opts.Epoch, opts.BaseFee, circToReport, opts.NetworkVersion, opts.StateBase, ) if err != nil { return nil, err diff --git a/conformance/driver.go b/conformance/driver.go index 6af4372d2ec..0a24f07ef15 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -155,7 +155,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params results: []*vm.ApplyRet{}, } - sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (*vm.VM, error) { + sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.VMI, error) { vmopt.CircSupplyCalc = func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error) { return big.Zero(), nil } diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 9ff2301105f..084ee8673f6 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 9ff2301105fcf25101f1fcda52e6417f3e2ca60b +Subproject commit 084ee8673f6487c71b60996e6d8d6c5fa2cf04ab