Skip to content

Commit a82f71e

Browse files
committed
Add up the total gas limit required by the ops
1 parent f36565a commit a82f71e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

bundler/bundler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def eth_getOperationsGasValues(request) -> Result:
7272
results = []
7373
for op in operationsDict:
7474
operation = dict(op)
75-
callGas = 10**5 # TODO : should be dynamic
75+
callGas = 250000 # TODO : should be dynamic
7676
verificationGas = 10**5 # TODO : should be dynamic
7777
preVerificationGas = calcPreVerificationGas(operation)
7878
maxFeePerGas = w3.toWei(gasFees["medium"]["suggestedMaxFeePerGas"], 'gwei')
@@ -169,11 +169,16 @@ def eth_sendUserOperation(request) -> Result:
169169

170170
bundleDict = serialzer.data
171171

172+
opsGas = 0
173+
for op in bundleDict:
174+
opsGas += op["callGas"] + op["verificationGas"] + op["preVerificationGas"]
175+
172176
transactionTemplate = entryPoint.functions.handleOps([dict(op) for op in bundleDict],
173177
address)
174178

175179
try:
176180
gasEstimation = transactionTemplate.estimate_gas()
181+
gasEstimation = max(opsGas, gasEstimation * 1.4)
177182
except Exception as inst:
178183
print('\033[91m' + "Bundle operation failed (Gas estimation reverted): " + str(inst) + '\033[39m')
179184
return Error(2, "failed-to-submit", data={"status": "failed-to-submit", "txHash": None})
@@ -184,7 +189,7 @@ def eth_sendUserOperation(request) -> Result:
184189
"chainId": 5,
185190
"from": env('bundler_pub'),
186191
"nonce": w3.eth.get_transaction_count(env('bundler_pub')),
187-
'gas': math.ceil(gasEstimation * 1.4),
192+
'gas': math.ceil(gasEstimation),
188193
}
189194

190195
if env('isGanache') == "True": #as ganache evm doesn't support maxFeePerGas & maxPriorityFeePerGas

0 commit comments

Comments
 (0)