Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sealing: improve gasEstimate logging #11840

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions storage/pipeline/commit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ func (b *CommitBatcher) processBatchV2(cfg sealiface.Config, sectors []abi.Secto
_, err = simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.ProveCommitSectors3, needFunds, maxFee, enc.Bytes())

if err != nil && (!api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) || len(sectors) < miner.MinAggregatedSectors*2) {
log.Errorf("simulating CommitBatch message failed (%x): %s", enc.Bytes(), err)
log.Errorf("simulating CommitBatch %s", err)
res.Error = err.Error()
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("simulating CommitBatch message failed: %w", err)
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("simulating CommitBatch %w", err)
}

msgTooLarge := len(enc.Bytes()) > (messagepool.MaxMessageSize - 128)
Expand Down Expand Up @@ -590,9 +590,9 @@ func (b *CommitBatcher) processBatchV1(cfg sealiface.Config, sectors []abi.Secto
_, err = simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.ProveCommitAggregate, needFunds, maxFee, enc.Bytes())

if err != nil && (!api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) || len(sectors) < miner.MinAggregatedSectors*2) {
log.Errorf("simulating CommitBatch message failed (%x): %s", enc.Bytes(), err)
log.Errorf("simulating CommitBatch %s", err)
res.Error = err.Error()
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("simulating CommitBatch message failed: %w", err)
return []sealiface.CommitBatchRes{res}, xerrors.Errorf("simulating CommitBatch %w", err)
}

// If we're out of gas, split the batch in half and evaluate again
Expand Down
2 changes: 1 addition & 1 deletion storage/pipeline/precommit_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.To

if err != nil && (!api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) || len(entries) == 1) {
res.Error = err.Error()
return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("simulating PreCommitBatch message failed: %w", err)
return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("simulating PreCommitBatch %w", err)
}

// If we're out of gas, split the batch in half and evaluate again
Expand Down
14 changes: 13 additions & 1 deletion storage/pipeline/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package sealing

import (
"bytes"
"context"
"fmt"
"math/bits"

"github.com/ipfs/go-cid"
Expand Down Expand Up @@ -105,7 +107,17 @@ func simulateMsgGas(ctx context.Context, sa interface {
Params: params,
}

return sa.GasEstimateMessageGas(ctx, &msg, nil, types.EmptyTSK)
var b bytes.Buffer
err := msg.MarshalCBOR(&b)
if err != nil {
return nil, xerrors.Errorf("failed to unmarshal the signed message: %w", err)
}

gmsg, err := sa.GasEstimateMessageGas(ctx, &msg, nil, types.EmptyTSK)
if err != nil {
err = fmt.Errorf("message %x failed: %w", b.Bytes(), err)
}
return gmsg, err
}

func sendMsg(ctx context.Context, sa interface {
Expand Down