From e35aec78700f529ddf0c9c6764b77927a0cc0165 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 18 Jun 2025 14:18:56 +0200 Subject: [PATCH] chore: increase gas limits (#1272) --- codex/contracts/market.nim | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/codex/contracts/market.nim b/codex/contracts/market.nim index 52800b7e..f676012b 100644 --- a/codex/contracts/market.nim +++ b/codex/contracts/market.nim @@ -279,9 +279,10 @@ method fillSlot( # happen to be the last one to fill a slot in this request trace "estimating gas for fillSlot" let gas = await market.contract.estimateGas.fillSlot(requestId, slotIndex, proof) - let overrides = TransactionOverrides(gasLimit: some (gas * 110) div 100) + let gasLimit = (gas * 110) div 100 + let overrides = TransactionOverrides(gasLimit: some gasLimit) - trace "calling fillSlot on contract" + trace "calling fillSlot on contract", estimatedGas = gas, gasLimit = gasLimit discard await market.contract .fillSlot(requestId, slotIndex, proof, overrides) .confirm(1) @@ -303,12 +304,15 @@ method freeSlot*( # the SP's address as the collateral recipient let collateralRecipient = await market.getSigner() - # Add 10% to gas estimate to deal with different evm code flow when we + # Add 200% to gas estimate to deal with different evm code flow when we # happen to be the one to make the request fail let gas = await market.contract.estimateGas.freeSlot( slotId, rewardRecipient, collateralRecipient ) - let overrides = TransactionOverrides(gasLimit: some (gas * 110) div 100) + let gasLimit = gas * 3 + let overrides = TransactionOverrides(gasLimit: some gasLimit) + + trace "calling freeSlot on contract", estimatedGas = gas, gasLimit = gasLimit freeSlot = market.contract.freeSlot( slotId, @@ -320,10 +324,13 @@ method freeSlot*( # Otherwise, use the SP's address as both the reward and collateral # recipient (the contract will use msg.sender for both) - # Add 10% to gas estimate to deal with different evm code flow when we + # Add 200% to gas estimate to deal with different evm code flow when we # happen to be the one to make the request fail let gas = await market.contract.estimateGas.freeSlot(slotId) - let overrides = TransactionOverrides(gasLimit: some (gas * 110) div 100) + let gasLimit = gas * 3 + let overrides = TransactionOverrides(gasLimit: some (gasLimit)) + + trace "calling freeSlot on contract", estimatedGas = gas, gasLimit = gasLimit freeSlot = market.contract.freeSlot(slotId, overrides) @@ -377,10 +384,14 @@ method markProofAsMissing*( market: OnChainMarket, id: SlotId, period: Period ) {.async: (raises: [CancelledError, MarketError]).} = convertEthersError("Failed to mark proof as missing"): - # Add 10% to gas estimate to deal with different evm code flow when we + # Add 50% to gas estimate to deal with different evm code flow when we # happen to be the one to make the request fail let gas = await market.contract.estimateGas.markProofAsMissing(id, period) - let overrides = TransactionOverrides(gasLimit: some (gas * 110) div 100) + let gasLimit = (gas * 150) div 100 + let overrides = TransactionOverrides(gasLimit: some gasLimit) + + trace "calling markProofAsMissing on contract", + estimatedGas = gas, gasLimit = gasLimit discard await market.contract.markProofAsMissing(id, period, overrides).confirm(1) @@ -400,10 +411,13 @@ method reserveSlot*( ) {.async: (raises: [CancelledError, MarketError]).} = convertEthersError("Failed to reserve slot"): try: - # Add 10% to gas estimate to deal with different evm code flow when we + # Add 25% to gas estimate to deal with different evm code flow when we # happen to be the last one that is allowed to reserve the slot let gas = await market.contract.estimateGas.reserveSlot(requestId, slotIndex) - let overrides = TransactionOverrides(gasLimit: some (gas * 110) div 100) + let gasLimit = (gas * 125) div 100 + let overrides = TransactionOverrides(gasLimit: some gasLimit) + + trace "calling reserveSlot on contract", estimatedGas = gas, gasLimit = gasLimit discard await market.contract.reserveSlot(requestId, slotIndex, overrides).confirm(1)