fix(gateway): replace transfer() with call() in withdrawFees#2238
fix(gateway): replace transfer() with call() in withdrawFees#2238shlee-lab wants to merge 1 commit intokleros:devfrom
Conversation
Using .transfer() only forwards 2300 gas, which can cause failures
when the relayer is a smart contract wallet (e.g., Gnosis Safe).
Replace with .call{value:}() to forward all available gas.
|
| Name | Link |
|---|---|
| 🔨 Latest commit | b2faa6a |
👷 Deploy request for kleros-v2-testnet-devtools pending review.Visit the deploys page to approve it
|
👷 Deploy request for kleros-v2-testnet pending review.Visit the deploys page to approve it
|
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @shlee-lab thanks for the contribution. For ETH transfers we have been using another pattern which is to rely on the SafeSend.sol library. The gateways are lagging a bit behind and need to start using SafeSend too. |
|
@jaybuidl Thanks for the guidance! I'll update this PR to use the SafeSend.sol library instead of raw .call(). One questio, does the ForeignGateway already have a WETH address stored, or should I add a new state variable / initializer parameter for it? |
Summary
Replace
.transfer()with.call{value:}()inForeignGateway.withdrawFees()Problem
.transfer()only forwards 2300 gas. If the relayer is a smart contract wallet (e.g., Gnosis Safe, automated relayer service), the fee withdrawal will fail.Solution
Use
.call{value:}()which forwards all available gas.Changes
contracts/src/gateway/ForeignGateway.sol(3 lines)PR-Codex overview
This PR focuses on enhancing the
ForeignGatewaycontract by improving the payment transfer mechanism when resolving disputes, ensuring it handles failures more gracefully.Detailed summary
callmethod for transferringamounttodispute.relayer.TransferFailed()error.TransferFailed()for handling transfer failures.Summary by CodeRabbit