Rename the Lotus VM to LegacyVM

This commit is contained in:
Aayush 2022-03-15 19:40:17 -04:00
parent e6117c49ef
commit 9ea623e125
15 changed files with 54 additions and 54 deletions

View File

@ -112,7 +112,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager
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 Lotus VM, and also NOT needed by the FVM from v15 onwards.
// 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

View File

@ -495,9 +495,9 @@ func VerifyPreSealedData(ctx context.Context, cs *store.ChainStore, sys vm.Sysca
NetworkVersion: nv,
BaseFee: big.Zero(),
}
vm, err := vm.NewLotusVM(ctx, &vmopt)
vm, err := vm.NewLegacyVM(ctx, &vmopt)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewLotusVM: %w", err)
return cid.Undef, xerrors.Errorf("failed to create NewLegacyVM: %w", err)
}
for mi, m := range template.Miners {

View File

@ -99,9 +99,9 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
FilVested: big.Zero(),
}
vm, err := vm.NewLotusVM(ctx, vmopt)
vm, err := vm.NewLegacyVM(ctx, vmopt)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewLotusVM: %w", err)
return cid.Undef, xerrors.Errorf("failed to create NewLegacyVM: %w", err)
}
if len(miners) == 0 {
@ -521,7 +521,7 @@ func (fr *fakeRand) GetBeaconRandomness(ctx context.Context, personalization cry
return out, nil
}
func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) {
func currentTotalPower(ctx context.Context, vm *vm.LegacyVM, maddr address.Address) (*power0.CurrentTotalPowerReturn, error) {
pwret, err := doExecValue(ctx, vm, power.Address, maddr, big.Zero(), builtin0.MethodsPower.CurrentTotalPower, nil)
if err != nil {
return nil, err
@ -534,7 +534,7 @@ func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*
return &pwr, nil
}
func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) {
func dealWeight(ctx context.Context, vm *vm.LegacyVM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch, av actors.Version) (abi.DealWeight, abi.DealWeight, error) {
// TODO: This hack should move to market actor wrapper
if av <= actors.Version2 {
params := &market0.VerifyDealsForActivationParams{
@ -594,7 +594,7 @@ func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs [
return dealWeights.Sectors[0].DealWeight, dealWeights.Sectors[0].VerifiedDealWeight, nil
}
func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) {
func currentEpochBlockReward(ctx context.Context, vm *vm.LegacyVM, maddr address.Address, av actors.Version) (abi.StoragePower, builtin.FilterEstimate, error) {
rwret, err := doExecValue(ctx, vm, reward.Address, maddr, big.Zero(), reward.Methods.ThisEpochReward, nil)
if err != nil {
return big.Zero(), builtin.FilterEstimate{}, err
@ -629,7 +629,7 @@ func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Addre
return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(epochReward.ThisEpochRewardSmoothed), nil
}
func circSupply(ctx context.Context, vmi *vm.VM, maddr address.Address) abi.TokenAmount {
func circSupply(ctx context.Context, vmi *vm.LegacyVM, maddr address.Address) abi.TokenAmount {
unsafeVM := &vm.UnsafeVM{VM: vmi}
rt := unsafeVM.MakeRuntime(ctx, &types.Message{
GasLimit: 1_000_000_000,

View File

@ -21,7 +21,7 @@ func mustEnc(i cbg.CBORMarshaler) []byte {
return enc
}
func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value types.BigInt, method abi.MethodNum, params []byte) ([]byte, error) {
func doExecValue(ctx context.Context, vm *vm.LegacyVM, to, from address.Address, value types.BigInt, method abi.MethodNum, params []byte) ([]byte, error) {
act, err := vm.StateTree().GetActor(from)
if err != nil {
return nil, xerrors.Errorf("doExec failed to get from actor (%s): %w", from, err)

View File

@ -167,7 +167,7 @@ func TestForkHeightTriggers(t *testing.T) {
inv.Register(nil, testActor{})
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
nvm, err := vm.NewLotusVM(ctx, vmopt)
nvm, err := vm.NewLegacyVM(ctx, vmopt)
if err != nil {
return nil, err
}
@ -282,7 +282,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) {
inv.Register(nil, testActor{})
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
nvm, err := vm.NewLotusVM(ctx, vmopt)
nvm, err := vm.NewLegacyVM(ctx, vmopt)
if err != nil {
return nil, err
}
@ -501,7 +501,7 @@ func TestForkPreMigration(t *testing.T) {
inv.Register(nil, testActor{})
sm.SetVMConstructor(func(ctx context.Context, vmopt *vm.VMOpts) (vm.Interface, error) {
nvm, err := vm.NewLotusVM(ctx, vmopt)
nvm, err := vm.NewLegacyVM(ctx, vmopt)
if err != nil {
return nil, err
}

View File

@ -42,7 +42,7 @@ type FvmExtern struct {
base cid.Cid
}
// VerifyConsensusFault is similar to the one in syscalls.go used by the Lotus VM, except it never errors
// VerifyConsensusFault is similar to the one in syscalls.go used by the LegacyVM, except it never errors
// Errors are logged and "no fault" is returned, which is functionally what go-actors does anyway
func (x *FvmExtern) VerifyConsensusFault(ctx context.Context, a, b, extra []byte) (*ffi_cgo.ConsensusFault, int64) {
totalGas := int64(0)

View File

@ -50,7 +50,7 @@ func newGasCharge(name string, computeGas int64, storageGas int64) GasCharge {
}
}
// Pricelist provides prices for operations in the VM.
// Pricelist provides prices for operations in the LegacyVM.
//
// Note: this interface should be APPEND ONLY since last chain checkpoint
type Pricelist interface {

View File

@ -50,7 +50,7 @@ type pricelistV0 struct {
// whether it succeeds or fails in application) is given by:
// OnChainMessageBase + len(serialized message)*OnChainMessagePerByte
// Together, these account for the cost of message propagation and validation,
// up to but excluding any actual processing by the VM.
// up to but excluding any actual processing by the LegacyVM.
// This is the cost a block producer burns when including an invalid message.
onChainMessageComputeBase int64
onChainMessageStorageBase int64
@ -83,11 +83,11 @@ type pricelistV0 struct {
sendInvokeMethod int64
// Gas cost for any Get operation to the IPLD store
// in the runtime VM context.
// in the runtime LegacyVM context.
ipldGetBase int64
// Gas cost (Base + len*PerByte) for any Put operation to the IPLD store
// in the runtime VM context.
// in the runtime LegacyVM context.
//
// Note: these costs should be significantly higher than the costs for Get
// operations, since they reflect not only serialization/deserialization

View File

@ -135,7 +135,7 @@ func TestInvokerBasic(t *testing.T) {
{
_, aerr := code[1](&Runtime{
vm: &VM{networkVersion: network.Version0},
vm: &LegacyVM{networkVersion: network.Version0},
Message: &basicRtMessage{},
}, []byte{99})
if aerrors.IsFatal(aerr) {
@ -146,7 +146,7 @@ func TestInvokerBasic(t *testing.T) {
{
_, aerr := code[1](&Runtime{
vm: &VM{networkVersion: network.Version7},
vm: &LegacyVM{networkVersion: network.Version7},
Message: &basicRtMessage{},
}, []byte{99})
if aerrors.IsFatal(aerr) {

View File

@ -65,7 +65,7 @@ type Runtime struct {
ctx context.Context
vm *VM
vm *LegacyVM
state *state.StateTree
height abi.ChainEpoch
cst ipldcbor.IpldStore
@ -158,7 +158,7 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
defer func() {
if r := recover(); r != nil {
if ar, ok := r.(aerrors.ActorError); ok {
log.Warnf("VM.Call failure in call from: %s to %s: %+v", rt.Caller(), rt.Receiver(), ar)
log.Warnf("LegacyVM.Call failure in call from: %s to %s: %+v", rt.Caller(), rt.Receiver(), ar)
aerr = ar
return
}

View File

@ -122,7 +122,7 @@ func (bs *gasChargingBlocks) Put(ctx context.Context, blk block.Block) error {
return nil
}
func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, parent *Runtime) *Runtime {
func (vm *LegacyVM) makeRuntime(ctx context.Context, msg *types.Message, parent *Runtime) *Runtime {
rt := &Runtime{
ctx: ctx,
vm: vm,
@ -188,7 +188,7 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, parent *Runti
}
type UnsafeVM struct {
VM *VM
VM *LegacyVM
}
func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message) *Runtime {
@ -201,9 +201,9 @@ type (
LookbackStateGetter func(context.Context, abi.ChainEpoch) (*state.StateTree, error)
)
var _ Interface = (*VM)(nil)
var _ Interface = (*LegacyVM)(nil)
type VM struct {
type LegacyVM struct {
cstate *state.StateTree
cst *cbor.BasicIpldStore
buf *blockstore.BufferedBlockstore
@ -234,7 +234,7 @@ type VMOpts struct {
LookbackState LookbackStateGetter
}
func NewLotusVM(ctx context.Context, opts *VMOpts) (*VM, error) {
func NewLegacyVM(ctx context.Context, opts *VMOpts) (*LegacyVM, error) {
buf := blockstore.NewBuffered(opts.Bstore)
cst := cbor.NewCborStore(buf)
state, err := state.LoadStateTree(cst, opts.StateBase)
@ -247,7 +247,7 @@ func NewLotusVM(ctx context.Context, opts *VMOpts) (*VM, error) {
return nil, err
}
return &VM{
return &LegacyVM{
cstate: state,
cst: cst,
buf: buf,
@ -276,7 +276,7 @@ type ApplyRet struct {
GasCosts *GasOutputs
}
func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
func (vm *LegacyVM) send(ctx context.Context, msg *types.Message, parent *Runtime,
gasCharge *GasCharge, start time.Time) ([]byte, aerrors.ActorError, *Runtime) {
defer atomic.AddUint64(&StatSends, 1)
@ -395,7 +395,7 @@ func checkMessage(msg *types.Message) error {
return nil
}
func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
func (vm *LegacyVM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*ApplyRet, error) {
start := build.Clock.Now()
defer atomic.AddUint64(&StatApplied, 1)
ret, actorErr, rt := vm.send(ctx, msg, nil, nil, start)
@ -413,7 +413,7 @@ func (vm *VM) ApplyImplicitMessage(ctx context.Context, msg *types.Message) (*Ap
}, actorErr
}
func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) {
func (vm *LegacyVM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, error) {
start := build.Clock.Now()
ctx, span := trace.StartSpan(ctx, "vm.ApplyMessage")
defer span.End()
@ -620,7 +620,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
}, nil
}
func (vm *VM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *types.Message, errcode exitcode.ExitCode) (bool, error) {
func (vm *LegacyVM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *types.Message, errcode exitcode.ExitCode) (bool, error) {
if vm.networkVersion <= network.Version12 {
// Check to see if we should burn funds. We avoid burning on successful
// window post. This won't catch _indirect_ window post calls, but this
@ -650,7 +650,7 @@ func (vm *VM) ShouldBurn(ctx context.Context, st *state.StateTree, msg *types.Me
type vmFlushKey struct{}
func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
func (vm *LegacyVM) Flush(ctx context.Context) (cid.Cid, error) {
_, span := trace.StartSpan(ctx, "vm.Flush")
defer span.End()
@ -669,9 +669,9 @@ func (vm *VM) Flush(ctx context.Context) (cid.Cid, error) {
return root, nil
}
// Get the buffered blockstore associated with the VM. This includes any temporary blocks produced
// during this VM's execution.
func (vm *VM) ActorStore(ctx context.Context) adt.Store {
// Get the buffered blockstore associated with the LegacyVM. This includes any temporary blocks produced
// during this LegacyVM's execution.
func (vm *LegacyVM) ActorStore(ctx context.Context) adt.Store {
return adt.WrapStore(ctx, vm.cst)
}
@ -824,11 +824,11 @@ func copyRec(ctx context.Context, from, to blockstore.Blockstore, root cid.Cid,
return nil
}
func (vm *VM) StateTree() types.StateTree {
func (vm *LegacyVM) StateTree() types.StateTree {
return vm.cstate
}
func (vm *VM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) {
func (vm *LegacyVM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) {
ctx, span := trace.StartSpan(rt.ctx, "vm.Invoke")
defer span.End()
if span.IsRecordingEvents() {
@ -851,11 +851,11 @@ func (vm *VM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params
return ret, nil
}
func (vm *VM) SetInvoker(i *ActorRegistry) {
func (vm *LegacyVM) SetInvoker(i *ActorRegistry) {
vm.areg = i
}
func (vm *VM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error) {
func (vm *LegacyVM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error) {
// Before v15, this was recalculated on each invocation as the state tree was mutated
if vm.networkVersion <= network.Version14 {
return vm.circSupplyCalc(ctx, vm.blockHeight, vm.cstate)
@ -864,14 +864,14 @@ func (vm *VM) GetCircSupply(ctx context.Context) (abi.TokenAmount, error) {
return vm.baseCircSupply, nil
}
func (vm *VM) incrementNonce(addr address.Address) error {
func (vm *LegacyVM) incrementNonce(addr address.Address) error {
return vm.cstate.MutateActor(addr, func(a *types.Actor) error {
a.Nonce++
return nil
})
}
func (vm *VM) transfer(from, to address.Address, amt types.BigInt, networkVersion network.Version) aerrors.ActorError {
func (vm *LegacyVM) transfer(from, to address.Address, amt types.BigInt, networkVersion network.Version) aerrors.ActorError {
var f *types.Actor
var fromID, toID address.Address
var err error
@ -959,7 +959,7 @@ func (vm *VM) transfer(from, to address.Address, amt types.BigInt, networkVersio
return nil
}
func (vm *VM) transferToGasHolder(addr address.Address, gasHolder *types.Actor, amt types.BigInt) error {
func (vm *LegacyVM) transferToGasHolder(addr address.Address, gasHolder *types.Actor, amt types.BigInt) error {
if amt.LessThan(types.NewInt(0)) {
return xerrors.Errorf("attempted to transfer negative value to gas holder")
}
@ -973,7 +973,7 @@ func (vm *VM) transferToGasHolder(addr address.Address, gasHolder *types.Actor,
})
}
func (vm *VM) transferFromGasHolder(addr address.Address, gasHolder *types.Actor, amt types.BigInt) error {
func (vm *LegacyVM) transferFromGasHolder(addr address.Address, gasHolder *types.Actor, amt types.BigInt) error {
if amt.LessThan(types.NewInt(0)) {
return xerrors.Errorf("attempted to transfer negative value from gas holder")
}

View File

@ -23,5 +23,5 @@ func NewVM(ctx context.Context, opts *VMOpts) (Interface, error) {
return NewFVM(ctx, opts)
}
return NewLotusVM(ctx, opts)
return NewLegacyVM(ctx, opts)
}

View File

@ -44,7 +44,7 @@ type BlockBuilder struct {
parentTs *types.TipSet
parentSt *state.StateTree
vm *vm.VM
vm *vm.LegacyVM
sm *stmgr.StateManager
gasTotal int64
@ -73,9 +73,9 @@ func NewBlockBuilder(ctx context.Context, logger *zap.SugaredLogger, sm *stmgr.S
parentSt: parentSt,
}
// Then we construct a VM to execute messages for gas estimation.
// Then we construct a LegacyVM to execute messages for gas estimation.
//
// Most parts of this VM are "real" except:
// Most parts of this LegacyVM are "real" except:
// 1. We don't charge a fee.
// 2. The runtime has "fake" proof logic.
// 3. We don't actually save any of the results.
@ -92,7 +92,7 @@ func NewBlockBuilder(ctx context.Context, logger *zap.SugaredLogger, sm *stmgr.S
BaseFee: abi.NewTokenAmount(0),
LookbackState: stmgr.LookbackStateGetterForTipset(sm, parentTs),
}
bb.vm, err = vm.NewLotusVM(bb.ctx, vmopt)
bb.vm, err = vm.NewLegacyVM(bb.ctx, vmopt)
if err != nil {
return nil, err
}
@ -190,12 +190,12 @@ func (bb *BlockBuilder) PushMessage(msg *types.Message) (*types.MessageReceipt,
return &ret.MessageReceipt, nil
}
// ActorStore returns the VM's current (pending) blockstore.
// ActorStore returns the LegacyVM's current (pending) blockstore.
func (bb *BlockBuilder) ActorStore() adt.Store {
return bb.vm.ActorStore(bb.ctx)
}
// StateTree returns the VM's current (pending) state-tree. This includes any changes made by
// StateTree returns the LegacyVM's current (pending) state-tree. This includes any changes made by
// successfully pushed messages.
//
// You probably want ParentStateTree

View File

@ -160,7 +160,7 @@ func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params
return big.Zero(), nil
}
return vm.NewLotusVM(ctx, vmopt)
return vm.NewLegacyVM(ctx, vmopt)
})
postcid, receiptsroot, err := tse.ApplyBlocks(context.Background(),
@ -226,7 +226,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP
NetworkVersion: params.NetworkVersion,
}
lvm, err := vm.NewLotusVM(context.TODO(), vmOpts)
lvm, err := vm.NewLegacyVM(context.TODO(), vmOpts)
if err != nil {
return nil, cid.Undef, err
}

View File

@ -65,7 +65,7 @@ var ChainNode = Options(
Override(new(ffiwrapper.Verifier), ffiwrapper.ProofVerifier),
Override(new(ffiwrapper.Prover), ffiwrapper.ProofProver),
// Consensus: VM
// Consensus: LegacyVM
Override(new(vm.SyscallBuilder), vm.Syscalls),
// Consensus: Chain storage/access