Merge pull request #11654 from filecoin-project/fix/lp-winpost
fix: lpwinning: Fix MiningBase.afterPropDelay
This commit is contained in:
commit
68f1a44469
@ -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 {
|
||||
@ -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
|
||||
{
|
||||
@ -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)
|
||||
@ -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,
|
||||
@ -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
|
||||
{
|
||||
@ -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)
|
||||
@ -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)
|
||||
}
|
||||
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user