From 4b8aa53806da6b823f9e99cfbf9fb0938fcf9831 Mon Sep 17 00:00:00 2001 From: "Andrew Jackson (Ajax)" Date: Tue, 14 Nov 2023 22:58:43 -0600 Subject: [PATCH] lints and non parallel --- cli/net.go | 3 ++- cmd/lotus-miner/proving.go | 3 ++- cmd/lotus-provider/proving.go | 2 +- cmd/lotus-provider/run.go | 6 ++--- cmd/lotus-shed/terminations.go | 3 ++- itests/harmonytask_test.go | 8 +++--- provider/lpmessage/sender.go | 2 +- provider/lpwindow/compute_do.go | 13 +++++----- provider/lpwindow/compute_task.go | 42 +++++++++++++++---------------- provider/lpwindow/recover_task.go | 21 +++++++++------- provider/lpwindow/submit_task.go | 2 +- 11 files changed, 56 insertions(+), 49 deletions(-) diff --git a/cli/net.go b/cli/net.go index f25799e95..99ee92aef 100644 --- a/cli/net.go +++ b/cli/net.go @@ -847,7 +847,8 @@ var NetStatCmd = &cli.Command{ }) for _, stat := range stats { - printScope(&stat.stat, name+stat.name) + tmp := stat.stat + printScope(&tmp, name+stat.name) } } diff --git a/cmd/lotus-miner/proving.go b/cmd/lotus-miner/proving.go index 3ecc58ba7..2fc1427b5 100644 --- a/cmd/lotus-miner/proving.go +++ b/cmd/lotus-miner/proving.go @@ -559,7 +559,8 @@ var provingCheckProvableCmd = &cli.Command{ for parIdx, par := range partitions { sectors := make(map[abi.SectorNumber]struct{}) - sectorInfos, err := api.StateMinerSectors(ctx, addr, &par.LiveSectors, types.EmptyTSK) + tmp := par.LiveSectors + sectorInfos, err := api.StateMinerSectors(ctx, addr, &tmp, types.EmptyTSK) if err != nil { return err } diff --git a/cmd/lotus-provider/proving.go b/cmd/lotus-provider/proving.go index 42e023dc5..1f2f186ce 100644 --- a/cmd/lotus-provider/proving.go +++ b/cmd/lotus-provider/proving.go @@ -65,7 +65,7 @@ It will not send any messages to the chain. Since it can compute any deadline, o Action: func(cctx *cli.Context) error { ctx := context.Background() - deps, err := getDeps(cctx, ctx) + deps, err := getDeps(ctx, cctx) if err != nil { return err } diff --git a/cmd/lotus-provider/run.go b/cmd/lotus-provider/run.go index ffb2f5b5f..763993c58 100644 --- a/cmd/lotus-provider/run.go +++ b/cmd/lotus-provider/run.go @@ -134,7 +134,7 @@ var runCmd = &cli.Command{ } shutdownChan := make(chan struct{}) - deps, err := getDeps(cctx, ctx) + deps, err := getDeps(ctx, cctx) if err != nil { return err @@ -267,7 +267,7 @@ type Deps struct { listenAddr string } -func getDeps(cctx *cli.Context, ctx context.Context) (*Deps, error) { +func getDeps(ctx context.Context, cctx *cli.Context) (*Deps, error) { // Open repo repoPath := cctx.String(FlagRepoPath) @@ -319,7 +319,7 @@ func getDeps(cctx *cli.Context, ctx context.Context) (*Deps, error) { if err != nil { return nil, err } - defer j.Close() + defer func() { _ = j.Close() }() full, fullCloser, err := cliutil.GetFullNodeAPIV1LotusProvider(cctx, cfg.Apis.ChainApiInfo) if err != nil { diff --git a/cmd/lotus-shed/terminations.go b/cmd/lotus-shed/terminations.go index c5f35995a..563c1ba3a 100644 --- a/cmd/lotus-shed/terminations.go +++ b/cmd/lotus-shed/terminations.go @@ -157,7 +157,8 @@ var terminationsCmd = &cli.Command{ } for _, t := range termParams.Terminations { - sectors, err := minerSt.LoadSectors(&t.Sectors) + tmp := t.Sectors + sectors, err := minerSt.LoadSectors(&tmp) if err != nil { return err } diff --git a/itests/harmonytask_test.go b/itests/harmonytask_test.go index f3b02f9b2..d588a2490 100644 --- a/itests/harmonytask_test.go +++ b/itests/harmonytask_test.go @@ -78,7 +78,7 @@ func init() { } func TestHarmonyTasks(t *testing.T) { - t.Parallel() + //t.Parallel() withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB t1 := &task1{ @@ -160,7 +160,7 @@ func fooLetterSaver(t *testing.T, cdb *harmonydb.DB, dest *[]string) *passthru { } func TestHarmonyTasksWith2PartiesPolling(t *testing.T) { - t.Parallel() + //t.Parallel() withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB senderParty := fooLetterAdder(t, cdb) @@ -180,7 +180,7 @@ func TestHarmonyTasksWith2PartiesPolling(t *testing.T) { } func TestWorkStealing(t *testing.T) { - t.Parallel() + //t.Parallel() withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB ctx := context.Background() @@ -209,7 +209,7 @@ func TestWorkStealing(t *testing.T) { } func TestTaskRetry(t *testing.T) { - t.Parallel() + //t.Parallel() withDbSetup(t, func(m *kit.TestMiner) { cdb := m.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB senderParty := fooLetterAdder(t, cdb) diff --git a/provider/lpmessage/sender.go b/provider/lpmessage/sender.go index 5123410c9..1dff1d6f7 100644 --- a/provider/lpmessage/sender.go +++ b/provider/lpmessage/sender.go @@ -168,7 +168,7 @@ func (s *Sender) Send(ctx context.Context, msg *types.Message, mss *api.MessageS return cid.Undef, xerrors.Errorf("updating db record: %w", err) } if cn != 1 { - return cid.Undef, xerrors.Errorf("updating db record: expected 1 row to be affected, got %d", c) + return cid.Undef, xerrors.Errorf("updating db record: expected 1 row to be affected, got %d", cn) } log.Infow("sent message", "cid", sigMsg.Cid(), "from", fromA, "to", msg.To, "nonce", msg.Nonce, "value", msg.Value, "gaslimit", msg.GasLimit) diff --git a/provider/lpwindow/compute_do.go b/provider/lpwindow/compute_do.go index 3f7c8f6b1..800f23c57 100644 --- a/provider/lpwindow/compute_do.go +++ b/provider/lpwindow/compute_do.go @@ -207,8 +207,9 @@ func (t *WdPostTask) DoPartition(ctx context.Context, ts *types.TipSet, maddr ad time.Sleep(5 * time.Second) continue todo retry loop */ } else if !correct { + _ = correct /*log.Errorw("generated incorrect window post proof", "post", postOut, "error", err) - continue todo retry loop */ + continue todo retry loop*/ } // Proof generation successful, stop retrying @@ -322,11 +323,11 @@ func (t *WdPostTask) sectorsForProof(ctx context.Context, maddr address.Address, if err := allSectors.ForEach(func(sectorNo uint64) error { if info, found := sectorByID[sectorNo]; found { proofSectors = append(proofSectors, info) - } else { - //skip - // todo: testing: old logic used to put 'substitute' sectors here - // that probably isn't needed post nv19, but we do need to check that - } + } //else { + //skip + // todo: testing: old logic used to put 'substitute' sectors here + // that probably isn't needed post nv19, but we do need to check that + //} return nil }); err != nil { return nil, xerrors.Errorf("iterating partition sector bitmap: %w", err) diff --git a/provider/lpwindow/compute_task.go b/provider/lpwindow/compute_task.go index de35f11bb..f606c7105 100644 --- a/provider/lpwindow/compute_task.go +++ b/provider/lpwindow/compute_task.go @@ -74,10 +74,10 @@ type WdPostTask struct { } type wdTaskIdentity struct { - Sp_id uint64 - Proving_period_start abi.ChainEpoch - Deadline_index uint64 - Partition_index uint64 + SpID uint64 + ProvingPeriodStart abi.ChainEpoch + DeadlineIndex uint64 + PartitionIndex uint64 } func NewWdPostTask(db *harmonydb.DB, @@ -206,11 +206,11 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng // GetData for tasks type wdTaskDef struct { - Task_id harmonytask.TaskID - Sp_id uint64 - Proving_period_start abi.ChainEpoch - Deadline_index uint64 - Partition_index uint64 + TaskID harmonytask.TaskID + SpID uint64 + ProvingPeriodStart abi.ChainEpoch + DeadlineIndex uint64 + PartitionIndex uint64 dlInfo *dline.Info `pgx:"-"` openTs *types.TipSet @@ -232,10 +232,10 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng // Accept those past deadline, then delete them in Do(). for i := range tasks { - tasks[i].dlInfo = wdpost.NewDeadlineInfo(tasks[i].Proving_period_start, tasks[i].Deadline_index, ts.Height()) + tasks[i].dlInfo = wdpost.NewDeadlineInfo(tasks[i].ProvingPeriodStart, tasks[i].DeadlineIndex, ts.Height()) if tasks[i].dlInfo.PeriodElapsed() { - return &tasks[i].Task_id, nil + return &tasks[i].TaskID, nil } tasks[i].openTs, err = t.api.ChainGetTipSetAfterHeight(context.Background(), tasks[i].dlInfo.Open, ts.Key()) @@ -281,7 +281,7 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng var r int err := t.db.QueryRow(context.Background(), `SELECT COUNT(*) FROM harmony_task_history - WHERE task_id = $1 AND result = false`, d.Task_id).Scan(&r) + WHERE task_id = $1 AND result = false`, d.TaskID).Scan(&r) if err != nil { log.Errorf("WdPostTask.CanAccept() failed to queryRow: %v", err) } @@ -293,7 +293,7 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng return tasks[i].dlInfo.Open < tasks[j].dlInfo.Open }) - return &tasks[0].Task_id, nil + return &tasks[0].TaskID, nil } var res = storiface.ResourceTable[sealtasks.TTGenerateWindowPoSt] @@ -353,10 +353,10 @@ func (t *WdPostTask) processHeadChange(ctx context.Context, revert, apply *types for pidx := range partitions { tid := wdTaskIdentity{ - Sp_id: aid, - Proving_period_start: di.PeriodStart, - Deadline_index: di.Index, - Partition_index: uint64(pidx), + SpID: aid, + ProvingPeriodStart: di.PeriodStart, + DeadlineIndex: di.Index, + PartitionIndex: uint64(pidx), } tf := t.windowPoStTF.Val(ctx) @@ -384,10 +384,10 @@ func (t *WdPostTask) addTaskToDB(taskId harmonytask.TaskID, taskIdent wdTaskIden partition_index ) VALUES ($1, $2, $3, $4, $5)`, taskId, - taskIdent.Sp_id, - taskIdent.Proving_period_start, - taskIdent.Deadline_index, - taskIdent.Partition_index, + taskIdent.SpID, + taskIdent.ProvingPeriodStart, + taskIdent.DeadlineIndex, + taskIdent.PartitionIndex, ) if err != nil { return false, xerrors.Errorf("insert partition task: %w", err) diff --git a/provider/lpwindow/recover_task.go b/provider/lpwindow/recover_task.go index fafe76e56..6006f3c35 100644 --- a/provider/lpwindow/recover_task.go +++ b/provider/lpwindow/recover_task.go @@ -166,7 +166,7 @@ func (w *WdPostRecoverDeclareTask) Do(taskID harmonytask.TaskID, stillOwned func recDecl := miner.RecoveryDeclaration{ Deadline: dlIdx, - Partition: uint64(partIdx), + Partition: partIdx, Sectors: recovered, } @@ -187,6 +187,9 @@ func (w *WdPostRecoverDeclareTask) Do(taskID harmonytask.TaskID, stillOwned func } msg, mss, err := preparePoStMessage(w.api, w.as, maddr, msg, abi.TokenAmount(w.maxDeclareRecoveriesGasFee)) + if err != nil { + return false, xerrors.Errorf("sending declare recoveries message: %w", err) + } mc, err := w.sender.Send(ctx, msg, mss, "declare-recoveries") if err != nil { @@ -279,10 +282,10 @@ func (w *WdPostRecoverDeclareTask) processHeadChange(ctx context.Context, revert } tid := wdTaskIdentity{ - Sp_id: aid, - Proving_period_start: pps, - Deadline_index: declDeadline, - Partition_index: uint64(pidx), + SpID: aid, + ProvingPeriodStart: pps, + DeadlineIndex: declDeadline, + PartitionIndex: uint64(pidx), } tf(func(id harmonytask.TaskID, tx *harmonydb.Tx) (bool, error) { @@ -304,10 +307,10 @@ func (w *WdPostRecoverDeclareTask) addTaskToDB(taskId harmonytask.TaskID, taskId partition_index ) VALUES ($1, $2, $3, $4, $5)`, taskId, - taskIdent.Sp_id, - taskIdent.Proving_period_start, - taskIdent.Deadline_index, - taskIdent.Partition_index, + taskIdent.SpID, + taskIdent.ProvingPeriodStart, + taskIdent.DeadlineIndex, + taskIdent.PartitionIndex, ) if err != nil { return false, xerrors.Errorf("insert partition task: %w", err) diff --git a/provider/lpwindow/submit_task.go b/provider/lpwindow/submit_task.go index ba0f63f6d..f7e051c91 100644 --- a/provider/lpwindow/submit_task.go +++ b/provider/lpwindow/submit_task.go @@ -257,7 +257,7 @@ func preparePoStMessage(w MsgPrepAPI, as *ctladdr.AddressSelector, maddr address msg.From = mi.Worker mss := &api.MessageSendSpec{ - MaxFee: abi.TokenAmount(maxFee), + MaxFee: maxFee, } // (optimal) initial estimation with some overestimation that guarantees