Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 927f3a7

Browse files
authored
Fix preVerificationGas calculation (#116)
1 parent 82df661 commit 927f3a7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/gas/overhead.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Overhead struct {
2525
// CalcPreVerificationGas returns an expected gas cost for processing a UserOperation from a batch.
2626
func (ov *Overhead) CalcPreVerificationGas(op *userop.UserOperation) *big.Int {
2727
packed := op.Pack()
28+
lengthInWord := float64(len(packed)+31) / 32
2829
callDataCost := float64(0)
2930

3031
for _, b := range packed {
@@ -35,9 +36,7 @@ func (ov *Overhead) CalcPreVerificationGas(op *userop.UserOperation) *big.Int {
3536
}
3637
}
3738

38-
pvg := callDataCost + (ov.fixed / ov.minBundleSize) + ov.perUserOp + ov.perUserOpWord*float64(
39-
(len(packed)),
40-
)
39+
pvg := callDataCost + (ov.fixed / ov.minBundleSize) + ov.perUserOp + (ov.perUserOpWord * lengthInWord)
4140
return big.NewInt(int64(math.Round(pvg)))
4241
}
4342

0 commit comments

Comments
 (0)