Add a mining-heartbeat INFO line at every epoch
This commit is contained in:
parent
c074031fa1
commit
72134ff458
@ -3,6 +3,7 @@ package gen
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -610,6 +611,8 @@ func (wpp *wppProvider) ComputeProof(context.Context, []proof2.SectorInfo, abi.P
|
|||||||
return ValidWpostForTesting, nil
|
return ValidWpostForTesting, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var b64 = base64.URLEncoding.WithPadding(base64.NoPadding)
|
||||||
|
|
||||||
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
|
func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
|
||||||
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {
|
miner address.Address, brand types.BeaconEntry, mbi *api.MiningBaseInfo, a MiningCheckAPI) (*types.ElectionProof, error) {
|
||||||
|
|
||||||
@ -631,6 +634,12 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
|
|||||||
ep := &types.ElectionProof{VRFProof: vrfout}
|
ep := &types.ElectionProof{VRFProof: vrfout}
|
||||||
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
|
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
|
||||||
ep.WinCount = j
|
ep.WinCount = j
|
||||||
|
|
||||||
|
log.Infow("completed winAttemptVRF",
|
||||||
|
"VRFb64", b64.EncodeToString(vrfout),
|
||||||
|
"winCount", j,
|
||||||
|
)
|
||||||
|
|
||||||
if j < 1 {
|
if j < 1 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
|
proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
|
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -425,8 +426,37 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
|
|||||||
return nil, xerrors.Errorf("failed to get mining base info: %w", err)
|
return nil, xerrors.Errorf("failed to get mining base info: %w", err)
|
||||||
}
|
}
|
||||||
if mbi == nil {
|
if mbi == nil {
|
||||||
|
log.Warnf("mineOne: unexpectedly nil MiningBaseInfo for round %d, off tipset %d/%s", round, base.TipSet.Height(), base.TipSet.Key().String())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always write out a log from this point out
|
||||||
|
var winner *types.ElectionProof
|
||||||
|
lookBack := make(chan int64)
|
||||||
|
|
||||||
|
// figure this out in the background, instead of slowing down the main loop
|
||||||
|
go func() {
|
||||||
|
lb := int64(-1)
|
||||||
|
if netVer, err := m.api.StateNetworkVersion(ctx, base.TipSet.Key()); err == nil {
|
||||||
|
lb = int64(policy.GetWinningPoStSectorSetLookback(netVer))
|
||||||
|
}
|
||||||
|
lookBack <- lb
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
|
||||||
|
log.Infow(
|
||||||
|
"completed mineOne",
|
||||||
|
"forRound", int64(round),
|
||||||
|
"baseEpoch", int64(base.TipSet.Height()),
|
||||||
|
"lookbackEpochs", <-lookBack,
|
||||||
|
"networkPowerAtLookback", mbi.NetworkPower.String(),
|
||||||
|
"minerPowerAtLookback", mbi.MinerPower.String(),
|
||||||
|
"isEligible", mbi.EligibleForMining,
|
||||||
|
"isWinner", (winner != nil),
|
||||||
|
)
|
||||||
|
}()
|
||||||
|
|
||||||
if !mbi.EligibleForMining {
|
if !mbi.EligibleForMining {
|
||||||
// slashed or just have no power yet
|
// slashed or just have no power yet
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -453,7 +483,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
|
|||||||
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
|
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
winner, err := gen.IsRoundWinner(ctx, base.TipSet, round, m.address, rbase, mbi, m.api)
|
winner, err = gen.IsRoundWinner(ctx, base.TipSet, round, m.address, rbase, mbi, m.api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to check if we win next round: %w", err)
|
return nil, xerrors.Errorf("failed to check if we win next round: %w", err)
|
||||||
}
|
}
|
||||||
@ -505,7 +535,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
|
|||||||
for i, header := range base.TipSet.Blocks() {
|
for i, header := range base.TipSet.Blocks() {
|
||||||
parentMiners[i] = header.Miner
|
parentMiners[i] = header.Miner
|
||||||
}
|
}
|
||||||
log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "miner", b.Header.Miner, "parents", parentMiners, "took", dur)
|
log.Infow("mined new block", "cid", b.Cid(), "height", int64(b.Header.Height), "miner", b.Header.Miner, "parents", parentMiners, "parentTipset", base.TipSet.Key().String(), "took", dur)
|
||||||
if dur > time.Second*time.Duration(build.BlockDelaySecs) {
|
if dur > time.Second*time.Duration(build.BlockDelaySecs) {
|
||||||
log.Warnw("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up",
|
log.Warnw("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up",
|
||||||
"tMinerBaseInfo ", tMBI.Sub(start),
|
"tMinerBaseInfo ", tMBI.Sub(start),
|
||||||
|
Loading…
Reference in New Issue
Block a user