diff --git a/chain/consensus/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index 37e78874d..82763c052 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -94,6 +94,16 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager }() makeVmWithBaseStateAndEpoch := func(base cid.Cid, e abi.ChainEpoch) (vm.VMI, error) { + st, err := sm.StateTree(base) + if err != nil { + return nil, err + } + supply, err := sm.GetVMCirculatingSupplyDetailed(ctx, e, st) + if err != nil { + return nil, err + } + circulating := big.Add(supply.FilMined, supply.FilVested) + vmopt := &vm.VMOpts{ StateBase: base, Epoch: e, @@ -102,6 +112,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager Actors: NewActorRegistry(), Syscalls: sm.Syscalls, CircSupplyCalc: sm.GetVMCirculatingSupply, + BaseCircSupply: circulating, NetworkVersion: sm.GetNetworkVersion(ctx, e), BaseFee: baseFee, LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts), diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index 5b4756dff..1049a8ddc 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -9,8 +9,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/blockstore" - "github.com/filecoin-project/lotus/chain/state" - cbor "github.com/ipfs/go-ipld-cbor" ffi "github.com/filecoin-project/filecoin-ffi" ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo" @@ -36,21 +34,9 @@ type FVM struct { } func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) { - buf := blockstore.NewBuffered(opts.Bstore) - cst := cbor.NewCborStore(buf) - state, err := state.LoadStateTree(cst, opts.StateBase) - if err != nil { - return nil, err - } - - baseCirc, 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}, - opts.Epoch, opts.BaseFee, baseCirc, opts.NetworkVersion, opts.StateBase, + opts.Epoch, opts.BaseFee, opts.BaseCircSupply, opts.NetworkVersion, opts.StateBase, ) if err != nil { return nil, err diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 2ee732d5e..831b58254 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -227,6 +227,8 @@ type VMOpts struct { Actors *ActorRegistry Syscalls SyscallBuilder CircSupplyCalc CircSupplyCalculator + // Amount of FIL vested & mined. + BaseCircSupply abi.TokenAmount NetworkVersion network.Version BaseFee abi.TokenAmount LookbackState LookbackStateGetter