Skip to content

Commit

Permalink
Merge pull request #11654 from filecoin-project/fix/lp-winpost
Browse files Browse the repository at this point in the history
fix: lpwinning: Fix MiningBase.afterPropDelay
  • Loading branch information
snadrus authored Feb 27, 2024
2 parents 0eddfee + d1f7eb1 commit 68f1a44
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions provider/lpwinning/winning_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
})

// MAKE A MINING ATTEMPT!!
log.Debugw("attempting to mine a block", "tipset", types.LogCids(base.TipSet.Cids()))
log.Debugw("attempting to mine a block", "tipset", types.LogCids(base.TipSet.Cids()), "null-rounds", base.AddRounds)

mbi, err := t.api.MinerGetBaseInfo(ctx, maddr, round, base.TipSet.Key())
if err != nil {
Expand Down Expand Up @@ -226,6 +226,8 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
}
}

log.Infow("WinPostTask won election", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "eproof", eproof)

// winning PoSt
var wpostProof []prooftypes.PoStProof
{
Expand Down Expand Up @@ -277,6 +279,8 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
}
}

log.Infow("WinPostTask winning PoSt computed", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "proofs", wpostProof)

ticket, err := t.computeTicket(ctx, maddr, &rbase, round, base.TipSet.MinTicket(), mbi)
if err != nil {
return false, xerrors.Errorf("scratching ticket failed: %w", err)
Expand All @@ -288,6 +292,8 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
return false, xerrors.Errorf("failed to select messages for block: %w", err)
}

log.Infow("WinPostTask selected messages", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "messages", len(msgs))

// equivocation handling
{
// This next block exists to "catch" equivocating miners,
Expand Down Expand Up @@ -358,6 +364,8 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
}
}

log.Infow("WinPostTask base ready", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "ticket", ticket)

// block construction
var blockMsg *types.BlockMsg
{
Expand All @@ -379,6 +387,8 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
}
}

log.Infow("WinPostTask block ready", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "block", blockMsg.Header.Cid(), "timestamp", blockMsg.Header.Timestamp)

// persist in db
{
bhjson, err := json.Marshal(blockMsg.Header)
Expand All @@ -396,11 +406,13 @@ func (t *WinPostTask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don

// wait until block timestamp
{
log.Infow("WinPostTask waiting for block timestamp", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "block", blockMsg.Header.Cid(), "until", time.Unix(int64(blockMsg.Header.Timestamp), 0))
time.Sleep(time.Until(time.Unix(int64(blockMsg.Header.Timestamp), 0)))
}

// submit block!!
{
log.Infow("WinPostTask submitting block", "tipset", types.LogCids(base.TipSet.Cids()), "miner", maddr, "round", round, "block", blockMsg.Header.Cid())
if err := t.api.SyncSubmitBlock(ctx, blockMsg); err != nil {
return false, xerrors.Errorf("failed to submit block: %w", err)
}
Expand Down Expand Up @@ -489,7 +501,7 @@ func (mb MiningBase) baseTime() time.Time {
}

func (mb MiningBase) afterPropDelay() time.Time {
return mb.baseTime().Add(randTimeOffset(time.Second))
return mb.baseTime().Add(time.Duration(build.PropagationDelaySecs) * time.Second).Add(randTimeOffset(time.Second))
}

func (t *WinPostTask) mineBasic(ctx context.Context) {
Expand Down

0 comments on commit 68f1a44

Please sign in to comment.