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

hack: don't load prior messages when estimating gas #10548

Closed
wants to merge 1 commit into from
Closed
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
48 changes: 25 additions & 23 deletions node/impl/full/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,26 @@ func gasEstimateCallWithGas(
currTs *types.TipSet,
) (*api.InvocResult, []types.ChainMsg, *types.TipSet, error) {
msg := *msgIn
fromA, err := smgr.ResolveToDeterministicAddress(ctx, msgIn.From, currTs)
if err != nil {
return nil, []types.ChainMsg{}, nil, xerrors.Errorf("getting key address: %w", err)
}

pending, ts := mpool.PendingFor(ctx, fromA)
priorMsgs := make([]types.ChainMsg, 0, len(pending))
for _, m := range pending {
if m.Message.Nonce == msg.Nonce {
break
}
priorMsgs = append(priorMsgs, m)
}
//fromA, err := smgr.ResolveToDeterministicAddress(ctx, msgIn.From, currTs)
//if err != nil {
// return nil, []types.ChainMsg{}, nil, xerrors.Errorf("getting key address: %w", err)
//}

//pending, ts := mpool.PendingFor(ctx, fromA)
//priorMsgs := make([]types.ChainMsg, 0, len(pending))
//for _, m := range pending {
// if m.Message.Nonce == msg.Nonce {
// break
// }
// priorMsgs = append(priorMsgs, m)
//}

// Try calling until we find a height with no migration.
ts := currTs
var res *api.InvocResult
var err error
for {
res, err = smgr.CallWithGas(ctx, &msg, priorMsgs, ts)
res, err = smgr.CallWithGas(ctx, &msg, nil, ts)
if err != stmgr.ErrExpensiveFork {
break
}
Expand All @@ -292,7 +294,7 @@ func gasEstimateCallWithGas(
return nil, []types.ChainMsg{}, nil, xerrors.Errorf("CallWithGas failed: %w", err)
}

return res, priorMsgs, ts, nil
return res, nil, ts, nil
}

func gasEstimateGasLimit(
Expand Down Expand Up @@ -375,14 +377,14 @@ func gasEstimateGasLimit(
// Special case for PaymentChannel collect, which is deleting actor
// We ignore errors in this special case since they CAN occur,
// and we just want to detect existing payment channel actors
st, err := smgr.ParentState(ts)
if err == nil {
act, err := st.GetActor(msg.To)
if err == nil && lbuiltin.IsPaymentChannelActor(act.Code) && msgIn.Method == builtin.MethodsPaych.Collect {
// add the refunded gas for DestroyActor back into the gas used
ret += 76e3
}
}
//st, err := smgr.ParentState(ts)
//if err == nil {
// act, err := st.GetActor(msg.To)
// if err == nil && lbuiltin.IsPaymentChannelActor(act.Code) && msgIn.Method == builtin.MethodsPaych.Collect {
// // add the refunded gas for DestroyActor back into the gas used
// ret += 76e3
// }
//}

return ret, nil
}
Expand Down