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

Commit 989aaa2

Browse files
authored
Add fixed overhead to callGasLimit estimate (#146)
1 parent de66978 commit 989aaa2

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pkg/gas/callgas.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ func CallGasEstimate(
4242
return 0, err
4343
}
4444

45+
ov := NewDefaultOverhead()
4546
tg := big.NewInt(0).Div(sim.Paid, op.MaxFeePerGas)
46-
cgl := big.NewInt(0).Sub(tg, sim.PreOpGas)
47-
call := NewDefaultOverhead().NonZeroValueCall()
48-
if cgl.Cmp(call) >= 1 {
47+
cgl := big.NewInt(0).Add(big.NewInt(0).Sub(tg, sim.PreOpGas), big.NewInt(int64(ov.fixed)))
48+
min := ov.NonZeroValueCall()
49+
if cgl.Cmp(min) >= 1 {
4950
return cgl.Uint64(), nil
5051
}
51-
return call.Uint64(), nil
52+
return min.Uint64(), nil
5253
}

pkg/gas/overhead.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (ov *Overhead) CalcPreVerificationGas(op *userop.UserOperation) *big.Int {
4444
// See https://github.com/wolflo/evm-opcodes/blob/main/gas.md#aa-1-call.
4545
func (ov *Overhead) NonZeroValueCall() *big.Int {
4646
return big.NewInt(
47-
int64(ov.warmStorageRead + ov.nonZeroValueCall + ov.callOpcode + ov.nonZeroValueStipend),
47+
int64(ov.fixed + ov.warmStorageRead + ov.nonZeroValueCall + ov.callOpcode + ov.nonZeroValueStipend),
4848
)
4949
}
5050

0 commit comments

Comments
 (0)