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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/rand"
|
"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),
|
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)
|
return sm.VMConstructor()(ctx, vmopt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +491,6 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca
|
|||||||
Actors: filcns.NewActorRegistry(),
|
Actors: filcns.NewActorRegistry(),
|
||||||
Syscalls: mkFakedSigSyscalls(sys),
|
Syscalls: mkFakedSigSyscalls(sys),
|
||||||
CircSupplyCalc: csc,
|
CircSupplyCalc: csc,
|
||||||
FilVested: big.Zero(),
|
|
||||||
NetworkVersion: nv,
|
NetworkVersion: nv,
|
||||||
BaseFee: big.Zero(),
|
BaseFee: big.Zero(),
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
|
|||||||
CircSupplyCalc: csc,
|
CircSupplyCalc: csc,
|
||||||
NetworkVersion: nv,
|
NetworkVersion: nv,
|
||||||
BaseFee: big.Zero(),
|
BaseFee: big.Zero(),
|
||||||
FilVested: big.Zero(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm.NewVM(ctx, vmopt)
|
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)
|
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{
|
vmopt := &vm.VMOpts{
|
||||||
StateBase: bstate,
|
StateBase: bstate,
|
||||||
Epoch: vmHeight,
|
Epoch: vmHeight,
|
||||||
@ -95,7 +90,6 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
|
|||||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||||
NetworkVersion: sm.GetNetworkVersion(ctx, pheight+1),
|
NetworkVersion: sm.GetNetworkVersion(ctx, pheight+1),
|
||||||
BaseFee: types.NewInt(0),
|
BaseFee: types.NewInt(0),
|
||||||
FilVested: filVested,
|
|
||||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
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())
|
buffStore := blockstore.NewTieredBstore(sm.cs.StateBlockstore(), blockstore.NewMemorySync())
|
||||||
vmopt := &vm.VMOpts{
|
vmopt := &vm.VMOpts{
|
||||||
StateBase: stateCid,
|
StateBase: stateCid,
|
||||||
@ -234,7 +223,6 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
|
|||||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||||
NetworkVersion: sm.GetNetworkVersion(ctx, ts.Height()+1),
|
NetworkVersion: sm.GetNetworkVersion(ctx, ts.Height()+1),
|
||||||
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
||||||
FilVested: filVested,
|
|
||||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
||||||
}
|
}
|
||||||
vmi, err := sm.newVM(ctx, vmopt)
|
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.
|
// 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)
|
r := rand.NewStateRand(sm.cs, ts.Cids(), sm.beacon, sm.GetNetworkVersion)
|
||||||
vmopt := &vm.VMOpts{
|
vmopt := &vm.VMOpts{
|
||||||
StateBase: base,
|
StateBase: base,
|
||||||
@ -95,7 +90,6 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
|
|||||||
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
CircSupplyCalc: sm.GetVMCirculatingSupply,
|
||||||
NetworkVersion: sm.GetNetworkVersion(ctx, height),
|
NetworkVersion: sm.GetNetworkVersion(ctx, height),
|
||||||
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
||||||
FilVested: filVested,
|
|
||||||
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
LookbackState: LookbackStateGetterForTipset(sm, ts),
|
||||||
}
|
}
|
||||||
vmi, err := sm.newVM(ctx, vmopt)
|
vmi, err := sm.newVM(ctx, vmopt)
|
||||||
|
@ -256,20 +256,15 @@ 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)
|
state, err := state.LoadStateTree(cbor.NewCborStore(opts.Bstore), opts.StateBase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
circToReport, err = opts.CircSupplyCalc(ctx, opts.Epoch, state)
|
circToReport, err := opts.CircSupplyCalc(ctx, opts.Epoch, state)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fvmopts := &ffi.FVMOpts{
|
fvmopts := &ffi.FVMOpts{
|
||||||
FVMVersion: 0,
|
FVMVersion: 0,
|
||||||
|
@ -227,8 +227,6 @@ type VMOpts struct {
|
|||||||
Actors *ActorRegistry
|
Actors *ActorRegistry
|
||||||
Syscalls SyscallBuilder
|
Syscalls SyscallBuilder
|
||||||
CircSupplyCalc CircSupplyCalculator
|
CircSupplyCalc CircSupplyCalculator
|
||||||
// Amount of FIL vested from genesis actors.
|
|
||||||
FilVested abi.TokenAmount
|
|
||||||
NetworkVersion network.Version
|
NetworkVersion network.Version
|
||||||
BaseFee abi.TokenAmount
|
BaseFee abi.TokenAmount
|
||||||
LookbackState LookbackStateGetter
|
LookbackState LookbackStateGetter
|
||||||
|
@ -19,13 +19,15 @@ type Interface interface {
|
|||||||
Flush(ctx context.Context) (cid.Cid, error)
|
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) {
|
func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) {
|
||||||
if opts.NetworkVersion >= network.Version16 {
|
if opts.NetworkVersion >= network.Version16 {
|
||||||
return NewFVM(ctx, opts)
|
return NewFVM(ctx, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove after v16 upgrade, this is only to support testing and validation of the FVM
|
// 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)
|
return NewFVM(ctx, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user