Merge pull request #8197 from filecoin-project/asr/fvm/nv15
FVM: support nv15
This commit is contained in:
commit
6d4fb8866e
@ -96,11 +96,6 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
|
|||||||
|
|
||||||
ctx = blockstore.WithHotView(ctx)
|
ctx = blockstore.WithHotView(ctx)
|
||||||
makeVmWithBaseStateAndEpoch := func(base cid.Cid, e abi.ChainEpoch) (vm.VMI, error) {
|
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{
|
vmopt := &vm.VMOpts{
|
||||||
StateBase: base,
|
StateBase: base,
|
||||||
Epoch: e,
|
Epoch: e,
|
||||||
@ -109,13 +104,18 @@ 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,
|
||||||
FilVested: filVested,
|
|
||||||
NetworkVersion: sm.GetNetworkVersion(ctx, e),
|
NetworkVersion: sm.GetNetworkVersion(ctx, e),
|
||||||
BaseFee: baseFee,
|
BaseFee: baseFee,
|
||||||
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
|
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("LOTUS_USE_FVM_DOESNT_WORK_YET") == "1" {
|
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)
|
return vm.NewFVM(ctx, vmopt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
inv := filcns.NewActorRegistry()
|
inv := filcns.NewActorRegistry()
|
||||||
inv.Register(nil, testActor{})
|
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)
|
nvm, err := vm.NewLotusVM(ctx, vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -281,7 +281,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) {
|
|||||||
inv := filcns.NewActorRegistry()
|
inv := filcns.NewActorRegistry()
|
||||||
inv.Register(nil, testActor{})
|
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)
|
nvm, err := vm.NewLotusVM(ctx, vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -500,7 +500,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
inv := filcns.NewActorRegistry()
|
inv := filcns.NewActorRegistry()
|
||||||
inv.Register(nil, testActor{})
|
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)
|
nvm, err := vm.NewLotusVM(ctx, vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -5,6 +5,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -215,9 +217,24 @@ type FVM struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFVM(ctx context.Context, opts *VMOpts) (*FVM, error) {
|
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,
|
fvm, err := ffi.CreateFVM(0,
|
||||||
&FvmExtern{Rand: opts.Rand, Blockstore: opts.Bstore, lbState: opts.LookbackState, base: opts.StateBase, epoch: opts.Epoch},
|
&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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -155,7 +155,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
|
|||||||
results: []*vm.ApplyRet{},
|
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) {
|
vmopt.CircSupplyCalc = func(context.Context, abi.ChainEpoch, *state.StateTree) (abi.TokenAmount, error) {
|
||||||
return big.Zero(), nil
|
return big.Zero(), nil
|
||||||
}
|
}
|
||||||
|
2
extern/filecoin-ffi
vendored
2
extern/filecoin-ffi
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9ff2301105fcf25101f1fcda52e6417f3e2ca60b
|
Subproject commit 084ee8673f6487c71b60996e6d8d6c5fa2cf04ab
|
Loading…
Reference in New Issue
Block a user