Sword-Smith / Sword

Sword — A financial derivative language for the blockchain
MIT License
29 stars 2 forks source link

Do not make external calls to ERC20 transfer with amount = 0 #32

Closed Sword-Smith closed 3 years ago

Sword-Smith commented 3 years ago

in EvmCompiler.hs/executeTransferCallsHH we call transfer on the settlement asset even though either the payout value is zero or the balance in this token is zero. We should probably jump to the end of the codeblock if either is the case.

BUT! That JUMPI instruction MUST be placed after the evaluated TC value has been stored in storage. Otherwise we prevent PT0 from getting their payouts in case on zero-valued TransferCalls.

Sword-Smith commented 3 years ago

Closed with fe313c270e0be0ee4716beae9ed3f17097e95684 and 25b59f7bea32de9ae3252ceaa1515eddb6e39d50.

Tests to verify that we do not skip evaluation of TC value in these cases are included in the geth_tools repo in the commits: 3dbdb189c343d3fdf7b253692c2d5af81832c3b5, 264496d467b705f94e73be69609db26729a7494c, 1369abec6725051c723a15c02c6130c721a9c5e0.