Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lotus-provider: Fix winning PoSt #11482

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions provider/lpwinning/winning_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"bytes"
"context"
"crypto/rand"
"database/sql"
"encoding/binary"
"encoding/json"
"errors"
"time"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -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)
Expand Down