diff --git a/chain/actors/actors.go b/chain/actors/actors.go deleted file mode 100644 index 1ea9daf5d..000000000 --- a/chain/actors/actors.go +++ /dev/null @@ -1,22 +0,0 @@ -package actors - -import ( - "github.com/filecoin-project/specs-actors/actors/builtin" -) - -var AccountCodeCid = builtin.AccountActorCodeID -var CronCodeCid = builtin.CronActorCodeID -var StoragePowerCodeCid = builtin.StoragePowerActorCodeID -var StorageMarketCodeCid = builtin.StorageMarketActorCodeID -var StorageMinerCodeCid = builtin.StorageMinerActorCodeID -var MultisigCodeCid = builtin.MultisigActorCodeID -var InitCodeCid = builtin.InitActorCodeID -var PaymentChannelCodeCid = builtin.PaymentChannelActorCodeID - -var SystemAddress = builtin.SystemActorAddr -var InitAddress = builtin.InitActorAddr -var RewardActor = builtin.RewardActorAddr -var CronAddress = builtin.CronActorAddr -var StoragePowerAddress = builtin.StoragePowerActorAddr -var StorageMarketAddress = builtin.StorageMarketActorAddr -var BurntFundsAddress = builtin.BurntFundsActorAddr diff --git a/chain/actors/address.go b/chain/actors/address.go deleted file mode 100644 index eb3bcbff3..000000000 --- a/chain/actors/address.go +++ /dev/null @@ -1,14 +0,0 @@ -package actors - -import ( - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/actors/aerrors" -) - -func NewIDAddress(id uint64) (address.Address, ActorError) { - a, err := address.NewIDAddress(id) - if err != nil { - return address.Undef, aerrors.Escalate(err, "could not create ID Address") - } - return a, nil -} diff --git a/chain/actors/error.go b/chain/actors/error.go deleted file mode 100644 index a24f952da..000000000 --- a/chain/actors/error.go +++ /dev/null @@ -1,5 +0,0 @@ -package actors - -import "github.com/filecoin-project/lotus/chain/actors/aerrors" - -type ActorError = aerrors.ActorError diff --git a/chain/actors/forks.go b/chain/actors/forks.go deleted file mode 100644 index 0e79521df..000000000 --- a/chain/actors/forks.go +++ /dev/null @@ -1,50 +0,0 @@ -package actors - -import ( - "reflect" - "sort" - - logging "github.com/ipfs/go-log/v2" - - "github.com/filecoin-project/lotus/chain/actors/aerrors" - "github.com/filecoin-project/lotus/chain/types" -) - -var log = logging.Logger("actors") - -type update struct { - start uint64 - method interface{} -} - -func withUpdates(updates ...update) interface{} { - sort.Slice(updates, func(i, j int) bool { // so we iterate from newest below - return updates[i].start > updates[j].start - }) - - // -} - -func notFound(vmctx types.VMContext) func() ([]byte, ActorError) { - return func() ([]byte, ActorError) { - return nil, aerrors.Fatal("no code for method %d at height %d", vmctx.Message().Method, vmctx.BlockHeight()) - } -} diff --git a/chain/actors/params.go b/chain/actors/params.go index c713167ce..e14dcafc9 100644 --- a/chain/actors/params.go +++ b/chain/actors/params.go @@ -7,10 +7,6 @@ import ( cbg "github.com/whyrusleeping/cbor-gen" ) -var ( - EmptyStructCBOR = []byte{0xa0} -) - func SerializeParams(i cbg.CBORMarshaler) ([]byte, aerrors.ActorError) { buf := new(bytes.Buffer) if err := i.MarshalCBOR(buf); err != nil { diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index a891aa14b..7d82fcceb 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -20,7 +20,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/build" - actors "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -116,7 +115,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err != nil { return nil, xerrors.Errorf("setup init actor: %w", err) } - if err := state.SetActor(actors.SystemAddress, sysact); err != nil { + if err := state.SetActor(builtin.SystemActorAddr, sysact); err != nil { return nil, xerrors.Errorf("set init actor: %w", err) } @@ -126,12 +125,12 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err != nil { return nil, xerrors.Errorf("setup init actor: %w", err) } - if err := state.SetActor(actors.InitAddress, initact); err != nil { + if err := state.SetActor(builtin.InitActorAddr, initact); err != nil { return nil, xerrors.Errorf("set init actor: %w", err) } // Setup reward - err = state.SetActor(actors.RewardActor, &types.Actor{ + err = state.SetActor(builtin.RewardActorAddr, &types.Actor{ Code: builtin.RewardActorCodeID, Balance: big.Int{Int: build.InitialReward}, Head: emptyobject, // TODO ? @@ -145,7 +144,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err != nil { return nil, xerrors.Errorf("setup cron actor: %w", err) } - if err := state.SetActor(actors.CronAddress, cronact); err != nil { + if err := state.SetActor(builtin.CronActorAddr, cronact); err != nil { return nil, xerrors.Errorf("set cron actor: %w", err) } @@ -154,7 +153,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err != nil { return nil, xerrors.Errorf("setup storage market actor: %w", err) } - if err := state.SetActor(actors.StoragePowerAddress, spact); err != nil { + if err := state.SetActor(builtin.StoragePowerActorAddr, spact); err != nil { return nil, xerrors.Errorf("set storage market actor: %w", err) } @@ -163,13 +162,13 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge if err != nil { return nil, xerrors.Errorf("setup storage market actor: %w", err) } - if err := state.SetActor(actors.StorageMarketAddress, marketact); err != nil { + if err := state.SetActor(builtin.StorageMarketActorAddr, marketact); err != nil { return nil, xerrors.Errorf("set market actor: %w", err) } // Setup burnt-funds - err = state.SetActor(actors.BurntFundsAddress, &types.Actor{ - Code: actors.AccountCodeCid, + err = state.SetActor(builtin.BurntFundsActorAddr, &types.Actor{ + Code: builtin.AccountActorCodeID, Balance: types.NewInt(0), Head: emptyobject, }) @@ -199,7 +198,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge } err = state.SetActor(ida, &types.Actor{ - Code: actors.AccountCodeCid, + Code: builtin.AccountActorCodeID, Balance: info.Balance, Head: st, }) @@ -255,7 +254,7 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys } b := &types.BlockHeader{ - Miner: actors.InitAddress, + Miner: builtin.InitActorAddr, Ticket: genesisticket, EPostProof: types.EPostProof{ Proof: []byte("not a real proof"), diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index e24846617..277b77523 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -21,7 +21,6 @@ import ( "github.com/ipfs/go-cid" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/vm" @@ -43,7 +42,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid networkPower = big.Add(networkPower, big.NewInt(int64(m.SectorSize)*int64(len(m.Sectors)))) } - vm, err := vm.NewVM(sroot, 0, &fakeRand{}, actors.SystemAddress, cs.Blockstore(), cs.VMSys()) + vm, err := vm.NewVM(sroot, 0, &fakeRand{}, builtin.SystemActorAddr, cs.Blockstore(), cs.VMSys()) if err != nil { return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err) } @@ -69,7 +68,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } params := mustEnc(constructorParams) - rval, err := doExecValue(ctx, vm, actors.StoragePowerAddress, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params) + rval, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } @@ -90,14 +89,14 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid { params := mustEnc(&maddr) - _, err := doExecValue(ctx, vm, actors.StorageMarketAddress, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params) + _, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } } { params := mustEnc(&m.Worker) - _, err := doExecValue(ctx, vm, actors.StorageMarketAddress, m.Worker, big.Zero(), builtin.MethodsMarket.AddBalance, params) + _, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.AddBalance, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } diff --git a/chain/gen/genesis/t01_init.go b/chain/gen/genesis/t01_init.go index 7797eae6f..1402f7a69 100644 --- a/chain/gen/genesis/t01_init.go +++ b/chain/gen/genesis/t01_init.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" "github.com/ipfs/go-hamt-ipld" @@ -11,7 +12,6 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/genesis" ) @@ -61,7 +61,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi } act := &types.Actor{ - Code: actors.InitCodeCid, + Code: builtin.InitActorCodeID, Head: statecid, } diff --git a/chain/gen/genesis/t03_cron.go b/chain/gen/genesis/t03_cron.go index 432927e09..3c300d7e9 100644 --- a/chain/gen/genesis/t03_cron.go +++ b/chain/gen/genesis/t03_cron.go @@ -8,7 +8,6 @@ import ( bstore "github.com/ipfs/go-ipfs-blockstore" cbor "github.com/ipfs/go-ipld-cbor" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -26,7 +25,7 @@ func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) { } return &types.Actor{ - Code: actors.CronCodeCid, + Code: builtin.CronActorCodeID, Head: stcid, Nonce: 0, Balance: types.NewInt(0), diff --git a/chain/gen/genesis/t04_power.go b/chain/gen/genesis/t04_power.go index 48fa9ef8f..49bc5aa4d 100644 --- a/chain/gen/genesis/t04_power.go +++ b/chain/gen/genesis/t04_power.go @@ -2,6 +2,7 @@ package genesis import ( "context" + "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin/power" @@ -9,7 +10,6 @@ import ( bstore "github.com/ipfs/go-ipfs-blockstore" cbor "github.com/ipfs/go-ipld-cbor" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -38,7 +38,7 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) { } return &types.Actor{ - Code: actors.StoragePowerCodeCid, + Code: builtin.StoragePowerActorCodeID, Head: stcid, Nonce: 0, Balance: types.NewInt(0), diff --git a/chain/gen/genesis/t05_market.go b/chain/gen/genesis/t05_market.go index 23c61ed59..9c55dff19 100644 --- a/chain/gen/genesis/t05_market.go +++ b/chain/gen/genesis/t05_market.go @@ -2,14 +2,14 @@ package genesis import ( "context" - "github.com/filecoin-project/go-amt-ipld/v2" "github.com/ipfs/go-hamt-ipld" + "github.com/filecoin-project/go-amt-ipld/v2" + "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/market" bstore "github.com/ipfs/go-ipfs-blockstore" cbor "github.com/ipfs/go-ipld-cbor" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -33,7 +33,7 @@ func SetupStorageMarketActor(bs bstore.Blockstore) (*types.Actor, error) { } act := &types.Actor{ - Code: actors.StorageMarketCodeCid, + Code: builtin.StorageMarketActorCodeID, Head: stcid, Balance: types.NewInt(0), } diff --git a/chain/market/fundmgr.go b/chain/market/fundmgr.go index d0a7564c8..e43dbfa79 100644 --- a/chain/market/fundmgr.go +++ b/chain/market/fundmgr.go @@ -63,7 +63,7 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr address.Address, am } smsg, err := fm.mpool.MpoolPushMessage(ctx, &types.Message{ - To: actors.StorageMarketAddress, + To: builtin.StorageMarketActorAddr, From: addr, Value: toAdd, GasPrice: types.NewInt(0), diff --git a/chain/state/statetree.go b/chain/state/statetree.go index 3b12f3576..4637540c4 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -3,6 +3,7 @@ package state import ( "context" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" "github.com/filecoin-project/specs-actors/actors/util/adt" @@ -14,7 +15,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" ) @@ -74,7 +74,7 @@ func (st *StateTree) LookupID(addr address.Address) (address.Address, error) { return addr, nil } - act, err := st.GetActor(actors.InitAddress) + act, err := st.GetActor(builtin.InitActorAddr) if err != nil { return address.Undef, xerrors.Errorf("getting init actor: %w", err) } @@ -157,7 +157,7 @@ func (st *StateTree) Snapshot(ctx context.Context) error { func (st *StateTree) RegisterNewAddress(addr address.Address, act *types.Actor) (address.Address, error) { var out address.Address - err := st.MutateActor(actors.InitAddress, func(initact *types.Actor) error { + err := st.MutateActor(builtin.InitActorAddr, func(initact *types.Actor) error { var ias init_.State if err := st.Store.Get(context.TODO(), initact.Head, &ias); err != nil { return err diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 68626aabe..720781842 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -3,6 +3,7 @@ package stmgr import ( "context" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/ipfs/go-cid" @@ -10,7 +11,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" @@ -20,7 +20,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate ctx, span := trace.StartSpan(ctx, "statemanager.CallRaw") defer span.End() - vmi, err := vm.NewVM(bstate, bheight, r, actors.SystemAddress, sm.cs.Blockstore(), sm.cs.VMSys()) + vmi, err := vm.NewVM(bstate, bheight, r, builtin.SystemActorAddr, sm.cs.Blockstore(), sm.cs.VMSys()) if err != nil { return nil, xerrors.Errorf("failed to set up vm: %w", err) } diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 8e7fb8b68..91794aaae 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -8,7 +8,6 @@ import ( "github.com/filecoin-project/go-address" amt "github.com/filecoin-project/go-amt-ipld/v2" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" @@ -155,13 +154,13 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl return cid.Undef, cid.Undef, xerrors.Errorf("instantiating VM failed: %w", err) } - rewardActor, err := vmi.StateTree().GetActor(actors.RewardActor) + rewardActor, err := vmi.StateTree().GetActor(builtin.RewardActorAddr) if err != nil { return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) } reward := vm.MiningReward(rewardActor.Balance) for _, b := range blks { - rewardActor, err = vmi.StateTree().GetActor(actors.RewardActor) + rewardActor, err = vmi.StateTree().GetActor(builtin.RewardActorAddr) if err != nil { return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) } @@ -248,14 +247,14 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl } // TODO: this nonce-getting is a tiny bit ugly - ca, err := vmi.StateTree().GetActor(actors.SystemAddress) + ca, err := vmi.StateTree().GetActor(builtin.SystemActorAddr) if err != nil { return cid.Undef, cid.Undef, err } ret, err := vmi.ApplyMessage(ctx, &types.Message{ - To: actors.CronAddress, - From: actors.SystemAddress, + To: builtin.CronActorAddr, + From: builtin.SystemActorAddr, Nonce: ca.Nonce, Value: types.NewInt(0), GasPrice: types.NewInt(0), @@ -629,7 +628,7 @@ func (sm *StateManager) ListAllActors(ctx context.Context, ts *types.TipSet) ([] func (sm *StateManager) MarketBalance(ctx context.Context, addr address.Address, ts *types.TipSet) (api.MarketBalance, error) { var state market.State - _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts) + _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts) if err != nil { return api.MarketBalance{}, err } diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index b2c98da84..2f99cd9f1 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -23,7 +23,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" @@ -222,7 +221,7 @@ func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, mad func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) { var state market.State - if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { + if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil { return nil, err } @@ -250,7 +249,7 @@ func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error) { var state power.State - if _, err := sm.LoadActorState(ctx, actors.StoragePowerAddress, &state, ts); err != nil { + if _, err := sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &state, ts); err != nil { return nil, err } @@ -310,7 +309,7 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, } r := store.NewChainRand(sm.cs, ts.Cids(), height) - vmi, err := vm.NewVM(fstate, height, r, actors.SystemAddress, sm.cs.Blockstore(), sm.cs.VMSys()) + vmi, err := vm.NewVM(fstate, height, r, builtin.SystemActorAddr, sm.cs.Blockstore(), sm.cs.VMSys()) if err != nil { return cid.Undef, err } diff --git a/chain/store/weight.go b/chain/store/weight.go index 573050839..d4005bb3d 100644 --- a/chain/store/weight.go +++ b/chain/store/weight.go @@ -5,7 +5,6 @@ import ( "math/big" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" @@ -73,7 +72,7 @@ func (cs *ChainStore) call(ctx context.Context, msg *types.Message, ts *types.Ti r := NewChainRand(cs, ts.Cids(), ts.Height()) - vmi, err := vm.NewVM(bstate, ts.Height(), r, actors.SystemAddress, cs.bs, cs.vmcalls) + vmi, err := vm.NewVM(bstate, ts.Height(), r, builtin.SystemActorAddr, cs.bs, cs.vmcalls) if err != nil { return nil, xerrors.Errorf("failed to set up vm: %w", err) } diff --git a/chain/sync.go b/chain/sync.go index 71b5f21c9..1229e754b 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "errors" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" "sync" "time" @@ -33,7 +34,6 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/blocksync" "github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/state" @@ -469,7 +469,7 @@ func (syncer *Syncer) ValidateTipSet(ctx context.Context, fts *store.FullTipSet) func (syncer *Syncer) minerIsValid(ctx context.Context, maddr address.Address, baseTs *types.TipSet) error { var spast power.State - _, err := syncer.sm.LoadActorState(ctx, actors.StoragePowerAddress, &spast, baseTs) + _, err := syncer.sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &spast, baseTs) if err != nil { return err } diff --git a/chain/vm/invoker.go b/chain/vm/invoker.go index 64b98489d..70a7011e5 100644 --- a/chain/vm/invoker.go +++ b/chain/vm/invoker.go @@ -24,7 +24,6 @@ import ( vmr "github.com/filecoin-project/specs-actors/actors/runtime" "github.com/filecoin-project/specs-actors/actors/util/adt" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/types" ) @@ -45,20 +44,20 @@ func NewInvoker() *invoker { // add builtInCode using: register(cid, singleton) inv.Register(builtin.SystemActorCodeID, system.Actor{}, adt.EmptyValue{}) - inv.Register(actors.InitCodeCid, init_.Actor{}, init_.State{}) - inv.Register(actors.CronCodeCid, cron.Actor{}, cron.State{}) - inv.Register(actors.StoragePowerCodeCid, power.Actor{}, power.State{}) - inv.Register(actors.StorageMarketCodeCid, market.Actor{}, market.State{}) - inv.Register(actors.StorageMinerCodeCid, miner.Actor{}, miner.State{}) - inv.Register(actors.MultisigCodeCid, multisig.Actor{}, multisig.State{}) - inv.Register(actors.PaymentChannelCodeCid, paych.Actor{}, paych.State{}) + inv.Register(builtin.InitActorCodeID, init_.Actor{}, init_.State{}) + inv.Register(builtin.CronActorCodeID, cron.Actor{}, cron.State{}) + inv.Register(builtin.StoragePowerActorCodeID, power.Actor{}, power.State{}) + inv.Register(builtin.StorageMarketActorCodeID, market.Actor{}, market.State{}) + inv.Register(builtin.StorageMinerActorCodeID, miner.Actor{}, miner.State{}) + inv.Register(builtin.MultisigActorCodeID, multisig.Actor{}, multisig.State{}) + inv.Register(builtin.PaymentChannelActorCodeID, paych.Actor{}, paych.State{}) return inv } func (inv *invoker) Invoke(act *types.Actor, vmctx types.VMContext, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) { - if act.Code == actors.AccountCodeCid { + if act.Code == builtin.AccountActorCodeID { return nil, aerrors.Newf(254, "cannot invoke methods on account actors") } @@ -264,7 +263,7 @@ func DecodeParams(b []byte, out interface{}) error { } func DumpActorState(code cid.Cid, b []byte) (interface{}, error) { - if code == actors.AccountCodeCid { // Account code special case + if code == builtin.AccountActorCodeID { // Account code special case return nil, nil } diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 773163714..df3f235dd 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -2,13 +2,13 @@ package vm import ( "context" + "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/account" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -64,7 +64,7 @@ func NewBLSAccountActor(st *state.StateTree, addr address.Address) (*types.Actor } nact := &types.Actor{ - Code: actors.AccountCodeCid, + Code: builtin.AccountActorCodeID, Balance: types.NewInt(0), Head: c, } @@ -74,7 +74,7 @@ func NewBLSAccountActor(st *state.StateTree, addr address.Address) (*types.Actor func NewSecp256k1AccountActor(st *state.StateTree, addr address.Address) (*types.Actor, aerrors.ActorError) { nact := &types.Actor{ - Code: actors.AccountCodeCid, + Code: builtin.AccountActorCodeID, Balance: types.NewInt(0), Head: EmptyObjectCid, } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 3c23d81fe..c74f2cafe 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" "math/big" "reflect" @@ -27,7 +28,6 @@ import ( "github.com/filecoin-project/specs-actors/actors/runtime" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/aerrors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -184,7 +184,7 @@ func (vmc *VMContext) ChargeGas(amount uint64) aerrors.ActorError { } func (vmc *VMContext) StateTree() (types.StateTree, aerrors.ActorError) { - if vmc.msg.To != actors.InitAddress { + if vmc.msg.To != builtin.InitActorAddr { return nil, aerrors.Escalate(fmt.Errorf("only init actor can access state tree directly"), "invalid use of StateTree") } @@ -235,7 +235,7 @@ func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Ad return address.Undef, aerrors.Newf(1, "failed to find actor: %s", addr) } - if act.Code != actors.AccountCodeCid { + if act.Code != builtin.AccountActorCodeID { return address.Undef, aerrors.New(1, "address was not for an account actor") } diff --git a/cli/chain.go b/cli/chain.go index 2618fbff4..1bebc78e9 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -618,7 +618,7 @@ var slashConsensusFault = &cli.Command{ }) msg := &types.Message{ - To: actors.StoragePowerAddress, + To: builtin.StoragePowerActorAddr, From: def, Value: types.NewInt(0), GasPrice: types.NewInt(1), diff --git a/cli/multisig.go b/cli/multisig.go index df138b62b..91959d6b3 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -106,7 +106,7 @@ var msigCreateCmd = &cli.Command{ // new actors are created by invoking 'exec' on the init actor with the constructor params execParams := &init_.ExecParams{ - CodeCID: actors.MultisigCodeCid, + CodeCID: builtin.MultisigActorCodeID, ConstructorParams: enc, } @@ -117,7 +117,7 @@ var msigCreateCmd = &cli.Command{ // now we create the message to send this with msg := types.Message{ - To: actors.InitAddress, + To: builtin.InitActorAddr, From: sendAddr, Method: builtin.MethodsInit.Exec, Params: enc, diff --git a/cli/state.go b/cli/state.go index e585a5e94..5e489ed7c 100644 --- a/cli/state.go +++ b/cli/state.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/filecoin-project/specs-actors/actors/builtin" "reflect" "strconv" "strings" @@ -20,7 +21,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api" - actors "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/miner" @@ -832,7 +832,7 @@ var stateCallCmd = &cli.Command{ &cli.StringFlag{ Name: "from", Usage: "", - Value: actors.SystemAddress.String(), + Value: builtin.SystemActorAddr.String(), }, &cli.StringFlag{ Name: "value", @@ -973,15 +973,15 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er var f interface{} switch act { - case actors.StorageMarketCodeCid: + case builtin.StorageMarketActorCodeID: f = market.Actor{}.Exports()[method] - case actors.StorageMinerCodeCid: + case builtin.StorageMinerActorCodeID: f = miner2.Actor{}.Exports()[method] - case actors.StoragePowerCodeCid: + case builtin.StoragePowerActorCodeID: f = power.Actor{}.Exports()[method] - case actors.MultisigCodeCid: + case builtin.MultisigActorCodeID: f = samsig.Actor{}.Exports()[method] - case actors.PaymentChannelCodeCid: + case builtin.PaymentChannelActorCodeID: f = paych.Actor{}.Exports()[method] default: return nil, fmt.Errorf("the lazy devs didnt add support for that actor to this call yet") diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 76cf9192e..07ea75f61 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -550,7 +550,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, } createStorageMinerMsg := &types.Message{ - To: actors.StoragePowerAddress, + To: builtin.StoragePowerActorAddr, From: owner, Value: types.BigAdd(collateral, types.BigDiv(collateral, types.NewInt(100))), diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 3c57c6e39..34cd5352c 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -18,7 +18,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/lotus/build" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/events" "github.com/filecoin-project/lotus/chain/market" "github.com/filecoin-project/lotus/chain/stmgr" @@ -123,7 +122,7 @@ func (n *ClientNodeAdapter) MostRecentStateId(ctx context.Context) (storagemarke func (n *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) error { // (Provider Node API) smsg, err := n.MpoolPushMessage(ctx, &types.Message{ - To: actors.StorageMarketAddress, + To: builtin.StorageMarketActorAddr, From: addr, Value: amount, GasPrice: types.NewInt(0), @@ -178,7 +177,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return 0, xerrors.Errorf("deal wasn't published by storage provider: from=%s, provider=%s", pubmsg.From, deal.Proposal.Provider) } - if pubmsg.To != actors.StorageMarketAddress { + if pubmsg.To != builtin.StorageMarketActorAddr { return 0, xerrors.Errorf("deal publish message wasn't set to StorageMarket actor (to=%s)", pubmsg.To) } diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index b8ace84c5..c7837894d 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -68,7 +68,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark // TODO: We may want this to happen after fetching data smsg, err := n.MpoolPushMessage(ctx, &types.Message{ - To: actors.StorageMarketAddress, + To: builtin.StorageMarketActorAddr, From: worker, Value: types.NewInt(0), GasPrice: types.NewInt(0), @@ -156,7 +156,7 @@ func (n *ProviderNodeAdapter) MostRecentStateId(ctx context.Context) (storagemar func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) error { // (Provider Node API) smsg, err := n.MpoolPushMessage(ctx, &types.Message{ - To: actors.StorageMarketAddress, + To: builtin.StorageMarketActorAddr, From: addr, Value: amount, GasPrice: types.NewInt(0), diff --git a/node/impl/full/state.go b/node/impl/full/state.go index a8dfbbc87..9fb2e4933 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -4,27 +4,27 @@ import ( "bytes" "context" "fmt" - "github.com/prometheus/common/log" "strconv" - "github.com/filecoin-project/go-amt-ipld/v2" - "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/specs-actors/actors/abi/big" - "github.com/filecoin-project/specs-actors/actors/builtin/market" - "github.com/filecoin-project/specs-actors/actors/builtin/miner" - samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig" cid "github.com/ipfs/go-cid" "github.com/ipfs/go-hamt-ipld" cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" + "github.com/prometheus/common/log" cbg "github.com/whyrusleeping/cbor-gen" "go.uber.org/fx" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-amt-ipld/v2" + "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/specs-actors/actors/abi/big" + "github.com/filecoin-project/specs-actors/actors/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/market" + "github.com/filecoin-project/specs-actors/actors/builtin/miner" + samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" @@ -333,7 +333,7 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSet if err != nil { return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { + if _, err := a.StateManager.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil { return nil, err } cst := cbor.NewCborStore(a.StateManager.ChainStore().Blockstore()) @@ -382,7 +382,7 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (m if err != nil { return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } - if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil { + if _, err := a.StateManager.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil { return nil, err } @@ -558,7 +558,7 @@ func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Add return types.EmptyInt, xerrors.Errorf("failed to load multisig actor state: %w", err) } - if act.Code != actors.MultisigCodeCid { + if act.Code != builtin.MultisigActorCodeID { return types.EmptyInt, fmt.Errorf("given actor was not a multisig") } diff --git a/paychmgr/simple.go b/paychmgr/simple.go index 007ed4c78..1370865ed 100644 --- a/paychmgr/simple.go +++ b/paychmgr/simple.go @@ -23,7 +23,7 @@ func (pm *Manager) createPaych(ctx context.Context, from, to address.Address, am } enc, aerr := actors.SerializeParams(&init_.ExecParams{ - CodeCID: actors.PaymentChannelCodeCid, + CodeCID: builtin.PaymentChannelActorCodeID, ConstructorParams: params, }) if aerr != nil { @@ -31,7 +31,7 @@ func (pm *Manager) createPaych(ctx context.Context, from, to address.Address, am } msg := &types.Message{ - To: actors.InitAddress, + To: builtin.InitActorAddr, From: from, Value: amt, Method: builtin.MethodsInit.Exec, diff --git a/storage/sealing/checks.go b/storage/sealing/checks.go index 35b37daab..b45966d9f 100644 --- a/storage/sealing/checks.go +++ b/storage/sealing/checks.go @@ -98,7 +98,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se } ccmt := &types.Message{ - To: actors.StorageMarketAddress, + To: builtin.StorageMarketActorAddr, From: maddr, Value: types.NewInt(0), GasPrice: types.NewInt(0),