From fb9334c3391dc42972ebf8c3aeac427dc9e8ed5b Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:17:05 +0800 Subject: [PATCH] feat(protocol): increase GAS_OVERHEAD value based on testnet data (#16769) --- packages/protocol/contracts/bridge/Bridge.sol | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 7c9d939089..1e266f7348 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -43,7 +43,7 @@ contract Bridge is EssentialContract, IBridge { /// @dev The gas overhead for both receiving and invoking a message, as well as the proof /// calldata cost. /// This value should be fine-tuned with production data. - uint32 public constant GAS_OVERHEAD = 60_000; + uint32 public constant GAS_OVERHEAD = 120_000; /// @dev The amount of gas not to charge fee per cache operation. uint256 private constant _GAS_REFUND_PER_CACHE_OPERATION = 20_000; @@ -262,11 +262,9 @@ contract Bridge is EssentialContract, IBridge { if (msg.sender != _message.destOwner && _message.gasLimit != 0) { unchecked { uint256 refund = numCacheOps * _GAS_REFUND_PER_CACHE_OPERATION; - stats.gasUsedInFeeCalc = stats.start - gasleft(); - - uint256 gasCharged = - (GAS_OVERHEAD + stats.gasUsedInFeeCalc).max(refund) - refund; + stats.gasUsedInFeeCalc = GAS_OVERHEAD + stats.start - gasleft(); + uint256 gasCharged = stats.gasUsedInFeeCalc.max(refund) - refund; uint256 maxFee = gasCharged * _message.fee / _message.gasLimit; uint256 baseFee = gasCharged * block.basefee; uint256 fee =