From 871c30d2a04b3bd4581ec4b0e545250cd41ef27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 26 Nov 2019 16:15:32 +0100 Subject: [PATCH] WIP trying to get election post to compute --- build/bootstrap/bootstrappers.pi | 1 - build/bootstrap/root.pi | 1 - build/params.go | 3 +- cmd/lotus-seed/main.go | 13 ++++- lib/sectorbuilder/sectorbuilder.go | 2 +- lib/sectorbuilder/sectorbuilder_test.go | 68 ++++++++++++++++++++++++- miner/miner.go | 2 +- storage/miner.go | 2 +- storage/sector_states.go | 2 +- 9 files changed, 84 insertions(+), 10 deletions(-) delete mode 100644 build/bootstrap/bootstrappers.pi delete mode 100644 build/bootstrap/root.pi diff --git a/build/bootstrap/bootstrappers.pi b/build/bootstrap/bootstrappers.pi deleted file mode 100644 index 27abfeb3f..000000000 --- a/build/bootstrap/bootstrappers.pi +++ /dev/null @@ -1 +0,0 @@ -/ip4/147.75.80.17/tcp/1347/p2p/12D3KooWFCkQdiJEMBVA6RrWq22ZXVFfM41YX8soQ5QVvNFjMJT8 diff --git a/build/bootstrap/root.pi b/build/bootstrap/root.pi deleted file mode 100644 index af18e8d88..000000000 --- a/build/bootstrap/root.pi +++ /dev/null @@ -1 +0,0 @@ -/ip4/147.75.80.29/tcp/1347/p2p/12D3KooWSw9h3e6YrYZfRWDcir8qMV7ctZG9VmtXwSaP2ntsKXYf diff --git a/build/params.go b/build/params.go index 63b6ef95f..d316d8b5e 100644 --- a/build/params.go +++ b/build/params.go @@ -90,8 +90,7 @@ const SectorChallengeRatioDiv = 25 const EcRandomnessLookback = 300 const FallbackPoStBegin = 1000 -const SlashablePowerDelay = 2000 - +const SlashablePowerDelay = 2000 const PowerCollateralProportion = 5 const PerCapitaCollateralProportion = 1 diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index cb011a42b..c84761831 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -137,7 +137,7 @@ var preSealCmd = &cli.Command{ pco, err := sb.SealPreCommit(i, ticket, []sectorbuilder.PublicPieceInfo{pi}) if err != nil { - return err + return xerrors.Errorf("commit: %w", err) } sealedSectors = append(sealedSectors, genesis.PreSeal{ @@ -145,6 +145,17 @@ var preSealCmd = &cli.Command{ CommD: pco.CommD, SectorID: i, }) + + srand := sha256.Sum256([]byte(c.String("seed-preimage"))) + seed := sectorbuilder.SealSeed{ + TicketBytes: srand, + } + + _, err = sb.SealCommit(i, ticket, seed, []sectorbuilder.PublicPieceInfo{pi}, pco) + if err != nil { + return xerrors.Errorf("commit: %w", err) + } + } output := map[string]genesis.GenesisMiner{ diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index b8c015cdc..b4dc9557f 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -258,7 +258,7 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece return rspco, nil } -func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed SealSeed, pieces []PublicPieceInfo, pieceKeys []string, rspco RawSealPreCommitOutput) (proof []byte, err error) { +func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed SealSeed, pieces []PublicPieceInfo, rspco RawSealPreCommitOutput) (proof []byte, err error) { ret := sb.RateLimit() defer ret() diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index 39e0a2bd1..6ad7f96fe 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -21,6 +21,7 @@ import ( ) const sectorSize = 1024 + type seal struct { sid uint64 @@ -59,7 +60,7 @@ func (s *seal) commit(t *testing.T, sb *sectorbuilder.SectorBuilder, done func() TicketBytes: [32]byte{0, 9, 8, 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}, } - proof, err := sb.SealCommit(s.sid, s.ticket, seed, []sectorbuilder.PublicPieceInfo{s.ppi}, []string{"foo"}, s.pco) + proof, err := sb.SealCommit(s.sid, s.ticket, seed, []sectorbuilder.PublicPieceInfo{s.ppi}, s.pco) if err != nil { t.Fatalf("%+v", err) } @@ -183,6 +184,71 @@ func TestSealAndVerify(t *testing.T) { fmt.Printf("EPoSt: %s\n", epost.Sub(genCandidiates).String()) } +func TestSealPoStNoCommit(t *testing.T) { + if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware + t.Skip("this is slow") + } + os.Setenv("BELLMAN_NO_GPU", "1") + os.Setenv("RUST_LOG", "info") + + build.SectorSizes = []uint64{sectorSize} + + if err := build.GetParams(true, true); err != nil { + t.Fatalf("%+v", err) + } + + ds := datastore.NewMapDatastore() + + dir, err := ioutil.TempDir("", "sbtest") + if err != nil { + t.Fatal(err) + } + + sb, err := sectorbuilder.TempSectorbuilderDir(dir, sectorSize, ds) + if err != nil { + t.Fatalf("%+v", err) + } + cleanup := func() { + sb.Destroy() + if t.Failed() { + fmt.Printf("not removing %s\n", dir) + return + } + if err := os.RemoveAll(dir); err != nil { + t.Error(err) + } + } + defer cleanup() + + si, err := sb.AcquireSectorId() + if err != nil { + t.Fatalf("%+v", err) + } + + s := seal{sid: si} + + start := time.Now() + + s.precommit(t, sb, 1, func() {}) + + precommit := time.Now() + + // Restart sectorbuilder, re-run post + sb.Destroy() + sb, err = sectorbuilder.TempSectorbuilderDir(dir, sectorSize, ds) + if err != nil { + t.Fatalf("%+v", err) + } + + genCandidiates := s.post(t, sb) + + epost := time.Now() + + fmt.Printf("PreCommit: %s\n", precommit.Sub(start).String()) + fmt.Printf("GenCandidates: %s\n", genCandidiates.Sub(precommit).String()) + fmt.Printf("EPoSt: %s\n", epost.Sub(genCandidiates).String()) +} + func TestSealAndVerify2(t *testing.T) { if runtime.NumCPU() < 10 && os.Getenv("CI") == "" { // don't bother on slow hardware t.Skip("this is slow") diff --git a/miner/miner.go b/miner/miner.go index 7fa0f63c2..aea344cc7 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -165,7 +165,7 @@ eventLoop: for _, addr := range addrs { b, err := m.mineOne(ctx, addr, base) if err != nil { - log.Errorf("mining block failed: %s", err) + log.Errorf("mining block failed: %+v", err) continue } if b != nil { diff --git a/storage/miner.go b/storage/miner.go index f8323b2ac..3721be65c 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -143,7 +143,7 @@ func NewElectionPoStProver(sb *sectorbuilder.SectorBuilder) *sectorBuilderEpp { return §orBuilderEpp{sb} } -var _ (gen.ElectionPoStProver) = (*sectorBuilderEpp)(nil) +var _ gen.ElectionPoStProver = (*sectorBuilderEpp)(nil) func (epp *sectorBuilderEpp) GenerateCandidates(ctx context.Context, ssi sectorbuilder.SortedPublicSectorInfo, rand []byte) ([]sectorbuilder.EPostCandidate, error) { var faults []uint64 // TODO diff --git a/storage/sector_states.go b/storage/sector_states.go index 537ee2b1d..ec0810d26 100644 --- a/storage/sector_states.go +++ b/storage/sector_states.go @@ -176,7 +176,7 @@ func (m *Miner) preCommitted(ctx context.Context, sector SectorInfo) (func(*Sect func (m *Miner) committing(ctx context.Context, sector SectorInfo) (func(*SectorInfo), error) { log.Info("scheduling seal proof computation...") - proof, err := m.sb.SealCommit(sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.refs(), sector.rspco()) + proof, err := m.sb.SealCommit(sector.SectorID, sector.Ticket.SB(), sector.Seed.SB(), sector.pieceInfos(), sector.rspco()) if err != nil { return nil, xerrors.Errorf("computing seal proof failed: %w", err) }