avoid estimating gas and explicitly calling blocks on fork tipsets
These tipsets can be slow.
This commit is contained in:
+12
-1
@@ -160,7 +160,18 @@ func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message,
|
||||
priorMsgs = append(priorMsgs, m)
|
||||
}
|
||||
|
||||
res, err := a.Stmgr.CallWithGas(ctx, &msg, priorMsgs, ts)
|
||||
// Try calling until we find a height with no migration.
|
||||
var res *api.InvocResult
|
||||
for {
|
||||
res, err = a.Stmgr.CallWithGas(ctx, &msg, priorMsgs, ts)
|
||||
if err != stmgr.ErrWouldFork {
|
||||
break
|
||||
}
|
||||
ts, err = a.Chain.GetTipSetFromKey(ts.Parents())
|
||||
if err != nil {
|
||||
return -1, xerrors.Errorf("getting parent tipset: %w", err)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return -1, xerrors.Errorf("CallWithGas failed: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user