Merge pull request #8683 from filecoin-project/fix/drop-fvm-nv14
feat: fvm: drop nv14 support from the FVM
This commit is contained in:
commit
eab4d4b464
@ -2,7 +2,6 @@ package filcns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/rand"
|
||||
@ -94,19 +93,6 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
|
||||
LookbackState: stmgr.LookbackStateGetterForTipset(sm, ts),
|
||||
}
|
||||
|
||||
if os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" {
|
||||
// This is needed so that the FVM does not have to duplicate the genesis vesting schedule, one
|
||||
// of the components of the circ supply calc.
|
||||
// This field is NOT needed by the LegacyVM, and also NOT needed by the FVM from v15 onwards.
|
||||
filVested, err := sm.GetFilVested(ctx, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vmopt.FilVested = filVested
|
||||
return vm.NewFVM(ctx, vmopt)
|
||||
}
|
||||
|
||||
return sm.VMConstructor()(ctx, vmopt)
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,6 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca
|
||||
Actors: filcns.NewActorRegistry(),
|
||||
Syscalls: mkFakedSigSyscalls(sys),
|
||||
CircSupplyCalc: csc,
|
||||
FilVested: big.Zero(),
|
||||
NetworkVersion: nv,
|
||||
BaseFee: big.Zero(),
|
||||
}
|
||||
|
@ -109,7 +109,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
|
||||
CircSupplyCalc: csc,
|
||||
NetworkVersion: nv,
|
||||
BaseFee: big.Zero(),
|
||||
FilVested: big.Zero(),
|
||||
}
|
||||
|
||||
return vm.NewVM(ctx, vmopt)
|
||||
|
@ -80,11 +80,6 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
|
||||
return nil, fmt.Errorf("failed to handle fork: %w", err)
|
||||
}
|
||||
|
||||
filVested, err := sm.GetFilVested(ctx, vmHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
vmopt := &vm.VMOpts{
|
||||
StateBase: bstate,
|
||||
Epoch: vmHeight,
|
||||
@ -95,7 +90,6 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
|
||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||
NetworkVersion: sm.GetNetworkVersion(ctx, pheight+1),
|
||||
BaseFee: types.NewInt(0),
|
||||
FilVested: filVested,
|
||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
||||
}
|
||||
|
||||
@ -218,11 +212,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
|
||||
)
|
||||
}
|
||||
|
||||
filVested, err := sm.GetFilVested(ctx, vmHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buffStore := blockstore.NewTieredBstore(sm.cs.StateBlockstore(), blockstore.NewMemorySync())
|
||||
vmopt := &vm.VMOpts{
|
||||
StateBase: stateCid,
|
||||
@ -234,7 +223,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
|
||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||
NetworkVersion: sm.GetNetworkVersion(ctx, ts.Height()+1),
|
||||
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
||||
FilVested: filVested,
|
||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
||||
}
|
||||
vmi, err := sm.newVM(ctx, vmopt)
|
||||
|
@ -79,11 +79,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
|
||||
// future. It's not guaranteed to be accurate... but that's fine.
|
||||
}
|
||||
|
||||
filVested, err := sm.GetFilVested(ctx, height)
|
||||
if err != nil {
|
||||
return cid.Undef, nil, err
|
||||
}
|
||||
|
||||
r := rand.NewStateRand(sm.cs, ts.Cids(), sm.beacon, sm.GetNetworkVersion)
|
||||
vmopt := &vm.VMOpts{
|
||||
StateBase: base,
|
||||
@ -95,7 +90,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
|
||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||
NetworkVersion: sm.GetNetworkVersion(ctx, height),
|
||||
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
||||
FilVested: filVested,
|
||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
||||
}
|
||||
vmi, err := sm.newVM(ctx, vmopt)
|
||||
|
@ -256,19 +256,14 @@ 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
|
||||
}
|
||||
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
|
||||
}
|
||||
circToReport, err := opts.CircSupplyCalc(ctx, opts.Epoch, state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fvmopts := &ffi.FVMOpts{
|
||||
|
@ -227,8 +227,6 @@ type VMOpts struct {
|
||||
Actors *ActorRegistry
|
||||
Syscalls SyscallBuilder
|
||||
CircSupplyCalc CircSupplyCalculator
|
||||
// Amount of FIL vested from genesis actors.
|
||||
FilVested abi.TokenAmount
|
||||
NetworkVersion network.Version
|
||||
BaseFee abi.TokenAmount
|
||||
LookbackState LookbackStateGetter
|
||||
|
@ -19,13 +19,15 @@ type Interface interface {
|
||||
Flush(ctx context.Context) (cid.Cid, error)
|
||||
}
|
||||
|
||||
var experimentalUseFvm = os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1"
|
||||
|
||||
func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) {
|
||||
if opts.NetworkVersion >= network.Version16 {
|
||||
return NewFVM(ctx, opts)
|
||||
}
|
||||
|
||||
// Remove after v16 upgrade, this is only to support testing and validation of the FVM
|
||||
if os.Getenv("LOTUS_USE_FVM_EXPERIMENTAL") == "1" {
|
||||
if experimentalUseFvm && opts.NetworkVersion >= network.Version15 {
|
||||
return NewFVM(ctx, opts)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user