Giter VIP home page Giter VIP logo

Comments (6)

riusricardo avatar riusricardo commented on September 14, 2024

It is correct but there is another thing to mention. Freeing space in smart contracts storage (delete) gives you extra gas to run in your transaction, this is useful for gas free transactions. As you said, I agree with the smart contract execution which can change the execution flow.
If a transaction reverts, also the delete will be reverted.

from burner-wallet.

mohoff avatar mohoff commented on September 14, 2024

Not sure how the extra gas you're mentioning adds to OP. Deleting is fine when you use destination.transfer() which will revert on failure. When it doesn't revert, delete frees some gas, yup.

But I'm curious, maybe I didn't understand your comment?

from burner-wallet.

riusricardo avatar riusricardo commented on September 14, 2024

I'll talk about 3 different cases:

  1. Send value to EOA - Probably this is the desired case for burner wallets. If a transaction gets to the delete instruction, it will get gas to run the call and send the value. It will be extremely hard (not impossible) to fail on sending the value with this extra boost.
  2. Send value/tx to a contract (Honest smart contract that reverts) - In this case all the transaction states will be reverted, including the delete. However if it gets out of gas on the external contract, the fund will be deleted without revert.
  3. Send value/tx to a contract (Bad smart contract actor) - Calling an external contract can change the execution flow by trying reentrancy attacks or calling functions in the original contract that can alter the storage state.

As you said, destination.transfer() will revert in case of failure. Depending on the design, it could be or not the desired effect. destination.send() has the same gas limitation as transfer but it doesn't reverts. It only returns a boolean status.

from burner-wallet.

mohoff avatar mohoff commented on September 14, 2024

Thanks for explaining!

  1. Do you have some numbers? How much gas is freed vs gas cost of simply sending ETH (2300gas?)
  2. According to this answer, you are not correct here. If an honest smart contract reverts, the tx will succeed.
  3. Agreed

from burner-wallet.

riusricardo avatar riusricardo commented on September 14, 2024
  1. From Ethereum Yellow Paper p.25,7,8
    15000 Refund given (added into refund counter) when the storage value is set to zero from
    non-zero.
    24000 Refund given (added into refund counter) for self-destructing an account.
    Even with this numbers it is difficult to estimate. I added some measurements in the audit tests but they are not very consistent in every run.
    If you find a better way to measure it, please let me know.

  2. You are right. External calls return a status value. It becomes an independent call which can revert without affecting the original call.
    To revert the original transaction, some more checks should have been needed:
    require(destination.call.value(value).gas(gasleft())())

from burner-wallet.

austintgriffith avatar austintgriffith commented on September 14, 2024

I'll get this changed in the contract. Thanks guys!

from burner-wallet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.