GithubHelp home page GithubHelp logo

Comments (3)

ehildenb avatar ehildenb commented on July 20, 2024 1

I think this does fall into the same category of things I'm trying to clean up, so I will pay special attention to this issue.

from evm-semantics.

daejunpark avatar daejunpark commented on July 20, 2024

Another proposal: factor out common part of #finishTx and #return.

A function is called either from a top-level transaction directly or from another function. The former is started by startTx followed by loadTx, and the latter is by CALL. But both will eventually reach a uniform entry point #call.

However, there is no uniform exit point, as the former is finalized by #finishTx and the latter is by #return, while both do the common task of pop/drop of {callStack,worldState,subState}.

This absence of the uniform exit point makes it hard to write a uniform spec of a function that can be used for both contexts. We'd like to specify like <k> #call => ??? </k>, but currently no ??? is available.

Below is the current definition of #finishTx and #return:

    syntax EthereumCommand ::= "#finishTx"
 // --------------------------------------
    rule <k> #exception ~> #finishTx => #popCallStack ~> #popWorldState ~> #popSubstate ... </k>
    rule <k> #revert    ~> #finishTx => #popCallStack ~> #popWorldState ~> #popSubstate ~> #refund GAVAIL ... </k> <gas> GAVAIL </gas>
         
    rule <k> #end ~> #finishTx => #mkCodeDeposit ACCT ... </k>
         <id> ACCT </id>
         <txPending> ListItem(TXID:Int) ... </txPending>
         <message>
           <msgID> TXID     </msgID>
           <to>    .Account </to>
           ...
         </message>

    rule <k> #end ~> #finishTx => #popCallStack ~> #dropWorldState ~> #dropSubstate ~> #refund GAVAIL ... </k>
         <id> ACCT </id>
         <gas> GAVAIL </gas>
         <txPending> ListItem(TXID:Int) ... </txPending>
         <message>
           <msgID> TXID </msgID>
           <to>    TT   </to>
           ...
         </message>
      requires TT =/=K .Account
    syntax KItem ::= "#return" Int Int
 // ----------------------------------                                                   
    rule <k> #exception ~> #return _ _
          => #popCallStack ~> #popWorldState ~> #popSubstate ~> 0 ~> #push
         ... 
         </k>
         <output> _ => .WordStack </output>
         
    rule <k> #revert ~> #return RETSTART RETWIDTH
          => #popCallStack ~> #popWorldState ~> #popSubstate
          ~> 0 ~> #push ~> #refund GAVAIL ~> #setLocalMem RETSTART RETWIDTH OUT
         ... 
         </k>
         <output> OUT </output>
         <gas> GAVAIL </gas>
         
    rule <mode> EXECMODE </mode>
         <k> #end ~> #return RETSTART RETWIDTH
          => #popCallStack
          ~> #if EXECMODE ==K VMTESTS #then #popWorldState #else #dropWorldState #fi
          ~> #dropSubstate
          ~> 1 ~> #push ~> #refund GAVAIL ~> #setLocalMem RETSTART RETWIDTH OUT
         ... 
         </k>
         <output> OUT </output>
         <gas> GAVAIL </gas>

from evm-semantics.

ehildenb avatar ehildenb commented on July 20, 2024

Several of these cleanups have made their way in, we'll need new issues for more specific changes.

from evm-semantics.

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.