Uniswap / v1-contracts

🐍Uniswap V1 smart contracts
GNU General Public License v3.0
493 stars 317 forks source link

What will happen in case of REVERT inside DELEGATE_CALL? #39

Open k06a opened 4 years ago

k06a commented 4 years ago

I see a lot of BAD JUMP DESTINATION transactions here: https://etherscan.io/address/0x3958b4ec427f8fa24eb60f42821760e88d485f7f

SNX token calls tokenFallback on Uniswap contract in the middle of exchange and it seems Uniswap proxy handles this problem in a wrong way.

Proxy code is:

CALLDATASIZE
PUSH1 0x00
PUSH1 0x00
CALLDATACOPY
PUSH2 0x1000
PUSH1 0x00
CALLDATASIZE
PUSH1 0x00
PUSH20 0x2157a7894439191e520825fe9399ab8655e0f708
GAS
DELEGATE_CALL
ISZERO
PC
JUMPI
PUSH2 0x1000
PUSH1 0x00
RETURN

What does the latest part after DELEGATE_CALL means can anyone describe what should happen after DELEGATE_CALL reverts internally?

It seems Uniswap exchange called by another smart contract will eat all of its gas.

haydenadams commented 4 years ago

Yeah that comes from a vyper bug that wasn't discovered until after Uniswap launch

https://github.com/ethereum/vyper/issues/1091

k06a commented 4 years ago

So now we have an issue with Uniswap contract eating all the gas our smart contract provided.

haydenadams commented 4 years ago

@k06a on transaction fail, yes

k06a commented 4 years ago

@haydenadams found a reason and solution to 900K gas estimation to be dramatically decreased for SNX. Think could be delivered with upcoming token upgrade.