Skip to content

Commit d829b55

Browse files
magik6krvagg
authored andcommitted
fix individual batch commit gas estimate gas error (#602)
1 parent 75208dc commit d829b55

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tasks/seal/task_submit_commit.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8+
"strings"
89

910
"github.com/ipfs/go-cid"
1011
"go.uber.org/multierr"
@@ -460,7 +461,7 @@ func (s *SubmitCommitTask) createCommitMessage(ctx context.Context, maddr addres
460461
}
461462
aggMsg, err = s.gasEstimateCommit(ctx, maddr, aggEnc.Bytes(), mi, goodFunds, aggCollateral, maxFee, ts.Key())
462463
if err != nil {
463-
return nil, err
464+
return nil, xerrors.Errorf("gas estimate aggregate commit: %w", err)
464465
}
465466
aggGas := big.Mul(big.Add(ts.MinTicketBlock().ParentBaseFee, aggMsg.GasPremium), big.NewInt(aggMsg.GasLimit))
466467
aggCost = big.Add(aggGas, aggFee)
@@ -474,9 +475,15 @@ func (s *SubmitCommitTask) createCommitMessage(ctx context.Context, maddr addres
474475
return nil, xerrors.Errorf("could not serialize commit params: %w", err)
475476
}
476477
msg, err = s.gasEstimateCommit(ctx, maddr, enc.Bytes(), mi, goodFunds, collateral, maxFee, ts.Key())
477-
if err != nil {
478-
return nil, err
478+
if err != nil && !strings.Contains(err.Error(), "call ran out of gas") {
479+
return nil, xerrors.Errorf("gas estimate individual commit: %w", err)
480+
} else if err != nil && !aggCost.Nil() {
481+
log.Errorw("gas estimate individual commit failed", "err", err, "sp", SpID, "sector", infos[0].Number)
482+
log.Infow("Sending commit message with aggregate due to no alternative", "Batch Cost", cost, "Aggregate Cost", aggCost)
483+
return aggMsg, nil
479484
}
485+
486+
log.Infow("gas estimate individual commit succeeded", "sp", SpID, "sector", infos[0].Number)
480487
gas := big.Mul(big.Add(ts.MinTicketBlock().ParentBaseFee, msg.GasPremium), big.NewInt(msg.GasLimit))
481488
cost = gas
482489
}

0 commit comments

Comments
 (0)