Giter Site home page Giter Site logo

Comments (5)

deelawn avatar deelawn commented on June 21, 2024 2

I'm very skeptical that state should be reverted when an error is returned from a top level realm function; it seems inconsistent with go's behavior. For example, if I modify a value in go that exists in a scope outside of the function from which it is modified, I would expect that value to be persisted regardless of whether or not the function that modified it later returns an error. Returning an error usually means that the operation could not be fully completed as intended and any state modifications outside the scope of the function that returned the error will remain. Panicking means something went horribly wrong and we need to get rid of all state unless the panic is recovered. It seems like the current implementation most closely aligns with how the terms are used in go.

from gno.

ajnavarro avatar ajnavarro commented on June 21, 2024 2

I'm with @deelawn here for several reasons:

  • Consistency: rollback only when returning an error on top-level methods but not on the rest is not consistent. It might mislead users.
  • Unexpected: as @deelawn said, is not consistent with Go behavior.
  • Limiting choices: We already have a way to roll back the Realm state, that is, throwing a panic. I can see use cases where a Realm's dev wants to return an error without rollbacking the whole state, like when saving some metadata about who voted, or metrics about the amount of people that used the Realm, as examples.

from gno.

petar-dambovaliev avatar petar-dambovaliev commented on June 21, 2024 1

Errors are just values, they have no special semantics within the language.
Just like you can return an integer, you can return an error. We shouldn't rollback when people create integers, right?
Panic, on the other hand, is special and does what you suggested. This proposal is basically to make errors be treated as panics. I am against.

from gno.

leohhhn avatar leohhhn commented on June 21, 2024 1

Okay. got it. Documentation already states that panics revert state, but I will make sure to add mentions and examples of errors not reverting state, which might be what blockchain developers could expect. Thanks.

from gno.

zivkovicmilos avatar zivkovicmilos commented on June 21, 2024

Thank you for giving your thoughts @deelawn @ajnavarro @petar-dambovaliev

I think we can find good middle ground here -- don't introduce this top-level error logic, but make it clear in the documentation that panics are equivalent to reverts. @leohhhn, what do you think?

from gno.

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.