Merge pull request #8197 from filecoin-project/asr/fvm/nv15

FVM: support nv15
This commit is contained in:
Aayush Rajasekaran 2022-03-11 17:35:20 -05:00 committed by GitHub
commit 6d4fb8866e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 12 deletions

View File

@ -96,11 +96,6 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
ctx = blockstore.WithHotView(ctx)
makeVmWithBaseStateAndEpoch := func(base cid.Cid, e abi.ChainEpoch) (vm.VMI, error) {
filVested, err := sm.GetFilVested(ctx, e)
if err != nil {
return nil, err
}
vmopt := &vm.VMOpts{
StateBase: base,
Epoch: e,
@ -109,13 +104,18 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
Actors: NewActorRegistry(),
Syscalls: sm.Syscalls,
CircSupplyCalc: sm.GetVMCirculatingSupply,
FilVested: filVested,
NetworkVersion: sm.GetNetworkVersion(ctx, e),
BaseFee: baseFee,
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
}
if os.Getenv("LOTUS_USE_FVM_DOESNT_WORK_YET") == "1" {
filVested, err := sm.GetFilVested(ctx, e)
if err != nil {
return nil, err
}
vmopt.FilVested = filVested
return vm.NewFVM(ctx, vmopt)
}

View File

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

View File

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

View File

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

2
extern/filecoin-ffi vendored

@ -1 +1 @@
Subproject commit 9ff2301105fcf25101f1fcda52e6417f3e2ca60b
Subproject commit 084ee8673f6487c71b60996e6d8d6c5fa2cf04ab