Monday, March 21, 2016

Lost in the gas

Back to transaction topic. It's possible make a transaction atomic using check / rollback mechanism. It's not very convenient and still provide a lot freedom for mistakes and at the end of the day with funds that did not manage to arrive at destination account. But another question what happened with gas when we called rollback?

if(!regaMain.send(_amount))
throw;

We lost it! The whole gas limit! So, if a client was trying to send money to our smart contract and smart contract for any reason call rollback he/her will ended with less money on account. Not very nice marketing feature of the service...

Here is an example, when the second transaction in the block is failed to execute and all transaction was reversed minus 5,000,000 * 20 gWei - very good motivation do not call throw;





No comments:

Post a Comment