Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0852fc

Browse files
committedFeb 27, 2025·
kevm-pyk/evm.md: optimize for non-underflow stack check
1 parent 87242ce commit c0852fc

File tree

1 file changed

+10
-1
lines changed
  • kevm-pyk/src/kevm_pyk/kproj/evm-semantics

1 file changed

+10
-1
lines changed
 

‎kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,16 @@ The `#next [_]` operator initiates execution by:
380380
syntax Bool ::= #stackUnderflow ( WordStack , OpCode ) [symbol(#stackUnderflow), function, total]
381381
| #stackOverflow ( WordStack , OpCode ) [symbol(#stackOverflow), function, total]
382382
// ------------------------------------------------------------------------------------------------
383-
rule #stackUnderflow(WS, OP:OpCode) => #sizeWordStack(WS) <Int #stackNeeded(OP)
383+
rule #stackUnderflow( _WS , _POP:PushOp ) => false
384+
rule #stackUnderflow( _WS , _IOP:InvalidOp ) => false
385+
rule #stackUnderflow( _WS , _NOP:NullStackOp ) => false
386+
rule #stackUnderflow( _W0 : _WS , _UOP:UnStackOp ) => false
387+
rule #stackUnderflow( _W0 : _W1 : _WS , BOP:BinStackOp ) => false requires notBool isLogOp(BOP)
388+
rule #stackUnderflow( _W0 : _W1 : _W2 : _WS , _TOP:TernStackOp ) => false
389+
rule #stackUnderflow( _W0 : _W1 : _W2 : _W3 : _WS , _QOP:QuadStackOp ) => false
390+
rule #stackUnderflow( _W0 : _W1 : _W2 : _W3 : _W4 : _W5 : _W6 : _WS , _CSOP:CallSixOp ) => false
391+
rule #stackUnderflow( _W0 : _W1 : _W2 : _W3 : _W4 : _W5 : _W6 : _W7 : _WS , COP:CallOp ) => false requires notBool isCallSixOp(COP)
392+
rule #stackUnderflow(WS, OP:OpCode) => #sizeWordStack(WS) <Int #stackNeeded(OP) [owise]
384393
385394
rule #stackOverflow(_WS, OP) => false requires #stackDelta(OP) <=Int 0
386395
rule #stackOverflow(WS, OP) => 1024 <Int #sizeWordStack(WS) +Int #stackDelta(OP) [owise]

0 commit comments

Comments
 (0)
Please sign in to comment.