Skip to content

Commit

Permalink
add wallet balance check to makeDisputeWindowedPosts func
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagaprasadvr committed Apr 4, 2024
1 parent 5026881 commit 5ac6b25
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cli/disputer.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@ var disputerStartCmd = &cli.Command{

// TODO: Parallelizeable
for _, dl := range dls {
// CHECK: if miner waller balance is zero then skip sending dispute message
walletBalance, err := api.WalletBalance(ctx, dl.miner)
if err != nil {
return xerrors.Errorf("failed to get wallet balance while checking to send dispute messages to miner %w: %w", dl.miner, err)
}
if walletBalance.Equals(big.Zero()) {
disputeLog.Warnw("wallet balance is zero, skipping dispute message", "wallet", dl.miner)
return nil
}
fullDeadlines, err := api.StateMinerDeadlines(ctx, dl.miner, tsk)
if err != nil {
return xerrors.Errorf("failed to load deadlines: %w", err)
Expand All @@ -260,6 +251,9 @@ var disputerStartCmd = &cli.Command{
proofsChecked += disputableProofs

ms, err := makeDisputeWindowedPosts(ctx, api, dl, disputableProofs, fromAddr)
if ms == nil {
continue
}
if err != nil {
return xerrors.Errorf("failed to check for disputes: %w", err)
}
Expand Down Expand Up @@ -370,6 +364,15 @@ var disputerStartCmd = &cli.Command{
// 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
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.Equals(big.Zero()) {
disputeLog.Warnw("wallet balance is zero, skipping dispute message", "wallet", dl.miner)
return nil, nil
}
disputes := make([]*types.Message, 0)

for i := uint64(0); i < postsSnapshotted; i++ {
Expand Down

0 comments on commit 5ac6b25

Please sign in to comment.