Estimate gas across the upgrade with per message multipliers

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2022-05-09 17:00:00 +02:00
parent 8282484f65
commit 5fb69281d8
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -297,6 +297,47 @@ func gasEstimateGasLimit(
ret := res.MsgRct.GasUsed
transitionalMulti := 1.0
// Overestimate gas around the upgrade
if ts.Height() <= build.UpgradeFVM1Height && (build.UpgradeFVM1Height-ts.Height() <= 20) {
transitionalMulti = 2.0
func() {
st, err := smgr.ParentState(ts)
if err != nil {
return
}
act, err := st.GetActor(msg.To)
if err != nil {
return
}
if builtin.IsStorageMinerActor(act.Code) {
switch msgIn.Method {
case 5:
transitionalMulti = 3.954
case 6:
transitionalMulti = 4.095
case 7:
// skip, stay at 2.0
//transitionalMulti = 1.289
case 11:
transitionalMulti = 17.8758
case 16:
transitionalMulti = 2.1704
case 25:
transitionalMulti = 3.1177
case 26:
transitionalMulti = 2.3322
default:
}
}
// skip storage market, 80th percentie for everything ~1.9, leave it at 2.0
}()
}
ret = (ret * int64(transitionalMulti*1024)) >> 10
// 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
@ -309,11 +350,6 @@ func gasEstimateGasLimit(
}
}
// Overestimate gas used around the
if ts.Height() <= build.UpgradeFVM1Height && (build.UpgradeFVM1Height-ts.Height() <= 5) {
ret *= 2
}
return ret, nil
}