actors: drop a bunch of type aliases

This commit is contained in:
Łukasz Magiera 2020-02-25 21:35:15 +01:00
parent f1d9033194
commit cd10a3126b
24 changed files with 54 additions and 138 deletions

View File

@ -1,9 +0,0 @@
package actors
import (
"github.com/filecoin-project/specs-actors/actors/builtin/cron"
)
type CronActor = cron.Actor
type CronActorState = cron.State

View File

@ -1,12 +0,0 @@
package actors
import (
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
logging "github.com/ipfs/go-log/v2"
)
var log = logging.Logger("actors")
type InitActor = init_.Actor
type InitActorState = init_.State

View File

@ -1,9 +0,0 @@
package actors
import (
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
)
type StorageMinerActor = miner.Actor
type StorageMinerActorState = miner.State

View File

@ -1,9 +0,0 @@
package actors
import (
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
)
type PaymentChannelActor = paych.Actor
type PaymentChannelActorState = paych.State

View File

@ -1,45 +0,0 @@
package actors
import (
"github.com/filecoin-project/specs-actors/actors/builtin/market"
)
type StorageMarketState = market.State
// TODO: Drop in favour of car storage
type SerializationMode = uint64
const (
SerializationUnixFSv0 = iota
// IPLD / car
)
type StorageDealProposal = market.DealProposal
type WithdrawBalanceParams = market.WithdrawBalanceParams
type PublishStorageDealsParams = market.PublishStorageDealsParams
type PublishStorageDealResponse = market.PublishStorageDealsReturn
type ActivateStorageDealsParams = market.VerifyDealsOnSectorProveCommitParams
type ComputeDataCommitmentParams = market.ComputeDataCommitmentParams
/*
func (sma StorageMarketActor) HandleCronAction(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) SettleExpiredDeals(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) SlashStorageDealCollateral(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
func (sma StorageMarketActor) GetLastExpirationFromDealIDs(act *types.Actor, vmctx types.VMContext, params *struct{}) ([]byte, ActorError) {
}
*/

View File

@ -1,12 +0,0 @@
package actors
import (
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
)
type StoragePowerActor = power.Actor
var SPAMethods = builtin.MethodsPower
type StoragePowerState = power.State

View File

@ -4,10 +4,14 @@ 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{}

View File

@ -69,7 +69,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, actors.SPAMethods.CreateMiner, params)
rval, err := doExecValue(ctx, vm, actors.StoragePowerAddress, m.Owner, m.PowerBalance, builtin.MethodsPower.CreateMiner, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/ipfs/go-hamt-ipld"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
@ -20,7 +21,7 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
return nil, xerrors.New("too many initial actors")
}
var ias actors.InitActorState
var ias init_.State
ias.NextID = MinerStart
ias.NetworkName = netname

View File

@ -14,7 +14,7 @@ import (
func SetupCronActor(bs bstore.Blockstore) (*types.Actor, error) {
cst := cbor.NewCborStore(bs)
cas := &actors.CronActorState{Entries: []cron.Entry{{
cas := &cron.State{Entries: []cron.Entry{{
Receiver: builtin.StoragePowerActorAddr,
MethodNum: builtin.MethodsPower.OnEpochTickEnd,
},

View File

@ -79,7 +79,7 @@ func (st *StateTree) LookupID(addr address.Address) (address.Address, error) {
return address.Undef, xerrors.Errorf("getting init actor: %w", err)
}
var ias actors.InitActorState
var ias init_.State
if err := st.Store.Get(context.TODO(), act.Head, &ias); err != nil {
return address.Undef, xerrors.Errorf("loading init actor state: %w", err)
}
@ -158,7 +158,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 {
var ias actors.InitActorState
var ias init_.State
if err := st.Store.Get(context.TODO(), initact.Head, &ias); err != nil {
return err
}

View File

@ -16,6 +16,7 @@ import (
"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/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
cbg "github.com/whyrusleeping/cbor-gen"
@ -627,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 actors.StorageMarketState
var state market.State
_, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts)
if err != nil {
return api.MarketBalance{}, err

View File

@ -103,7 +103,7 @@ func GetMinerWorker(ctx context.Context, sm *StateManager, ts *types.TipSet, mad
}
func GetMinerPostState(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*miner.PoStState, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get eps) failed to load miner actor state: %w", err)
@ -113,7 +113,7 @@ func GetMinerPostState(ctx context.Context, sm *StateManager, ts *types.TipSet,
}
func SectorSetSizes(ctx context.Context, sm *StateManager, maddr address.Address, ts *types.TipSet) (api.MinerSectors, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return api.MinerSectors{}, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
@ -137,7 +137,7 @@ func SectorSetSizes(ctx context.Context, sm *StateManager, maddr address.Address
}
func GetMinerProvingSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]*api.ChainSectorInfo, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get pset) failed to load miner actor state: %w", err)
@ -147,7 +147,7 @@ func GetMinerProvingSet(ctx context.Context, sm *StateManager, ts *types.TipSet,
}
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]*api.ChainSectorInfo, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
@ -181,7 +181,7 @@ func GetSectorsForElectionPost(ctx context.Context, sm *StateManager, ts *types.
}
func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (abi.SectorSize, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return 0, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
@ -196,7 +196,7 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
}
func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]abi.SectorNumber, error) {
var mas actors.StorageMinerActorState
var mas miner.State
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
if err != nil {
return nil, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
@ -249,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 actors.StoragePowerState
var state power.State
if _, err := sm.LoadActorState(ctx, actors.StoragePowerAddress, &state, ts); err != nil {
return nil, err
}

View File

@ -13,9 +13,13 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/cron"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/system"
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
@ -41,13 +45,13 @@ func NewInvoker() *invoker {
// add builtInCode using: register(cid, singleton)
inv.Register(builtin.SystemActorCodeID, system.Actor{}, adt.EmptyValue{})
inv.Register(actors.InitCodeCid, actors.InitActor{}, actors.InitActorState{})
inv.Register(actors.CronCodeCid, actors.CronActor{}, actors.CronActorState{})
inv.Register(actors.StoragePowerCodeCid, actors.StoragePowerActor{}, actors.StoragePowerState{})
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, actors.PaymentChannelActor{}, actors.PaymentChannelActorState{})
inv.Register(actors.PaymentChannelCodeCid, paych.Actor{}, paych.State{})
return inv
}

View File

@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"reflect"
"strconv"
"strings"
@ -13,7 +12,10 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/libp2p/go-libp2p-core/peer"
"golang.org/x/xerrors"
@ -974,13 +976,13 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er
case actors.StorageMarketCodeCid:
f = market.Actor{}.Exports()[method]
case actors.StorageMinerCodeCid:
f = actors.StorageMinerActor{}.Exports()[method]
f = miner2.Actor{}.Exports()[method]
case actors.StoragePowerCodeCid:
f = actors.StoragePowerActor{}.Exports()[method]
f = power.Actor{}.Exports()[method]
case actors.MultisigCodeCid:
f = samsig.Actor{}.Exports()[method]
case actors.PaymentChannelCodeCid:
f = actors.PaymentChannelActor{}.Exports()[method]
f = paych.Actor{}.Exports()[method]
default:
return nil, fmt.Errorf("the lazy devs didnt add support for that actor to this call yet")
}

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
crypto2 "github.com/filecoin-project/specs-actors/actors/crypto"
@ -308,7 +309,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, metadata string,
return nil
}
func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.StorageDealProposal) (abi.DealID, error) {
func findMarketDealID(ctx context.Context, api lapi.FullNode, deal market.DealProposal) (abi.DealID, error) {
// TODO: find a better way
// (this is only used by genesis miners)

View File

@ -186,7 +186,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
return 0, xerrors.Errorf("deal publish message called incorrect method (method=%s)", pubmsg.Method)
}
var params actors.PublishStorageDealsParams
var params samarket.PublishStorageDealsParams
if err := params.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil {
return 0, err
}
@ -218,7 +218,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
return 0, xerrors.Errorf("deal publish failed: exit=%d", ret.ExitCode)
}
var res actors.PublishStorageDealResponse
var res samarket.PublishStorageDealsReturn
if err := res.UnmarshalCBOR(bytes.NewReader(ret.Return)); err != nil {
return 0, err
}

View File

@ -58,7 +58,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
return 0, cid.Undef, err
}
params, err := actors.SerializeParams(&actors.PublishStorageDealsParams{
params, err := actors.SerializeParams(&market.PublishStorageDealsParams{
Deals: []market.ClientDealProposal{deal.ClientDealProposal},
})
@ -86,7 +86,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
if r.Receipt.ExitCode != 0 {
return 0, cid.Undef, xerrors.Errorf("publishing deal failed: exit %d", r.Receipt.ExitCode)
}
var resp actors.PublishStorageDealResponse
var resp market.PublishStorageDealsReturn
if err := resp.UnmarshalCBOR(bytes.NewReader(r.Receipt.Return)); err != nil {
return 0, cid.Undef, err
}

View File

@ -328,7 +328,7 @@ func (a *StateAPI) StateMarketBalance(ctx context.Context, addr address.Address,
func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketBalance, error) {
out := map[string]api.MarketBalance{}
var state actors.StorageMarketState
var state market.State
ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
@ -377,7 +377,7 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSet
func (a *StateAPI) StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]api.MarketDeal, error) {
out := map[string]api.MarketDeal{}
var state actors.StorageMarketState
var state market.State
ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)

View File

@ -53,7 +53,7 @@ func NewManager(sm *stmgr.StateManager, pchstore *Store, api ManagerApi) *Manage
}
}
func maxLaneFromState(st *actors.PaymentChannelActorState) (uint64, error) {
func maxLaneFromState(st *paych.State) (uint64, error) {
maxLane := uint64(math.MaxInt64)
for _, state := range st.LaneStates {
if (state.ID)+1 > maxLane+1 {

View File

@ -7,12 +7,11 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
)
func (pm *Manager) loadPaychState(ctx context.Context, ch address.Address) (*types.Actor, *actors.PaymentChannelActorState, error) {
var pcast actors.PaymentChannelActorState
func (pm *Manager) loadPaychState(ctx context.Context, ch address.Address) (*types.Actor, *paych.State, error) {
var pcast paych.State
act, err := pm.sm.LoadActorState(ctx, ch, &pcast, nil)
if err != nil {
return nil, nil, err

View File

@ -5,9 +5,9 @@ import (
commcid "github.com/filecoin-project/go-fil-commcid"
"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/crypto"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
"github.com/filecoin-project/lotus/genesis"
@ -35,7 +35,7 @@ func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis
preseal.CommD = commD(sdata)
preseal.CommR = commDR(preseal.CommD[:])
preseal.SectorID = abi.SectorNumber(i + 1)
preseal.Deal = actors.StorageDealProposal{
preseal.Deal = market.DealProposal{
PieceCID: commcid.PieceCommitmentV1ToCID(preseal.CommD[:]),
PieceSize: abi.PaddedPieceSize(ssize),
Client: maddr,

View File

@ -3,20 +3,21 @@ package sealing
import (
"bytes"
"context"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/lotus/lib/zerocomm"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multihash"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/zerocomm"
)
// TODO: For now we handle this by halting state execution, when we get jsonrpc reconnecting
@ -88,7 +89,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se
return &ErrApi{err}
}
ccparams, err := actors.SerializeParams(&actors.ComputeDataCommitmentParams{
ccparams, err := actors.SerializeParams(&market.ComputeDataCommitmentParams{
DealIDs: si.deals(),
SectorSize: ssize,
})

View File

@ -11,7 +11,6 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/apibstore"
"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/lib/statemachine"
@ -46,7 +45,7 @@ func (m *Sealing) checkPreCommitted(ctx statemachine.Context, sector SectorInfo)
return nil, true
}
var state actors.StorageMinerActorState
var state miner.State
if err := state.UnmarshalCBOR(bytes.NewReader(st)); err != nil {
log.Errorf("handleSealFailed(%d): temp error: unmarshaling miner state: %+v", sector.SectorID, err)
return nil, true