diff --git a/api/api_storage.go b/api/api_storage.go index c032a8e1b..f4b06d00a 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -283,19 +283,20 @@ type SectorPiece struct { } type SectorInfo struct { - SectorID abi.SectorNumber - State SectorState - CommD *cid.Cid - CommR *cid.Cid - Proof []byte - Deals []abi.DealID - Pieces []SectorPiece - Ticket SealTicket - Seed SealSeed - PreCommitMsg *cid.Cid - CommitMsg *cid.Cid - Retries uint64 - ToUpgrade bool + SectorID abi.SectorNumber + State SectorState + CommD *cid.Cid + CommR *cid.Cid + Proof []byte + Deals []abi.DealID + Pieces []SectorPiece + Ticket SealTicket + Seed SealSeed + PreCommitMsg *cid.Cid + CommitMsg *cid.Cid + Retries uint64 + ToUpgrade bool + ReplicaUpdateMessage *cid.Cid LastErr string diff --git a/extern/sector-storage/faults.go b/extern/sector-storage/faults.go index e5ac519d5..c68d18ef0 100644 --- a/extern/sector-storage/faults.go +++ b/extern/sector-storage/faults.go @@ -60,7 +60,7 @@ func (m *Manager) CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, return nil } - commr, err := rg(ctx, sector.ID) + commr, update, err := rg(ctx, sector.ID) if err != nil { log.Warnw("CheckProvable Sector FAULT: getting commR", "sector", sector, "sealed", "err", err) bad[sector.ID] = fmt.Sprintf("getting commR: %s", err) @@ -72,6 +72,7 @@ func (m *Manager) CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, SectorNumber: sector.ID.Number, SealedCID: commr, Challenge: ch.Challenges[sector.ID.Number], + Update: update, }, wpp) if err != nil { log.Warnw("CheckProvable Sector FAULT: generating vanilla proof", "sector", sector, "err", err) diff --git a/extern/sector-storage/manager_post.go b/extern/sector-storage/manager_post.go index 6a00e0f8d..d0aea80eb 100644 --- a/extern/sector-storage/manager_post.go +++ b/extern/sector-storage/manager_post.go @@ -54,6 +54,7 @@ func (m *Manager) generateWinningPoSt(ctx context.Context, minerID abi.ActorID, SectorNumber: s.SectorNumber, SealedCID: s.SealedCID, Challenge: postChallenges.Challenges[s.SectorNumber], + Update: s.SectorKey != nil, } } @@ -82,7 +83,7 @@ func (m *Manager) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, s return m.generateWindowPoSt(ctx, minerID, sectorInfo, randomness) } -func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.SectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorID, error) { +func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []proof.ExtendedSectorInfo, randomness abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorID, error) { var retErr error = nil randomness[31] &= 0x3f @@ -118,7 +119,7 @@ func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, s }) sectorNums := make([]abi.SectorNumber, len(sectorInfo)) - sectorMap := make(map[abi.SectorNumber]proof.SectorInfo) + sectorMap := make(map[abi.SectorNumber]proof.ExtendedSectorInfo) for i, s := range sectorInfo { sectorNums[i] = s.SectorNumber sectorMap[s.SectorNumber] = s @@ -152,6 +153,7 @@ func (m *Manager) generateWindowPoSt(ctx context.Context, minerID abi.ActorID, s SectorNumber: snum, SealedCID: sinfo.SealedCID, Challenge: postChallenges.Challenges[snum], + Update: sinfo.SectorKey != nil, }) } diff --git a/extern/sector-storage/stores/local.go b/extern/sector-storage/stores/local.go index 8af84add8..3b270d8d3 100644 --- a/extern/sector-storage/stores/local.go +++ b/extern/sector-storage/stores/local.go @@ -729,12 +729,23 @@ func (st *Local) GenerateSingleVanillaProof(ctx context.Context, minerID abi.Act ProofType: si.SealProof, } - src, _, err := st.AcquireSector(ctx, sr, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove) - if err != nil { - return nil, xerrors.Errorf("acquire sector: %w", err) + var cache string + var sealed string + if si.Update { + src, _, err := st.AcquireSector(ctx, sr, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove) + if err != nil { + return nil, xerrors.Errorf("acquire sector: %w", err) + } + cache, sealed = src.Update, src.UpdateCache + } else { + src, _, err := st.AcquireSector(ctx, sr, storiface.FTSealed|storiface.FTCache, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove) + if err != nil { + return nil, xerrors.Errorf("acquire sector: %w", err) + } + cache, sealed = src.Cache, src.Sealed } - if src.Sealed == "" || src.Cache == "" { + if sealed == "" || cache == "" { return nil, errPathNotFound } @@ -744,9 +755,9 @@ func (st *Local) GenerateSingleVanillaProof(ctx context.Context, minerID abi.Act SectorNumber: si.SectorNumber, SealedCID: si.SealedCID, }, - CacheDirPath: src.Cache, + CacheDirPath: cache, PoStProofType: ppt, - SealedSectorPath: src.Sealed, + SealedSectorPath: sealed, } return ffi.GenerateSingleVanillaProof(psi, si.Challenge) diff --git a/extern/sector-storage/storiface/ffi.go b/extern/sector-storage/storiface/ffi.go index 2b6df667a..9696b29db 100644 --- a/extern/sector-storage/storiface/ffi.go +++ b/extern/sector-storage/storiface/ffi.go @@ -28,4 +28,4 @@ func (i UnpaddedByteIndex) Valid() error { type PaddedByteIndex uint64 -type RGetter func(ctx context.Context, id abi.SectorID) (cid.Cid, error) +type RGetter func(ctx context.Context, id abi.SectorID) (sealed cid.Cid, update bool, err error) diff --git a/extern/sector-storage/storiface/worker.go b/extern/sector-storage/storiface/worker.go index feea90ec5..1e9ea4bbc 100644 --- a/extern/sector-storage/storiface/worker.go +++ b/extern/sector-storage/storiface/worker.go @@ -146,6 +146,7 @@ type PostSectorChallenge struct { SectorNumber abi.SectorNumber SealedCID cid.Cid Challenge []uint64 + Update bool } type FallbackChallenges struct { diff --git a/go.mod b/go.mod index 042f60945..1a88039c3 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/filecoin-project/specs-actors/v5 v5.0.4 github.com/filecoin-project/specs-actors/v6 v6.0.1 github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1 - github.com/filecoin-project/specs-storage v0.1.1-0.20220114131651-ee969fade269 + github.com/filecoin-project/specs-storage v0.1.1-0.20220118100615-64256a3e01ac github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/gbrlsnchs/jwt/v3 v3.0.1 github.com/gdamore/tcell/v2 v2.2.0 diff --git a/go.sum b/go.sum index caf84db99..ec254d7fc 100644 --- a/go.sum +++ b/go.sum @@ -377,15 +377,17 @@ github.com/filecoin-project/specs-actors/v6 v6.0.0/go.mod h1:V1AYfi5GkHXipx1mnVi github.com/filecoin-project/specs-actors/v6 v6.0.1 h1:laxvHNsvrq83Y9n+W7znVCePi3oLyRf0Rkl4jFO8Wew= github.com/filecoin-project/specs-actors/v6 v6.0.1/go.mod h1:V1AYfi5GkHXipx1mnVivoICZh3wtwPxDVuds+fbfQtk= github.com/filecoin-project/specs-actors/v7 v7.0.0-20211117170924-fd07a4c7dff9/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE= +github.com/filecoin-project/specs-actors/v7 v7.0.0-20211222192039-c83bea50c402 h1:jPJlk7YpWKDNLx/3Dosgm3ie3wsNhe3YP6Xl8Gc5vqY= +github.com/filecoin-project/specs-actors/v7 v7.0.0-20211222192039-c83bea50c402/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE= github.com/filecoin-project/specs-actors/v7 v7.0.0-20211222192039-c83bea50c402/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE= github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1 h1:FuDaXIbcw2hRsFI8SDTmsGGCE+NumpF6aiBoU/2X5W4= github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1/go.mod h1:TA5FwCna+Yi36POaT7SLKXsgEDvJwc0V/L6ZsO19B9M= github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9 h1:oUYOvF7EvdXS0Zmk9mNkaB6Bu0l+WXBYPzVodKMiLug= github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU= -github.com/filecoin-project/specs-actors/v7 v7.0.0-20211222192039-c83bea50c402 h1:jPJlk7YpWKDNLx/3Dosgm3ie3wsNhe3YP6Xl8Gc5vqY= -github.com/filecoin-project/specs-actors/v7 v7.0.0-20211222192039-c83bea50c402/go.mod h1:p6LIOFezA1rgRLMewbvdi3Pp6SAu+q9FtJ9CAleSjrE= github.com/filecoin-project/specs-storage v0.1.1-0.20220114131651-ee969fade269 h1:icvWX24jKnt8qCobOE5fLJhMxiYEZy5RcGSkLPTPndU= github.com/filecoin-project/specs-storage v0.1.1-0.20220114131651-ee969fade269/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU= +github.com/filecoin-project/specs-storage v0.1.1-0.20220118100615-64256a3e01ac h1:NE64qumS2opyKJQgkHNSnojJNrS1pfMjK3irBx72BBA= +github.com/filecoin-project/specs-storage v0.1.1-0.20220118100615-64256a3e01ac/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU= github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg= github.com/filecoin-project/test-vectors/schema v0.0.5/go.mod h1:iQ9QXLpYWL3m7warwvK1JC/pTri8mnfEmKygNDqqY6E= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 3ebac1409..0518323d2 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -1126,16 +1126,16 @@ func (sm *StorageMinerAPI) CreateBackup(ctx context.Context, fpath string) error func (sm *StorageMinerAPI) CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, sectors []sto.SectorRef, expensive bool) (map[abi.SectorNumber]string, error) { var rg storiface.RGetter if expensive { - rg = func(ctx context.Context, id abi.SectorID) (cid.Cid, error) { + rg = func(ctx context.Context, id abi.SectorID) (cid.Cid, bool, error) { si, err := sm.Miner.SectorsStatus(ctx, id.Number, false) if err != nil { - return cid.Undef, err + return cid.Undef, false, err } if si.CommR == nil { - return cid.Undef, xerrors.Errorf("commr is nil") + return cid.Undef, false, xerrors.Errorf("commr is nil") } - return *si.CommR, nil + return *si.CommR, si.ReplicaUpdateMessage != nil, nil } } diff --git a/storage/miner_sealing.go b/storage/miner_sealing.go index d8ef26835..08d47818b 100644 --- a/storage/miner_sealing.go +++ b/storage/miner_sealing.go @@ -140,10 +140,11 @@ func (m *Miner) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnC Value: info.SeedValue, Epoch: info.SeedEpoch, }, - PreCommitMsg: info.PreCommitMessage, - CommitMsg: info.CommitMessage, - Retries: info.InvalidProofs, - ToUpgrade: m.IsMarkedForUpgrade(sid), + PreCommitMsg: info.PreCommitMessage, + CommitMsg: info.CommitMessage, + Retries: info.InvalidProofs, + ToUpgrade: m.IsMarkedForUpgrade(sid), + ReplicaUpdateMessage: info.ReplicaUpdateMessage, LastErr: info.LastErr, Log: log, diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index b561cd6d0..bce20bb04 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -204,10 +204,18 @@ func (s *WindowPoStScheduler) checkSectors(ctx context.Context, check bitfield.B return bitfield.BitField{}, err } - sectors := make(map[abi.SectorNumber]cid.Cid) + type checkSector struct { + sealed cid.Cid + update bool + } + + sectors := make(map[abi.SectorNumber]checkSector) var tocheck []storage.SectorRef for _, info := range sectorInfos { - sectors[info.SectorNumber] = info.SealedCID + sectors[info.SectorNumber] = checkSector{ + sealed: info.SealedCID, + update: info.SectorKeyCID != nil, + } tocheck = append(tocheck, storage.SectorRef{ ProofType: info.SealProof, ID: abi.SectorID{ @@ -217,12 +225,12 @@ func (s *WindowPoStScheduler) checkSectors(ctx context.Context, check bitfield.B }) } - bad, err := s.faultTracker.CheckProvable(ctx, s.proofType, tocheck, func(ctx context.Context, id abi.SectorID) (cid.Cid, error) { - scid, ok := sectors[id.Number] + bad, err := s.faultTracker.CheckProvable(ctx, s.proofType, tocheck, func(ctx context.Context, id abi.SectorID) (cid.Cid, bool, error) { + s, ok := sectors[id.Number] if !ok { - return cid.Undef, xerrors.Errorf("sealed CID not found") + return cid.Undef, false, xerrors.Errorf("sealed CID not found") } - return scid, nil + return s.sealed, s.update, nil }) if err != nil { return bitfield.BitField{}, xerrors.Errorf("checking provable sectors: %w", err)