fvm: feed in correct "base" circulating supply
This commit is contained in:
parent
279cdd0760
commit
32b3618c74
@ -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) {
|
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{
|
vmopt := &vm.VMOpts{
|
||||||
StateBase: base,
|
StateBase: base,
|
||||||
Epoch: e,
|
Epoch: e,
|
||||||
@ -102,6 +112,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
|
|||||||
Actors: NewActorRegistry(),
|
Actors: NewActorRegistry(),
|
||||||
Syscalls: sm.Syscalls,
|
Syscalls: sm.Syscalls,
|
||||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||||
|
BaseCircSupply: circulating,
|
||||||
NetworkVersion: sm.GetNetworkVersion(ctx, e),
|
NetworkVersion: sm.GetNetworkVersion(ctx, e),
|
||||||
BaseFee: baseFee,
|
BaseFee: baseFee,
|
||||||
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
|
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
|
||||||
|
@ -9,8 +9,6 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/blockstore"
|
"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 "github.com/filecoin-project/filecoin-ffi"
|
||||||
ffi_cgo "github.com/filecoin-project/filecoin-ffi/cgo"
|
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) {
|
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,
|
fvm, err := ffi.CreateFVM(0,
|
||||||
&FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore},
|
&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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -227,6 +227,8 @@ type VMOpts struct {
|
|||||||
Actors *ActorRegistry
|
Actors *ActorRegistry
|
||||||
Syscalls SyscallBuilder
|
Syscalls SyscallBuilder
|
||||||
CircSupplyCalc CircSupplyCalculator
|
CircSupplyCalc CircSupplyCalculator
|
||||||
|
// Amount of FIL vested & mined.
|
||||||
|
BaseCircSupply abi.TokenAmount
|
||||||
NetworkVersion network.Version
|
NetworkVersion network.Version
|
||||||
BaseFee abi.TokenAmount
|
BaseFee abi.TokenAmount
|
||||||
LookbackState LookbackStateGetter
|
LookbackState LookbackStateGetter
|
||||||
|
Loading…
Reference in New Issue
Block a user