From 9f9ae155e35018a15777e79ffa6013889220c78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 21 Apr 2020 23:38:26 +0200 Subject: [PATCH] windowed post: Review cleanup --- build/genesis/devnet.car | Bin 4973 -> 0 bytes chain/gen/gen.go | 25 ------------------------- chain/gen/genesis/genesis.go | 1 + chain/gen/genesis/miners.go | 16 +++------------- cmd/lotus-bench/main.go | 2 +- node/impl/client/client.go | 13 +++++++++---- storage/wdpost_run.go | 11 +---------- 7 files changed, 15 insertions(+), 53 deletions(-) delete mode 100644 build/genesis/devnet.car diff --git a/build/genesis/devnet.car b/build/genesis/devnet.car deleted file mode 100644 index 90100855dc34e667e0669a25f5e7326d174b04a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4973 zcmb7|3p`X?7r^%z<55&M^+ib&UtTGXB!wCp<1H$g(!&^IOk&)b@u-xUGl)DAQq(7p zL`gO2p}HzcMOWNX7m?eCW+j#U||KDkWOPJw#+icWOTvbwdW7SU6&)1Ar z8og2=ub;DD_^~l%ZekRJ(Y@)tJ!)t?dy4!EYm>-gf$yQJ4S8Mq4?Tfqm&O_Lme3wz zX(g$D_SV?fzWv~)3}QQ$77$rm=9XPd7R^uqc>(E&I$d{wa|6?TSUdC$^|?GYhsIFl5Y zv{L^Xg@aLR#HdLKiWR^@bFN39Sh$HxXb8zlDdTQmB6>?-vn&2)0&Qm9~YJc6zwXC)zOuM(6JnJ?^r@|K41Cyl{h2_sP0f6YB zLl!3fU_t#^0b>?)pZXo&FB{YAm#N9w`Z#&%&RWT<-^bfxcgOG|ySt#Q^}EyX<1D3f z*a0Z#JGQ#`p4}<`#BxY~#_8^&i$k}p|5S-se@sr4>%gkNs`Q=XjcMr$^1yVwdAsYP z=YXshfqiwkr*#$$*u+nDEjaS@W2#n0-NSEPK3q&3fW zGs{}6ekg%xcLAB{Q5@Qv?JG*1i4ViwJxfpgH+&91!{bbG>{0v|gRLt)LG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iXy&G@mxPmfZaW$*gWY`p5Bxh zF%glBD90K5G;jAAoxfzZ*?zFEeQ7nXNwaZzo+c1Tqj`=%s`B=)!^76jjkur@-w{Sx zuQmOPTVjpU1D)KSw5A9GLd!R|FfMrH9Q^%egom%T5)cr^vCOIynD+ZaCtdFzVabfL z{Cu*gqC>eA2amHjGwYA`gj1P*cDw#_C|RB;moV^F0SIKqvT%)%BhEtqw}bdwBP`ib zmcWM8N7=T&Z1eR__eYOTy?S=;WJc-sb1(4?$DbR}nR-AVJC1dPeYWv|S6TP014JS! zxrr}^$o>=e79nwqbv+aaAS)m}brUig>jo&G{(PoErFi6mi0Fv)*CF#_T@)eMUEkhC iVI>EW#B!`RJVF43BtCx+q5;-R9<&BnWR$X4L;nFdq}Ztd diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 210342055..292f88b4b 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -554,31 +554,6 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch, return &types.ElectionProof{VRFProof: vrfout}, nil } -/* -func ComputeProof(ctx context.Context, epp WinningPoStProver, pi *ProofInput) (*types.EPostProof, error) { - proof, err := epp.ComputeProof(ctx, pi.sectors, pi.hvrf, pi.challengedSectors) - if err != nil { - return nil, xerrors.Errorf("failed to compute snark for election proof: %w", err) - } - - ept := types.EPostProof{ - Proofs: proof, - PostRand: pi.vrfout, - } - for _, win := range pi.challengedSectors { - part := make([]byte, 32) - copy(part, win.Candidate.PartialTicket) - ept.Candidates = append(ept.Candidates, types.EPostTicket{ - Partial: part, - SectorID: win.Candidate.SectorID.Number, - ChallengeIndex: uint64(win.Candidate.ChallengeIndex), - }) - } - - return &ept, nil -} -*/ - type SignFunc func(context.Context, address.Address, []byte) (*crypto.Signature, error) func VerifyVRF(ctx context.Context, worker address.Address, vrfBase, vrfproof []byte) error { diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 2cbf7fd44..8e108dcb4 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -32,6 +32,7 @@ var log = logging.Logger("genesis") type GenesisBootstrap struct { Genesis *types.BlockHeader } + /* From a list of parameters, create a genesis block / initial state diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 4d5a5cf92..4d7e563af 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -141,16 +141,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid } } - // setup windowed post - { - // TODO: Can drop, now done in constructor - err = vm.MutateState(ctx, maddr, func(cst cbor.IpldStore, st *miner.State) error { - fmt.Println("PROVINg BOUNDARY: #### ", st.Info.ProvingPeriodBoundary) - return nil - }) - - } - // Commit sectors for pi, preseal := range m.Sectors { // TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file) @@ -204,11 +194,11 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid RegisteredProof: preseal.ProofType, SectorNumber: preseal.SectorID, SealedCID: preseal.CommR, - SealRandEpoch: 0, // TODO: REVIEW: Correct? + SealRandEpoch: 0, DealIDs: []abi.DealID{dealIDs[pi]}, Expiration: preseal.Deal.EndEpoch, }, - ActivationEpoch: 0, // TODO: REVIEW: Correct? + ActivationEpoch: 0, DealWeight: dealWeight.DealWeight, VerifiedDealWeight: dealWeight.VerifiedDealWeight, } @@ -242,7 +232,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid c, err := vm.Flush(ctx) if err != nil { - return cid.Cid{}, xerrors.Errorf("flushing vm: %w", err) + return cid.Undef, xerrors.Errorf("flushing vm: %w", err) } return c, nil } diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index c50ac6c75..2d9e82500 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -133,7 +133,7 @@ var sealBenchCmd = &cli.Command{ Usage: "Save commit2 input to a file", }, &cli.IntFlag{ - Name: "num-sectors", + Name: "num-sectors", Value: 1, }, }, diff --git a/node/impl/client/client.go b/node/impl/client/client.go index 0464ee9eb..3a5cb3bc7 100644 --- a/node/impl/client/client.go +++ b/node/impl/client/client.go @@ -66,6 +66,14 @@ type API struct { Filestore dtypes.ClientFilestore `optional:"true"` } +func calcDealExpiration(minDuration uint64, mi miner.MinerInfo, ts *types.TipSet) abi.ChainEpoch { + // Make sure we give some time for the miner to seal + minExp := ts.Height() + dealStartBuffer + abi.ChainEpoch(minDuration) + + // Align on miners ProvingPeriodBoundary + return minExp + miner.WPoStProvingPeriod - (minExp % miner.WPoStProvingPeriod) + mi.ProvingPeriodBoundary - 1 +} + func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) (*cid.Cid, error) { exist, err := a.WalletHas(ctx, params.Wallet) if err != nil { @@ -95,16 +103,13 @@ func (a *API) ClientStartDeal(ctx context.Context, params *api.StartDealParams) return nil, xerrors.Errorf("failed getting chain height: %w", err) } - exp := ts.Height() + dealStartBuffer + abi.ChainEpoch(params.MinBlocksDuration) - exp += miner.WPoStProvingPeriod - (exp % miner.WPoStProvingPeriod) + mi.ProvingPeriodBoundary - 1 - result, err := a.SMDealClient.ProposeStorageDeal( ctx, params.Wallet, &providerInfo, params.Data, ts.Height()+dealStartBuffer, - exp, + calcDealExpiration(params.MinBlocksDuration, mi, ts), params.EpochPrice, big.Zero(), rt, diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 7d16e95a4..151eb4155 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -57,10 +57,6 @@ func (s *WindowPoStScheduler) doPost(ctx context.Context, deadline *miner.Deadli func (s *WindowPoStScheduler) checkFaults(ctx context.Context, ssi []abi.SectorNumber) ([]abi.SectorNumber, error) { //faults := s.prover.Scrub(ssi) log.Warnf("Stub checkFaults") - var faults []struct { - SectorNum abi.SectorNumber - Err error - } declaredFaults := map[abi.SectorNumber]struct{}{} @@ -75,12 +71,7 @@ func (s *WindowPoStScheduler) checkFaults(ctx context.Context, ssi []abi.SectorN } } - var faultIDs []abi.SectorNumber - if len(faults) > 0 { - panic("Aaaaaaaaaaaaaaaaaaaa") - } - - return faultIDs, nil + return nil, nil } func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo, ts *types.TipSet) (*miner.SubmitWindowedPoStParams, error) {