-
Notifications
You must be signed in to change notification settings - Fork 3
ETH transfers fail due to incorrect receiver dust balance handling #141
Copy link
Copy link
Closed
Description
Issue: Bug in eth-decimals - ETH transfers fail due to incorrect receiver dust balance handling
Context
During the migration of Uniswap V2 periphery, ETH transfer operations were initially failing due to precision conversion issues between ETH and DOT. Values smaller than 1,000,000 couldn't be converted to native balance, resulting in DecimalPrecisionLoss errors. This issue was addressed in paritytech/polkadot-sdk#9101.
Problem Description
After applying the fix from #9101, ETH transfer operations still fail during v2-periphery testing.
Steps to Reproduce
- Clone the repository
git clone https://github.com/papermoonio/v2-periphery-polkadot
cd v2-periphery-polkadot
pnpm install- Add
.envfile
Create a.envfile in the project root:
LOCAL_PRIV_KEY=0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
AH_PRIV_KEY=0xxx
- Run the test
USE_POLKAVM=true npx hardhat test ./test/UniswapV2Router01.spec.ts --network local --grep 'swapExactTokensForETH'Error Messages
Hardhat reports two types of errors:
- Revert error:
1) UniswapV2Router{01,02}
UniswapV2Router02
swapExactTokensForETH
happy path123:
Error: execution reverted: "TransferHelper::safeTransferETH: ETH transfer failed" (action="estimateGas", data="0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000345472616e7366657248656c7065723a3a736166655472616e736665724554483a20455448207472616e73666572206661696c6564000000000000000000000000", reason="TransferHelper::safeTransferETH: ETH transfer failed", transaction={ "data": "0x18cbafe50000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f24ff3a9cf04c71dbc94d0b566f7a27b94566cacffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c530e4cd4933357da902577e78cc7c65c5759e0c00000000000000000000000079d08b1fddcc8961bc252e77e28a8519243d3d28", "from": "0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac", "to": "0x7b21801C4B7219BDeb3494AC98e948abBD25b2e9" }, invocation=null, revert={ "args": [ "TransferHelper::safeTransferETH: ETH transfer failed" ], "name": "Error", "signature": "Error(string)" }, code=CALL_EXCEPTION, version=6.14.3)
- Panic error:
2) UniswapV2Router{01,02}
UniswapV2Router02
swapExactTokensForETH
amounts:
ProviderError: execution reverted: panic: assertion failed (0x01)
Investigation
Detailed investigation of the substrate node logs reveals a suspicious error (both hardhat errors stem from this underlying issue):
TRACE tokio-runtime-worker runtime::revive::strace: call(flags_and_callee: 34359935664, ref_time_limit: 18446744073709551615, proof_size_limit: 18446744073709551615, deposit_and_value: 18446159137818405824, input_data: 133232, output_data: 18446158996084753072) = Ok(TransferFailed) gas_consumed: Weight { ref_time: 22257362352, proof_size: 1049891 }
Root Cause
After reviewing the code in paritytech/polkadot-sdk#9101, I've identified a bug in the handling of the receiver's dust balance.
Impact
- All ETH transfer operations fail
- Uniswap V2 and other DeFi protocols cannot function properly
- Any contract relying on ETH transfers is affected
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels