From 15722b4bb9067b945ab6c539fa5adc8f7b54fdba Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 11 Feb 2020 15:29:45 -0800 Subject: [PATCH] Re: #1250: API methods should receive TipSetKeys, not TipSets, as input --- checks.go | 6 +++--- sealing.go | 20 ++++++++++---------- states_failed.go | 3 ++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/checks.go b/checks.go index 9baf2d993..cbcbca8fc 100644 --- a/checks.go +++ b/checks.go @@ -34,7 +34,7 @@ func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error { } for i, piece := range si.Pieces { - deal, err := api.StateMarketStorageDeal(ctx, piece.DealID, nil) + deal, err := api.StateMarketStorageDeal(ctx, piece.DealID, types.EmptyTSK) if err != nil { return &ErrApi{xerrors.Errorf("getting deal %d for piece %d: %w", piece.DealID, i, err)} } @@ -63,7 +63,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se return &ErrApi{xerrors.Errorf("getting chain head: %w", err)} } - ssize, err := api.StateMinerSectorSize(ctx, maddr, head) + ssize, err := api.StateMinerSectorSize(ctx, maddr, head.Key()) if err != nil { return &ErrApi{err} } @@ -85,7 +85,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se Method: actors.SMAMethods.ComputeDataCommitment, Params: ccparams, } - r, err := api.StateCall(ctx, ccmt, nil) + r, err := api.StateCall(ctx, ccmt, types.EmptyTSK) if err != nil { return &ErrApi{xerrors.Errorf("calling ComputeDataCommitment: %w", err)} } diff --git a/sealing.go b/sealing.go index 6e562001d..c39b98257 100644 --- a/sealing.go +++ b/sealing.go @@ -29,23 +29,23 @@ type TicketFn func(context.Context) (*sectorbuilder.SealTicket, error) type sealingApi interface { // TODO: trim down // Call a read only method on actors (no interaction with the chain required) - StateCall(context.Context, *types.Message, *types.TipSet) (*api.MethodCall, error) - StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error) - StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) - StateMinerSectors(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) - StateMinerProvingSet(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) - StateMinerSectorSize(context.Context, address.Address, *types.TipSet) (uint64, error) + StateCall(context.Context, *types.Message, types.TipSetKey) (*api.MethodCall, error) + StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error) + StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, tsk types.TipSetKey) (uint64, error) + StateMinerSectors(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) + StateMinerProvingSet(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) + StateMinerSectorSize(context.Context, address.Address, types.TipSetKey) (uint64, error) StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error) // TODO: removeme eventually - StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) - StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) - StateMarketStorageDeal(context.Context, uint64, *types.TipSet) (*actors.OnChainDeal, error) + StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) + StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) + StateMarketStorageDeal(context.Context, uint64, types.TipSetKey) (*actors.OnChainDeal, error) MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error) ChainHead(context.Context) (*types.TipSet, error) ChainNotify(context.Context) (<-chan []*store.HeadChange, error) ChainGetRandomness(context.Context, types.TipSetKey, int64) ([]byte, error) - ChainGetTipSetByHeight(context.Context, uint64, *types.TipSet) (*types.TipSet, error) + ChainGetTipSetByHeight(context.Context, uint64, types.TipSetKey) (*types.TipSet, error) ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error) ChainReadObj(context.Context, cid.Cid) ([]byte, error) diff --git a/states_failed.go b/states_failed.go index 680ba6891..642469dd6 100644 --- a/states_failed.go +++ b/states_failed.go @@ -3,6 +3,7 @@ package sealing import ( "bytes" "fmt" + "github.com/filecoin-project/lotus/chain/types" "time" "golang.org/x/xerrors" @@ -29,7 +30,7 @@ func failedCooldown(ctx statemachine.Context, sector SectorInfo) error { } func (m *Sealing) checkPreCommitted(ctx statemachine.Context, sector SectorInfo) (*actors.PreCommittedSector, bool) { - act, err := m.api.StateGetActor(ctx.Context(), m.maddr, nil) + act, err := m.api.StateGetActor(ctx.Context(), m.maddr, types.EmptyTSK) if err != nil { log.Errorf("handleSealFailed(%d): temp error: %+v", sector.SectorID, err) return nil, true