From 943c223dad598a253636dcc1a2934ed315058366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 5 Dec 2023 17:51:42 +0100 Subject: [PATCH] fix: lotus-provider: Fix winning PoSt --- provider/lpwinning/winning_task.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/provider/lpwinning/winning_task.go b/provider/lpwinning/winning_task.go index f02ffa1ae..907b594fd 100644 --- a/provider/lpwinning/winning_task.go +++ b/provider/lpwinning/winning_task.go @@ -4,10 +4,8 @@ import ( "bytes" "context" "crypto/rand" - "database/sql" "encoding/binary" "encoding/json" - "errors" "time" "github.com/ipfs/go-cid" @@ -579,12 +577,13 @@ func (t *WinPostTask) mineBasic(ctx context.Context) { taskFn(func(id harmonytask.TaskID, tx *harmonydb.Tx) (shouldCommit bool, seriousError error) { // First we check if the mining base includes blocks we may have mined previously to avoid getting slashed // select mining_tasks where epoch==base_epoch if win=true to maybe get base block cid which has to be included in our tipset - var baseBlockCid string - err := tx.QueryRow(`SELECT mined_cid FROM mining_tasks WHERE epoch = $1 AND sp_id = $2 AND won = true`, baseEpoch, spID).Scan(&baseBlockCid) - if err != nil && !errors.Is(err, sql.ErrNoRows) { + var baseBlockCids []string + err := tx.Select(&baseBlockCids, `SELECT mined_cid FROM mining_tasks WHERE epoch = $1 AND sp_id = $2 AND won = true`, baseEpoch, spID) + if err != nil { return false, xerrors.Errorf("querying mining_tasks: %w", err) } - if baseBlockCid != "" { + if len(baseBlockCids) >= 1 { + baseBlockCid := baseBlockCids[0] c, err := cid.Parse(baseBlockCid) if err != nil { return false, xerrors.Errorf("parsing mined_cid: %w", err)