From 79826447f582211560e9e71f24f7d954451c37cf Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Wed, 12 Apr 2023 21:45:43 -0400 Subject: [PATCH] fix unit and integration test breaks --- storage/pipeline/commit_batch.go | 4 +++- storage/pipeline/commit_batch_test.go | 1 + storage/pipeline/precommit_batch.go | 14 ++++---------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/storage/pipeline/commit_batch.go b/storage/pipeline/commit_batch.go index 8adb7f3cd..09f1357d7 100644 --- a/storage/pipeline/commit_batch.go +++ b/storage/pipeline/commit_batch.go @@ -392,17 +392,19 @@ func (b *CommitBatcher) processBatch(cfg sealiface.Config, sectors []abi.SectorN _, 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: %s", err) res.Error = err.Error() return []sealiface.CommitBatchRes{res}, xerrors.Errorf("simulating CommitBatch message failed: %w", err) } // If we're out of gas, split the batch in half and try again if api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) { + log.Warnf("CommitAggregate message ran out of gas, splitting batch in half and trying again (sectors: %d)", len(sectors)) mid := len(sectors) / 2 ret0, _ := b.processBatch(cfg, sectors[:mid]) ret1, _ := b.processBatch(cfg, sectors[mid:]) - return append(ret0, ret1...), err + return append(ret0, ret1...), nil } mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.ProveCommitAggregate, needFunds, maxFee, enc.Bytes()) diff --git a/storage/pipeline/commit_batch_test.go b/storage/pipeline/commit_batch_test.go index a8948edcf..ef45b6b71 100644 --- a/storage/pipeline/commit_batch_test.go +++ b/storage/pipeline/commit_batch_test.go @@ -201,6 +201,7 @@ func TestCommitBatcher(t *testing.T) { if batch { s.EXPECT().StateNetworkVersion(gomock.Any(), gomock.Any()).Return(network.Version13, nil) + s.EXPECT().GasEstimateMessageGas(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(&types.Message{GasLimit: 1000000}, nil) //s.EXPECT().ChainBaseFee(gomock.Any(), gomock.Any()).Return(basefee, nil) } diff --git a/storage/pipeline/precommit_batch.go b/storage/pipeline/precommit_batch.go index dc50737a7..869c4feb5 100644 --- a/storage/pipeline/precommit_batch.go +++ b/storage/pipeline/precommit_batch.go @@ -321,7 +321,6 @@ func (b *PreCommitBatcher) processSingle(cfg sealiface.Config, mi api.MinerInfo, } func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.TokenAmount, entries []*preCommitEntry, nv network.Version) ([]sealiface.PreCommitBatchRes, error) { - log.Errorf("!!!!!!!!!!!!!!!!processPreCommitBatch: %d entries!!!!!!!!!!!!!!!!", len(entries)) params := miner.PreCommitSectorBatchParams{} deposit := big.Zero() var res sealiface.PreCommitBatchRes @@ -368,13 +367,8 @@ func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.To return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("no good address found: %w", err) } - msg, err := simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, deposit, maxFee, enc.Bytes()) + _, err = simulateMsgGas(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) - var gasLimit int64 - if msg != nil { - gasLimit = msg.GasLimit - } - log.Errorf("!!!!!!!!!!!!!!simulate Msg err: %w, gasLimit: %d !!!!!!!!!!!!!!!!!!!!", err, gasLimit) 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) @@ -382,16 +376,16 @@ func (b *PreCommitBatcher) processPreCommitBatch(cfg sealiface.Config, bf abi.To // If we're out of gas, split the batch in half and try again if api.ErrorIsIn(err, []error{&api.ErrOutOfGas{}}) { + log.Warnf("PreCommitBatch out of gas, splitting batch in half and trying again") mid := len(entries) / 2 ret0, _ := b.processPreCommitBatch(cfg, bf, entries[:mid], nv) ret1, _ := b.processPreCommitBatch(cfg, bf, entries[mid:], nv) - return append(ret0, ret1...), err + return append(ret0, ret1...), nil } // If state call succeeds, we can send the message for real - mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, deposit, maxFee, enc.Bytes()) - log.Errorf("!!!!!!!!!!!!!!sendMsg err: %w, mcid: %v!!!!!!!!!!!!!!!!!!!!", err, mcid) + mcid, err := sendMsg(b.mctx, b.api, from, b.maddr, builtin.MethodsMiner.PreCommitSectorBatch, needFunds, maxFee, enc.Bytes()) if err != nil { res.Error = err.Error() return []sealiface.PreCommitBatchRes{res}, xerrors.Errorf("pushing message to mpool: %w", err)