Skip to content

Commit

Permalink
Estimate gas across the upgrade with per message multipliers
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Jakub Sztandera committed May 9, 2022
1 parent 8282484 commit 5fb6928
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions node/impl/full/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 5fb6928

Please sign in to comment.