fvm: feed in correct "base" circulating supply

This commit is contained in:
Steven Allen 2022-02-08 13:20:03 -08:00
parent 279cdd0760
commit 32b3618c74
3 changed files with 14 additions and 15 deletions

View File

@ -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),

View File

@ -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

View File

@ -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