refactor: cli: Avoid disputing WindowedPoSt messages when the target miner has no balance to pay rewards (#11800)

In https://github.com/filecoin-project/lotus/issues/11703, a user came across an edge case where an SP:

1. Submitted a bad PoSt.
2. Terminated their sectors.
3. Withdrew all funds (after paying all fees).

This left the SP's miner actor with a bad proof but without any funds to pay for disputes. On the other hand, given that the sectors have been terminated and termination fees were already paid we don't really care about fining the SP for the bad proofs anyways.

But... we still don't want to submit dispute messages in this case because doing so isn't free and doesn't really serve a purpose.

So add a check to fetch miner wallet balance and only send disputing messages if balance is non zero.

fixes https://github.com/filecoin-project/lotus/issues/11715
This commit is contained in:
Nagaprasad V R 2024-04-10 19:46:04 +05:30 committed by GitHub
parent 6d9bb2e0bf
commit a67e7adf04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -361,6 +361,15 @@ var disputerStartCmd = &cli.Command{
// for a given miner, index, and maxPostIndex, tries to dispute posts from 0...postsSnapshotted-1 // for a given miner, index, and maxPostIndex, tries to dispute posts from 0...postsSnapshotted-1
// returns a list of DisputeWindowedPoSt msgs that are expected to succeed if sent // returns a list of DisputeWindowedPoSt msgs that are expected to succeed if sent
func makeDisputeWindowedPosts(ctx context.Context, api v0api.FullNode, dl minerDeadline, postsSnapshotted uint64, sender address.Address) ([]*types.Message, error) { func makeDisputeWindowedPosts(ctx context.Context, api v0api.FullNode, dl minerDeadline, postsSnapshotted uint64, sender address.Address) ([]*types.Message, error) {
// CHECK: if miner waller balance is zero then skip sending dispute message
walletBalance, err := api.WalletBalance(ctx, dl.miner)
if err != nil {
return nil, xerrors.Errorf("failed to get wallet balance while checking to send dispute messages to miner %w: %w", dl.miner, err)
}
if walletBalance.IsZero() {
disputeLog.Warnw("wallet balance is zero, skipping dispute message", "wallet", dl.miner)
return nil, nil
}
disputes := make([]*types.Message, 0) disputes := make([]*types.Message, 0)
for i := uint64(0); i < postsSnapshotted; i++ { for i := uint64(0); i < postsSnapshotted; i++ {