From bcaa395bb515d5528967e32eb1fd3d77c34f0fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 9 Sep 2022 12:54:48 +0200 Subject: [PATCH] sector import: Remote Commit2 --- api/api_storage.go | 10 ++++ build/openrpc/miner.json.gz | Bin 15801 -> 15813 bytes cmd/lotus-miner/info.go | 2 +- documentation/en/api-v0-methods-miner.md | 3 +- itests/sector_import_full_test.go | 2 +- itests/sector_import_simple_test.go | 29 ++++++++++++ storage/pipeline/cbor_gen.go | 36 ++++++++++++++- storage/pipeline/fsm.go | 10 ++-- storage/pipeline/fsm_events.go | 5 ++ storage/pipeline/receive.go | 20 +++++++- storage/pipeline/sector_state.go | 4 +- storage/pipeline/states_failed.go | 4 +- storage/pipeline/states_sealing.go | 56 ++++++++++++++++++++--- storage/pipeline/types.go | 1 + 14 files changed, 162 insertions(+), 20 deletions(-) diff --git a/api/api_storage.go b/api/api_storage.go index 6c4f2fbe463..7c454c846f6 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -566,6 +566,8 @@ type RemoteSectorMeta struct { // todo better doc RemoteCommit1Endpoint string + RemoteCommit2Endpoint string + // todo OnDone / OnStateChange } @@ -577,3 +579,11 @@ type RemoteCommit1Params struct { ProofType abi.RegisteredSealProof } + +type RemoteCommit2Params struct { + Sector abi.SectorID + ProofType abi.RegisteredSealProof + + // todo spec better + Commit1Out storiface.Commit1Out +} diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 61fcef75cdf265fe7db147deffcb16be1289e05c..3d42364ddb4334b44a3ef885e0d3e628097916d1 100644 GIT binary patch delta 5199 zcmV-V6tL^Ld&PUOrYV1#01$09$ZA%)bT^kmW%q-gysGk9ggmQ#?vejDje8u}A9GBg zvwcr=i|?5jKe}i#itH~#7_n6?F;T(tMs~m@KIar6*^PTdp_Cq)EcWWrq^vFgr%)xJ zafWIqBqh$;DG>^!;+VM3k-4EVZvu#^B$aKbr?M)|k8jvl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ajTextString, uint64(len("RemoteCommit2Endpoint"))); err != nil { + return err + } + if _, err := io.WriteString(w, string("RemoteCommit2Endpoint")); err != nil { + return err + } + + if len(t.RemoteCommit2Endpoint) > cbg.MaxLength { + return xerrors.Errorf("Value in field t.RemoteCommit2Endpoint was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.RemoteCommit2Endpoint))); err != nil { + return err + } + if _, err := io.WriteString(w, string(t.RemoteCommit2Endpoint)); err != nil { + return err + } + // t.RemoteDataFinalized (bool) (bool) if len("RemoteDataFinalized") > cbg.MaxLength { return xerrors.Errorf("Value in field \"RemoteDataFinalized\" was too long") @@ -1550,6 +1573,17 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) (err error) { t.RemoteCommit1Endpoint = string(sval) } + // t.RemoteCommit2Endpoint (string) (string) + case "RemoteCommit2Endpoint": + + { + sval, err := cbg.ReadString(cr) + if err != nil { + return err + } + + t.RemoteCommit2Endpoint = string(sval) + } // t.RemoteDataFinalized (bool) (bool) case "RemoteDataFinalized": diff --git a/storage/pipeline/fsm.go b/storage/pipeline/fsm.go index fb0d16b387d..fc0a93a8502 100644 --- a/storage/pipeline/fsm.go +++ b/storage/pipeline/fsm.go @@ -225,7 +225,7 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto on(SectorRetryComputeProof{}, Committing), on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed), ), - RemoteCommit1Failed: planOne( + RemoteCommitFailed: planOne( on(SectorRetryComputeProof{}, Committing), ), CommitFinalizeFailed: planOne( @@ -542,8 +542,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta return m.handlePreCommitFailed, processed, nil case ComputeProofFailed: return m.handleComputeProofFailed, processed, nil - case RemoteCommit1Failed: - return m.handleRemoteCommit1Failed, processed, nil + case RemoteCommitFailed: + return m.handleRemoteCommitFailed, processed, nil case CommitFailed: return m.handleCommitFailed, processed, nil case CommitFinalizeFailed: @@ -671,8 +671,8 @@ func planCommitting(events []statemachine.Event, state *SectorInfo) (uint64, err return uint64(i + 1), nil case SectorComputeProofFailed: state.State = ComputeProofFailed - case SectorRemoteCommit1Failed: - state.State = RemoteCommit1Failed + case SectorRemoteCommit1Failed, SectorRemoteCommit2Failed: + state.State = RemoteCommitFailed case SectorSealPreCommit1Failed: state.State = SealPreCommit1Failed case SectorCommitFailed: diff --git a/storage/pipeline/fsm_events.go b/storage/pipeline/fsm_events.go index 5c975bddacd..1252296e0d5 100644 --- a/storage/pipeline/fsm_events.go +++ b/storage/pipeline/fsm_events.go @@ -224,6 +224,11 @@ type SectorRemoteCommit1Failed struct{ error } func (evt SectorRemoteCommit1Failed) FormatError(xerrors.Printer) (next error) { return evt.error } func (evt SectorRemoteCommit1Failed) apply(*SectorInfo) {} +type SectorRemoteCommit2Failed struct{ error } + +func (evt SectorRemoteCommit2Failed) FormatError(xerrors.Printer) (next error) { return evt.error } +func (evt SectorRemoteCommit2Failed) apply(*SectorInfo) {} + type SectorComputeProofFailed struct{ error } func (evt SectorComputeProofFailed) FormatError(xerrors.Printer) (next error) { return evt.error } diff --git a/storage/pipeline/receive.go b/storage/pipeline/receive.go index d7eb5de7e8c..f06848bcbf6 100644 --- a/storage/pipeline/receive.go +++ b/storage/pipeline/receive.go @@ -3,6 +3,7 @@ package sealing import ( "bytes" "context" + "net/url" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" @@ -177,7 +178,24 @@ func (m *Sealing) checkSectorMeta(ctx context.Context, meta api.RemoteSectorMeta } info.RemoteDataSealed = meta.DataSealed // todo make head requests to check? info.RemoteDataCache = meta.DataCache - info.RemoteCommit1Endpoint = meta.RemoteCommit1Endpoint + + if meta.RemoteCommit1Endpoint != "" { + // validate the url + if _, err := url.Parse(meta.RemoteCommit1Endpoint); err != nil { + return SectorInfo{}, xerrors.Errorf("parsing remote c1 endpoint url: %w", err) + } + + info.RemoteCommit1Endpoint = meta.RemoteCommit1Endpoint + } + + if meta.RemoteCommit2Endpoint != "" { + // validate the url + if _, err := url.Parse(meta.RemoteCommit2Endpoint); err != nil { + return SectorInfo{}, xerrors.Errorf("parsing remote c2 endpoint url: %w", err) + } + + info.RemoteCommit2Endpoint = meta.RemoteCommit2Endpoint + } // If we get a sector after PC2, and remote C1 endpoint is set, assume that we're getting finalized sector data if info.RemoteCommit1Endpoint != "" { diff --git a/storage/pipeline/sector_state.go b/storage/pipeline/sector_state.go index 136e72a1658..7a56c136b52 100644 --- a/storage/pipeline/sector_state.go +++ b/storage/pipeline/sector_state.go @@ -31,7 +31,7 @@ var ExistSectorStateList = map[SectorState]struct{}{ SealPreCommit2Failed: {}, PreCommitFailed: {}, ComputeProofFailed: {}, - RemoteCommit1Failed: {}, + RemoteCommitFailed: {}, CommitFailed: {}, PackingFailed: {}, FinalizeFailed: {}, @@ -125,7 +125,7 @@ const ( SealPreCommit2Failed SectorState = "SealPreCommit2Failed" PreCommitFailed SectorState = "PreCommitFailed" ComputeProofFailed SectorState = "ComputeProofFailed" - RemoteCommit1Failed SectorState = "RemoteCommit1Failed" + RemoteCommitFailed SectorState = "RemoteCommitFailed" CommitFailed SectorState = "CommitFailed" PackingFailed SectorState = "PackingFailed" // TODO: deprecated, remove FinalizeFailed SectorState = "FinalizeFailed" diff --git a/storage/pipeline/states_failed.go b/storage/pipeline/states_failed.go index 7597273b889..4952e30048d 100644 --- a/storage/pipeline/states_failed.go +++ b/storage/pipeline/states_failed.go @@ -184,13 +184,13 @@ func (m *Sealing) handleComputeProofFailed(ctx statemachine.Context, sector Sect return ctx.Send(SectorRetryComputeProof{}) } -func (m *Sealing) handleRemoteCommit1Failed(ctx statemachine.Context, sector SectorInfo) error { +func (m *Sealing) handleRemoteCommitFailed(ctx statemachine.Context, sector SectorInfo) error { if err := failedCooldown(ctx, sector); err != nil { return err } if sector.InvalidProofs > 1 { - log.Errorw("consecutive remote commit1 fails", "sector", sector.SectorNumber, "c1url", sector.RemoteCommit1Endpoint) + log.Errorw("consecutive remote commit fails", "sector", sector.SectorNumber, "c1url", sector.RemoteCommit1Endpoint, "c2url", sector.RemoteCommit2Endpoint) } return ctx.Send(SectorRetryComputeProof{}) diff --git a/storage/pipeline/states_sealing.go b/storage/pipeline/states_sealing.go index 428dd30a67b..04f214f3b7b 100644 --- a/storage/pipeline/states_sealing.go +++ b/storage/pipeline/states_sealing.go @@ -567,6 +567,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) var c2in storiface.Commit1Out if sector.RemoteCommit1Endpoint == "" { + // Local Commit1 cids := storiface.SectorCids{ Unsealed: *sector.CommD, Sealed: *sector.CommR, @@ -576,6 +577,8 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(1): %w", err)}) } } else { + // Remote Commit1 + reqData := api.RemoteCommit1Params{ Ticket: sector.TicketValue, Seed: sector.SeedValue, @@ -611,9 +614,50 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) } } - proof, err := m.sealer.SealCommit2(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), c2in) - if err != nil { - return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(2): %w", err)}) + var porepProof storiface.Proof + + if sector.RemoteCommit2Endpoint == "" { + // Local Commit2 + + porepProof, err = m.sealer.SealCommit2(sector.sealingCtx(ctx.Context()), m.minerSector(sector.SectorType, sector.SectorNumber), c2in) + if err != nil { + return ctx.Send(SectorComputeProofFailed{xerrors.Errorf("computing seal proof failed(2): %w", err)}) + } + } else { + // Remote Commit2 + + reqData := api.RemoteCommit2Params{ + ProofType: sector.SectorType, + Sector: m.minerSectorID(sector.SectorNumber), + + Commit1Out: c2in, + } + reqBody, err := json.Marshal(&reqData) + if err != nil { + return xerrors.Errorf("marshaling remote commit2 request: %w", err) + } + + req, err := http.NewRequest("POST", sector.RemoteCommit2Endpoint, bytes.NewReader(reqBody)) + if err != nil { + return ctx.Send(SectorRemoteCommit2Failed{xerrors.Errorf("creating new remote commit2 request: %w", err)}) + } + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(ctx.Context()) + resp, err := http.DefaultClient.Do(req) + if err != nil { + return ctx.Send(SectorRemoteCommit2Failed{xerrors.Errorf("requesting remote commit2: %w", err)}) + } + + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return ctx.Send(SectorRemoteCommit2Failed{xerrors.Errorf("remote commit2 received non-200 http response %s", resp.Status)}) + } + + porepProof, err = io.ReadAll(resp.Body) // todo some len constraint + if err != nil { + return ctx.Send(SectorRemoteCommit2Failed{xerrors.Errorf("reading commit2 response: %w", err)}) + } } { @@ -623,19 +667,19 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) return nil } - if err := m.checkCommit(ctx.Context(), sector, proof, ts.Key()); err != nil { + if err := m.checkCommit(ctx.Context(), sector, porepProof, ts.Key()); err != nil { return ctx.Send(SectorCommitFailed{xerrors.Errorf("commit check error: %w", err)}) } } if cfg.FinalizeEarly { return ctx.Send(SectorProofReady{ - Proof: proof, + Proof: porepProof, }) } return ctx.Send(SectorCommitted{ - Proof: proof, + Proof: porepProof, }) } diff --git a/storage/pipeline/types.go b/storage/pipeline/types.go index 8ae2cdeb1fd..93d0ce2191e 100644 --- a/storage/pipeline/types.go +++ b/storage/pipeline/types.go @@ -100,6 +100,7 @@ type SectorInfo struct { RemoteDataSealed *storiface.SectorData RemoteDataCache *storiface.SectorData RemoteCommit1Endpoint string + RemoteCommit2Endpoint string RemoteDataFinalized bool // Debug