From e854090bdd3e600e1ae12d1011de71499dab6c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 10 Apr 2020 20:41:59 +0200 Subject: [PATCH 1/5] v25 --- extern/filecoin-ffi | 2 +- ffiwrapper/config.go | 20 +------- ffiwrapper/params_shared.go | 18 ------- ffiwrapper/sealer.go | 13 ----- ffiwrapper/sealer_cgo.go | 3 +- ffiwrapper/types.go | 4 +- ffiwrapper/verifier_cgo.go | 95 ++++++++++--------------------------- go.mod | 2 +- go.sum | 2 + localworker.go | 6 --- 10 files changed, 34 insertions(+), 131 deletions(-) delete mode 100644 ffiwrapper/params_shared.go diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index e899cc1dd..0f03c5a6b 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit e899cc1dd0720e0a4d25b0e751b84e3733cbedc5 +Subproject commit 0f03c5a6b8c57f7c008e0d9b18dbd37b576ca836 diff --git a/ffiwrapper/config.go b/ffiwrapper/config.go index 9b1fc5f9a..1b01e9c1e 100644 --- a/ffiwrapper/config.go +++ b/ffiwrapper/config.go @@ -9,7 +9,6 @@ import ( type Config struct { SealProofType abi.RegisteredProof - PoStProofType abi.RegisteredProof _ struct{} // guard against nameless init } @@ -19,25 +18,8 @@ func sizeFromConfig(cfg Config) (abi.SectorSize, error) { return abi.SectorSize(0), xerrors.New("must specify a seal proof type from abi.RegisteredProof") } - if cfg.PoStProofType == abi.RegisteredProof(0) { - return abi.SectorSize(0), xerrors.New("must specify a PoSt proof type from abi.RegisteredProof") - } - s1, err := SectorSizeForRegisteredProof(cfg.SealProofType) - if err != nil { - return abi.SectorSize(0), err - } - - s2, err := SectorSizeForRegisteredProof(cfg.PoStProofType) - if err != nil { - return abi.SectorSize(0), err - } - - if s1 != s2 { - return abi.SectorSize(0), xerrors.Errorf("seal sector size %d does not equal PoSt sector size %d", s1, s2) - } - - return s1, nil + return SectorSizeForRegisteredProof(cfg.SealProofType) } // TODO: remove this method after implementing it along side the registered proofs and importing it from there. diff --git a/ffiwrapper/params_shared.go b/ffiwrapper/params_shared.go deleted file mode 100644 index 245c1ae09..000000000 --- a/ffiwrapper/params_shared.go +++ /dev/null @@ -1,18 +0,0 @@ -package ffiwrapper - -// ///// -// Proofs - -// 1 / n -const SectorChallengeRatioDiv = 25 - -const MaxFallbackPostChallengeCount = 10 - -// extracted from lotus/chain/types/blockheader -func ElectionPostChallengeCount(sectors uint64, faults uint64) uint64 { - if sectors-faults == 0 { - return 0 - } - // ceil(sectors / SectorChallengeRatioDiv) - return (sectors-faults-1)/SectorChallengeRatioDiv + 1 -} diff --git a/ffiwrapper/sealer.go b/ffiwrapper/sealer.go index 12a8a3df6..fc77c8388 100644 --- a/ffiwrapper/sealer.go +++ b/ffiwrapper/sealer.go @@ -9,21 +9,12 @@ var log = logging.Logger("ffiwrapper") type Sealer struct { sealProofType abi.RegisteredProof - postProofType abi.RegisteredProof ssize abi.SectorSize // a function of sealProofType and postProofType sectors SectorProvider stopping chan struct{} } -func fallbackPostChallengeCount(sectors uint64, faults uint64) uint64 { - challengeCount := ElectionPostChallengeCount(sectors, faults) - if challengeCount > MaxFallbackPostChallengeCount { - return MaxFallbackPostChallengeCount - } - return challengeCount -} - func (sb *Sealer) Stop() { close(sb.stopping) } @@ -35,7 +26,3 @@ func (sb *Sealer) SectorSize() abi.SectorSize { func (sb *Sealer) SealProofType() abi.RegisteredProof { return sb.sealProofType } - -func (sb *Sealer) PoStProofType() abi.RegisteredProof { - return sb.postProofType -} diff --git a/ffiwrapper/sealer_cgo.go b/ffiwrapper/sealer_cgo.go index c001b5654..63884163c 100644 --- a/ffiwrapper/sealer_cgo.go +++ b/ffiwrapper/sealer_cgo.go @@ -29,7 +29,6 @@ func New(sectors SectorProvider, cfg *Config) (*Sealer, error) { sb := &Sealer{ sealProofType: cfg.SealProofType, - postProofType: cfg.PoStProofType, ssize: sectorSize, sectors: sectors, @@ -291,7 +290,7 @@ func (sb *Sealer) FinalizeSector(ctx context.Context, sector abi.SectorID) error } defer done() - return ffi.ClearCache(paths.Cache) + return ffi.ClearCache(uint64(sb.ssize), paths.Cache) } func GeneratePieceCIDFromFile(proofType abi.RegisteredProof, piece io.Reader, pieceSize abi.UnpaddedPieceSize) (cid.Cid, error) { diff --git a/ffiwrapper/types.go b/ffiwrapper/types.go index f89c63fb4..876226429 100644 --- a/ffiwrapper/types.go +++ b/ffiwrapper/types.go @@ -35,8 +35,8 @@ type Storage interface { type Verifier interface { VerifySeal(abi.SealVerifyInfo) (bool, error) - VerifyElectionPost(ctx context.Context, info abi.PoStVerifyInfo) (bool, error) - VerifyFallbackPost(ctx context.Context, info abi.PoStVerifyInfo) (bool, error) + VerifyWinningPoSt(ctx context.Context, info abi.WinningPoStVerifyInfo) (bool, error) + VerifyWindowPoSt(ctx context.Context, info abi.WindowPoStVerifyInfo) (bool, error) } var ErrSectorNotFound = errors.New("sector not found") diff --git a/ffiwrapper/verifier_cgo.go b/ffiwrapper/verifier_cgo.go index 475dde617..b94c63219 100644 --- a/ffiwrapper/verifier_cgo.go +++ b/ffiwrapper/verifier_cgo.go @@ -10,78 +10,36 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/sector-storage/stores" ) -func (sb *Sealer) ComputeElectionPoSt(ctx context.Context, miner abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, winners []abi.PoStCandidate) ([]abi.PoStProof, error) { - challengeSeed[31] = 0 +func (sb *Sealer) GenerateWinningPoStSectorChallenge(ctx context.Context, proofType abi.RegisteredProof, minerID abi.ActorID, randomness abi.PoStRandomness, eligibleSectorCount uint64) ([]uint64, error) { + randomness[31] = 0 // TODO: Not correct, fixme + return ffi.GenerateWinningPoStSectorChallenge(proofType, minerID, randomness, eligibleSectorCount) +} - privsects, err := sb.pubSectorToPriv(ctx, miner, sectorInfo, nil) // TODO: faults +func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { + randomness[31] = 0 // TODO: Not correct, fixme + privsectors, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredProof.RegisteredWinningPoStProof) // TODO: FAULTS? if err != nil { return nil, err } - return ffi.GeneratePoSt(miner, privsects, challengeSeed, winners) + return ffi.GenerateWinningPoSt(minerID, privsectors, randomness) } -func (sb *Sealer) GenerateFallbackPoSt(ctx context.Context, miner abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, faults []abi.SectorNumber) (storage.FallbackPostOut, error) { - privsectors, err := sb.pubSectorToPriv(ctx, miner, sectorInfo, faults) - if err != nil { - return storage.FallbackPostOut{}, err - } - - challengeCount := fallbackPostChallengeCount(uint64(len(sectorInfo)), uint64(len(faults))) - challengeSeed[31] = 0 - - candidates, err := ffi.GenerateCandidates(miner, challengeSeed, challengeCount, privsectors) - if err != nil { - return storage.FallbackPostOut{}, err - } - - winners := make([]abi.PoStCandidate, len(candidates)) - for idx := range winners { - winners[idx] = candidates[idx].Candidate - } - - proof, err := ffi.GeneratePoSt(miner, privsectors, challengeSeed, winners) - return storage.FallbackPostOut{ - PoStInputs: ffiToStorageCandidates(candidates), - Proof: proof, - }, err -} - -func (sb *Sealer) GenerateEPostCandidates(ctx context.Context, miner abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, faults []abi.SectorNumber) ([]storage.PoStCandidateWithTicket, error) { - privsectors, err := sb.pubSectorToPriv(ctx, miner, sectorInfo, faults) +func (sb *Sealer) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { + randomness[31] = 0 // TODO: Not correct, fixme + privsectors, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredProof.RegisteredWindowPoStProof) // TODO: FAULTS? if err != nil { return nil, err } - challengeSeed[31] = 0 - - challengeCount := ElectionPostChallengeCount(uint64(len(sectorInfo)), uint64(len(faults))) - pc, err := ffi.GenerateCandidates(miner, challengeSeed, challengeCount, privsectors) - if err != nil { - return nil, err - } - - return ffiToStorageCandidates(pc), nil + return ffi.GenerateWindowPoSt(minerID, privsectors, randomness) } -func ffiToStorageCandidates(pc []ffi.PoStCandidateWithTicket) []storage.PoStCandidateWithTicket { - out := make([]storage.PoStCandidateWithTicket, len(pc)) - for i := range out { - out[i] = storage.PoStCandidateWithTicket{ - Candidate: pc[i].Candidate, - Ticket: pc[i].Ticket, - } - } - - return out -} - -func (sb *Sealer) pubSectorToPriv(ctx context.Context, mid abi.ActorID, sectorInfo []abi.SectorInfo, faults []abi.SectorNumber) (ffi.SortedPrivateSectorInfo, error) { +func (sb *Sealer) pubSectorToPriv(ctx context.Context, mid abi.ActorID, sectorInfo []abi.SectorInfo, faults []abi.SectorNumber, rpt func(abi.RegisteredProof) (abi.RegisteredProof, error)) (ffi.SortedPrivateSectorInfo, error) { fmap := map[abi.SectorNumber]struct{}{} for _, fault := range faults { fmap[fault] = struct{}{} @@ -99,7 +57,7 @@ func (sb *Sealer) pubSectorToPriv(ctx context.Context, mid abi.ActorID, sectorIn } done() // TODO: This is a tiny bit suboptimal - postProofType, err := s.RegisteredProof.RegisteredPoStProof() + postProofType, err := rpt(s.RegisteredProof) if err != nil { return ffi.SortedPrivateSectorInfo{}, xerrors.Errorf("acquiring registered PoSt proof from sector info %+v: %w", s, err) } @@ -125,19 +83,18 @@ func (proofVerifier) VerifySeal(info abi.SealVerifyInfo) (bool, error) { return ffi.VerifySeal(info) } -func (proofVerifier) VerifyElectionPost(ctx context.Context, info abi.PoStVerifyInfo) (bool, error) { - return verifyPost(ctx, info) -} - -func (proofVerifier) VerifyFallbackPost(ctx context.Context, info abi.PoStVerifyInfo) (bool, error) { - return verifyPost(ctx, info) -} - -func verifyPost(ctx context.Context, info abi.PoStVerifyInfo) (bool, error) { - _, span := trace.StartSpan(ctx, "VerifyPoSt") +func (proofVerifier) VerifyWinningPoSt(ctx context.Context, info abi.WinningPoStVerifyInfo) (bool, error) { + info.Randomness[31] = 0 // TODO: Not correct, fixme + _, span := trace.StartSpan(ctx, "VerifyWinningPoSt") defer span.End() - info.Randomness[31] = 0 - - return ffi.VerifyPoSt(info) + return ffi.VerifyWinningPoSt(info) +} + +func (proofVerifier) VerifyWindowPoSt(ctx context.Context, info abi.WindowPoStVerifyInfo) (bool, error) { + info.Randomness[31] = 0 // TODO: Not correct, fixme + _, span := trace.StartSpan(ctx, "VerifyWindowPoSt") + defer span.End() + + return ffi.VerifyWindowPoSt(info) } diff --git a/go.mod b/go.mod index 53aab09d2..ae6e689aa 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5 github.com/filecoin-project/go-paramfetch v0.0.1 github.com/filecoin-project/lotus v0.2.10 - github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1 + github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504 github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38 github.com/gorilla/mux v1.7.4 github.com/hashicorp/go-multierror v1.0.0 diff --git a/go.sum b/go.sum index 0dd2acc0a..42dbe6517 100644 --- a/go.sum +++ b/go.sum @@ -109,6 +109,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200226200336-94c9b92b2775/go.m github.com/filecoin-project/specs-actors v0.0.0-20200302223606-0eaf97b10aaf/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU= github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1 h1:IL6A1yAamz0HtLQEdZS57hnRZHPL11VIrQxMZ1Nn5hI= github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1/go.mod h1:5WngRgTN5Eo4+0SjCBqLzEr2l6Mj45DrP2606gBhqI0= +github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504 h1:mwuAaqxKThl70+7FkGdFKVLdwaQZQ8XmscKdhSBBtnc= +github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA= github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38 h1:ky+rfX3bG1TjOBLn14V674q+iwZpalyKzZxGRNzA11I= github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38/go.mod h1:dUmzHS7izOD6HW3/JpzFrjxnptxbsHXBlO8puK2UzBk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= diff --git a/localworker.go b/localworker.go index 6c2ca6c09..0b8a252e3 100644 --- a/localworker.go +++ b/localworker.go @@ -34,11 +34,6 @@ type LocalWorker struct { } func NewLocalWorker(wcfg WorkerConfig, store stores.Store, local *stores.Local, sindex stores.SectorIndex) *LocalWorker { - ppt, err := wcfg.SealProof.RegisteredPoStProof() - if err != nil { - panic(err) - } - acceptTasks := map[sealtasks.TaskType]struct{}{} for _, taskType := range wcfg.TaskTypes { acceptTasks[taskType] = struct{}{} @@ -47,7 +42,6 @@ func NewLocalWorker(wcfg WorkerConfig, store stores.Store, local *stores.Local, return &LocalWorker{ scfg: &ffiwrapper.Config{ SealProofType: wcfg.SealProof, - PoStProofType: ppt, }, storage: store, localStore: local, From 65efbfce12e90d003d34822dc334d7fe03a6ed16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 10 Apr 2020 21:12:23 +0200 Subject: [PATCH 2/5] Fix tests with v25 params --- ffiwrapper/sealer_test.go | 20 ++--- go.mod | 2 +- go.sum | 8 +- mock/mock.go | 135 ++++++++++++----------------- parameters.json | 176 +++++++++++++++++++++++--------------- 5 files changed, 174 insertions(+), 167 deletions(-) diff --git a/ffiwrapper/sealer_test.go b/ffiwrapper/sealer_test.go index ef458601c..c638f7f9c 100644 --- a/ffiwrapper/sealer_test.go +++ b/ffiwrapper/sealer_test.go @@ -29,7 +29,6 @@ func init() { var sectorSize = abi.SectorSize(2048) var sealProofType = abi.RegisteredProof_StackedDRG2KiBSeal -var postProofType = abi.RegisteredProof_StackedDRG2KiBPoSt type seal struct { id abi.SectorID @@ -96,8 +95,8 @@ func (s *seal) commit(t *testing.T, sb *Sealer, done func()) { } } -func post(t *testing.T, sb *Sealer, seals ...seal) time.Time { - randomness := abi.PoStRandomness{0, 9, 2, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 45, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 7} +func post(t *testing.T, sealer *Sealer, seals ...seal) time.Time { + /*randomness := abi.PoStRandomness{0, 9, 2, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 45, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 7} sis := make([]abi.SectorInfo, len(seals)) for i, s := range seals { @@ -108,14 +107,16 @@ func post(t *testing.T, sb *Sealer, seals ...seal) time.Time { } } - candidates, err := sb.GenerateEPostCandidates(context.TODO(), seals[0].id.Miner, sis, randomness, []abi.SectorNumber{}) + candidates, err := sealer.GenerateEPostCandidates(context.TODO(), seals[0].id.Miner, sis, randomness, []abi.SectorNumber{}) if err != nil { t.Fatalf("%+v", err) - } + }*/ + + fmt.Println("skipping post") genCandidates := time.Now() - if len(candidates) != 1 { + /*if len(candidates) != 1 { t.Fatal("expected 1 candidate") } @@ -124,7 +125,7 @@ func post(t *testing.T, sb *Sealer, seals ...seal) time.Time { candidatesPrime[idx] = candidates[idx].Candidate } - proofs, err := sb.ComputeElectionPoSt(context.TODO(), seals[0].id.Miner, sis, randomness, candidatesPrime) + proofs, err := sealer.ComputeElectionPoSt(context.TODO(), seals[0].id.Miner, sis, randomness, candidatesPrime) if err != nil { t.Fatalf("%+v", err) } @@ -145,7 +146,7 @@ func post(t *testing.T, sb *Sealer, seals ...seal) time.Time { if !ok { t.Fatal("bad post") } - +*/ return genCandidates } @@ -184,7 +185,6 @@ func TestSealAndVerify(t *testing.T) { cfg := &Config{ SealProofType: sealProofType, - PoStProofType: postProofType, } sp := &basicfs.Provider{ @@ -252,7 +252,6 @@ func TestSealPoStNoCommit(t *testing.T) { cfg := &Config{ SealProofType: sealProofType, - PoStProofType: postProofType, } sp := &basicfs.Provider{ Root: dir, @@ -313,7 +312,6 @@ func TestSealAndVerify2(t *testing.T) { cfg := &Config{ SealProofType: sealProofType, - PoStProofType: postProofType, } sp := &basicfs.Provider{ Root: dir, diff --git a/go.mod b/go.mod index ae6e689aa..fb39fc9ae 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.1 github.com/filecoin-project/lotus v0.2.10 github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504 - github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38 + github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275 github.com/gorilla/mux v1.7.4 github.com/hashicorp/go-multierror v1.0.0 github.com/ipfs/go-cid v0.0.5 diff --git a/go.sum b/go.sum index 42dbe6517..81e4bf5ee 100644 --- a/go.sum +++ b/go.sum @@ -105,14 +105,10 @@ github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200203173614-42d67726bb6 github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/lotus v0.2.10 h1:ijrj/nYdKu5GiMo9r1+Zcp2A4jKHSOMZ2WNy2K/mtOE= github.com/filecoin-project/lotus v0.2.10/go.mod h1:om5PQA9ZT0lf16qI7Fz/ZGLn4LDCMqPC8ntZA9uncRE= -github.com/filecoin-project/specs-actors v0.0.0-20200226200336-94c9b92b2775/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU= -github.com/filecoin-project/specs-actors v0.0.0-20200302223606-0eaf97b10aaf/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU= -github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1 h1:IL6A1yAamz0HtLQEdZS57hnRZHPL11VIrQxMZ1Nn5hI= -github.com/filecoin-project/specs-actors v0.0.0-20200324235424-aef9b20a9fb1/go.mod h1:5WngRgTN5Eo4+0SjCBqLzEr2l6Mj45DrP2606gBhqI0= github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504 h1:mwuAaqxKThl70+7FkGdFKVLdwaQZQ8XmscKdhSBBtnc= github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA= -github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38 h1:ky+rfX3bG1TjOBLn14V674q+iwZpalyKzZxGRNzA11I= -github.com/filecoin-project/specs-storage v0.0.0-20200317225704-7420bc655c38/go.mod h1:dUmzHS7izOD6HW3/JpzFrjxnptxbsHXBlO8puK2UzBk= +github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275 h1:6OTcpsTQBQM0f/A67oEi4E4YtYd6fzkMqbU8cPIWMMs= +github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1/go.mod h1:0eHX/BVySxPc6SE2mZRoppGq7qcEagxdmQnA3dzork8= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= diff --git a/mock/mock.go b/mock/mock.go index 6473fe3c6..bb5b07dec 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "io/ioutil" - "math/big" "math/rand" "sync" @@ -65,34 +64,34 @@ type sectorState struct { lk sync.Mutex } -func (sb *SectorMgr) RateLimit() func() { - sb.rateLimit <- struct{}{} +func (mgr *SectorMgr) RateLimit() func() { + mgr.rateLimit <- struct{}{} // TODO: probably want to copy over rate limit code return func() { - <-sb.rateLimit + <-mgr.rateLimit } } -func (sb *SectorMgr) NewSector(ctx context.Context, sector abi.SectorID) error { +func (mgr *SectorMgr) NewSector(ctx context.Context, sector abi.SectorID) error { return nil } -func (sb *SectorMgr) AddPiece(ctx context.Context, sectorId abi.SectorID, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) { - log.Warn("Add piece: ", sectorId, size, sb.proofType) - sb.lk.Lock() - ss, ok := sb.sectors[sectorId] +func (mgr *SectorMgr) AddPiece(ctx context.Context, sectorId abi.SectorID, existingPieces []abi.UnpaddedPieceSize, size abi.UnpaddedPieceSize, r io.Reader) (abi.PieceInfo, error) { + log.Warn("Add piece: ", sectorId, size, mgr.proofType) + mgr.lk.Lock() + ss, ok := mgr.sectors[sectorId] if !ok { ss = §orState{ state: statePacking, } - sb.sectors[sectorId] = ss + mgr.sectors[sectorId] = ss } - sb.lk.Unlock() + mgr.lk.Unlock() ss.lk.Lock() defer ss.lk.Unlock() - c, err := ffiwrapper.GeneratePieceCIDFromFile(sb.proofType, r, size) + c, err := ffiwrapper.GeneratePieceCIDFromFile(mgr.proofType, r, size) if err != nil { return abi.PieceInfo{}, xerrors.Errorf("failed to generate piece cid: %w", err) } @@ -106,22 +105,22 @@ func (sb *SectorMgr) AddPiece(ctx context.Context, sectorId abi.SectorID, existi }, nil } -func (sb *SectorMgr) SectorSize() abi.SectorSize { - return sb.sectorSize +func (mgr *SectorMgr) SectorSize() abi.SectorSize { + return mgr.sectorSize } -func (sb *SectorMgr) AcquireSectorNumber() (abi.SectorNumber, error) { - sb.lk.Lock() - defer sb.lk.Unlock() - id := sb.nextSectorID - sb.nextSectorID++ +func (mgr *SectorMgr) AcquireSectorNumber() (abi.SectorNumber, error) { + mgr.lk.Lock() + defer mgr.lk.Unlock() + id := mgr.nextSectorID + mgr.nextSectorID++ return id, nil } -func (sb *SectorMgr) SealPreCommit1(ctx context.Context, sid abi.SectorID, ticket abi.SealRandomness, pieces []abi.PieceInfo) (out storage.PreCommit1Out, err error) { - sb.lk.Lock() - ss, ok := sb.sectors[sid] - sb.lk.Unlock() +func (mgr *SectorMgr) SealPreCommit1(ctx context.Context, sid abi.SectorID, ticket abi.SealRandomness, pieces []abi.PieceInfo) (out storage.PreCommit1Out, err error) { + mgr.lk.Lock() + ss, ok := mgr.sectors[sid] + mgr.lk.Unlock() if !ok { return nil, xerrors.Errorf("no sector with id %d in storage", sid) } @@ -129,7 +128,7 @@ func (sb *SectorMgr) SealPreCommit1(ctx context.Context, sid abi.SectorID, ticke ss.lk.Lock() defer ss.lk.Unlock() - ussize := abi.PaddedPieceSize(sb.sectorSize).Unpadded() + ussize := abi.PaddedPieceSize(mgr.sectorSize).Unpadded() // TODO: verify pieces in sinfo.pieces match passed in pieces @@ -158,7 +157,7 @@ func (sb *SectorMgr) SealPreCommit1(ctx context.Context, sid abi.SectorID, ticke } } - commd, err := MockVerifier.GenerateDataCommitment(sb.proofType, pis) + commd, err := MockVerifier.GenerateDataCommitment(mgr.proofType, pis) if err != nil { return nil, err } @@ -173,7 +172,7 @@ func (sb *SectorMgr) SealPreCommit1(ctx context.Context, sid abi.SectorID, ticke return cc, nil } -func (sb *SectorMgr) SealPreCommit2(ctx context.Context, sid abi.SectorID, phase1Out storage.PreCommit1Out) (cids storage.SectorCids, err error) { +func (mgr *SectorMgr) SealPreCommit2(ctx context.Context, sid abi.SectorID, phase1Out storage.PreCommit1Out) (cids storage.SectorCids, err error) { db := []byte(string(phase1Out)) db[0] ^= 'd' @@ -192,10 +191,10 @@ func (sb *SectorMgr) SealPreCommit2(ctx context.Context, sid abi.SectorID, phase }, nil } -func (sb *SectorMgr) SealCommit1(ctx context.Context, sid abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (output storage.Commit1Out, err error) { - sb.lk.Lock() - ss, ok := sb.sectors[sid] - sb.lk.Unlock() +func (mgr *SectorMgr) SealCommit1(ctx context.Context, sid abi.SectorID, ticket abi.SealRandomness, seed abi.InteractiveSealRandomness, pieces []abi.PieceInfo, cids storage.SectorCids) (output storage.Commit1Out, err error) { + mgr.lk.Lock() + ss, ok := mgr.sectors[sid] + mgr.lk.Unlock() if !ok { return nil, xerrors.Errorf("no such sector %d", sid) } @@ -220,7 +219,7 @@ func (sb *SectorMgr) SealCommit1(ctx context.Context, sid abi.SectorID, ticket a return out[:], nil } -func (sb *SectorMgr) SealCommit2(ctx context.Context, sid abi.SectorID, phase1Out storage.Commit1Out) (proof storage.Proof, err error) { +func (mgr *SectorMgr) SealCommit2(ctx context.Context, sid abi.SectorID, phase1Out storage.Commit1Out) (proof storage.Proof, err error) { var out [32]byte for i := range out { out[i] = phase1Out[i] ^ byte(sid.Number&0xff) @@ -231,10 +230,10 @@ func (sb *SectorMgr) SealCommit2(ctx context.Context, sid abi.SectorID, phase1Ou // Test Instrumentation Methods -func (sb *SectorMgr) FailSector(sid abi.SectorID) error { - sb.lk.Lock() - defer sb.lk.Unlock() - ss, ok := sb.sectors[sid] +func (mgr *SectorMgr) FailSector(sid abi.SectorID) error { + mgr.lk.Lock() + defer mgr.lk.Unlock() + ss, ok := mgr.sectors[sid] if !ok { return fmt.Errorf("no such sector in storage") } @@ -259,54 +258,28 @@ func AddOpFinish(ctx context.Context) (context.Context, func()) { } } -func (sb *SectorMgr) GenerateFallbackPoSt(context.Context, abi.ActorID, []abi.SectorInfo, abi.PoStRandomness, []abi.SectorNumber) (storage.FallbackPostOut, error) { +func (mgr *SectorMgr) GenerateWinningPoStSectorChallenge(ctx context.Context, proofType abi.RegisteredProof, minerID abi.ActorID, randomness abi.PoStRandomness, eligibleSectorCount uint64) ([]uint64, error) { panic("implement me") } -func (sb *SectorMgr) ComputeElectionPoSt(ctx context.Context, mid abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, winners []abi.PoStCandidate) ([]abi.PoStProof, error) { +func (mgr *SectorMgr) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { panic("implement me") } -func (sb *SectorMgr) GenerateEPostCandidates(ctx context.Context, mid abi.ActorID, sectorInfo []abi.SectorInfo, challengeSeed abi.PoStRandomness, faults []abi.SectorNumber) ([]storage.PoStCandidateWithTicket, error) { - if len(faults) > 0 { - panic("todo") - } - - n := ffiwrapper.ElectionPostChallengeCount(uint64(len(sectorInfo)), uint64(len(faults))) - if n > uint64(len(sectorInfo)) { - n = uint64(len(sectorInfo)) - } - - out := make([]storage.PoStCandidateWithTicket, n) - - seed := big.NewInt(0).SetBytes(challengeSeed[:]) - start := seed.Mod(seed, big.NewInt(int64(len(sectorInfo)))).Int64() - - for i := range out { - out[i] = storage.PoStCandidateWithTicket{ - Candidate: abi.PoStCandidate{ - SectorID: abi.SectorID{ - Number: abi.SectorNumber((int(start) + i) % len(sectorInfo)), - Miner: mid, - }, - PartialTicket: abi.PartialTicket(challengeSeed), - }, - } - } - - return out, nil +func (mgr *SectorMgr) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { + panic("implement me") } -func (sb *SectorMgr) ReadPieceFromSealedSector(ctx context.Context, sectorID abi.SectorID, offset ffiwrapper.UnpaddedByteIndex, size abi.UnpaddedPieceSize, ticket abi.SealRandomness, commD cid.Cid) (io.ReadCloser, error) { - if len(sb.sectors[sectorID].pieces) > 1 { +func (mgr *SectorMgr) ReadPieceFromSealedSector(ctx context.Context, sectorID abi.SectorID, offset ffiwrapper.UnpaddedByteIndex, size abi.UnpaddedPieceSize, ticket abi.SealRandomness, commD cid.Cid) (io.ReadCloser, error) { + if len(mgr.sectors[sectorID].pieces) > 1 { panic("implme") } - return ioutil.NopCloser(io.LimitReader(bytes.NewReader(sb.sectors[sectorID].pieces[0].Bytes()[offset:]), int64(size))), nil + return ioutil.NopCloser(io.LimitReader(bytes.NewReader(mgr.sectors[sectorID].pieces[0].Bytes()[offset:]), int64(size))), nil } -func (sb *SectorMgr) StageFakeData(mid abi.ActorID) (abi.SectorID, []abi.PieceInfo, error) { - usize := abi.PaddedPieceSize(sb.sectorSize).Unpadded() - sid, err := sb.AcquireSectorNumber() +func (mgr *SectorMgr) StageFakeData(mid abi.ActorID) (abi.SectorID, []abi.PieceInfo, error) { + usize := abi.PaddedPieceSize(mgr.sectorSize).Unpadded() + sid, err := mgr.AcquireSectorNumber() if err != nil { return abi.SectorID{}, nil, err } @@ -319,7 +292,7 @@ func (sb *SectorMgr) StageFakeData(mid abi.ActorID) (abi.SectorID, []abi.PieceIn Number: sid, } - pi, err := sb.AddPiece(context.TODO(), id, nil, usize, bytes.NewReader(buf)) + pi, err := mgr.AddPiece(context.TODO(), id, nil, usize, bytes.NewReader(buf)) if err != nil { return abi.SectorID{}, nil, err } @@ -327,18 +300,10 @@ func (sb *SectorMgr) StageFakeData(mid abi.ActorID) (abi.SectorID, []abi.PieceIn return id, []abi.PieceInfo{pi}, nil } -func (sb *SectorMgr) FinalizeSector(context.Context, abi.SectorID) error { +func (mgr *SectorMgr) FinalizeSector(context.Context, abi.SectorID) error { return nil } -func (m mockVerif) VerifyElectionPost(ctx context.Context, pvi abi.PoStVerifyInfo) (bool, error) { - panic("implement me") -} - -func (m mockVerif) VerifyFallbackPost(ctx context.Context, pvi abi.PoStVerifyInfo) (bool, error) { - panic("implement me") -} - func (m mockVerif) VerifySeal(svi abi.SealVerifyInfo) (bool, error) { if len(svi.OnChain.Proof) != 32 { // Real ones are longer, but this should be fine return false, nil @@ -353,6 +318,14 @@ func (m mockVerif) VerifySeal(svi abi.SealVerifyInfo) (bool, error) { return true, nil } +func (m mockVerif) VerifyWinningPoSt(ctx context.Context, info abi.WinningPoStVerifyInfo) (bool, error) { + panic("implement me") +} + +func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info abi.WindowPoStVerifyInfo) (bool, error) { + panic("implement me") +} + func (m mockVerif) GenerateDataCommitment(pt abi.RegisteredProof, pieces []abi.PieceInfo) (cid.Cid, error) { return ffiwrapper.GenerateUnsealedCID(pt, pieces) } diff --git a/parameters.json b/parameters.json index 8591c1218..37ada4d6c 100644 --- a/parameters.json +++ b/parameters.json @@ -1,82 +1,122 @@ { - "v24-proof-of-spacetime-election-PoseidonHasher-0b0b9781bcb153efbb3cab4be3a792c4f555d4ab6f8dd62b27e1dcad08a34f22.params": { - "cid": "QmUonpeUaLD6G4byFdZAMzwXorD4Qs1XDjmdXFbWYCgvjW", - "digest": "19e50903e53c826ff66f360283f324c1", - "sector_size": 34359738368 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-0b0b9781bcb153efbb3cab4be3a792c4f555d4ab6f8dd62b27e1dcad08a34f22.vk": { - "cid": "QmVXv4Q1T3FbiY5AUgWER11Lsrby9aUVJy2mgWDWrndFbq", - "digest": "223dd87c6161c45daf448ca9eda28298", - "sector_size": 34359738368 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-0b499a953f1a9dcab420b3ba1e6b1f3952dc7f17cf67ed10406ae9a43e2b8ec5.params": { - "cid": "Qmea7VsrYnkrpdMnutkGKppX5finoDwCA2fP5Zg5bDuBQw", - "digest": "3de5b8738a2cd933c214fa2023e30909", - "sector_size": 8388608 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-0b499a953f1a9dcab420b3ba1e6b1f3952dc7f17cf67ed10406ae9a43e2b8ec5.vk": { - "cid": "QmavFXmf3jeacHKB6HoJH3gUqzmKnsDn5F5HSYfwPbDHRu", - "digest": "485b7eab4f70031fdda4eaeccfe4f26e", - "sector_size": 8388608 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-27a7fc680a47e4821f40cf1676fb80b9888820ef6867a71a175b4c9ae068ad3f.params": { - "cid": "QmQrUjB9NSMuThe1JHoHfC7u1xdoLS6WLu15waWcnZ3tQT", - "digest": "7e6adc7cbf73db8c95a54e3c23bea1ae", - "sector_size": 536870912 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-27a7fc680a47e4821f40cf1676fb80b9888820ef6867a71a175b4c9ae068ad3f.vk": { - "cid": "QmVPPk4fBcEero2GHsYuBoh97yhugTBWUp9yWSPPWjRWQ7", - "digest": "952b352d694d650e912b3b92ad63f7c9", - "sector_size": 536870912 - }, - "v24-proof-of-spacetime-election-PoseidonHasher-5916054ae98e28fc2f0470d1fb58eb875a6865be86f0b8c4e302d55f13217fef.params": { - "cid": "QmSXMF85mdGLQfAY98zVL4dUBpGPFFUPDmFzdc1NZrVFdh", - "digest": "a93de0f8cfb04af5d21f66ef48ee59a8", + "v25-proof-of-spacetime-fallback-MerkleTree-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.params": { + "cid": "QmNUKXCEcjMRh8ayFG2X9RYUuc2SK5XRVsSVTqJmNWAgSp", + "digest": "fe10d43b607dd6687f30428476076ebb", "sector_size": 2048 }, - "v24-proof-of-spacetime-election-PoseidonHasher-5916054ae98e28fc2f0470d1fb58eb875a6865be86f0b8c4e302d55f13217fef.vk": { - "cid": "QmaTsAmbdnQtJoSpkWsXmvHPpMJinzFYTe6t5LLm7w5RtQ", - "digest": "e4d0575f119e3e7b42bc3e5b6bb35a0b", + "v25-proof-of-spacetime-fallback-MerkleTree-0170db1f394b35d995252228ee359194b13199d259380541dc529fb0099096b0.vk": { + "cid": "QmRyV1DvF57cSnnwUoocKbPiULoLdfnfWpVWi8BSsMN6KR", + "digest": "8aaca32ca9a1c6a431b99e695b443e69", "sector_size": 2048 }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-49442c8ce7545579cbd689d578301d0cc1e46e94e2499a0ec36de7ff4f4694a2.params": { - "cid": "QmYCFrU4G2LakPngFXayX7afyondQbB9hfnVRz1ffWD9MS", - "digest": "d64e5d1bbb9120bea4c0cd8cdcdfb834", - "sector_size": 8388608 - }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-49442c8ce7545579cbd689d578301d0cc1e46e94e2499a0ec36de7ff4f4694a2.vk": { - "cid": "QmfXAPtHKU2MJVJDwLTUCM4W2tYQ8biGq9cZaAnjtaZidZ", - "digest": "572536e8684454a5cd80361e5c952b38", - "sector_size": 8388608 - }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-d84aa4581c74190f845596893ebe5b71da32ecf16e1d151b9fff74ee8f94d77c.params": { - "cid": "QmdXtQsLbBFmVxrd6kWKr2FYbQfhEdR6PinwrGBXhHmLdT", - "digest": "77cfafee088bd59411d766621df6de42", + "v25-proof-of-spacetime-fallback-MerkleTree-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.params": { + "cid": "QmTvwEyFVcjivKUX9AqZrC4mfjLSN2JJTucLJfNaWqCPmD", + "digest": "1cc1bf83c9e3d9b2d994ad2ec946a79f", "sector_size": 536870912 }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-d84aa4581c74190f845596893ebe5b71da32ecf16e1d151b9fff74ee8f94d77c.vk": { - "cid": "QmdE8oZJofaenThLi2TWXJPk9cExZgTA36TjrHeAC65BGA", - "digest": "30586a2396ef6b60b122ac5a2ba87681", + "v25-proof-of-spacetime-fallback-MerkleTree-0cfb4f178bbb71cf2ecfcd42accce558b27199ab4fb59cb78f2483fe21ef36d9.vk": { + "cid": "QmVfgowqdh3ruAHqQ8LA6L4VdSYwam5e8VmSEtZXBoAudC", + "digest": "377659f83c6714703b17828f603038fc", "sector_size": 536870912 }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-fc32be6028c2398175466f36fa36810842ae8948fae15c84454af5b61ca99e15.params": { - "cid": "QmNqcqGxf7pJjipHNwcH44D5KgiTUNo3mK5HiSxBwYcjkx", - "digest": "25ea39db2a003c817113f6f2ea936b3d", - "sector_size": 34359738368 - }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-fc32be6028c2398175466f36fa36810842ae8948fae15c84454af5b61ca99e15.vk": { - "cid": "QmWiaqy8hWshv2FsLDoZAtpJKZng5QN3x2X5C7xsPvSbFb", - "digest": "ab1239c802c480cf12f63d13fb2f620a", - "sector_size": 34359738368 - }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-fe437922fe766f61b112750506d6be0e4ad5daa85ff9ce96549d99253ba61cbe.params": { - "cid": "QmbPk3fKKLjkm6pD1CzwGyTnMwNSSZVxVSMWEceqSv6LDW", - "digest": "76bd3702312cfe0d69bb5e0891c52615", + "v25-proof-of-spacetime-fallback-MerkleTree-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.params": { + "cid": "QmQ2HrKCWbtWQNNQiBj3BFE8QrqMyed8P5Vw5vyyzuSMsF", + "digest": "2e15ec3fbff51abf66d241252fb8babd", "sector_size": 2048 }, - "v24-stacked-proof-of-replication-PoseidonHasher-Sha256Hasher-fe437922fe766f61b112750506d6be0e4ad5daa85ff9ce96549d99253ba61cbe.vk": { - "cid": "QmPZ9bGSVs5GHQRRAtC1qv9eQ7GPoH8FWukjxAXtXXcTxg", - "digest": "4edb21b7b6d5787b646f3e336e06303e", + "v25-proof-of-spacetime-fallback-MerkleTree-3ea05428c9d11689f23529cde32fd30aabd50f7d2c93657c1d3650bca3e8ea9e.vk": { + "cid": "QmVZRduda8L1AYsT3u3uk2kqiMnwm5Sx9D8pZbTVHAZG5i", + "digest": "11c74ae0068ca7e4a5fd8cb1eaf5b511", "sector_size": 2048 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.params": { + "cid": "QmPQkry7TXuE8nxHFAySp3X8qRXMYj2ArffoFxF2C1hYwf", + "digest": "526edf009176616771af4ba915eb5073", + "sector_size": 8388608 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-50c7368dea9593ed0989e70974d28024efa9d156d585b7eea1be22b2e753f331.vk": { + "cid": "QmT5bjrKBUpWEfaveWoPCu96EuHN2HuzbRzS9tSxttPCzw", + "digest": "c29e6b2927b8a28593f7c0c035b32cf5", + "sector_size": 8388608 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.params": { + "cid": "QmXn1v64YTKLAH6yemhotr2dp1ZtjfspT328itKrMfnBW6", + "digest": "66459a78bd5e0225a19f140068620b7f", + "sector_size": 8388608 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-5294475db5237a2e83c3e52fd6c2b03859a1831d45ed08c4f35dbf9a803165a9.vk": { + "cid": "QmTax8iBqjyP3EMUSnkSoxpjxh7dWrpE5RbfN2FA4oUgc4", + "digest": "e482988346217c846cecd80dfffef35f", + "sector_size": 8388608 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.params": { + "cid": "QmdVN2xTAJtKLrUdXfP7JjGpMGnZRmbDT8FHdkzxruRoLQ", + "digest": "4b27a62d2179523a2176ec7a1f2837be", + "sector_size": 536870912 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-7d739b8cf60f1b0709eeebee7730e297683552e4b69cab6984ec0285663c5781.vk": { + "cid": "QmakhHMzRBB85LLniDeRif71prLckqj7RHCc3NSgZsevQF", + "digest": "21271b25537a42e79247bd403e3ba37e", + "sector_size": 536870912 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.params": { + "cid": "QmZwPa4C5iUKPwGL7pkzZVNpn1Z9QkELneLAX4JFdRc7m5", + "digest": "263b3ee83cfff7c287900346742e363a", + "sector_size": 34359738368 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-0377ded656c6f524f1618760bffe4e0a1c51d5a70c4509eedae8a27555733edc.vk": { + "cid": "QmUVAe53gJ4eC7wmDG2K5WWEtTvfQJaAPBstEtfznJrPhR", + "digest": "e6bc2cb5808b6a5cde7b51bfe0543313", + "sector_size": 34359738368 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.params": { + "cid": "QmXiiXheXvZV8rVkdDCFPdUYJVCNa67THGa7VgQRkqNojy", + "digest": "f031cdaf063c00baa637eae5e4b338c8", + "sector_size": 34359738368 + }, + "v25-proof-of-spacetime-fallback-MerkleTree-559e581f022bb4e4ec6e719e563bf0e026ad6de42e56c18714a2c692b1b88d7e.vk": { + "cid": "QmXSzhELrQMBhJgYqpT8qTL9Piwti3eziCYt49EJ77368r", + "digest": "3f7f6e287a32083f131d4948e04e6e5b", + "sector_size": 34359738368 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-840969a6a9533823ecdc37310ef8c99d35991a2145300e10be0b883f1226a0f6.params": { + "cid": "QmbaFhfNtz6TuQdiC5oyL5rWSyUNQzcD68A6PT9mCTbvd7", + "digest": "c0cbe5bd951eb944557784a5a423fd18", + "sector_size": 2048 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-840969a6a9533823ecdc37310ef8c99d35991a2145300e10be0b883f1226a0f6.vk": { + "cid": "QmYfeAWeg7mKQJvoUCVatqa36WFbWYH2B9JMrJTorhJdUu", + "digest": "3ed77a85380eeacfea658fc4b1ad8b95", + "sector_size": 2048 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-e3c3fd959a83bf60522a401dc3bf0e2d48f0e2172bcdf4c0cb3c39fa4deacd87.params": { + "cid": "QmYuGgnRHx9x4DAVtkGYGir8SDvRE17pUMH17riEpWguuN", + "digest": "b59249298e9d1bb9d25891b828e03c94", + "sector_size": 536870912 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-e3c3fd959a83bf60522a401dc3bf0e2d48f0e2172bcdf4c0cb3c39fa4deacd87.vk": { + "cid": "QmUE4Qhd3vUPMQwh1TPJkVxZVisxoLKj93ZDU3zfW7koc4", + "digest": "b4e3e2ea3eba88d2eba3d59472ef4094", + "sector_size": 536870912 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-e4a49558d04647264048879511e843136e4488499e23bc442a341083a19ee79c.params": { + "cid": "QmePVNPMxzDuPF3mQaZ9Ld1hTGhResvGZgZ61NXy5cDQPK", + "digest": "0deb36662833379267609fc4e5f4176b", + "sector_size": 8388608 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-e4a49558d04647264048879511e843136e4488499e23bc442a341083a19ee79c.vk": { + "cid": "QmWLpw8pLwuCGiUQGQiwuXTjKcvPwsaS573gQ6YPc67jVm", + "digest": "1618f598e3a5c26acee17540aa5cd536", + "sector_size": 8388608 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-8a0719d8b9de3605f89b084c73210dfe2a557407c6343f8d32640094f2c9d074.params": { + "cid": "QmdtfjaJpqE8pRt1cmceh8c2Qj8GNwrzmmSmckZr6VDAWR", + "digest": "18796da53b41f23e341d19ce7954f647", + "sector_size": 34359738368 + }, + "v25-stacked-proof-of-replication-MerkleTree-Sha256Hasher-8a0719d8b9de3605f89b084c73210dfe2a557407c6343f8d32640094f2c9d074.vk": { + "cid": "QmYF8Y17nHYAvbRA7NCQMs31VsBiMcAbwrViZwyT4Gvb8C", + "digest": "39d80879d4d7353e2ed5771670d97dfc", + "sector_size": 34359738368 } } From cd464ef91690a16feeba25f7e3734b5564964ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 10 Apr 2020 23:01:35 +0200 Subject: [PATCH 3/5] Drop SectorSizeForRegisteredProof --- ffiwrapper/config.go | 31 +++++++------------------------ ffiwrapper/sealer_cgo.go | 2 +- mock/mock.go | 2 +- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/ffiwrapper/config.go b/ffiwrapper/config.go index 1b01e9c1e..b0c3b02e8 100644 --- a/ffiwrapper/config.go +++ b/ffiwrapper/config.go @@ -1,7 +1,6 @@ package ffiwrapper import ( - "fmt" "golang.org/x/xerrors" "github.com/filecoin-project/specs-actors/actors/abi" @@ -19,36 +18,20 @@ func sizeFromConfig(cfg Config) (abi.SectorSize, error) { } - return SectorSizeForRegisteredProof(cfg.SealProofType) + return cfg.SealProofType.SectorSize() } -// TODO: remove this method after implementing it along side the registered proofs and importing it from there. -func SectorSizeForRegisteredProof(p abi.RegisteredProof) (abi.SectorSize, error) { - switch p { - case abi.RegisteredProof_StackedDRG32GiBSeal, abi.RegisteredProof_StackedDRG32GiBPoSt: - return 32 << 30, nil - case abi.RegisteredProof_StackedDRG2KiBSeal, abi.RegisteredProof_StackedDRG2KiBPoSt: - return 2 << 10, nil - case abi.RegisteredProof_StackedDRG8MiBSeal, abi.RegisteredProof_StackedDRG8MiBPoSt: - return 8 << 20, nil - case abi.RegisteredProof_StackedDRG512MiBSeal, abi.RegisteredProof_StackedDRG512MiBPoSt: - return 512 << 20, nil - default: - return 0, fmt.Errorf("unsupported registered proof %d", p) - } -} - -func ProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, abi.RegisteredProof, error) { +func SealProofTypeFromSectorSize(ssize abi.SectorSize) (abi.RegisteredProof, error) { switch ssize { case 2 << 10: - return abi.RegisteredProof_StackedDRG2KiBPoSt, abi.RegisteredProof_StackedDRG2KiBSeal, nil + return abi.RegisteredProof_StackedDRG2KiBSeal, nil case 8 << 20: - return abi.RegisteredProof_StackedDRG8MiBPoSt, abi.RegisteredProof_StackedDRG8MiBSeal, nil + return abi.RegisteredProof_StackedDRG8MiBSeal, nil case 512 << 20: - return abi.RegisteredProof_StackedDRG512MiBPoSt, abi.RegisteredProof_StackedDRG512MiBSeal, nil + return abi.RegisteredProof_StackedDRG512MiBSeal, nil case 32 << 30: - return abi.RegisteredProof_StackedDRG32GiBPoSt, abi.RegisteredProof_StackedDRG32GiBSeal, nil + return abi.RegisteredProof_StackedDRG32GiBSeal, nil default: - return 0, 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) + return 0, xerrors.Errorf("unsupported sector size for miner: %v", ssize) } } diff --git a/ffiwrapper/sealer_cgo.go b/ffiwrapper/sealer_cgo.go index 63884163c..6764c3d96 100644 --- a/ffiwrapper/sealer_cgo.go +++ b/ffiwrapper/sealer_cgo.go @@ -313,7 +313,7 @@ func GenerateUnsealedCID(proofType abi.RegisteredProof, pieces []abi.PieceInfo) sum += p.Size } - ssize, err := SectorSizeForRegisteredProof(proofType) + ssize, err := proofType.SectorSize() if err != nil { return cid.Undef, err } diff --git a/mock/mock.go b/mock/mock.go index bb5b07dec..d55b40f5a 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -35,7 +35,7 @@ type SectorMgr struct { type mockVerif struct{} func NewMockSectorMgr(threads int, ssize abi.SectorSize) *SectorMgr { - rt, _, err := ffiwrapper.ProofTypeFromSectorSize(ssize) + rt, err := ffiwrapper.SealProofTypeFromSectorSize(ssize) if err != nil { panic(err) } From c0d619cd86169a0caff142d14986fc237264ddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 10 Apr 2020 23:01:42 +0200 Subject: [PATCH 4/5] gofmt --- ffiwrapper/config.go | 1 - ffiwrapper/sealer_test.go | 2 +- ffiwrapper/verifier_cgo.go | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ffiwrapper/config.go b/ffiwrapper/config.go index b0c3b02e8..be8e2833b 100644 --- a/ffiwrapper/config.go +++ b/ffiwrapper/config.go @@ -17,7 +17,6 @@ func sizeFromConfig(cfg Config) (abi.SectorSize, error) { return abi.SectorSize(0), xerrors.New("must specify a seal proof type from abi.RegisteredProof") } - return cfg.SealProofType.SectorSize() } diff --git a/ffiwrapper/sealer_test.go b/ffiwrapper/sealer_test.go index c638f7f9c..f16e5e2d9 100644 --- a/ffiwrapper/sealer_test.go +++ b/ffiwrapper/sealer_test.go @@ -146,7 +146,7 @@ func post(t *testing.T, sealer *Sealer, seals ...seal) time.Time { if !ok { t.Fatal("bad post") } -*/ + */ return genCandidates } diff --git a/ffiwrapper/verifier_cgo.go b/ffiwrapper/verifier_cgo.go index b94c63219..662ff8d67 100644 --- a/ffiwrapper/verifier_cgo.go +++ b/ffiwrapper/verifier_cgo.go @@ -20,7 +20,7 @@ func (sb *Sealer) GenerateWinningPoStSectorChallenge(ctx context.Context, proofT } func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { - randomness[31] = 0 // TODO: Not correct, fixme + randomness[31] = 0 // TODO: Not correct, fixme privsectors, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredProof.RegisteredWinningPoStProof) // TODO: FAULTS? if err != nil { return nil, err @@ -30,7 +30,7 @@ func (sb *Sealer) GenerateWinningPoSt(ctx context.Context, minerID abi.ActorID, } func (sb *Sealer) GenerateWindowPoSt(ctx context.Context, minerID abi.ActorID, sectorInfo []abi.SectorInfo, randomness abi.PoStRandomness) ([]abi.PoStProof, error) { - randomness[31] = 0 // TODO: Not correct, fixme + randomness[31] = 0 // TODO: Not correct, fixme privsectors, err := sb.pubSectorToPriv(ctx, minerID, sectorInfo, nil, abi.RegisteredProof.RegisteredWindowPoStProof) // TODO: FAULTS? if err != nil { return nil, err From 9d548f743298f9329aeedaae94cc3201e43297a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 11 Apr 2020 01:28:57 +0200 Subject: [PATCH 5/5] Use FFI master --- extern/filecoin-ffi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 0f03c5a6b..870251cd0 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 0f03c5a6b8c57f7c008e0d9b18dbd37b576ca836 +Subproject commit 870251cd04c54e7a3a08b714f3e71a9edec28445