diff --git a/api/api_full.go b/api/api_full.go index 79b098a84..6e45073fb 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -220,7 +220,7 @@ type FullNode interface { // Returns all non-expired Faults that occur within lookback epochs of the given tipset StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error) StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) - StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) + StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index e5986bbe0..9cc3f9f60 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -132,7 +132,7 @@ type FullNodeStruct struct { StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"` StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"` StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"` - StateMinerInitialPledgeCollateral func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"` StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` @@ -202,12 +202,12 @@ type StorageMinerStruct struct { PledgeSector func(context.Context) error `perm:"write"` - SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"` - SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"` - SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"` - SectorStartSealing func(context.Context, abi.SectorNumber) error`perm:"write"` - SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"admin"` - SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"` + SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"` + SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"` + SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"` + SectorStartSealing func(context.Context, abi.SectorNumber) error `perm:"write"` + SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"admin"` + SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"` WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"` @@ -591,8 +591,8 @@ func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address return c.Internal.StateMinerRecoveries(ctx, actor, tsk) } -func (c *FullNodeStruct) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, snum abi.SectorNumber, tsk types.TipSetKey) (types.BigInt, error) { - return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, snum, tsk) +func (c *FullNodeStruct) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { + return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, pci, tsk) } func (c *FullNodeStruct) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (types.BigInt, error) { diff --git a/build/version.go b/build/version.go index 03d5c0792..fc64eae71 100644 --- a/build/version.go +++ b/build/version.go @@ -53,7 +53,7 @@ func (ve Version) EqMajorMinor(v2 Version) bool { } // APIVersion is a semver version of the rpc api exposed -var APIVersion Version = newVer(0, 4, 0) +var APIVersion Version = newVer(0, 5, 0) //nolint:varcheck,deadcode const ( diff --git a/go.mod b/go.mod index c6b39b293..0e274ad31 100644 --- a/go.mod +++ b/go.mod @@ -25,14 +25,13 @@ require ( github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5 github.com/filecoin-project/go-fil-markets v0.3.0 github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24 - github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6 github.com/filecoin-project/go-paramfetch v0.0.2-0.20200605171344-fcac609550ca github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200626110003-76ce3b9d9496 github.com/filecoin-project/specs-actors v0.7.0 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea - github.com/filecoin-project/storage-fsm v0.0.0-20200626110227-c059934fe82e + github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-kit/kit v0.10.0 github.com/go-ole/go-ole v1.2.4 // indirect @@ -128,5 +127,3 @@ require ( replace github.com/golangci/golangci-lint => github.com/golangci/golangci-lint v1.18.0 replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi - -replace github.com/filecoin-project/storage-fsm => /home/magik6k/gohack/github.com/filecoin-project/storage-fsm diff --git a/go.sum b/go.sum index be6fd1f1f..63c3ab9d3 100644 --- a/go.sum +++ b/go.sum @@ -259,18 +259,14 @@ github.com/filecoin-project/sector-storage v0.0.0-20200626110003-76ce3b9d9496/go github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= -github.com/filecoin-project/specs-actors v0.6.2-0.20200617175406-de392ca14121 h1:oRA+b4iN4H86xXDXbU3TOyvmBZp7//c5VqTc0oJ6nLg= -github.com/filecoin-project/specs-actors v0.6.2-0.20200617175406-de392ca14121/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY= github.com/filecoin-project/specs-actors v0.7.0 h1:tldjW8pFiJcMtyGPsXmPoFdbN/18mKW3BpEMlO4NJAc= github.com/filecoin-project/specs-actors v0.7.0/go.mod h1:+z0htZu/wLBDbOLcQTKKUEC2rkUTFzL2KJ/bRAVWkws= github.com/filecoin-project/specs-storage v0.1.0 h1:PkDgTOT5W5Ao7752onjDl4QSv+sgOVdJbvFjOnD5w94= github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= -github.com/filecoin-project/storage-fsm v0.0.0-20200625160832-379a4655b044 h1:i4oMhv1kx/MAUxRN4EM5tag5fI1uagrwQwINgKrzUt4= -github.com/filecoin-project/storage-fsm v0.0.0-20200625160832-379a4655b044/go.mod h1:JD7fmV1BYADDcy4EYQnqFH/rUzXsh0Je0jXarCjZqSk= -github.com/filecoin-project/storage-fsm v0.0.0-20200626110227-c059934fe82e h1:U4HSiMGHuLjIWkUDFxg8yM7cAwbFRGHIGet2zxYo0yc= -github.com/filecoin-project/storage-fsm v0.0.0-20200626110227-c059934fe82e/go.mod h1:JD7fmV1BYADDcy4EYQnqFH/rUzXsh0Je0jXarCjZqSk= +github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336 h1:zg2YbDReOfovC9g2M7YmtL/RQe0hBZiIOYeuy/NAV4Y= +github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336/go.mod h1:e1FIsgLiVFP0ybBdHeGEbhCu3idjCDtEJj+hMgaSJpI= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= diff --git a/node/impl/full/state.go b/node/impl/full/state.go index f7e161dab..5bb27d223 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -693,7 +693,7 @@ func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Add var initialPledgeNum = types.NewInt(103) var initialPledgeDen = types.NewInt(100) -func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, snum abi.SectorNumber, tsk types.TipSetKey) (types.BigInt, error) { +func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) { ts, err := a.Chain.GetTipSetFromKey(tsk) if err != nil { return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err) @@ -734,21 +734,12 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr } } - precommit, found, err := minerState.GetPrecommittedSector(as, snum) - if err != nil { - return types.EmptyInt, err - } - - if !found { - return types.EmptyInt, xerrors.Errorf("no precommit found for sector %d", snum) - } - var dealWeights market.VerifyDealsForActivationReturn { var err error params, err := actors.SerializeParams(&market.VerifyDealsForActivationParams{ - DealIDs: precommit.Info.DealIDs, - SectorExpiry: precommit.Info.Expiration, + DealIDs: pci.DealIDs, + SectorExpiry: pci.Expiration, }) if err != nil { return types.EmptyInt, err @@ -771,12 +762,12 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr } } - ssize, err := precommit.Info.SealProof.SectorSize() + ssize, err := pci.SealProof.SectorSize() if err != nil { return types.EmptyInt, err } - duration := precommit.Info.Expiration - ts.Height() // NB: not exactly accurate, but should always lead us to *over* estimate, not under + duration := pci.Expiration - ts.Height() // NB: not exactly accurate, but should always lead us to *over* estimate, not under circSupply, err := a.StateManager.CirculatingSupply(ctx, ts) if err != nil { diff --git a/storage/adapter_storage_miner.go b/storage/adapter_storage_miner.go index 5fc811997..266ee3849 100644 --- a/storage/adapter_storage_miner.go +++ b/storage/adapter_storage_miner.go @@ -49,13 +49,13 @@ func (s SealingAPIAdapter) StateMinerSectorSize(ctx context.Context, maddr addre return mi.SectorSize, nil } -func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, n abi.SectorNumber, tok sealing.TipSetToken) (big.Int, error) { +func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) { tsk, err := types.TipSetKeyFromBytes(tok) if err != nil { return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) } - return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, n, tsk) + return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, pci, tsk) } func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (address.Address, error) { diff --git a/storage/miner.go b/storage/miner.go index 514af527a..b0880e57b 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -53,7 +53,7 @@ type storageMinerApi interface { StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error) - StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) + StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) // TODO: removeme eventually StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error) StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) @@ -105,7 +105,7 @@ func (m *Miner) Run(ctx context.Context) error { evts := events.NewEvents(ctx, m.api) adaptedAPI := NewSealingAPIAdapter(m.api) - pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, 10000000, md.PeriodStart%miner.WPoStProvingPeriod) + pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, miner.MaxSectorExpirationExtension-(miner.WPoStProvingPeriod*2), md.PeriodStart%miner.WPoStProvingPeriod) m.sealing = sealing.New(adaptedAPI, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp) go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function